Move InProcessCompositorWidget to its own file. (bug 1281998 part 3, r=jimm)
☠☠ backed out by 48bd14a01b55 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Wed, 29 Jun 2016 16:47:22 -0400
changeset 303197 54a0e73f69069c1b5c180a88ead3e9e06f1ce72c
parent 303196 99d1da1293b7af8a5a42612a103d81b3b7edfc22
child 303198 74198f88fa3715d5f7a01b7186af341a540614b6
push id30382
push usercbook@mozilla.com
push dateThu, 30 Jun 2016 10:34:10 +0000
treeherdermozilla-central@bcf4ff0c3eef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1281998
milestone50.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
Move InProcessCompositorWidget to its own file. (bug 1281998 part 3, r=jimm)
gfx/ipc/CompositorSession.cpp
gfx/tests/gtest/TestCompositor.cpp
widget/CompositorWidget.cpp
widget/CompositorWidget.h
widget/InProcessCompositorWidget.cpp
widget/InProcessCompositorWidget.h
widget/moz.build
widget/nsBaseWidget.cpp
--- a/gfx/ipc/CompositorSession.cpp
+++ b/gfx/ipc/CompositorSession.cpp
@@ -6,16 +6,18 @@
 #include "CompositorSession.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "base/process_util.h"
 
 namespace mozilla {
 namespace layers {
 
+using namespace widget;
+
 class InProcessCompositorSession final : public CompositorSession
 {
 public:
   InProcessCompositorSession(
     widget::CompositorWidget* aWidget,
     ClientLayerManager* aLayerManager,
     CSSToLayoutDeviceScale aScale,
     bool aUseAPZ,
--- a/gfx/tests/gtest/TestCompositor.cpp
+++ b/gfx/tests/gtest/TestCompositor.cpp
@@ -10,16 +10,17 @@
 #include "TestLayers.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/layers/BasicCompositor.h"  // for BasicCompositor
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/CompositorOGL.h"  // for CompositorOGL
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/LayerManagerComposite.h"
+#include "mozilla/widget/InProcessCompositorWidget.h"
 #include "nsBaseWidget.h"
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include <vector>
 
 const int gCompWidth = 256;
 const int gCompHeight = 256;
 
@@ -152,17 +153,17 @@ 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 = widget->NewCompositorWidget();
+    RefPtr<widget::CompositorWidget> proxy = new widget::InProcessCompositorWidget(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
@@ -65,122 +65,10 @@ CompositorWidget::EndBackBufferDrawing()
 }
 
 uint32_t
 CompositorWidget::GetGLFrameBufferFormat()
 {
   return LOCAL_GL_RGBA;
 }
 
-InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
- : mWidget(aWidget)
-{
-}
-
-bool
-InProcessCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
-{
-  return mWidget->PreRender(aManager);
-}
-
-void
-InProcessCompositorWidget::PostRender(layers::LayerManagerComposite* aManager)
-{
-  mWidget->PostRender(aManager);
-}
-
-void
-InProcessCompositorWidget::DrawWindowUnderlay(layers::LayerManagerComposite* aManager,
-                                          LayoutDeviceIntRect aRect)
-{
-  mWidget->DrawWindowUnderlay(aManager, aRect);
-}
-
-void
-InProcessCompositorWidget::DrawWindowOverlay(layers::LayerManagerComposite* aManager,
-                                         LayoutDeviceIntRect aRect)
-{
-  mWidget->DrawWindowOverlay(aManager, aRect);
-}
-
-already_AddRefed<gfx::DrawTarget>
-InProcessCompositorWidget::StartRemoteDrawing()
-{
-  return mWidget->StartRemoteDrawing();
-}
-
-already_AddRefed<gfx::DrawTarget>
-InProcessCompositorWidget::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
-                                                  layers::BufferMode* aBufferMode)
-{
-  return mWidget->StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
-}
-
-void
-InProcessCompositorWidget::EndRemoteDrawing()
-{
-  mWidget->EndRemoteDrawing();
-}
-
-void
-InProcessCompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
-                                                LayoutDeviceIntRegion& aInvalidRegion)
-{
-  mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
-}
-
-void
-InProcessCompositorWidget::CleanupRemoteDrawing()
-{
-  mWidget->CleanupRemoteDrawing();
-}
-
-void
-InProcessCompositorWidget::CleanupWindowEffects()
-{
-  mWidget->CleanupWindowEffects();
-}
-
-bool
-InProcessCompositorWidget::InitCompositor(layers::Compositor* aCompositor)
-{
-  return mWidget->InitCompositor(aCompositor);
-}
-
-LayoutDeviceIntSize
-InProcessCompositorWidget::GetClientSize()
-{
-  return mWidget->GetClientSize();
-}
-
-uint32_t
-InProcessCompositorWidget::GetGLFrameBufferFormat()
-{
-  return mWidget->GetGLFrameBufferFormat();
-}
-
-layers::Composer2D*
-InProcessCompositorWidget::GetComposer2D()
-{
-  return mWidget->GetComposer2D();
-}
-
-uintptr_t
-InProcessCompositorWidget::GetWidgetKey()
-{
-  return reinterpret_cast<uintptr_t>(mWidget);
-}
-
-nsIWidget*
-InProcessCompositorWidget::RealWidget()
-{
-  return mWidget;
-}
-
-already_AddRefed<CompositorVsyncDispatcher>
-InProcessCompositorWidget::GetCompositorVsyncDispatcher()
-{
-  RefPtr<CompositorVsyncDispatcher> cvd = mWidget->GetCompositorVsyncDispatcher();
-  return cvd.forget();
-}
-
 } // namespace widget
 } // namespace mozilla
