Bug 1447216 [wpt PR 10104] - Worker: Support ES Modules on DedicatedWorker behind...
[gecko.git] / widget / InProcessCompositorWidget.cpp
blob0d21aafb2188e26c6ed923c3c39faf8f362097ed
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"
12 #endif
14 namespace mozilla {
15 namespace widget {
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,
23 nsIWidget* aWidget)
25 MOZ_ASSERT(aWidget);
26 #ifdef MOZ_WIDGET_ANDROID
27 return new AndroidCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
28 #else
29 return new InProcessCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
30 #endif
32 #endif
34 InProcessCompositorWidget::InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
35 nsBaseWidget* aWidget)
36 : CompositorWidget(aOptions)
37 , mWidget(aWidget)
41 bool
42 InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext)
44 return mWidget->PreRender(aContext);
47 void
48 InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext)
50 mWidget->PostRender(aContext);
53 void
54 InProcessCompositorWidget::DrawWindowUnderlay(WidgetRenderingContext* aContext,
55 LayoutDeviceIntRect aRect)
57 mWidget->DrawWindowUnderlay(aContext, aRect);
60 void
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);
80 void
81 InProcessCompositorWidget::EndRemoteDrawing()
83 mWidget->EndRemoteDrawing();
86 void
87 InProcessCompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
88 LayoutDeviceIntRegion& aInvalidRegion)
90 mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
93 void
94 InProcessCompositorWidget::CleanupRemoteDrawing()
96 mWidget->CleanupRemoteDrawing();
99 void
100 InProcessCompositorWidget::CleanupWindowEffects()
102 mWidget->CleanupWindowEffects();
105 bool
106 InProcessCompositorWidget::InitCompositor(layers::Compositor* aCompositor)
108 return mWidget->InitCompositor(aCompositor);
111 LayoutDeviceIntSize
112 InProcessCompositorWidget::GetClientSize()
114 return mWidget->GetClientSize();
117 uint32_t
118 InProcessCompositorWidget::GetGLFrameBufferFormat()
120 return mWidget->GetGLFrameBufferFormat();
123 uintptr_t
124 InProcessCompositorWidget::GetWidgetKey()
126 return reinterpret_cast<uintptr_t>(mWidget);
129 nsIWidget*
130 InProcessCompositorWidget::RealWidget()
132 return mWidget;
135 void
136 InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver)
138 if (RefPtr<CompositorVsyncDispatcher> cvd = mWidget->GetCompositorVsyncDispatcher()) {
139 cvd->SetCompositorVsyncObserver(aObserver);
143 } // namespace widget
144 } // namespace mozilla