Bug 1592150 - Enable support for partial updates in the WebRender OS compositor on macOS. r=jrmuizel
authorMarkus Stange <mstange@themasta.com>
Tue, 19 Nov 2019 03:33:43 +0000
changeset 502529 8ae9d7dc86f2e723b73d3b7cdc1cea4c821ad9f0
parent 502528 1af8d457ec9937c9d59746905bbbd30e32ee57c4
child 502530 4d11ccc1252922ab6ec9090468e844ab5fe96ee7
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
bugs1592150
milestone72.0a1
Bug 1592150 - Enable support for partial updates in the WebRender OS compositor on macOS. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D51762
gfx/webrender_bindings/RenderCompositorOGL.cpp
gfx/webrender_bindings/RenderCompositorOGL.h
modules/libpref/init/StaticPrefList.yaml
--- a/gfx/webrender_bindings/RenderCompositorOGL.cpp
+++ b/gfx/webrender_bindings/RenderCompositorOGL.cpp
@@ -143,16 +143,24 @@ bool RenderCompositorOGL::Resume() { ret
 LayoutDeviceIntSize RenderCompositorOGL::GetBufferSize() {
   return mWidget->GetClientSize();
 }
 
 bool RenderCompositorOGL::ShouldUseNativeCompositor() {
   return mNativeLayerRoot && StaticPrefs::gfx_webrender_compositor_AtStartup();
 }
 
+uint32_t RenderCompositorOGL::GetMaxUpdateRects() {
+  if (ShouldUseNativeCompositor() &&
+      StaticPrefs::gfx_webrender_compositor_max_update_rects_AtStartup() > 0) {
+    return 1;
+  }
+  return 0;
+}
+
 void RenderCompositorOGL::CompositorBeginFrame() {
   mAddedLayers.Clear();
   mAddedPixelCount = 0;
   mAddedClippedPixelCount = 0;
 }
 
 void RenderCompositorOGL::CompositorEndFrame() {
   auto bufferSize = GetBufferSize();
@@ -173,32 +181,28 @@ void RenderCompositorOGL::CompositorEndF
 void RenderCompositorOGL::Bind(wr::NativeSurfaceId aId,
                                wr::DeviceIntPoint* aOffset, uint32_t* aFboId,
                                wr::DeviceIntRect aDirtyRect) {
   MOZ_RELEASE_ASSERT(!mCurrentlyBoundNativeLayer);
 
   auto layerCursor = mNativeLayers.find(wr::AsUint64(aId));
   MOZ_RELEASE_ASSERT(layerCursor != mNativeLayers.end());
   RefPtr<layers::NativeLayer> layer = layerCursor->second;
-  gfx::IntRect layerRect = layer->GetRect();
+
   gfx::IntRect dirtyRect(aDirtyRect.origin.x, aDirtyRect.origin.y,
                          aDirtyRect.size.width, aDirtyRect.size.height);
-  MOZ_RELEASE_ASSERT(
-      dirtyRect.IsEqualInterior(layerRect - layerRect.TopLeft()),
-      "We currently do not support partial updates (max_update_rects is set to "
-      "0), so we expect the dirty rect to always cover the entire layer.");
 
   Maybe<GLuint> fbo = layer->NextSurfaceAsFramebuffer(dirtyRect, true);
   MOZ_RELEASE_ASSERT(fbo);  // TODO: make fallible
   mCurrentlyBoundNativeLayer = layer;
 
   *aFboId = *fbo;
   *aOffset = wr::DeviceIntPoint{0, 0};
 
-  mDrawnPixelCount += layerRect.Area();
+  mDrawnPixelCount += dirtyRect.Area();
 }
 
 void RenderCompositorOGL::Unbind() {
   MOZ_RELEASE_ASSERT(mCurrentlyBoundNativeLayer);
 
   mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
   mCurrentlyBoundNativeLayer->NotifySurfaceReady();
   mCurrentlyBoundNativeLayer = nullptr;
--- a/gfx/webrender_bindings/RenderCompositorOGL.h
+++ b/gfx/webrender_bindings/RenderCompositorOGL.h
@@ -35,16 +35,17 @@ class RenderCompositorOGL : public Rende
 
   gl::GLContext* gl() const override { return mGL; }
 
   bool UseANGLE() const override { return false; }
 
   LayoutDeviceIntSize GetBufferSize() override;
 
   bool ShouldUseNativeCompositor() override;
+  uint32_t GetMaxUpdateRects() override;
 
   // Interface for wr::Compositor
   void CompositorBeginFrame() override;
   void CompositorEndFrame() override;
   void Bind(wr::NativeSurfaceId aId, wr::DeviceIntPoint* aOffset,
             uint32_t* aFboId, wr::DeviceIntRect aDirtyRect) override;
   void Unbind() override;
   void CreateSurface(wr::NativeSurfaceId aId, wr::DeviceIntSize aSize,
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -3638,17 +3638,17 @@
 
 - name: gfx.webrender.compositor
   type: bool
   value: false
   mirror: once
 
 - name: gfx.webrender.compositor.max_update_rects
   type: uint32_t
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(XP_MACOSX)
   value: 1
 #else
   value: 0
 #endif
   mirror: once
 
 - name: gfx.webrender.max-partial-present-rects
   type: uint32_t