Bug 1594950 - Track the nsChildView invalid region inside nsChildView, rather than on the layer. r=jrmuizel
☠☠ backed out by c351bea71696 ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Tue, 12 Nov 2019 19:50:26 +0000
changeset 501636 aea7108204e950084354be4614349e614ae19166
parent 501635 15baea8520de4503c11b07accc0f0de013336971
child 501637 adea6912c3a313742b1662803d48caff5a6a8c3c
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1594950
milestone72.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 1594950 - Track the nsChildView invalid region inside nsChildView, rather than on the layer. r=jrmuizel This allows us to move the call to InvalidateRegionThroughoutSwapchain to just before the call to NextSurface, which makes it easier to merge the two calls. Differential Revision: https://phabricator.services.mozilla.com/D50877
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -700,16 +700,19 @@ class nsChildView final : public nsBaseW
 
   // In BasicLayers mode, this is the CoreAnimation layer that contains the
   // rendering from Gecko. It is a sublayer of mNativeLayerRoot's underlying
   // wrapper layer.
   // Lazily created by EnsureContentLayerForMainThreadPainting().
   // Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is false.
   RefPtr<mozilla::layers::NativeLayerCA> mContentLayer;
 
+  // In BasicLayers mode, this is the invalid region of mContentLayer.
+  LayoutDeviceIntRegion mContentLayerInvalidRegion;
+
   mozilla::UniquePtr<mozilla::VibrancyManager> mVibrancyManager;
   RefPtr<mozilla::SwipeTracker> mSwipeTracker;
   mozilla::UniquePtr<mozilla::SwipeEventQueue> mSwipeEventQueue;
 
   // Only used for drawRect-based painting in popups.
   // Always null if StaticPrefs::gfx_core_animation_enabled_AtStartup() is true.
   RefPtr<mozilla::gfx::DrawTarget> mBackingSurface;
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -1289,17 +1289,17 @@ void nsChildView::Invalidate(const Layou
 
   if (!mView || !mVisible) return;
 
   NS_ASSERTION(GetLayerManager()->GetBackendType() != LayersBackend::LAYERS_CLIENT,
                "Shouldn't need to invalidate with accelerated OMTC layers!");
 
   if (StaticPrefs::gfx_core_animation_enabled_AtStartup()) {
     EnsureContentLayerForMainThreadPainting();
-    mContentLayer->InvalidateRegionThroughoutSwapchain(aRect.ToUnknownRect());
+    mContentLayerInvalidRegion.OrWith(aRect.Intersect(GetBounds()));
     [mView markLayerForDisplay];
   } else {
     [[mView pixelHostingView] setNeedsDisplayInRect:DevPixelsToCocoaPoints(aRect)];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
@@ -1496,31 +1496,34 @@ void nsChildView::EnsureContentLayerForM
   if (mContentLayer && mContentLayer->GetSize() != size) {
     mNativeLayerRoot->RemoveLayer(mContentLayer);
     mContentLayer = nullptr;
   }
   if (!mContentLayer) {
     RefPtr<NativeLayer> contentLayer = mNativeLayerRoot->CreateLayer(size, false);
     mNativeLayerRoot->AppendLayer(contentLayer);
     mContentLayer = contentLayer->AsNativeLayerCA();
+    mContentLayerInvalidRegion = GetBounds();
   }
 }
 
 void nsChildView::PaintWindowInContentLayer() {
   EnsureContentLayerForMainThreadPainting();
   mContentLayer->SetSurfaceIsFlipped(false);
+  mContentLayer->InvalidateRegionThroughoutSwapchain(mContentLayerInvalidRegion.ToUnknownRegion());
   RefPtr<DrawTarget> dt = mContentLayer->NextSurfaceAsDrawTarget(gfx::BackendType::SKIA);
   if (!dt) {
     return;
   }
 
   PaintWindowInDrawTarget(
       dt, LayoutDeviceIntRegion::FromUnknownRegion(mContentLayer->CurrentSurfaceInvalidRegion()),
       dt->GetSize());
   mContentLayer->NotifySurfaceReady();
+  mContentLayerInvalidRegion.SetEmpty();
 }
 
 void nsChildView::HandleMainThreadCATransaction() {
   WillPaintWindow();
 
   if (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_BASIC) {
     // We're in BasicLayers mode, i.e. main thread software compositing.
     // Composite the window into our layer's surface.