OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 | 851 |
852 // Schedule running of |tasks|. This replaces any previously | 852 // Schedule running of |tasks|. This replaces any previously |
853 // scheduled tasks and effectively cancels all tasks not present | 853 // scheduled tasks and effectively cancels all tasks not present |
854 // in |tasks|. | 854 // in |tasks|. |
855 raster_worker_pool_->ScheduleTasks(&tasks); | 855 raster_worker_pool_->ScheduleTasks(&tasks); |
856 | 856 |
857 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 857 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
858 } | 858 } |
859 | 859 |
860 RasterWorkerPool::Task TileManager::CreateImageDecodeTask( | 860 RasterWorkerPool::Task TileManager::CreateImageDecodeTask( |
861 Tile* tile, skia::LazyPixelRef* pixel_ref) { | 861 Tile* tile, SkPixelRef* pixel_ref) { |
862 return RasterWorkerPool::CreateImageDecodeTask( | 862 return RasterWorkerPool::CreateImageDecodeTask( |
863 pixel_ref, | 863 pixel_ref, |
864 tile->layer_id(), | 864 tile->layer_id(), |
865 rendering_stats_instrumentation_, | 865 rendering_stats_instrumentation_, |
866 base::Bind(&TileManager::OnImageDecodeTaskCompleted, | 866 base::Bind(&TileManager::OnImageDecodeTaskCompleted, |
867 base::Unretained(this), | 867 base::Unretained(this), |
868 tile->layer_id(), | 868 tile->layer_id(), |
869 base::Unretained(pixel_ref))); | 869 base::Unretained(pixel_ref))); |
870 } | 870 } |
871 | 871 |
872 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { | 872 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { |
873 ManagedTileState& mts = tile->managed_state(); | 873 ManagedTileState& mts = tile->managed_state(); |
874 | 874 |
875 scoped_ptr<ScopedResource> resource = | 875 scoped_ptr<ScopedResource> resource = |
876 resource_pool_->AcquireResource(tile->tile_size_.size()); | 876 resource_pool_->AcquireResource(tile->tile_size_.size()); |
877 const ScopedResource* const_resource = resource.get(); | 877 const ScopedResource* const_resource = resource.get(); |
878 | 878 |
879 // Create and queue all image decode tasks that this tile depends on. | 879 // Create and queue all image decode tasks that this tile depends on. |
880 RasterWorkerPool::Task::Set decode_tasks; | 880 RasterWorkerPool::Task::Set decode_tasks; |
881 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; | 881 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; |
882 for (PicturePileImpl::PixelRefIterator iter(tile->content_rect(), | 882 for (PicturePileImpl::PixelRefIterator iter(tile->content_rect(), |
883 tile->contents_scale(), | 883 tile->contents_scale(), |
884 tile->picture_pile()); | 884 tile->picture_pile()); |
885 iter; ++iter) { | 885 iter; ++iter) { |
886 skia::LazyPixelRef* pixel_ref = *iter; | 886 SkPixelRef* pixel_ref = *iter; |
887 uint32_t id = pixel_ref->getGenerationID(); | 887 uint32_t id = pixel_ref->getGenerationID(); |
888 | 888 |
889 // Append existing image decode task if available. | 889 // Append existing image decode task if available. |
890 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id); | 890 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id); |
891 if (decode_task_it != existing_pixel_refs.end()) { | 891 if (decode_task_it != existing_pixel_refs.end()) { |
892 decode_tasks.Insert(decode_task_it->second); | 892 decode_tasks.Insert(decode_task_it->second); |
893 continue; | 893 continue; |
894 } | 894 } |
895 | 895 |
896 // Create and append new image decode task for this pixel ref. | 896 // Create and append new image decode task for this pixel ref. |
(...skipping 17 matching lines...) Expand all Loading... | |
914 base::Bind(&TileManager::OnRasterTaskCompleted, | 914 base::Bind(&TileManager::OnRasterTaskCompleted, |
915 base::Unretained(this), | 915 base::Unretained(this), |
916 tile->id(), | 916 tile->id(), |
917 base::Passed(&resource), | 917 base::Passed(&resource), |
918 mts.raster_mode), | 918 mts.raster_mode), |
919 &decode_tasks); | 919 &decode_tasks); |
920 } | 920 } |
921 | 921 |
922 void TileManager::OnImageDecodeTaskCompleted( | 922 void TileManager::OnImageDecodeTaskCompleted( |
923 int layer_id, | 923 int layer_id, |
924 skia::LazyPixelRef* pixel_ref, | 924 SkPixelRef* pixel_ref, |
925 bool was_canceled) { | 925 bool was_canceled) { |
926 // If the task was canceled, we need to clean it up | 926 // If the task was canceled, we need to clean it up |
927 // from |image_decode_tasks_|. | 927 // from |image_decode_tasks_|. |
928 if (!was_canceled) | 928 if (!was_canceled) |
929 return; | 929 return; |
930 | 930 |
931 LayerPixelRefTaskMap::iterator layer_it = | 931 LayerPixelRefTaskMap::iterator layer_it = |
932 image_decode_tasks_.find(layer_id); | 932 image_decode_tasks_.find(layer_id); |
vmpstr
2013/12/20 17:41:06
I assume we'll also be removing this decode-once t
reveman
2013/12/20 18:22:19
Yes, correct.
| |
933 | 933 |
934 if (layer_it == image_decode_tasks_.end()) | 934 if (layer_it == image_decode_tasks_.end()) |
935 return; | 935 return; |
936 | 936 |
937 PixelRefTaskMap& pixel_ref_tasks = layer_it->second; | 937 PixelRefTaskMap& pixel_ref_tasks = layer_it->second; |
938 PixelRefTaskMap::iterator task_it = | 938 PixelRefTaskMap::iterator task_it = |
939 pixel_ref_tasks.find(pixel_ref->getGenerationID()); | 939 pixel_ref_tasks.find(pixel_ref->getGenerationID()); |
940 | 940 |
941 if (task_it != pixel_ref_tasks.end()) | 941 if (task_it != pixel_ref_tasks.end()) |
942 pixel_ref_tasks.erase(task_it); | 942 pixel_ref_tasks.erase(task_it); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1016 int offset_y, | 1016 int offset_y, |
1017 int width, | 1017 int width, |
1018 int height) { | 1018 int height) { |
1019 scoped_refptr<TileBundle> bundle = make_scoped_refptr( | 1019 scoped_refptr<TileBundle> bundle = make_scoped_refptr( |
1020 new TileBundle(this, offset_x, offset_y, width, height)); | 1020 new TileBundle(this, offset_x, offset_y, width, height)); |
1021 bundles_[bundle->id()] = bundle; | 1021 bundles_[bundle->id()] = bundle; |
1022 return bundle; | 1022 return bundle; |
1023 } | 1023 } |
1024 | 1024 |
1025 } // namespace cc | 1025 } // namespace cc |
OLD | NEW |