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" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 DCHECK(clients_visible_mru_.empty()); | 55 DCHECK(clients_visible_mru_.empty()); |
56 DCHECK(clients_nonvisible_mru_.empty()); | 56 DCHECK(clients_nonvisible_mru_.empty()); |
57 DCHECK(clients_nonsurface_.empty()); | 57 DCHECK(clients_nonsurface_.empty()); |
58 DCHECK(!bytes_allocated_managed_current_); | 58 DCHECK(!bytes_allocated_managed_current_); |
59 DCHECK(!bytes_allocated_unmanaged_current_); | 59 DCHECK(!bytes_allocated_unmanaged_current_); |
60 } | 60 } |
61 | 61 |
62 void GpuMemoryManager::UpdateAvailableGpuMemory() { | 62 void GpuMemoryManager::UpdateAvailableGpuMemory() { |
63 // If the value was overridden on the command line, use the specified value. | 63 // If the value was overridden on the command line, use the specified value. |
64 static bool client_hard_limit_bytes_overridden = | 64 static bool client_hard_limit_bytes_overridden = |
65 CommandLine::ForCurrentProcess()->HasSwitch( | 65 base::CommandLine::ForCurrentProcess()->HasSwitch( |
66 switches::kForceGpuMemAvailableMb); | 66 switches::kForceGpuMemAvailableMb); |
67 if (client_hard_limit_bytes_overridden) { | 67 if (client_hard_limit_bytes_overridden) { |
68 base::StringToUint64( | 68 base::StringToUint64( |
69 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 69 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
70 switches::kForceGpuMemAvailableMb), | 70 switches::kForceGpuMemAvailableMb), |
71 &client_hard_limit_bytes_); | 71 &client_hard_limit_bytes_); |
72 client_hard_limit_bytes_ *= 1024 * 1024; | 72 client_hard_limit_bytes_ *= 1024 * 1024; |
73 return; | 73 return; |
74 } | 74 } |
75 | 75 |
76 #if defined(OS_ANDROID) | 76 #if defined(OS_ANDROID) |
77 // On non-Android, we use an operating system query when possible. | 77 // On non-Android, we use an operating system query when possible. |
78 // We do not have a reliable concept of multiple GPUs existing in | 78 // We do not have a reliable concept of multiple GPUs existing in |
79 // a system, so just be safe and go with the minimum encountered. | 79 // a system, so just be safe and go with the minimum encountered. |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 403 |
404 void GpuMemoryManager::RemoveClientFromList( | 404 void GpuMemoryManager::RemoveClientFromList( |
405 GpuMemoryManagerClientState* client_state) { | 405 GpuMemoryManagerClientState* client_state) { |
406 DCHECK(client_state->list_iterator_valid_); | 406 DCHECK(client_state->list_iterator_valid_); |
407 ClientStateList* client_list = GetClientList(client_state); | 407 ClientStateList* client_list = GetClientList(client_state); |
408 client_list->erase(client_state->list_iterator_); | 408 client_list->erase(client_state->list_iterator_); |
409 client_state->list_iterator_valid_ = false; | 409 client_state->list_iterator_valid_ = false; |
410 } | 410 } |
411 | 411 |
412 } // namespace content | 412 } // namespace content |
OLD | NEW |