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/. */
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
);
26 return sGLContextProviderEGL
.CreateForCompositorWidget(
27 aCompositorWidget
, aHardwareWebRender
, aForceAccelerated
);
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
);
37 return sGLContextProviderEGL
.CreateHeadless(desc
, out_failureId
);
42 GLContext
* GLContextProviderX11::GetGlobalContext() {
43 if (!gfxVars::UseEGL()) {
44 return sGLContextProviderGLX
.GetGlobalContext();
46 return sGLContextProviderEGL
.GetGlobalContext();
51 void GLContextProviderX11::Shutdown() {
52 if (!gfxVars::UseEGL()) {
53 sGLContextProviderGLX
.Shutdown();
55 sGLContextProviderEGL
.Shutdown();
59 } // namespace mozilla::gl