1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
gpu / command_buffer / service / transfer_buffer_manager.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
#define GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_
#include <stddef.h>
#include <stdint.h>
#include "base/compiler_specific.h"
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/trace_event/memory_dump_provider.h"
#include "gpu/command_buffer/common/command_buffer.h"
namespace gpu {
class MemoryTracker;
class GPU_EXPORT TransferBufferManager
: public base::trace_event::MemoryDumpProvider {
public:
explicit TransferBufferManager(MemoryTracker* memory_tracker);
TransferBufferManager(const TransferBufferManager&) = delete;
TransferBufferManager& operator=(const TransferBufferManager&) = delete;
~TransferBufferManager() override;
// Overridden from base::trace_event::MemoryDumpProvider:
bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) override;
bool RegisterTransferBuffer(int32_t id, scoped_refptr<Buffer> buffer);
void DestroyTransferBuffer(int32_t id);
scoped_refptr<Buffer> GetTransferBuffer(int32_t id);
size_t shared_memory_bytes_allocated() const {
return shared_memory_bytes_allocated_;
}
private:
typedef base::flat_map<int32_t, scoped_refptr<Buffer>> BufferMap;
BufferMap registered_buffers_;
size_t shared_memory_bytes_allocated_;
raw_ptr<MemoryTracker, AcrossTasksDanglingUntriaged> memory_tracker_;
};
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_TRANSFER_BUFFER_MANAGER_H_