diff --git a/gfx/ipc/CompositorSession.cpp b/gfx/ipc/CompositorSession.cpp index ec403160f3ae1..fac7d9f5d3f2c 100644 --- a/gfx/ipc/CompositorSession.cpp +++ b/gfx/ipc/CompositorSession.cpp @@ -11,6 +11,8 @@ namespace mozilla { namespace layers { +using namespace widget; + class InProcessCompositorSession final : public CompositorSession { public: diff --git a/gfx/tests/gtest/TestCompositor.cpp b/gfx/tests/gtest/TestCompositor.cpp index 71eb9a346f237..2a10b2b94b3a3 100644 --- a/gfx/tests/gtest/TestCompositor.cpp +++ b/gfx/tests/gtest/TestCompositor.cpp @@ -15,6 +15,7 @@ #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" @@ -157,7 +158,7 @@ static std::vector GetLayerManagers(std::vector auto backend = aBackends[i]; RefPtr widget = new MockWidget(); - RefPtr proxy = widget->NewCompositorWidget(); + RefPtr proxy = new widget::InProcessCompositorWidget(widget); RefPtr compositor = CreateTestCompositor(backend, proxy); RefPtr layerManager = new LayerManagerComposite(compositor); diff --git a/widget/CompositorWidget.cpp b/widget/CompositorWidget.cpp index 9dff790e5107c..f5b86f1152ab3 100644 --- a/widget/CompositorWidget.cpp +++ b/widget/CompositorWidget.cpp @@ -70,117 +70,5 @@ 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 -InProcessCompositorWidget::StartRemoteDrawing() -{ - return mWidget->StartRemoteDrawing(); -} - -already_AddRefed -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(mWidget); -} - -nsIWidget* -InProcessCompositorWidget::RealWidget() -{ - return mWidget; -} - -already_AddRefed -InProcessCompositorWidget::GetCompositorVsyncDispatcher() -{ - RefPtr cvd = mWidget->GetCompositorVsyncDispatcher(); - return cvd.forget(); -} - } // namespace widget } // namespace mozilla diff --git a/widget/CompositorWidget.h b/widget/CompositorWidget.h index 1c6fff48debd2..0ad2c462462ee 100644 --- a/widget/CompositorWidget.h +++ b/widget/CompositorWidget.h @@ -211,42 +211,6 @@ class CompositorWidget RefPtr 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 StartRemoteDrawing() override; - virtual already_AddRefed - 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 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 diff --git a/widget/InProcessCompositorWidget.cpp b/widget/InProcessCompositorWidget.cpp new file mode 100644 index 0000000000000..16453250fb6ac --- /dev/null +++ b/widget/InProcessCompositorWidget.cpp @@ -0,0 +1,124 @@ +/* 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 "InProcessCompositorWidget.h" + +namespace mozilla { +namespace widget { + +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 +InProcessCompositorWidget::StartRemoteDrawing() +{ + return mWidget->StartRemoteDrawing(); +} + +already_AddRefed +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(mWidget); +} + +nsIWidget* +InProcessCompositorWidget::RealWidget() +{ + return mWidget; +} + +already_AddRefed +InProcessCompositorWidget::GetCompositorVsyncDispatcher() +{ + RefPtr cvd = mWidget->GetCompositorVsyncDispatcher(); + return cvd.forget(); +} + +} // namespace widget +} // namespace mozilla + diff --git a/widget/InProcessCompositorWidget.h b/widget/InProcessCompositorWidget.h new file mode 100644 index 0000000000000..e41f781bb0633 --- /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 StartRemoteDrawing() override; + virtual already_AddRefed + 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 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 diff --git a/widget/moz.build b/widget/moz.build index 1bac68e8d6509..62c87eda1aaae 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -130,6 +130,7 @@ EXPORTS.mozilla += [ EXPORTS.mozilla.widget += [ 'CompositorWidget.h', 'IMEData.h', + 'InProcessCompositorWidget.h', 'PuppetBidiKeyboard.h', 'WidgetMessageUtils.h', ] @@ -141,6 +142,7 @@ UNIFIED_SOURCES += [ 'GfxInfoBase.cpp', 'GfxInfoCollector.cpp', 'GfxInfoWebGL.cpp', + 'InProcessCompositorWidget.cpp', 'InputData.cpp', 'nsBaseAppShell.cpp', 'nsBaseScreen.cpp', diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index c8d60e03f6666..f519d04cbce79 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -72,6 +72,7 @@ #endif #include "gfxConfig.h" #include "mozilla/layers/CompositorSession.h" +#include "InProcessCompositorWidget.h" #ifdef DEBUG #include "nsIObserver.h"