Bug 1315706 - Pass a wrapper struct to various CompositorWidget functions. r=dvander

This is the first step in using these functions without having a
LayerManagerComposite at all.

MozReview-Commit-ID: 2zkuB7Ox4Ut

--HG--
extra : rebase_source : b23988275f5851a2fd30bd3e8a9931107a224c66
This commit is contained in:
Kartikaya Gupta 2016-11-07 21:16:52 -05:00
Родитель 50ccc2b3a2
Коммит 54c54c7a09
11 изменённых файлов: 72 добавлений и 47 удалений

Просмотреть файл

@ -42,6 +42,7 @@
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc #include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper #include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
#include "mozilla/layers/LayersTypes.h" // for etc #include "mozilla/layers/LayersTypes.h" // for etc
#include "mozilla/widget/CompositorWidget.h" // for WidgetRenderingContext
#include "ipc/CompositorBench.h" // for CompositorBench #include "ipc/CompositorBench.h" // for CompositorBench
#include "ipc/ShadowLayerUtils.h" #include "ipc/ShadowLayerUtils.h"
#include "mozilla/mozalloc.h" // for operator new, etc #include "mozilla/mozalloc.h" // for operator new, etc
@ -911,11 +912,18 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
mLastFrameMissedHWC = !!composer2D; mLastFrameMissedHWC = !!composer2D;
} }
mozilla::widget::WidgetRenderingContext widgetContext;
#if defined(XP_MACOSX)
widgetContext.mLayerManager = this;
#elif defined(MOZ_WIDGET_ANDROID)
widgetContext.mCompositor = GetCompositor();
#endif
{ {
PROFILER_LABEL("LayerManagerComposite", "PreRender", PROFILER_LABEL("LayerManagerComposite", "PreRender",
js::ProfileEntry::Category::GRAPHICS); js::ProfileEntry::Category::GRAPHICS);
if (!mCompositor->GetWidget()->PreRender(this)) { if (!mCompositor->GetWidget()->PreRender(&widgetContext)) {
return; return;
} }
} }
@ -946,13 +954,13 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
} }
if (actualBounds.IsEmpty()) { if (actualBounds.IsEmpty()) {
mCompositor->GetWidget()->PostRender(this); mCompositor->GetWidget()->PostRender(&widgetContext);
return; return;
} }
// Allow widget to render a custom background. // Allow widget to render a custom background.
mCompositor->GetWidget()->DrawWindowUnderlay( mCompositor->GetWidget()->DrawWindowUnderlay(
this, LayoutDeviceIntRect::FromUnknownRect(actualBounds)); &widgetContext, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
RefPtr<CompositingRenderTarget> previousTarget; RefPtr<CompositingRenderTarget> previousTarget;
if (haveLayerEffects) { if (haveLayerEffects) {
@ -980,7 +988,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
// Allow widget to render a custom foreground. // Allow widget to render a custom foreground.
mCompositor->GetWidget()->DrawWindowOverlay( mCompositor->GetWidget()->DrawWindowOverlay(
this, LayoutDeviceIntRect::FromUnknownRect(actualBounds)); &widgetContext, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
// Debugging // Debugging
RenderDebugOverlay(actualBounds); RenderDebugOverlay(actualBounds);
@ -999,7 +1007,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
composer2D->Render(mCompositor->GetWidget()->RealWidget()); composer2D->Render(mCompositor->GetWidget()->RealWidget());
} }
mCompositor->GetWidget()->PostRender(this); mCompositor->GetWidget()->PostRender(&widgetContext);
RecordFrame(); RecordFrame();
} }

Просмотреть файл

