Bug 1568227. Render blobs at visibleRect.x,y instead of 0,0. r=nical
☠☠ backed out by 35e9f24cc4c9 ☠ ☠
authorJeff Muizelaar <jrmuizel@gmail.com>
Tue, 10 Sep 2019 15:12:05 +0000
changeset 492523 bb324781c1e3ac2d006636ac0842d804a10878c3
parent 492522 9dd37b1e1cbb13ba70f5a3badafd64253655d669
child 492524 fef155ac9c6039de75923334a75c03d7aa5ab156
push id94963
push userjmuizelaar@mozilla.com
push dateTue, 10 Sep 2019 15:26:36 +0000
treeherderautoland@fef155ac9c60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1568227
milestone71.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 1568227. Render blobs at visibleRect.x,y instead of 0,0. r=nical Differential Revision: https://phabricator.services.mozilla.com/D45322
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -2042,25 +2042,26 @@ static bool PaintByLayer(nsDisplayItem* 
   aManager->SetTarget(nullptr);
   aManager->SetDefaultTarget(nullptr);
 
   return isInvalidated;
 }
 
 static bool PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
                                   const LayoutDevicePoint& aOffset,
+                                  const IntRect& visibleRect,
                                   nsDisplayListBuilder* aDisplayListBuilder,
                                   const RefPtr<BasicLayerManager>& aManager,
                                   const gfx::Size& aScale,
                                   Maybe<gfx::Color>& aHighlight) {
   MOZ_ASSERT(aDT);
 
   bool isInvalidated = false;
   // XXX Why is this ClearRect() needed?
-  aDT->ClearRect(Rect(aDT->GetRect()));
+  aDT->ClearRect(Rect(visibleRect));
   RefPtr<gfxContext> context = gfxContext::CreateOrNull(aDT);
   MOZ_ASSERT(context);
 
   switch (aItem->GetType()) {
     case DisplayItemType::TYPE_SVG_WRAPPER:
     case DisplayItemType::TYPE_MASK: {
       // These items should be handled by other code paths
       MOZ_RELEASE_ASSERT(0);
@@ -2095,25 +2096,24 @@ static bool PaintItemByDrawTarget(nsDisp
   }
 
   if (aItem->GetType() != DisplayItemType::TYPE_MASK) {
     // Apply highlight fills, if the appropriate prefs are set.
     // We don't do this for masks because we'd be filling the A8 mask surface,
     // which isn't very useful.
     if (aHighlight) {
       aDT->SetTransform(gfx::Matrix());
-      aDT->FillRect(Rect(aDT->GetRect()),
-                    gfx::ColorPattern(aHighlight.value()));
+      aDT->FillRect(Rect(visibleRect), gfx::ColorPattern(aHighlight.value()));
     }
     if (aItem->Frame()->PresContext()->GetPaintFlashing() && isInvalidated) {
       aDT->SetTransform(gfx::Matrix());
       float r = float(rand()) / float(RAND_MAX);
       float g = float(rand()) / float(RAND_MAX);
       float b = float(rand()) / float(RAND_MAX);
-      aDT->FillRect(Rect(aDT->GetRect()),
+      aDT->FillRect(Rect(visibleRect),
                     gfx::ColorPattern(gfx::Color(r, g, b, 0.5)));
     }
   }
 
   return isInvalidated;
 }
 
 already_AddRefed<WebRenderFallbackData>
@@ -2190,17 +2190,17 @@ WebRenderCommandBuilder::GenerateFallbac
                              scale.height, appUnitsPerDevPixel, residualOffset))
                          .Intersect(dtRect);
   // visibleRect is relative to the blob origin so adjust for that
   visibleRect -= dtRect.TopLeft();
 
   if (dtSize.IsEmpty()) {
     return nullptr;
   }
-
+  // Display item bounds should be unscaled
   aImageRect = dtRect / layerScale;
 
   nsDisplayItemGeometry* geometry = fallbackData->mGeometry;
 
   bool needPaint = true;
 
   // nsDisplayFilters is rendered via BasicLayerManager which means the
   // invalidate region is unknown until we traverse the displaylist contained by
@@ -2271,18 +2271,21 @@ WebRenderCommandBuilder::GenerateFallbac
       RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(
           gfx::BackendType::SKIA, gfx::IntSize(1, 1), format);
       RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(
           recorder, dummyDt, dtRect.ToUnknownRect());
       if (!fallbackData->mBasicLayerManager) {
         fallbackData->mBasicLayerManager =
             new BasicLayerManager(BasicLayerManager::BLM_INACTIVE);
       }
+      // aOffset is (0, 0) because blobs don't want to normalize their
+      // coordinates
       bool isInvalidated = PaintItemByDrawTarget(
-          aItem, dt, LayoutDevicePoint(0, 0), aDisplayListBuilder,
+          aItem, dt, LayoutDevicePoint(0, 0),
+          /*aVisibleRect: */ dtRect.ToUnknownRect(), aDisplayListBuilder,
           fallbackData->mBasicLayerManager, scale, highlight);
       if (!isInvalidated) {
         if (!aItem->GetBuildingRect().IsEqualInterior(
                 fallbackData->mBuildingRect)) {
           // The building rect has changed but we didn't see any invalidations.
           // We should still consider this an invalidation.
           isInvalidated = true;
         }
@@ -2341,18 +2344,22 @@ WebRenderCommandBuilder::GenerateFallbac
           RefPtr<gfx::DrawTarget> dt = helper.GetDrawTarget();
           if (!dt) {
             return nullptr;
           }
           if (!fallbackData->mBasicLayerManager) {
             fallbackData->mBasicLayerManager =
                 new BasicLayerManager(mManager->GetWidget());
           }
+          // aOffset is applied because this case is a "real" image and not a
+          // blob
           isInvalidated = PaintItemByDrawTarget(
-              aItem, dt, aImageRect.TopLeft(), aDisplayListBuilder,
+              aItem, dt,
+              /*aOffset: */ aImageRect.TopLeft(),
+              /*aVisibleRect: */ dt->GetRect(), aDisplayListBuilder,
               fallbackData->mBasicLayerManager, scale, highlight);
         }
 
         if (isInvalidated) {
           // Update image if there it's invalidated.
           if (!helper.UpdateImage(aBuilder.GetRenderRoot())) {
             return nullptr;
           }