Bug 1562184. Have a regular nsRegion for the window opaque region for non-retained cases. r=mattwoodrow
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 24 Jul 2019 21:09:42 +0000
changeset 484138 8a8b3e0a54cc19a53838ef6d988dc05a02338cf6
parent 484137 7cbaf01a8dc2acf95f8fdb7a1c37315393448c00
child 484139 fd57b600fcba71f59b2e96d68bd900633a6b6649
push id90838
push usertnikkel@mozilla.com
push dateWed, 24 Jul 2019 22:55:47 +0000
treeherderautoland@8a8b3e0a54cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1562184
milestone70.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 1562184. Have a regular nsRegion for the window opaque region for non-retained cases. r=mattwoodrow Not sure if we need this, but the window dragging regions have it, so in case we need to turn off retained display lists we have this and there will be no difference to before the patches in this bug. Depends on D38589 Differential Revision: https://phabricator.services.mozilla.com/D38590
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2363,17 +2363,17 @@ void nsDisplayListBuilder::AddSizeOfExcl
   MallocSizeOf mallocSizeOf = aSizes.mState.mMallocSizeOf;
   n += mWillChangeBudget.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mWillChangeBudgetSet.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mAGRBudgetSet.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mEffectsUpdates.ShallowSizeOfExcludingThis(mallocSizeOf);
   n += mWindowExcludeGlassRegion.SizeOfExcludingThis(mallocSizeOf);
   n += mRetainedWindowDraggingRegion.SizeOfExcludingThis(mallocSizeOf);
   n += mRetainedWindowNoDraggingRegion.SizeOfExcludingThis(mallocSizeOf);
-  n += mWindowOpaqueRegion.SizeOfExcludingThis(mallocSizeOf);
+  n += mRetainedWindowOpaqueRegion.SizeOfExcludingThis(mallocSizeOf);
   // XXX can't measure mClipDeduplicator since it uses std::unordered_set.
 
   aSizes.mLayoutRetainedDisplayListSize += n;
 }
 
 void RetainedDisplayList::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const {
   for (nsDisplayItem* item : *this) {
     item->AddSizeOfExcludingThis(aSizes);
@@ -2432,26 +2432,26 @@ void nsDisplayListBuilder::WeakFrameRegi
   mFrames.TruncateLength(length);
   mRects.TruncateLength(length);
 }
 
 void nsDisplayListBuilder::RemoveModifiedWindowRegions() {
   mRetainedWindowDraggingRegion.RemoveModifiedFramesAndRects();
   mRetainedWindowNoDraggingRegion.RemoveModifiedFramesAndRects();
   mWindowExcludeGlassRegion.RemoveModifiedFramesAndRects();
-  mWindowOpaqueRegion.RemoveModifiedFramesAndRects();
+  mRetainedWindowOpaqueRegion.RemoveModifiedFramesAndRects();
 
   mHasGlassItemDuringPartial = false;
 }
 
 void nsDisplayListBuilder::ClearRetainedWindowRegions() {
   mRetainedWindowDraggingRegion.Clear();
   mRetainedWindowNoDraggingRegion.Clear();
   mWindowExcludeGlassRegion.Clear();
-  mWindowOpaqueRegion.Clear();
+  mRetainedWindowOpaqueRegion.Clear();
 
   mGlassDisplayItem = nullptr;
 }
 
 const uint32_t gWillChangeAreaMultiplier = 3;
 static uint32_t GetLayerizationCost(const nsSize& aSize) {
   // There's significant overhead for each layer created from Gecko
   // (IPC+Shared Objects) and from the backend (like an OpenGL texture).
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -1609,24 +1609,29 @@ class nsDisplayListBuilder {
   nsRegion GetWindowExcludeGlassRegion() const {
     return mWindowExcludeGlassRegion.ToRegion();
   }
 
   /**
    * Accumulates opaque stuff into the window opaque region.
    */
   void AddWindowOpaqueRegion(nsIFrame* aFrame, const nsRect& aBounds) {
-    mWindowOpaqueRegion.Add(aFrame, aBounds);
+    if (IsRetainingDisplayList()) {
+      mRetainedWindowOpaqueRegion.Add(aFrame, aBounds);
+      return;
+    }
+    mWindowOpaqueRegion.Or(mWindowOpaqueRegion, aBounds);
   }
   /**
    * Returns the window opaque region built so far. This may be incomplete
    * since the opaque region is built during layer construction.
    */
   const nsRegion GetWindowOpaqueRegion() {
-    return mWindowOpaqueRegion.ToRegion();
+    return IsRetainingDisplayList() ? mRetainedWindowOpaqueRegion.ToRegion()
+                                    : mWindowOpaqueRegion;
   }
 
   void SetGlassDisplayItem(nsDisplayItem* aItem);
   void ClearGlassDisplayItem() { mGlassDisplayItem = nullptr; }
   nsDisplayItem* GetGlassDisplayItem() { return mGlassDisplayItem; }
 
   bool NeedToForceTransparentSurfaceForItem(nsDisplayItem* aItem);
 
@@ -1925,21 +1930,22 @@ class nsDisplayListBuilder {
   nsRect mDirtyRect;
 
   // Tracked regions used for retained display list.
   WeakFrameRegion mWindowExcludeGlassRegion;
   WeakFrameRegion mRetainedWindowDraggingRegion;
   WeakFrameRegion mRetainedWindowNoDraggingRegion;
 
   // Window opaque region is calculated during layer building.
-  WeakFrameRegion mWindowOpaqueRegion;
+  WeakFrameRegion mRetainedWindowOpaqueRegion;
 
   // Optimized versions for non-retained display list.
   LayoutDeviceIntRegion mWindowDraggingRegion;
   LayoutDeviceIntRegion mWindowNoDraggingRegion;
+  nsRegion mWindowOpaqueRegion;
 
   // The display item for the Windows window glass background, if any
   // Set during full display list builds or during display list merging only,
   // partial display list builds don't touch this.
   nsDisplayItem* mGlassDisplayItem;
   // If we've encountered a glass item yet, only used during partial display
   // list builds.
   bool mHasGlassItemDuringPartial;