Bug 1876177 [wpt PR 44153] - [FedCM] Add a WPT test for authz, a=testonly
[gecko.git] / gfx / gl / GLContextCGL.h
blobb065df4554eb9444eddfbb9da8d88f12df18e58b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef GLCONTEXTCGL_H_
8 #define GLCONTEXTCGL_H_
10 #include "GLContext.h"
12 #include "OpenGL/OpenGL.h"
14 #ifdef __OBJC__
15 # include <AppKit/NSOpenGL.h>
16 #else
17 typedef void NSOpenGLContext;
18 #endif
20 #include <CoreGraphics/CGDisplayConfiguration.h>
22 #include "mozilla/Atomics.h"
24 class nsIWidget;
26 namespace mozilla {
27 namespace gl {
29 class GLContextCGL : public GLContext {
30 friend class GLContextProviderCGL;
32 NSOpenGLContext* mContext;
34 mozilla::Atomic<bool> mActiveGPUSwitchMayHaveOccurred;
36 public:
37 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL, override)
38 GLContextCGL(const GLContextDesc&, NSOpenGLContext* context);
40 ~GLContextCGL();
42 virtual GLContextType GetContextType() const override {
43 return GLContextType::CGL;
46 static GLContextCGL* Cast(GLContext* gl) {
47 MOZ_ASSERT(gl->GetContextType() == GLContextType::CGL);
48 return static_cast<GLContextCGL*>(gl);
51 NSOpenGLContext* GetNSOpenGLContext() const { return mContext; }
52 CGLContextObj GetCGLContext() const;
54 // Can be called on any thread
55 static void DisplayReconfigurationCallback(CGDirectDisplayID aDisplay,
56 CGDisplayChangeSummaryFlags aFlags,
57 void* aUserInfo);
59 // Call at the beginning of a frame, on contexts that should stay on the
60 // active GPU. This method will migrate the context to the new active GPU, if
61 // the active GPU has changed since the last call.
62 void MigrateToActiveGPU();
64 virtual bool MakeCurrentImpl() const override;
66 virtual bool IsCurrentImpl() const override;
68 virtual GLenum GetPreferredARGB32Format() const override;
70 virtual bool SwapBuffers() override;
72 virtual void GetWSIInfo(nsCString* const out) const override;
74 Maybe<SymbolLoader> GetSymbolLoader() const override;
77 } // namespace gl
78 } // namespace mozilla
80 #endif // GLCONTEXTCGL_H_