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"
21 void InitializeStaticGLBindingsGL();
22 void InitializeDynamicGLBindingsGL(GLContext
* context
);
23 void InitializeDebugGLBindingsGL();
24 void InitializeNullDrawGLBindingsGL();
25 // TODO(danakj): Remove this when all test suites are using null-draw.
26 bool HasInitializedNullDrawGLBindingsGL();
27 bool SetNullDrawGLBindingsEnabledGL(bool enabled
);
28 void ClearGLBindingsGL();
29 void SetGLToRealGLApi();
30 void SetGLApi(GLApi
* api
);
31 void SetGLApiToNoContext();
33 class GLApiBase
: public GLApi
{
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"
43 void InitializeBase(DriverGL
* driver
);
49 // Implemenents the GL API by calling directly into the driver.
50 class RealGLApi
: public GLApiBase
{
54 void Initialize(DriverGL
* driver
);
57 virtual void glFinishFn() OVERRIDE
;
58 virtual void glFlushFn() OVERRIDE
;
61 // Inserts a TRACE for every GL call.
62 class TraceGLApi
: public GLApi
{
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"
76 // Catches incorrect usage when GL calls are made without a current context.
77 class NoContextGLApi
: public GLApi
{
80 virtual ~NoContextGLApi();
82 // Include the auto-generated part of this class. We split this because
83 // it means we can easily edit the non-auto generated parts right here in
84 // this file instead of having to edit some template or the code generator.
85 #include "gl_bindings_api_autogen_gl.h"
88 // Implementents the GL API using co-operative state restoring.
89 // Assumes there is only one real GL context and that multiple virtual contexts
90 // are implemented above it. Restores the needed state from the current context.
91 class VirtualGLApi
: public GLApiBase
{
94 virtual ~VirtualGLApi();
95 void Initialize(DriverGL
* driver
, GLContext
* real_context
);
97 // Sets the current virutal context.
98 bool MakeCurrent(GLContext
* virtual_context
, GLSurface
* surface
);
100 void OnReleaseVirtuallyCurrent(GLContext
* virtual_context
);
103 // Overridden functions from GLApiBase
104 virtual const GLubyte
* glGetStringFn(GLenum name
) OVERRIDE
;
105 virtual void glFinishFn() OVERRIDE
;
106 virtual void glFlushFn() OVERRIDE
;
108 // The real context we're running on.
109 GLContext
* real_context_
;
111 // The current virtual context.
112 GLContext
* current_context_
;
114 // The supported extensions being advertised for this virtual context.
115 std::string extensions_
;
120 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_