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