cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ui / gl / gl_gl_api_implementation.h
blobcfefb1384bcdd77a0a1fbbcfde4256acbde8695f
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 GLApi* GetCurrentGLApi();
40 const GLVersionInfo* GetGLVersionInfo();
42 class GL_EXPORT GLApiBase : public GLApi {
43 public:
44 // Include the auto-generated part of this class. We split this because
45 // it means we can easily edit the non-auto generated parts right here in
46 // this file instead of having to edit some template or the code generator.
47 #include "gl_bindings_api_autogen_gl.h"
49 protected:
50 GLApiBase();
51 ~GLApiBase() override;
52 void InitializeBase(DriverGL* driver);
54 DriverGL* driver_;
57 // Implemenents the GL API by calling directly into the driver.
58 class GL_EXPORT RealGLApi : public GLApiBase {
59 public:
60 RealGLApi();
61 ~RealGLApi() override;
62 void Initialize(DriverGL* driver);
63 void InitializeWithCommandLine(DriverGL* driver,
64 base::CommandLine* command_line);
66 void glGetIntegervFn(GLenum pname, GLint* params) override;
67 const GLubyte* glGetStringFn(GLenum name) override;
68 const GLubyte* glGetStringiFn(GLenum name, GLuint index) override;
70 void InitializeFilteredExtensions();
72 private:
73 void glFinishFn() override;
74 void glFlushFn() override;
76 // Filtered GL_EXTENSIONS we return to glGetString(i) calls.
77 std::vector<std::string> disabled_exts_;
78 std::vector<std::string> filtered_exts_;
79 std::string filtered_exts_str_;
81 #if DCHECK_IS_ON()
82 bool filtered_exts_initialized_;
83 #endif
86 // Inserts a TRACE for every GL call.
87 class TraceGLApi : public GLApi {
88 public:
89 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
90 ~TraceGLApi() override;
92 // Include the auto-generated part of this class. We split this because
93 // it means we can easily edit the non-auto generated parts right here in
94 // this file instead of having to edit some template or the code generator.
95 #include "gl_bindings_api_autogen_gl.h"
97 private:
98 GLApi* gl_api_;
101 // Catches incorrect usage when GL calls are made without a current context.
102 class NoContextGLApi : public GLApi {
103 public:
104 NoContextGLApi();
105 ~NoContextGLApi() override;
107 // Include the auto-generated part of this class. We split this because
108 // it means we can easily edit the non-auto generated parts right here in
109 // this file instead of having to edit some template or the code generator.
110 #include "gl_bindings_api_autogen_gl.h"
113 // Implementents the GL API using co-operative state restoring.
114 // Assumes there is only one real GL context and that multiple virtual contexts
115 // are implemented above it. Restores the needed state from the current context.
116 class VirtualGLApi : public GLApiBase {
117 public:
118 VirtualGLApi();
119 ~VirtualGLApi() override;
120 void Initialize(DriverGL* driver, GLContext* real_context);
122 // Sets the current virutal context.
123 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
125 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
127 private:
128 // Overridden functions from GLApiBase
129 const GLubyte* glGetStringFn(GLenum name) override;
130 void glFinishFn() override;
131 void glFlushFn() override;
133 // The real context we're running on.
134 GLContext* real_context_;
136 // The current virtual context.
137 GLContext* current_context_;
139 // The supported extensions being advertised for this virtual context.
140 std::string extensions_;
143 } // namespace gfx
145 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_