[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 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. | ||||
4 | |||||
[email protected] | 764c182 | 2014-01-11 02:12:21 | [diff] [blame] | 5 | #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
6 | #define UI_GL_GL_GL_API_IMPLEMENTATION_H_ | ||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 7 | |
8 | #include "base/compiler_specific.h" | ||||
9 | #include "ui/gl/gl_bindings.h" | ||||
10 | #include "ui/gl/gl_export.h" | ||||
11 | |||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 12 | namespace gpu { |
13 | namespace gles2 { | ||||
14 | class GLES2Decoder; | ||||
15 | } | ||||
16 | } | ||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 17 | namespace gfx { |
18 | |||||
19 | class GLContext; | ||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 20 | class GLSurface; |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 21 | |
[email protected] | a37d7ff | 2014-01-17 21:31:00 | [diff] [blame] | 22 | void InitializeStaticGLBindingsGL(); |
23 | void InitializeDynamicGLBindingsGL(GLContext* context); | ||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 24 | void InitializeDebugGLBindingsGL(); |
[email protected] | 70c908c | 2014-01-12 02:09:45 | [diff] [blame] | 25 | void InitializeNullDrawGLBindingsGL(); |
[email protected] | 2fc82a9 | 2014-02-20 22:52:08 | [diff] [blame^] | 26 | bool SetNullDrawGLBindingsEnabledGL(bool enabled); |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 27 | void ClearGLBindingsGL(); |
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 28 | void SetGLToRealGLApi(); |
29 | void SetGLApi(GLApi* api); | ||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 30 | |
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 31 | class GL_EXPORT GLApiBase : public GLApi { |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 32 | public: |
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 33 | // 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] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 38 | protected: |
39 | GLApiBase(); | ||||
40 | virtual ~GLApiBase(); | ||||
41 | void InitializeBase(DriverGL* driver); | ||||
42 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 43 | DriverGL* driver_; |
44 | }; | ||||
45 | |||||
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 46 | // Implemenents the GL API by calling directly into the driver. |
47 | class GL_EXPORT RealGLApi : public GLApiBase { | ||||
48 | public: | ||||
49 | RealGLApi(); | ||||
50 | virtual ~RealGLApi(); | ||||
51 | void Initialize(DriverGL* driver); | ||||
52 | }; | ||||
53 | |||||
[email protected] | b8f1d48c | 2013-02-07 05:21:12 | [diff] [blame] | 54 | // Inserts a TRACE for every GL call. |
55 | class 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] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 69 | // 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] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 72 | class GL_EXPORT VirtualGLApi : public GLApiBase { |
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 73 | public: |
74 | VirtualGLApi(); | ||||
75 | virtual ~VirtualGLApi(); | ||||
76 | void Initialize(DriverGL* driver, GLContext* real_context); | ||||
77 | |||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 78 | // Sets the current virutal context. |
79 | bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); | ||||
80 | |||||
[email protected] | 063121b8 | 2013-05-31 03:48:14 | [diff] [blame] | 81 | void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
[email protected] | b3cbad1 | 2012-12-05 19:56:36 | [diff] [blame] | 82 | |
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 83 | // Overridden functions from GLApiBase |
84 | virtual const GLubyte* glGetStringFn(GLenum name) OVERRIDE; | ||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 85 | |
[email protected] | 95c9d11 | 2012-12-16 04:52:36 | [diff] [blame] | 86 | private: |
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 87 | // The real context we're running on. |
88 | GLContext* real_context_; | ||||
89 | |||||
90 | // The current virtual context. | ||||
91 | GLContext* current_context_; | ||||
[email protected] | b3cbad1 | 2012-12-05 19:56:36 | [diff] [blame] | 92 | |
93 | // The supported extensions being advertised for this virtual context. | ||||
94 | std::string extensions_; | ||||
[email protected] | 1868a34 | 2012-11-07 15:56:02 | [diff] [blame] | 95 | }; |
96 | |||||
[email protected] | b97c908 | 2012-10-25 17:21:38 | [diff] [blame] | 97 | } // namespace gfx |
98 | |||||
[email protected] | 764c182 | 2014-01-11 02:12:21 | [diff] [blame] | 99 | #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ |