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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 the buffer into the client's address space so it can be written to by |
65 // the CPU. This call may block, for instance if the GPU needs to finish | 65 // the CPU. This call may block, for instance if the GPU needs to finish |
66 // accessing the buffer or if CPU caches need to be synchronized. Returns NULL | 66 // accessing the buffer or if CPU caches need to be synchronized. |
67 // on failure. | 67 // If the buffer contains a single plane, it returns a pointer to that single |
68 // plane. If the buffer contains multiple planes, it returns a pointer to the | |
69 // plane at index 0. | |
70 // Returns NULL on failure. | |
68 virtual void* Map() = 0; | 71 virtual void* Map() = 0; |
reveman
2015/03/21 03:03:55
I don't like having multiple versions of Map(). Le
emircan
2015/03/23 19:21:35
Done.
| |
69 | 72 |
73 // Maps the plane of the buffer at index |plane_index| into the client's | |
74 // address space so it can be written to by the CPU. This call may block, for | |
75 // instance if the GPU needs to finish accessing the buffer or if CPU caches | |
76 // need to be synchronized. | |
77 // If |plane_index| points to an index greater than or equal to the return | |
78 // value of GetNumberOfPlanes(), returns NULL. | |
79 // Returns NULL on failure. | |
80 virtual void* Map(size_t plane_index) = 0; | |
reveman
2015/03/21 03:03:55
I'd prefer if Map took an array of void* and retur
emircan
2015/03/23 19:21:35
Done.
My reasoning to do it initially this way wa
| |
81 | |
70 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 82 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
71 // this has been called. | 83 // this has been called. |
72 virtual void Unmap() = 0; | 84 virtual void Unmap() = 0; |
73 | 85 |
74 // Returns true iff the buffer is mapped. | 86 // Returns true iff the buffer is mapped. |
75 virtual bool IsMapped() const = 0; | 87 virtual bool IsMapped() const = 0; |
76 | 88 |
89 // Returns the number of planes based on the format of the buffer. | |
90 virtual size_t GetNumberOfPlanes() const = 0; | |
reveman
2015/03/21 03:03:55
Do we really need this? Is the number not implied
emircan
2015/03/23 19:21:35
It is implied and derived from format in the const
| |
91 | |
77 // Returns the format for the buffer. | 92 // Returns the format for the buffer. |
78 virtual Format GetFormat() const = 0; | 93 virtual Format GetFormat() const = 0; |
79 | 94 |
80 // Returns the stride in bytes for the buffer. | 95 // Returns the stride in bytes for the buffer. |
96 // If the buffer contains a single plane, it returns the stride in bytes for | |
97 // that single plane. If the buffer contains multiple planes, it returns the | |
98 // stride in bytes for the plane at index 0. | |
81 virtual uint32 GetStride() const = 0; | 99 virtual uint32 GetStride() const = 0; |
reveman
2015/03/21 03:03:55
Same here. I prefer if we just have one version of
emircan
2015/03/23 19:21:35
Done.
| |
82 | 100 |
101 // Returns the stride in bytes for the plane of the buffer at index | |
102 // |plane_index|. | |
103 // If |plane_index| points to an index greater than or equal to the return | |
104 // value of GetNumberOfPlanes(), returns 0. | |
105 virtual uint32 GetStride(size_t plane_index) const = 0; | |
reveman
2015/03/21 03:03:55
For consistency, I would prefer GetStride(uint32*
emircan
2015/03/23 19:21:35
Done.
| |
106 | |
83 // Returns a platform specific handle for this buffer. | 107 // Returns a platform specific handle for this buffer. |
84 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 108 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
85 | 109 |
86 // Type-checking downcast routine. | 110 // Type-checking downcast routine. |
87 virtual ClientBuffer AsClientBuffer() = 0; | 111 virtual ClientBuffer AsClientBuffer() = 0; |
88 }; | 112 }; |
89 | 113 |
90 } // namespace gfx | 114 } // namespace gfx |
91 | 115 |
92 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 116 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |