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

Side by Side Diff: content/common/gpu/gpu_memory_manager_unittest.cc

Issue 12210030: Linux/ChromeOS Chromium style checker cleanup, content/ edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "content/common/gpu/gpu_memory_allocation.h" 5 #include "content/common/gpu/gpu_memory_allocation.h"
6 #include "content/common/gpu/gpu_memory_manager.h" 6 #include "content/common/gpu/gpu_memory_manager.h"
7 #include "content/common/gpu/gpu_memory_manager_client.h" 7 #include "content/common/gpu/gpu_memory_manager_client.h"
8 #include "content/common/gpu/gpu_memory_tracking.h" 8 #include "content/common/gpu/gpu_memory_tracking.h"
9 #include "ui/gfx/size_conversions.h" 9 #include "ui/gfx/size_conversions.h"
10 10
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 #if defined(COMPILER_GCC) 13 #if defined(COMPILER_GCC)
14 namespace BASE_HASH_NAMESPACE { 14 namespace BASE_HASH_NAMESPACE {
15 template<> 15 template<>
16 struct hash<content::GpuMemoryManagerClient*> { 16 struct hash<content::GpuMemoryManagerClient*> {
17 uint64 operator()(content::GpuMemoryManagerClient* ptr) const { 17 uint64 operator()(content::GpuMemoryManagerClient* ptr) const {
18 return hash<uint64>()(reinterpret_cast<uint64>(ptr)); 18 return hash<uint64>()(reinterpret_cast<uint64>(ptr));
19 } 19 }
20 }; 20 };
21 } // namespace BASE_HASH_NAMESPACE 21 } // namespace BASE_HASH_NAMESPACE
22 #endif // COMPILER 22 #endif // COMPILER
23 23
24 class FakeMemoryTracker : public gpu::gles2::MemoryTracker { 24 class FakeMemoryTracker : public gpu::gles2::MemoryTracker {
25 public: 25 public:
26 virtual void TrackMemoryAllocatedChange( 26 virtual void TrackMemoryAllocatedChange(
27 size_t /* old_size */, 27 size_t /* old_size */,
28 size_t /* new_size */, 28 size_t /* new_size */,
29 gpu::gles2::MemoryTracker::Pool /* pool */) { 29 gpu::gles2::MemoryTracker::Pool /* pool */) OVERRIDE {
30 } 30 }
31 virtual bool EnsureGPUMemoryAvailable(size_t /* size_needed */) { 31 virtual bool EnsureGPUMemoryAvailable(size_t /* size_needed */) OVERRIDE {
32 return true; 32 return true;
33 } 33 }
34 private: 34 private:
35 ~FakeMemoryTracker() { 35 virtual ~FakeMemoryTracker() {
36 } 36 }
37 }; 37 };
38 38
39 namespace content { 39 namespace content {
40 40
41 // This class is used to collect all stub assignments during a 41 // This class is used to collect all stub assignments during a
42 // Manage() call. 42 // Manage() call.
43 class ClientAssignmentCollector { 43 class ClientAssignmentCollector {
44 public: 44 public:
45 struct ClientMemoryStat { 45 struct ClientMemoryStat {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 , share_group_(NULL) 102 , share_group_(NULL)
103 , memory_tracker_(NULL) 103 , memory_tracker_(NULL)
104 , tracking_group_(NULL) { 104 , tracking_group_(NULL) {
105 memory_tracker_ = new FakeMemoryTracker(); 105 memory_tracker_ = new FakeMemoryTracker();
106 tracking_group_.reset( 106 tracking_group_.reset(
107 memmgr_->CreateTrackingGroup(0, memory_tracker_)); 107 memmgr_->CreateTrackingGroup(0, memory_tracker_));
108 client_state_.reset(memmgr_->CreateClientState( 108 client_state_.reset(memmgr_->CreateClientState(
109 this, surface_id != 0, visible)); 109 this, surface_id != 0, visible));
110 } 110 }
111 111
112 ~FakeClient() { 112 virtual ~FakeClient() {
113 client_state_.reset(); 113 client_state_.reset();
114 tracking_group_.reset(); 114 tracking_group_.reset();
115 memory_tracker_ = NULL; 115 memory_tracker_ = NULL;
116 } 116 }
117 117
118 void SetMemoryAllocation(const GpuMemoryAllocation& alloc) { 118 virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) OVERRIDE {
119 allocation_ = alloc; 119 allocation_ = alloc;
120 ClientAssignmentCollector::AddClientStat(this, alloc); 120 ClientAssignmentCollector::AddClientStat(this, alloc);
121 } 121 }
122 122
123 bool GetTotalGpuMemory(uint64* bytes) { 123 virtual bool GetTotalGpuMemory(uint64* bytes) OVERRIDE {
124 if (total_gpu_memory_) { 124 if (total_gpu_memory_) {
125 *bytes = total_gpu_memory_; 125 *bytes = total_gpu_memory_;
126 return true; 126 return true;
127 } 127 }
128 return false; 128 return false;
129 } 129 }
130 void SetTotalGpuMemory(uint64 bytes) { total_gpu_memory_ = bytes; } 130 void SetTotalGpuMemory(uint64 bytes) { total_gpu_memory_ = bytes; }
131 131
132 gpu::gles2::MemoryTracker* GetMemoryTracker() const OVERRIDE { 132 virtual gpu::gles2::MemoryTracker* GetMemoryTracker() const OVERRIDE {
133 if (share_group_) 133 if (share_group_)
134 return share_group_->GetMemoryTracker(); 134 return share_group_->GetMemoryTracker();
135 return memory_tracker_.get(); 135 return memory_tracker_.get();
136 } 136 }
137 137
138 gfx::Size GetSurfaceSize() const { 138 virtual gfx::Size GetSurfaceSize() const OVERRIDE {
139 return surface_size_; 139 return surface_size_;
140 } 140 }
141 void SetSurfaceSize(gfx::Size size) { surface_size_ = size; } 141 void SetSurfaceSize(gfx::Size size) { surface_size_ = size; }
142 142
143 void SetVisible(bool visible) { 143 void SetVisible(bool visible) {
144 client_state_->SetVisible(visible); 144 client_state_->SetVisible(visible);
145 } 145 }
146 146
147 void SetManagedMemoryStats(const GpuManagedMemoryStats& stats) { 147 void SetManagedMemoryStats(const GpuManagedMemoryStats& stats) {
148 client_state_->SetManagedMemoryStats(stats); 148 client_state_->SetManagedMemoryStats(stats);
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 1043
1044 // Expect that a client which has not sent stats receive the 1044 // Expect that a client which has not sent stats receive the
1045 // default allocation. 1045 // default allocation.
1046 Manage(); 1046 Manage();
1047 EXPECT_EQ(stub1.BytesWhenVisible(), 1047 EXPECT_EQ(stub1.BytesWhenVisible(),
1048 memmgr_.GetDefaultClientAllocation()); 1048 memmgr_.GetDefaultClientAllocation());
1049 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); 1049 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u);
1050 } 1050 }
1051 1051
1052 } // namespace content 1052 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.cc ('k') | content/common/gpu/media/video_decode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698