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