mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
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:
parent
50ccc2b3a2
commit
54c54c7a09
@ -42,6 +42,7 @@
|
||||
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "mozilla/layers/LayersTypes.h" // for etc
|
||||
#include "mozilla/widget/CompositorWidget.h" // for WidgetRenderingContext
|
||||
#include "ipc/CompositorBench.h" // for CompositorBench
|
||||
#include "ipc/ShadowLayerUtils.h"
|
||||
#include "mozilla/mozalloc.h" // for operator new, etc
|
||||
@ -911,11 +912,18 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
|
||||
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",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
||||
if (!mCompositor->GetWidget()->PreRender(this)) {
|
||||
if (!mCompositor->GetWidget()->PreRender(&widgetContext)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -946,13 +954,13 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
|
||||
}
|
||||
|
||||
if (actualBounds.IsEmpty()) {
|
||||
mCompositor->GetWidget()->PostRender(this);
|
||||
mCompositor->GetWidget()->PostRender(&widgetContext);
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow widget to render a custom background.
|
||||
mCompositor->GetWidget()->DrawWindowUnderlay(
|
||||
this, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
|
||||
&widgetContext, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
|
||||
|
||||
RefPtr<CompositingRenderTarget> previousTarget;
|
||||
if (haveLayerEffects) {
|
||||
@ -980,7 +988,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
|
||||
|
||||
// Allow widget to render a custom foreground.
|
||||
mCompositor->GetWidget()->DrawWindowOverlay(
|
||||
this, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
|
||||
&widgetContext, LayoutDeviceIntRect::FromUnknownRect(actualBounds));
|
||||
|
||||
// Debugging
|
||||
RenderDebugOverlay(actualBounds);
|
||||
@ -999,7 +1007,7 @@ LayerManagerComposite::Render(const nsIntRegion& aInvalidRegion, const nsIntRegi
|
||||
composer2D->Render(mCompositor->GetWidget()->RealWidget());
|
||||
}
|
||||
|
||||
mCompositor->GetWidget()->PostRender(this);
|
||||
mCompositor->GetWidget()->PostRender(&widgetContext);
|
||||
|
||||
RecordFrame();
|
||||
}
|
||||
|
@ -53,6 +53,18 @@ class CompositorWidgetChild;
|
||||
# define MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
|
||||
#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.
|
||||
*/
|
||||
@ -74,7 +86,7 @@ public:
|
||||
* Always called from the compositing thread, which may be the main-thread if
|
||||
* OMTC is not enabled.
|
||||
*/
|
||||
virtual bool PreRender(layers::LayerManagerComposite* aManager) {
|
||||
virtual bool PreRender(WidgetRenderingContext* aContext) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -85,7 +97,7 @@ public:
|
||||
* Always called from the compositing thread, which may be the main-thread if
|
||||
* 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.
|
||||
*/
|
||||
virtual void DrawWindowUnderlay(layers::LayerManagerComposite* aManager,
|
||||
virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{}
|
||||
|
||||
@ -102,7 +114,7 @@ public:
|
||||
*
|
||||
* Always called from the compositing thread.
|
||||
*/
|
||||
virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager,
|
||||
virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{}
|
||||
|
||||
|
@ -33,29 +33,29 @@ InProcessCompositorWidget::InProcessCompositorWidget(nsBaseWidget* aWidget)
|
||||
}
|
||||
|
||||
bool
|
||||
InProcessCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
|
||||
InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
return mWidget->PreRender(aManager);
|
||||
return mWidget->PreRender(aContext);
|
||||
}
|
||||
|
||||
void
|
||||
InProcessCompositorWidget::PostRender(layers::LayerManagerComposite* aManager)
|
||||
InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
mWidget->PostRender(aManager);
|
||||
mWidget->PostRender(aContext);
|
||||
}
|
||||
|
||||
void
|
||||
InProcessCompositorWidget::DrawWindowUnderlay(layers::LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect)
|
||||
InProcessCompositorWidget::DrawWindowUnderlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
mWidget->DrawWindowUnderlay(aManager, aRect);
|
||||
mWidget->DrawWindowUnderlay(aContext, aRect);
|
||||
}
|
||||
|
||||
void
|
||||
InProcessCompositorWidget::DrawWindowOverlay(layers::LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect)
|
||||
InProcessCompositorWidget::DrawWindowOverlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
mWidget->DrawWindowOverlay(aManager, aRect);
|
||||
mWidget->DrawWindowOverlay(aContext, aRect);
|
||||
}
|
||||
|
||||
already_AddRefed<gfx::DrawTarget>
|
||||
|
@ -17,11 +17,11 @@ 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,
|
||||
virtual bool PreRender(WidgetRenderingContext* aManager) override;
|
||||
virtual void PostRender(WidgetRenderingContext* aManager) override;
|
||||
virtual void DrawWindowUnderlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(layers::LayerManagerComposite* aManager,
|
||||
virtual void DrawWindowOverlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
|
||||
virtual already_AddRefed<gfx::DrawTarget>
|
||||
|
@ -3462,13 +3462,13 @@ nsWindow::SynthesizeNativeMouseMove(LayoutDeviceIntPoint aPoint,
|
||||
}
|
||||
|
||||
bool
|
||||
nsWindow::PreRender(LayerManagerComposite* aManager)
|
||||
nsWindow::PreRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
if (Destroyed()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
layers::Compositor* compositor = aManager->GetCompositor();
|
||||
layers::Compositor* compositor = aContext->mCompositor;
|
||||
|
||||
GeckoLayerClient::LocalRef client;
|
||||
|
||||
@ -3484,7 +3484,7 @@ nsWindow::PreRender(LayerManagerComposite* aManager)
|
||||
return true;
|
||||
}
|
||||
void
|
||||
nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager,
|
||||
nsWindow::DrawWindowUnderlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
if (Destroyed()) {
|
||||
@ -3515,7 +3515,7 @@ nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager,
|
||||
}
|
||||
|
||||
void
|
||||
nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
nsWindow::DrawWindowOverlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
PROFILER_LABEL("nsWindow", "DrawWindowOverlay",
|
||||
|
@ -204,9 +204,11 @@ public:
|
||||
LayerManagerPersistence aPersistence = LAYER_MANAGER_CURRENT) override;
|
||||
|
||||
virtual bool NeedsPaint() override;
|
||||
virtual bool PreRender(LayerManagerComposite* aManager) override;
|
||||
virtual void DrawWindowUnderlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager, LayoutDeviceIntRect aRect) override;
|
||||
virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
|
||||
virtual void DrawWindowUnderlay(mozilla::widget::WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
|
||||
virtual bool WidgetPaintsBackground() override;
|
||||
|
||||
|
@ -52,6 +52,7 @@ class IAPZCTreeManager;
|
||||
} // namespace layers
|
||||
namespace widget {
|
||||
class RectTextureImage;
|
||||
class WidgetRenderingContext;
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
||||
@ -441,9 +442,9 @@ public:
|
||||
virtual void CreateCompositor() override;
|
||||
virtual void PrepareWindowEffects() override;
|
||||
virtual void CleanupWindowEffects() override;
|
||||
virtual bool PreRender(LayerManagerComposite* aManager) override;
|
||||
virtual void PostRender(LayerManagerComposite* aManager) override;
|
||||
virtual void DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) override;
|
||||
virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext) override;
|
||||
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aManager,
|
||||
LayoutDeviceIntRect aRect) override;
|
||||
|
||||
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
|
||||
|
@ -67,6 +67,7 @@
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/BasicCompositor.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
#include "mozilla/widget/CompositorWidget.h"
|
||||
#include "gfxUtils.h"
|
||||
#include "gfxPrefs.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
@ -2019,9 +2020,9 @@ nsChildView::CleanupWindowEffects()
|
||||
}
|
||||
|
||||
bool
|
||||
nsChildView::PreRender(LayerManagerComposite* aManager)
|
||||
nsChildView::PreRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager));
|
||||
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
|
||||
if (!manager) {
|
||||
return true;
|
||||
}
|
||||
@ -2041,9 +2042,9 @@ nsChildView::PreRender(LayerManagerComposite* aManager)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::PostRender(LayerManagerComposite* aManager)
|
||||
nsChildView::PostRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager));
|
||||
UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
|
||||
if (!manager) {
|
||||
return;
|
||||
}
|
||||
@ -2053,10 +2054,10 @@ nsChildView::PostRender(LayerManagerComposite* aManager)
|
||||
}
|
||||
|
||||
void
|
||||
nsChildView::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
nsChildView::DrawWindowOverlay(WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aManager));
|
||||
mozilla::UniquePtr<GLManager> manager(GLManager::CreateGLManager(aContext->mLayerManager));
|
||||
if (manager) {
|
||||
DrawWindowOverlay(manager.get(), aRect);
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ struct ScrollableLayerGuid;
|
||||
namespace widget {
|
||||
class CompositorWidgetDelegate;
|
||||
class InProcessCompositorWidget;
|
||||
class WidgetRenderingContext;
|
||||
} // namespace widget
|
||||
|
||||
class CompositorVsyncDispatcher;
|
||||
@ -391,15 +392,15 @@ protected:
|
||||
// These are methods for CompositorWidgetWrapper, and should only be
|
||||
// accessed from that class. Derived widgets can choose which methods to
|
||||
// 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;
|
||||
}
|
||||
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)
|
||||
{}
|
||||
virtual void DrawWindowOverlay(mozilla::layers::LayerManagerComposite* aManager,
|
||||
virtual void DrawWindowOverlay(mozilla::widget::WidgetRenderingContext* aContext,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{}
|
||||
virtual already_AddRefed<DrawTarget> StartRemoteDrawing();
|
||||
|
@ -44,7 +44,7 @@ WinCompositorWidget::OnDestroyWindow()
|
||||
}
|
||||
|
||||
bool
|
||||
WinCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
|
||||
WinCompositorWidget::PreRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
// This can block waiting for WM_SETTEXT to finish
|
||||
// Using PreRender is unnecessarily pessimistic because
|
||||
@ -55,7 +55,7 @@ WinCompositorWidget::PreRender(layers::LayerManagerComposite* aManager)
|
||||
}
|
||||
|
||||
void
|
||||
WinCompositorWidget::PostRender(layers::LayerManagerComposite* aManager)
|
||||
WinCompositorWidget::PostRender(WidgetRenderingContext* aContext)
|
||||
{
|
||||
mPresentLock.Leave();
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ class WinCompositorWidget
|
||||
public:
|
||||
WinCompositorWidget(const CompositorWidgetInitData& aInitData);
|
||||
|
||||
bool PreRender(layers::LayerManagerComposite*) override;
|
||||
void PostRender(layers::LayerManagerComposite*) override;
|
||||
bool PreRender(WidgetRenderingContext*) override;
|
||||
void PostRender(WidgetRenderingContext*) override;
|
||||
already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
|
||||
void EndRemoteDrawing() override;
|
||||
bool NeedsToDeferEndRemoteDrawing() override;
|
||||
|
Loading…
Reference in New Issue
Block a user