| 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 "base/trace_event/memory_dump_manager.h" | 9 #include "base/trace_event/memory_dump_manager.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "ui/gfx/buffer_types.h" |
| 11 #include "ui/gfx/gfx_export.h" | 12 #include "ui/gfx/gfx_export.h" |
| 12 | 13 |
| 13 extern "C" typedef struct _ClientBuffer* ClientBuffer; | 14 extern "C" typedef struct _ClientBuffer* ClientBuffer; |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 enum GpuMemoryBufferType { | 18 enum GpuMemoryBufferType { |
| 18 EMPTY_BUFFER, | 19 EMPTY_BUFFER, |
| 19 SHARED_MEMORY_BUFFER, | 20 SHARED_MEMORY_BUFFER, |
| 20 IO_SURFACE_BUFFER, | 21 IO_SURFACE_BUFFER, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 | 36 |
| 36 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT | 37 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT |
| 37 GetGpuMemoryBufferGUIDForTracing(uint64 tracing_process_id, | 38 GetGpuMemoryBufferGUIDForTracing(uint64 tracing_process_id, |
| 38 GpuMemoryBufferId buffer_id); | 39 GpuMemoryBufferId buffer_id); |
| 39 | 40 |
| 40 // This interface typically correspond to a type of shared memory that is also | 41 // This interface typically correspond to a type of shared memory that is also |
| 41 // shared with the GPU. A GPU memory buffer can be written to directly by | 42 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 42 // regular CPU code, but can also be read by the GPU. | 43 // regular CPU code, but can also be read by the GPU. |
| 43 class GFX_EXPORT GpuMemoryBuffer { | 44 class GFX_EXPORT GpuMemoryBuffer { |
| 44 public: | 45 public: |
| 45 // The format needs to be taken into account when mapping a buffer into the | |
| 46 // client's address space. | |
| 47 enum Format { | |
| 48 ATC, | |
| 49 ATCIA, | |
| 50 DXT1, | |
| 51 DXT5, | |
| 52 ETC1, | |
| 53 R_8, | |
| 54 RGBA_4444, | |
| 55 RGBA_8888, | |
| 56 RGBX_8888, | |
| 57 BGRA_8888, | |
| 58 YUV_420, | |
| 59 | |
| 60 FORMAT_LAST = YUV_420 | |
| 61 }; | |
| 62 | |
| 63 // The usage mode affects how a buffer can be used. Only buffers created with | |
| 64 // MAP can be mapped into the client's address space and accessed by the CPU. | |
| 65 // PERSISTENT_MAP adds the additional condition that successive Map() calls | |
| 66 // (with Unmap() calls between) will return a pointer to the same memory | |
| 67 // contents. | |
| 68 enum Usage { MAP, PERSISTENT_MAP, SCANOUT, USAGE_LAST = SCANOUT }; | |
| 69 | |
| 70 virtual ~GpuMemoryBuffer() {} | 46 virtual ~GpuMemoryBuffer() {} |
| 71 | 47 |
| 72 // Maps each plane of the buffer into the client's address space so it can be | 48 // Maps each plane of the buffer into the client's address space so it can be |
| 73 // written to by the CPU. A pointer to plane K is stored at index K-1 of the | 49 // written to by the CPU. A pointer to plane K is stored at index K-1 of the |
| 74 // |data| array. This call may block, for instance if the GPU needs to finish | 50 // |data| array. This call may block, for instance if the GPU needs to finish |
| 75 // accessing the buffer or if CPU caches need to be synchronized. Returns | 51 // accessing the buffer or if CPU caches need to be synchronized. Returns |
| 76 // false on failure. | 52 // false on failure. |
| 77 virtual bool Map(void** data) = 0; | 53 virtual bool Map(void** data) = 0; |
| 78 | 54 |
| 79 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 55 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
| 80 // this has been called. | 56 // this has been called. |
| 81 virtual void Unmap() = 0; | 57 virtual void Unmap() = 0; |
| 82 | 58 |
| 83 // Returns true iff the buffer is mapped. | 59 // Returns true iff the buffer is mapped. |
| 84 virtual bool IsMapped() const = 0; | 60 virtual bool IsMapped() const = 0; |
| 85 | 61 |
| 86 // Returns the format for the buffer. | 62 // Returns the format for the buffer. |
| 87 virtual Format GetFormat() const = 0; | 63 virtual BufferFormat GetFormat() const = 0; |
| 88 | 64 |
| 89 // Fills the stride in bytes for each plane of the buffer. The stride of | 65 // Fills the stride in bytes for each plane of the buffer. The stride of |
| 90 // plane K is stored at index K-1 of the |stride| array. | 66 // plane K is stored at index K-1 of the |stride| array. |
| 91 virtual void GetStride(int* stride) const = 0; | 67 virtual void GetStride(int* stride) const = 0; |
| 92 | 68 |
| 93 // Returns a unique identifier associated with buffer. | 69 // Returns a unique identifier associated with buffer. |
| 94 virtual GpuMemoryBufferId GetId() const = 0; | 70 virtual GpuMemoryBufferId GetId() const = 0; |
| 95 | 71 |
| 96 // Returns a platform specific handle for this buffer. | 72 // Returns a platform specific handle for this buffer. |
| 97 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 73 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 98 | 74 |
| 99 // Type-checking downcast routine. | 75 // Type-checking downcast routine. |
| 100 virtual ClientBuffer AsClientBuffer() = 0; | 76 virtual ClientBuffer AsClientBuffer() = 0; |
| 101 }; | 77 }; |
| 102 | 78 |
| 103 } // namespace gfx | 79 } // namespace gfx |
| 104 | 80 |
| 105 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 81 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |