Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / widget / windows / CompositorWidgetParent.h
blobc8b41a6450f1431444a085ac8a218924c0b21fb5
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef widget_windows_CompositorWidgetParent_h
7 #define widget_windows_CompositorWidgetParent_h
9 #include "WinCompositorWidget.h"
10 #include "mozilla/Maybe.h"
11 #include "mozilla/widget/PCompositorWidgetParent.h"
13 namespace mozilla {
14 namespace widget {
16 enum class TransparencyMode : uint8_t;
18 namespace remote_backbuffer {
19 class Client;
22 class CompositorWidgetParent final : public PCompositorWidgetParent,
23 public WinCompositorWidget {
24 public:
25 explicit CompositorWidgetParent(const CompositorWidgetInitData& aInitData,
26 const layers::CompositorOptions& aOptions);
27 ~CompositorWidgetParent() override;
29 bool Initialize(const RemoteBackbufferHandles& aRemoteHandles);
31 bool PreRender(WidgetRenderingContext*) override;
32 void PostRender(WidgetRenderingContext*) override;
33 already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
34 const LayoutDeviceIntRegion& aInvalidRegion,
35 layers::BufferMode* aBufferMode) override;
36 void EndRemoteDrawingInRegion(
37 gfx::DrawTarget* aDrawTarget,
38 const LayoutDeviceIntRegion& aInvalidRegion) override;
39 bool NeedsToDeferEndRemoteDrawing() override;
40 LayoutDeviceIntSize GetClientSize() override;
41 already_AddRefed<gfx::DrawTarget> GetBackBufferDrawTarget(
42 gfx::DrawTarget* aScreenTarget, const gfx::IntRect& aRect,
43 bool* aOutIsCleared) override;
44 already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing() override;
45 bool InitCompositor(layers::Compositor* aCompositor) override;
46 bool IsHidden() const override;
48 bool GetWindowIsFullyOccluded() const override;
50 mozilla::ipc::IPCResult RecvInitialize(
51 const RemoteBackbufferHandles& aRemoteHandles) override;
52 mozilla::ipc::IPCResult RecvEnterPresentLock() override;
53 mozilla::ipc::IPCResult RecvLeavePresentLock() override;
54 mozilla::ipc::IPCResult RecvNotifyVisibilityUpdated(
55 const bool& aIsFullyOccluded) override;
56 mozilla::ipc::IPCResult RecvUpdateTransparency(
57 const TransparencyMode& aTransparencyMode) override;
58 mozilla::ipc::IPCResult RecvClearTransparentWindow() override;
59 void ActorDestroy(ActorDestroyReason aWhy) override;
61 nsIWidget* RealWidget() override;
62 void ObserveVsync(VsyncObserver* aObserver) override;
63 RefPtr<VsyncObserver> GetVsyncObserver() const override;
65 // PlatformCompositorWidgetDelegate Overrides
66 void UpdateCompositorWnd(const HWND aCompositorWnd,
67 const HWND aParentWnd) override;
68 void SetRootLayerTreeID(const layers::LayersId& aRootLayerTreeId) override;
70 private:
71 RefPtr<VsyncObserver> mVsyncObserver;
72 Maybe<layers::LayersId> mRootLayerTreeID;
74 HWND mWnd;
76 gfx::CriticalSection mPresentLock;
78 // Visibility handling.
79 mozilla::Atomic<nsSizeMode, MemoryOrdering::Relaxed> mSizeMode;
80 mozilla::Atomic<bool, MemoryOrdering::Relaxed> mIsFullyOccluded;
82 std::unique_ptr<remote_backbuffer::Client> mRemoteBackbufferClient;
85 } // namespace widget
86 } // namespace mozilla
88 #endif // widget_windows_CompositorWidgetParent_h