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 <memory> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
12 #include "ui/gl/gl_export.h" | 13 #include "ui/gl/gl_export.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class CommandLine; | 16 class CommandLine; |
16 } | 17 } |
17 | 18 |
18 namespace gl { | 19 namespace gl { |
19 | 20 |
20 class GLContext; | |
21 struct GLVersionInfo; | 21 struct GLVersionInfo; |
22 | 22 |
23 GL_EXPORT void InitializeStaticGLBindingsGL(); | 23 GL_EXPORT void InitializeStaticGLBindingsGL(); |
24 void InitializeDynamicGLBindingsGL(GLContext* context); | 24 GL_EXPORT void ClearBindingsGL(); |
| 25 |
25 GL_EXPORT void InitializeDebugGLBindingsGL(); | 26 GL_EXPORT void InitializeDebugGLBindingsGL(); |
26 void InitializeNullDrawGLBindingsGL(); | 27 bool GetDebugGLBindingsInitializedGL(); |
27 // TODO(danakj): Remove this when all test suites are using null-draw. | 28 |
28 bool HasInitializedNullDrawGLBindingsGL(); | 29 bool SetNullDrawGLBindingsEnabled(bool enabled); |
29 bool SetNullDrawGLBindingsEnabledGL(bool enabled); | 30 bool GetNullDrawBindingsEnabled(); |
30 GL_EXPORT void ClearBindingsGL(); | 31 |
31 void SetGLToRealGLApi(); | 32 void SetCurrentGL(CurrentGL* current); |
32 void SetGLToStubGLApi(); | |
33 void SetGLApi(GLApi* api); | |
34 void SetGLApiToNoContext(); | |
35 GLApi* GetCurrentGLApi(); | |
36 GL_EXPORT void SetStubGLApi(GLApi* api); | |
37 const GLVersionInfo* GetGLVersionInfo(); | |
38 | 33 |
39 class GL_EXPORT GLApiBase : public GLApi { | 34 class GL_EXPORT GLApiBase : public GLApi { |
40 public: | 35 public: |
41 // Include the auto-generated part of this class. We split this because | 36 // Include the auto-generated part of this class. We split this because |
42 // it means we can easily edit the non-auto generated parts right here in | 37 // it means we can easily edit the non-auto generated parts right here in |
43 // this file instead of having to edit some template or the code generator. | 38 // this file instead of having to edit some template or the code generator. |
44 #include "gl_bindings_api_autogen_gl.h" | 39 #include "gl_bindings_api_autogen_gl.h" |
45 | 40 |
46 protected: | 41 protected: |
47 GLApiBase(); | 42 GLApiBase(); |
48 ~GLApiBase() override; | 43 ~GLApiBase() override; |
49 void InitializeBase(DriverGL* driver); | 44 void InitializeBase(DriverGL* driver); |
50 | 45 |
51 DriverGL* driver_; | 46 DriverGL* driver_; |
52 }; | 47 }; |
53 | 48 |
54 // Implemenents the GL API by calling directly into the driver. | 49 // Implemenents the GL API by calling directly into the driver. |
55 class GL_EXPORT RealGLApi : public GLApiBase { | 50 class GL_EXPORT RealGLApi : public GLApiBase { |
56 public: | 51 public: |
57 RealGLApi(); | 52 RealGLApi(); |
58 ~RealGLApi() override; | 53 ~RealGLApi() override; |
59 void Initialize(DriverGL* driver); | 54 void Initialize(DriverGL* driver); |
60 void InitializeWithCommandLine(DriverGL* driver, | 55 void InitializeWithCommandLine(DriverGL* driver, |
61 base::CommandLine* command_line); | 56 base::CommandLine* command_line); |
62 | 57 |
63 void glGetIntegervFn(GLenum pname, GLint* params) override; | 58 void glGetIntegervFn(GLenum pname, GLint* params) override; |
64 const GLubyte* glGetStringFn(GLenum name) override; | 59 const GLubyte* glGetStringFn(GLenum name) override; |
65 const GLubyte* glGetStringiFn(GLenum name, GLuint index) override; | 60 const GLubyte* glGetStringiFn(GLenum name, GLuint index) override; |
66 | 61 |
| 62 void glTexImage2DFn(GLenum target, |
| 63 GLint level, |
| 64 GLint internalformat, |
| 65 GLsizei width, |
| 66 GLsizei height, |
| 67 GLint border, |
| 68 GLenum format, |
| 69 GLenum type, |
| 70 const void* pixels) override; |
| 71 |
| 72 void glTexSubImage2DFn(GLenum target, |
| 73 GLint level, |
| 74 GLint xoffset, |
| 75 GLint yoffset, |
| 76 GLsizei width, |
| 77 GLsizei height, |
| 78 GLenum format, |
| 79 GLenum type, |
| 80 const void* pixels) override; |
| 81 |
| 82 void glTexStorage2DEXTFn(GLenum target, |
| 83 GLsizei levels, |
| 84 GLenum internalformat, |
| 85 GLsizei width, |
| 86 GLsizei height) override; |
| 87 |
| 88 void glRenderbufferStorageEXTFn(GLenum target, |
| 89 GLenum internalformat, |
| 90 GLsizei width, |
| 91 GLsizei height) override; |
| 92 |
| 93 void glRenderbufferStorageMultisampleEXTFn(GLenum target, |
| 94 GLsizei samples, |
| 95 GLenum internalformat, |
| 96 GLsizei width, |
| 97 GLsizei height) override; |
| 98 |
| 99 void glRenderbufferStorageMultisampleFn(GLenum target, |
| 100 GLsizei samples, |
| 101 GLenum internalformat, |
| 102 GLsizei width, |
| 103 GLsizei height) override; |
| 104 |
| 105 void glClearFn(GLbitfield mask) override; |
| 106 void glDrawArraysFn(GLenum mode, GLint first, GLsizei count) override; |
| 107 void glDrawElementsFn(GLenum mode, |
| 108 GLsizei count, |
| 109 GLenum type, |
| 110 const void* indices) override; |
| 111 |
| 112 void glClearDepthFn(GLclampd depth) override; |
| 113 void glDepthRangeFn(GLclampd z_near, GLclampd z_far) override; |
| 114 |
67 void InitializeFilteredExtensions(); | 115 void InitializeFilteredExtensions(); |
| 116 void set_version(std::unique_ptr<GLVersionInfo> version); |
68 | 117 |
69 private: | 118 private: |
70 // Filtered GL_EXTENSIONS we return to glGetString(i) calls. | 119 // Filtered GL_EXTENSIONS we return to glGetString(i) calls. |
71 std::vector<std::string> disabled_exts_; | 120 std::vector<std::string> disabled_exts_; |
72 std::vector<std::string> filtered_exts_; | 121 std::vector<std::string> filtered_exts_; |
73 std::string filtered_exts_str_; | 122 std::string filtered_exts_str_; |
74 | 123 |
| 124 std::unique_ptr<GLVersionInfo> version_; |
| 125 |
75 #if DCHECK_IS_ON() | 126 #if DCHECK_IS_ON() |
76 bool filtered_exts_initialized_; | 127 bool filtered_exts_initialized_; |
77 #endif | 128 #endif |
78 }; | 129 }; |
79 | 130 |
80 // Inserts a TRACE for every GL call. | 131 // Inserts a TRACE for every GL call. |
81 class TraceGLApi : public GLApi { | 132 class TraceGLApi : public GLApi { |
82 public: | 133 public: |
83 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } | 134 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } |
84 ~TraceGLApi() override; | 135 ~TraceGLApi() override; |
85 | 136 |
86 // Include the auto-generated part of this class. We split this because | 137 // Include the auto-generated part of this class. We split this because |
87 // it means we can easily edit the non-auto generated parts right here in | 138 // it means we can easily edit the non-auto generated parts right here in |
88 // this file instead of having to edit some template or the code generator. | 139 // this file instead of having to edit some template or the code generator. |
89 #include "gl_bindings_api_autogen_gl.h" | 140 #include "gl_bindings_api_autogen_gl.h" |
90 | 141 |
91 private: | 142 private: |
92 GLApi* gl_api_; | 143 GLApi* gl_api_; |
93 }; | 144 }; |
94 | 145 |
| 146 // Logs debug information for every GL call. |
| 147 class DebugGLApi : public GLApi { |
| 148 public: |
| 149 DebugGLApi(GLApi* gl_api); |
| 150 ~DebugGLApi() override; |
| 151 |
| 152 // Include the auto-generated part of this class. We split this because |
| 153 // it means we can easily edit the non-auto generated parts right here in |
| 154 // this file instead of having to edit some template or the code generator. |
| 155 #include "gl_bindings_api_autogen_gl.h" |
| 156 |
| 157 private: |
| 158 GLApi* gl_api_; |
| 159 }; |
| 160 |
95 // Catches incorrect usage when GL calls are made without a current context. | 161 // Catches incorrect usage when GL calls are made without a current context. |
96 class NoContextGLApi : public GLApi { | 162 class NoContextGLApi : public GLApi { |
97 public: | 163 public: |
98 NoContextGLApi(); | 164 NoContextGLApi(); |
99 ~NoContextGLApi() override; | 165 ~NoContextGLApi() override; |
100 | 166 |
101 // Include the auto-generated part of this class. We split this because | 167 // Include the auto-generated part of this class. We split this because |
102 // it means we can easily edit the non-auto generated parts right here in | 168 // it means we can easily edit the non-auto generated parts right here in |
103 // this file instead of having to edit some template or the code generator. | 169 // this file instead of having to edit some template or the code generator. |
104 #include "gl_bindings_api_autogen_gl.h" | 170 #include "gl_bindings_api_autogen_gl.h" |
105 }; | 171 }; |
106 | 172 |
107 } // namespace gl | 173 } // namespace gl |
108 | 174 |
109 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 175 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
OLD | NEW |