author Mozilla Releng Treescript <>
Tue, 16 Aug 2022 19:03:11 +0000
changeset 627318 a51ffdf576ee6dde088f4a39c8e0d7d37844a830
parent 543720 192bcaecf2693450eadc00bf225a47d4b91b28f1
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD cy -> fe475b7bab2af983d4cee8e65e4972bfbcf66cec en-CA -> a3ef65c7edaf9177bc6d86a575da123b8724a329 en-GB -> a5a0d021121c2b7a8df335e57bfb0b432f7c7ca4 fr -> 4970122e206d2d09f9c62e143b6c762f0cbe1a9a fy-NL -> 291db3aaa83f252be9f5da671b265bb6fb45a28c gn -> 788acda2302098b31a0812bac3041737be91f8e3 it -> 12c20d432cac1df7c787e5c3d3aa112079c2378d nn-NO -> 2b14fbbce8aab53ad5eebbe7c2f13022a0fddd0f si -> 579629b003e5dd54eefdef80b4fd0c41bc167ee7 tr -> 1ace5ae3f35fafb4c08e4f2c6b43f87716f2bd7e

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 */


#include "GLContext.h"

#include "OpenGL/OpenGL.h"

#ifdef __OBJC__
#  include <AppKit/NSOpenGL.h>
typedef void NSOpenGLContext;

#include <CoreGraphics/CGDisplayConfiguration.h>

#include "mozilla/Atomics.h"

class nsIWidget;

namespace mozilla {
namespace gl {

class GLContextCGL : public GLContext {
  friend class GLContextProviderCGL;

  NSOpenGLContext* mContext;

  mozilla::Atomic<bool> mActiveGPUSwitchMayHaveOccurred;

  GLContextCGL(const GLContextDesc&, NSOpenGLContext* context);


  virtual GLContextType GetContextType() const override {
    return GLContextType::CGL;

  static GLContextCGL* Cast(GLContext* gl) {
    MOZ_ASSERT(gl->GetContextType() == GLContextType::CGL);
    return static_cast<GLContextCGL*>(gl);

  NSOpenGLContext* GetNSOpenGLContext() const { return mContext; }
  CGLContextObj GetCGLContext() const;

  // Can be called on any thread
  static void DisplayReconfigurationCallback(CGDirectDisplayID aDisplay,
                                             CGDisplayChangeSummaryFlags aFlags,
                                             void* aUserInfo);

  // Call at the beginning of a frame, on contexts that should stay on the
  // active GPU. This method will migrate the context to the new active GPU, if
  // the active GPU has changed since the last call.
  void MigrateToActiveGPU();

  virtual bool MakeCurrentImpl() const override;

  virtual bool IsCurrentImpl() const override;

  virtual GLenum GetPreferredARGB32Format() const override;

  virtual bool SwapBuffers() override;

  virtual void GetWSIInfo(nsCString* const out) const override;

  Maybe<SymbolLoader> GetSymbolLoader() const override;

}  // namespace gl
}  // namespace mozilla

#endif  // GLCONTEXTCGL_H_