Bug 1574592 - Add CompositorWidget::GetNativeLayerRoot. r=mattwoodrow
authorMarkus Stange <mstange@themasta.com>
Sun, 25 Aug 2019 17:10:52 +0000
changeset 553556 de0c56e1ffad7de4e606b77a1f7156772f857569
parent 553555 0b6e738b45ea147530bff7dab828026cfad693a2
child 553557 c6d52b09f158420ec69829adb7d3815073c85392
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
bugs1574592
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 1574592 - Add CompositorWidget::GetNativeLayerRoot. r=mattwoodrow This will give the layer manager direct access to the native layers. Differential Revision: https://phabricator.services.mozilla.com/D42400
widget/CompositorWidget.h
widget/InProcessCompositorWidget.cpp
widget/InProcessCompositorWidget.h
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
widget/nsBaseWidget.h
--- a/widget/CompositorWidget.h
+++ b/widget/CompositorWidget.h
@@ -6,16 +6,17 @@
 #define mozilla_widget_CompositorWidget_h__
 
 #include "nsISupports.h"
 #include "mozilla/RefPtr.h"
 #include "Units.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/layers/CompositorOptions.h"
 #include "mozilla/layers/LayersTypes.h"
+#include "mozilla/layers/NativeLayer.h"
 
 class nsIWidget;
 class nsBaseWidget;
 
 namespace mozilla {
 class VsyncObserver;
 namespace gl {
 class GLContext;
@@ -118,16 +119,20 @@ class CompositorWidget {
 
   /**
    * Called on the same thread as PreRender/PostRender during destruction.
    * This method gives the widget a chance to do any cleanup for state that it
    * created during PreRender / PostRender.
    */
   virtual void DoCompositorCleanup() {}
 
+  virtual RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() {
+    return nullptr;
+  }
+
   /**
    * Called before the LayerManager draws the layer tree.
    *
    * Always called from the compositing thread.
    */
   virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
                                   LayoutDeviceIntRect aRect) {}
 
--- a/widget/InProcessCompositorWidget.cpp
+++ b/widget/InProcessCompositorWidget.cpp
@@ -43,16 +43,21 @@ bool InProcessCompositorWidget::PreRende
 void InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext) {
   mWidget->PostRender(aContext);
 }
 
 void InProcessCompositorWidget::DoCompositorCleanup() {
   mWidget->DoCompositorCleanup();
 }
 
+RefPtr<layers::NativeLayerRoot>
+InProcessCompositorWidget::GetNativeLayerRoot() {
+  return mWidget->GetNativeLayerRoot();
+}
+
 void InProcessCompositorWidget::DrawWindowUnderlay(
     WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
   mWidget->DrawWindowUnderlay(aContext, aRect);
 }
 
 void InProcessCompositorWidget::DrawWindowOverlay(
     WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
   mWidget->DrawWindowOverlay(aContext, aRect);
--- a/widget/InProcessCompositorWidget.h
+++ b/widget/InProcessCompositorWidget.h
@@ -15,16 +15,17 @@ namespace widget {
 class InProcessCompositorWidget : public CompositorWidget {
  public:
   explicit InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
                                      nsBaseWidget* aWidget);
 
   virtual bool PreRender(WidgetRenderingContext* aManager) override;
   virtual void PostRender(WidgetRenderingContext* aManager) override;
   virtual void DoCompositorCleanup() override;
+  virtual RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() override;
   virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
                                   LayoutDeviceIntRect aRect) override;
   virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
                                  LayoutDeviceIntRect aRect) override;
   virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
   virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
       LayoutDeviceIntRegion& aInvalidRegion,
       layers::BufferMode* aBufferMode) override;
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -493,16 +493,17 @@ class nsChildView final : public nsBaseW
   virtual void AddWindowOverlayWebRenderCommands(
       mozilla::layers::WebRenderBridgeChild* aWrBridge, mozilla::wr::DisplayListBuilder& aBuilder,
       mozilla::wr::IpcResourceUpdateQueue& aResourceUpdates) override;
 
   virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
   bool PreRenderImpl(mozilla::widget::WidgetRenderingContext* aContext);
   virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;
   virtual void DoCompositorCleanup() override;
+  virtual RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() override;
   virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aManager,
                                  LayoutDeviceIntRect aRect) override;
 
   virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
 
   virtual void UpdateWindowDraggingRegion(const LayoutDeviceIntRegion& aRegion) override;
   LayoutDeviceIntRegion GetNonDraggableRegion() { return mNonDraggableRegion.Region(); }
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2081,16 +2081,18 @@ void nsChildView::PostRender(WidgetRende
 }
 
 void nsChildView::DoCompositorCleanup() {
   if (mContentLayer) {
     mContentLayer->SetSurfaceRegistry(nullptr);
   }
 }
 
+RefPtr<layers::NativeLayerRoot> nsChildView::GetNativeLayerRoot() { return mNativeLayerRoot; }
+
 void nsChildView::DrawWindowOverlay(WidgetRenderingContext* aContext, LayoutDeviceIntRect aRect) {
   mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
   if (manager) {
     DrawWindowOverlay(manager.get(), aRect);
   }
 }
 
 void nsChildView::DrawWindowOverlay(GLManager* aManager, LayoutDeviceIntRect aRect) {
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -8,16 +8,17 @@
 #include "InputData.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/WidgetUtils.h"
 #include "mozilla/layers/APZCCallbackHelper.h"
 #include "mozilla/layers/CompositorOptions.h"
+#include "mozilla/layers/NativeLayer.h"
 #include "nsRect.h"
 #include "nsIWidget.h"
 #include "nsWidgetsCID.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsIRollupListener.h"
 #include "nsIObserver.h"
@@ -444,16 +445,19 @@ class nsBaseWidget : public nsIWidget, p
   // These are methods for CompositorWidgetWrapper, and should only be
   // accessed from that class. Derived widgets can choose which methods to
   // implement, or none if supporting out-of-process compositing.
   virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) {
     return true;
   }
   virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) {}
   virtual void DoCompositorCleanup() {}
+  virtual RefPtr<mozilla::layers::NativeLayerRoot> GetNativeLayerRoot() {
+    return nullptr;
+  }
   virtual void DrawWindowUnderlay(
       mozilla::widget::WidgetRenderingContext* aContext,
       LayoutDeviceIntRect aRect) {}
   virtual void DrawWindowOverlay(
       mozilla::widget::WidgetRenderingContext* aContext,
       LayoutDeviceIntRect aRect) {}
   virtual already_AddRefed<DrawTarget> StartRemoteDrawing();
   virtual already_AddRefed<DrawTarget> StartRemoteDrawingInRegion(