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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 GpuMemoryAllocation allocation_; | 73 GpuMemoryAllocation allocation_; |
74 uint64 total_gpu_memory_; | 74 uint64 total_gpu_memory_; |
75 gfx::Size surface_size_; | 75 gfx::Size surface_size_; |
76 GpuMemoryManagerClient* share_group_; | 76 GpuMemoryManagerClient* share_group_; |
77 scoped_refptr<gpu::gles2::MemoryTracker> memory_tracker_; | 77 scoped_refptr<gpu::gles2::MemoryTracker> memory_tracker_; |
78 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_; | 78 scoped_ptr<GpuMemoryTrackingGroup> tracking_group_; |
79 scoped_ptr<GpuMemoryManagerClientState> client_state_; | 79 scoped_ptr<GpuMemoryManagerClientState> client_state_; |
80 | 80 |
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) { | |
88 if (!share_group_) { | 87 if (!share_group_) { |
89 memory_tracker_ = new FakeMemoryTracker(); | 88 memory_tracker_ = new FakeMemoryTracker(); |
90 tracking_group_.reset( | 89 tracking_group_.reset( |
91 memmgr_->CreateTrackingGroup(0, memory_tracker_.get())); | 90 memmgr_->CreateTrackingGroup(0, memory_tracker_.get())); |
92 } | 91 } |
93 client_state_.reset(memmgr_->CreateClientState(this, false, true)); | 92 client_state_.reset(memmgr_->CreateClientState(this, false, true)); |
94 } | 93 } |
95 | 94 |
96 // This will create a client with a surface | 95 // This will create a client with a surface |
97 FakeClient(GpuMemoryManager* memmgr, | 96 FakeClient(GpuMemoryManager* memmgr, int32 surface_id, bool visible) |
98 int32 surface_id, | 97 : memmgr_(memmgr), |
99 bool visible) | 98 total_gpu_memory_(0), |
100 : memmgr_(memmgr) | 99 share_group_(NULL), |
101 , total_gpu_memory_(0) | 100 memory_tracker_(NULL) { |
102 , share_group_(NULL) | |
103 , memory_tracker_(NULL) | |
104 , tracking_group_(NULL) { | |
105 memory_tracker_ = new FakeMemoryTracker(); | 101 memory_tracker_ = new FakeMemoryTracker(); |
106 tracking_group_.reset( | 102 tracking_group_.reset( |
107 memmgr_->CreateTrackingGroup(0, memory_tracker_.get())); | 103 memmgr_->CreateTrackingGroup(0, memory_tracker_.get())); |
108 client_state_.reset( | 104 client_state_.reset( |
109 memmgr_->CreateClientState(this, surface_id != 0, visible)); | 105 memmgr_->CreateClientState(this, surface_id != 0, visible)); |
110 } | 106 } |
111 | 107 |
112 virtual ~FakeClient() { | 108 virtual ~FakeClient() { |
113 client_state_.reset(); | 109 client_state_.reset(); |
114 tracking_group_.reset(); | 110 tracking_group_.reset(); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 862 |
867 // Expect that a client which has not sent stats receive at | 863 // Expect that a client which has not sent stats receive at |
868 // least the default allocation. | 864 // least the default allocation. |
869 Manage(); | 865 Manage(); |
870 EXPECT_GE(stub1.BytesWhenVisible(), | 866 EXPECT_GE(stub1.BytesWhenVisible(), |
871 memmgr_.GetDefaultClientAllocation()); | 867 memmgr_.GetDefaultClientAllocation()); |
872 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); | 868 EXPECT_EQ(stub1.BytesWhenNotVisible(), 0u); |
873 } | 869 } |
874 | 870 |
875 } // namespace content | 871 } // namespace content |
OLD | NEW |