| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/memory/shared_memory.h" | 11 #include "base/memory/shared_memory.h" |
| 12 #include "base/trace_event/memory_dump_manager.h" | 12 #include "base/trace_event/memory_dump_manager.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "ui/gfx/buffer_types.h" | 14 #include "ui/gfx/buffer_types.h" |
| 15 #include "ui/gfx/generic_shared_memory_id.h" | 15 #include "ui/gfx/generic_shared_memory_id.h" |
| 16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/gfx_export.h" | 17 #include "ui/gfx/gfx_export.h" |
| 18 | 18 |
| 19 #if defined(USE_OZONE) | 19 #if defined(USE_OZONE) |
| 20 #include "ui/gfx/native_pixmap_handle_ozone.h" | 20 #include "ui/gfx/native_pixmap_handle_ozone.h" |
| 21 #elif defined(OS_MACOSX) |
| 22 #include "ui/gfx/mac/io_surface.h" |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 extern "C" typedef struct _ClientBuffer* ClientBuffer; | 25 extern "C" typedef struct _ClientBuffer* ClientBuffer; |
| 24 | 26 |
| 25 namespace gfx { | 27 namespace gfx { |
| 26 | 28 |
| 27 enum GpuMemoryBufferType { | 29 enum GpuMemoryBufferType { |
| 28 EMPTY_BUFFER, | 30 EMPTY_BUFFER, |
| 29 SHARED_MEMORY_BUFFER, | 31 SHARED_MEMORY_BUFFER, |
| 30 IO_SURFACE_BUFFER, | 32 IO_SURFACE_BUFFER, |
| 31 SURFACE_TEXTURE_BUFFER, | 33 SURFACE_TEXTURE_BUFFER, |
| 32 OZONE_NATIVE_PIXMAP, | 34 OZONE_NATIVE_PIXMAP, |
| 33 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP | 35 GPU_MEMORY_BUFFER_TYPE_LAST = OZONE_NATIVE_PIXMAP |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 using GpuMemoryBufferId = GenericSharedMemoryId; | 38 using GpuMemoryBufferId = GenericSharedMemoryId; |
| 37 | 39 |
| 38 struct GFX_EXPORT GpuMemoryBufferHandle { | 40 struct GFX_EXPORT GpuMemoryBufferHandle { |
| 39 GpuMemoryBufferHandle(); | 41 GpuMemoryBufferHandle(); |
| 42 ~GpuMemoryBufferHandle(); |
| 40 bool is_null() const { return type == EMPTY_BUFFER; } | 43 bool is_null() const { return type == EMPTY_BUFFER; } |
| 41 GpuMemoryBufferType type; | 44 GpuMemoryBufferType type; |
| 42 GpuMemoryBufferId id; | 45 GpuMemoryBufferId id; |
| 43 base::SharedMemoryHandle handle; | 46 base::SharedMemoryHandle handle; |
| 44 uint32_t offset; | 47 uint32_t offset; |
| 45 int32_t stride; | 48 int32_t stride; |
| 46 #if defined(USE_OZONE) | 49 #if defined(USE_OZONE) |
| 47 NativePixmapHandle native_pixmap_handle; | 50 NativePixmapHandle native_pixmap_handle; |
| 51 #elif defined(OS_MACOSX) |
| 52 ScopedRefCountedIOSurfaceMachPort mach_port; |
| 48 #endif | 53 #endif |
| 49 }; | 54 }; |
| 50 | 55 |
| 51 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT | 56 base::trace_event::MemoryAllocatorDumpGuid GFX_EXPORT |
| 52 GetGpuMemoryBufferGUIDForTracing(uint64_t tracing_process_id, | 57 GetGpuMemoryBufferGUIDForTracing(uint64_t tracing_process_id, |
| 53 GpuMemoryBufferId buffer_id); | 58 GpuMemoryBufferId buffer_id); |
| 54 | 59 |
| 55 // This interface typically correspond to a type of shared memory that is also | 60 // This interface typically correspond to a type of shared memory that is also |
| 56 // shared with the GPU. A GPU memory buffer can be written to directly by | 61 // shared with the GPU. A GPU memory buffer can be written to directly by |
| 57 // regular CPU code, but can also be read by the GPU. | 62 // regular CPU code, but can also be read by the GPU. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Returns a platform specific handle for this buffer. | 94 // Returns a platform specific handle for this buffer. |
| 90 virtual GpuMemoryBufferHandle GetHandle() const = 0; | 95 virtual GpuMemoryBufferHandle GetHandle() const = 0; |
| 91 | 96 |
| 92 // Type-checking downcast routine. | 97 // Type-checking downcast routine. |
| 93 virtual ClientBuffer AsClientBuffer() = 0; | 98 virtual ClientBuffer AsClientBuffer() = 0; |
| 94 }; | 99 }; |
| 95 | 100 |
| 96 } // namespace gfx | 101 } // namespace gfx |
| 97 | 102 |
| 98 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ | 103 #endif // UI_GFX_GPU_MEMORY_BUFFER_H_ |
| OLD | NEW |