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_cache.h" | 5 #include "cc/tiles/software_image_decode_cache.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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 task_type_(task_type), | 106 task_type_(task_type), |
107 tracing_info_(tracing_info) {} | 107 tracing_info_(tracing_info) {} |
108 | 108 |
109 // Overridden from Task: | 109 // Overridden from Task: |
110 void RunOnWorkerThread() override { | 110 void RunOnWorkerThread() override { |
111 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode", | 111 TRACE_EVENT2("cc", "ImageDecodeTaskImpl::RunOnWorkerThread", "mode", |
112 "software", "source_prepare_tiles_id", | 112 "software", "source_prepare_tiles_id", |
113 tracing_info_.prepare_tiles_id); | 113 tracing_info_.prepare_tiles_id); |
114 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( | 114 devtools_instrumentation::ScopedImageDecodeTask image_decode_task( |
115 image_.image().get(), | 115 image_.image().get(), |
116 devtools_instrumentation::ScopedImageDecodeTask::SOFTWARE); | 116 devtools_instrumentation::ScopedImageDecodeTask::kSoftware, |
| 117 ImageDecodeCache::ToScopedTaskType(tracing_info_.task_type)); |
117 cache_->DecodeImage(image_key_, image_, task_type_); | 118 cache_->DecodeImage(image_key_, image_, task_type_); |
118 } | 119 } |
119 | 120 |
120 // Overridden from TileTask: | 121 // Overridden from TileTask: |
121 void OnTaskCompleted() override { | 122 void OnTaskCompleted() override { |
122 cache_->RemovePendingTask(image_key_, task_type_); | 123 cache_->RemovePendingTask(image_key_, task_type_); |
123 } | 124 } |
124 | 125 |
125 protected: | 126 protected: |
126 ~ImageDecodeTaskImpl() override {} | 127 ~ImageDecodeTaskImpl() override {} |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 221 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
221 this); | 222 this); |
222 // Unregister this component with memory_coordinator::ClientRegistry. | 223 // Unregister this component with memory_coordinator::ClientRegistry. |
223 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); | 224 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this); |
224 } | 225 } |
225 | 226 |
226 bool SoftwareImageDecodeCache::GetTaskForImageAndRef( | 227 bool SoftwareImageDecodeCache::GetTaskForImageAndRef( |
227 const DrawImage& image, | 228 const DrawImage& image, |
228 const TracingInfo& tracing_info, | 229 const TracingInfo& tracing_info, |
229 scoped_refptr<TileTask>* task) { | 230 scoped_refptr<TileTask>* task) { |
| 231 DCHECK_EQ(tracing_info.task_type, TaskType::kInRaster); |
230 return GetTaskForImageAndRefInternal( | 232 return GetTaskForImageAndRefInternal( |
231 image, tracing_info, DecodeTaskType::USE_IN_RASTER_TASKS, task); | 233 image, tracing_info, DecodeTaskType::USE_IN_RASTER_TASKS, task); |
232 } | 234 } |
233 | 235 |
234 bool SoftwareImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef( | 236 bool SoftwareImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef( |
235 const DrawImage& image, | 237 const DrawImage& image, |
236 scoped_refptr<TileTask>* task) { | 238 scoped_refptr<TileTask>* task) { |
237 return GetTaskForImageAndRefInternal( | 239 return GetTaskForImageAndRefInternal( |
238 image, TracingInfo(), DecodeTaskType::USE_OUT_OF_RASTER_TASKS, task); | 240 image, TracingInfo(0, TilePriority::NOW, TaskType::kOutOfRaster), |
| 241 DecodeTaskType::USE_OUT_OF_RASTER_TASKS, task); |
239 } | 242 } |
240 | 243 |
241 bool SoftwareImageDecodeCache::GetTaskForImageAndRefInternal( | 244 bool SoftwareImageDecodeCache::GetTaskForImageAndRefInternal( |
242 const DrawImage& image, | 245 const DrawImage& image, |
243 const TracingInfo& tracing_info, | 246 const TracingInfo& tracing_info, |
244 DecodeTaskType task_type, | 247 DecodeTaskType task_type, |
245 scoped_refptr<TileTask>* task) { | 248 scoped_refptr<TileTask>* task) { |
246 // If the image already exists or if we're going to create a task for it, then | 249 // If the image already exists or if we're going to create a task for it, then |
247 // we'll likely need to ref this image (the exception is if we're prerolling | 250 // we'll likely need to ref this image (the exception is if we're prerolling |
248 // the image only). That means the image is or will be in the cache. When the | 251 // the image only). That means the image is or will be in the cache. When the |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 } | 1182 } |
1180 } | 1183 } |
1181 } | 1184 } |
1182 | 1185 |
1183 void SoftwareImageDecodeCache::OnPurgeMemory() { | 1186 void SoftwareImageDecodeCache::OnPurgeMemory() { |
1184 base::AutoLock lock(lock_); | 1187 base::AutoLock lock(lock_); |
1185 ReduceCacheUsageUntilWithinLimit(0); | 1188 ReduceCacheUsageUntilWithinLimit(0); |
1186 } | 1189 } |
1187 | 1190 |
1188 } // namespace cc | 1191 } // namespace cc |
OLD | NEW |