Chromium Code Reviews| 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" |
| 11 | 11 |
| 12 #if defined(OS_ANDROID) | 12 #if defined(OS_ANDROID) |
| 13 #include <third_party/khronos/EGL/egl.h> | 13 #include <third_party/khronos/EGL/egl.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #if defined(USE_OZONE) | |
| 17 #include "ui/gfx/ozone/surface_factory_ozone.h" | |
| 18 #endif | |
| 19 | |
| 16 namespace gfx { | 20 namespace gfx { |
| 17 | 21 |
| 18 enum GpuMemoryBufferType { | 22 enum GpuMemoryBufferType { |
| 19 EMPTY_BUFFER, | 23 EMPTY_BUFFER, |
| 20 SHARED_MEMORY_BUFFER, | 24 SHARED_MEMORY_BUFFER, |
| 21 IO_SURFACE_BUFFER, | 25 IO_SURFACE_BUFFER, |
| 22 ANDROID_NATIVE_BUFFER, | 26 ANDROID_NATIVE_BUFFER, |
| 23 SURFACE_TEXTURE_BUFFER, | 27 SURFACE_TEXTURE_BUFFER, |
| 24 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER | 28 OZONE_NATIVE_BUFFER, |
| 29 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_BUFFER | |
| 25 }; | 30 }; |
| 26 | 31 |
| 27 #if defined(OS_ANDROID) | 32 #if defined(OS_ANDROID) |
| 28 struct SurfaceTextureId { | 33 struct SurfaceTextureId { |
| 29 SurfaceTextureId() : primary_id(0), secondary_id(0) {} | 34 SurfaceTextureId() : primary_id(0), secondary_id(0) {} |
| 30 SurfaceTextureId(int32 primary_id, int32 secondary_id) | 35 SurfaceTextureId(int32 primary_id, int32 secondary_id) |
| 31 : primary_id(primary_id), secondary_id(secondary_id) {} | 36 : primary_id(primary_id), secondary_id(secondary_id) {} |
| 32 int32 primary_id; | 37 int32 primary_id; |
| 33 int32 secondary_id; | 38 int32 secondary_id; |
| 34 }; | 39 }; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 51 bool is_null() const { return type == EMPTY_BUFFER; } | 56 bool is_null() const { return type == EMPTY_BUFFER; } |
| 52 GpuMemoryBufferType type; | 57 GpuMemoryBufferType type; |
| 53 base::SharedMemoryHandle handle; | 58 base::SharedMemoryHandle handle; |
| 54 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 55 uint32 io_surface_id; | 60 uint32 io_surface_id; |
| 56 #endif | 61 #endif |
| 57 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 58 EGLClientBuffer native_buffer; | 63 EGLClientBuffer native_buffer; |
| 59 SurfaceTextureId surface_texture_id; | 64 SurfaceTextureId surface_texture_id; |
| 60 #endif | 65 #endif |
| 66 #if defined(OS_MACOSX) | |
| 67 uint32 io_surface_id; | |
| 68 #endif | |
| 69 #if defined(USE_OZONE) | |
| 70 gfx::NativeBufferOzone ozone_native_buffer; | |
| 71 #endif | |
| 61 }; | 72 }; |
| 62 | 73 |
| 63 // This interface typically correspond to a type of shared memory that is also | 74 // This interface typically correspond to a type of shared memory that is also |
| 64 // shared with the GPU. A GPU memory buffer can be written to directly by | 75 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 65 // regular CPU code, but can also be read by the GPU. | 76 // regular CPU code, but can also be read by the GPU. |
| 66 class GFX_EXPORT GpuMemoryBuffer { | 77 class GFX_EXPORT GpuMemoryBuffer { |
| 67 public: | 78 public: |
| 68 enum AccessMode { READ_ONLY, WRITE_ONLY, READ_WRITE }; | 79 enum Usage { READ_WRITE, SCANOUT, USAGE_LAST = SCANOUT }; |
| 69 | |
| 70 GpuMemoryBuffer(); | 80 GpuMemoryBuffer(); |
| 71 virtual ~GpuMemoryBuffer(); | 81 virtual ~GpuMemoryBuffer(); |
| 72 | 82 |
| 73 // Maps the buffer into the client's address space so it can be written to by | 83 // Maps the buffer into the client's address space so it can be written to by |
| 74 // the CPU. This call may block, for instance if the GPU needs to finish | 84 // the CPU. This call may block, for instance if the GPU needs to finish |
| 75 // accessing the buffer or if CPU caches need to be synchronized. |mode| | 85 // accessing the buffer or if CPU caches need to be synchronized. |mode| |
| 76 // indicate how the client intends to use the mapped buffer. Returns NULL on | 86 // indicate how the client intends to use the mapped buffer. Returns NULL on |
| 77 // failure. | 87 // failure. |
| 78 virtual void* Map(AccessMode mode) = 0; | 88 virtual void* Map() = 0; |
|
reveman
2014/04/29 20:04:43
Can we start be making this change first and all t
| |
| 79 | 89 |
| 80 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after | 90 // Unmaps the buffer. It's illegal to use the pointer returned by Map() after |
| 81 // this has been called. | 91 // this has been called. |
| 82 virtual void Unmap() = 0; | 92 virtual void Unmap() = 0; |
| 83 | 93 |
| 84 // Returns true iff the buffer is mapped. | 94 // Returns true iff the buffer is mapped. |
| 85 virtual bool IsMapped() const = 0; | 95 virtual bool IsMapped() const = 0; |
| 86 | 96 |
| 87 // Returns the stride in bytes for the buffer. | 97 // Returns the stride in bytes for the buffer. |
| 88 virtual uint32 GetStride() const = 0; | 98 virtual uint32 GetStride() const = 0; |
| 89 | 99 |
| 90 // Returns a platform specific handle for this buffer. | 100 // Returns a platform specific handle for this buffer. |
| 91 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 101 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 92 }; | 102 }; |
| 93 | 103 |
| 94 } // namespace gfx | 104 } // namespace gfx |
| 95 | 105 |
| 96 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 106 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |