blob: 173917213d8fc8ea63e231042bc849399451b1ef [file] [log] [blame]
[email protected]b97c9082012-10-25 17:21:381// 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.
4
[email protected]764c1822014-01-11 02:12:215#ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_
6#define UI_GL_GL_GL_API_IMPLEMENTATION_H_
[email protected]b97c9082012-10-25 17:21:387
8#include "base/compiler_specific.h"
9#include "ui/gl/gl_bindings.h"
10#include "ui/gl/gl_export.h"
11
[email protected]1868a342012-11-07 15:56:0212namespace gpu {
13namespace gles2 {
14class GLES2Decoder;
15}
16}
[email protected]b97c9082012-10-25 17:21:3817namespace gfx {
18
19class GLContext;
[email protected]1868a342012-11-07 15:56:0220class GLSurface;
[email protected]b97c9082012-10-25 17:21:3821
[email protected]a37d7ff2014-01-17 21:31:0022void InitializeStaticGLBindingsGL();
23void InitializeDynamicGLBindingsGL(GLContext* context);
[email protected]b97c9082012-10-25 17:21:3824void InitializeDebugGLBindingsGL();
[email protected]70c908c2014-01-12 02:09:4525void InitializeNullDrawGLBindingsGL();
[email protected]2fc82a92014-02-20 22:52:0826bool SetNullDrawGLBindingsEnabledGL(bool enabled);
[email protected]b97c9082012-10-25 17:21:3827void ClearGLBindingsGL();
[email protected]1868a342012-11-07 15:56:0228void SetGLToRealGLApi();
29void SetGLApi(GLApi* api);
[email protected]b97c9082012-10-25 17:21:3830
[email protected]95c9d112012-12-16 04:52:3631class GL_EXPORT GLApiBase : public GLApi {
[email protected]b97c9082012-10-25 17:21:3832 public:
[email protected]b97c9082012-10-25 17:21:3833 // Include the auto-generated part of this class. We split this because
34 // it means we can easily edit the non-auto generated parts right here in
35 // this file instead of having to edit some template or the code generator.
36 #include "gl_bindings_api_autogen_gl.h"
37
[email protected]95c9d112012-12-16 04:52:3638 protected:
39 GLApiBase();
40 virtual ~GLApiBase();
41 void InitializeBase(DriverGL* driver);
42
[email protected]b97c9082012-10-25 17:21:3843 DriverGL* driver_;
44};
45
[email protected]95c9d112012-12-16 04:52:3646// Implemenents the GL API by calling directly into the driver.
47class GL_EXPORT RealGLApi : public GLApiBase {
48 public:
49 RealGLApi();
50 virtual ~RealGLApi();
51 void Initialize(DriverGL* driver);
52};
53
[email protected]b8f1d48c2013-02-07 05:21:1254// Inserts a TRACE for every GL call.
55class GL_EXPORT TraceGLApi : public GLApi {
56 public:
57 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { }
58 virtual ~TraceGLApi();
59
60 // Include the auto-generated part of this class. We split this because
61 // it means we can easily edit the non-auto generated parts right here in
62 // this file instead of having to edit some template or the code generator.
63 #include "gl_bindings_api_autogen_gl.h"
64
65 private:
66 GLApi* gl_api_;
67};
68
[email protected]1868a342012-11-07 15:56:0269// Implementents the GL API using co-operative state restoring.
70// Assumes there is only one real GL context and that multiple virtual contexts
71// are implemented above it. Restores the needed state from the current context.
[email protected]95c9d112012-12-16 04:52:3672class GL_EXPORT VirtualGLApi : public GLApiBase {
[email protected]1868a342012-11-07 15:56:0273 public:
74 VirtualGLApi();
75 virtual ~VirtualGLApi();
76 void Initialize(DriverGL* driver, GLContext* real_context);
77
[email protected]1868a342012-11-07 15:56:0278 // Sets the current virutal context.
79 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface);
80
[email protected]063121b82013-05-31 03:48:1481 void OnReleaseVirtuallyCurrent(GLContext* virtual_context);
[email protected]b3cbad12012-12-05 19:56:3682
[email protected]95c9d112012-12-16 04:52:3683 // Overridden functions from GLApiBase
84 virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE;
[email protected]1868a342012-11-07 15:56:0285
[email protected]95c9d112012-12-16 04:52:3686 private:
[email protected]1868a342012-11-07 15:56:0287 // The real context we're running on.
88 GLContext* real_context_;
89
90 // The current virtual context.
91 GLContext* current_context_;
[email protected]b3cbad12012-12-05 19:56:3692
93 // The supported extensions being advertised for this virtual context.
94 std::string extensions_;
[email protected]1868a342012-11-07 15:56:0295};
96
[email protected]b97c9082012-10-25 17:21:3897} // namespace gfx
98
[email protected]764c1822014-01-11 02:12:2199#endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_