Add ICU message format support
[chromium-blink-merge.git] / ui / gl / gl_gl_api_implementation.h
bloba5197fed774418c6f6cfe8d338828febd1dfd761
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
3 // found in the LICENSE file.
5 #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_
6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_
8 #include <vector>
10 #include "base/compiler_specific.h"
11 #include "ui/gl/gl_bindings.h"
12 #include "ui/gl/gl_export.h"
14 namespace base {
15 class CommandLine;
17 namespace gpu {
18 namespace gles2 {
19 class GLES2Decoder;
22 namespace gfx {
24 class GLContext;
25 class GLSurface;
26 struct GLVersionInfo;
28 void InitializeStaticGLBindingsGL();
29 void InitializeDynamicGLBindingsGL(GLContext* context);
30 void InitializeDebugGLBindingsGL();
31 void InitializeNullDrawGLBindingsGL();
32 // TODO(danakj): Remove this when all test suites are using null-draw.
33 bool HasInitializedNullDrawGLBindingsGL();
34 bool SetNullDrawGLBindingsEnabledGL(bool enabled);
35 void ClearGLBindingsGL();
36 void SetGLToRealGLApi();
37 void SetGLApi(GLApi* api);
38 void SetGLApiToNoContext();
39 const GLVersionInfo* GetGLVersionInfo();
41 class GL_EXPORT GLApiBase : public GLApi {
42 public:
43 // Include the auto-generated part of this class. We split this because
44 // it means we can easily edit the non-auto generated parts right here in
45 // this file instead of having to edit some template or the code generator.
46 #include "gl_bindings_api_autogen_gl.h"
48 protected:
49 GLApiBase();
50 ~GLApiBase() override;
51 void InitializeBase(DriverGL* driver);
53 DriverGL* driver_;
56 // Implemenents the GL API by calling directly into the driver.
57 class GL_EXPORT RealGLApi : public GLApiBase {
58 public:
59 RealGLApi();
60 ~RealGLApi() override;
61 void Initialize(DriverGL* driver);
62 void InitializeWithCommandLine(DriverGL* driver,
63 base::CommandLine* command_line);
65 void glGetIntegervFn(GLenum pname, GLint* params) override;
66 const GLubyte* glGetStringFn(GLenum name) override;
67 const GLubyte* glGetStringiFn(GLenum name, GLuint index) override;
69 void InitializeFilteredExtensions();
71 private:
72 void glFinishFn() override;
73 void glFlushFn() override;
75 // Filtered GL_EXTENSIONS we return to glGetString(i) calls.
76 std::vector<std::string> disabled_exts_;
77 std::vector<std::string> filtered_exts_;
78 std::string filtered_exts_str_;
80 #if DCHECK_IS_ON()
81 bool filtered_exts_initialized_;
82 #endif
85 // Inserts a TRACE for every GL call.
86 class TraceGLApi : public GLApi {
87 public:
88 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
89 ~TraceGLApi() override;
91 // Include the auto-generated part of this class. We split this because
92 // it means we can easily edit the non-auto generated parts right here in
93 // this file instead of having to edit some template or the code generator.
94 #include "gl_bindings_api_autogen_gl.h"
96 private:
97 GLApi* gl_api_;
100 // Catches incorrect usage when GL calls are made without a current context.
101 class NoContextGLApi : public GLApi {
102 public:
103 NoContextGLApi();
104 ~NoContextGLApi() override;
106 // Include the auto-generated part of this class. We split this because
107 // it means we can easily edit the non-auto generated parts right here in
108 // this file instead of having to edit some template or the code generator.
109 #include "gl_bindings_api_autogen_gl.h"
112 // Implementents the GL API using co-operative state restoring.
113 // Assumes there is only one real GL context and that multiple virtual contexts
114 // are implemented above it. Restores the needed state from the current context.
115 class VirtualGLApi : public GLApiBase {
116 public:
117 VirtualGLApi();
118 ~VirtualGLApi() override;
119 void Initialize(DriverGL* driver, GLContext* real_context);
121 // Sets the current virutal context.
122 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
124 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
126 private:
127 // Overridden functions from GLApiBase
128 const GLubyte* glGetStringFn(GLenum name) override;
129 void glFinishFn() override;
130 void glFlushFn() override;
132 // The real context we're running on.
133 GLContext* real_context_;
135 // The current virtual context.
136 GLContext* current_context_;
138 // The supported extensions being advertised for this virtual context.
139 std::string extensions_;
142 class GL_EXPORT ScopedSetGLToRealGLApi {
143 public:
144 ScopedSetGLToRealGLApi();
145 ~ScopedSetGLToRealGLApi();
147 private:
148 GLApi* old_gl_api_;
151 } // namespace gfx
153 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_