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 |
78 // Returns the number of planes based on the format of the buffer. | |
79 virtual size_t GetNumberOfPlanes() const = 0; | |
reveman
2015/03/23 22:24:01
I still think it's better to not have this functio
emircan
2015/03/24 16:52:27
I see your point, but I don't see the case where i
reveman
2015/03/24 20:13:59
I think most of these DCHECKs are not needed. Eith
emircan
2015/03/24 21:43:44
Done. Thanks for the explanation.
| |
80 | |
77 // Returns the format for the buffer. | 81 // Returns the format for the buffer. |
78 virtual Format GetFormat() const = 0; | 82 virtual Format GetFormat() const = 0; |
79 | 83 |
80 // Returns the stride in bytes for the buffer. | 84 // Fills the stride in bytes for the each plane of the buffer. The stride of |
81 virtual uint32 GetStride() const = 0; | 85 // plane K is stored at index K-1 of the |stride| array. Returns |
86 // false on failure. | |
87 virtual bool GetStride(uint32* stride) const = 0; | |
reveman
2015/03/23 22:24:01
When would this fail? Please remove the return val
emircan
2015/03/24 16:52:27
GpuMemoryBufferImplSharedMemory::GetStride() calls
reveman
2015/03/24 20:13:59
GpuMemoryBufferImpl::StrideInBytes() having a retu
emircan
2015/03/24 21:43:44
Done.
| |
82 | 88 |
83 // Returns a platform specific handle for this buffer. | 89 // Returns a platform specific handle for this buffer. |
84 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 90 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
85 | 91 |
86 // Type-checking downcast routine. | 92 // Type-checking downcast routine. |
87 virtual ClientBuffer AsClientBuffer() = 0; | 93 virtual ClientBuffer AsClientBuffer() = 0; |
88 }; | 94 }; |
89 | 95 |
90 } // namespace gfx | 96 } // namespace gfx |
91 | 97 |
92 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 98 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |