1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -88,10 +88,14 @@
#if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WAYLAND)
- if (gl->GetContextType() == GLContextType::EGL) {
- if (gfxPlatformGtk::GetPlatform()->UseWaylandDMABufWebGL()) {
- factory =
- MakeUnique<SurfaceFactory_DMABUF>(gl, caps, ipcChannel, flags);
+ if (gl->GetContextType() == GLContextType::EGL &&
+ gfxPlatformGtk::GetPlatform()->UseWaylandDMABufWebGL()) {
+ auto DMABUFFactory =
+ MakeUnique<SurfaceFactory_DMABUF>(gl, caps, ipcChannel, flags);
+ if (DMABUFFactory && DMABUFFactory->CanCreateSurface()) {
+ factory = std::move(DMABUFFactory);
+ } else {
+ gfxPlatformGtk::GetPlatform()->DisableWaylandDMABufWebGL();
}
}
#elif defined(MOZ_X11)
diff --git a/gfx/gl/SharedSurfaceDMABUF.h b/gfx/gl/SharedSurfaceDMABUF.h
--- a/gfx/gl/SharedSurfaceDMABUF.h
+++ b/gfx/gl/SharedSurfaceDMABUF.h
@@ -71,6 +71,11 @@
bool hasAlpha = mReadCaps.alpha;
return SharedSurface_DMABUF::Create(mGL, mFormats, size, hasAlpha);
}
+
+ bool CanCreateSurface() {
+ UniquePtr<SharedSurface> test = CreateShared(gfx::IntSize(1, 1));
+ return test != nullptr;
+ }
};
} // namespace gl
diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h
--- a/gfx/thebes/gfxPlatformGtk.h
+++ b/gfx/thebes/gfxPlatformGtk.h
@@ -88,7 +88,8 @@
#ifdef MOZ_WAYLAND
bool UseWaylandDMABufTextures();
- bool UseWaylandDMABufWebGL();
+ bool UseWaylandDMABufWebGL() { return mUseWebGLDmabufBackend; }
+ void DisableWaylandDMABufWebGL() { mUseWebGLDmabufBackend = false; }
bool UseWaylandHardwareVideoDecoding();
#endif
@@ -110,6 +111,9 @@
#ifdef MOZ_X11
Display* mCompositorDisplay;
#endif
+#ifdef MOZ_WAYLAND
+ bool mUseWebGLDmabufBackend;
+#endif
};
#endif /* GFX_PLATFORM_GTK_H */
diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp
--- a/gfx/thebes/gfxPlatformGtk.cpp
+++ b/gfx/thebes/gfxPlatformGtk.cpp
@@ -116,6 +116,9 @@
Factory::ReleaseFTLibrary(gPlatformFTLibrary);
gPlatformFTLibrary = nullptr;
+
+ mUseWebGLDmabufBackend =
+ IsWaylandDisplay() && nsWaylandDisplay::IsDMABufWebGLEnabled();
}
void gfxPlatformGtk::FlushContentDrawing() {
@@ -725,9 +728,6 @@
bool gfxPlatformGtk::UseWaylandDMABufTextures() {
return IsWaylandDisplay() && nsWaylandDisplay::IsDMABufTexturesEnabled();
}
-bool gfxPlatformGtk::UseWaylandDMABufWebGL() {
- return IsWaylandDisplay() && nsWaylandDisplay::IsDMABufWebGLEnabled();
-}
bool gfxPlatformGtk::UseWaylandHardwareVideoDecoding() {
return IsWaylandDisplay() && nsWaylandDisplay::IsDMABufVAAPIEnabled() &&
gfxPlatform::CanUseHardwareVideoDecoding();
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -9111,7 +9111,7 @@
# Use DMABuf backend for WebGL on Wayland.
- name: widget.wayland-dmabuf-webgl.enabled
type: RelaxedAtomicBool
- value: false
+ value: true
mirror: always
# Use VA-API for video playback on Wayland.
|