Bug 1330037 - Propagate the CompositorOptions to all CompositorWidget instances. r=dvander
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 12 Jan 2017 17:29:42 -0500
changeset 329206 25254cf7bd3f3273e6d0a198e05e48dabb7c825c
parent 329205 cfebe97561fb3c35c99776cb5deaa7607fdf0b21
child 329207 01050a98e53e9ae27fd281a4f3f88555fd10ad21
push id31200
push usercbook@mozilla.com
push dateFri, 13 Jan 2017 09:18:41 +0000
treeherdermozilla-central@eca7348f32d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1330037
milestone53.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 1330037 - Propagate the CompositorOptions to all CompositorWidget instances. r=dvander MozReview-Commit-ID: DFeeo2WNmhZ
gfx/ipc/InProcessCompositorSession.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/tests/gtest/TestCompositor.cpp
widget/CompositorWidget.cpp
widget/CompositorWidget.h
widget/InProcessCompositorWidget.cpp
widget/InProcessCompositorWidget.h
widget/gtk/CompositorWidgetParent.cpp
widget/gtk/CompositorWidgetParent.h
widget/gtk/InProcessX11CompositorWidget.cpp
widget/gtk/InProcessX11CompositorWidget.h
widget/gtk/X11CompositorWidget.cpp
widget/gtk/X11CompositorWidget.h
widget/windows/CompositorWidgetParent.cpp
widget/windows/CompositorWidgetParent.h
widget/windows/InProcessWinCompositorWidget.cpp
widget/windows/InProcessWinCompositorWidget.h
widget/windows/WinCompositorWidget.cpp
widget/windows/WinCompositorWidget.h
widget/windows/nsWindow.cpp
--- a/gfx/ipc/InProcessCompositorSession.cpp
+++ b/gfx/ipc/InProcessCompositorSession.cpp
@@ -29,17 +29,17 @@ InProcessCompositorSession::Create(nsIWi
                                    CSSToLayoutDeviceScale aScale,
                                    const CompositorOptions& aOptions,
                                    bool aUseExternalSurfaceSize,
                                    const gfx::IntSize& aSurfaceSize)
 {
   CompositorWidgetInitData initData;
   aWidget->GetCompositorWidgetInitData(&initData);
 
-  RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aWidget);
+  RefPtr<CompositorWidget> widget = CompositorWidget::CreateLocal(initData, aOptions, aWidget);
   RefPtr<CompositorBridgeChild> child = new CompositorBridgeChild(aLayerManager);
   RefPtr<CompositorBridgeParent> parent =
     child->InitSameProcess(widget, aRootLayerTreeId, aScale, aOptions, aUseExternalSurfaceSize, aSurfaceSize);
 
   return new InProcessCompositorSession(widget, child, parent);
 }
 
 CompositorBridgeParent*
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -1651,17 +1651,17 @@ CompositorBridgeParent::AllocPCompositor
 {
 #if defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
   if (mWidget) {
     // Should not create two widgets on the same compositor.
     return nullptr;
   }
 
   widget::CompositorWidgetParent* widget =
-    new widget::CompositorWidgetParent(aInitData);
+    new widget::CompositorWidgetParent(aInitData, mOptions);
   widget->AddRef();
 
   // Sending the constructor acts as initialization as well.
   mWidget = widget;
   return widget;
 #else
   return nullptr;
 #endif
--- a/gfx/tests/gtest/TestCompositor.cpp
+++ b/gfx/tests/gtest/TestCompositor.cpp
@@ -148,17 +148,18 @@ static already_AddRefed<Compositor> Crea
 static std::vector<LayerManagerData> GetLayerManagers(std::vector<LayersBackend> aBackends)
 {
   std::vector<LayerManagerData> managers;
 
   for (size_t i = 0; i < aBackends.size(); i++) {
     auto backend = aBackends[i];
 
     RefPtr<MockWidget> widget = new MockWidget();
-    RefPtr<widget::CompositorWidget> proxy = new widget::InProcessCompositorWidget(widget);
+    CompositorOptions options;
+    RefPtr<widget::CompositorWidget> proxy = new widget::InProcessCompositorWidget(options, widget);
     RefPtr<Compositor> compositor = CreateTestCompositor(backend, proxy);
 
     RefPtr<LayerManagerComposite> layerManager = new LayerManagerComposite(compositor);
 
     managers.push_back(LayerManagerData(compositor, widget, proxy, layerManager));
   }
 
   return managers;
--- a/widget/CompositorWidget.cpp
+++ b/widget/CompositorWidget.cpp
@@ -5,16 +5,21 @@
 #include "CompositorWidget.h"
 #include "GLConsts.h"
 #include "nsBaseWidget.h"
 #include "VsyncDispatcher.h"
 
 namespace mozilla {
 namespace widget {
 
+CompositorWidget::CompositorWidget(const layers::CompositorOptions& aOptions)
+  : mOptions(aOptions)
+{
+}
+
 CompositorWidget::~CompositorWidget()
 {
 }
 
 already_AddRefed<gfx::DrawTarget>
 CompositorWidget::StartRemoteDrawing()
 {
   return nullptr;
--- a/widget/CompositorWidget.h
+++ b/widget/CompositorWidget.h
@@ -4,16 +4,17 @@
 
 #ifndef mozilla_widget_CompositorWidget_h__
 #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"
 
 class nsIWidget;
 class nsBaseWidget;
 
 namespace mozilla {
 class VsyncObserver;
 namespace layers {
@@ -72,17 +73,19 @@ class CompositorWidget
 {
 public:
   NS_INLINE_DECL_REFCOUNTING(mozilla::widget::CompositorWidget)
 
   /**
    * Create an in-process compositor widget. aWidget may be ignored if the
    * platform does not require it.
    */
-  static RefPtr<CompositorWidget> CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget);
+  static RefPtr<CompositorWidget> CreateLocal(const CompositorWidgetInitData& aInitData,
+                                              const layers::CompositorOptions& aOptions,
+                                              nsIWidget* aWidget);
 
   /**
    * Called before rendering using OMTC. Returns false when the widget is
    * not ready to be rendered (for example while the window is closed).
    *
    * Always called from the compositing thread, which may be the main-thread if
    * OMTC is not enabled.
    */
@@ -247,16 +250,24 @@ public:
   virtual already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing();
 
   /**
    * Observe or unobserve vsync.
    */
   virtual void ObserveVsync(VsyncObserver* aObserver) = 0;
 
   /**
+   * Get the compositor options for the compositor associated with this
+   * CompositorWidget.
+   */
+  const layers::CompositorOptions& GetCompositorOptions() {
+    return mOptions;
+  }
+
+  /**
    * This is only used by out-of-process compositors.
    */
   virtual RefPtr<VsyncObserver> GetVsyncObserver() const;
 
   virtual WinCompositorWidget* AsWindows() {
     return nullptr;
   }
   virtual X11CompositorWidget* AsX11() {
@@ -269,18 +280,21 @@ public:
   /**
    * Return the platform-specific delegate for the widget, if any.
    */
   virtual CompositorWidgetDelegate* AsDelegate() {
     return nullptr;
   }
 
 protected:
+  explicit CompositorWidget(const layers::CompositorOptions& aOptions);
   virtual ~CompositorWidget();
 
   // Back buffer of BasicCompositor
   RefPtr<gfx::DrawTarget> mLastBackBuffer;
+
+  layers::CompositorOptions mOptions;
 };
 
 } // namespace widget
 } // namespace mozilla
 
 #endif
--- a/widget/InProcessCompositorWidget.cpp
+++ b/widget/InProcessCompositorWidget.cpp
@@ -11,29 +11,33 @@
 
 namespace mozilla {
 namespace widget {
 
 // Platforms with no OOP compositor process support use
 // InProcessCompositorWidget by default.
 #if !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
 /* static */ RefPtr<CompositorWidget>
-CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
+CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData,
+                              const layers::CompositorOptions& aOptions,
+                              nsIWidget* aWidget)
 {
   MOZ_ASSERT(aWidget);
 #ifdef MOZ_WIDGET_ANDROID
-  return new AndroidCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
+  return new AndroidCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
 #else
-  return new InProcessCompositorWidget(static_cast<nsBaseWidget*>(aWidget));
+  return new InProcessCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
 #endif
 }
 #endif
 
-InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
- : mWidget(aWidget)
+InProcessCompositorWidget::InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
+                                                     nsBaseWidget* aWidget)
+ : CompositorWidget(aOptions)
+ , mWidget(aWidget)
 {
 }
 
 bool
 InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext)
 {
   return mWidget->PreRender(aContext);
 }
--- a/widget/InProcessCompositorWidget.h
+++ b/widget/InProcessCompositorWidget.h
@@ -10,17 +10,18 @@
 namespace mozilla {
 namespace widget {
 
 // This version of CompositorWidget implements a wrapper around
 // nsBaseWidget.
 class InProcessCompositorWidget : public CompositorWidget
 {
 public:
-  explicit InProcessCompositorWidget(nsBaseWidget* aWidget);
+  explicit InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
+                                     nsBaseWidget* aWidget);
 
   virtual bool PreRender(WidgetRenderingContext* aManager) override;
   virtual void PostRender(WidgetRenderingContext* aManager) override;
   virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
                                   LayoutDeviceIntRect aRect) override;
   virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
                                  LayoutDeviceIntRect aRect) override;
   virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
--- a/widget/gtk/CompositorWidgetParent.cpp
+++ b/widget/gtk/CompositorWidgetParent.cpp
@@ -4,18 +4,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "CompositorWidgetParent.h"
 #include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace widget {
 
-CompositorWidgetParent::CompositorWidgetParent(const CompositorWidgetInitData& aInitData)
- : X11CompositorWidget(aInitData)
+CompositorWidgetParent::CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
+                                               const layers::CompositorOptions& aOptions)
+ : X11CompositorWidget(aInitData, aOptions)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
 }
 
 CompositorWidgetParent::~CompositorWidgetParent()
 {
 }
 
--- a/widget/gtk/CompositorWidgetParent.h
+++ b/widget/gtk/CompositorWidgetParent.h
@@ -12,17 +12,18 @@
 namespace mozilla {
 namespace widget {
 
 class CompositorWidgetParent final
  : public PCompositorWidgetParent,
    public X11CompositorWidget
 {
 public:
-  explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData);
+  explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
+                                  const layers::CompositorOptions& aOptions);
   ~CompositorWidgetParent() override;
 
   void ActorDestroy(ActorDestroyReason aWhy) override { }
 
   void ObserveVsync(VsyncObserver* aObserver) override;
   RefPtr<VsyncObserver> GetVsyncObserver() const override;
 
   mozilla::ipc::IPCResult RecvNotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize) override;
--- a/widget/gtk/InProcessX11CompositorWidget.cpp
+++ b/widget/gtk/InProcessX11CompositorWidget.cpp
@@ -6,24 +6,27 @@
 #include "InProcessX11CompositorWidget.h"
 
 #include "nsWindow.h"
 
 namespace mozilla {
 namespace widget {
 
 /* static */ RefPtr<CompositorWidget>
-CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
+CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData,
+                              const layers::CompositorOptions& aOptions,
+                              nsIWidget* aWidget)
 {
-  return new InProcessX11CompositorWidget(aInitData, static_cast<nsWindow*>(aWidget));
+  return new InProcessX11CompositorWidget(aInitData, aOptions, static_cast<nsWindow*>(aWidget));
 }
 
 InProcessX11CompositorWidget::InProcessX11CompositorWidget(const CompositorWidgetInitData& aInitData,
+                                                           const layers::CompositorOptions& aOptions,
                                                            nsWindow* aWindow)
-  : X11CompositorWidget(aInitData, aWindow)
+  : X11CompositorWidget(aInitData, aOptions, aWindow)
 {
 }
 
 void
 InProcessX11CompositorWidget::ObserveVsync(VsyncObserver* aObserver)
 {
   if (RefPtr<CompositorVsyncDispatcher> cvd = mWidget->GetCompositorVsyncDispatcher()) {
     cvd->SetCompositorVsyncObserver(aObserver);
--- a/widget/gtk/InProcessX11CompositorWidget.h
+++ b/widget/gtk/InProcessX11CompositorWidget.h
@@ -12,16 +12,17 @@ class nsWindow;
 
 namespace mozilla {
 namespace widget {
 
 class InProcessX11CompositorWidget final : public X11CompositorWidget
 {
 public:
   InProcessX11CompositorWidget(const CompositorWidgetInitData& aInitData,
+                               const layers::CompositorOptions& aOptions,
                                nsWindow* aWindow);
 
   // CompositorWidgetDelegate
 
   void ObserveVsync(VsyncObserver* aObserver) override;
 };
 
 } // namespace widget
--- a/widget/gtk/X11CompositorWidget.cpp
+++ b/widget/gtk/X11CompositorWidget.cpp
@@ -10,18 +10,20 @@
 #include "mozilla/widget/InProcessCompositorWidget.h"
 #include "mozilla/widget/PlatformWidgetTypes.h"
 #include "nsWindow.h"
 
 namespace mozilla {
 namespace widget {
 
 X11CompositorWidget::X11CompositorWidget(const CompositorWidgetInitData& aInitData,
+                                         const CompositorOptions& aOptions,
                                          nsWindow* aWindow)
-      : mWidget(aWindow)
+      : CompositorWidget(aOptions)
+      , mWidget(aWindow)
 {
   // If we have a nsWindow, then grab the already existing display connection
   // If we don't, then use the init data to connect to the display
   if (aWindow) {
     mXDisplay = aWindow->XDisplay();
   } else {
     mXDisplay = XOpenDisplay(aInitData.XDisplayString().get());
   }
--- a/widget/gtk/X11CompositorWidget.h
+++ b/widget/gtk/X11CompositorWidget.h
@@ -22,16 +22,17 @@ public:
 };
 
 class X11CompositorWidget
  : public CompositorWidget
  , public CompositorWidgetDelegate
 {
 public:
   X11CompositorWidget(const CompositorWidgetInitData& aInitData,
+                      const layers::CompositorOptions& aOptions,
                       nsWindow* aWindow = nullptr);
   ~X11CompositorWidget();
 
   // CompositorWidget Overrides
 
   already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
   void EndRemoteDrawing() override;
 
--- a/widget/windows/CompositorWidgetParent.cpp
+++ b/widget/windows/CompositorWidgetParent.cpp
@@ -5,18 +5,19 @@
 
 #include "CompositorWidgetParent.h"
 
 #include "mozilla/Unused.h"
 
 namespace mozilla {
 namespace widget {
 
-CompositorWidgetParent::CompositorWidgetParent(const CompositorWidgetInitData& aInitData)
- : WinCompositorWidget(aInitData)
+CompositorWidgetParent::CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
+                                               const layers::CompositorOptions& aOptions)
+ : WinCompositorWidget(aInitData, aOptions)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_GPU);
 }
 
 CompositorWidgetParent::~CompositorWidgetParent()
 {
 }
 
--- a/widget/windows/CompositorWidgetParent.h
+++ b/widget/windows/CompositorWidgetParent.h
@@ -12,17 +12,18 @@
 namespace mozilla {
 namespace widget {
 
 class CompositorWidgetParent final
  : public PCompositorWidgetParent,
    public WinCompositorWidget
 {
 public:
-  explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData);
+  explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
+                                  const layers::CompositorOptions& aOptions);
   ~CompositorWidgetParent() override;
 
   mozilla::ipc::IPCResult RecvEnterPresentLock() override;
   mozilla::ipc::IPCResult RecvLeavePresentLock() override;
   mozilla::ipc::IPCResult RecvUpdateTransparency(const int32_t& aMode) override;
   mozilla::ipc::IPCResult RecvClearTransparentWindow() override;
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
--- a/widget/windows/InProcessWinCompositorWidget.cpp
+++ b/widget/windows/InProcessWinCompositorWidget.cpp
@@ -5,24 +5,27 @@
 
 #include "InProcessWinCompositorWidget.h"
 #include "nsWindow.h"
 
 namespace mozilla {
 namespace widget {
 
 /* static */ RefPtr<CompositorWidget>
-CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData, nsIWidget* aWidget)
+CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData,
+                              const layers::CompositorOptions& aOptions,
+                              nsIWidget* aWidget)
 {
-  return new InProcessWinCompositorWidget(aInitData, static_cast<nsWindow*>(aWidget));
+  return new InProcessWinCompositorWidget(aInitData, aOptions, static_cast<nsWindow*>(aWidget));
 }
 
 InProcessWinCompositorWidget::InProcessWinCompositorWidget(const CompositorWidgetInitData& aInitData,
+                                                           const layers::CompositorOptions& aOptions,
                                                            nsWindow* aWindow)
- : WinCompositorWidget(aInitData),
+ : WinCompositorWidget(aInitData, aOptions),
    mWindow(aWindow)
 {
   MOZ_ASSERT(mWindow);
 }
 
 nsIWidget*
 InProcessWinCompositorWidget::RealWidget()
 {
--- a/widget/windows/InProcessWinCompositorWidget.h
+++ b/widget/windows/InProcessWinCompositorWidget.h
@@ -15,17 +15,19 @@ namespace widget {
 
 // This is the Windows-specific implementation of CompositorWidget. For
 // the most part it only requires an HWND, however it maintains extra state
 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
 // with the compositor.
 class InProcessWinCompositorWidget final : public WinCompositorWidget
 {
 public:
-  InProcessWinCompositorWidget(const CompositorWidgetInitData& aInitData, nsWindow* aWindow);
+  InProcessWinCompositorWidget(const CompositorWidgetInitData& aInitData,
+                               const layers::CompositorOptions& aOptions,
+                               nsWindow* aWindow);
 
   void ObserveVsync(VsyncObserver* aObserver) override;
   nsIWidget* RealWidget() override;
 
 private:
   nsWindow* mWindow;
 };
 
--- a/widget/windows/WinCompositorWidget.cpp
+++ b/widget/windows/WinCompositorWidget.cpp
@@ -14,18 +14,20 @@
 
 #include <ddraw.h>
 
 namespace mozilla {
 namespace widget {
 
 using namespace mozilla::gfx;
 
-WinCompositorWidget::WinCompositorWidget(const CompositorWidgetInitData& aInitData)
- : mWidgetKey(aInitData.widgetKey()),
+WinCompositorWidget::WinCompositorWidget(const CompositorWidgetInitData& aInitData,
+                                         const layers::CompositorOptions& aOptions)
+ : CompositorWidget(aOptions)
+ , mWidgetKey(aInitData.widgetKey()),
    mWnd(reinterpret_cast<HWND>(aInitData.hWnd())),
    mTransparencyMode(static_cast<nsTransparencyMode>(aInitData.transparencyMode())),
    mMemoryDC(nullptr),
    mCompositeDC(nullptr),
    mLockedBackBufferData(nullptr)
 {
   MOZ_ASSERT(mWnd && ::IsWindow(mWnd));
 
--- a/widget/windows/WinCompositorWidget.h
+++ b/widget/windows/WinCompositorWidget.h
@@ -38,17 +38,18 @@ public:
 // the most part it only requires an HWND, however it maintains extra state
 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
 // with the compositor.
 class WinCompositorWidget
  : public CompositorWidget,
    public CompositorWidgetDelegate
 {
 public:
-  WinCompositorWidget(const CompositorWidgetInitData& aInitData);
+  WinCompositorWidget(const CompositorWidgetInitData& aInitData,
+                      const layers::CompositorOptions& aOptions);
 
   bool PreRender(WidgetRenderingContext*) override;
   void PostRender(WidgetRenderingContext*) override;
   already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
   void EndRemoteDrawing() override;
   bool NeedsToDeferEndRemoteDrawing() override;
   LayoutDeviceIntSize GetClientSize() override;
   already_AddRefed<gfx::DrawTarget> GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget,
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -3896,17 +3896,19 @@ nsWindow::GetLayerManager(PLayerTransact
     MOZ_ASSERT(!mCompositorWidgetDelegate);
 
     // Ensure we have a widget proxy even if we're not using the compositor,
     // since all our transparent window handling lives there.
     CompositorWidgetInitData initData(
       reinterpret_cast<uintptr_t>(mWnd),
       reinterpret_cast<uintptr_t>(static_cast<nsIWidget*>(this)),
       mTransparencyMode);
-    mBasicLayersSurface = new InProcessWinCompositorWidget(initData, this);
+    // If we're not using the compositor, the options don't actually matter.
+    CompositorOptions options(false);
+    mBasicLayersSurface = new InProcessWinCompositorWidget(initData, options, this);
     mCompositorWidgetDelegate = mBasicLayersSurface;
     mLayerManager = CreateBasicLayerManager();
   }
 
   NS_ASSERTION(mLayerManager, "Couldn't provide a valid layer manager.");
 
   return mLayerManager;
 }