Bug 1568227. Change to using the visual rect for the blob bounds. r=nical
authorJeff Muizelaar <jrmuizel@gmail.com>
Tue, 10 Sep 2019 17:48:43 +0000
changeset 492592 7fa90877a45bd1b70b0d49fad6f4cb9718c3b7b7
parent 492591 3b17e84b9bf83bd15d3c43079bf356eb08040aa8
child 492593 b3dd0e5042fbf7d068104dac67ba74197f6e7851
push id95008
push userjmuizelaar@mozilla.com
push dateTue, 10 Sep 2019 21:26:27 +0000
treeherderautoland@7fa90877a45b [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. Change to using the visual rect for the blob bounds. r=nical This also makes sure that we invalidate for any visible rect bounds changes. This makes more sense even if it's more conservative. Differential Revision: https://phabricator.services.mozilla.com/D45325
gfx/layers/wr/WebRenderCommandBuilder.cpp
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -363,17 +363,17 @@ struct DIGroup {
 
     int32_t appUnitsPerDevPixel =
         aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
     MOZ_RELEASE_ASSERT(mAppUnitsPerDevPixel == appUnitsPerDevPixel);
     GP("\n");
     GP("clippedImageRect %d %d %d %d\n", mClippedImageBounds.x,
        mClippedImageBounds.y, mClippedImageBounds.width,
        mClippedImageBounds.height);
-    LayerIntSize size = mLayerBounds.Size();
+    LayerIntSize size = mVisibleRect.Size();
     GP("imageSize: %d %d\n", size.width, size.height);
     /*if (aItem->IsReused() && aData->mGeometry) {
       return;
     }*/
     aData->mInvalidRegion = false;
 
     GP("pre mInvalidRect: %s %p-%d - inv: %d %d %d %d\n", aItem->Name(),
        aItem->Frame(), aItem->GetPerFrameKey(), mInvalidRect.x, mInvalidRect.y,
@@ -597,22 +597,22 @@ struct DIGroup {
         InvalidateRect(data->mRect);
         iter.Remove();
         delete data;
       } else {
         data->mUsed = false;
       }
     }
 
-    IntSize dtSize = mLayerBounds.Size().ToUnknownSize();
+    IntSize dtSize = mVisibleRect.Size().ToUnknownSize();
     // The actual display item's size shouldn't have the scale factored in
     // Round the bounds out to leave space for unsnapped content
     LayoutDeviceToLayerScale2D scale(mScale.width, mScale.height);
     LayoutDeviceRect itemBounds =
-        (LayerRect(mLayerBounds) - mResidualOffset) / scale;
+        (LayerRect(mVisibleRect) - mResidualOffset) / scale;
 
     if (mInvalidRect.IsEmpty()) {
       GP("Not repainting group because it's empty\n");
       GP("End EndGroup\n");
       if (mKey) {
         // Although the contents haven't changed, the visible area *may* have,
         // so request it be updated unconditionally (wr should be able to easily
         // detect if this is a no-op on its side, if that matters)
@@ -642,17 +642,17 @@ struct DIGroup {
                   validFonts = false;
                   break;
                 }
                 BlobFont font = {key.value(), scaled};
                 aStream.write((const char*)&font, sizeof(font));
               }
               fonts = std::move(aScaledFonts);
             },
-            mLayerBounds.ToUnknownRect().TopLeft());
+            mVisibleRect.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, mLayerBounds.ToUnknownRect());
     // Setup the gfxContext
     RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
@@ -704,17 +704,17 @@ struct DIGroup {
       }
       mKey = Some(MakePair(aBuilder.GetRenderRoot(), key));
     } else {
       wr::ImageDescriptor descriptor(dtSize, 0, dt->GetFormat(), opacity);
 
       // Convert mInvalidRect to image space by subtracting the corner of the
       // image bounds
       auto dirtyRect = ViewAs<ImagePixel>(
-          mInvalidRect - mLayerBounds.ToUnknownRect().TopLeft());
+          mInvalidRect - mVisibleRect.ToUnknownRect().TopLeft());
 
       auto bottomRight = dirtyRect.BottomRight();
       GP("check invalid %d %d - %d %d\n", bottomRight.x, bottomRight.y,
          dtSize.width, dtSize.height);
       MOZ_RELEASE_ASSERT(bottomRight.x <= dtSize.width &&
                          bottomRight.y <= dtSize.height);
       GP("Update Blob %d %d %d %d\n", mInvalidRect.x, mInvalidRect.y,
          mInvalidRect.width, mInvalidRect.height);
