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.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/containers/hash_tables.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/shared_memory.h"
16 #include "base/trace_event/memory_dump_provider.h"
17 #include "gpu/command_buffer/common/command_buffer_shared.h"
24 class GPU_EXPORT TransferBufferManagerInterface
:
25 public base::RefCounted
<TransferBufferManagerInterface
> {
27 virtual bool RegisterTransferBuffer(int32 id
,
28 scoped_ptr
<BufferBacking
> buffer
) = 0;
29 virtual void DestroyTransferBuffer(int32 id
) = 0;
30 virtual scoped_refptr
<Buffer
> GetTransferBuffer(int32 id
) = 0;
33 friend class base::RefCounted
<TransferBufferManagerInterface
>;
35 virtual ~TransferBufferManagerInterface();
38 class GPU_EXPORT TransferBufferManager
39 : public TransferBufferManagerInterface
,
40 public base::trace_event::MemoryDumpProvider
{
42 explicit TransferBufferManager(gles2::MemoryTracker
* memory_tracker
);
44 // Overridden from base::trace_event::MemoryDumpProvider:
45 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs
& args
,
46 base::trace_event::ProcessMemoryDump
* pmd
) override
;
49 bool RegisterTransferBuffer(
51 scoped_ptr
<BufferBacking
> buffer_backing
) override
;
52 void DestroyTransferBuffer(int32 id
) override
;
53 scoped_refptr
<Buffer
> GetTransferBuffer(int32 id
) override
;
56 ~TransferBufferManager() override
;
58 typedef base::hash_map
<int32
, scoped_refptr
<Buffer
> > BufferMap
;
59 BufferMap registered_buffers_
;
60 size_t shared_memory_bytes_allocated_
;
61 gles2::MemoryTracker
* memory_tracker_
;
63 DISALLOW_COPY_AND_ASSIGN(TransferBufferManager
);
68 #endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_