| 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 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "content/common/gpu/gpu_channel_manager.h" |
| 16 #include "content/common/gpu/gpu_memory_manager_client.h" | 16 #include "content/common/gpu/gpu_memory_manager_client.h" |
| 17 #include "content/common/gpu/gpu_memory_tracking.h" | 17 #include "content/common/gpu/gpu_memory_tracking.h" |
| 18 #include "content/common/gpu/gpu_memory_uma_stats.h" | 18 #include "content/common/gpu/gpu_memory_uma_stats.h" |
| 19 #include "content/common/gpu/gpu_messages.h" | 19 #include "content/common/gpu/gpu_messages.h" |
| 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 20 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 21 #include "gpu/command_buffer/service/gpu_switches.h" | 21 #include "gpu/command_buffer/service/gpu_switches.h" |
| 22 | 22 |
| 23 using gpu::ManagedMemoryStats; | |
| 24 using gpu::MemoryAllocation; | 23 using gpu::MemoryAllocation; |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 27 namespace { | 26 namespace { |
| 28 | 27 |
| 29 const int kDelayedScheduleManageTimeoutMs = 67; | 28 const int kDelayedScheduleManageTimeoutMs = 67; |
| 30 | 29 |
| 31 const uint64 kBytesAllocatedUnmanagedStep = 16 * 1024 * 1024; | 30 const uint64 kBytesAllocatedUnmanagedStep = 16 * 1024 * 1024; |
| 32 | 31 |
| 33 void TrackValueChanged(uint64 old_size, uint64 new_size, uint64* total_size) { | 32 void TrackValueChanged(uint64 old_size, uint64 new_size, uint64* total_size) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 DCHECK(client_state->has_surface_); | 200 DCHECK(client_state->has_surface_); |
| 202 if (client_state->visible_ == visible) | 201 if (client_state->visible_ == visible) |
| 203 return; | 202 return; |
| 204 | 203 |
| 205 RemoveClientFromList(client_state); | 204 RemoveClientFromList(client_state); |
| 206 client_state->visible_ = visible; | 205 client_state->visible_ = visible; |
| 207 AddClientToList(client_state); | 206 AddClientToList(client_state); |
| 208 ScheduleManage(visible ? kScheduleManageNow : kScheduleManageLater); | 207 ScheduleManage(visible ? kScheduleManageNow : kScheduleManageLater); |
| 209 } | 208 } |
| 210 | 209 |
| 211 void GpuMemoryManager::SetClientStateManagedMemoryStats( | |
| 212 GpuMemoryManagerClientState* client_state, | |
| 213 const ManagedMemoryStats& stats) { | |
| 214 // TODO(ccameron): delete this from the full stack. | |
| 215 } | |
| 216 | |
| 217 uint64 GpuMemoryManager::GetClientMemoryUsage( | 210 uint64 GpuMemoryManager::GetClientMemoryUsage( |
| 218 const GpuMemoryManagerClient* client) const { | 211 const GpuMemoryManagerClient* client) const { |
| 219 TrackingGroupMap::const_iterator tracking_group_it = | 212 TrackingGroupMap::const_iterator tracking_group_it = |
| 220 tracking_groups_.find(client->GetMemoryTracker()); | 213 tracking_groups_.find(client->GetMemoryTracker()); |
| 221 DCHECK(tracking_group_it != tracking_groups_.end()); | 214 DCHECK(tracking_group_it != tracking_groups_.end()); |
| 222 return tracking_group_it->second->GetSize(); | 215 return tracking_group_it->second->GetSize(); |
| 223 } | 216 } |
| 224 | 217 |
| 225 GpuMemoryTrackingGroup* GpuMemoryManager::CreateTrackingGroup( | 218 GpuMemoryTrackingGroup* GpuMemoryManager::CreateTrackingGroup( |
| 226 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker) { | 219 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 403 |
| 411 void GpuMemoryManager::RemoveClientFromList( | 404 void GpuMemoryManager::RemoveClientFromList( |
| 412 GpuMemoryManagerClientState* client_state) { | 405 GpuMemoryManagerClientState* client_state) { |
| 413 DCHECK(client_state->list_iterator_valid_); | 406 DCHECK(client_state->list_iterator_valid_); |
| 414 ClientStateList* client_list = GetClientList(client_state); | 407 ClientStateList* client_list = GetClientList(client_state); |
| 415 client_list->erase(client_state->list_iterator_); | 408 client_list->erase(client_state->list_iterator_); |
| 416 client_state->list_iterator_valid_ = false; | 409 client_state->list_iterator_valid_ = false; |
| 417 } | 410 } |
| 418 | 411 |
| 419 } // namespace content | 412 } // namespace content |
| OLD | NEW |