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 void ClearGLBindingsGL();
27 void SetGLToRealGLApi();
28 void SetGLApi(GLApi
* api
);
30 class GL_EXPORT GLApiBase
: public GLApi
{
32 // Include the auto-generated part of this class. We split this because
33 // it means we can easily edit the non-auto generated parts right here in
34 // this file instead of having to edit some template or the code generator.
35 #include "gl_bindings_api_autogen_gl.h"
40 void InitializeBase(DriverGL
* driver
);
45 // Implemenents the GL API by calling directly into the driver.
46 class GL_EXPORT RealGLApi
: public GLApiBase
{
50 void Initialize(DriverGL
* driver
);
53 // Inserts a TRACE for every GL call.
54 class GL_EXPORT TraceGLApi
: public GLApi
{
56 TraceGLApi(GLApi
* gl_api
) : gl_api_(gl_api
) { }
57 virtual ~TraceGLApi();
59 // Include the auto-generated part of this class. We split this because
60 // it means we can easily edit the non-auto generated parts right here in
61 // this file instead of having to edit some template or the code generator.
62 #include "gl_bindings_api_autogen_gl.h"
68 // Implementents the GL API using co-operative state restoring.
69 // Assumes there is only one real GL context and that multiple virtual contexts
70 // are implemented above it. Restores the needed state from the current context.
71 class GL_EXPORT VirtualGLApi
: public GLApiBase
{
74 virtual ~VirtualGLApi();
75 void Initialize(DriverGL
* driver
, GLContext
* real_context
);
77 // Sets the current virutal context.
78 bool MakeCurrent(GLContext
* virtual_context
, GLSurface
* surface
);
80 void OnReleaseVirtuallyCurrent(GLContext
* virtual_context
);
82 // Overridden functions from GLApiBase
83 virtual const GLubyte
* glGetStringFn(GLenum name
) OVERRIDE
;
86 // The real context we're running on.
87 GLContext
* real_context_
;
89 // The current virtual context.
90 GLContext
* current_context_
;
92 // The supported extensions being advertised for this virtual context.
93 std::string extensions_
;
98 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_