1 // Copyright (c) 2012 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_SERVICE_TRANSFER_BUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_ 7 8 #include <set> 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "base/compiler_specific.h" 13 #include "base/containers/hash_tables.h" 14 #include "base/memory/shared_memory.h" 15 #include "gpu/command_buffer/common/command_buffer_shared.h" 16 17 namespace gpu { 18 19 class GPU_EXPORT TransferBufferManagerInterface { 20 public: 21 virtual ~TransferBufferManagerInterface(); 22 23 virtual bool RegisterTransferBuffer(int32 id, 24 base::SharedMemory* shared_memory, 25 size_t size) = 0; 26 virtual void DestroyTransferBuffer(int32 id) = 0; 27 virtual Buffer GetTransferBuffer(int32 id) = 0; 28 29 }; 30 31 class GPU_EXPORT TransferBufferManager 32 : public TransferBufferManagerInterface { 33 public: 34 TransferBufferManager(); 35 36 bool Initialize(); 37 virtual bool RegisterTransferBuffer(int32 id, 38 base::SharedMemory* shared_memory, 39 size_t size) OVERRIDE; 40 virtual void DestroyTransferBuffer(int32 id) OVERRIDE; 41 virtual Buffer GetTransferBuffer(int32 id) OVERRIDE; 42 43 private: 44 virtual ~TransferBufferManager(); 45 46 typedef base::hash_map<int32, Buffer> BufferMap; 47 BufferMap registered_buffers_; 48 size_t shared_memory_bytes_allocated_; 49 50 DISALLOW_COPY_AND_ASSIGN(TransferBufferManager); 51 }; 52 53 } // namespace gpu 54 55 #endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_ 56