@ -53,6 +53,18 @@ class CompositorWidgetChild;
# define MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING # define MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
#endif #endif
class WidgetRenderingContext
{
public:
#if defined(XP_MACOSX)
WidgetRenderingContext() : mLayerManager(nullptr) {}
layers::LayerManagerComposite* mLayerManager;
#elif defined(MOZ_WIDGET_ANDROID)
WidgetRenderingContext() : mCompositor(nullptr) {}
layers::Compositor* mCompositor;
#endif
};
/** /**
* Access to a widget from the compositor is restricted to these methods. * Access to a widget from the compositor is restricted to these methods.
*/ */
@ -74,7 +86,7 @@ public:
* Always called from the compositing thread, which may be the main-thread if * Always called from the compositing thread, which may be the main-thread if
* OMTC is not enabled. * OMTC is not enabled.
*/ */
virtual bool PreRender(layers::LayerManagerComposite* aManager) { virtual bool PreRender(WidgetRenderingContext* aContext) {
return true; return true;
} }
@ -85,7 +97,7 @@ public:
* Always called from the compositing thread, which may be the main-thread if * Always called from the compositing thread, which may be the main-thread if
* OMTC is not enabled. * OMTC is not enabled.
*/ */
virtual void PostRender(layers::LayerManagerComposite* aManager) virtual void PostRender(WidgetRenderingContext* aContext)
{} {}
/** /**
@ -93,7 +105,7 @@ public:
* *
* Always called from the compositing thread. * Always called from the compositing thread.
*/ */
virtual void DrawWindowUnderlay(layers::LayerManagerComposite* aManager, virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{} {}
@ -102,7 +114,7 @@ public:
* *
* Always called from the compositing thread. * Always called from the compositing thread.
*/ */
virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager, virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{} {}

Просмотреть файл

@ -33,29 +33,29 @@ InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
} }
bool bool
InProcessCompositorWidget::PreRender(layers::LayerManagerComposite* aManager) InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext)
{ {
return mWidget->PreRender(aManager); return mWidget->PreRender(aContext);
} }
void void
InProcessCompositorWidget::PostRender(layers::LayerManagerComposite* aManager) InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext)
{ {
mWidget->PostRender(aManager); mWidget->PostRender(aContext);
} }
void void
InProcessCompositorWidget::DrawWindowUnderlay(layers::LayerManagerComposite* aManager, InProcessCompositorWidget::DrawWindowUnderlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{ {
mWidget->DrawWindowUnderlay(aManager, aRect); mWidget->DrawWindowUnderlay(aContext, aRect);
} }
void void
InProcessCompositorWidget::DrawWindowOverlay(layers::LayerManagerComposite* aManager, InProcessCompositorWidget::DrawWindowOverlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{ {
mWidget->DrawWindowOverlay(aManager, aRect); mWidget->DrawWindowOverlay(aContext, aRect);
} }
already_AddRefed<gfx::DrawTarget> already_AddRefed<gfx::DrawTarget>

Просмотреть файл

@ -17,11 +17,11 @@ class InProcessCompositorWidget : public CompositorWidget
public: public:
explicit InProcessCompositorWidget(nsBaseWidget* aWidget); explicit InProcessCompositorWidget(nsBaseWidget* aWidget);
virtual bool PreRender(layers::LayerManagerComposite* aManager) override; virtual bool PreRender(WidgetRenderingContext* aManager) override;
virtual void PostRender(layers::LayerManagerComposite* aManager) override; virtual void PostRender(WidgetRenderingContext* aManager) override;
virtual void DrawWindowUnderlay(layers::LayerManagerComposite* aManager, virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) override; LayoutDeviceIntRect aRect) override;
virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager, virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) override; LayoutDeviceIntRect aRect) override;
virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override; virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
virtual already_AddRefed<gfx::DrawTarget> virtual already_AddRefed<gfx::DrawTarget>

Просмотреть файл

