Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/tiles/software_image_decode_controller.h" | 5 #include "cc/tiles/software_image_decode_controller.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 172 : decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
| 173 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), | 173 at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT), |
| 174 locked_images_budget_(locked_memory_limit_bytes), | 174 locked_images_budget_(locked_memory_limit_bytes), |
| 175 format_(format) { | 175 format_(format) { |
| 176 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 176 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
| 177 // Don't register a dump provider in these cases. | 177 // Don't register a dump provider in these cases. |
| 178 if (base::ThreadTaskRunnerHandle::IsSet()) { | 178 if (base::ThreadTaskRunnerHandle::IsSet()) { |
| 179 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 179 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 180 this, "cc::SoftwareImageDecodeController", | 180 this, "cc::SoftwareImageDecodeController", |
| 181 base::ThreadTaskRunnerHandle::Get()); | 181 base::ThreadTaskRunnerHandle::Get()); |
| 182 } | 182 } |
|
tasak
2016/08/26 10:08:05
Need to register this with ChildMemoryCoordinator
| |
| 183 } | 183 } |
| 184 | 184 |
| 185 SoftwareImageDecodeController::~SoftwareImageDecodeController() { | 185 SoftwareImageDecodeController::~SoftwareImageDecodeController() { |
| 186 DCHECK_EQ(0u, decoded_images_ref_counts_.size()); | 186 DCHECK_EQ(0u, decoded_images_ref_counts_.size()); |
| 187 DCHECK_EQ(0u, at_raster_decoded_images_ref_counts_.size()); | 187 DCHECK_EQ(0u, at_raster_decoded_images_ref_counts_.size()); |
| 188 | 188 |
| 189 // It is safe to unregister, even if we didn't register in the constructor. | 189 // It is safe to unregister, even if we didn't register in the constructor. |
| 190 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 190 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 191 this); | 191 this); |
|
tasak
2016/08/26 10:08:05
Need to unregister this with ChildMemoryCoordinato
| |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool SoftwareImageDecodeController::GetTaskForImageAndRef( | 194 bool SoftwareImageDecodeController::GetTaskForImageAndRef( |
| 195 const DrawImage& image, | 195 const DrawImage& image, |
| 196 const TracingInfo& tracing_info, | 196 const TracingInfo& tracing_info, |
| 197 scoped_refptr<TileTask>* task) { | 197 scoped_refptr<TileTask>* task) { |
| 198 // If the image already exists or if we're going to create a task for it, then | 198 // If the image already exists or if we're going to create a task for it, then |
| 199 // we'll likely need to ref this image (the exception is if we're prerolling | 199 // we'll likely need to ref this image (the exception is if we're prerolling |
| 200 // the image only). That means the image is or will be in the cache. When the | 200 // the image only). That means the image is or will be in the cache. When the |
| 201 // ref goes to 0, it will be unpinned but will remain in the cache. If the | 201 // ref goes to 0, it will be unpinned but will remain in the cache. If the |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1071 | 1071 |
| 1072 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { | 1072 void SoftwareImageDecodeController::MemoryBudget::ResetUsage() { |
| 1073 current_usage_bytes_ = 0; | 1073 current_usage_bytes_ = 0; |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() | 1076 size_t SoftwareImageDecodeController::MemoryBudget::GetCurrentUsageSafe() |
| 1077 const { | 1077 const { |
| 1078 return current_usage_bytes_.ValueOrDie(); | 1078 return current_usage_bytes_.ValueOrDie(); |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 void SoftwareImageDecodeController::OnMemoryStateChange( | |
| 1082 memory_coordinator::mojom::MemoryState state) { | |
| 1083 if (state == memory_coordinator::mojom::MemoryState::SUSPENDED) { | |
|
vmpstr
2016/08/31 17:45:51
What are the different states that we can be in?
| |
| 1084 decoded_images_.Clear(); | |
| 1085 at_raster_decoded_images_.Clear(); | |
|
vmpstr
2016/08/31 17:45:51
I don't think this is safe to do, because both of
| |
| 1086 } | |
| 1087 } | |
| 1088 | |
| 1081 } // namespace cc | 1089 } // namespace cc |
| OLD | NEW |