Skip to content

Commit

Permalink
Move InProcessCompositorWidget to its own file. (bug 1281998 part 3, …
Browse files Browse the repository at this point in the history
…r=jimm)

--HG--
rename : widget/CompositorWidget.cpp => widget/InProcessCompositorWidget.cpp
  • Loading branch information
David Anderson committed Jul 1, 2016
1 parent 3f0ea05 commit 56c221c
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 149 deletions.
2 changes: 2 additions & 0 deletions gfx/ipc/CompositorSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
namespace mozilla {
namespace layers {

using namespace widget;

class InProcessCompositorSession final : public CompositorSession
{
public:
Expand Down
3 changes: 2 additions & 1 deletion gfx/tests/gtest/TestCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -157,7 +158,7 @@ static std::vector<LayerManagerData> GetLayerManagers(std::vector<LayersBackend>
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);
Expand Down
112 changes: 0 additions & 112 deletions widget/CompositorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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
36 changes: 0 additions & 36 deletions widget/CompositorWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,42 +211,6 @@ class CompositorWidget
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

Expand Down
124 changes: 124 additions & 0 deletions widget/InProcessCompositorWidget.cpp
Original file line number Diff line number Diff line change
@@ -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<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

52 changes: 52 additions & 0 deletions widget/InProcessCompositorWidget.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions widget/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ EXPORTS.mozilla += [
EXPORTS.mozilla.widget += [
'CompositorWidget.h',
'IMEData.h',
'InProcessCompositorWidget.h',
'PuppetBidiKeyboard.h',
'WidgetMessageUtils.h',
]
Expand All @@ -141,6 +142,7 @@ UNIFIED_SOURCES += [
'GfxInfoBase.cpp',
'GfxInfoCollector.cpp',
'GfxInfoWebGL.cpp',
'InProcessCompositorWidget.cpp',
'InputData.cpp',
'nsBaseAppShell.cpp',
'nsBaseScreen.cpp',
Expand Down
1 change: 1 addition & 0 deletions widget/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#endif
#include "gfxConfig.h"
#include "mozilla/layers/CompositorSession.h"
#include "InProcessCompositorWidget.h"

#ifdef DEBUG
#include "nsIObserver.h"
Expand Down

0 comments on commit 56c221c

Please sign in to comment.