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 struct SurfaceConfiguration { | 28 struct SurfaceConfiguration { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // Unschedule the GpuScheduler and return true to abort the processing of | 61 // Unschedule the GpuScheduler and return true to abort the processing of |
61 // a GL draw call to this surface and defer it until the GpuScheduler is | 62 // a GL draw call to this surface and defer it until the GpuScheduler is |
62 // rescheduled. | 63 // rescheduled. |
63 virtual bool DeferDraws(); | 64 virtual bool DeferDraws(); |
64 | 65 |
65 // Returns true if this surface is offscreen. | 66 // Returns true if this surface is offscreen. |
66 virtual bool IsOffscreen() = 0; | 67 virtual bool IsOffscreen() = 0; |
67 | 68 |
68 // Swaps front and back buffers. This has no effect for off-screen | 69 // Swaps front and back buffers. This has no effect for off-screen |
69 // contexts. | 70 // contexts. |
70 virtual bool SwapBuffers() = 0; | 71 virtual gfx::SwapResult SwapBuffers() = 0; |
71 | 72 |
72 // Get the size of the surface. | 73 // Get the size of the surface. |
73 virtual gfx::Size GetSize() = 0; | 74 virtual gfx::Size GetSize() = 0; |
74 | 75 |
75 // Get the underlying platform specific surface "handle". | 76 // Get the underlying platform specific surface "handle". |
76 virtual void* GetHandle() = 0; | 77 virtual void* GetHandle() = 0; |
77 | 78 |
78 // Returns whether or not the surface supports PostSubBuffer. | 79 // Returns whether or not the surface supports PostSubBuffer. |
79 virtual bool SupportsPostSubBuffer(); | 80 virtual bool SupportsPostSubBuffer(); |
80 | 81 |
81 // Returns the internal frame buffer object name if the surface is backed by | 82 // Returns the internal frame buffer object name if the surface is backed by |
82 // FBO. Otherwise returns 0. | 83 // FBO. Otherwise returns 0. |
83 virtual unsigned int GetBackingFrameBufferObject(); | 84 virtual unsigned int GetBackingFrameBufferObject(); |
84 | 85 |
85 typedef base::Callback<void()> SwapCompletionCallback; | 86 typedef base::Callback<void(gfx::SwapResult)> SwapCompletionCallback; |
86 // Swaps front and back buffers. This has no effect for off-screen | 87 // Swaps front and back buffers. This has no effect for off-screen |
87 // contexts. On some platforms, we want to send SwapBufferAck only after the | 88 // contexts. On some platforms, we want to send SwapBufferAck only after the |
88 // surface is displayed on screen. The callback can be used to delay sending | 89 // surface is displayed on screen. The callback can be used to delay sending |
89 // SwapBufferAck till that data is available. The callback should be run on | 90 // SwapBufferAck till that data is available. The callback should be run on |
90 // the calling thread (i.e. same thread SwapBuffersAsync is called) | 91 // the calling thread (i.e. same thread SwapBuffersAsync is called) |
91 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); | 92 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); |
92 | 93 |
93 // Copy part of the backbuffer to the frontbuffer. | 94 // Copy part of the backbuffer to the frontbuffer. |
94 virtual bool PostSubBuffer(int x, int y, int width, int height); | 95 virtual gfx::SwapResult PostSubBuffer(int x, int y, int width, int height); |
95 | 96 |
96 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want | 97 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want |
97 // to send SwapBufferAck only after the surface is displayed on screen. The | 98 // to send SwapBufferAck only after the surface is displayed on screen. The |
98 // callback can be used to delay sending SwapBufferAck till that data is | 99 // callback can be used to delay sending SwapBufferAck till that data is |
99 // available. The callback should be run on the calling thread (i.e. same | 100 // available. The callback should be run on the calling thread (i.e. same |
100 // thread PostSubBufferAsync is called) | 101 // thread PostSubBufferAsync is called) |
101 virtual bool PostSubBufferAsync(int x, | 102 virtual bool PostSubBufferAsync(int x, |
102 int y, | 103 int y, |
103 int width, | 104 int width, |
104 int height, | 105 int height, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 class GL_EXPORT GLSurfaceAdapter : public GLSurface { | 216 class GL_EXPORT GLSurfaceAdapter : public GLSurface { |
216 public: | 217 public: |
217 explicit GLSurfaceAdapter(GLSurface* surface); | 218 explicit GLSurfaceAdapter(GLSurface* surface); |
218 | 219 |
219 bool Initialize() override; | 220 bool Initialize() override; |
220 void Destroy() override; | 221 void Destroy() override; |
221 bool Resize(const gfx::Size& size) override; | 222 bool Resize(const gfx::Size& size) override; |
222 bool Recreate() override; | 223 bool Recreate() override; |
223 bool DeferDraws() override; | 224 bool DeferDraws() override; |
224 bool IsOffscreen() override; | 225 bool IsOffscreen() override; |
225 bool SwapBuffers() override; | 226 gfx::SwapResult SwapBuffers() override; |
226 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 227 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
227 bool PostSubBuffer(int x, int y, int width, int height) override; | 228 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
228 bool PostSubBufferAsync(int x, | 229 bool PostSubBufferAsync(int x, |
229 int y, | 230 int y, |
230 int width, | 231 int width, |
231 int height, | 232 int height, |
232 const SwapCompletionCallback& callback) override; | 233 const SwapCompletionCallback& callback) override; |
233 bool SupportsPostSubBuffer() override; | 234 bool SupportsPostSubBuffer() override; |
234 gfx::Size GetSize() override; | 235 gfx::Size GetSize() override; |
235 void* GetHandle() override; | 236 void* GetHandle() override; |
236 unsigned int GetBackingFrameBufferObject() override; | 237 unsigned int GetBackingFrameBufferObject() override; |
237 bool OnMakeCurrent(GLContext* context) override; | 238 bool OnMakeCurrent(GLContext* context) override; |
(...skipping 18 matching lines...) Expand all Loading... |
256 | 257 |
257 private: | 258 private: |
258 scoped_refptr<GLSurface> surface_; | 259 scoped_refptr<GLSurface> surface_; |
259 | 260 |
260 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 261 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
261 }; | 262 }; |
262 | 263 |
263 } // namespace gfx | 264 } // namespace gfx |
264 | 265 |
265 #endif // UI_GL_GL_SURFACE_H_ | 266 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |