OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_GFX_GPU_MEMORY_BUFFER_H_ | 5 #ifndef UI_GFX_GPU_MEMORY_BUFFER_H_ |
6 #define UI_GFX_GPU_MEMORY_BUFFER_H_ | 6 #define UI_GFX_GPU_MEMORY_BUFFER_H_ |
7 | 7 |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 FORMAT_LAST = BGRA_8888 | 55 FORMAT_LAST = BGRA_8888 |
56 }; | 56 }; |
57 | 57 |
58 // The usage mode affects how a buffer can be used. Only buffers created with | 58 // The usage mode affects how a buffer can be used. Only buffers created with |
59 // MAP can be mapped into the client's address space and accessed by the CPU. | 59 // MAP can be mapped into the client's address space and accessed by the CPU. |
60 enum Usage { MAP, SCANOUT, USAGE_LAST = SCANOUT }; | 60 enum Usage { MAP, SCANOUT, USAGE_LAST = SCANOUT }; |
61 | 61 |
62 virtual ~GpuMemoryBuffer() {} | 62 virtual ~GpuMemoryBuffer() {} |
63 | 63 |
64 // Maps the buffer into the client's address space so it can be written to by | 64 // Maps each plane of the buffer into the client's address space so it can be |
65 // the CPU. This call may block, for instance if the GPU needs to finish | 65 // written to by the CPU. A pointer to plane K is stored at index K-1 of the |
66 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL | 66 // |data| array. This call may block, for instance if the GPU needs to finish |
67 // on failure. | 67 // accessing the buffer or if CPU caches need to be synchronized. Returns |
68 virtual void* Map() = 0; | 68 // false on failure. |
| 69 virtual bool Map(void** data) = 0; |
69 | 70 |
70 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 71 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
71 // this has been called. | 72 // this has been called. |
72 virtual void Unmap() = 0; | 73 virtual void Unmap() = 0; |
73 | 74 |
74 // Returns true iff the buffer is mapped. | 75 // Returns true iff the buffer is mapped. |
75 virtual bool IsMapped() const = 0; | 76 virtual bool IsMapped() const = 0; |
76 | 77 |
77 // Returns the format for the buffer. | 78 // Returns the format for the buffer. |
78 virtual Format GetFormat() const = 0; | 79 virtual Format GetFormat() const = 0; |
79 | 80 |
80 // Returns the stride in bytes for the buffer. | 81 // Fills the stride in bytes for the each plane of the buffer. The stride of |
81 virtual uint32 GetStride() const = 0; | 82 // plane K is stored at index K-1 of the |stride| array. |
| 83 virtual void GetStride(uint32* stride) const = 0; |
82 | 84 |
83 // Returns a platform specific handle for this buffer. | 85 // Returns a platform specific handle for this buffer. |
84 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 86 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
85 | 87 |
86 // Type-checking downcast routine. | 88 // Type-checking downcast routine. |
87 virtual ClientBuffer AsClientBuffer() = 0; | 89 virtual ClientBuffer AsClientBuffer() = 0; |
88 }; | 90 }; |
89 | 91 |
90 } // namespace gfx | 92 } // namespace gfx |
91 | 93 |
92 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 94 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |