Bug 1793629 - Implement attention indicator for the unified extensions button, r...
[gecko.git] / widget / windows / InProcessWinCompositorWidget.h
blob8ef79bef71605f3378e70d21e5ee36e843855599
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_InProcessWinCompositorWidget_h
7 #define widget_windows_InProcessWinCompositorWidget_h
9 #include "WinCompositorWidget.h"
11 class nsWindow;
12 class gfxASurface;
14 namespace mozilla {
15 namespace widget {
17 // This is the Windows-specific implementation of CompositorWidget. For
18 // the most part it only requires an HWND, however it maintains extra state
19 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
20 // with the compositor.
21 class InProcessWinCompositorWidget final
22 : public WinCompositorWidget,
23 public PlatformCompositorWidgetDelegate {
24 public:
25 InProcessWinCompositorWidget(const WinCompositorWidgetInitData& aInitData,
26 const layers::CompositorOptions& aOptions,
27 nsWindow* aWindow);
29 bool PreRender(WidgetRenderingContext*) override;
30 void PostRender(WidgetRenderingContext*) override;
31 already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
32 void EndRemoteDrawing() override;
33 bool NeedsToDeferEndRemoteDrawing() override;
34 LayoutDeviceIntSize GetClientSize() override;
35 already_AddRefed<gfx::DrawTarget> GetBackBufferDrawTarget(
36 gfx::DrawTarget* aScreenTarget, const gfx::IntRect& aRect,
37 bool* aOutIsCleared) override;
38 already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing() override;
39 bool InitCompositor(layers::Compositor* aCompositor) override;
40 CompositorWidgetDelegate* AsDelegate() override { return this; }
41 bool IsHidden() const override;
43 // PlatformCompositorWidgetDelegate Overrides
45 void EnterPresentLock() override;
46 void LeavePresentLock() override;
47 void OnDestroyWindow() override;
48 bool OnWindowResize(const LayoutDeviceIntSize& aSize) override;
49 void OnWindowModeChange(nsSizeMode aSizeMode) override;
50 void UpdateTransparency(nsTransparencyMode aMode) override;
51 void NotifyVisibilityUpdated(nsSizeMode aSizeMode,
52 bool aIsFullyOccluded) override;
53 void ClearTransparentWindow() override;
55 bool RedrawTransparentWindow();
57 // Ensure that a transparent surface exists, then return it.
58 RefPtr<gfxASurface> EnsureTransparentSurface();
60 HDC GetTransparentDC() const { return mMemoryDC; }
62 mozilla::Mutex& GetTransparentSurfaceLock() {
63 return mTransparentSurfaceLock;
66 bool HasGlass() const override;
68 nsSizeMode GetWindowSizeMode() const override;
69 bool GetWindowIsFullyOccluded() const override;
71 void ObserveVsync(VsyncObserver* aObserver) override;
72 nsIWidget* RealWidget() override;
74 void UpdateCompositorWnd(const HWND aCompositorWnd,
75 const HWND aParentWnd) override {}
76 void SetRootLayerTreeID(const layers::LayersId& aRootLayerTreeId) override {}
78 private:
79 HDC GetWindowSurface();
80 void FreeWindowSurface(HDC dc);
82 void CreateTransparentSurface(const gfx::IntSize& aSize);
84 nsWindow* mWindow;
86 HWND mWnd;
88 gfx::CriticalSection mPresentLock;
90 // Transparency handling.
91 mozilla::Mutex mTransparentSurfaceLock MOZ_UNANNOTATED;
92 mozilla::Atomic<nsTransparencyMode, MemoryOrdering::Relaxed>
93 mTransparencyMode;
95 // Visibility handling.
96 mozilla::Atomic<nsSizeMode, MemoryOrdering::Relaxed> mSizeMode;
97 mozilla::Atomic<bool, MemoryOrdering::Relaxed> mIsFullyOccluded;
99 RefPtr<gfxASurface> mTransparentSurface;
100 HDC mMemoryDC;
101 HDC mCompositeDC;
103 // Locked back buffer of BasicCompositor
104 uint8_t* mLockedBackBufferData;
106 bool mNotDeferEndRemoteDrawing;
109 } // namespace widget
110 } // namespace mozilla
112 #endif // widget_windows_InProcessWinCompositorWidget_h