Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: cc/resources/tile_manager.cc

Issue 168083002: cc: Remove RasterWorkerPool::Task. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove RasterTaskQueueIterator Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/test/fake_tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 208
209 TileManager::~TileManager() { 209 TileManager::~TileManager() {
210 // Reset global state and manage. This should cause 210 // Reset global state and manage. This should cause
211 // our memory usage to drop to zero. 211 // our memory usage to drop to zero.
212 global_state_ = GlobalStateThatImpactsTilePriority(); 212 global_state_ = GlobalStateThatImpactsTilePriority();
213 213
214 CleanUpReleasedTiles(); 214 CleanUpReleasedTiles();
215 DCHECK_EQ(0u, tiles_.size()); 215 DCHECK_EQ(0u, tiles_.size());
216 216
217 RasterWorkerPool::RasterTask::Queue empty[NUM_RASTER_WORKER_POOL_TYPES]; 217 RasterTaskQueue empty[NUM_RASTER_WORKER_POOL_TYPES];
218 raster_worker_pool_delegate_->ScheduleTasks(empty); 218 raster_worker_pool_delegate_->ScheduleTasks(empty);
219 219
220 // This should finish all pending tasks and release any uninitialized 220 // This should finish all pending tasks and release any uninitialized
221 // resources. 221 // resources.
222 raster_worker_pool_delegate_->Shutdown(); 222 raster_worker_pool_delegate_->Shutdown();
223 raster_worker_pool_delegate_->CheckForCompletedTasks(); 223 raster_worker_pool_delegate_->CheckForCompletedTasks();
224 224
225 DCHECK_EQ(0u, bytes_releasable_); 225 DCHECK_EQ(0u, bytes_releasable_);
226 DCHECK_EQ(0u, resources_releasable_); 226 DCHECK_EQ(0u, resources_releasable_);
227 } 227 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 const TreePriority tree_priority = global_state_.tree_priority; 347 const TreePriority tree_priority = global_state_.tree_priority;
348 348
349 // For each tree, bin into different categories of tiles. 349 // For each tree, bin into different categories of tiles.
350 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 350 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
351 Tile* tile = it->second; 351 Tile* tile = it->second;
352 ManagedTileState& mts = tile->managed_state(); 352 ManagedTileState& mts = tile->managed_state();
353 353
354 const ManagedTileState::TileVersion& tile_version = 354 const ManagedTileState::TileVersion& tile_version =
355 tile->GetTileVersionForDrawing(); 355 tile->GetTileVersionForDrawing();
356 bool tile_is_ready_to_draw = tile_version.IsReadyToDraw(); 356 bool tile_is_ready_to_draw = tile_version.IsReadyToDraw();
357 bool tile_is_active = 357 bool tile_is_active = tile_is_ready_to_draw ||
358 tile_is_ready_to_draw || 358 mts.tile_versions[mts.raster_mode].raster_task_;
359 !mts.tile_versions[mts.raster_mode].raster_task_.is_null();
360 359
361 // Get the active priority and bin. 360 // Get the active priority and bin.
362 TilePriority active_priority = tile->priority(ACTIVE_TREE); 361 TilePriority active_priority = tile->priority(ACTIVE_TREE);
363 ManagedTileBin active_bin = BinFromTilePriority(active_priority); 362 ManagedTileBin active_bin = BinFromTilePriority(active_priority);
364 363
365 // Get the pending priority and bin. 364 // Get the pending priority and bin.
366 TilePriority pending_priority = tile->priority(PENDING_TREE); 365 TilePriority pending_priority = tile->priority(PENDING_TREE);
367 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); 366 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority);
368 367
369 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION; 368 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 tile_resources++; 678 tile_resources++;
680 } 679 }
681 } 680 }
682 681
683 // Allow lower priority tiles with initialized resources to keep 682 // Allow lower priority tiles with initialized resources to keep
684 // their memory by only assigning memory to new raster tasks if 683 // their memory by only assigning memory to new raster tasks if
685 // they can be scheduled. 684 // they can be scheduled.
686 if (raster_bytes_if_rastered <= max_raster_bytes) { 685 if (raster_bytes_if_rastered <= max_raster_bytes) {
687 // If we don't have the required version, and it's not in flight 686 // If we don't have the required version, and it's not in flight
688 // then we'll have to pay to create a new task. 687 // then we'll have to pay to create a new task.
689 if (!tile_version.resource_ && tile_version.raster_task_.is_null()) { 688 if (!tile_version.resource_ && !tile_version.raster_task_) {
690 tile_bytes += bytes_if_allocated; 689 tile_bytes += bytes_if_allocated;
691 tile_resources++; 690 tile_resources++;
692 } 691 }
693 } 692 }
694 693
695 // Tile is OOM. 694 // Tile is OOM.
696 if (tile_bytes > tile_bytes_left || tile_resources > resources_left) { 695 if (tile_bytes > tile_bytes_left || tile_resources > resources_left) {
697 FreeResourcesForTile(tile); 696 FreeResourcesForTile(tile);
698 697
699 // This tile was already on screen and now its resources have been 698 // This tile was already on screen and now its resources have been
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 it != tiles_that_need_to_be_rasterized.end(); 811 it != tiles_that_need_to_be_rasterized.end();
813 ++it) { 812 ++it) {
814 Tile* tile = *it; 813 Tile* tile = *it;
815 ManagedTileState& mts = tile->managed_state(); 814 ManagedTileState& mts = tile->managed_state();
816 ManagedTileState::TileVersion& tile_version = 815 ManagedTileState::TileVersion& tile_version =
817 mts.tile_versions[mts.raster_mode]; 816 mts.tile_versions[mts.raster_mode];
818 817
819 DCHECK(tile_version.requires_resource()); 818 DCHECK(tile_version.requires_resource());
820 DCHECK(!tile_version.resource_); 819 DCHECK(!tile_version.resource_);
821 820
822 if (tile_version.raster_task_.is_null()) 821 if (!tile_version.raster_task_)
823 tile_version.raster_task_ = CreateRasterTask(tile); 822 tile_version.raster_task_ = CreateRasterTask(tile);
824 823
825 size_t pool_type = tile->use_gpu_rasterization() 824 size_t pool_type = tile->use_gpu_rasterization()
826 ? RASTER_WORKER_POOL_TYPE_DIRECT 825 ? RASTER_WORKER_POOL_TYPE_DIRECT
827 : RASTER_WORKER_POOL_TYPE_DEFAULT; 826 : RASTER_WORKER_POOL_TYPE_DEFAULT;
828 827
829 raster_queue_[pool_type] 828 raster_queue_[pool_type].items.push_back(RasterTaskQueue::Item(
830 .Append(tile_version.raster_task_, tile->required_for_activation()); 829 tile_version.raster_task_.get(), tile->required_for_activation()));
830 raster_queue_[pool_type].required_for_activation_count +=
831 tile->required_for_activation();
831 } 832 }
832 833
833 // We must reduce the amount of unused resoruces before calling 834 // We must reduce the amount of unused resoruces before calling
834 // ScheduleTasks to prevent usage from rising above limits. 835 // ScheduleTasks to prevent usage from rising above limits.
835 resource_pool_->ReduceResourceUsage(); 836 resource_pool_->ReduceResourceUsage();
836 837
837 // Schedule running of |raster_tasks_|. This replaces any previously 838 // Schedule running of |raster_tasks_|. This replaces any previously
838 // scheduled tasks and effectively cancels all tasks not present 839 // scheduled tasks and effectively cancels all tasks not present
839 // in |raster_tasks_|. 840 // in |raster_tasks_|.
840 raster_worker_pool_delegate_->ScheduleTasks(raster_queue_); 841 raster_worker_pool_delegate_->ScheduleTasks(raster_queue_);
841 842
842 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; 843 did_check_for_completed_tasks_since_last_schedule_tasks_ = false;
843 } 844 }
844 845
845 RasterWorkerPool::Task TileManager::CreateImageDecodeTask( 846 scoped_refptr<internal::WorkerPoolTask> TileManager::CreateImageDecodeTask(
846 Tile* tile, 847 Tile* tile,
847 SkPixelRef* pixel_ref) { 848 SkPixelRef* pixel_ref) {
848 return RasterWorkerPool::CreateImageDecodeTask( 849 return RasterWorkerPool::CreateImageDecodeTask(
849 pixel_ref, 850 pixel_ref,
850 tile->layer_id(), 851 tile->layer_id(),
851 rendering_stats_instrumentation_, 852 rendering_stats_instrumentation_,
852 base::Bind(&TileManager::OnImageDecodeTaskCompleted, 853 base::Bind(&TileManager::OnImageDecodeTaskCompleted,
853 base::Unretained(this), 854 base::Unretained(this),
854 tile->layer_id(), 855 tile->layer_id(),
855 base::Unretained(pixel_ref))); 856 base::Unretained(pixel_ref)));
856 } 857 }
857 858
858 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { 859 scoped_refptr<internal::RasterWorkerPoolTask> TileManager::CreateRasterTask(
860 Tile* tile) {
859 ManagedTileState& mts = tile->managed_state(); 861 ManagedTileState& mts = tile->managed_state();
860 862
861 scoped_ptr<ScopedResource> resource = 863 scoped_ptr<ScopedResource> resource =
862 resource_pool_->AcquireResource(tile->tile_size_.size()); 864 resource_pool_->AcquireResource(tile->tile_size_.size());
863 const ScopedResource* const_resource = resource.get(); 865 const ScopedResource* const_resource = resource.get();
864 866
865 // Create and queue all image decode tasks that this tile depends on. 867 // Create and queue all image decode tasks that this tile depends on.
866 RasterWorkerPool::Task::Set decode_tasks; 868 internal::WorkerPoolTask::Vector decode_tasks;
867 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; 869 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()];
868 for (PicturePileImpl::PixelRefIterator iter( 870 for (PicturePileImpl::PixelRefIterator iter(
869 tile->content_rect(), tile->contents_scale(), tile->picture_pile()); 871 tile->content_rect(), tile->contents_scale(), tile->picture_pile());
870 iter; 872 iter;
871 ++iter) { 873 ++iter) {
872 SkPixelRef* pixel_ref = *iter; 874 SkPixelRef* pixel_ref = *iter;
873 uint32_t id = pixel_ref->getGenerationID(); 875 uint32_t id = pixel_ref->getGenerationID();
874 876
875 // Append existing image decode task if available. 877 // Append existing image decode task if available.
876 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id); 878 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id);
877 if (decode_task_it != existing_pixel_refs.end()) { 879 if (decode_task_it != existing_pixel_refs.end()) {
878 decode_tasks.Insert(decode_task_it->second); 880 decode_tasks.push_back(decode_task_it->second);
879 continue; 881 continue;
880 } 882 }
881 883
882 // Create and append new image decode task for this pixel ref. 884 // Create and append new image decode task for this pixel ref.
883 RasterWorkerPool::Task decode_task = CreateImageDecodeTask(tile, pixel_ref); 885 scoped_refptr<internal::WorkerPoolTask> decode_task =
884 decode_tasks.Insert(decode_task); 886 CreateImageDecodeTask(tile, pixel_ref);
887 decode_tasks.push_back(decode_task);
885 existing_pixel_refs[id] = decode_task; 888 existing_pixel_refs[id] = decode_task;
886 } 889 }
887 890
888 return RasterWorkerPool::CreateRasterTask( 891 return RasterWorkerPool::CreateRasterTask(
889 const_resource, 892 const_resource,
890 tile->picture_pile(), 893 tile->picture_pile(),
891 tile->content_rect(), 894 tile->content_rect(),
892 tile->contents_scale(), 895 tile->contents_scale(),
893 mts.raster_mode, 896 mts.raster_mode,
894 mts.resolution, 897 mts.resolution,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 TileMap::iterator it = tiles_.find(tile_id); 938 TileMap::iterator it = tiles_.find(tile_id);
936 if (it == tiles_.end()) { 939 if (it == tiles_.end()) {
937 ++update_visible_tiles_stats_.canceled_count; 940 ++update_visible_tiles_stats_.canceled_count;
938 resource_pool_->ReleaseResource(resource.Pass()); 941 resource_pool_->ReleaseResource(resource.Pass());
939 return; 942 return;
940 } 943 }
941 944
942 Tile* tile = it->second; 945 Tile* tile = it->second;
943 ManagedTileState& mts = tile->managed_state(); 946 ManagedTileState& mts = tile->managed_state();
944 ManagedTileState::TileVersion& tile_version = mts.tile_versions[raster_mode]; 947 ManagedTileState::TileVersion& tile_version = mts.tile_versions[raster_mode];
945 DCHECK(!tile_version.raster_task_.is_null()); 948 DCHECK(tile_version.raster_task_);
946 tile_version.raster_task_.Reset(); 949 tile_version.raster_task_ = NULL;
947 950
948 if (was_canceled) { 951 if (was_canceled) {
949 ++update_visible_tiles_stats_.canceled_count; 952 ++update_visible_tiles_stats_.canceled_count;
950 resource_pool_->ReleaseResource(resource.Pass()); 953 resource_pool_->ReleaseResource(resource.Pass());
951 return; 954 return;
952 } 955 }
953 956
954 ++update_visible_tiles_stats_.completed_count; 957 ++update_visible_tiles_stats_.completed_count;
955 958
956 tile_version.set_has_text(analysis.has_text); 959 tile_version.set_has_text(analysis.has_text);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 flags)); 992 flags));
990 DCHECK(tiles_.find(tile->id()) == tiles_.end()); 993 DCHECK(tiles_.find(tile->id()) == tiles_.end());
991 994
992 tiles_[tile->id()] = tile; 995 tiles_[tile->id()] = tile;
993 used_layer_counts_[tile->layer_id()]++; 996 used_layer_counts_[tile->layer_id()]++;
994 prioritized_tiles_dirty_ = true; 997 prioritized_tiles_dirty_ = true;
995 return tile; 998 return tile;
996 } 999 }
997 1000
998 } // namespace cc 1001 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.h ('k') | cc/test/fake_tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698