Line data Source code
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/. */
4 :
5 : #include "InProcessCompositorWidget.h"
6 : #include "nsBaseWidget.h"
7 :
8 : #if defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
9 : #include "mozilla/widget/AndroidCompositorWidget.h"
10 : #endif
11 :
12 : namespace mozilla {
13 : namespace widget {
14 :
15 : // Platforms with no OOP compositor process support use
16 : // InProcessCompositorWidget by default.
17 : #if !defined(MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING)
18 : /* static */ RefPtr<CompositorWidget>
19 : CompositorWidget::CreateLocal(const CompositorWidgetInitData& aInitData,
20 : const layers::CompositorOptions& aOptions,
21 : nsIWidget* aWidget)
22 : {
23 : MOZ_ASSERT(aWidget);
24 : #ifdef MOZ_WIDGET_ANDROID
25 : return new AndroidCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
26 : #else
27 : return new InProcessCompositorWidget(aOptions, static_cast<nsBaseWidget*>(aWidget));
28 : #endif
29 : }
30 : #endif
31 :
32 0 : InProcessCompositorWidget::InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
33 0 : nsBaseWidget* aWidget)
34 : : CompositorWidget(aOptions)
35 0 : , mWidget(aWidget)
36 : {
37 0 : }
38 :
39 : bool
40 0 : InProcessCompositorWidget::PreRender(WidgetRenderingContext* aContext)
41 : {
42 0 : return mWidget->PreRender(aContext);
43 : }
44 :
45 : void
46 0 : InProcessCompositorWidget::PostRender(WidgetRenderingContext* aContext)
47 : {
48 0 : mWidget->PostRender(aContext);
49 0 : }
50 :
51 : void
52 0 : InProcessCompositorWidget::DrawWindowUnderlay(WidgetRenderingContext* aContext,
53 : LayoutDeviceIntRect aRect)
54 : {
55 0 : mWidget->DrawWindowUnderlay(aContext, aRect);
56 0 : }
57 :
58 : void
59 0 : InProcessCompositorWidget::DrawWindowOverlay(WidgetRenderingContext* aContext,
60 : LayoutDeviceIntRect aRect)
61 : {
62 0 : mWidget->DrawWindowOverlay(aContext, aRect);
63 0 : }
64 :
65 : already_AddRefed<gfx::DrawTarget>
66 0 : InProcessCompositorWidget::StartRemoteDrawing()
67 : {
68 0 : return mWidget->StartRemoteDrawing();
69 : }
70 :
71 : already_AddRefed<gfx::DrawTarget>
72 0 : InProcessCompositorWidget::StartRemoteDrawingInRegion(LayoutDeviceIntRegion& aInvalidRegion,
73 : layers::BufferMode* aBufferMode)
74 : {
75 0 : return mWidget->StartRemoteDrawingInRegion(aInvalidRegion, aBufferMode);
76 : }
77 :
78 : void
79 0 : InProcessCompositorWidget::EndRemoteDrawing()
80 : {
81 0 : mWidget->EndRemoteDrawing();
82 0 : }
83 :
84 : void
85 0 : InProcessCompositorWidget::EndRemoteDrawingInRegion(gfx::DrawTarget* aDrawTarget,
86 : LayoutDeviceIntRegion& aInvalidRegion)
87 : {
88 0 : mWidget->EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion);
89 0 : }
90 :
91 : void
92 0 : InProcessCompositorWidget::CleanupRemoteDrawing()
93 : {
94 0 : mWidget->CleanupRemoteDrawing();
95 0 : }
96 :
97 : void
98 0 : InProcessCompositorWidget::CleanupWindowEffects()
99 : {
100 0 : mWidget->CleanupWindowEffects();
101 0 : }
102 :
103 : bool
104 0 : InProcessCompositorWidget::InitCompositor(layers::Compositor* aCompositor)
105 : {
106 0 : return mWidget->InitCompositor(aCompositor);
107 : }
108 :
109 : LayoutDeviceIntSize
110 0 : InProcessCompositorWidget::GetClientSize()
111 : {
112 0 : return mWidget->GetClientSize();
113 : }
114 :
115 : uint32_t
116 0 : InProcessCompositorWidget::GetGLFrameBufferFormat()
117 : {
118 0 : return mWidget->GetGLFrameBufferFormat();
119 : }
120 :
121 : uintptr_t
122 0 : InProcessCompositorWidget::GetWidgetKey()
123 : {
124 0 : return reinterpret_cast<uintptr_t>(mWidget);
125 : }
126 :
127 : nsIWidget*
128 0 : InProcessCompositorWidget::RealWidget()
129 : {
130 0 : return mWidget;
131 : }
132 :
133 : void
134 0 : InProcessCompositorWidget::ObserveVsync(VsyncObserver* aObserver)
135 : {
136 0 : if (RefPtr<CompositorVsyncDispatcher> cvd = mWidget->GetCompositorVsyncDispatcher()) {
137 0 : cvd->SetCompositorVsyncObserver(aObserver);
138 : }
139 0 : }
140 :
141 : } // namespace widget
142 : } // namespace mozilla
143 :
|