--- a/widget/CompositorWidget.h
+++ b/widget/CompositorWidget.h
@@ -206,48 +206,12 @@ public:
 
 protected:
   virtual ~CompositorWidget();
 
   // Back buffer of BasicCompositor
   RefPtr<gfx::DrawTarget> mLastBackBuffer;
 };
 
-// This version of CompositorWidget implements a wrapper around
-// nsBaseWidget.
-class InProcessCompositorWidget : public CompositorWidget
-{
-public:
-  explicit InProcessCompositorWidget(nsBaseWidget* aWidget);
-
-  virtual bool PreRender(layers::LayerManagerComposite* aManager) override;
-  virtual void PostRender(layers::LayerManagerComposite* aManager) override;
-  virtual void DrawWindowUnderlay(layers::LayerManagerComposite* aManager,
-                                  LayoutDeviceIntRect aRect) override;
-  virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager,
-                                 LayoutDeviceIntRect aRect) override;
-  virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
-  virtual already_AddRefed<gfx::DrawTarget>
-  StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
-                             layers::BufferMode* aBufferMode) override;
-  virtual void EndRemoteDrawing() override;
-  virtual void EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
-                                        LayoutDeviceIntRegion& aInvalidRegion) override;
-  virtual void CleanupRemoteDrawing() override;
-  virtual void CleanupWindowEffects() override;
-  virtual bool InitCompositor(layers::Compositor* aCompositor) override;
-  virtual LayoutDeviceIntSize GetClientSize() override;
-  virtual uint32_t GetGLFrameBufferFormat() override;
-  virtual layers::Composer2D* GetComposer2D() override;
-  virtual already_AddRefed<CompositorVsyncDispatcher> GetCompositorVsyncDispatcher() override;
-  virtual uintptr_t GetWidgetKey() override;
-
-  // If you can override this method, inherit from CompositorWidget instead.
-  nsIWidget* RealWidget() override;
-
-private:
-  nsBaseWidget* mWidget;
-};
-
 } // namespace widget
 } // namespace mozilla
 
 #endif
