Obey renderer-supplied quota in the browser.
[chromium-blink-merge.git] / ui / gl / gl_gl_api_implementation.h
blobe764ec3ce3d4afb241c7f5062185537e1586c91f
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 "base/compiler_specific.h"
9 #include "ui/gl/gl_bindings.h"
10 #include "ui/gl/gl_export.h"
12 namespace gpu {
13 namespace gles2 {
14 class GLES2Decoder;
17 namespace gfx {
19 class GLContext;
20 class GLSurface;
22 void InitializeStaticGLBindingsGL();
23 void InitializeDynamicGLBindingsGL(GLContext* context);
24 void InitializeDebugGLBindingsGL();
25 void InitializeNullDrawGLBindingsGL();
26 // TODO(danakj): Remove this when all test suites are using null-draw.
27 bool HasInitializedNullDrawGLBindingsGL();
28 bool SetNullDrawGLBindingsEnabledGL(bool enabled);
29 void ClearGLBindingsGL();
30 void SetGLToRealGLApi();
31 void SetGLApi(GLApi* api);
33 class GL_EXPORT GLApiBase : public GLApi {
34 public:
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
37 // this file instead of having to edit some template or the code generator.
38 #include "gl_bindings_api_autogen_gl.h"
40 protected:
41 GLApiBase();
42 virtual ~GLApiBase();
43 void InitializeBase(DriverGL* driver);
44 void SignalFlush();
46 DriverGL* driver_;
49 // Implemenents the GL API by calling directly into the driver.
50 class GL_EXPORT RealGLApi : public GLApiBase {
51 public:
52 RealGLApi();
53 virtual ~RealGLApi();
54 void Initialize(DriverGL* driver);
56 private:
57 virtual void glFinishFn() OVERRIDE;
58 virtual void glFlushFn() OVERRIDE;
61 // Inserts a TRACE for every GL call.
62 class GL_EXPORT TraceGLApi : public GLApi {
63 public:
64 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
65 virtual ~TraceGLApi();
67 // Include the auto-generated part of this class. We split this because
68 // it means we can easily edit the non-auto generated parts right here in
69 // this file instead of having to edit some template or the code generator.
70 #include "gl_bindings_api_autogen_gl.h"
72 private:
73 GLApi* gl_api_;
76 // Implementents the GL API using co-operative state restoring.
77 // Assumes there is only one real GL context and that multiple virtual contexts
78 // are implemented above it. Restores the needed state from the current context.
79 class GL_EXPORT VirtualGLApi : public GLApiBase {
80 public:
81 VirtualGLApi();
82 virtual ~VirtualGLApi();
83 void Initialize(DriverGL* driver, GLContext* real_context);
85 // Sets the current virutal context.
86 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
88 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
90 private:
91 // Overridden functions from GLApiBase
92 virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE;
93 virtual void glFinishFn() OVERRIDE;
94 virtual void glFlushFn() OVERRIDE;
96 // The real context we're running on.
97 GLContext* real_context_;
99 // The current virtual context.
100 GLContext* current_context_;
102 // The supported extensions being advertised for this virtual context.
103 std::string extensions_;
106 } // namespace gfx
108 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_