Update configs. IGNORE BROKEN CHANGESETS CLOSED TREE NO BUG a=release ba=release
[gecko.git] / widget / windows / InProcessWinCompositorWidget.h
blobe28720446129f29863d82813666a2e6c749b6ca3
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::widget {
16 // This is the Windows-specific implementation of CompositorWidget. For
17 // the most part it only requires an HWND, however it maintains extra state
18 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
19 // with the compositor.
20 class InProcessWinCompositorWidget final
21 : public WinCompositorWidget,
22 public PlatformCompositorWidgetDelegate {
23 public:
24 InProcessWinCompositorWidget(const WinCompositorWidgetInitData& aInitData,
25 const layers::CompositorOptions& aOptions,
26 nsWindow* aWindow);
28 bool PreRender(WidgetRenderingContext*) override;
29 void PostRender(WidgetRenderingContext*) override;
30 already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
31 void EndRemoteDrawing() override;
32 bool NeedsToDeferEndRemoteDrawing() override;
33 LayoutDeviceIntSize GetClientSize() override;
34 already_AddRefed<gfx::DrawTarget> GetBackBufferDrawTarget(
35 gfx::DrawTarget* aScreenTarget, const gfx::IntRect& aRect,
36 bool* aOutIsCleared) override;
37 already_AddRefed<gfx::SourceSurface> EndBackBufferDrawing() override;
38 bool InitCompositor(layers::Compositor* aCompositor) override;
39 CompositorWidgetDelegate* AsDelegate() override { return this; }
40 bool IsHidden() const override;
42 // PlatformCompositorWidgetDelegate Overrides
44 void EnterPresentLock() override;
45 void LeavePresentLock() override;
46 void OnDestroyWindow() override;
47 bool OnWindowResize(const LayoutDeviceIntSize& aSize) override;
48 void OnWindowModeChange(nsSizeMode aSizeMode) override;
49 void UpdateTransparency(TransparencyMode aMode) override;
50 void NotifyVisibilityUpdated(nsSizeMode aSizeMode,
51 bool aIsFullyOccluded) override;
52 void ClearTransparentWindow() override;
54 bool RedrawTransparentWindow();
56 // Ensure that a transparent surface exists, then return it.
57 RefPtr<gfxASurface> EnsureTransparentSurface();
59 HDC GetTransparentDC() const { return mMemoryDC; }
61 mozilla::Mutex& GetTransparentSurfaceLock() {
62 return mTransparentSurfaceLock;
65 nsSizeMode GetWindowSizeMode() const override;
66 bool GetWindowIsFullyOccluded() const override;
68 void ObserveVsync(VsyncObserver* aObserver) override;
69 nsIWidget* RealWidget() override;
71 void UpdateCompositorWnd(const HWND aCompositorWnd,
72 const HWND aParentWnd) override;
73 void SetRootLayerTreeID(const layers::LayersId& aRootLayerTreeId) override {}
75 private:
76 HDC GetWindowSurface();
77 void FreeWindowSurface(HDC dc);
79 void CreateTransparentSurface(const gfx::IntSize& aSize);
81 nsWindow* mWindow;
83 HWND mWnd;
85 gfx::CriticalSection mPresentLock;
87 // Transparency handling.
88 mozilla::Mutex mTransparentSurfaceLock MOZ_UNANNOTATED;
89 mozilla::Atomic<uint32_t, MemoryOrdering::Relaxed> mTransparencyMode;
91 bool TransparencyModeIs(TransparencyMode aMode) const {
92 return TransparencyMode(uint32_t(mTransparencyMode)) == aMode;
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 mozilla::widget
111 #endif // widget_windows_InProcessWinCompositorWidget_h