Bug 1568227. Use the visible rect as the display items bounds for fallback items. r=nical
☠☠ backed out by 35e9f24cc4c9 ☠ ☠
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 10 Sep 2019 15:14:37 +0000
changeset 492524 fef155ac9c6039de75923334a75c03d7aa5ab156
parent 492523 bb324781c1e3ac2d006636ac0842d804a10878c3
child 492525 cd0ea6dafa051426035949cfbbfdeb04c1c05661
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. Use the visible rect as the display items bounds for fallback items. r=nical Differential Revision: https://phabricator.services.mozilla.com/D45323
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -2177,31 +2177,29 @@ WebRenderCommandBuilder::GenerateFallbac
   auto trans =
       ViewAs<LayerPixel>(aSc.GetSnappingSurfaceTransform().GetTranslation());
   auto snappedTrans = LayerIntPoint::Floor(trans);
   LayerPoint residualOffset = trans - snappedTrans;
 
   auto dtRect = LayerIntRect::FromUnknownRect(
       ScaleToOutsidePixelsOffset(paintBounds, scale.width, scale.height,
                                  appUnitsPerDevPixel, residualOffset));
-  auto dtSize = dtRect.Size();
 
   auto visibleRect = LayerIntRect::FromUnknownRect(
                          ScaleToOutsidePixelsOffset(
                              aItem->GetBuildingRect(), scale.width,
                              scale.height, appUnitsPerDevPixel, residualOffset))
                          .Intersect(dtRect);
-  // visibleRect is relative to the blob origin so adjust for that
-  visibleRect -= dtRect.TopLeft();
 
-  if (dtSize.IsEmpty()) {
+  auto visibleSize = visibleRect.Size();
+  if (visibleSize.IsEmpty()) {
     return nullptr;
   }
   // Display item bounds should be unscaled
-  aImageRect = dtRect / layerScale;
+  aImageRect = visibleRect / 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
   // it.
@@ -2262,53 +2260,53 @@ WebRenderCommandBuilder::GenerateFallbac
                     validFonts = false;
                     break;
                   }
                   BlobFont font = {key.value(), scaled};
                   aStream.write((const char*)&font, sizeof(font));
                 }
                 fonts = std::move(aScaledFonts);
               },
-              dtRect.ToUnknownRect().TopLeft());
+              visibleRect.ToUnknownRect().TopLeft());
       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),
-          /*aVisibleRect: */ dtRect.ToUnknownRect(), aDisplayListBuilder,
+          /*aVisibleRect: */ visibleRect.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;
         }
       }
-      recorder->FlushItem(dtRect.ToUnknownRect());
+      recorder->FlushItem(visibleRect.ToUnknownRect());
       recorder->Finish();
 
       if (!validFonts) {
         gfxCriticalNote << "Failed serializing fonts for blob image";
         return nullptr;
       }
 
       if (isInvalidated) {
         Range<uint8_t> bytes((uint8_t*)recorder->mOutputStream.mData,
                              recorder->mOutputStream.mLength);
         wr::BlobImageKey key =
             wr::BlobImageKey{mManager->WrBridge()->GetNextImageKey()};
-        wr::ImageDescriptor descriptor(dtSize.ToUnknownSize(), 0,
+        wr::ImageDescriptor descriptor(visibleSize.ToUnknownSize(), 0,
                                        dt->GetFormat(), opacity);
         if (!aResources.AddBlobImage(
                 key, descriptor, bytes,
                 ViewAs<ImagePixel>(visibleRect,
                                    PixelCastJustification::LayerIsImage))) {
           return nullptr;
         }
         TakeExternalSurfaces(
@@ -2334,17 +2332,17 @@ WebRenderCommandBuilder::GenerateFallbac
       imageData->CreateImageClientIfNeeded();
       RefPtr<ImageClient> imageClient = imageData->GetImageClient();
       RefPtr<ImageContainer> imageContainer =
           LayerManager::CreateImageContainer();
       bool isInvalidated = false;
 
       {
         UpdateImageHelper helper(imageContainer, imageClient,
-                                 dtSize.ToUnknownSize(), format);
+                                 visibleSize.ToUnknownSize(), format);
         {
           RefPtr<gfx::DrawTarget> dt = helper.GetDrawTarget();
           if (!dt) {
             return nullptr;
           }
           if (!fallbackData->mBasicLayerManager) {
             fallbackData->mBasicLayerManager =
                 new BasicLayerManager(mManager->GetWidget());