summaryrefslogtreecommitdiffstats
path: root/gfx/gl/GLContextProviderLinux.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /gfx/gl/GLContextProviderLinux.cpp
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/gl/GLContextProviderLinux.cpp')
-rw-r--r--gfx/gl/GLContextProviderLinux.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/gfx/gl/GLContextProviderLinux.cpp b/gfx/gl/GLContextProviderLinux.cpp
new file mode 100644
index 0000000000..7205449387
--- /dev/null
+++ b/gfx/gl/GLContextProviderLinux.cpp
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+#include "prenv.h"
+
+#include "GLContextProvider.h"
+#include "mozilla/gfx/gfxVars.h"
+
+namespace mozilla::gl {
+
+using namespace mozilla::gfx;
+using namespace mozilla::widget;
+
+#ifdef MOZ_X11
+static class GLContextProviderGLX sGLContextProviderGLX;
+#endif
+static class GLContextProviderEGL sGLContextProviderEGL;
+
+already_AddRefed<GLContext> GLContextProviderLinux::CreateForCompositorWidget(
+ CompositorWidget* aCompositorWidget, bool aHardwareWebRender,
+ bool aForceAccelerated) {
+ if (gfxVars::UseEGL()) {
+ return sGLContextProviderEGL.CreateForCompositorWidget(
+ aCompositorWidget, aHardwareWebRender, aForceAccelerated);
+#ifdef MOZ_X11
+ } else {
+ return sGLContextProviderGLX.CreateForCompositorWidget(
+ aCompositorWidget, aHardwareWebRender, aForceAccelerated);
+#endif
+ }
+}
+
+/*static*/
+already_AddRefed<GLContext> GLContextProviderLinux::CreateHeadless(
+ const GLContextCreateDesc& desc, nsACString* const out_failureId) {
+ if (gfxVars::UseEGL()) {
+ return sGLContextProviderEGL.CreateHeadless(desc, out_failureId);
+#ifdef MOZ_X11
+ } else {
+ return sGLContextProviderGLX.CreateHeadless(desc, out_failureId);
+#endif
+ }
+}
+
+/*static*/
+GLContext* GLContextProviderLinux::GetGlobalContext() {
+ if (gfxVars::UseEGL()) {
+ return sGLContextProviderEGL.GetGlobalContext();
+#ifdef MOZ_X11
+ } else {
+ return sGLContextProviderGLX.GetGlobalContext();
+#endif
+ }
+}
+
+/*static*/
+void GLContextProviderLinux::Shutdown() {
+ if (gfxVars::UseEGL()) {
+ sGLContextProviderEGL.Shutdown();
+#ifdef MOZ_X11
+ } else {
+ sGLContextProviderGLX.Shutdown();
+#endif
+ }
+}
+
+} // namespace mozilla::gl