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)
21 RefPtr
<CompositorWidget
> CompositorWidget::CreateLocal(
22 const CompositorWidgetInitData
& aInitData
,
23 const layers::CompositorOptions
& aOptions
, nsIWidget
* aWidget
) {
25 # ifdef MOZ_WIDGET_ANDROID
26 return new AndroidCompositorWidget(aOptions
,
27 static_cast<nsBaseWidget
*>(aWidget
));
29 return new InProcessCompositorWidget(aOptions
,
30 static_cast<nsBaseWidget
*>(aWidget
));
35 InProcessCompositorWidget::InProcessCompositorWidget(
36 const layers::CompositorOptions
& aOptions
, nsBaseWidget
* aWidget
)
37 : CompositorWidget(aOptions
), mWidget(aWidget
) {}
39 bool InProcessCompositorWidget::PreRender(WidgetRenderingContext
* aContext
) {
40 return mWidget
->PreRender(aContext
);
43 void InProcessCompositorWidget::PostRender(WidgetRenderingContext
* aContext
) {
44 mWidget
->PostRender(aContext
);
47 RefPtr
<layers::NativeLayerRoot
>
48 InProcessCompositorWidget::GetNativeLayerRoot() {
49 return mWidget
->GetNativeLayerRoot();
52 already_AddRefed
<gfx::DrawTarget
>
53 InProcessCompositorWidget::StartRemoteDrawing() {
54 return mWidget
->StartRemoteDrawing();
57 already_AddRefed
<gfx::DrawTarget
>
58 InProcessCompositorWidget::StartRemoteDrawingInRegion(
59 LayoutDeviceIntRegion
& aInvalidRegion
, layers::BufferMode
* aBufferMode
) {
60 return mWidget
->StartRemoteDrawingInRegion(aInvalidRegion
, aBufferMode
);
63 void InProcessCompositorWidget::EndRemoteDrawing() {
64 mWidget
->EndRemoteDrawing();
67 void InProcessCompositorWidget::EndRemoteDrawingInRegion(
68 gfx::DrawTarget
* aDrawTarget
, const LayoutDeviceIntRegion
& aInvalidRegion
) {
69 mWidget
->EndRemoteDrawingInRegion(aDrawTarget
, aInvalidRegion
);
72 void InProcessCompositorWidget::CleanupRemoteDrawing() {
73 mWidget
->CleanupRemoteDrawing();
76 void InProcessCompositorWidget::CleanupWindowEffects() {
77 mWidget
->CleanupWindowEffects();
80 bool InProcessCompositorWidget::InitCompositor(
81 layers::Compositor
* aCompositor
) {
82 return mWidget
->InitCompositor(aCompositor
);
85 LayoutDeviceIntSize
InProcessCompositorWidget::GetClientSize() {
86 return mWidget
->GetClientSize();
89 uint32_t InProcessCompositorWidget::GetGLFrameBufferFormat() {
90 return mWidget
->GetGLFrameBufferFormat();
93 uintptr_t InProcessCompositorWidget::GetWidgetKey() {
94 return reinterpret_cast<uintptr_t>(mWidget
);
97 nsIWidget
* InProcessCompositorWidget::RealWidget() { return mWidget
; }
100 LayoutDeviceIntRegion
InProcessCompositorWidget::GetOpaqueWidgetRegion() {
101 return mWidget
->GetOpaqueWidgetRegion();
105 void InProcessCompositorWidget::ObserveVsync(VsyncObserver
* aObserver
) {
106 if (RefPtr
<CompositorVsyncDispatcher
> cvd
=
107 mWidget
->GetCompositorVsyncDispatcher()) {
108 cvd
->SetCompositorVsyncObserver(aObserver
);
112 } // namespace widget
113 } // namespace mozilla