@ -3462,13 +3462,13 @@ nsWindow::SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
} }
bool bool
nsWindow::PreRender(LayerManagerComposite* aManager) nsWindow::PreRender(WidgetRenderingContext* aContext)
{ {
if (Destroyed()) { if (Destroyed()) {
return true; return true;
} }
layers::Compositor* compositor = aManager->GetCompositor(); layers::Compositor* compositor = aContext->mCompositor;
GeckoLayerClient::LocalRef client; GeckoLayerClient::LocalRef client;
@ -3484,7 +3484,7 @@ nsWindow::PreRender(LayerManagerComposite* aManager)
return true; return true;
} }
void void
nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager, nsWindow::DrawWindowUnderlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{ {
if (Destroyed()) { if (Destroyed()) {
@ -3515,7 +3515,7 @@ nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager,
} }
void void
nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager, nsWindow::DrawWindowOverlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{ {
PROFILER_LABEL("nsWindow", "DrawWindowOverlay", PROFILER_LABEL("nsWindow", "DrawWindowOverlay",

Просмотреть файл

@ -204,9 +204,11 @@ public:
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override; LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
virtual bool NeedsPaint() override; virtual bool NeedsPaint() override;
virtual bool PreRender(LayerManagerComposite* aManager) override; virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override; virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext,
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override; LayoutDeviceIntRect aRect) override;
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) override;
virtual bool WidgetPaintsBackground() override; virtual bool WidgetPaintsBackground() override;

Просмотреть файл

@ -52,6 +52,7 @@ class IAPZCTreeManager;
} // namespace layers } // namespace layers
namespace widget { namespace widget {
class RectTextureImage; class RectTextureImage;
class WidgetRenderingContext;
} // namespace widget } // namespace widget
} // namespace mozilla } // namespace mozilla
@ -441,9 +442,9 @@ public:
virtual void CreateCompositor() override; virtual void CreateCompositor() override;
virtual void PrepareWindowEffects() override; virtual void PrepareWindowEffects() override;
virtual void CleanupWindowEffects() override; virtual void CleanupWindowEffects() override;
virtual bool PreRender(LayerManagerComposite* aManager) override; virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void PostRender(LayerManagerComposite* aManager) override; virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aManager,
LayoutDeviceIntRect aRect) override; LayoutDeviceIntRect aRect) override;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override; virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;

Просмотреть файл

@ -67,6 +67,7 @@
#include "mozilla/layers/CompositorBridgeParent.h" #include "mozilla/layers/CompositorBridgeParent.h"
#include "mozilla/layers/BasicCompositor.h" #include "mozilla/layers/BasicCompositor.h"
#include "mozilla/layers/InputAPZContext.h" #include "mozilla/layers/InputAPZContext.h"
#include "mozilla/widget/CompositorWidget.h"
#include "gfxUtils.h" #include "gfxUtils.h"
#include "gfxPrefs.h" #include "gfxPrefs.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
@ -2019,9 +2020,9 @@ nsChildView::CleanupWindowEffects()
} }
bool bool
nsChildView::PreRender(LayerManagerComposite* aManager) nsChildView::PreRender(WidgetRenderingContext* aContext)
{ {
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager)); UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
if (!manager) { if (!manager) {
return true; return true;
} }
@ -2041,9 +2042,9 @@ nsChildView::PreRender(LayerManagerComposite* aManager)
} }
void void
nsChildView::PostRender(LayerManagerComposite* aManager) nsChildView::PostRender(WidgetRenderingContext* aContext)
{ {
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager)); UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
if (!manager) { if (!manager) {
return; return;
} }
@ -2053,10 +2054,10 @@ nsChildView::PostRender(LayerManagerComposite* aManager)
} }
void void
nsChildView::DrawWindowOverlay(LayerManagerComposite* aManager, nsChildView::DrawWindowOverlay(WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{ {
mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager)); mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
if (manager) { if (manager) {
DrawWindowOverlay(manager.get(), aRect); DrawWindowOverlay(manager.get(), aRect);
} }

Просмотреть файл

@ -63,6 +63,7 @@ struct ScrollableLayerGuid;
namespace widget { namespace widget {
class CompositorWidgetDelegate; class CompositorWidgetDelegate;
class InProcessCompositorWidget; class InProcessCompositorWidget;
class WidgetRenderingContext;
} // namespace widget } // namespace widget
class CompositorVsyncDispatcher; class CompositorVsyncDispatcher;
@ -391,15 +392,15 @@ protected:
// These are methods for CompositorWidgetWrapper, and should only be // These are methods for CompositorWidgetWrapper, and should only be
// accessed from that class. Derived widgets can choose which methods to // accessed from that class. Derived widgets can choose which methods to
// implement, or none if supporting out-of-process compositing. // implement, or none if supporting out-of-process compositing.
virtual bool PreRender(mozilla::layers::LayerManagerComposite* aManager) { virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) {
return true; return true;
} }
virtual void PostRender(mozilla::layers::LayerManagerComposite* aManager) virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext)
{} {}
virtual void DrawWindowUnderlay(mozilla::layers::LayerManagerComposite* aManager, virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{} {}
virtual void DrawWindowOverlay(mozilla::layers::LayerManagerComposite* aManager, virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext,
LayoutDeviceIntRect aRect) LayoutDeviceIntRect aRect)
{} {}
virtual already_AddRefed<DrawTarget> StartRemoteDrawing(); virtual already_AddRefed<DrawTarget> StartRemoteDrawing();

Просмотреть файл

@ -44,7 +44,7 @@ WinCompositorWidget::OnDestroyWindow()
} }
bool bool
WinCompositorWidget::PreRender(layers::LayerManagerComposite* aManager) WinCompositorWidget::PreRender(WidgetRenderingContext* aContext)
{ {
// This can block waiting for WM_SETTEXT to finish // This can block waiting for WM_SETTEXT to finish
// Using PreRender is unnecessarily pessimistic because // Using PreRender is unnecessarily pessimistic because
@ -55,7 +55,7 @@ WinCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
} }
void void
WinCompositorWidget::PostRender(layers::LayerManagerComposite* aManager) WinCompositorWidget::PostRender(WidgetRenderingContext* aContext)
{ {
mPresentLock.Leave(); mPresentLock.Leave();
} }

Просмотреть файл

@ -45,8 +45,8 @@ class WinCompositorWidget
public: public:
WinCompositorWidget(const CompositorWidgetInitData& aInitData); WinCompositorWidget(const CompositorWidgetInitData& aInitData);
bool PreRender(layers::LayerManagerComposite*) override; bool PreRender(WidgetRenderingContext*) override;
void PostRender(layers::LayerManagerComposite*) override; void PostRender(WidgetRenderingContext*) override;
already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override; already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
void EndRemoteDrawing() override; void EndRemoteDrawing() override;
bool NeedsToDeferEndRemoteDrawing() override; bool NeedsToDeferEndRemoteDrawing() override;