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
10 #include "mozilla/DataMutex.h"
11 #include "mozilla/widget/CompositorWidget.h"
12 #include "WindowSurfaceProvider.h"
20 class PlatformCompositorWidgetDelegate
: public CompositorWidgetDelegate
{
22 virtual void NotifyClientSizeChanged(
23 const LayoutDeviceIntSize
& aClientSize
) = 0;
25 // CompositorWidgetDelegate Overrides
27 PlatformCompositorWidgetDelegate
* AsPlatformSpecificDelegate() override
{
32 class GtkCompositorWidgetInitData
;
34 class GtkCompositorWidget
: public CompositorWidget
,
35 public PlatformCompositorWidgetDelegate
{
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();
65 Display
* XDisplay() const { return mXDisplay
; }
66 Window
XWindow() const { return mXWindow
; }
68 #if defined(MOZ_WAYLAND)
69 void SetEGLNativeWindowSize(const LayoutDeviceIntSize
& aEGLWindowSize
);
72 // PlatformCompositorWidgetDelegate Overrides
74 void NotifyClientSizeChanged(const LayoutDeviceIntSize
& aClientSize
) override
;
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
86 DataMutex
<LayoutDeviceIntSize
> mClientSize
;
88 WindowSurfaceProvider mProvider
;
91 Display
* mXDisplay
= {};
98 } // namespace mozilla
100 #endif // widget_gtk_GtkCompositorWidget_h