Bug 1057211 - Use DrawTargetDual for component alpha layers when tiling so that we get correct PushGroupAndCopyBackground behaviour. r=nical
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 27 Aug 2014 10:18:55 +1200
changeset 201719 247755b96ab8513391ca537fbe82e24f68ac7167
parent 201718 e1d9104a958f4231ff96aaf3c128bce1e0869188
child 201720 c9e48790f6fa33dd04dfa1ce0009a5658dc2a636
push id48247
push usermwoodrow@mozilla.com
push dateTue, 26 Aug 2014 22:28:53 +0000
treeherdermozilla-inbound@c3474588bddd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1057211
milestone34.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 1057211 - Use DrawTargetDual for component alpha layers when tiling so that we get correct PushGroupAndCopyBackground behaviour. r=nical
gfx/layers/client/TiledContentClient.cpp
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -1117,32 +1117,31 @@ ClientTiledLayerBuffer::ValidateTile(Til
     if (backBuffer->HasInternalBuffer()) {
       // If our new buffer has an internal buffer, we don't want to keep another
       // TextureClient around unnecessarily, so discard the back-buffer.
       aTile.DiscardBackBuffer();
     }
 
     // prepare an array of Moz2D tiles that will be painted into in PostValidate
     gfx::Tile moz2DTile;
-    gfx::Tile moz2DTileOnWhite;
-    moz2DTile.mDrawTarget = backBuffer->BorrowDrawTarget();
+    RefPtr<DrawTarget> dt = backBuffer->BorrowDrawTarget();
+    RefPtr<DrawTarget> dtOnWhite;
     if (backBufferOnWhite) {
-      moz2DTileOnWhite.mDrawTarget = backBufferOnWhite->BorrowDrawTarget();
+      dtOnWhite = backBufferOnWhite->BorrowDrawTarget();
+      moz2DTile.mDrawTarget = Factory::CreateDualDrawTarget(dt, dtOnWhite);
+    } else {
+      moz2DTile.mDrawTarget = dt;
     }
-    moz2DTile.mTileOrigin = moz2DTileOnWhite.mTileOrigin = gfx::IntPoint(aTileOrigin.x, aTileOrigin.y);
-    if (!moz2DTile.mDrawTarget ||
-        (backBufferOnWhite && !moz2DTileOnWhite.mDrawTarget)) {
+    moz2DTile.mTileOrigin = gfx::IntPoint(aTileOrigin.x, aTileOrigin.y);
+    if (!dt || (backBufferOnWhite && !dtOnWhite)) {
       aTile.DiscardFrontBuffer();
       return aTile;
     }
 
     mMoz2DTiles.push_back(moz2DTile);
-    if (backBufferOnWhite) {
-      mMoz2DTiles.push_back(moz2DTileOnWhite);
-    }
 
     nsIntRegionRectIterator it(aDirtyRegion);
     for (const nsIntRect* dirtyRect = it.Next(); dirtyRect != nullptr; dirtyRect = it.Next()) {
       gfx::Rect drawRect(dirtyRect->x - aTileOrigin.x,
                          dirtyRect->y - aTileOrigin.y,
                          dirtyRect->width,
                          dirtyRect->height);
       drawRect.Scale(mResolution);
@@ -1151,20 +1150,20 @@ ClientTiledLayerBuffer::ValidateTile(Til
                             NS_roundf((dirtyRect->y - mSinglePaintBufferOffset.y) * mResolution),
                             drawRect.width,
                             drawRect.height);
       gfx::IntPoint copyTarget(NS_roundf(drawRect.x), NS_roundf(drawRect.y));
       // Mark the newly updated area as invalid in the front buffer
       aTile.mInvalidFront.Or(aTile.mInvalidFront, nsIntRect(copyTarget.x, copyTarget.y, copyRect.width, copyRect.height));
 
       if (mode == SurfaceMode::SURFACE_COMPONENT_ALPHA) {
-        moz2DTile.mDrawTarget->FillRect(drawRect, ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
-        moz2DTileOnWhite.mDrawTarget->FillRect(drawRect, ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
+        dt->FillRect(drawRect, ColorPattern(Color(0.0, 0.0, 0.0, 1.0)));
+        dtOnWhite->FillRect(drawRect, ColorPattern(Color(1.0, 1.0, 1.0, 1.0)));
       } else if (content == gfxContentType::COLOR_ALPHA) {
-        moz2DTile.mDrawTarget->ClearRect(drawRect);
+        dt->ClearRect(drawRect);
       }
     }
 
     return aTile;
   } else {
     MOZ_ASSERT(!backBufferOnWhite, "Component alpha only supported with TiledDrawTarget");
   }