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(USE_X11) | 12 #if defined(USE_X11) |
13 #include "ui/gfx/x/x11_types.h" | 13 #include "ui/gfx/x/x11_types.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 X11_PIXMAP_BUFFER, | 24 X11_PIXMAP_BUFFER, |
25 OZONE_NATIVE_BUFFER, | 25 OZONE_NATIVE_BUFFER, |
26 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_BUFFER | 26 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_BUFFER |
27 }; | 27 }; |
28 | 28 |
29 // TODO(alexst): Merge this with GpuMemoryBufferId as part of switchover to | |
30 // the new API for GpuMemoryBuffer allocation when it's done. | |
31 #if defined(OS_ANDROID) | |
32 struct SurfaceTextureId { | |
33 SurfaceTextureId() : primary_id(0), secondary_id(0) {} | |
34 SurfaceTextureId(int32 primary_id, int32 secondary_id) | |
35 : primary_id(primary_id), secondary_id(secondary_id) {} | |
36 int32 primary_id; | |
37 int32 secondary_id; | |
38 }; | |
39 #endif | |
40 | |
41 struct GpuMemoryBufferId { | 29 struct GpuMemoryBufferId { |
42 GpuMemoryBufferId() : primary_id(0), secondary_id(0) {} | 30 GpuMemoryBufferId() : primary_id(0), secondary_id(0) {} |
43 GpuMemoryBufferId(int32 primary_id, int32 secondary_id) | 31 GpuMemoryBufferId(int32 primary_id, int32 secondary_id) |
44 : primary_id(primary_id), secondary_id(secondary_id) {} | 32 : primary_id(primary_id), secondary_id(secondary_id) {} |
45 int32 primary_id; | 33 int32 primary_id; |
46 int32 secondary_id; | 34 int32 secondary_id; |
47 }; | 35 }; |
48 | 36 |
49 struct GFX_EXPORT GpuMemoryBufferHandle { | 37 struct GFX_EXPORT GpuMemoryBufferHandle { |
50 GpuMemoryBufferHandle(); | 38 GpuMemoryBufferHandle(); |
51 bool is_null() const { return type == EMPTY_BUFFER; } | 39 bool is_null() const { return type == EMPTY_BUFFER; } |
52 GpuMemoryBufferType type; | 40 GpuMemoryBufferType type; |
53 base::SharedMemoryHandle handle; | 41 base::SharedMemoryHandle handle; |
54 GpuMemoryBufferId global_id; | 42 GpuMemoryBufferId global_id; |
55 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
56 uint32 io_surface_id; | 44 uint32 io_surface_id; |
57 #endif | 45 #endif |
58 #if defined(OS_ANDROID) | |
59 long buffer_id; | |
60 SurfaceTextureId surface_texture_id; | |
61 #endif | |
62 #if defined(USE_X11) | 46 #if defined(USE_X11) |
63 XID pixmap; | 47 XID pixmap; |
64 #endif | 48 #endif |
65 }; | 49 }; |
66 | 50 |
67 // This interface typically correspond to a type of shared memory that is also | 51 // This interface typically correspond to a type of shared memory that is also |
68 // shared with the GPU. A GPU memory buffer can be written to directly by | 52 // shared with the GPU. A GPU memory buffer can be written to directly by |
69 // regular CPU code, but can also be read by the GPU. | 53 // regular CPU code, but can also be read by the GPU. |
70 class GFX_EXPORT GpuMemoryBuffer { | 54 class GFX_EXPORT GpuMemoryBuffer { |
71 public: | 55 public: |
(...skipping 16 matching lines...) Expand all Loading... |
88 // Returns the stride in bytes for the buffer. | 72 // Returns the stride in bytes for the buffer. |
89 virtual uint32 GetStride() const = 0; | 73 virtual uint32 GetStride() const = 0; |
90 | 74 |
91 // Returns a platform specific handle for this buffer. | 75 // Returns a platform specific handle for this buffer. |
92 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 76 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
93 }; | 77 }; |
94 | 78 |
95 } // namespace gfx | 79 } // namespace gfx |
96 | 80 |
97 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 81 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |