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/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
12 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
13 #include "ui/gfx/overlay_transform.h" | 14 #include "ui/gfx/overlay_transform.h" |
14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
15 #include "ui/gfx/rect_f.h" | 16 #include "ui/gfx/rect_f.h" |
16 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" |
17 #include "ui/gl/gl_export.h" | 18 #include "ui/gl/gl_export.h" |
18 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
19 | 20 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Get the underlying platform specific surface "handle". | 66 // Get the underlying platform specific surface "handle". |
66 virtual void* GetHandle() = 0; | 67 virtual void* GetHandle() = 0; |
67 | 68 |
68 // Returns whether or not the surface supports PostSubBuffer. | 69 // Returns whether or not the surface supports PostSubBuffer. |
69 virtual bool SupportsPostSubBuffer(); | 70 virtual bool SupportsPostSubBuffer(); |
70 | 71 |
71 // Returns the internal frame buffer object name if the surface is backed by | 72 // Returns the internal frame buffer object name if the surface is backed by |
72 // FBO. Otherwise returns 0. | 73 // FBO. Otherwise returns 0. |
73 virtual unsigned int GetBackingFrameBufferObject(); | 74 virtual unsigned int GetBackingFrameBufferObject(); |
74 | 75 |
| 76 typedef base::Callback<void()> SwapCompletionCallback; |
| 77 // 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 // 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 // the calling thread (i.e. same thread SwapBuffersAsync is called) |
| 82 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); |
| 83 |
75 // Copy part of the backbuffer to the frontbuffer. | 84 // Copy part of the backbuffer to the frontbuffer. |
76 virtual bool PostSubBuffer(int x, int y, int width, int height); | 85 virtual bool PostSubBuffer(int x, int y, int width, int height); |
77 | 86 |
| 87 // 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 // 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 // thread PostSubBufferAsync is called) |
| 92 virtual bool PostSubBufferAsync(int x, |
| 93 int y, |
| 94 int width, |
| 95 int height, |
| 96 const SwapCompletionCallback& callback); |
| 97 |
78 // Initialize GL bindings. | 98 // Initialize GL bindings. |
79 static bool InitializeOneOff(GLImplementation = kGLImplementationNone); | 99 static bool InitializeOneOff(GLImplementation = kGLImplementationNone); |
80 | 100 |
81 // Unit tests should call these instead of InitializeOneOff() to set up | 101 // Unit tests should call these instead of InitializeOneOff() to set up |
82 // GL bindings appropriate for tests. | 102 // GL bindings appropriate for tests. |
83 static void InitializeOneOffForTests(); | 103 static void InitializeOneOffForTests(); |
84 static void InitializeOneOffWithMockBindingsForTests(); | 104 static void InitializeOneOffWithMockBindingsForTests(); |
85 static void InitializeDynamicMockBindingsForTests(GLContext* context); | 105 static void InitializeDynamicMockBindingsForTests(GLContext* context); |
86 | 106 |
87 // Called after a context is made current with this surface. Returns false | 107 // Called after a context is made current with this surface. Returns false |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 public: | 186 public: |
167 explicit GLSurfaceAdapter(GLSurface* surface); | 187 explicit GLSurfaceAdapter(GLSurface* surface); |
168 | 188 |
169 bool Initialize() override; | 189 bool Initialize() override; |
170 void Destroy() override; | 190 void Destroy() override; |
171 bool Resize(const gfx::Size& size) override; | 191 bool Resize(const gfx::Size& size) override; |
172 bool Recreate() override; | 192 bool Recreate() override; |
173 bool DeferDraws() override; | 193 bool DeferDraws() override; |
174 bool IsOffscreen() override; | 194 bool IsOffscreen() override; |
175 bool SwapBuffers() override; | 195 bool SwapBuffers() override; |
| 196 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
176 bool PostSubBuffer(int x, int y, int width, int height) override; | 197 bool PostSubBuffer(int x, int y, int width, int height) override; |
| 198 bool PostSubBufferAsync(int x, |
| 199 int y, |
| 200 int width, |
| 201 int height, |
| 202 const SwapCompletionCallback& callback) override; |
177 bool SupportsPostSubBuffer() override; | 203 bool SupportsPostSubBuffer() override; |
178 gfx::Size GetSize() override; | 204 gfx::Size GetSize() override; |
179 void* GetHandle() override; | 205 void* GetHandle() override; |
180 unsigned int GetBackingFrameBufferObject() override; | 206 unsigned int GetBackingFrameBufferObject() override; |
181 bool OnMakeCurrent(GLContext* context) override; | 207 bool OnMakeCurrent(GLContext* context) override; |
182 bool SetBackbufferAllocation(bool allocated) override; | 208 bool SetBackbufferAllocation(bool allocated) override; |
183 void SetFrontbufferAllocation(bool allocated) override; | 209 void SetFrontbufferAllocation(bool allocated) override; |
184 void* GetShareHandle() override; | 210 void* GetShareHandle() override; |
185 void* GetDisplay() override; | 211 void* GetDisplay() override; |
186 void* GetConfig() override; | 212 void* GetConfig() override; |
(...skipping 13 matching lines...) Expand all Loading... |
200 | 226 |
201 private: | 227 private: |
202 scoped_refptr<GLSurface> surface_; | 228 scoped_refptr<GLSurface> surface_; |
203 | 229 |
204 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 230 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
205 }; | 231 }; |
206 | 232 |
207 } // namespace gfx | 233 } // namespace gfx |
208 | 234 |
209 #endif // UI_GL_GL_SURFACE_H_ | 235 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |