Chromium Code Reviews| 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 // GPUMainThread only. | |
|
piman
2014/12/22 20:53:15
nit: in ui/gl there's no notion of GpuMainThread.
kalyank
2014/12/23 11:22:42
Done.
| |
| 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 GPUMainThread only. | |
| 91 virtual bool PostSubBufferAsync(int x, | |
| 92 int y, | |
| 93 int width, | |
| 94 int height, | |
| 95 const SwapCompletionCallback& callback); | |
| 96 | |
| 78 // Initialize GL bindings. | 97 // Initialize GL bindings. |
| 79 static bool InitializeOneOff(); | 98 static bool InitializeOneOff(); |
| 80 | 99 |
| 81 // Unit tests should call these instead of InitializeOneOff() to set up | 100 // Unit tests should call these instead of InitializeOneOff() to set up |
| 82 // GL bindings appropriate for tests. | 101 // GL bindings appropriate for tests. |
| 83 static void InitializeOneOffForTests(); | 102 static void InitializeOneOffForTests(); |
| 84 static void InitializeOneOffWithMockBindingsForTests(); | 103 static void InitializeOneOffWithMockBindingsForTests(); |
| 85 static void InitializeDynamicMockBindingsForTests(GLContext* context); | 104 static void InitializeDynamicMockBindingsForTests(GLContext* context); |
| 86 | 105 |
| 87 // Called after a context is made current with this surface. Returns false | 106 // 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: | 185 public: |
| 167 explicit GLSurfaceAdapter(GLSurface* surface); | 186 explicit GLSurfaceAdapter(GLSurface* surface); |
| 168 | 187 |
| 169 bool Initialize() override; | 188 bool Initialize() override; |
| 170 void Destroy() override; | 189 void Destroy() override; |
| 171 bool Resize(const gfx::Size& size) override; | 190 bool Resize(const gfx::Size& size) override; |
| 172 bool Recreate() override; | 191 bool Recreate() override; |
| 173 bool DeferDraws() override; | 192 bool DeferDraws() override; |
| 174 bool IsOffscreen() override; | 193 bool IsOffscreen() override; |
| 175 bool SwapBuffers() override; | 194 bool SwapBuffers() override; |
| 195 bool SwapBuffersAsync(const SwapCompletionCallback& callback) override; | |
| 176 bool PostSubBuffer(int x, int y, int width, int height) override; | 196 bool PostSubBuffer(int x, int y, int width, int height) override; |
| 197 bool PostSubBufferAsync(int x, | |
| 198 int y, | |
| 199 int width, | |
| 200 int height, | |
| 201 const SwapCompletionCallback& callback) override; | |
| 177 bool SupportsPostSubBuffer() override; | 202 bool SupportsPostSubBuffer() override; |
| 178 gfx::Size GetSize() override; | 203 gfx::Size GetSize() override; |
| 179 void* GetHandle() override; | 204 void* GetHandle() override; |
| 180 unsigned int GetBackingFrameBufferObject() override; | 205 unsigned int GetBackingFrameBufferObject() override; |
| 181 bool OnMakeCurrent(GLContext* context) override; | 206 bool OnMakeCurrent(GLContext* context) override; |
| 182 bool SetBackbufferAllocation(bool allocated) override; | 207 bool SetBackbufferAllocation(bool allocated) override; |
| 183 void SetFrontbufferAllocation(bool allocated) override; | 208 void SetFrontbufferAllocation(bool allocated) override; |
| 184 void* GetShareHandle() override; | 209 void* GetShareHandle() override; |
| 185 void* GetDisplay() override; | 210 void* GetDisplay() override; |
| 186 void* GetConfig() override; | 211 void* GetConfig() override; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 200 | 225 |
| 201 private: | 226 private: |
| 202 scoped_refptr<GLSurface> surface_; | 227 scoped_refptr<GLSurface> surface_; |
| 203 | 228 |
| 204 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 229 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
| 205 }; | 230 }; |
| 206 | 231 |
| 207 } // namespace gfx | 232 } // namespace gfx |
| 208 | 233 |
| 209 #endif // UI_GL_GL_SURFACE_H_ | 234 #endif // UI_GL_GL_SURFACE_H_ |
| OLD | NEW |