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. |
| 81 virtual bool SwapBuffersAsync(const SwapCompletionCallback& callback); |
| 82 |
75 // Copy part of the backbuffer to the frontbuffer. | 83 // Copy part of the backbuffer to the frontbuffer. |
76 virtual bool PostSubBuffer(int x, int y, int width, int height); | 84 virtual bool PostSubBuffer(int x, int y, int width, int height); |
77 | 85 |
| 86 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want |
| 87 // to send SwapBufferAck only after the surface is displayed on screen. The |
| 88 // callback can be used to delay sending SwapBufferAck till that data is |
| 89 // available. |
| 90 virtual bool PostSubBufferAsync(int x, |
| 91 int y, |
| 92 int width, |
| 93 int height, |
| 94 const SwapCompletionCallback& callback); |
| 95 |
78 // Initialize GL bindings. | 96 // Initialize GL bindings. |
79 static bool InitializeOneOff(); | 97 static bool InitializeOneOff(); |
80 | 98 |
81 // Unit tests should call these instead of InitializeOneOff() to set up | 99 // Unit tests should call these instead of InitializeOneOff() to set up |
82 // GL bindings appropriate for tests. | 100 // GL bindings appropriate for tests. |
83 static void InitializeOneOffForTests(); | 101 static void InitializeOneOffForTests(); |
84 static void InitializeOneOffWithMockBindingsForTests(); | 102 static void InitializeOneOffWithMockBindingsForTests(); |
85 static void InitializeDynamicMockBindingsForTests(GLContext* context); | 103 static void InitializeDynamicMockBindingsForTests(GLContext* context); |
86 | 104 |
87 // Called after a context is made current with this surface. Returns false | 105 // Called after a context is made current with this surface. Returns false |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 public: | 180 public: |
163 explicit GLSurfaceAdapter(GLSurface* surface); | 181 explicit GLSurfaceAdapter(GLSurface* surface); |
164 | 182 |
165 bool Initialize() override; | 183 bool Initialize() override; |
166 void Destroy() override; | 184 void Destroy() override; |
167 bool Resize(const gfx::Size& size) override; | 185 bool Resize(const gfx::Size& size) override; |
168 bool Recreate() override; | 186 bool Recreate() override; |
169 bool DeferDraws() override; | 187 bool DeferDraws() override; |
170 bool IsOffscreen() override; | 188 bool IsOffscreen() override; |
171 bool SwapBuffers() override; | 189 bool SwapBuffers() override; |
| 190 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
172 bool PostSubBuffer(int x, int y, int width, int height) override; | 191 bool PostSubBuffer(int x, int y, int width, int height) override; |
| 192 bool PostSubBufferAsync(int x, |
| 193 int y, |
| 194 int width, |
| 195 int height, |
| 196 const SwapCompletionCallback& callback) override; |
173 bool SupportsPostSubBuffer() override; | 197 bool SupportsPostSubBuffer() override; |
174 gfx::Size GetSize() override; | 198 gfx::Size GetSize() override; |
175 void* GetHandle() override; | 199 void* GetHandle() override; |
176 unsigned int GetBackingFrameBufferObject() override; | 200 unsigned int GetBackingFrameBufferObject() override; |
177 bool OnMakeCurrent(GLContext* context) override; | 201 bool OnMakeCurrent(GLContext* context) override; |
178 bool SetBackbufferAllocation(bool allocated) override; | 202 bool SetBackbufferAllocation(bool allocated) override; |
179 void SetFrontbufferAllocation(bool allocated) override; | 203 void SetFrontbufferAllocation(bool allocated) override; |
180 void* GetShareHandle() override; | 204 void* GetShareHandle() override; |
181 void* GetDisplay() override; | 205 void* GetDisplay() override; |
182 void* GetConfig() override; | 206 void* GetConfig() override; |
(...skipping 13 matching lines...) Expand all Loading... |
196 | 220 |
197 private: | 221 private: |
198 scoped_refptr<GLSurface> surface_; | 222 scoped_refptr<GLSurface> surface_; |
199 | 223 |
200 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 224 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
201 }; | 225 }; |
202 | 226 |
203 } // namespace gfx | 227 } // namespace gfx |
204 | 228 |
205 #endif // UI_GL_GL_SURFACE_H_ | 229 #endif // UI_GL_GL_SURFACE_H_ |
OLD | NEW |