@@ -760,17 +760,17 @@ struct DIGroup {
     aBuilder.ClearHitTestInfo();
   }
 
   void PaintItemRange(Grouper* aGrouper, nsDisplayItem* aStartItem,
                       nsDisplayItem* aEndItem, gfxContext* aContext,
                       WebRenderDrawEventRecorder* aRecorder,
                       RenderRootStateManager* aRootManager,
                       wr::IpcResourceUpdateQueue& aResources) {
-    LayerIntSize size = mLayerBounds.Size();
+    LayerIntSize size = mVisibleRect.Size();
     for (nsDisplayItem* item = aStartItem; item != aEndItem;
          item = item->GetAbove()) {
       BlobItemData* data = GetBlobItemData(item);
       IntRect bounds = data->mRect;
       auto bottomRight = bounds.BottomRight();
 
       GP("Trying %s %p-%d %d %d %d %d\n", item->Name(), item->Frame(),
          item->GetPerFrameKey(), bounds.x, bounds.y, bounds.XMost(),
@@ -1234,18 +1234,18 @@ void Grouper::ConstructGroups(nsDisplayL
           aCommandBuilder->CreateOrRecycleWebRenderUserData<WebRenderGroupData>(
               item, aBuilder.GetRenderRoot());
 
       // Initialize groupData->mFollowingGroup
       // TODO: compute the group bounds post-grouping, so that they can be
       // tighter for just the sublist that made it into this group.
       // We want to ensure the tight bounds are still clipped by area
       // that we're building the display list for.
-      if (!groupData->mFollowingGroup.mGroupBounds.IsEqualEdges(
-              currentGroup->mGroupBounds) ||
+      if (!groupData->mFollowingGroup.mVisibleRect.IsEqualEdges(currentGroup->mVisibleRect) ||
+          !groupData->mFollowingGroup.mGroupBounds.IsEqualEdges(currentGroup->mGroupBounds) ||
           groupData->mFollowingGroup.mScale != currentGroup->mScale ||
           groupData->mFollowingGroup.mAppUnitsPerDevPixel !=
               currentGroup->mAppUnitsPerDevPixel ||
           groupData->mFollowingGroup.mResidualOffset !=
               currentGroup->mResidualOffset) {
         if (groupData->mFollowingGroup.mAppUnitsPerDevPixel !=
             currentGroup->mAppUnitsPerDevPixel) {
           GP("app unit change following: %d %d\n",
@@ -1455,18 +1455,16 @@ void WebRenderCommandBuilder::DoGrouping
   // gets split into multiple groups (blobs), then they will all inherit this
   // overall size even though they may each be much smaller. This can lead to
   // allocating much larger textures than necessary in webrender.
   //
   // Don’t bother fixing this unless we run into this in the real world, though.
   auto layerBounds = LayerIntRect::FromUnknownRect(
       ScaleToOutsidePixelsOffset(groupBounds, scale.width, scale.height,
                                  appUnitsPerDevPixel, residualOffset));
-  GP("scale: %f %f - %d - %f %f\n", scale.width, scale.height,
-     group.mAppUnitsPerDevPixel, residualOffset.x, residualOffset.y);
 
   const nsRect& untransformedPaintRect = aWrappingItem->GetUntransformedPaintRect();
 
   auto visibleRect = LayerIntRect::FromUnknownRect(
                          ScaleToOutsidePixelsOffset(
                              untransformedPaintRect, scale.width,
                              scale.height, appUnitsPerDevPixel, residualOffset))
                          .Intersect(layerBounds);
@@ -1474,17 +1472,18 @@ void WebRenderCommandBuilder::DoGrouping
   GP("LayerBounds: %d %d %d %d\n", layerBounds.x, layerBounds.y,
      layerBounds.width, layerBounds.height);
   GP("VisibleRect: %d %d %d %d\n", visibleRect.x, visibleRect.y,
      visibleRect.width, visibleRect.height);
 
   GP("Inherrited scale %f %f\n", scale.width, scale.height);
   GP("Bounds: %d %d %d %d vs %d %d %d %d\n", p.x, p.y, p.width, p.height, q.x,
      q.y, q.width, q.height);
-  if (!group.mGroupBounds.IsEqualEdges(groupBounds) ||
+  if (!group.mVisibleRect.IsEqualEdges(visibleRect) ||
+      !group.mGroupBounds.IsEqualEdges(groupBounds) ||
       group.mAppUnitsPerDevPixel != appUnitsPerDevPixel ||
       group.mScale != scale || group.mResidualOffset != residualOffset) {
     GP("Property change. Deleting blob\n");
 
     if (group.mAppUnitsPerDevPixel != appUnitsPerDevPixel) {
       GP(" App unit change %d -> %d\n", group.mAppUnitsPerDevPixel,
          appUnitsPerDevPixel);
     }
@@ -1519,16 +1518,17 @@ void WebRenderCommandBuilder::DoGrouping
 
   g.mAppUnitsPerDevPixel = appUnitsPerDevPixel;
   group.mResidualOffset = residualOffset;
   group.mGroupBounds = groupBounds;
   group.mLayerBounds = layerBounds;
   group.mVisibleRect = visibleRect;
   group.mAppUnitsPerDevPixel = appUnitsPerDevPixel;
   group.mImageBounds = layerBounds.ToUnknownRect();
+  group.mImageBounds = visibleRect.ToUnknownRect();
   group.mClippedImageBounds = group.mImageBounds;
 
   g.mTransform = Matrix::Scaling(scale.width, scale.height)
                      .PostTranslate(residualOffset.x, residualOffset.y);
   group.mScale = scale;
   group.mScrollId = scrollId;
   g.ConstructGroups(aDisplayListBuilder, this, aBuilder, aResources, &group,
                     aList, aSc);