Bug 1673311 [wpt PR 26282] - Fieldset NG: Percentage heights for content elements...
[gecko.git] / widget / gtk / GtkCompositorWidget.h
blob4e8b08967dfa86c7e0a72984a919f67cc64f2149
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_gtk_GtkCompositorWidget_h
7 #define widget_gtk_GtkCompositorWidget_h
9 #include "GLDefs.h"
10 #include "mozilla/DataMutex.h"
11 #include "mozilla/widget/CompositorWidget.h"
12 #include "WindowSurfaceProvider.h"
14 class nsIWidget;
15 class nsWindow;
17 namespace mozilla {
18 namespace widget {
20 class PlatformCompositorWidgetDelegate : public CompositorWidgetDelegate {
21 public:
22 virtual void NotifyClientSizeChanged(
23 const LayoutDeviceIntSize& aClientSize) = 0;
25 // CompositorWidgetDelegate Overrides
27 PlatformCompositorWidgetDelegate* AsPlatformSpecificDelegate() override {
28 return this;
32 class GtkCompositorWidgetInitData;
34 class GtkCompositorWidget : public CompositorWidget,
35 public PlatformCompositorWidgetDelegate {
36 public:
37 GtkCompositorWidget(const GtkCompositorWidgetInitData& aInitData,
38 const layers::CompositorOptions& aOptions,
39 nsWindow* aWindow /* = nullptr*/);
40 ~GtkCompositorWidget();
42 // CompositorWidget Overrides
44 already_AddRefed<gfx::DrawTarget> StartRemoteDrawing() override;
45 void EndRemoteDrawing() override;
47 already_AddRefed<gfx::DrawTarget> StartRemoteDrawingInRegion(
48 LayoutDeviceIntRegion& aInvalidRegion,
49 layers::BufferMode* aBufferMode) override;
50 void EndRemoteDrawingInRegion(
51 gfx::DrawTarget* aDrawTarget,
52 const LayoutDeviceIntRegion& aInvalidRegion) override;
53 uintptr_t GetWidgetKey() override;
55 LayoutDeviceIntSize GetClientSize() override;
57 nsIWidget* RealWidget() override;
58 GtkCompositorWidget* AsX11() override { return this; }
59 CompositorWidgetDelegate* AsDelegate() override { return this; }
61 EGLNativeWindowType GetEGLNativeWindow();
62 int32_t GetDepth();
64 #if defined(MOZ_X11)
65 Display* XDisplay() const { return mXDisplay; }
66 Window XWindow() const { return mXWindow; }
67 #endif
68 #if defined(MOZ_WAYLAND)
69 void SetEGLNativeWindowSize(const LayoutDeviceIntSize& aEGLWindowSize);
70 #endif
72 // PlatformCompositorWidgetDelegate Overrides
74 void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize) override;
76 protected:
77 nsWindow* mWidget;
79 private:
80 // This field is written to on the main thread and read from on the compositor
81 // or renderer thread. During window resizing, this is subject to a (largely
82 // benign) read/write race, see bug 1665726. The DataMutex doesn't prevent the
83 // read/write race, but it does make it Not Undefined Behaviour, and also
84 // ensures we only ever use the old or new size, and not some weird synthesis
85 // of the two.
86 DataMutex<LayoutDeviceIntSize> mClientSize;
88 WindowSurfaceProvider mProvider;
90 #if defined(MOZ_X11)
91 Display* mXDisplay = {};
92 Window mXWindow = {};
93 #endif
94 int32_t mDepth = {};
97 } // namespace widget
98 } // namespace mozilla
100 #endif // widget_gtk_GtkCompositorWidget_h