Bug 909607. Check if we are minimised before compositing. r=Bas
authorNicholas Cameron <ncameron@mozilla.com>
Mon, 09 Sep 2013 09:07:01 +1200
changeset 159008 e8be00af7e2cdb7956bb9ab4af49b692b0894e13
parent 159007 08144be95a5c45e9290a5b30077abb5abf7715e7
child 159009 feb1791602731b52a9c72bdf0cc8442656309a44
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs909607
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 909607. Check if we are minimised before compositing. r=Bas
gfx/layers/d3d11/CompositorD3D11.cpp
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -55,18 +55,19 @@ struct DeviceAttachmentsD3D11
   RefPtr<ID3D11SamplerState> mLinearSamplerState;
   RefPtr<ID3D11SamplerState> mPointSamplerState;
   RefPtr<ID3D11BlendState> mPremulBlendState;
   RefPtr<ID3D11BlendState> mNonPremulBlendState;
   RefPtr<ID3D11BlendState> mComponentBlendState;
 };
 
 CompositorD3D11::CompositorD3D11(nsIWidget* aWidget)
-  : mWidget(aWidget)
-  , mAttachments(nullptr)
+  : mAttachments(nullptr)
+  , mWidget(aWidget)
+  , mHwnd(nullptr)
 {
   sBackend = LAYERS_D3D11;
 }
 
 CompositorD3D11::~CompositorD3D11()
 {
   if (mDevice) {
     int referenceCount = 0;
@@ -103,16 +104,18 @@ CompositorD3D11::Initialize()
   }
 
   mDevice->GetImmediateContext(byRef(mContext));
 
   if (!mContext) {
     return false;
   }
 
+  mHwnd = (HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW);
+
   memset(&mVSConstants, 0, sizeof(VertexShaderConstants));
 
   int referenceCount = 0;
   UINT size = sizeof(referenceCount);
   // If this isn't there yet it'll fail, count will remain 0, which is correct.
   mDevice->GetPrivateData(sLayerManagerCount, &size, &referenceCount);
   referenceCount++;
   mDevice->SetPrivateData(sLayerManagerCount,
@@ -297,17 +300,17 @@ CompositorD3D11::Initialize()
     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;
     swapDesc.SampleDesc.Quality = 0;
     swapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
     swapDesc.BufferCount = 1;
-    swapDesc.OutputWindow = (HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW);
+    swapDesc.OutputWindow = mHwnd;
     swapDesc.Windowed = TRUE;
     // We don't really need this flag, however it seems on some NVidia hardware
     // smaller area windows do not present properly without this flag. This flag
     // should have no negative consequences by itself. See bug 613790. This flag
     // is broken on optimus devices. As a temporary solution we don't set it
     // there, the only way of reliably detecting we're on optimus is looking for
     // the DLL. See Bug 623807.
     if (gfxWindowsPlatform::IsOptimus()) {
@@ -619,16 +622,25 @@ CompositorD3D11::DrawQuad(const gfx::Rec
 
 void
 CompositorD3D11::BeginFrame(const Rect* aClipRectIn,
                             const gfxMatrix& aTransform,
                             const Rect& aRenderBounds,
                             Rect* aClipRectOut,
                             Rect* aRenderBoundsOut)
 {
+  // Don't composite if we are minimised. Other than for the sake of efficency,
+  // this is important because resizing our buffers when mimised will fail and
+  // cause a crash when we're restored.
+  NS_ASSERTION(mHwnd, "Couldn't find an HWND when initialising?");
+  if (::IsIconic(mHwnd)) {
+    *aRenderBoundsOut = Rect();
+    return;
+  }
+
   UpdateRenderTarget();
 
   // Failed to create a render target.
   if (!mDefaultRT ||
       mSize.width == 0 || mSize.height == 0) {
     *aRenderBoundsOut = Rect();
     return;
   }