Home | History | Annotate | Download | only in service
      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                                       scoped_ptr<BufferBacking> buffer) = 0;
     25   virtual void DestroyTransferBuffer(int32 id) = 0;
     26   virtual scoped_refptr<Buffer> GetTransferBuffer(int32 id) = 0;
     27 };
     28 
     29 class GPU_EXPORT TransferBufferManager
     30     : public TransferBufferManagerInterface {
     31  public:
     32   TransferBufferManager();
     33 
     34   bool Initialize();
     35   virtual bool RegisterTransferBuffer(int32 id,
     36                                       scoped_ptr<BufferBacking> buffer_backing)
     37       OVERRIDE;
     38   virtual void DestroyTransferBuffer(int32 id) OVERRIDE;
     39   virtual scoped_refptr<Buffer> GetTransferBuffer(int32 id) OVERRIDE;
     40 
     41  private:
     42   virtual ~TransferBufferManager();
     43 
     44   typedef base::hash_map<int32, scoped_refptr<Buffer> > BufferMap;
     45   BufferMap registered_buffers_;
     46   size_t shared_memory_bytes_allocated_;
     47 
     48   DISALLOW_COPY_AND_ASSIGN(TransferBufferManager);
     49 };
     50 
     51 }  // namespace gpu
     52 
     53 #endif  // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
     54