OLD | NEW |
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 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 // This will create a client with no surface | 81 // This will create a client with no surface |
82 FakeClient(GpuMemoryManager* memmgr, GpuMemoryManagerClient* share_group) | 82 FakeClient(GpuMemoryManager* memmgr, GpuMemoryManagerClient* share_group) |
83 : memmgr_(memmgr) | 83 : memmgr_(memmgr) |
84 , total_gpu_memory_(0) | 84 , total_gpu_memory_(0) |
85 , share_group_(share_group) | 85 , share_group_(share_group) |
86 , memory_tracker_(NULL) | 86 , memory_tracker_(NULL) |
87 , tracking_group_(NULL) { | 87 , tracking_group_(NULL) { |
88 if (!share_group_) { | 88 if (!share_group_) { |
89 memory_tracker_ = new FakeMemoryTracker(); | 89 memory_tracker_ = new FakeMemoryTracker(); |
90 tracking_group_.reset( | 90 tracking_group_.reset( |
91 memmgr_->CreateTrackingGroup(0, memory_tracker_)); | 91 memmgr_->CreateTrackingGroup(0, memory_tracker_.get())); |
92 } | 92 } |
93 client_state_.reset(memmgr_->CreateClientState(this, false, true)); | 93 client_state_.reset(memmgr_->CreateClientState(this, false, true)); |
94 } | 94 } |
95 | 95 |
96 // This will create a client with a surface | 96 // This will create a client with a surface |
97 FakeClient(GpuMemoryManager* memmgr, | 97 FakeClient(GpuMemoryManager* memmgr, |
98 int32 surface_id, | 98 int32 surface_id, |
99 bool visible) | 99 bool visible) |
100 : memmgr_(memmgr) | 100 : memmgr_(memmgr) |
101 , total_gpu_memory_(0) | 101 , total_gpu_memory_(0) |
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_.get())); |
108 client_state_.reset(memmgr_->CreateClientState( | 108 client_state_.reset( |
109 this, surface_id != 0, visible)); | 109 memmgr_->CreateClientState(this, surface_id != 0, visible)); |
110 } | 110 } |
111 | 111 |
112 virtual ~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 virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) OVERRIDE { | 118 virtual void SetMemoryAllocation(const GpuMemoryAllocation& alloc) OVERRIDE { |
119 allocation_ = alloc; | 119 allocation_ = alloc; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 866 |
867 // Expect that a client which has not sent stats receive at | 867 // Expect that a client which has not sent stats receive at |
868 // least the default allocation. | 868 // least the default allocation. |
869 Manage(); | 869 Manage(); |
870 EXPECT_GE(stub1.BytesWhenVisible(), | 870 EXPECT_GE(stub1.BytesWhenVisible(), |
871 memmgr_.GetDefaultClientAllocation()); | 871 memmgr_.GetDefaultClientAllocation()); |
872 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); | 872 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); |
873 } | 873 } |
874 | 874 |
875 } // namespace content | 875 } // namespace content |
OLD | NEW |