OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 5 #ifndef UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 6 #define UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "ui/gl/gl_bindings.h" | 9 #include "ui/gl/gl_bindings.h" |
10 #include "ui/gl/gl_export.h" | 10 #include "ui/gl/gl_export.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 class GLApiBase : public GLApi { | 36 class GLApiBase : public GLApi { |
37 public: | 37 public: |
38 // Include the auto-generated part of this class. We split this because | 38 // Include the auto-generated part of this class. We split this because |
39 // it means we can easily edit the non-auto generated parts right here in | 39 // it means we can easily edit the non-auto generated parts right here in |
40 // this file instead of having to edit some template or the code generator. | 40 // this file instead of having to edit some template or the code generator. |
41 #include "gl_bindings_api_autogen_gl.h" | 41 #include "gl_bindings_api_autogen_gl.h" |
42 | 42 |
43 protected: | 43 protected: |
44 GLApiBase(); | 44 GLApiBase(); |
45 virtual ~GLApiBase(); | 45 ~GLApiBase() override; |
46 void InitializeBase(DriverGL* driver); | 46 void InitializeBase(DriverGL* driver); |
47 void SignalFlush(); | 47 void SignalFlush(); |
48 | 48 |
49 DriverGL* driver_; | 49 DriverGL* driver_; |
50 }; | 50 }; |
51 | 51 |
52 // Implemenents the GL API by calling directly into the driver. | 52 // Implemenents the GL API by calling directly into the driver. |
53 class RealGLApi : public GLApiBase { | 53 class RealGLApi : public GLApiBase { |
54 public: | 54 public: |
55 RealGLApi(); | 55 RealGLApi(); |
56 virtual ~RealGLApi(); | 56 ~RealGLApi() override; |
57 void Initialize(DriverGL* driver); | 57 void Initialize(DriverGL* driver); |
58 | 58 |
59 private: | 59 private: |
60 virtual void glFinishFn() override; | 60 void glFinishFn() override; |
61 virtual void glFlushFn() override; | 61 void glFlushFn() override; |
62 }; | 62 }; |
63 | 63 |
64 // Inserts a TRACE for every GL call. | 64 // Inserts a TRACE for every GL call. |
65 class TraceGLApi : public GLApi { | 65 class TraceGLApi : public GLApi { |
66 public: | 66 public: |
67 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } | 67 TraceGLApi(GLApi* gl_api) : gl_api_(gl_api) { } |
68 virtual ~TraceGLApi(); | 68 ~TraceGLApi() override; |
69 | 69 |
70 // Include the auto-generated part of this class. We split this because | 70 // Include the auto-generated part of this class. We split this because |
71 // it means we can easily edit the non-auto generated parts right here in | 71 // it means we can easily edit the non-auto generated parts right here in |
72 // this file instead of having to edit some template or the code generator. | 72 // this file instead of having to edit some template or the code generator. |
73 #include "gl_bindings_api_autogen_gl.h" | 73 #include "gl_bindings_api_autogen_gl.h" |
74 | 74 |
75 private: | 75 private: |
76 GLApi* gl_api_; | 76 GLApi* gl_api_; |
77 }; | 77 }; |
78 | 78 |
79 // Catches incorrect usage when GL calls are made without a current context. | 79 // Catches incorrect usage when GL calls are made without a current context. |
80 class NoContextGLApi : public GLApi { | 80 class NoContextGLApi : public GLApi { |
81 public: | 81 public: |
82 NoContextGLApi(); | 82 NoContextGLApi(); |
83 virtual ~NoContextGLApi(); | 83 ~NoContextGLApi() override; |
84 | 84 |
85 // Include the auto-generated part of this class. We split this because | 85 // Include the auto-generated part of this class. We split this because |
86 // it means we can easily edit the non-auto generated parts right here in | 86 // it means we can easily edit the non-auto generated parts right here in |
87 // this file instead of having to edit some template or the code generator. | 87 // this file instead of having to edit some template or the code generator. |
88 #include "gl_bindings_api_autogen_gl.h" | 88 #include "gl_bindings_api_autogen_gl.h" |
89 }; | 89 }; |
90 | 90 |
91 // Implementents the GL API using co-operative state restoring. | 91 // Implementents the GL API using co-operative state restoring. |
92 // Assumes there is only one real GL context and that multiple virtual contexts | 92 // Assumes there is only one real GL context and that multiple virtual contexts |
93 // are implemented above it. Restores the needed state from the current context. | 93 // are implemented above it. Restores the needed state from the current context. |
94 class VirtualGLApi : public GLApiBase { | 94 class VirtualGLApi : public GLApiBase { |
95 public: | 95 public: |
96 VirtualGLApi(); | 96 VirtualGLApi(); |
97 virtual ~VirtualGLApi(); | 97 ~VirtualGLApi() override; |
98 void Initialize(DriverGL* driver, GLContext* real_context); | 98 void Initialize(DriverGL* driver, GLContext* real_context); |
99 | 99 |
100 // Sets the current virutal context. | 100 // Sets the current virutal context. |
101 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); | 101 bool MakeCurrent(GLContext* virtual_context, GLSurface* surface); |
102 | 102 |
103 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); | 103 void OnReleaseVirtuallyCurrent(GLContext* virtual_context); |
104 | 104 |
105 private: | 105 private: |
106 // Overridden functions from GLApiBase | 106 // Overridden functions from GLApiBase |
107 virtual const GLubyte* glGetStringFn(GLenum name) override; | 107 const GLubyte* glGetStringFn(GLenum name) override; |
108 virtual void glFinishFn() override; | 108 void glFinishFn() override; |
109 virtual void glFlushFn() override; | 109 void glFlushFn() override; |
110 | 110 |
111 // The real context we're running on. | 111 // The real context we're running on. |
112 GLContext* real_context_; | 112 GLContext* real_context_; |
113 | 113 |
114 // The current virtual context. | 114 // The current virtual context. |
115 GLContext* current_context_; | 115 GLContext* current_context_; |
116 | 116 |
117 // The supported extensions being advertised for this virtual context. | 117 // The supported extensions being advertised for this virtual context. |
118 std::string extensions_; | 118 std::string extensions_; |
119 }; | 119 }; |
120 | 120 |
121 class GL_EXPORT ScopedSetGLToRealGLApi { | 121 class GL_EXPORT ScopedSetGLToRealGLApi { |
122 public: | 122 public: |
123 ScopedSetGLToRealGLApi(); | 123 ScopedSetGLToRealGLApi(); |
124 ~ScopedSetGLToRealGLApi(); | 124 ~ScopedSetGLToRealGLApi(); |
125 | 125 |
126 private: | 126 private: |
127 GLApi* old_gl_api_; | 127 GLApi* old_gl_api_; |
128 }; | 128 }; |
129 | 129 |
130 } // namespace gfx | 130 } // namespace gfx |
131 | 131 |
132 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ | 132 #endif // UI_GL_GL_GL_API_IMPLEMENTATION_H_ |
OLD | NEW |