|
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/. */ |
|
6 |
|
7 #ifndef GLCONTEXTCGL_H_ |
|
8 #define GLCONTEXTCGL_H_ |
|
9 |
|
10 #include "GLContext.h" |
|
11 |
|
12 #include "OpenGL/OpenGL.h" |
|
13 |
|
14 #ifdef __OBJC__ |
|
15 #include <AppKit/NSOpenGL.h> |
|
16 #else |
|
17 typedef void NSOpenGLContext; |
|
18 #endif |
|
19 |
|
20 namespace mozilla { |
|
21 namespace gl { |
|
22 |
|
23 class GLContextCGL : public GLContext |
|
24 { |
|
25 friend class GLContextProviderCGL; |
|
26 |
|
27 NSOpenGLContext *mContext; |
|
28 |
|
29 public: |
|
30 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL) |
|
31 GLContextCGL(const SurfaceCaps& caps, |
|
32 GLContext *shareContext, |
|
33 NSOpenGLContext *context, |
|
34 bool isOffscreen = false); |
|
35 |
|
36 ~GLContextCGL(); |
|
37 |
|
38 virtual GLContextType GetContextType() const MOZ_OVERRIDE { return GLContextType::CGL; } |
|
39 |
|
40 static GLContextCGL* Cast(GLContext* gl) { |
|
41 MOZ_ASSERT(gl->GetContextType() == GLContextType::CGL); |
|
42 return static_cast<GLContextCGL*>(gl); |
|
43 } |
|
44 |
|
45 bool Init() MOZ_OVERRIDE; |
|
46 |
|
47 NSOpenGLContext* GetNSOpenGLContext() const { return mContext; } |
|
48 CGLContextObj GetCGLContext() const; |
|
49 |
|
50 virtual bool MakeCurrentImpl(bool aForce) MOZ_OVERRIDE; |
|
51 |
|
52 virtual bool IsCurrent() MOZ_OVERRIDE; |
|
53 |
|
54 virtual GLenum GetPreferredARGB32Format() const MOZ_OVERRIDE; |
|
55 |
|
56 virtual bool SetupLookupFunction() MOZ_OVERRIDE; |
|
57 |
|
58 virtual bool IsDoubleBuffered() const MOZ_OVERRIDE; |
|
59 |
|
60 virtual bool SupportsRobustness() const MOZ_OVERRIDE; |
|
61 |
|
62 virtual bool SwapBuffers() MOZ_OVERRIDE; |
|
63 }; |
|
64 |
|
65 } |
|
66 } |
|
67 |
|
68 #endif // GLCONTEXTCGL_H_ |