1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set ts=8 sts=4 et sw=4 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"
15 #include <AppKit/NSOpenGL.h>
17 typedef void NSOpenGLContext
;
23 class GLContextCGL
: public GLContext
25 friend class GLContextProviderCGL
;
27 NSOpenGLContext
*mContext
;
30 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL
, MOZ_OVERRIDE
)
31 GLContextCGL(const SurfaceCaps
& caps
,
32 GLContext
*shareContext
,
33 NSOpenGLContext
*context
,
34 bool isOffscreen
= false);
38 virtual GLContextType
GetContextType() const MOZ_OVERRIDE
{ return GLContextType::CGL
; }
40 static GLContextCGL
* Cast(GLContext
* gl
) {
41 MOZ_ASSERT(gl
->GetContextType() == GLContextType::CGL
);
42 return static_cast<GLContextCGL
*>(gl
);
45 bool Init() MOZ_OVERRIDE
;
47 NSOpenGLContext
* GetNSOpenGLContext() const { return mContext
; }
48 CGLContextObj
GetCGLContext() const;
50 virtual bool MakeCurrentImpl(bool aForce
) MOZ_OVERRIDE
;
52 virtual bool IsCurrent() MOZ_OVERRIDE
;
54 virtual GLenum
GetPreferredARGB32Format() const MOZ_OVERRIDE
;
56 virtual bool SetupLookupFunction() MOZ_OVERRIDE
;
58 virtual bool IsDoubleBuffered() const MOZ_OVERRIDE
;
60 virtual bool SupportsRobustness() const MOZ_OVERRIDE
;
62 virtual bool SwapBuffers() MOZ_OVERRIDE
;
68 #endif // GLCONTEXTCGL_H_