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_SURFACE_H_ | 5 #ifndef UI_GL_GL_SURFACE_H_ |
6 #define UI_GL_GL_SURFACE_H_ | 6 #define UI_GL_GL_SURFACE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // EGL surface associated to be recreated without destroying the associated | 32 // EGL surface associated to be recreated without destroying the associated |
33 // context. The implementation of this function for other GLSurface derived | 33 // context. The implementation of this function for other GLSurface derived |
34 // classes is in a pending changelist. | 34 // classes is in a pending changelist. |
35 virtual bool Initialize(); | 35 virtual bool Initialize(); |
36 | 36 |
37 // Destroys the surface. | 37 // Destroys the surface. |
38 virtual void Destroy() = 0; | 38 virtual void Destroy() = 0; |
39 | 39 |
40 virtual bool Resize(const gfx::Size& size); | 40 virtual bool Resize(const gfx::Size& size); |
41 | 41 |
| 42 // Recreate the surface without changing the size. |
| 43 virtual bool Recreate(); |
| 44 |
42 // Unschedule the GpuScheduler and return true to abort the processing of | 45 // Unschedule the GpuScheduler and return true to abort the processing of |
43 // a GL draw call to this surface and defer it until the GpuScheduler is | 46 // a GL draw call to this surface and defer it until the GpuScheduler is |
44 // rescheduled. | 47 // rescheduled. |
45 virtual bool DeferDraws(); | 48 virtual bool DeferDraws(); |
46 | 49 |
47 // Returns true if this surface is offscreen. | 50 // Returns true if this surface is offscreen. |
48 virtual bool IsOffscreen() = 0; | 51 virtual bool IsOffscreen() = 0; |
49 | 52 |
50 // Swaps front and back buffers. This has no effect for off-screen | 53 // Swaps front and back buffers. This has no effect for off-screen |
51 // contexts. | 54 // contexts. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Get the platfrom specific configuration for this surface, if available. | 98 // Get the platfrom specific configuration for this surface, if available. |
96 virtual void* GetConfig(); | 99 virtual void* GetConfig(); |
97 | 100 |
98 // Get the GL pixel format of the surface, if available. | 101 // Get the GL pixel format of the surface, if available. |
99 virtual unsigned GetFormat(); | 102 virtual unsigned GetFormat(); |
100 | 103 |
101 // Get access to a helper providing time of recent refresh and period | 104 // Get access to a helper providing time of recent refresh and period |
102 // of screen refresh. If unavailable, returns NULL. | 105 // of screen refresh. If unavailable, returns NULL. |
103 virtual VSyncProvider* GetVSyncProvider(); | 106 virtual VSyncProvider* GetVSyncProvider(); |
104 | 107 |
| 108 // Certain surfaces need to be destroyed and recreated |
| 109 // every time they are made the current surface. |
| 110 virtual bool RecreateOnMakeCurrent(); |
| 111 virtual void SetRecreateOnMakeCurrent(bool recreate); |
| 112 |
105 // Create a GL surface that renders directly to a view. | 113 // Create a GL surface that renders directly to a view. |
106 static scoped_refptr<GLSurface> CreateViewGLSurface( | 114 static scoped_refptr<GLSurface> CreateViewGLSurface( |
107 bool software, | 115 bool software, |
108 gfx::AcceleratedWidget window); | 116 gfx::AcceleratedWidget window); |
109 | 117 |
110 // Create a GL surface used for offscreen rendering. | 118 // Create a GL surface used for offscreen rendering. |
111 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( | 119 static scoped_refptr<GLSurface> CreateOffscreenGLSurface( |
112 bool software, | 120 bool software, |
113 const gfx::Size& size); | 121 const gfx::Size& size); |
114 | 122 |
(...skipping 15 matching lines...) Expand all Loading... |
130 | 138 |
131 // Implementation of GLSurface that forwards all calls through to another | 139 // Implementation of GLSurface that forwards all calls through to another |
132 // GLSurface. | 140 // GLSurface. |
133 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 141 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
134 public: | 142 public: |
135 explicit GLSurfaceAdapter(GLSurface* surface); | 143 explicit GLSurfaceAdapter(GLSurface* surface); |
136 | 144 |
137 virtual bool Initialize() OVERRIDE; | 145 virtual bool Initialize() OVERRIDE; |
138 virtual void Destroy() OVERRIDE; | 146 virtual void Destroy() OVERRIDE; |
139 virtual bool Resize(const gfx::Size& size) OVERRIDE; | 147 virtual bool Resize(const gfx::Size& size) OVERRIDE; |
| 148 virtual bool Recreate() OVERRIDE; |
140 virtual bool DeferDraws() OVERRIDE; | 149 virtual bool DeferDraws() OVERRIDE; |
141 virtual bool IsOffscreen() OVERRIDE; | 150 virtual bool IsOffscreen() OVERRIDE; |
142 virtual bool SwapBuffers() OVERRIDE; | 151 virtual bool SwapBuffers() OVERRIDE; |
143 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; | 152 virtual bool PostSubBuffer(int x, int y, int width, int height) OVERRIDE; |
144 virtual std::string GetExtensions() OVERRIDE; | 153 virtual std::string GetExtensions() OVERRIDE; |
145 virtual gfx::Size GetSize() OVERRIDE; | 154 virtual gfx::Size GetSize() OVERRIDE; |
146 virtual void* GetHandle() OVERRIDE; | 155 virtual void* GetHandle() OVERRIDE; |
147 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; | 156 virtual unsigned int GetBackingFrameBufferObject() OVERRIDE; |
148 virtual bool OnMakeCurrent(GLContext* context) OVERRIDE; | 157 virtual bool OnMakeCurrent(GLContext* context) OVERRIDE; |
149 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; | 158 virtual bool SetBackbufferAllocation(bool allocated) OVERRIDE; |
150 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; | 159 virtual void SetFrontbufferAllocation(bool allocated) OVERRIDE; |
151 virtual void* GetShareHandle() OVERRIDE; | 160 virtual void* GetShareHandle() OVERRIDE; |
152 virtual void* GetDisplay() OVERRIDE; | 161 virtual void* GetDisplay() OVERRIDE; |
153 virtual void* GetConfig() OVERRIDE; | 162 virtual void* GetConfig() OVERRIDE; |
154 virtual unsigned GetFormat() OVERRIDE; | 163 virtual unsigned GetFormat() OVERRIDE; |
155 virtual VSyncProvider* GetVSyncProvider() OVERRIDE; | 164 virtual VSyncProvider* GetVSyncProvider() OVERRIDE; |
| 165 virtual bool RecreateOnMakeCurrent() OVERRIDE; |
| 166 virtual void SetRecreateOnMakeCurrent(bool recreate) OVERRIDE; |
156 | 167 |
157 GLSurface* surface() const { return surface_.get(); } | 168 GLSurface* surface() const { return surface_.get(); } |
158 | 169 |
159 protected: | 170 protected: |
160 virtual ~GLSurfaceAdapter(); | 171 virtual ~GLSurfaceAdapter(); |
161 | 172 |
162 private: | 173 private: |
163 scoped_refptr<GLSurface> surface_; | 174 scoped_refptr<GLSurface> surface_; |
164 | 175 |
165 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 176 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
166 }; | 177 }; |
167 | 178 |
168 } // namespace gfx | 179 } // namespace gfx |
169 | 180 |
170 #endif // UI_GL_GL_SURFACE_H_ | 181 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |