1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "InProcessCompositorWidget.h"
7 #include "mozilla/VsyncDispatcher.h"
8 #include "nsBaseWidget.h"
10 #if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
11 #include "mozilla/widget/AndroidCompositorWidget.h"
17 // Platforms with no OOP compositor process support use
18 // InProcessCompositorWidget by default.
19 #if !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
20 /* static */ RefPtr
<CompositorWidget
>
21 CompositorWidget::CreateLocal(const CompositorWidgetInitData
& aInitData
,
22 const layers::CompositorOptions
& aOptions
,
26 #ifdef MOZ_WIDGET_ANDROID
27 return new AndroidCompositorWidget(aOptions
, static_cast<nsBaseWidget
*>(aWidget
));
29 return new InProcessCompositorWidget(aOptions
, static_cast<nsBaseWidget
*>(aWidget
));
34 InProcessCompositorWidget::InProcessCompositorWidget(const layers::CompositorOptions
& aOptions
,
35 nsBaseWidget
* aWidget
)
36 : CompositorWidget(aOptions
)
42 InProcessCompositorWidget::PreRender(WidgetRenderingContext
* aContext
)
44 return mWidget
->PreRender(aContext
);
48 InProcessCompositorWidget::PostRender(WidgetRenderingContext
* aContext
)
50 mWidget
->PostRender(aContext
);
54 InProcessCompositorWidget::DrawWindowUnderlay(WidgetRenderingContext
* aContext
,
55 LayoutDeviceIntRect aRect
)
57 mWidget
->DrawWindowUnderlay(aContext
, aRect
);
61 InProcessCompositorWidget::DrawWindowOverlay(WidgetRenderingContext
* aContext
,
62 LayoutDeviceIntRect aRect
)
64 mWidget
->DrawWindowOverlay(aContext
, aRect
);
67 already_AddRefed
<gfx::DrawTarget
>
68 InProcessCompositorWidget::StartRemoteDrawing()
70 return mWidget
->StartRemoteDrawing();
73 already_AddRefed
<gfx::DrawTarget
>
74 InProcessCompositorWidget::StartRemoteDrawingInRegion(LayoutDeviceIntRegion
& aInvalidRegion
,
75 layers::BufferMode
* aBufferMode
)
77 return mWidget
->StartRemoteDrawingInRegion(aInvalidRegion
, aBufferMode
);
81 InProcessCompositorWidget::EndRemoteDrawing()
83 mWidget
->EndRemoteDrawing();
87 InProcessCompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget
* aDrawTarget
,
88 LayoutDeviceIntRegion
& aInvalidRegion
)
90 mWidget
->EndRemoteDrawingInRegion(aDrawTarget
, aInvalidRegion
);
94 InProcessCompositorWidget::CleanupRemoteDrawing()
96 mWidget
->CleanupRemoteDrawing();
100 InProcessCompositorWidget::CleanupWindowEffects()
102 mWidget
->CleanupWindowEffects();
106 InProcessCompositorWidget::InitCompositor(layers::Compositor
* aCompositor
)
108 return mWidget
->InitCompositor(aCompositor
);
112 InProcessCompositorWidget::GetClientSize()
114 return mWidget
->GetClientSize();
118 InProcessCompositorWidget::GetGLFrameBufferFormat()
120 return mWidget
->GetGLFrameBufferFormat();
124 InProcessCompositorWidget::GetWidgetKey()
126 return reinterpret_cast<uintptr_t>(mWidget
);
130 InProcessCompositorWidget::RealWidget()
136 InProcessCompositorWidget::ObserveVsync(VsyncObserver
* aObserver
)
138 if (RefPtr
<CompositorVsyncDispatcher
> cvd
= mWidget
->GetCompositorVsyncDispatcher()) {
139 cvd
->SetCompositorVsyncObserver(aObserver
);
143 } // namespace widget
144 } // namespace mozilla