Bug 1574745 - Move ShouldRecordFrames() from BasicCompositor to Compositor because CompositorOGL will need it. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Fri, 30 Aug 2019 19:52:15 +0000
changeset 551512 6d1b97aed6f0ed5b25eeb1246d38ebd964156e81
parent 551511 ee0a3838c5c1d210b3c0b94da267b7d8a55bc5c6
child 551513 29be5f4832cabc9a1a94268138b47b1af988e1e4
push id11865
push userbtara@mozilla.com
push dateMon, 02 Sep 2019 08:54:37 +0000
treeherdermozilla-beta@37f59c4671b3 [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 - Move ShouldRecordFrames() from BasicCompositor to Compositor because CompositorOGL will need it. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D43875
gfx/layers/Compositor.cpp
gfx/layers/Compositor.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/BasicCompositor.h
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -8,16 +8,17 @@
 #include "base/message_loop.h"                      // for MessageLoop
 #include "mozilla/layers/CompositorBridgeParent.h"  // for CompositorBridgeParent
 #include "mozilla/layers/Diagnostics.h"
 #include "mozilla/layers/Effects.h"  // for Effect, EffectChain, etc
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/TextureHost.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/mozalloc.h"  // for operator delete, etc
+#include "GeckoProfiler.h"
 #include "gfx2DGlue.h"
 #include "nsAppRunner.h"
 #include "LayersHelpers.h"
 
 namespace mozilla {
 
 namespace layers {
 
@@ -592,10 +593,19 @@ already_AddRefed<RecordedFrame> Composit
 
   if (!ReadbackRenderTarget(renderTarget, buffer)) {
     return nullptr;
   }
 
   return MakeAndAddRef<CompositorRecordedFrame>(aTimeStamp, std::move(buffer));
 }
 
+bool Compositor::ShouldRecordFrames() const {
+#ifdef MOZ_GECKO_PROFILER
+  if (profiler_feature_active(ProfilerFeature::Screenshots)) {
+    return true;
+  }
+#endif
+  return mRecordFrames;
+}
+
 }  // namespace layers
 }  // namespace mozilla
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -591,17 +591,19 @@ class Compositor : public TextureSourceP
   bool IsValid() const override;
   CompositorBridgeParent* GetCompositorBridgeParent() const { return mParent; }
 
   /**
    * Request the compositor to allow recording its frames.
    *
    * This is a noop on |CompositorOGL|.
    */
-  virtual void RequestAllowFrameRecording(bool aWillRecord) {}
+  virtual void RequestAllowFrameRecording(bool aWillRecord) {
+    mRecordFrames = aWillRecord;
+  }
 
   /**
    * Record the current frame for readback by the |CompositionRecorder|.
    *
    * If this compositor does not support this feature, a null pointer is
    * returned instead.
    */
   already_AddRefed<RecordedFrame> RecordFrame(const TimeStamp& aTimeStamp);
