Files
sousa-gecko/gfx/gl/GLContextProviderLinux.cpp
T
Emilio Cobos Álvarez 02d691fdef Bug 2054311 - Sort includes in gfx/. r=gfx-reviewers,gw
Autogenerated with:

    cp dom/.clang-format gfx/ && mach format gfx/**.{cpp,h,mm}

Manual changes:

    * OSVRSession headers are not system headers and they are not
      standalone / rely on stdint, so tweaked to preserve previous
      ordering.
    * Missing include in GLDefs.h
    * Missing include in gfxOTSUtils.
    * Need to keep the windows header order in DCLayerTree.
    * missing hb_font include in MockScaledFont.h

Differential Revision: https://phabricator.services.mozilla.com/D311695
2026-07-13 09:51:18 +00:00

71 lines
2.0 KiB
C++

/* 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 "GLContextProvider.h"
#include "mozilla/gfx/gfxVars.h"
#include "prenv.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() ||
bool(desc.flags & CreateContextFlags::FORBID_HARDWARE)) {
// We request EGL if software is required, because we don't know
// what X11 is using. It could be software or hardware.
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