| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 enum GpuMemoryBufferType { | 24 enum GpuMemoryBufferType { |
| 25 EMPTY_BUFFER, | 25 EMPTY_BUFFER, |
| 26 SHARED_MEMORY_BUFFER, | 26 SHARED_MEMORY_BUFFER, |
| 27 IO_SURFACE_BUFFER, | 27 IO_SURFACE_BUFFER, |
| 28 SURFACE_TEXTURE_BUFFER, | 28 SURFACE_TEXTURE_BUFFER, |
| 29 OZONE_NATIVE_PIXMAP, | 29 OZONE_NATIVE_PIXMAP, |
| 30 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP | 30 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 using GpuMemoryBufferId = gfx::GenericSharedMemoryId; | 33 using GpuMemoryBufferId = GenericSharedMemoryId; |
| 34 | 34 |
| 35 struct GFX_EXPORT GpuMemoryBufferHandle { | 35 struct GFX_EXPORT GpuMemoryBufferHandle { |
| 36 GpuMemoryBufferHandle(); | 36 GpuMemoryBufferHandle(); |
| 37 bool is_null() const { return type == EMPTY_BUFFER; } | 37 bool is_null() const { return type == EMPTY_BUFFER; } |
| 38 GpuMemoryBufferType type; | 38 GpuMemoryBufferType type; |
| 39 GpuMemoryBufferId id; | 39 GpuMemoryBufferId id; |
| 40 base::SharedMemoryHandle handle; | 40 base::SharedMemoryHandle handle; |
| 41 #if defined(USE_OZONE) | 41 #if defined(USE_OZONE) |
| 42 NativePixmapHandle native_pixmap_handle; | 42 NativePixmapHandle native_pixmap_handle; |
| 43 #endif | 43 #endif |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT | 46 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT |
| 47 GetGpuMemoryBufferGUIDForTracing(uint64 tracing_process_id, | 47 GetGpuMemoryBufferGUIDForTracing(uint64 tracing_process_id, |
| 48 GpuMemoryBufferId buffer_id); | 48 GpuMemoryBufferId buffer_id); |
| 49 | 49 |
| 50 // This interface typically correspond to a type of shared memory that is also | 50 // This interface typically correspond to a type of shared memory that is also |
| 51 // shared with the GPU. A GPU memory buffer can be written to directly by | 51 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 52 // regular CPU code, but can also be read by the GPU. | 52 // regular CPU code, but can also be read by the GPU. |
| 53 class GFX_EXPORT GpuMemoryBuffer { | 53 class GFX_EXPORT GpuMemoryBuffer { |
| 54 public: | 54 public: |
| 55 virtual ~GpuMemoryBuffer() {} | 55 virtual ~GpuMemoryBuffer() {} |
| 56 | 56 |
| 57 // Maps each plane of the buffer into the client's address space so it can be | 57 // Maps each plane of the buffer into the client's address space so it can be |
| 58 // written to by the CPU. A pointer to plane K is stored at index K-1 of the | 58 // written to by the CPU. This call may block, for instance if the GPU needs |
| 59 // |data| array. This call may block, for instance if the GPU needs to finish | 59 // to finish accessing the buffer or if CPU caches need to be synchronized. |
| 60 // accessing the buffer or if CPU caches need to be synchronized. Returns | 60 // Returns false on failure. |
| 61 // false on failure. | 61 virtual bool Map() = 0; |
| 62 virtual bool Map(void** data) = 0; | |
| 63 | 62 |
| 64 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 63 // Returns a pointer to the memory address of a plane. Buffer must have been |
| 65 // this has been called. | 64 // successfully mapped using a call to Map() before calling this function. |
| 65 virtual void* memory(size_t plane) = 0; |
| 66 |
| 67 // Unmaps the buffer. It's illegal to use any pointer returned by memory() |
| 68 // after this has been called. |
| 66 virtual void Unmap() = 0; | 69 virtual void Unmap() = 0; |
| 67 | 70 |
| 68 // Returns the size for the buffer. | 71 // Returns the size for the buffer. |
| 69 virtual gfx::Size GetSize() const = 0; | 72 virtual Size GetSize() const = 0; |
| 70 | 73 |
| 71 // Returns the format for the buffer. | 74 // Returns the format for the buffer. |
| 72 virtual BufferFormat GetFormat() const = 0; | 75 virtual BufferFormat GetFormat() const = 0; |
| 73 | 76 |
| 74 // Fills the stride in bytes for each plane of the buffer. The stride of | 77 // Fills the stride in bytes for each plane of the buffer. The stride of |
| 75 // plane K is stored at index K-1 of the |stride| array. | 78 // plane K is stored at index K-1 of the |stride| array. |
| 76 virtual void GetStride(int* stride) const = 0; | 79 virtual int stride(size_t plane) const = 0; |
| 77 | 80 |
| 78 // Returns a unique identifier associated with buffer. | 81 // Returns a unique identifier associated with buffer. |
| 79 virtual GpuMemoryBufferId GetId() const = 0; | 82 virtual GpuMemoryBufferId GetId() const = 0; |
| 80 | 83 |
| 81 // Returns a platform specific handle for this buffer. | 84 // Returns a platform specific handle for this buffer. |
| 82 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 85 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 83 | 86 |
| 84 // Type-checking downcast routine. | 87 // Type-checking downcast routine. |
| 85 virtual ClientBuffer AsClientBuffer() = 0; | 88 virtual ClientBuffer AsClientBuffer() = 0; |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 } // namespace gfx | 91 } // namespace gfx |
| 89 | 92 |
| 90 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 93 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |