Bug 1352547: Do not use IsWindows10OrGreater() on older SDKs. r=mattwoodrow
MozReview-Commit-ID: C0uOAKy0bOr
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -27,16 +27,17 @@
#include "mozilla/EnumeratedArray.h"
#include "mozilla/Telemetry.h"
#include "BlendShaderConstants.h"
#include "D3D11ShareHandleImage.h"
#include <VersionHelpers.h> // For IsWindows8OrGreater
+#include <winsdkver.h>
namespace mozilla {
using namespace gfx;
namespace layers {
static bool CanUsePartialPresents(ID3D11Device* aDevice);
@@ -486,21 +487,24 @@ CompositorD3D11::Initialize(nsCString* c
{
RefPtr<IDXGIFactory> dxgiFactory;
dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory.StartAssignment()));
RefPtr<IDXGIFactory2> dxgiFactory2;
hr = dxgiFactory->QueryInterface((IDXGIFactory2**)getter_AddRefs(dxgiFactory2));
+#if (_WIN32_WINDOWS_MAXVER >= 0x0A00)
if (gfxPrefs::Direct3D11UseDoubleBuffering() && SUCCEEDED(hr) && dxgiFactory2 && IsWindows10OrGreater()) {
// DXGI_SCALING_NONE is not available on Windows 7 with Platform Update.
// This looks awful for things like the awesome bar and browser window resizing
// so we don't use a flip buffer chain here. When using EFFECT_SEQUENTIAL
// it looks like windows doesn't stretch the surface when resizing.
+ // We chose not to run this on Windows 10 because it appears sometimes this breaks
+ // our ability to test ASAP compositing.
RefPtr<IDXGISwapChain1> swapChain;
DXGI_SWAP_CHAIN_DESC1 swapDesc;
::ZeroMemory(&swapDesc, sizeof(swapDesc));
swapDesc.Width = 0;
swapDesc.Height = 0;
swapDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapDesc.SampleDesc.Count = 1;
@@ -522,17 +526,19 @@ CompositorD3D11::Initialize(nsCString* c
*out_failureReason = "FEATURE_FAILURE_D3D11_SWAP_CHAIN";
return false;
}
DXGI_RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f };
swapChain->SetBackgroundColor(&color);
mSwapChain = swapChain;
- } else {
+ } else
+#endif
+ {
DXGI_SWAP_CHAIN_DESC swapDesc;
::ZeroMemory(&swapDesc, sizeof(swapDesc));
swapDesc.BufferDesc.Width = 0;
swapDesc.BufferDesc.Height = 0;
swapDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
swapDesc.BufferDesc.RefreshRate.Numerator = 60;
swapDesc.BufferDesc.RefreshRate.Denominator = 1;
swapDesc.SampleDesc.Count = 1;
@@ -818,16 +824,20 @@ CompositorD3D11::GetPSForEffect(Effect*
NS_WARNING("No shader to load");
return nullptr;
}
}
void
CompositorD3D11::ClearRect(const gfx::Rect& aRect)
{
+ if (aRect.IsEmpty()) {
+ return;
+ }
+
mContext->OMSetBlendState(mAttachments->mDisabledBlendState, sBlendFactor, 0xFFFFFFFF);
Matrix4x4 identity;
memcpy(&mVSConstants.layerTransform, &identity._11, 64);
mVSConstants.layerQuad = aRect;
mVSConstants.renderTargetOffset[0] = 0;
mVSConstants.renderTargetOffset[1] = 0;
@@ -849,18 +859,16 @@ CompositorD3D11::ClearRect(const gfx::Re
mPSConstants.layerColor[3] = 0;
if (!UpdateConstantBuffers()) {
NS_WARNING("Failed to update shader constant buffers");
return;
}
mContext->Draw(4, 0);
-
- mContext->OMSetBlendState(mAttachments->mPremulBlendState, sBlendFactor, 0xFFFFFFFF);
}
static inline bool
EffectHasPremultipliedAlpha(Effect* aEffect)
{
if (aEffect->mType == EffectTypes::RGB) {
return static_cast<TexturedEffect*>(aEffect)->mPremultiplied;
}
@@ -1353,18 +1361,22 @@ CompositorD3D11::BeginFrame(const nsIntR
}
mCurrentClip = mBackBufferInvalid.GetBounds();
mContext->RSSetState(mAttachments->mRasterizerState);
SetRenderTarget(mDefaultRT);
- // ClearRect will set the correct blend state for us.
- ClearRect(Rect(mCurrentClip.x, mCurrentClip.y, mCurrentClip.width, mCurrentClip.height));
+ IntRegion regionToClear(mCurrentClip);
+ regionToClear.Sub(regionToClear, aOpaqueRegion);
+
+ ClearRect(Rect(regionToClear.GetBounds()));
+
+ mContext->OMSetBlendState(mAttachments->mPremulBlendState, sBlendFactor, 0xFFFFFFFF);
if (mAttachments->mSyncTexture) {
RefPtr<IDXGIKeyedMutex> mutex;
mAttachments->mSyncTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
MOZ_ASSERT(mutex);
{
HRESULT hr;