Bug 1744358 move MediaEngineDefault-specific MediaEngineSource classes out of header...
[gecko.git] / gfx / gl / GLContextProviderX11.cpp
blob17bb2a9fcd3c9ad2269864f3f426a621c8ee3b37
1 /* -*- Mode: C++; tab-width: 20; 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 #include "prenv.h"
8 #include "GLContextProvider.h"
9 #include "mozilla/gfx/gfxVars.h"
11 namespace mozilla::gl {
13 using namespace mozilla::gfx;
14 using namespace mozilla::widget;
16 static class GLContextProviderGLX sGLContextProviderGLX;
17 static class GLContextProviderEGL sGLContextProviderEGL;
19 already_AddRefed<GLContext> GLContextProviderX11::CreateForCompositorWidget(
20 CompositorWidget* aCompositorWidget, bool aHardwareWebRender,
21 bool aForceAccelerated) {
22 if (!gfxVars::UseEGL()) {
23 return sGLContextProviderGLX.CreateForCompositorWidget(
24 aCompositorWidget, aHardwareWebRender, aForceAccelerated);
25 } else {
26 return sGLContextProviderEGL.CreateForCompositorWidget(
27 aCompositorWidget, aHardwareWebRender, aForceAccelerated);
31 /*static*/
32 already_AddRefed<GLContext> GLContextProviderX11::CreateHeadless(
33 const GLContextCreateDesc& desc, nsACString* const out_failureId) {
34 if (!gfxVars::UseEGL()) {
35 return sGLContextProviderGLX.CreateHeadless(desc, out_failureId);
36 } else {
37 return sGLContextProviderEGL.CreateHeadless(desc, out_failureId);
41 /*static*/
42 GLContext* GLContextProviderX11::GetGlobalContext() {
43 if (!gfxVars::UseEGL()) {
44 return sGLContextProviderGLX.GetGlobalContext();
45 } else {
46 return sGLContextProviderEGL.GetGlobalContext();
50 /*static*/
51 void GLContextProviderX11::Shutdown() {
52 if (!gfxVars::UseEGL()) {
53 sGLContextProviderGLX.Shutdown();
54 } else {
55 sGLContextProviderEGL.Shutdown();
59 } // namespace mozilla::gl