Implement nacl_irt_memory for non-sfi mode.
[chromium-blink-merge.git] / ui / gl / gl_gl_api_implementation.h
blob43aedafa7d2284bdc8e0375e1a6c426bab0c1817
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 void ClearGLBindingsGL();
27 void SetGLToRealGLApi();
28 void SetGLApi(GLApi* api);
30 class GL_EXPORT GLApiBase : public GLApi {
31 public:
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"
37 protected:
38 GLApiBase();
39 virtual ~GLApiBase();
40 void InitializeBase(DriverGL* driver);
42 DriverGL* driver_;
45 // Implemenents the GL API by calling directly into the driver.
46 class GL_EXPORT RealGLApi : public GLApiBase {
47 public:
48 RealGLApi();
49 virtual ~RealGLApi();
50 void Initialize(DriverGL* driver);
53 // Inserts a TRACE for every GL call.
54 class GL_EXPORT TraceGLApi : public GLApi {
55 public:
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"
64 private:
65 GLApi* gl_api_;
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 {
72 public:
73 VirtualGLApi();
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;
85 private:
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_;
96 } // namespace gfx
98 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_