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 }; | 23 }; |
23 | 24 |
24 struct GpuMemoryBufferHandle { | 25 struct GpuMemoryBufferHandle { |
25 GpuMemoryBufferHandle() | 26 GpuMemoryBufferHandle() |
26 : type(EMPTY_BUFFER), | 27 : type(EMPTY_BUFFER), |
27 handle(base::SharedMemory::NULLHandle()) | 28 handle(base::SharedMemory::NULLHandle()) |
28 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
29 , native_buffer(NULL) | 30 , native_buffer(NULL) |
30 #endif | 31 #endif |
| 32 #if defined(OS_MACOSX) |
| 33 , io_surface_id(0) |
| 34 #endif |
31 { | 35 { |
32 } | 36 } |
33 bool is_null() const { return type == EMPTY_BUFFER; } | 37 bool is_null() const { return type == EMPTY_BUFFER; } |
34 GpuMemoryBufferType type; | 38 GpuMemoryBufferType type; |
35 base::SharedMemoryHandle handle; | 39 base::SharedMemoryHandle handle; |
36 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
37 EGLClientBuffer native_buffer; | 41 EGLClientBuffer native_buffer; |
38 #endif | 42 #endif |
| 43 #if defined(OS_MACOSX) |
| 44 uint32 io_surface_id; |
| 45 #endif |
| 46 |
39 }; | 47 }; |
40 | 48 |
41 // Interface for creating and accessing a zero-copy GPU memory buffer. | 49 // Interface for creating and accessing a zero-copy GPU memory buffer. |
42 // This design evolved from the generalization of GraphicBuffer API | 50 // This design evolved from the generalization of GraphicBuffer API |
43 // of Android framework. | 51 // of Android framework. |
44 // | 52 // |
45 // THREADING CONSIDERATIONS: | 53 // THREADING CONSIDERATIONS: |
46 // | 54 // |
47 // This interface is thread-safe. However, multiple threads mapping | 55 // This interface is thread-safe. However, multiple threads mapping |
48 // a buffer for Write or ReadOrWrite simultaneously may result in undefined | 56 // a buffer for Write or ReadOrWrite simultaneously may result in undefined |
(...skipping 24 matching lines...) Expand all Loading... |
73 // Returns the stride in bytes for the buffer. | 81 // Returns the stride in bytes for the buffer. |
74 virtual uint32 GetStride() const = 0; | 82 virtual uint32 GetStride() const = 0; |
75 | 83 |
76 // Returns a platform specific handle for this buffer. | 84 // Returns a platform specific handle for this buffer. |
77 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 85 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
78 }; | 86 }; |
79 | 87 |
80 } // namespace gfx | 88 } // namespace gfx |
81 | 89 |
82 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 90 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |