Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: gpu/command_buffer/common/buffer.h

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/client/transfer_buffer.cc ('k') | gpu/command_buffer/common/buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GPU_COMMAND_BUFFER_COMMON_BUFFER_H_ 5 #ifndef GPU_COMMAND_BUFFER_COMMON_BUFFER_H_
6 #define GPU_COMMAND_BUFFER_COMMON_BUFFER_H_ 6 #define GPU_COMMAND_BUFFER_COMMON_BUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/shared_memory.h" 15 #include "base/memory/shared_memory.h"
16 #include "base/trace_event/memory_allocator_dump.h" 16 #include "base/trace_event/memory_allocator_dump.h"
17 #include "gpu/gpu_export.h" 17 #include "gpu/gpu_export.h"
18 18
19 namespace base { 19 namespace base {
20 class SharedMemory; 20 class SharedMemory;
21 } 21 }
22 22
23 namespace gpu { 23 namespace gpu {
24 24
25 class GPU_EXPORT BufferBacking { 25 class GPU_EXPORT BufferBacking {
26 public: 26 public:
27 virtual ~BufferBacking() {} 27 virtual ~BufferBacking() {}
28 virtual bool is_shared() const; 28 virtual base::SharedMemory* shared_memory();
29 virtual void* GetMemory() const = 0; 29 virtual void* GetMemory() const = 0;
30 virtual size_t GetSize() const = 0; 30 virtual size_t GetSize() const = 0;
31 }; 31 };
32 32
33 class GPU_EXPORT SharedMemoryBufferBacking : public BufferBacking { 33 class GPU_EXPORT SharedMemoryBufferBacking : public BufferBacking {
34 public: 34 public:
35 SharedMemoryBufferBacking(std::unique_ptr<base::SharedMemory> shared_memory, 35 SharedMemoryBufferBacking(std::unique_ptr<base::SharedMemory> shared_memory,
36 size_t size); 36 size_t size);
37 ~SharedMemoryBufferBacking() override; 37 ~SharedMemoryBufferBacking() override;
38 bool is_shared() const override; 38 base::SharedMemory* shared_memory() override;
39 void* GetMemory() const override; 39 void* GetMemory() const override;
40 size_t GetSize() const override; 40 size_t GetSize() const override;
41 base::SharedMemory* shared_memory() { return shared_memory_.get(); }
42 41
43 private: 42 private:
44 std::unique_ptr<base::SharedMemory> shared_memory_; 43 std::unique_ptr<base::SharedMemory> shared_memory_;
45 size_t size_; 44 size_t size_;
46 DISALLOW_COPY_AND_ASSIGN(SharedMemoryBufferBacking); 45 DISALLOW_COPY_AND_ASSIGN(SharedMemoryBufferBacking);
47 }; 46 };
48 47
49 // Buffer owns a piece of shared-memory of a certain size. 48 // Buffer owns a piece of shared-memory of a certain size.
50 class GPU_EXPORT Buffer : public base::RefCountedThreadSafe<Buffer> { 49 class GPU_EXPORT Buffer : public base::RefCountedThreadSafe<Buffer> {
51 public: 50 public:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 89 }
91 90
92 // Generates GUID which can be used to trace buffer using an Id. 91 // Generates GUID which can be used to trace buffer using an Id.
93 GPU_EXPORT base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing( 92 GPU_EXPORT base::trace_event::MemoryAllocatorDumpGuid GetBufferGUIDForTracing(
94 uint64_t tracing_process_id, 93 uint64_t tracing_process_id,
95 int32_t buffer_id); 94 int32_t buffer_id);
96 95
97 } // namespace gpu 96 } // namespace gpu
98 97
99 #endif // GPU_COMMAND_BUFFER_COMMON_BUFFER_H_ 98 #endif // GPU_COMMAND_BUFFER_COMMON_BUFFER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/transfer_buffer.cc ('k') | gpu/command_buffer/common/buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698