Infobar material design refresh: bg color
[chromium-blink-merge.git] / gpu / command_buffer / service / transfer_buffer_manager.h
blobb89be1590c2ad11a4c688b7792e4abe2ac30d5e7
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_
8 #include <set>
9 #include <vector>
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"
19 namespace gpu {
20 namespace gles2 {
21 class MemoryTracker;
24 class GPU_EXPORT TransferBufferManagerInterface :
25 public base::RefCounted<TransferBufferManagerInterface> {
26 public:
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;
32 protected:
33 friend class base::RefCounted<TransferBufferManagerInterface>;
35 virtual ~TransferBufferManagerInterface();
38 class GPU_EXPORT TransferBufferManager
39 : public TransferBufferManagerInterface,
40 public base::trace_event::MemoryDumpProvider {
41 public:
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;
48 bool Initialize();
49 bool RegisterTransferBuffer(
50 int32 id,
51 scoped_ptr<BufferBacking> buffer_backing) override;
52 void DestroyTransferBuffer(int32 id) override;
53 scoped_refptr<Buffer> GetTransferBuffer(int32 id) override;
55 private:
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);
66 } // namespace gpu
68 #endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_