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 #ifndef mozilla_widget_InProcessCompositorWidget_h__
6 #define mozilla_widget_InProcessCompositorWidget_h__
7 
8 #include "CompositorWidget.h"
9 
10 namespace mozilla {
11 namespace widget {
12 
13 // This version of CompositorWidget implements a wrapper around
14 // nsBaseWidget.
15 class InProcessCompositorWidget : public CompositorWidget {
16  public:
17   explicit InProcessCompositorWidget(const layers::CompositorOptions& aOptions,
18                                      nsBaseWidget* aWidget);
19 
20   virtual bool PreRender(WidgetRenderingContext* aManager) override;
21   virtual void PostRender(WidgetRenderingContext* aManager) override;
22   virtual RefPtr<layers::NativeLayerRoot> GetNativeLayerRoot() override;
23   virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
24   virtual already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
25       const LayoutDeviceIntRegion& aInvalidRegion,
26       layers::BufferMode* aBufferMode) override;
27   virtual void EndRemoteDrawing() override;
28   virtual void EndRemoteDrawingInRegion(
29       gfx::DrawTarget* aDrawTarget,
30       const LayoutDeviceIntRegion& aInvalidRegion) override;
31   virtual void CleanupRemoteDrawing() override;
32   virtual void CleanupWindowEffects() override;
33   virtual bool InitCompositor(layers::Compositor* aCompositor) override;
34   virtual LayoutDeviceIntSize GetClientSize() override;
35   virtual uint32_t GetGLFrameBufferFormat() override;
36   virtual void ObserveVsync(VsyncObserver* aObserver) override;
37   virtual uintptr_t GetWidgetKey() override;
38 
39   // If you can override this method, inherit from CompositorWidget instead.
40   nsIWidget* RealWidget() override;
41 
42  protected:
43   nsBaseWidget* mWidget;
44   // Bug 1679368: Maintain an additional widget pointer, constant, and
45   // function for sanity checking while we chase a crash.
46   static const char* CANARY_VALUE;
47   const char* mCanary;
48   nsBaseWidget* mWidgetSanity;
49   void CheckWidgetSanity();
50 };
51 
52 }  // namespace widget
53 }  // namespace mozilla
54 
55 #endif
56