Bug 1256547: When the DWM is disabled don't force presentation. r=milan
MozReview-Commit-ID: 4fd8QUWq0f1
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -2588,22 +2588,30 @@ gfxWindowsPlatform::CreateD3D11DecoderDe
RefPtr<ID3D10Multithread> multi;
device->QueryInterface(__uuidof(ID3D10Multithread), getter_AddRefs(multi));
multi->SetMultithreadProtected(TRUE);
return device.forget();
}
-static bool
-DwmCompositionEnabled()
+bool
+gfxWindowsPlatform::DwmCompositionEnabled()
{
+ if (!IsVistaOrLater()) {
+ return false;
+ }
+
MOZ_ASSERT(WinUtils::dwmIsCompositionEnabledPtr);
BOOL dwmEnabled = false;
- WinUtils::dwmIsCompositionEnabledPtr(&dwmEnabled);
+
+ if (FAILED(WinUtils::dwmIsCompositionEnabledPtr(&dwmEnabled))) {
+ return false;
+ }
+
return dwmEnabled;
}
class D3DVsyncSource final : public VsyncSource
{
public:
class D3DVsyncDisplay final : public VsyncSource::Display
@@ -2619,17 +2627,17 @@ public:
const double rate = 1000 / 60.0;
mSoftwareVsyncRate = TimeDuration::FromMilliseconds(rate);
MOZ_RELEASE_ASSERT(mVsyncThread->Start(), "Could not start Windows vsync thread");
SetVsyncRate();
}
void SetVsyncRate()
{
- if (!DwmCompositionEnabled()) {
+ if (!gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) {
mVsyncRate = TimeDuration::FromMilliseconds(1000.0 / 60.0);
return;
}
DWM_TIMING_INFO vblankTime;
// Make sure to init the cbSize, otherwise GetCompositionTiming will fail
vblankTime.cbSize = sizeof(DWM_TIMING_INFO);
HRESULT hr = WinUtils::dwmGetCompositionTimingInfoPtr(0, &vblankTime);
@@ -2775,17 +2783,17 @@ public:
// must be <= Now() and cannot be in the future.
MOZ_ASSERT(vsync <= TimeStamp::Now());
Display::NotifyVsync(vsync);
// DwmComposition can be dynamically enabled/disabled
// so we have to check every time that it's available.
// When it is unavailable, we fallback to software but will try
// to get back to dwm rendering once it's re-enabled
- if (!DwmCompositionEnabled()) {
+ if (!gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) {
ScheduleSoftwareVsync(vsync);
return;
}
// Use a combination of DwmFlush + DwmGetCompositionTimingInfoPtr
// Using WaitForVBlank, the whole system dies :/
HRESULT hr = WinUtils::dwmFlushProcPtr();
if (!SUCCEEDED(hr)) {
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -216,16 +216,18 @@ public:
ID3D11Device *GetD3D11ContentDevice();
// Create a D3D11 device to be used for DXVA decoding.
already_AddRefed<ID3D11Device> CreateD3D11DecoderDevice();
bool CreateD3D11DecoderDeviceHelper(
IDXGIAdapter1* aAdapter, RefPtr<ID3D11Device>& aDevice,
HRESULT& aResOut);
+ bool DwmCompositionEnabled();
+
mozilla::layers::ReadbackManagerD3D11* GetReadbackManager();
static bool IsOptimus();
bool IsWARP() { return mIsWARP; }
// Returns whether the compositor's D3D11 device supports texture sharing.
bool CompositorD3D11TextureSharingWorks() const {
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -522,17 +522,17 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
}
}
}
break;
case LayersBackend::LAYERS_CLIENT:
{
result = listener->PaintWindow(
this, LayoutDeviceIntRegion::FromUnknownRegion(region));
- if (!gfxEnv::DisableForcePresent()) {
+ if (!gfxEnv::DisableForcePresent() && gfxWindowsPlatform::GetPlatform()->DwmCompositionEnabled()) {
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(this, &nsWindow::ForcePresent);
NS_DispatchToMainThread(event);
}
}
break;
default:
NS_ERROR("Unknown layers backend used!");