| 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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 // Get the size of the surface. | 64 // Get the size of the surface. |
| 65 virtual gfx::Size GetSize() = 0; | 65 virtual gfx::Size GetSize() = 0; |
| 66 | 66 |
| 67 // Get the underlying platform specific surface "handle". | 67 // Get the underlying platform specific surface "handle". |
| 68 virtual void* GetHandle() = 0; | 68 virtual void* GetHandle() = 0; |
| 69 | 69 |
| 70 // Returns whether or not the surface supports PostSubBuffer. | 70 // Returns whether or not the surface supports PostSubBuffer. |
| 71 virtual bool SupportsPostSubBuffer(); | 71 virtual bool SupportsPostSubBuffer(); |
| 72 | 72 |
| 73 // Returns whether or not the surface supports CommitOverlayPlanes. |
| 74 virtual bool SupportsCommitOverlayPlanes(); |
| 75 |
| 73 // Returns whether SwapBuffersAsync() is supported. | 76 // Returns whether SwapBuffersAsync() is supported. |
| 74 virtual bool SupportsAsyncSwap(); | 77 virtual bool SupportsAsyncSwap(); |
| 75 | 78 |
| 76 // Returns the internal frame buffer object name if the surface is backed by | 79 // Returns the internal frame buffer object name if the surface is backed by |
| 77 // FBO. Otherwise returns 0. | 80 // FBO. Otherwise returns 0. |
| 78 virtual unsigned int GetBackingFrameBufferObject(); | 81 virtual unsigned int GetBackingFrameBufferObject(); |
| 79 | 82 |
| 80 typedef base::Callback<void(SwapResult)> SwapCompletionCallback; | 83 typedef base::Callback<void(SwapResult)> SwapCompletionCallback; |
| 81 // Swaps front and back buffers. This has no effect for off-screen | 84 // Swaps front and back buffers. This has no effect for off-screen |
| 82 // contexts. On some platforms, we want to send SwapBufferAck only after the | 85 // contexts. On some platforms, we want to send SwapBufferAck only after the |
| 83 // surface is displayed on screen. The callback can be used to delay sending | 86 // surface is displayed on screen. The callback can be used to delay sending |
| 84 // SwapBufferAck till that data is available. The callback should be run on | 87 // SwapBufferAck till that data is available. The callback should be run on |
| 85 // the calling thread (i.e. same thread SwapBuffersAsync is called) | 88 // the calling thread (i.e. same thread SwapBuffersAsync is called) |
| 86 virtual void SwapBuffersAsync(const SwapCompletionCallback& callback); | 89 virtual void SwapBuffersAsync(const SwapCompletionCallback& callback); |
| 87 | 90 |
| 88 // Copy part of the backbuffer to the frontbuffer. | 91 // Copy part of the backbuffer to the frontbuffer. |
| 89 virtual gfx::SwapResult PostSubBuffer(int x, int y, int width, int height); | 92 virtual gfx::SwapResult PostSubBuffer(int x, int y, int width, int height); |
| 90 | 93 |
| 91 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want | 94 // Copy part of the backbuffer to the frontbuffer. On some platforms, we want |
| 92 // to send SwapBufferAck only after the surface is displayed on screen. The | 95 // to send SwapBufferAck only after the surface is displayed on screen. The |
| 93 // callback can be used to delay sending SwapBufferAck till that data is | 96 // callback can be used to delay sending SwapBufferAck till that data is |
| 94 // available. The callback should be run on the calling thread (i.e. same | 97 // available. The callback should be run on the calling thread (i.e. same |
| 95 // thread PostSubBufferAsync is called) | 98 // thread PostSubBufferAsync is called) |
| 96 virtual void PostSubBufferAsync(int x, | 99 virtual void PostSubBufferAsync(int x, |
| 97 int y, | 100 int y, |
| 98 int width, | 101 int width, |
| 99 int height, | 102 int height, |
| 100 const SwapCompletionCallback& callback); | 103 const SwapCompletionCallback& callback); |
| 101 | 104 |
| 105 // Show overlay planes but don't swap the front and back buffers. This acts |
| 106 // like SwapBuffers from the point of view of the client, but is cheaper when |
| 107 // overlays account for all the damage. |
| 108 virtual gfx::SwapResult CommitOverlayPlanes(); |
| 109 |
| 110 // Show overlay planes but don't swap the front and back buffers. On some |
| 111 // platforms, we want to send SwapBufferAck only after the overlays are |
| 112 // displayed on screen. The callback can be used to delay sending |
| 113 // SwapBufferAck till that data is available. The callback should be run on |
| 114 // the calling thread (i.e. same thread CommitOverlayPlanesAsync is called). |
| 115 virtual void CommitOverlayPlanesAsync(const SwapCompletionCallback& callback); |
| 116 |
| 102 // Initialize GL bindings. | 117 // Initialize GL bindings. |
| 103 static bool InitializeOneOff(); | 118 static bool InitializeOneOff(); |
| 104 | 119 |
| 105 // Called after a context is made current with this surface. Returns false | 120 // Called after a context is made current with this surface. Returns false |
| 106 // on error. | 121 // on error. |
| 107 virtual bool OnMakeCurrent(GLContext* context); | 122 virtual bool OnMakeCurrent(GLContext* context); |
| 108 | 123 |
| 109 // Called when the surface is bound as the current framebuffer for the | 124 // Called when the surface is bound as the current framebuffer for the |
| 110 // current context. | 125 // current context. |
| 111 virtual void NotifyWasBound(); | 126 virtual void NotifyWasBound(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 // Get the platfrom specific configuration for this surface, if available. | 140 // Get the platfrom specific configuration for this surface, if available. |
| 126 virtual void* GetConfig(); | 141 virtual void* GetConfig(); |
| 127 | 142 |
| 128 // Get the GL pixel format of the surface, if available. | 143 // Get the GL pixel format of the surface, if available. |
| 129 virtual unsigned GetFormat(); | 144 virtual unsigned GetFormat(); |
| 130 | 145 |
| 131 // Get access to a helper providing time of recent refresh and period | 146 // Get access to a helper providing time of recent refresh and period |
| 132 // of screen refresh. If unavailable, returns NULL. | 147 // of screen refresh. If unavailable, returns NULL. |
| 133 virtual VSyncProvider* GetVSyncProvider(); | 148 virtual VSyncProvider* GetVSyncProvider(); |
| 134 | 149 |
| 135 // Schedule an overlay plane to be shown at swap time. | 150 // Schedule an overlay plane to be shown at swap time, or on the next |
| 151 // CommitOverlayPlanes call. |
| 136 // |z_order| specifies the stacking order of the plane relative to the | 152 // |z_order| specifies the stacking order of the plane relative to the |
| 137 // main framebuffer located at index 0. For the case where there is no | 153 // main framebuffer located at index 0. For the case where there is no |
| 138 // main framebuffer, overlays may be scheduled at 0, taking its place. | 154 // main framebuffer, overlays may be scheduled at 0, taking its place. |
| 139 // |transform| specifies how the buffer is to be transformed during | 155 // |transform| specifies how the buffer is to be transformed during |
| 140 // composition. | 156 // composition. |
| 141 // |image| to be presented by the overlay. | 157 // |image| to be presented by the overlay. |
| 142 // |bounds_rect| specify where it is supposed to be on the screen in pixels. | 158 // |bounds_rect| specify where it is supposed to be on the screen in pixels. |
| 143 // |crop_rect| specifies the region within the buffer to be placed inside | 159 // |crop_rect| specifies the region within the buffer to be placed inside |
| 144 // |bounds_rect|. | 160 // |bounds_rect|. |
| 145 virtual bool ScheduleOverlayPlane(int z_order, | 161 virtual bool ScheduleOverlayPlane(int z_order, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool DeferDraws() override; | 229 bool DeferDraws() override; |
| 214 bool IsOffscreen() override; | 230 bool IsOffscreen() override; |
| 215 gfx::SwapResult SwapBuffers() override; | 231 gfx::SwapResult SwapBuffers() override; |
| 216 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; | 232 void SwapBuffersAsync(const SwapCompletionCallback& callback) override; |
| 217 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; | 233 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override; |
| 218 void PostSubBufferAsync(int x, | 234 void PostSubBufferAsync(int x, |
| 219 int y, | 235 int y, |
| 220 int width, | 236 int width, |
| 221 int height, | 237 int height, |
| 222 const SwapCompletionCallback& callback) override; | 238 const SwapCompletionCallback& callback) override; |
| 239 gfx::SwapResult CommitOverlayPlanes() override; |
| 240 void CommitOverlayPlanesAsync( |
| 241 const SwapCompletionCallback& callback) override; |
| 223 bool SupportsPostSubBuffer() override; | 242 bool SupportsPostSubBuffer() override; |
| 243 bool SupportsCommitOverlayPlanes() override; |
| 224 bool SupportsAsyncSwap() override; | 244 bool SupportsAsyncSwap() override; |
| 225 gfx::Size GetSize() override; | 245 gfx::Size GetSize() override; |
| 226 void* GetHandle() override; | 246 void* GetHandle() override; |
| 227 unsigned int GetBackingFrameBufferObject() override; | 247 unsigned int GetBackingFrameBufferObject() override; |
| 228 bool OnMakeCurrent(GLContext* context) override; | 248 bool OnMakeCurrent(GLContext* context) override; |
| 229 bool SetBackbufferAllocation(bool allocated) override; | 249 bool SetBackbufferAllocation(bool allocated) override; |
| 230 void SetFrontbufferAllocation(bool allocated) override; | 250 void SetFrontbufferAllocation(bool allocated) override; |
| 231 void* GetShareHandle() override; | 251 void* GetShareHandle() override; |
| 232 void* GetDisplay() override; | 252 void* GetDisplay() override; |
| 233 void* GetConfig() override; | 253 void* GetConfig() override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 247 | 267 |
| 248 private: | 268 private: |
| 249 scoped_refptr<GLSurface> surface_; | 269 scoped_refptr<GLSurface> surface_; |
| 250 | 270 |
| 251 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); | 271 DISALLOW_COPY_AND_ASSIGN(GLSurfaceAdapter); |
| 252 }; | 272 }; |
| 253 | 273 |
| 254 } // namespace gfx | 274 } // namespace gfx |
| 255 | 275 |
| 256 #endif // UI_GL_GL_SURFACE_H_ | 276 #endif // UI_GL_GL_SURFACE_H_ |
| OLD | NEW |