2020-07-02 16:50:41 +03:00
|
|
|
/* -*- 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"
|
2020-07-22 21:58:11 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2020-07-02 16:50:41 +03:00
|
|
|
|
|
|
|
namespace mozilla::gl {
|
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::widget;
|
|
|
|
|
|
|
|
static class GLContextProviderGLX sGLContextProviderGLX;
|
|
|
|
static class GLContextProviderEGL sGLContextProviderEGL;
|
|
|
|
|
|
|
|
already_AddRefed<GLContext> GLContextProviderX11::CreateForCompositorWidget(
|
|
|
|
CompositorWidget* aCompositorWidget, bool aWebRender,
|
|
|
|
bool aForceAccelerated) {
|
2020-07-22 21:58:11 +03:00
|
|
|
if (!gfxVars::UseEGL()) {
|
2020-07-02 16:50:41 +03:00
|
|
|
return sGLContextProviderGLX.CreateForCompositorWidget(
|
|
|
|
aCompositorWidget, aWebRender, aForceAccelerated);
|
|
|
|
} else {
|
|
|
|
return sGLContextProviderEGL.CreateForCompositorWidget(
|
|
|
|
aCompositorWidget, aWebRender, aForceAccelerated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
already_AddRefed<GLContext> GLContextProviderX11::CreateHeadless(
|
|
|
|
const GLContextCreateDesc& desc, nsACString* const out_failureId) {
|
2020-07-22 21:58:11 +03:00
|
|
|
if (!gfxVars::UseEGL()) {
|
2020-07-02 16:50:41 +03:00
|
|
|
return sGLContextProviderGLX.CreateHeadless(desc, out_failureId);
|
|
|
|
} else {
|
|
|
|
return sGLContextProviderEGL.CreateHeadless(desc, out_failureId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
GLContext* GLContextProviderX11::GetGlobalContext() {
|
2020-07-22 21:58:11 +03:00
|
|
|
if (!gfxVars::UseEGL()) {
|
2020-07-02 16:50:41 +03:00
|
|
|
return sGLContextProviderGLX.GetGlobalContext();
|
|
|
|
} else {
|
|
|
|
return sGLContextProviderEGL.GetGlobalContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/
|
|
|
|
void GLContextProviderX11::Shutdown() {
|
2020-07-22 21:58:11 +03:00
|
|
|
if (!gfxVars::UseEGL()) {
|
2020-07-02 16:50:41 +03:00
|
|
|
sGLContextProviderGLX.Shutdown();
|
|
|
|
} else {
|
|
|
|
sGLContextProviderEGL.Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla::gl
|