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/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 #include "ui/gfx/geometry/rect_f.h" | 14 #include "ui/gfx/geometry/rect_f.h" |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/overlay_transform.h" | 17 #include "ui/gfx/overlay_transform.h" |
| 18 #include "ui/gfx/swap_result.h" |
18 #include "ui/gl/gl_export.h" | 19 #include "ui/gl/gl_export.h" |
19 #include "ui/gl/gl_implementation.h" | 20 #include "ui/gl/gl_implementation.h" |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 | 23 |
23 class GLContext; | 24 class GLContext; |
24 class GLImage; | 25 class GLImage; |
25 class VSyncProvider; | 26 class VSyncProvider; |
26 | 27 |
27 // Encapsulates a surface that can be rendered to with GL, hiding platform | 28 // Encapsulates a surface that can be rendered to with GL, hiding platform |
(...skipping 23 matching lines...) Expand all Loading... |
51 // Unschedule the GpuScheduler and return true to abort the processing of | 52 // Unschedule the GpuScheduler and return true to abort the processing of |
52 // a GL draw call to this surface and defer it until the GpuScheduler is | 53 // a GL draw call to this surface and defer it until the GpuScheduler is |
53 // rescheduled. | 54 // rescheduled. |
54 virtual bool DeferDraws(); | 55 virtual bool DeferDraws(); |
55 | 56 |
56 // Returns true if this surface is offscreen. | 57 // Returns true if this surface is offscreen. |
57 virtual bool IsOffscreen() = 0; | 58 virtual bool IsOffscreen() = 0; |
58 | 59 |
59 // Swaps front and back buffers. This has no effect for off-screen | 60 // Swaps front and back buffers. This has no effect for off-screen |
60 // contexts. | 61 // contexts. |
61 virtual bool SwapBuffers() = 0; | 62 virtual gfx::SwapResult SwapBuffers() = 0; |
62 | 63 |
63 // Get the size of the surface. | 64 // Get the size of the surface. |
64 virtual gfx::Size GetSize() = 0; | 65 virtual gfx::Size GetSize() = 0; |
65 | 66 |
66 // Get the underlying platform specific surface "handle". | 67 // Get the underlying platform specific surface "handle". |
67 virtual void* GetHandle() = 0; | 68 virtual void* GetHandle() = 0; |
68 | 69 |
69 // Returns whether or not the surface supports PostSubBuffer. | 70 // Returns whether or not the surface supports PostSubBuffer. |
70 virtual bool SupportsPostSubBuffer(); | 71 virtual bool SupportsPostSubBuffer(); |
71 | 72 |
72 // Returns the internal frame buffer object name if the surface is backed by | 73 // Returns the internal frame buffer object name if the surface is backed by |
73 // FBO. Otherwise returns 0. | 74 // FBO. Otherwise returns 0. |
74 virtual unsigned int GetBackingFrameBufferObject(); | 75 virtual unsigned int GetBackingFrameBufferObject(); |
75 | 76 |
76 typedef base::Callback<void()> SwapCompletionCallback; | 77 typedef base::Callback<void(SwapResult)> SwapCompletionCallback; |
77 // Swaps front and back buffers. This has no effect for off-screen | 78 // Swaps front and back buffers. This has no effect for off-screen |
78 // contexts. On some platforms, we want to send SwapBufferAck only after the | 79 // contexts. On some platforms, we want to send SwapBufferAck only after the |
79 // surface is displayed on screen. The callback can be used to delay sending | 80 // surface is displayed on screen. The callback can be used to delay sending |
80 // SwapBufferAck till that data is available. The callback should be run on | 81 // SwapBufferAck till that data is available. The callback should be run on |
81 // the calling thread (i.e. same thread SwapBuffersAsync is called) | 82 // the calling thread (i.e. same thread SwapBuffersAsync is called) |
82 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); | 83 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); |
83 | 84 |
84 // Copy part of the backbuffer to the frontbuffer. | 85 // Copy part of the backbuffer to the frontbuffer. |
85 virtual bool PostSubBuffer(int x, int y, int width, int height); | 86 virtual gfx::SwapResult PostSubBuffer(int x, int y, int width, int height); |
86 | 87 |
87 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want | 88 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want |
88 // to send SwapBufferAck only after the surface is displayed on screen. The | 89 // to send SwapBufferAck only after the surface is displayed on screen. The |
89 // callback can be used to delay sending SwapBufferAck till that data is | 90 // callback can be used to delay sending SwapBufferAck till that data is |
90 // available. The callback should be run on the calling thread (i.e. same | 91 // available. The callback should be run on the calling thread (i.e. same |
91 // thread PostSubBufferAsync is called) | 92 // thread PostSubBufferAsync is called) |
92 virtual bool PostSubBufferAsync(int x, | 93 virtual bool PostSubBufferAsync(int x, |
93 int y, | 94 int y, |
94 int width, | 95 int width, |
95 int height, | 96 int height, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 198 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
198 public: | 199 public: |
199 explicit GLSurfaceAdapter(GLSurface* surface); | 200 explicit GLSurfaceAdapter(GLSurface* surface); |
200 | 201 |
201 bool Initialize() override; | 202 bool Initialize() override; |
202 void Destroy() override; | 203 void Destroy() override; |
203 bool Resize(const gfx::Size& size) override; | 204 bool Resize(const gfx::Size& size) override; |
204 bool Recreate() override; | 205 bool Recreate() override; |
205 bool DeferDraws() override; | 206 bool DeferDraws() override; |
206 bool IsOffscreen() override; | 207 bool IsOffscreen() override; |
207 bool SwapBuffers() override; | 208 gfx::SwapResult SwapBuffers() override; |
208 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 209 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
209 bool PostSubBuffer(int x, int y, int width, int height) override; | 210 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
210 bool PostSubBufferAsync(int x, | 211 bool PostSubBufferAsync(int x, |
211 int y, | 212 int y, |
212 int width, | 213 int width, |
213 int height, | 214 int height, |
214 const SwapCompletionCallback& callback) override; | 215 const SwapCompletionCallback& callback) override; |
215 bool SupportsPostSubBuffer() override; | 216 bool SupportsPostSubBuffer() override; |
216 gfx::Size GetSize() override; | 217 gfx::Size GetSize() override; |
217 void* GetHandle() override; | 218 void* GetHandle() override; |
218 unsigned int GetBackingFrameBufferObject() override; | 219 unsigned int GetBackingFrameBufferObject() override; |
219 bool OnMakeCurrent(GLContext* context) override; | 220 bool OnMakeCurrent(GLContext* context) override; |
(...skipping 18 matching lines...) Expand all Loading... |
238 | 239 |
239 private: | 240 private: |
240 scoped_refptr<GLSurface> surface_; | 241 scoped_refptr<GLSurface> surface_; |
241 | 242 |
242 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 243 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
243 }; | 244 }; |
244 | 245 |
245 } // namespace gfx | 246 } // namespace gfx |
246 | 247 |
247 #endif // UI_GL_GL_SURFACE_H_ | 248 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |