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_manager.h" | 5 #include "content/common/gpu/gpu_memory_manager.h" |
6 | 6 |
7 #if defined(ENABLE_GPU) | 7 #if defined(ENABLE_GPU) |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "content/common/gpu/gpu_command_buffer_stub.h" | 17 #include "content/common/gpu/gpu_command_buffer_stub.h" |
18 #include "content/common/gpu/gpu_memory_allocation.h" | 18 #include "content/common/gpu/gpu_memory_allocation.h" |
19 #include "content/common/gpu/gpu_memory_tracking.h" | 19 #include "content/common/gpu/gpu_memory_tracking.h" |
20 #include "gpu/command_buffer/service/gpu_switches.h" | 20 #include "gpu/command_buffer/service/gpu_switches.h" |
21 | 21 |
| 22 namespace content { |
22 namespace { | 23 namespace { |
23 | 24 |
24 const int kDelayedScheduleManageTimeoutMs = 67; | 25 const int kDelayedScheduleManageTimeoutMs = 67; |
25 | 26 |
26 bool IsInSameContextShareGroupAsAnyOf( | 27 bool IsInSameContextShareGroupAsAnyOf( |
27 const GpuCommandBufferStubBase* stub, | 28 const GpuCommandBufferStubBase* stub, |
28 const std::vector<GpuCommandBufferStubBase*>& stubs) { | 29 const std::vector<GpuCommandBufferStubBase*>& stubs) { |
29 for (std::vector<GpuCommandBufferStubBase*>::const_iterator it = | 30 for (std::vector<GpuCommandBufferStubBase*>::const_iterator it = |
30 stubs.begin(); it != stubs.end(); ++it) { | 31 stubs.begin(); it != stubs.end(); ++it) { |
31 if (stub->IsInSameContextShareGroup(**it)) | 32 if (stub->IsInSameContextShareGroup(**it)) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 GpuMemoryTrackingGroup* tracking_group) { | 197 GpuMemoryTrackingGroup* tracking_group) { |
197 tracking_groups_.insert(tracking_group); | 198 tracking_groups_.insert(tracking_group); |
198 } | 199 } |
199 | 200 |
200 void GpuMemoryManager::RemoveTrackingGroup( | 201 void GpuMemoryManager::RemoveTrackingGroup( |
201 GpuMemoryTrackingGroup* tracking_group) { | 202 GpuMemoryTrackingGroup* tracking_group) { |
202 tracking_groups_.erase(tracking_group); | 203 tracking_groups_.erase(tracking_group); |
203 } | 204 } |
204 | 205 |
205 void GpuMemoryManager::GetVideoMemoryUsageStats( | 206 void GpuMemoryManager::GetVideoMemoryUsageStats( |
206 content::GPUVideoMemoryUsageStats& video_memory_usage_stats) const { | 207 GPUVideoMemoryUsageStats& video_memory_usage_stats) const { |
207 // For each context group, assign its memory usage to its PID | 208 // For each context group, assign its memory usage to its PID |
208 video_memory_usage_stats.process_map.clear(); | 209 video_memory_usage_stats.process_map.clear(); |
209 for (std::set<GpuMemoryTrackingGroup*>::const_iterator i = | 210 for (std::set<GpuMemoryTrackingGroup*>::const_iterator i = |
210 tracking_groups_.begin(); i != tracking_groups_.end(); ++i) { | 211 tracking_groups_.begin(); i != tracking_groups_.end(); ++i) { |
211 const GpuMemoryTrackingGroup* tracking_group = (*i); | 212 const GpuMemoryTrackingGroup* tracking_group = (*i); |
212 video_memory_usage_stats.process_map[ | 213 video_memory_usage_stats.process_map[ |
213 tracking_group->GetPid()].video_memory += tracking_group->GetSize(); | 214 tracking_group->GetPid()].video_memory += tracking_group->GetSize(); |
214 } | 215 } |
215 | 216 |
216 // Assign the total across all processes in the GPU process | 217 // Assign the total across all processes in the GPU process |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 GpuMemoryAllocation::kHasNoBuffers), | 400 GpuMemoryAllocation::kHasNoBuffers), |
400 false); | 401 false); |
401 | 402 |
402 AssignMemoryAllocations( | 403 AssignMemoryAllocations( |
403 &stub_memory_stats_for_last_manage_, | 404 &stub_memory_stats_for_last_manage_, |
404 stubs_without_surface_hibernated, | 405 stubs_without_surface_hibernated, |
405 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers), | 406 GpuMemoryAllocation(0, GpuMemoryAllocation::kHasNoBuffers), |
406 false); | 407 false); |
407 } | 408 } |
408 | 409 |
| 410 } // namespace content |
| 411 |
409 #endif | 412 #endif |
OLD | NEW |