Bug 1574745 - Reorder layer rendering invocations. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 30 Aug 2019 19:52:56 +0000
changeset 554768 1db2a705c75c28805a054c2023401860fad803df
parent 554767 ea690c643c8cba21a81cc2ee279e21ba03b2a8b1
child 554769 56928dc94586cba272761f8af49e67795baab0bf
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1574745
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 1574745 - Reorder layer rendering invocations. r=mattwoodrow This change groups the work that has to be done per compositing tile. Differential Revision: https://phabricator.services.mozilla.com/D43878
gfx/layers/composite/LayerManagerComposite.cpp
--- a/gfx/layers/composite/LayerManagerComposite.cpp
+++ b/gfx/layers/composite/LayerManagerComposite.cpp
@@ -1017,75 +1017,75 @@ bool LayerManagerComposite::Render(const
   IntRect bounds = *maybeBounds;
   IntRect clipRect = rootLayerClip.valueOr(bounds);
 #if defined(MOZ_WIDGET_ANDROID)
   ScreenCoord offset = GetContentShiftForToolbar();
   ScopedCompositorRenderOffset scopedOffset(mCompositor->AsCompositorOGL(),
                                             ScreenPoint(0.0f, offset));
 #endif
 
-  RefPtr<CompositingRenderTarget> previousTarget;
-  if (haveLayerEffects) {
-    previousTarget = PushGroupForLayerEffects();
-  } else {
-    mTwoPassTmpTarget = nullptr;
-  }
-
-  // Render our layers.
+  // Prepare our layers.
   {
     Diagnostics::Record record(mRenderStartTime);
     RootLayer()->Prepare(RenderTargetIntRect::FromUnknownRect(clipRect));
     if (record.Recording()) {
       mDiagnostics->RecordPrepareTime(record.Duration());
     }
   }
-  // Execute draw commands.
+
   {
     Diagnostics::Record record;
+    RefPtr<CompositingRenderTarget> previousTarget;
+    if (haveLayerEffects) {
+      previousTarget = PushGroupForLayerEffects();
+    } else {
+      mTwoPassTmpTarget = nullptr;
+    }
+
+    // Execute draw commands.
     RootLayer()->RenderLayer(clipRect, Nothing());
+
+    if (mTwoPassTmpTarget) {
+      MOZ_ASSERT(haveLayerEffects);
+      PopGroupForLayerEffects(previousTarget, clipRect, grayscaleVal, invertVal,
+                              contrastVal);
+    }
+    if (!mRegionToClear.IsEmpty()) {
+      for (auto iter = mRegionToClear.RectIter(); !iter.Done(); iter.Next()) {
+        mCompositor->ClearRect(Rect(iter.Get()));
+      }
+    }
+    mCompositor->NormalDrawingDone();
     if (record.Recording()) {
       mDiagnostics->RecordCompositeTime(record.Duration());
     }
   }
+
   RootLayer()->Cleanup();
 
-  if (!mRegionToClear.IsEmpty()) {
-    for (auto iter = mRegionToClear.RectIter(); !iter.Done(); iter.Next()) {
-      mCompositor->ClearRect(Rect(iter.Get()));
-    }
-  }
-
-  if (mTwoPassTmpTarget) {
-    MOZ_ASSERT(haveLayerEffects);
-    PopGroupForLayerEffects(previousTarget, clipRect, grayscaleVal, invertVal,
-                            contrastVal);
-  }
-
-  // Allow widget to render a custom foreground.
-  mCompositor->GetWidget()->DrawWindowOverlay(
-      &widgetContext, LayoutDeviceIntRect::FromUnknownRect(bounds));
-
-  mCompositor->NormalDrawingDone();
-
   mProfilerScreenshotGrabber.MaybeGrabScreenshot(mCompositor);
 
   if (mCompositionRecorder) {
     bool hasContentPaint = std::any_of(
         mPayload.begin(), mPayload.end(), [](CompositionPayload& payload) {
           return payload.mType == CompositionPayloadType::eContentPaint;
         });
 
     if (hasContentPaint) {
       if (RefPtr<RecordedFrame> frame =
               mCompositor->RecordFrame(TimeStamp::Now())) {
         mCompositionRecorder->RecordFrame(frame);
       }
     }
   }
 
+  // Allow widget to render a custom foreground.
+  mCompositor->GetWidget()->DrawWindowOverlay(
+      &widgetContext, LayoutDeviceIntRect::FromUnknownRect(bounds));
+
 #if defined(MOZ_WIDGET_ANDROID)
   // Depending on the content shift the toolbar may be rendered on top of
   // some of the content so it must be rendered after the content.
   if (jni::IsFennec()) {
     RenderToolbar();
   }
   HandlePixelsTarget();
 #endif  // defined(MOZ_WIDGET_ANDROID)