@@ -645,16 +647,28 @@ class Compositor : public TextureSourceP
 
   virtual void DrawPolygon(const gfx::Polygon& aPolygon, const gfx::Rect& aRect,
                            const gfx::IntRect& aClipRect,
                            const EffectChain& aEffectChain, gfx::Float aOpacity,
                            const gfx::Matrix4x4& aTransform,
                            const gfx::Rect& aVisibleRect);
 
   /**
+   * Whether or not the compositor should be prepared to record frames. While
+   * this returns true, compositors are expected to maintain a full window
+   * render target that they return from GetWindowRenderTarget() between
+   * NormalDrawingDone() and EndFrame().
+   *
+   * This will be true when either we are recording a profile with screenshots
+   * enabled or the |LayerManagerComposite| has requested us to record frames
+   * for the |CompositionRecorder|.
+   */
+  bool ShouldRecordFrames() const;
+
+  /**
    * Last Composition end time.
    */
   TimeStamp mLastCompositionEndTime;
 
   DiagnosticTypes mDiagnosticTypes;
   CompositorBridgeParent* mParent;
 
   /**
@@ -669,16 +683,18 @@ class Compositor : public TextureSourceP
 
   widget::CompositorWidget* mWidget;
 
   bool mIsDestroyed;
 
   gfx::Color mClearColor;
   gfx::Color mDefaultClearColor;
 
+  bool mRecordFrames = false;
+
  private:
   static LayersBackend sBackend;
 };
 
 // Returns the number of rects. (Up to 4)
 typedef gfx::Rect decomposedRectArrayT[4];
 size_t DecomposeIntoNoRepeatRects(const gfx::Rect& aRect,
                                   const gfx::Rect& aTexCoordRect,
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -1237,19 +1237,10 @@ bool BasicCompositor::NeedToRecreateFull
   }
   if (!mFullWindowRenderTarget) {
     return true;
   }
   IntSize windowSize = mWidget->GetClientSize().ToUnknownSize();
   return mFullWindowRenderTarget->mDrawTarget->GetSize() != windowSize;
 }
 
-bool BasicCompositor::ShouldRecordFrames() const {
-#ifdef MOZ_GECKO_PROFILER
-  if (profiler_feature_active(ProfilerFeature::Screenshots)) {
-    return true;
-  }
-#endif
-  return mRecordFrames;
-}
-
 }  // namespace layers
 }  // namespace mozilla
--- a/gfx/layers/basic/BasicCompositor.h
+++ b/gfx/layers/basic/BasicCompositor.h
@@ -162,20 +162,16 @@ class BasicCompositor : public Composito
   LayersBackend GetBackendType() const override {
     return LayersBackend::LAYERS_BASIC;
   }
 
   bool IsPendingComposite() override { return mIsPendingEndRemoteDrawing; }
 
   void FinishPendingComposite() override;
 
-  virtual void RequestAllowFrameRecording(bool aWillRecord) override {
-    mRecordFrames = aWillRecord;
-  }
-
  private:
   template <typename Geometry>
   void DrawGeometry(const Geometry& aGeometry, const gfx::Rect& aRect,
                     const gfx::IntRect& aClipRect,
                     const EffectChain& aEffectChain, gfx::Float aOpacity,
                     const gfx::Matrix4x4& aTransform,
                     const gfx::Rect& aVisibleRect, const bool aEnableAA);
 
@@ -185,29 +181,16 @@ class BasicCompositor : public Composito
                    const gfx::Matrix4x4& aTransform,
                    const gfx::Rect& aVisibleRect) override;
 
   void TryToEndRemoteDrawing();
   void EndRemoteDrawing();
 
   bool NeedsToDeferEndRemoteDrawing();
 
-  /**
-   * Whether or not the compositor should be recording frames.
-   *
-   * When this returns true, the BasicCompositor will keep the
-   * |mFullWindowRenderTarget| as an up-to-date copy of the entire rendered
-   * window. This copy is maintained in NormalDrawingDone().
-   *
-   * This will be true when either we are recording a profile with screenshots
-   * enabled or the |LayerManagerComposite| has requested us to record frames
-   * for the |CompositionRecorder|.
-   */
-  bool ShouldRecordFrames() const;
-
   bool NeedToRecreateFullWindowRenderTarget() const;
 
   // When rendering to a back buffer, this is the front buffer that the contents
   // of the back buffer need to be copied to. Only non-null between
   // BeginFrameForWindow and EndRemoteDrawing, and only when using a back
   // buffer.
   RefPtr<gfx::DrawTarget> mFrontBuffer;
 
@@ -224,17 +207,16 @@ class BasicCompositor : public Composito
   // Non-null in the same cases as mCurrentNativeLayer.
   RefPtr<MacIOSurface> mCurrentIOSurface;
 #endif
 
   gfx::IntRegion mInvalidRegion;
 
   uint32_t mMaxTextureSize;
   bool mIsPendingEndRemoteDrawing;
-  bool mRecordFrames;
   bool mShouldInvalidateWindow = false;
 
   // Where the current frame is being rendered to.
   enum class FrameDestination : uint8_t {
     NO_CURRENT_FRAME,  // before BeginFrameForXYZ or after EndFrame
     WINDOW,            // between BeginFrameForWindow and EndFrame
     TARGET,            // between BeginFrameForTarget and EndFrame
     NATIVE_LAYERS      // between BeginFrameForNativeLayers and EndFrame