gfx/gl/GLContextProviderLinux.cpp
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Sun, 07 Aug 2022 07:00:20 +0000
changeset 626346 44a5d0f480929c4a3850e68f2701a907439f8c57
parent 624734 4838310f6e6c5c823c91fdafdb2fddf369b3a28d
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD ia -> 13b119f6b22fd39552b8ca6d8365d0fdfee076fd uk -> 04dd614d47732b72ee99dd913df676bb70d1cd60

/* -*- 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"
#include "mozilla/gfx/gfxVars.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()) {
    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