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
;
17 static class GLContextProviderGLX sGLContextProviderGLX
;
19 static class GLContextProviderEGL sGLContextProviderEGL
;
21 already_AddRefed
<GLContext
> GLContextProviderLinux::CreateForCompositorWidget(
22 CompositorWidget
* aCompositorWidget
, bool aHardwareWebRender
,
23 bool aForceAccelerated
) {
24 if (gfxVars::UseEGL()) {
25 return sGLContextProviderEGL
.CreateForCompositorWidget(
26 aCompositorWidget
, aHardwareWebRender
, aForceAccelerated
);
29 return sGLContextProviderGLX
.CreateForCompositorWidget(
30 aCompositorWidget
, aHardwareWebRender
, aForceAccelerated
);
36 already_AddRefed
<GLContext
> GLContextProviderLinux::CreateHeadless(
37 const GLContextCreateDesc
& desc
, nsACString
* const out_failureId
) {
38 if (gfxVars::UseEGL()) {
39 return sGLContextProviderEGL
.CreateHeadless(desc
, out_failureId
);
42 return sGLContextProviderGLX
.CreateHeadless(desc
, out_failureId
);
48 GLContext
* GLContextProviderLinux::GetGlobalContext() {
49 if (gfxVars::UseEGL()) {
50 return sGLContextProviderEGL
.GetGlobalContext();
53 return sGLContextProviderGLX
.GetGlobalContext();
59 void GLContextProviderLinux::Shutdown() {
60 if (gfxVars::UseEGL()) {
61 sGLContextProviderEGL
.Shutdown();
64 sGLContextProviderGLX
.Shutdown();
69 } // namespace mozilla::gl