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_WinCompositorWidget_h
7 #define widget_windows_WinCompositorWidget_h
9 #include "CompositorWidget.h"
10 #include "mozilla/Atomics.h"
11 #include "mozilla/gfx/CriticalSection.h"
12 #include "mozilla/gfx/Point.h"
13 #include "mozilla/layers/LayersTypes.h"
14 #include "mozilla/Mutex.h"
15 #include "mozilla/widget/WinCompositorWindowThread.h"
16 #include "FxROutputHandler.h"
17 #include "nsIWidget.h"
24 class PlatformCompositorWidgetDelegate
: public CompositorWidgetDelegate
{
26 // Callbacks for nsWindow.
27 virtual void EnterPresentLock() = 0;
28 virtual void LeavePresentLock() = 0;
29 virtual void OnDestroyWindow() = 0;
30 virtual bool OnWindowResize(const LayoutDeviceIntSize
& aSize
) = 0;
31 virtual void OnWindowModeChange(nsSizeMode aSizeMode
) = 0;
33 // Transparency handling.
34 virtual void UpdateTransparency(TransparencyMode aMode
) = 0;
35 virtual void ClearTransparentWindow() = 0;
37 // Deliver visibility info
38 virtual void NotifyVisibilityUpdated(nsSizeMode aSizeMode
,
39 bool aIsFullyOccluded
) = 0;
41 // CompositorWidgetDelegate Overrides
43 PlatformCompositorWidgetDelegate
* AsPlatformSpecificDelegate() override
{
48 class WinCompositorWidgetInitData
;
50 // This is the Windows-specific implementation of CompositorWidget. For
51 // the most part it only requires an HWND, however it maintains extra state
52 // for transparent windows, as well as for synchronizing WM_SETTEXT messages
53 // with the compositor.
54 class WinCompositorWidget
: public CompositorWidget
{
56 WinCompositorWidget(const WinCompositorWidgetInitData
& aInitData
,
57 const layers::CompositorOptions
& aOptions
);
58 ~WinCompositorWidget() override
;
60 // CompositorWidget Overrides
62 uintptr_t GetWidgetKey() override
;
63 WinCompositorWidget
* AsWindows() override
{ return this; }
65 HWND
GetHwnd() const {
66 return mCompositorWnds
.mCompositorWnd
? mCompositorWnds
.mCompositorWnd
70 HWND
GetCompositorHwnd() const { return mCompositorWnds
.mCompositorWnd
; }
72 void EnsureCompositorWindow();
73 void DestroyCompositorWindow();
74 void UpdateCompositorWndSizeIfNecessary();
76 void RequestFxrOutput();
77 bool HasFxrOutputHandler() const { return mFxrHandler
!= nullptr; }
78 FxROutputHandler
* GetFxrOutputHandler() const { return mFxrHandler
.get(); }
80 virtual nsSizeMode
GetWindowSizeMode() const = 0;
81 virtual bool GetWindowIsFullyOccluded() const = 0;
83 virtual void UpdateCompositorWnd(const HWND aCompositorWnd
,
84 const HWND aParentWnd
) = 0;
85 virtual void SetRootLayerTreeID(const layers::LayersId
& aRootLayerTreeId
) = 0;
88 bool mSetParentCompleted
;
94 WinCompositorWnds mCompositorWnds
;
95 LayoutDeviceIntSize mLastCompositorWndSize
;
97 UniquePtr
<FxROutputHandler
> mFxrHandler
;
100 } // namespace widget
101 } // namespace mozilla
103 #endif // widget_windows_WinCompositorWidget_h