Bug 937972 - Fix crashes for Windows Direct2D users that have Azure disabled. r=Bas, a=lsblakk
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 14 Nov 2013 13:58:04 +1300
changeset 167479 1c1fcdc50acc3964580262277a202e2cd9941cd4
parent 167478 0395ab4e357b27a5449843e4229d7994a7c7ed47
child 167480 8c087322d4497c8c91c0f25acddcc0a25b4f9b2c
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas, lsblakk
bugs937972
milestone27.0a2
Bug 937972 - Fix crashes for Windows Direct2D users that have Azure disabled. r=Bas, a=lsblakk
gfx/layers/d3d10/ThebesLayerD3D10.cpp
--- a/gfx/layers/d3d10/ThebesLayerD3D10.cpp
+++ b/gfx/layers/d3d10/ThebesLayerD3D10.cpp
@@ -409,29 +409,46 @@ ThebesLayerD3D10::DrawRegion(nsIntRegion
       // only the onBlack surface will really be used, so alpha information will
       // be incorrect.
       destinationSurface->SetAllowUseAsSource(false);
     }
   } else {
     destinationSurface = mD2DSurface;
   }
 
-  MOZ_ASSERT(mDrawTarget);
-  nsRefPtr<gfxContext> context = new gfxContext(mDrawTarget);
+  nsRefPtr<gfxContext> context;
+  if (mDrawTarget) {
+    context = new gfxContext(mDrawTarget);
+  } else {
+    context = new gfxContext(destinationSurface);
+  }
 
   context->Translate(gfxPoint(-visibleRect.x, -visibleRect.y));
-  if (aMode == SURFACE_SINGLE_CHANNEL_ALPHA) {
-    nsIntRegionRectIterator iter(aRegion);
-    const nsIntRect *iterRect;
-    while ((iterRect = iter.Next())) {
-      mDrawTarget->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
+
+  if (mD2DSurface) {
+    if (aMode == SURFACE_SINGLE_CHANNEL_ALPHA) {
+      context->Save();
+      gfxUtils::ClipToRegionSnapped(context, aRegion);
+      context->SetOperator(gfxContext::OPERATOR_CLEAR);
+      context->Paint();
+      context->Restore();
     }
-  }
 
-  mDrawTarget->SetPermitSubpixelAA(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
+    mD2DSurface->SetSubpixelAntialiasingEnabled(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
+  } else {
+    if (aMode == SURFACE_SINGLE_CHANNEL_ALPHA) {
+      nsIntRegionRectIterator iter(aRegion);
+      const nsIntRect *iterRect;
+      while ((iterRect = iter.Next())) {
+        mDrawTarget->ClearRect(Rect(iterRect->x, iterRect->y, iterRect->width, iterRect->height));
+      }
+    }
+
+    mDrawTarget->SetPermitSubpixelAA(!(mContentFlags & CONTENT_COMPONENT_ALPHA));
+  }
 
   LayerManagerD3D10::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
   cbInfo.Callback(this, context, aRegion, CLIP_DRAW, nsIntRegion(), cbInfo.CallbackData);
 }
 
 void
 ThebesLayerD3D10::CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode)
 {