OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GL_GPU_MEMORY_BUFFER_H_ |
| 6 #define UI_GL_GPU_MEMORY_BUFFER_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 |
| 12 namespace gfx { |
| 13 class Size; |
| 14 |
| 15 // Interface for creating and accessing a zero-copy GPU memory buffer. |
| 16 // This design evolved from the generalization of GraphicBuffer API |
| 17 // of Android framework. |
| 18 // |
| 19 // THREADING CONSIDERATIONS: |
| 20 // |
| 21 // This interface is thread-safe. However, multiple threads calling |
| 22 // MapForWrite() simultaneously may result in undefined behavior |
| 23 // and is not allowed. |
| 24 class GpuMemoryBuffer { |
| 25 public: |
| 26 typedef base::Callback<scoped_ptr<gfx::GpuMemoryBuffer>(gfx::Size)> Create; |
| 27 |
| 28 // Frees a previously allocated buffer. Freeing a buffer that is still |
| 29 // mapped in any process is undefined behavior. |
| 30 virtual ~GpuMemoryBuffer() {} |
| 31 |
| 32 // Maps the buffer so the client can write the bitmap data in |*vaddr| |
| 33 // subsequently. This call may block, for instance if the hardware needs |
| 34 // to finish rendering or if CPU caches need to be synchronized. |
| 35 virtual void MapForWrite(void** vaddr) = 0; |
| 36 |
| 37 // Unmaps the buffer. Called after all changes to the buffer are |
| 38 // completed. |
| 39 virtual void Unmap() = 0; |
| 40 |
| 41 // Returns the native pointer for the buffer. |
| 42 virtual void* GetNativeBuffer() = 0; |
| 43 |
| 44 // Returns the stride in pixels for the buffer. |
| 45 virtual uint32 GetStride() = 0; |
| 46 }; |
| 47 |
| 48 } // namespace gfx |
| 49 |
| 50 #endif // UI_GL_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |