OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 5 #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_export.h" | |
11 | 10 |
12 namespace gpu { | 11 namespace gpu { |
13 namespace gles2 { | 12 namespace gles2 { |
14 class GLES2Decoder; | 13 class GLES2Decoder; |
15 } | 14 } |
16 } | 15 } |
17 namespace gfx { | 16 namespace gfx { |
18 | 17 |
19 class GLContext; | 18 class GLContext; |
20 class GLSurface; | 19 class GLSurface; |
21 | 20 |
22 void InitializeStaticGLBindingsGL(); | 21 void InitializeStaticGLBindingsGL(); |
23 void InitializeDynamicGLBindingsGL(GLContext* context); | 22 void InitializeDynamicGLBindingsGL(GLContext* context); |
24 void InitializeDebugGLBindingsGL(); | 23 void InitializeDebugGLBindingsGL(); |
25 void InitializeNullDrawGLBindingsGL(); | 24 void InitializeNullDrawGLBindingsGL(); |
26 // TODO(danakj): Remove this when all test suites are using null-draw. | 25 // TODO(danakj): Remove this when all test suites are using null-draw. |
27 bool HasInitializedNullDrawGLBindingsGL(); | 26 bool HasInitializedNullDrawGLBindingsGL(); |
28 bool SetNullDrawGLBindingsEnabledGL(bool enabled); | 27 bool SetNullDrawGLBindingsEnabledGL(bool enabled); |
29 void ClearGLBindingsGL(); | 28 void ClearGLBindingsGL(); |
30 void SetGLToRealGLApi(); | 29 void SetGLToRealGLApi(); |
31 void SetGLApi(GLApi* api); | 30 void SetGLApi(GLApi* api); |
| 31 void SetGLApiToNoContext(); |
32 | 32 |
33 class GL_EXPORT GLApiBase : public GLApi { | 33 class GLApiBase : public GLApi { |
34 public: | 34 public: |
35 // Include the auto-generated part of this class. We split this because | 35 // Include the auto-generated part of this class. We split this because |
36 // it means we can easily edit the non-auto generated parts right here in | 36 // it means we can easily edit the non-auto generated parts right here in |
37 // this file instead of having to edit some template or the code generator. | 37 // this file instead of having to edit some template or the code generator. |
38 #include "gl_bindings_api_autogen_gl.h" | 38 #include "gl_bindings_api_autogen_gl.h" |
39 | 39 |
40 protected: | 40 protected: |
41 GLApiBase(); | 41 GLApiBase(); |
42 virtual ~GLApiBase(); | 42 virtual ~GLApiBase(); |
43 void InitializeBase(DriverGL* driver); | 43 void InitializeBase(DriverGL* driver); |
44 | 44 |
45 DriverGL* driver_; | 45 DriverGL* driver_; |
46 }; | 46 }; |
47 | 47 |
48 // Implemenents the GL API by calling directly into the driver. | 48 // Implemenents the GL API by calling directly into the driver. |
49 class GL_EXPORT RealGLApi : public GLApiBase { | 49 class RealGLApi : public GLApiBase { |
50 public: | 50 public: |
51 RealGLApi(); | 51 RealGLApi(); |
52 virtual ~RealGLApi(); | 52 virtual ~RealGLApi(); |
53 void Initialize(DriverGL* driver); | 53 void Initialize(DriverGL* driver); |
54 }; | 54 }; |
55 | 55 |
56 // Inserts a TRACE for every GL call. | 56 // Inserts a TRACE for every GL call. |
57 class GL_EXPORT TraceGLApi : public GLApi { | 57 class TraceGLApi : public GLApi { |
58 public: | 58 public: |
59 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } | 59 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } |
60 virtual ~TraceGLApi(); | 60 virtual ~TraceGLApi(); |
61 | 61 |
62 // Include the auto-generated part of this class. We split this because | 62 // Include the auto-generated part of this class. We split this because |
63 // it means we can easily edit the non-auto generated parts right here in | 63 // it means we can easily edit the non-auto generated parts right here in |
64 // this file instead of having to edit some template or the code generator. | 64 // this file instead of having to edit some template or the code generator. |
65 #include "gl_bindings_api_autogen_gl.h" | 65 #include "gl_bindings_api_autogen_gl.h" |
66 | 66 |
67 private: | 67 private: |
68 GLApi* gl_api_; | 68 GLApi* gl_api_; |
69 }; | 69 }; |
70 | 70 |
| 71 // Catches incorrect usage when GL calls are made without a current context. |
| 72 class NoContextGLApi : public GLApi { |
| 73 public: |
| 74 NoContextGLApi(); |
| 75 virtual ~NoContextGLApi(); |
| 76 |
| 77 // Include the auto-generated part of this class. We split this because |
| 78 // it means we can easily edit the non-auto generated parts right here in |
| 79 // this file instead of having to edit some template or the code generator. |
| 80 #include "gl_bindings_api_autogen_gl.h" |
| 81 }; |
| 82 |
71 // Implementents the GL API using co-operative state restoring. | 83 // Implementents the GL API using co-operative state restoring. |
72 // Assumes there is only one real GL context and that multiple virtual contexts | 84 // Assumes there is only one real GL context and that multiple virtual contexts |
73 // are implemented above it. Restores the needed state from the current context. | 85 // are implemented above it. Restores the needed state from the current context. |
74 class GL_EXPORT VirtualGLApi : public GLApiBase { | 86 class VirtualGLApi : public GLApiBase { |
75 public: | 87 public: |
76 VirtualGLApi(); | 88 VirtualGLApi(); |
77 virtual ~VirtualGLApi(); | 89 virtual ~VirtualGLApi(); |
78 void Initialize(DriverGL* driver, GLContext* real_context); | 90 void Initialize(DriverGL* driver, GLContext* real_context); |
79 | 91 |
80 // Sets the current virutal context. | 92 // Sets the current virutal context. |
81 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); | 93 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); |
82 | 94 |
83 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 95 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
84 | 96 |
85 // Overridden functions from GLApiBase | 97 // Overridden functions from GLApiBase |
86 virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE; | 98 virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE; |
87 | 99 |
88 private: | 100 private: |
89 // The real context we're running on. | 101 // The real context we're running on. |
90 GLContext* real_context_; | 102 GLContext* real_context_; |
91 | 103 |
92 // The current virtual context. | 104 // The current virtual context. |
93 GLContext* current_context_; | 105 GLContext* current_context_; |
94 | 106 |
95 // The supported extensions being advertised for this virtual context. | 107 // The supported extensions being advertised for this virtual context. |
96 std::string extensions_; | 108 std::string extensions_; |
97 }; | 109 }; |
98 | 110 |
99 } // namespace gfx | 111 } // namespace gfx |
100 | 112 |
101 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 113 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
OLD | NEW |