| 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 IO_SURFACE_BUFFER, | 21 IO_SURFACE_BUFFER, |
| 22 ANDROID_NATIVE_BUFFER, | 22 ANDROID_NATIVE_BUFFER, |
| 23 SURFACE_TEXTURE_BUFFER, | 23 SURFACE_TEXTURE_BUFFER, |
| 24 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER | 24 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 // TODO(alexst): Merge this with GpuMemoryBufferId as part of switchover to |
| 28 // the new API for GpuMemoryBuffer allocation when it's done. |
| 27 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 28 struct SurfaceTextureId { | 30 struct SurfaceTextureId { |
| 29 SurfaceTextureId() : primary_id(0), secondary_id(0) {} | 31 SurfaceTextureId() : primary_id(0), secondary_id(0) {} |
| 30 SurfaceTextureId(int32 primary_id, int32 secondary_id) | 32 SurfaceTextureId(int32 primary_id, int32 secondary_id) |
| 31 : primary_id(primary_id), secondary_id(secondary_id) {} | 33 : primary_id(primary_id), secondary_id(secondary_id) {} |
| 32 int32 primary_id; | 34 int32 primary_id; |
| 33 int32 secondary_id; | 35 int32 secondary_id; |
| 34 }; | 36 }; |
| 35 #endif | 37 #endif |
| 36 | 38 |
| 39 struct GpuMemoryBufferId { |
| 40 GpuMemoryBufferId() : primary_id(0), secondary_id(0) {} |
| 41 GpuMemoryBufferId(int32 primary_id, int32 secondary_id) |
| 42 : primary_id(primary_id), secondary_id(secondary_id) {} |
| 43 int32 primary_id; |
| 44 int32 secondary_id; |
| 45 }; |
| 46 |
| 37 struct GpuMemoryBufferHandle { | 47 struct GpuMemoryBufferHandle { |
| 38 GpuMemoryBufferHandle() | 48 GpuMemoryBufferHandle() |
| 39 : type(EMPTY_BUFFER), | 49 : type(EMPTY_BUFFER), |
| 40 handle(base::SharedMemory::NULLHandle()) | 50 handle(base::SharedMemory::NULLHandle()) |
| 41 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
| 42 , | 52 , |
| 43 io_surface_id(0u) | 53 io_surface_id(0u) |
| 44 #endif | 54 #endif |
| 45 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
| 46 , | 56 , |
| 47 native_buffer(NULL) | 57 native_buffer(NULL) |
| 48 #endif | 58 #endif |
| 49 { | 59 { |
| 50 } | 60 } |
| 51 bool is_null() const { return type == EMPTY_BUFFER; } | 61 bool is_null() const { return type == EMPTY_BUFFER; } |
| 52 GpuMemoryBufferType type; | 62 GpuMemoryBufferType type; |
| 53 base::SharedMemoryHandle handle; | 63 base::SharedMemoryHandle handle; |
| 64 GpuMemoryBufferId global_id; |
| 54 #if defined(OS_MACOSX) | 65 #if defined(OS_MACOSX) |
| 55 uint32 io_surface_id; | 66 uint32 io_surface_id; |
| 56 #endif | 67 #endif |
| 57 #if defined(OS_ANDROID) | 68 #if defined(OS_ANDROID) |
| 58 EGLClientBuffer native_buffer; | 69 EGLClientBuffer native_buffer; |
| 59 SurfaceTextureId surface_texture_id; | 70 SurfaceTextureId surface_texture_id; |
| 60 #endif | 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 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 84 // Returns the stride in bytes for the buffer. | 95 // Returns the stride in bytes for the buffer. |
| 85 virtual uint32 GetStride() const = 0; | 96 virtual uint32 GetStride() const = 0; |
| 86 | 97 |
| 87 // Returns a platform specific handle for this buffer. | 98 // Returns a platform specific handle for this buffer. |
| 88 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 99 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 89 }; | 100 }; |
| 90 | 101 |
| 91 } // namespace gfx | 102 } // namespace gfx |
| 92 | 103 |
| 93 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 104 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |