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 #include "ui/gfx/native_widget_types.h" | |
| 11 | 12 |
| 12 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 13 #include <third_party/khronos/EGL/egl.h> | 14 #include <third_party/khronos/EGL/egl.h> |
| 14 #endif | 15 #endif |
| 15 | 16 |
| 16 namespace gfx { | 17 namespace gfx { |
| 17 | 18 |
| 18 enum GpuMemoryBufferType { | 19 enum GpuMemoryBufferType { |
| 19 EMPTY_BUFFER, | 20 EMPTY_BUFFER, |
| 20 SHARED_MEMORY_BUFFER, | 21 SHARED_MEMORY_BUFFER, |
| 21 IO_SURFACE_BUFFER, | 22 IO_SURFACE_BUFFER, |
| 22 ANDROID_NATIVE_BUFFER, | 23 ANDROID_NATIVE_BUFFER, |
| 23 SURFACE_TEXTURE_BUFFER, | 24 SURFACE_TEXTURE_BUFFER, |
| 24 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER | 25 GPU_MEMORY_BUFFER_TYPE_LAST = SURFACE_TEXTURE_BUFFER |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 #if defined(OS_ANDROID) | 28 struct GpuMemoryBufferId { |
| 28 struct SurfaceTextureId { | 29 GpuMemoryBufferId() : primary_id(0), secondary_id(base::kNullProcessId) {} |
| 29 SurfaceTextureId() : primary_id(0), secondary_id(0) {} | 30 GpuMemoryBufferId(int32 primary_id, base::ProcessId secondary_id) |
| 30 SurfaceTextureId(int32 primary_id, int32 secondary_id) | |
| 31 : primary_id(primary_id), secondary_id(secondary_id) {} | 31 : primary_id(primary_id), secondary_id(secondary_id) {} |
| 32 int32 primary_id; | 32 int32 primary_id; |
| 33 int32 secondary_id; | 33 base::ProcessId secondary_id; |
|
alexst (slow to review)
2014/05/30 22:41:47
I'm thinking we can utilize this generically and w
reveman
2014/05/31 00:34:02
Let's keep this a client id. The client id is cont
| |
| 34 }; | 34 }; |
| 35 #endif | |
| 36 | 35 |
| 37 struct GpuMemoryBufferHandle { | 36 struct GpuMemoryBufferHandle { |
| 38 GpuMemoryBufferHandle() | 37 GpuMemoryBufferHandle() |
| 39 : type(EMPTY_BUFFER), | 38 : type(EMPTY_BUFFER), |
| 40 handle(base::SharedMemory::NULLHandle()) | 39 handle(base::SharedMemory::NULLHandle()), |
| 40 window(kNullPluginWindow) | |
| 41 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
| 42 , | 42 , |
| 43 io_surface_id(0u) | 43 io_surface_id(0u) |
| 44 #endif | 44 #endif |
| 45 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
| 46 , | 46 , |
| 47 native_buffer(NULL) | 47 native_buffer(NULL) |
| 48 #endif | 48 #endif |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 bool is_null() const { return type == EMPTY_BUFFER; } | 51 bool is_null() const { return type == EMPTY_BUFFER; } |
| 52 GpuMemoryBufferType type; | 52 GpuMemoryBufferType type; |
| 53 base::SharedMemoryHandle handle; | 53 base::SharedMemoryHandle handle; |
| 54 gfx::PluginWindowHandle window; | |
| 54 #if defined(OS_MACOSX) | 55 #if defined(OS_MACOSX) |
| 55 uint32 io_surface_id; | 56 uint32 io_surface_id; |
| 56 #endif | 57 #endif |
| 57 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
| 58 EGLClientBuffer native_buffer; | 59 EGLClientBuffer native_buffer; |
| 59 SurfaceTextureId surface_texture_id; | |
| 60 #endif | 60 #endif |
| 61 GpuMemoryBufferId gpu_memory_id; | |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 // This interface typically correspond to a type of shared memory that is also | 64 // 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 | 65 // 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. | 66 // regular CPU code, but can also be read by the GPU. |
| 66 class GFX_EXPORT GpuMemoryBuffer { | 67 class GFX_EXPORT GpuMemoryBuffer { |
| 67 public: | 68 public: |
| 68 GpuMemoryBuffer(); | 69 GpuMemoryBuffer(); |
| 69 virtual ~GpuMemoryBuffer(); | 70 virtual ~GpuMemoryBuffer(); |
| 70 | 71 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 84 // Returns the stride in bytes for the buffer. | 85 // Returns the stride in bytes for the buffer. |
| 85 virtual uint32 GetStride() const = 0; | 86 virtual uint32 GetStride() const = 0; |
| 86 | 87 |
| 87 // Returns a platform specific handle for this buffer. | 88 // Returns a platform specific handle for this buffer. |
| 88 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 89 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 } // namespace gfx | 92 } // namespace gfx |
| 92 | 93 |
| 93 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 94 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |