Bug 983169 - Fix handling of tile resolution in TiledContentClient. r=bas, a=lsblakk
authorChris Lord <chrislord.net@gmail.com>
Thu, 27 Mar 2014 18:52:09 +0000
changeset 192324 fd3adb4a2d16
parent 192323 35fe7342d5aa
child 192325 5608c1796eee
push id3568
push userryanvm@gmail.com
push date2014-05-20 16:00 +0000
treeherdermozilla-beta@26ba0b7f24ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, lsblakk
bugs983169
milestone30.0
Bug 983169 - Fix handling of tile resolution in TiledContentClient. r=bas, a=lsblakk
gfx/layers/client/TiledContentClient.cpp
--- a/gfx/layers/client/TiledContentClient.cpp
+++ b/gfx/layers/client/TiledContentClient.cpp
@@ -738,20 +738,22 @@ ClientTiledLayerBuffer::ValidateTile(Til
   // the calling code will already have taken care of invalidating the entire
   // layer.
   if (HasFormatChanged()) {
     aTile.DiscardBackBuffer();
     aTile.DiscardFrontBuffer();
   }
 
   bool createdTextureClient = false;
-  nsIntRegion offsetDirtyRegion = aDirtyRegion.MovedBy(-aTileOrigin);
+  nsIntRegion offsetScaledDirtyRegion = aDirtyRegion.MovedBy(-aTileOrigin);
+  offsetScaledDirtyRegion.ScaleRoundOut(mResolution, mResolution);
+
   bool usingSinglePaintBuffer = !!mSinglePaintDrawTarget;
   RefPtr<TextureClient> backBuffer =
-    aTile.GetBackBuffer(offsetDirtyRegion,
+    aTile.GetBackBuffer(offsetScaledDirtyRegion,
                         mManager->GetTexturePool(gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType())),
                         &createdTextureClient, !usingSinglePaintBuffer);
 
   if (!backBuffer->Lock(OPEN_READ_WRITE)) {
     NS_WARNING("Failed to lock tile TextureClient for updating.");
     aTile.DiscardFrontBuffer();
     return aTile;
   }
@@ -787,53 +789,60 @@ ClientTiledLayerBuffer::ValidateTile(Til
       drawTarget->CopySurface(source, copyRect, copyTarget);
 
       // 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));
     }
 
     // The new buffer is now validated, remove the dirty region from it.
     aTile.mInvalidBack.Sub(nsIntRect(0, 0, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE),
-                           offsetDirtyRegion);
+                           offsetScaledDirtyRegion);
   } else {
     // Area of the full tile...
-    nsIntRegion tileRegion = nsIntRect(aTileOrigin.x, aTileOrigin.y, TILEDLAYERBUFFER_TILE_SIZE, TILEDLAYERBUFFER_TILE_SIZE);
+    nsIntRegion tileRegion =
+      nsIntRect(aTileOrigin.x, aTileOrigin.y,
+                GetScaledTileLength(), GetScaledTileLength());
 
     // Intersect this area with the portion that's dirty.
     tileRegion = tileRegion.Intersect(aDirtyRegion);
 
-    // Move invalid areas into layer space.
-    aTile.mInvalidFront.MoveBy(aTileOrigin);
-    aTile.mInvalidBack.MoveBy(aTileOrigin);
+    // Add the resolution scale to store the dirty region.
+    nsIntPoint unscaledTileOrigin = nsIntPoint(aTileOrigin.x * mResolution,
+                                               aTileOrigin.y * mResolution);
+    nsIntRegion unscaledTileRegion(tileRegion);
+    unscaledTileRegion.ScaleRoundOut(mResolution, mResolution);
+
+    // Move invalid areas into scaled layer space.
+    aTile.mInvalidFront.MoveBy(unscaledTileOrigin);
+    aTile.mInvalidBack.MoveBy(unscaledTileOrigin);
 
     // Add the area that's going to be redrawn to the invalid area of the
     // front region.
-    aTile.mInvalidFront.Or(aTile.mInvalidFront, tileRegion);
+    aTile.mInvalidFront.Or(aTile.mInvalidFront, unscaledTileRegion);
 
     // Add invalid areas of the backbuffer to the area to redraw.
     tileRegion.Or(tileRegion, aTile.mInvalidBack);
 
     // Move invalid areas back into tile space.
-    aTile.mInvalidFront.MoveBy(-aTileOrigin);
+    aTile.mInvalidFront.MoveBy(-unscaledTileOrigin);
 
     // This will be validated now.
     aTile.mInvalidBack.SetEmpty();
 
     nsIntRect bounds = tileRegion.GetBounds();
-    bounds.ScaleRoundOut(mResolution, mResolution);
     bounds.MoveBy(-aTileOrigin);
 
     if (GetContentType() != gfxContentType::COLOR) {
       drawTarget->ClearRect(Rect(bounds.x, bounds.y, bounds.width, bounds.height));
     }
 
     ctxt->NewPath();
     ctxt->Clip(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height));
+    ctxt->Translate(gfxPoint(-unscaledTileOrigin.x, -unscaledTileOrigin.y));
     ctxt->Scale(mResolution, mResolution);
-    ctxt->Translate(gfxPoint(-aTileOrigin.x, -aTileOrigin.y));
     mCallback(mThebesLayer, ctxt,
               tileRegion.GetBounds(),
               DrawRegionClip::CLIP_NONE,
               nsIntRegion(), mCallbackData);
 
   }
 
 #ifdef GFX_TILEDLAYER_DEBUG_OVERLAY