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"
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
{
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 GL_EXPORT 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 GL_EXPORT 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 // 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
{
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
);
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_
;
108 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_