| Index: cc/tiles/software_image_decode_cache.cc
|
| diff --git a/cc/tiles/software_image_decode_cache.cc b/cc/tiles/software_image_decode_cache.cc
|
| index a69e1bcc0adc8a86b8795c20e48ae8b741541eaa..aa2066592517f744eaaaa1020d2ce9bf5d26c61d 100644
|
| --- a/cc/tiles/software_image_decode_cache.cc
|
| +++ b/cc/tiles/software_image_decode_cache.cc
|
| @@ -94,11 +94,13 @@ class ImageDecodeTaskImpl : public TileTask {
|
| ImageDecodeTaskImpl(SoftwareImageDecodeCache* cache,
|
| const SoftwareImageDecodeCache::ImageKey& image_key,
|
| const DrawImage& image,
|
| + const SoftwareImageDecodeCache::DecodeTaskType task_type,
|
| const ImageDecodeCache::TracingInfo& tracing_info)
|
| : TileTask(true),
|
| cache_(cache),
|
| image_key_(image_key),
|
| image_(image),
|
| + task_type_(task_type),
|
| tracing_info_(tracing_info) {}
|
|
|
| // Overridden from Task:
|
| @@ -109,11 +111,13 @@ class ImageDecodeTaskImpl : public TileTask {
|
| devtools_instrumentation::ScopedImageDecodeTask image_decode_task(
|
| image_.image().get(),
|
| devtools_instrumentation::ScopedImageDecodeTask::SOFTWARE);
|
| - cache_->DecodeImage(image_key_, image_);
|
| + cache_->DecodeImage(image_key_, image_, task_type_);
|
| }
|
|
|
| // Overridden from TileTask:
|
| - void OnTaskCompleted() override { cache_->RemovePendingTask(image_key_); }
|
| + void OnTaskCompleted() override {
|
| + cache_->RemovePendingTask(image_key_, task_type_);
|
| + }
|
|
|
| protected:
|
| ~ImageDecodeTaskImpl() override {}
|
| @@ -122,6 +126,7 @@ class ImageDecodeTaskImpl : public TileTask {
|
| SoftwareImageDecodeCache* cache_;
|
| SoftwareImageDecodeCache::ImageKey image_key_;
|
| DrawImage image_;
|
| + SoftwareImageDecodeCache::DecodeTaskType task_type_;
|
| const ImageDecodeCache::TracingInfo tracing_info_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ImageDecodeTaskImpl);
|
| @@ -208,6 +213,22 @@ bool SoftwareImageDecodeCache::GetTaskForImageAndRef(
|
| const DrawImage& image,
|
| const TracingInfo& tracing_info,
|
| scoped_refptr<TileTask>* task) {
|
| + return GetTaskForImageAndRefInternal(
|
| + image, tracing_info, DecodeTaskType::USE_IN_RASTER_TASKS, task);
|
| +}
|
| +
|
| +bool SoftwareImageDecodeCache::GetOutOfRasterDecodeTaskForImageAndRef(
|
| + const DrawImage& image,
|
| + scoped_refptr<TileTask>* task) {
|
| + return GetTaskForImageAndRefInternal(
|
| + image, TracingInfo(), DecodeTaskType::USE_OUT_OF_RASTER_TASKS, task);
|
| +}
|
| +
|
| +bool SoftwareImageDecodeCache::GetTaskForImageAndRefInternal(
|
| + const DrawImage& image,
|
| + const TracingInfo& tracing_info,
|
| + DecodeTaskType task_type,
|
| + scoped_refptr<TileTask>* task) {
|
| // If the image already exists or if we're going to create a task for it, then
|
| // we'll likely need to ref this image (the exception is if we're prerolling
|
| // the image only). That means the image is or will be in the cache. When the
|
| @@ -258,8 +279,15 @@ bool SoftwareImageDecodeCache::GetTaskForImageAndRef(
|
| }
|
| }
|
|
|
| - // If the task exists, return it.
|
| - scoped_refptr<TileTask>& existing_task = pending_image_tasks_[key];
|
| + DCHECK(task_type == DecodeTaskType::USE_IN_RASTER_TASKS ||
|
| + task_type == DecodeTaskType::USE_OUT_OF_RASTER_TASKS);
|
| + // If the task exists, return it. Note that if we always need to create a new
|
| + // task, then just set |existing_task| to reference the passed in task (which
|
| + // is set to nullptr above).
|
| + scoped_refptr<TileTask>& existing_task =
|
| + (task_type == DecodeTaskType::USE_IN_RASTER_TASKS)
|
| + ? pending_in_raster_image_tasks_[key]
|
| + : pending_out_of_raster_image_tasks_[key];
|
| if (existing_task) {
|
| RefImage(key);
|
| *task = existing_task;
|
| @@ -283,7 +311,7 @@ bool SoftwareImageDecodeCache::GetTaskForImageAndRef(
|
| // ref.
|
| RefImage(key);
|
| existing_task = make_scoped_refptr(
|
| - new ImageDecodeTaskImpl(this, key, image, tracing_info));
|
| + new ImageDecodeTaskImpl(this, key, image, task_type, tracing_info));
|
| *task = existing_task;
|
| SanityCheckState(__LINE__, true);
|
| return true;
|
| @@ -334,11 +362,16 @@ void SoftwareImageDecodeCache::UnrefImage(const DrawImage& image) {
|
| }
|
|
|
| void SoftwareImageDecodeCache::DecodeImage(const ImageKey& key,
|
| - const DrawImage& image) {
|
| + const DrawImage& image,
|
| + DecodeTaskType task_type) {
|
| TRACE_EVENT1("cc", "SoftwareImageDecodeCache::DecodeImage", "key",
|
| key.ToString());
|
| base::AutoLock lock(lock_);
|
| - AutoRemoveKeyFromTaskMap remove_key_from_task_map(&pending_image_tasks_, key);
|
| + AutoRemoveKeyFromTaskMap remove_key_from_task_map(
|
| + (task_type == DecodeTaskType::USE_IN_RASTER_TASKS)
|
| + ? &pending_in_raster_image_tasks_
|
| + : &pending_out_of_raster_image_tasks_,
|
| + key);
|
|
|
| // We could have finished all of the raster tasks (cancelled) while the task
|
| // was just starting to run. Since this task already started running, it
|
| @@ -768,9 +801,17 @@ void SoftwareImageDecodeCache::ReduceCacheUsage() {
|
| }
|
| }
|
|
|
| -void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key) {
|
| +void SoftwareImageDecodeCache::RemovePendingTask(const ImageKey& key,
|
| + DecodeTaskType task_type) {
|
| base::AutoLock lock(lock_);
|
| - pending_image_tasks_.erase(key);
|
| + switch (task_type) {
|
| + case DecodeTaskType::USE_IN_RASTER_TASKS:
|
| + pending_in_raster_image_tasks_.erase(key);
|
| + break;
|
| + case DecodeTaskType::USE_OUT_OF_RASTER_TASKS:
|
| + pending_out_of_raster_image_tasks_.erase(key);
|
| + break;
|
| + }
|
| }
|
|
|
| bool SoftwareImageDecodeCache::OnMemoryDump(
|
| @@ -837,7 +878,10 @@ void SoftwareImageDecodeCache::SanityCheckState(int line, bool lock_acquired) {
|
| DCHECK(ref_it != decoded_images_ref_counts_.end()) << line;
|
| } else {
|
| DCHECK(ref_it == decoded_images_ref_counts_.end() ||
|
| - pending_image_tasks_.find(key) != pending_image_tasks_.end())
|
| + pending_in_raster_image_tasks_.find(key) !=
|
| + pending_in_raster_image_tasks_.end() ||
|
| + pending_out_of_raster_image_tasks_.find(key) !=
|
| + pending_out_of_raster_image_tasks_.end())
|
| << line;
|
| }
|
| }
|
|
|