summaryrefslogtreecommitdiff
path: root/rb244010.patch
blob: 0df8c3bf1ecd6a106b636278973993d66f67644b (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
diff --git a/gfx/gl/GLContextProviderWayland.cpp b/gfx/gl/GLContextProviderWayland.cpp
new file mode 100644
--- /dev/null
+++ b/gfx/gl/GLContextProviderWayland.cpp
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifdef MOZ_WIDGET_GTK
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#endif
+
+#include "GLContextProvider.h"
+
+namespace mozilla {
+namespace gl {
+
+using namespace mozilla::gfx;
+using namespace mozilla::widget;
+
+static class GLContextProviderGLX sGLContextProviderGLX;
+static class GLContextProviderEGL sGLContextProviderEGL;
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateWrappingExisting(void* aContext, void* aSurface)
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.CreateWrappingExisting(aContext, aSurface);
+    } else {
+        return sGLContextProviderEGL.CreateWrappingExisting(aContext, aSurface);
+    }
+}
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateForCompositorWidget(CompositorWidget* aCompositorWidget, bool aForceAccelerated)
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
+    } else {
+        return sGLContextProviderEGL.CreateForCompositorWidget(aCompositorWidget, aForceAccelerated);
+    }
+}
+
+already_AddRefed<GLContext>
+GLContextProviderWayland::CreateForWindow(nsIWidget* aWidget,
+                                      bool aWebRender,
+                                      bool aForceAccelerated)
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
+    } else {
+        return sGLContextProviderEGL.CreateForWindow(aWidget, aWebRender, aForceAccelerated);
+    }
+}
+
+/*static*/ already_AddRefed<GLContext>
+GLContextProviderWayland::CreateHeadless(CreateContextFlags flags,
+                                     nsACString* const out_failureId)
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.CreateHeadless(flags, out_failureId);
+    } else {
+        return sGLContextProviderEGL.CreateHeadless(flags, out_failureId);
+    }
+}
+
+/*static*/ already_AddRefed<GLContext>
+GLContextProviderWayland::CreateOffscreen(const IntSize& size,
+                                      const SurfaceCaps& minCaps,
+                                      CreateContextFlags flags,
+                                      nsACString* const out_failureId)
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.CreateOffscreen(size, minCaps, flags, out_failureId);
+    } else {
+        return sGLContextProviderEGL.CreateOffscreen(size, minCaps, flags, out_failureId);
+    }
+}
+
+/*static*/ GLContext*
+GLContextProviderWayland::GetGlobalContext()
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        return sGLContextProviderGLX.GetGlobalContext();
+    } else {
+        return sGLContextProviderEGL.GetGlobalContext();
+    }
+}
+
+/*static*/ void
+GLContextProviderWayland::Shutdown()
+{
+    if (GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
+        sGLContextProviderGLX.Shutdown();
+    } else {
+        sGLContextProviderEGL.Shutdown();
+    }
+}
+
+} /* namespace gl */
+} /* namespace mozilla */
diff --git a/gfx/gl/moz.build b/gfx/gl/moz.build
--- a/gfx/gl/moz.build
+++ b/gfx/gl/moz.build
@@ -8,17 +8,17 @@ gl_provider = 'Null'
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     gl_provider = 'WGL'
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     gl_provider = 'CGL'
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
     gl_provider = 'EAGL'
 elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
-    if CONFIG['MOZ_EGL_XRENDER_COMPOSITE'] or CONFIG['MOZ_WAYLAND']:
+    if CONFIG['MOZ_EGL_XRENDER_COMPOSITE']:
         gl_provider = 'EGL'
     else:
         gl_provider = 'GLX'
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     gl_provider = 'EGL'
 
 if CONFIG['MOZ_GL_PROVIDER']:
     gl_provider = CONFIG['MOZ_GL_PROVIDER']
@@ -114,16 +114,21 @@ elif gl_provider == 'GLX':
     SOURCES += [
         'GLContextProviderGLX.cpp',
         'SharedSurfaceGLX.cpp'
     ]
     EXPORTS += [
         'SharedSurfaceGLX.h'
     ]
 
+if CONFIG['MOZ_WAYLAND']:
+    SOURCES += [
+        'GLContextProviderWayland.cpp',
+    ]
+
 UNIFIED_SOURCES += [
     'AndroidSurfaceTexture.cpp',
     'DecomposeIntoNoRepeatTriangles.cpp',
     'EGLUtils.cpp',
     'GfxTexturesReporter.cpp',
     'GLBlitHelper.cpp',
     'GLContext.cpp',
     'GLContextFeatures.cpp',

bgstack15