Bug 1594950 - Track the nsChildView invalid region inside nsChildView, rather than on the layer. r=jrmuizel
authorMarkus Stange <mstange@themasta.com>
Wed, 13 Nov 2019 18:33:20 +0000
changeset 501815 2a2c01a5ce9a25fd52d55b56a1b238eebfc7d752
parent 501814 aa9475c27a6d5c4359f3a6d1c058ef9b1b440f5b
child 501816 4391cb16bb0b291b02a1fc42a7295c564d76d9ec
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.