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/generic_shared_memory_id.h" | |
8 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
9 #include "base/trace_event/memory_dump_manager.h" | 10 #include "base/trace_event/memory_dump_manager.h" |
10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
11 #include "ui/gfx/buffer_types.h" | 12 #include "ui/gfx/buffer_types.h" |
12 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
13 | 14 |
14 extern "C" typedef struct _ClientBuffer* ClientBuffer; | 15 extern "C" typedef struct _ClientBuffer* ClientBuffer; |
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 SURFACE_TEXTURE_BUFFER, | 23 SURFACE_TEXTURE_BUFFER, |
23 OZONE_NATIVE_PIXMAP, | 24 OZONE_NATIVE_PIXMAP, |
24 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP | 25 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP |
25 }; | 26 }; |
26 | 27 |
27 using GpuMemoryBufferId = int32; | 28 using GpuMemoryBufferId = base::GenericSharedMemoryId; |
28 | 29 |
29 struct GFX_EXPORT GpuMemoryBufferHandle { | 30 struct GFX_EXPORT GpuMemoryBufferHandle { |
30 GpuMemoryBufferHandle(); | 31 GpuMemoryBufferHandle(); |
31 bool is_null() const { return type == EMPTY_BUFFER; } | 32 bool is_null() const { return type == EMPTY_BUFFER; } |
32 GpuMemoryBufferType type; | 33 GpuMemoryBufferType type; |
33 GpuMemoryBufferId id; | 34 GpuMemoryBufferId id; |
34 base::SharedMemoryHandle handle; | 35 base::SharedMemoryHandle handle; |
35 }; | 36 }; |
36 | 37 |
37 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT | |
38 GetGpuMemoryBufferGUIDForTracing(uint64 tracing_process_id, | |
39 GpuMemoryBufferId buffer_id); | |
reveman
2015/08/10 18:57:32
Maybe keep this for single process mode where gpu
ericrk
2015/08/10 21:12:14
Seems like using GenericSharedMemoryId for these i
reveman
2015/08/10 22:16:13
Yes, maybe just keeping the function as a wrapper
ericrk
2015/08/11 01:40:07
sounds good.
| |
40 | |
41 // This interface typically correspond to a type of shared memory that is also | 38 // This interface typically correspond to a type of shared memory that is also |
42 // shared with the GPU. A GPU memory buffer can be written to directly by | 39 // shared with the GPU. A GPU memory buffer can be written to directly by |
43 // regular CPU code, but can also be read by the GPU. | 40 // regular CPU code, but can also be read by the GPU. |
44 class GFX_EXPORT GpuMemoryBuffer { | 41 class GFX_EXPORT GpuMemoryBuffer { |
45 public: | 42 public: |
46 virtual ~GpuMemoryBuffer() {} | 43 virtual ~GpuMemoryBuffer() {} |
47 | 44 |
48 // Maps each plane of the buffer into the client's address space so it can be | 45 // Maps each plane of the buffer into the client's address space so it can be |
49 // written to by the CPU. A pointer to plane K is stored at index K-1 of the | 46 // written to by the CPU. A pointer to plane K is stored at index K-1 of the |
50 // |data| array. This call may block, for instance if the GPU needs to finish | 47 // |data| array. This call may block, for instance if the GPU needs to finish |
(...skipping 21 matching lines...) Expand all Loading... | |
72 // Returns a platform specific handle for this buffer. | 69 // Returns a platform specific handle for this buffer. |
73 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 70 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
74 | 71 |
75 // Type-checking downcast routine. | 72 // Type-checking downcast routine. |
76 virtual ClientBuffer AsClientBuffer() = 0; | 73 virtual ClientBuffer AsClientBuffer() = 0; |
77 }; | 74 }; |
78 | 75 |
79 } // namespace gfx | 76 } // namespace gfx |
80 | 77 |
81 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 78 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
OLD | NEW |