copy from widget/CompositorWidget.cpp
copy to widget/InProcessCompositorWidget.cpp
--- a/widget/CompositorWidget.cpp
+++ b/widget/InProcessCompositorWidget.cpp
@@ -1,80 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "CompositorWidget.h"
-#include "GLConsts.h"
-#include "nsBaseWidget.h"
-#include "VsyncDispatcher.h"
+#include "InProcessCompositorWidget.h"
 
 namespace mozilla {
 namespace widget {
 
-CompositorWidget::~CompositorWidget()
-{
-}
-
-already_AddRefed<gfx::DrawTarget>
-CompositorWidget::StartRemoteDrawing()
-{
-  return nullptr;
-}
-
-void
-CompositorWidget::CleanupRemoteDrawing()
-{
-  mLastBackBuffer = nullptr;
-}
-
-already_AddRefed<gfx::DrawTarget>
-CompositorWidget::GetBackBufferDrawTarget(gfx::DrawTarget* aScreenTarget,
-                                          const LayoutDeviceIntRect& aRect,
-                                          const LayoutDeviceIntRect& aClearRect)
-{
-  MOZ_ASSERT(aScreenTarget);
-  gfx::SurfaceFormat format =
-    aScreenTarget->GetFormat() == gfx::SurfaceFormat::B8G8R8X8 ? gfx::SurfaceFormat::B8G8R8X8 : gfx::SurfaceFormat::B8G8R8A8;
-  gfx::IntSize size = aRect.ToUnknownRect().Size();
-  gfx::IntSize clientSize(GetClientSize().ToUnknownSize());
-
-  RefPtr<gfx::DrawTarget> target;
-  // Re-use back buffer if possible
-  if (mLastBackBuffer &&
-      mLastBackBuffer->GetBackendType() == aScreenTarget->GetBackendType() &&
-      mLastBackBuffer->GetFormat() == format &&
-      size <= mLastBackBuffer->GetSize() &&
-      mLastBackBuffer->GetSize() <= clientSize) {
-    target = mLastBackBuffer;
-    target->SetTransform(gfx::Matrix());
-    if (!aClearRect.IsEmpty()) {
-      gfx::IntRect clearRect = aClearRect.ToUnknownRect() - aRect.ToUnknownRect().TopLeft();
-      target->ClearRect(gfx::Rect(clearRect.x, clearRect.y, clearRect.width, clearRect.height));
-    }
-  } else {
-    target = aScreenTarget->CreateSimilarDrawTarget(size, format);
-    mLastBackBuffer = target;
-  }
-  return target.forget();
-}
-
-already_AddRefed<gfx::SourceSurface>
-CompositorWidget::EndBackBufferDrawing()
-{
-  RefPtr<gfx::SourceSurface> surface = mLastBackBuffer ? mLastBackBuffer->Snapshot() : nullptr;
-  return surface.forget();
-}
-
-uint32_t
-CompositorWidget::GetGLFrameBufferFormat()
-{
-  return LOCAL_GL_RGBA;
-}
-
 InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
  : mWidget(aWidget)
 {
 }
 
 bool
 InProcessCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
 {
@@ -179,8 +116,9 @@ already_AddRefed<CompositorVsyncDispatch
 InProcessCompositorWidget::GetCompositorVsyncDispatcher()
 {
   RefPtr<CompositorVsyncDispatcher> cvd = mWidget->GetCompositorVsyncDispatcher();
   return cvd.forget();
 }
 
 } // namespace widget
 } // namespace mozilla
+
new file mode 100644
--- /dev/null
+++ b/widget/InProcessCompositorWidget.h
@@ -0,0 +1,52 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_widget_InProcessCompositorWidget_h__
+#define mozilla_widget_InProcessCompositorWidget_h__
+
+#include "CompositorWidget.h"
+
+namespace mozilla {
+namespace widget {
+
+// This version of CompositorWidget implements a wrapper around
+// nsBaseWidget.
+class InProcessCompositorWidget : public CompositorWidget
+{
+public:
+  explicit InProcessCompositorWidget(nsBaseWidget* aWidget);
+
+  virtual bool PreRender(layers::LayerManagerComposite* aManager) override;
+  virtual void PostRender(layers::LayerManagerComposite* aManager) override;
+  virtual void DrawWindowUnderlay(layers::LayerManagerComposite* aManager,
+                                  LayoutDeviceIntRect aRect) override;
+  virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager,
+                                 LayoutDeviceIntRect aRect) override;
+  virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
+  virtual already_AddRefed<gfx::DrawTarget>
+  StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
+                             layers::BufferMode* aBufferMode) override;
+  virtual void EndRemoteDrawing() override;
+  virtual void EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
+                                        LayoutDeviceIntRegion& aInvalidRegion) override;
+  virtual void CleanupRemoteDrawing() override;
+  virtual void CleanupWindowEffects() override;
+  virtual bool InitCompositor(layers::Compositor* aCompositor) override;
+  virtual LayoutDeviceIntSize GetClientSize() override;
+  virtual uint32_t GetGLFrameBufferFormat() override;
+  virtual layers::Composer2D* GetComposer2D() override;
+  virtual already_AddRefed<CompositorVsyncDispatcher> GetCompositorVsyncDispatcher() override;
+  virtual uintptr_t GetWidgetKey() override;
+
+  // If you can override this method, inherit from CompositorWidget instead.
+  nsIWidget* RealWidget() override;
+
+private:
+  nsBaseWidget* mWidget;
+};
+
+} // namespace widget
+} // namespace mozilla
+
+#endif
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -125,27 +125,29 @@ EXPORTS.mozilla += [
     'TouchEvents.h',
     'VsyncDispatcher.h',
     'WidgetUtils.h',
 ]
 
 EXPORTS.mozilla.widget += [
     'CompositorWidget.h',
     'IMEData.h',
+    'InProcessCompositorWidget.h',
     'PuppetBidiKeyboard.h',
     'WidgetMessageUtils.h',
 ]
 
 UNIFIED_SOURCES += [
     'CompositorWidget.cpp',
     'ContentCache.cpp',
     'GfxDriverInfo.cpp',
     'GfxInfoBase.cpp',
     'GfxInfoCollector.cpp',
     'GfxInfoWebGL.cpp',
+    'InProcessCompositorWidget.cpp',
     'InputData.cpp',
     'nsBaseAppShell.cpp',
     'nsBaseScreen.cpp',
     'nsClipboardHelper.cpp',
     'nsClipboardProxy.cpp',
     'nsColorPickerProxy.cpp',
     'nsContentProcessWidgetFactory.cpp',
     'nsDatePickerProxy.cpp',
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -67,16 +67,17 @@
 #include "WritingModes.h"
 #include "InputData.h"
 #include "FrameLayerBuilder.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
 #include "gfxConfig.h"
 #include "mozilla/layers/CompositorSession.h"
+#include "InProcessCompositorWidget.h"
 
 #ifdef DEBUG
 #include "nsIObserver.h"
 
 static void debug_RegisterPrefCallbacks();
 
 #endif