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 namespace gfx { | 16 namespace gfx { |
| 17 | 17 |
| 18 enum GpuMemoryBufferType { | 18 enum GpuMemoryBufferType { |
| 19 EMPTY_BUFFER, | 19 EMPTY_BUFFER, |
| 20 SHARED_MEMORY_BUFFER, | 20 SHARED_MEMORY_BUFFER, |
| 21 EGL_CLIENT_BUFFER, | 21 EGL_CLIENT_BUFFER, |
| 22 IO_SURFACE_BUFFER, | 22 IO_SURFACE_BUFFER, |
| 23 GPU_MEMORY_BUFFER_TYPE_LAST = IO_SURFACE_BUFFER | 23 SURFACE_TEXTURE_BUFFER, |
| 24 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER | |
| 24 }; | 25 }; |
| 25 | 26 |
| 27 #if defined(OS_ANDROID) | |
| 28 struct SurfaceTextureId { | |
| 29 SurfaceTextureId() : primary_id(0), secondary_id(0) {} | |
| 30 SurfaceTextureId(int32 primary_id, int32 secondary_id) | |
| 31 : primary_id(primary_id), secondary_id(secondary_id) {} | |
| 32 int32 primary_id; | |
| 33 int32 secondary_id; | |
| 34 }; | |
| 35 #endif | |
| 36 | |
| 26 struct GpuMemoryBufferHandle { | 37 struct GpuMemoryBufferHandle { |
| 27 GpuMemoryBufferHandle() | 38 GpuMemoryBufferHandle() |
| 28 : type(EMPTY_BUFFER), | 39 : type(EMPTY_BUFFER), |
| 29 handle(base::SharedMemory::NULLHandle()) | 40 handle(base::SharedMemory::NULLHandle()) |
| 30 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) |
| 31 , native_buffer(NULL) | 42 , native_buffer(NULL) |
| 32 #endif | 43 #endif |
| 33 #if defined(OS_MACOSX) | 44 #if defined(OS_MACOSX) |
| 34 , io_surface_id(0) | 45 , io_surface_id(0) |
| 35 #endif | 46 #endif |
| 36 { | 47 { |
| 37 } | 48 } |
| 38 bool is_null() const { return type == EMPTY_BUFFER; } | 49 bool is_null() const { return type == EMPTY_BUFFER; } |
| 39 GpuMemoryBufferType type; | 50 GpuMemoryBufferType type; |
| 40 base::SharedMemoryHandle handle; | 51 base::SharedMemoryHandle handle; |
| 41 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
| 42 EGLClientBuffer native_buffer; | 53 EGLClientBuffer native_buffer; |
| 43 #endif | 54 #endif |
| 44 #if defined(OS_MACOSX) | 55 #if defined(OS_MACOSX) |
| 45 uint32 io_surface_id; | 56 uint32 io_surface_id; |
| 46 #endif | 57 #endif |
| 47 | 58 #if defined(OS_ANDROID) |
| 59 SurfaceTextureId surface_texture_id; | |
|
piman
2014/03/27 01:07:25
nit: can we factor that into the #if in line 53?
reveman
2014/03/27 14:48:11
Done.
| |
| 60 #endif | |
| 48 }; | 61 }; |
| 49 | 62 |
| 50 // Interface for creating and accessing a zero-copy GPU memory buffer. | 63 // Interface for creating and accessing a zero-copy GPU memory buffer. |
| 51 // This design evolved from the generalization of GraphicBuffer API | 64 // This design evolved from the generalization of GraphicBuffer API |
| 52 // of Android framework. | 65 // of Android framework. |
| 53 // | 66 // |
| 54 // THREADING CONSIDERATIONS: | 67 // THREADING CONSIDERATIONS: |
| 55 // | 68 // |
| 56 // This interface is thread-safe. However, multiple threads mapping | 69 // This interface is thread-safe. However, multiple threads mapping |
| 57 // a buffer for Write or ReadOrWrite simultaneously may result in undefined | 70 // a buffer for Write or ReadOrWrite simultaneously may result in undefined |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 82 // Returns the stride in bytes for the buffer. | 95 // Returns the stride in bytes for the buffer. |
| 83 virtual uint32 GetStride() const = 0; | 96 virtual uint32 GetStride() const = 0; |
| 84 | 97 |
| 85 // Returns a platform specific handle for this buffer. | 98 // Returns a platform specific handle for this buffer. |
| 86 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 99 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 87 }; | 100 }; |
| 88 | 101 |
| 89 } // namespace gfx | 102 } // namespace gfx |
| 90 | 103 |
| 91 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 104 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |