michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set ts=8 sts=4 et sw=4 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GLCONTEXTCGL_H_ michael@0: #define GLCONTEXTCGL_H_ michael@0: michael@0: #include "GLContext.h" michael@0: michael@0: #include "OpenGL/OpenGL.h" michael@0: michael@0: #ifdef __OBJC__ michael@0: #include michael@0: #else michael@0: typedef void NSOpenGLContext; michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLContextCGL : public GLContext michael@0: { michael@0: friend class GLContextProviderCGL; michael@0: michael@0: NSOpenGLContext *mContext; michael@0: michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL) michael@0: GLContextCGL(const SurfaceCaps& caps, michael@0: GLContext *shareContext, michael@0: NSOpenGLContext *context, michael@0: bool isOffscreen = false); michael@0: michael@0: ~GLContextCGL(); michael@0: michael@0: virtual GLContextType GetContextType() const MOZ_OVERRIDE { return GLContextType::CGL; } michael@0: michael@0: static GLContextCGL* Cast(GLContext* gl) { michael@0: MOZ_ASSERT(gl->GetContextType() == GLContextType::CGL); michael@0: return static_cast(gl); michael@0: } michael@0: michael@0: bool Init() MOZ_OVERRIDE; michael@0: michael@0: NSOpenGLContext* GetNSOpenGLContext() const { return mContext; } michael@0: CGLContextObj GetCGLContext() const; michael@0: michael@0: virtual bool MakeCurrentImpl(bool aForce) MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsCurrent() MOZ_OVERRIDE; michael@0: michael@0: virtual GLenum GetPreferredARGB32Format() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool SetupLookupFunction() MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsDoubleBuffered() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool SupportsRobustness() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool SwapBuffers() MOZ_OVERRIDE; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif // GLCONTEXTCGL_H_