1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_ 7 8 #include <memory> 9 10 #include "gpu/gpu_export.h" 11 #include "gpu/ipc/common/surface_handle.h" 12 #include "ui/gfx/geometry/size.h" 13 #include "ui/gfx/gpu_memory_buffer.h" 14 15 namespace gpu { 16 17 struct SyncToken; 18 19 class GPU_EXPORT GpuMemoryBufferManager { 20 public: 21 GpuMemoryBufferManager(); 22 virtual ~GpuMemoryBufferManager(); 23 24 // Creates a GpuMemoryBuffer that can be shared with another process. It can 25 // be called on any thread. 26 virtual std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBuffer( 27 const gfx::Size& size, 28 gfx::BufferFormat format, 29 gfx::BufferUsage usage, 30 gpu::SurfaceHandle surface_handle) = 0; 31 32 // Associates destruction sync point with |buffer|. It can be called on any 33 // thread. 34 virtual void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, 35 const gpu::SyncToken& sync_token) = 0; 36 37 protected: 38 class GPU_EXPORT AllocatedBufferInfo { 39 public: 40 AllocatedBufferInfo(const gfx::GpuMemoryBufferHandle& handle, 41 const gfx::Size& size, 42 gfx::BufferFormat format); 43 ~AllocatedBufferInfo(); 44 type()45 gfx::GpuMemoryBufferType type() const { return type_; } 46 47 // Add a memory dump for this buffer to |pmd|. Returns false if adding the 48 // dump failed. 49 bool OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 50 int client_id, 51 uint64_t client_tracing_process_id) const; 52 53 private: 54 gfx::GpuMemoryBufferId buffer_id_; 55 gfx::GpuMemoryBufferType type_; 56 size_t size_in_bytes_; 57 base::UnguessableToken shared_memory_guid_; 58 }; 59 }; 60 61 } // namespace gpu 62 63 #endif // GPU_COMMAND_BUFFER_CLIENT_GPU_MEMORY_BUFFER_MANAGER_H_ 64