Chromium Code Reviews| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
| 16 #include "cc/resources/direct_raster_worker_pool.h" | |
| 16 #include "cc/resources/image_raster_worker_pool.h" | 17 #include "cc/resources/image_raster_worker_pool.h" |
| 17 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 18 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 18 #include "cc/resources/tile.h" | 19 #include "cc/resources/tile.h" |
| 19 #include "third_party/skia/include/core/SkCanvas.h" | |
| 20 #include "ui/gfx/rect_conversions.h" | 20 #include "ui/gfx/rect_conversions.h" |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 | |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 // Memory limit policy works by mapping some bin states to the NEVER bin. | 25 // Memory limit policy works by mapping some bin states to the NEVER bin. |
| 27 const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { | 26 const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { |
| 28 // [ALLOW_NOTHING] | 27 // [ALLOW_NOTHING] |
| 29 {NEVER_BIN, // [NOW_AND_READY_TO_DRAW_BIN] | 28 {NEVER_BIN, // [NOW_AND_READY_TO_DRAW_BIN] |
| 30 NEVER_BIN, // [NOW_BIN] | 29 NEVER_BIN, // [NOW_BIN] |
| 31 NEVER_BIN, // [SOON_BIN] | 30 NEVER_BIN, // [SOON_BIN] |
| 32 NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] | 31 NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] |
| 33 NEVER_BIN, // [EVENTUALLY_BIN] | 32 NEVER_BIN, // [EVENTUALLY_BIN] |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 return SOON_BIN; | 124 return SOON_BIN; |
| 126 | 125 |
| 127 if (prio.distance_to_visible == std::numeric_limits<float>::infinity()) | 126 if (prio.distance_to_visible == std::numeric_limits<float>::infinity()) |
| 128 return NEVER_BIN; | 127 return NEVER_BIN; |
| 129 | 128 |
| 130 return EVENTUALLY_BIN; | 129 return EVENTUALLY_BIN; |
| 131 } | 130 } |
| 132 | 131 |
| 133 } // namespace | 132 } // namespace |
| 134 | 133 |
| 134 class RasterWorkerPoolDelegate : public RasterWorkerPoolClient { | |
|
vmpstr
2014/02/14 17:16:51
Can you please make this a separate file?
I was t
reveman
2014/02/14 23:30:52
Done.
| |
| 135 public: | |
| 136 RasterWorkerPoolDelegate( | |
| 137 scoped_ptr<RasterWorkerPool> raster_worker_pool, | |
| 138 scoped_ptr<RasterWorkerPool> direct_raster_worker_pool) | |
| 139 : client_(NULL), | |
| 140 raster_worker_pool_(raster_worker_pool.Pass()), | |
| 141 direct_raster_worker_pool_(direct_raster_worker_pool.Pass()), | |
| 142 did_finish_running_tasks_pending_count_(0u), | |
| 143 did_finish_running_tasks_required_for_activation_pending_count_(0u) { | |
| 144 raster_worker_pool_->SetClient(this); | |
| 145 direct_raster_worker_pool_->SetClient(this); | |
| 146 } | |
| 147 | |
| 148 void SetClient(RasterWorkerPoolClient* client) { client_ = client; } | |
| 149 | |
| 150 void Shutdown() { | |
| 151 raster_worker_pool_->Shutdown(); | |
| 152 direct_raster_worker_pool_->Shutdown(); | |
| 153 } | |
| 154 | |
| 155 void ScheduleTasks(RasterTaskQueue* raster_queue, | |
| 156 RasterTaskQueue* direct_raster_queue) { | |
| 157 raster_worker_pool_->ScheduleTasks(raster_queue); | |
| 158 direct_raster_worker_pool_->ScheduleTasks(direct_raster_queue); | |
| 159 | |
| 160 did_finish_running_tasks_pending_count_ = 2u; | |
| 161 did_finish_running_tasks_required_for_activation_pending_count_ = 2u; | |
| 162 } | |
| 163 | |
| 164 void CheckForCompletedTasks() { | |
| 165 raster_worker_pool_->CheckForCompletedTasks(); | |
| 166 direct_raster_worker_pool_->CheckForCompletedTasks(); | |
| 167 } | |
| 168 | |
| 169 // Overriden from RasterWorkerPoolClient: | |
| 170 virtual bool ShouldForceTasksRequiredForActivationToComplete() | |
| 171 const OVERRIDE { | |
| 172 return client_->ShouldForceTasksRequiredForActivationToComplete(); | |
| 173 } | |
| 174 virtual void DidFinishRunningTasks() OVERRIDE { | |
| 175 DCHECK_LT(0u, did_finish_running_tasks_pending_count_); | |
| 176 if (--did_finish_running_tasks_pending_count_) | |
| 177 return; | |
| 178 client_->DidFinishRunningTasks(); | |
| 179 } | |
| 180 virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE { | |
| 181 DCHECK_LT(0u, | |
| 182 did_finish_running_tasks_required_for_activation_pending_count_); | |
| 183 if (--did_finish_running_tasks_required_for_activation_pending_count_) | |
| 184 return; | |
| 185 client_->DidFinishRunningTasksRequiredForActivation(); | |
| 186 } | |
| 187 | |
| 188 private: | |
| 189 RasterWorkerPoolClient* client_; | |
| 190 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | |
| 191 scoped_ptr<RasterWorkerPool> direct_raster_worker_pool_; | |
| 192 size_t did_finish_running_tasks_pending_count_; | |
| 193 size_t did_finish_running_tasks_required_for_activation_pending_count_; | |
| 194 }; | |
| 195 | |
| 135 RasterTaskCompletionStats::RasterTaskCompletionStats() | 196 RasterTaskCompletionStats::RasterTaskCompletionStats() |
| 136 : completed_count(0u), canceled_count(0u) {} | 197 : completed_count(0u), canceled_count(0u) {} |
| 137 | 198 |
| 138 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 199 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |
| 139 const RasterTaskCompletionStats& stats) { | 200 const RasterTaskCompletionStats& stats) { |
| 140 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 201 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 141 state->SetInteger("completed_count", stats.completed_count); | 202 state->SetInteger("completed_count", stats.completed_count); |
| 142 state->SetInteger("canceled_count", stats.canceled_count); | 203 state->SetInteger("canceled_count", stats.canceled_count); |
| 143 return state.PassAs<base::Value>(); | 204 return state.PassAs<base::Value>(); |
| 144 } | 205 } |
| 145 | 206 |
| 146 // static | 207 // static |
| 147 scoped_ptr<TileManager> TileManager::Create( | 208 scoped_ptr<TileManager> TileManager::Create( |
| 148 TileManagerClient* client, | 209 TileManagerClient* client, |
| 149 ResourceProvider* resource_provider, | 210 ResourceProvider* resource_provider, |
| 150 ContextProvider* context_provider, | 211 ContextProvider* context_provider, |
| 151 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 212 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 152 bool use_map_image, | 213 bool use_map_image, |
| 153 bool use_rasterize_on_demand, | 214 bool use_rasterize_on_demand, |
| 154 size_t max_transfer_buffer_usage_bytes, | 215 size_t max_transfer_buffer_usage_bytes, |
| 155 size_t max_raster_usage_bytes, | 216 size_t max_raster_usage_bytes, |
| 156 unsigned map_image_texture_target) { | 217 unsigned map_image_texture_target) { |
| 157 return make_scoped_ptr(new TileManager( | 218 return make_scoped_ptr(new TileManager( |
| 158 client, | 219 client, |
| 159 resource_provider, | 220 resource_provider, |
| 160 use_map_image | 221 context_provider, |
| 161 ? ImageRasterWorkerPool::Create( | 222 use_map_image ? ImageRasterWorkerPool::Create(resource_provider, |
| 162 resource_provider, context_provider, map_image_texture_target) | 223 map_image_texture_target) |
| 163 : PixelBufferRasterWorkerPool::Create( | 224 : PixelBufferRasterWorkerPool::Create( |
| 164 resource_provider, | 225 resource_provider, max_transfer_buffer_usage_bytes), |
| 165 context_provider, | 226 DirectRasterWorkerPool::Create(resource_provider, context_provider), |
|
alokp
2014/02/14 18:50:59
I was under the impression that we would create a
reveman
2014/02/14 23:30:52
Yes, that might be what we want to do long term bu
| |
| 166 max_transfer_buffer_usage_bytes), | |
| 167 max_raster_usage_bytes, | 227 max_raster_usage_bytes, |
| 168 rendering_stats_instrumentation, | 228 rendering_stats_instrumentation, |
| 169 use_rasterize_on_demand)); | 229 use_rasterize_on_demand)); |
| 170 } | 230 } |
| 171 | 231 |
| 172 TileManager::TileManager( | 232 TileManager::TileManager( |
| 173 TileManagerClient* client, | 233 TileManagerClient* client, |
| 174 ResourceProvider* resource_provider, | 234 ResourceProvider* resource_provider, |
| 235 ContextProvider* context_provider, | |
| 175 scoped_ptr<RasterWorkerPool> raster_worker_pool, | 236 scoped_ptr<RasterWorkerPool> raster_worker_pool, |
| 237 scoped_ptr<RasterWorkerPool> direct_raster_worker_pool, | |
| 176 size_t max_raster_usage_bytes, | 238 size_t max_raster_usage_bytes, |
| 177 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 239 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 178 bool use_rasterize_on_demand) | 240 bool use_rasterize_on_demand) |
| 179 : client_(client), | 241 : client_(client), |
| 242 resource_format_(raster_worker_pool->GetResourceFormat()), | |
| 180 resource_pool_( | 243 resource_pool_( |
| 181 ResourcePool::Create(resource_provider, | 244 ResourcePool::Create(resource_provider, |
| 182 raster_worker_pool->GetResourceTarget(), | 245 raster_worker_pool->GetResourceTarget(), |
| 183 raster_worker_pool->GetResourceFormat())), | 246 resource_format_)), |
| 184 raster_worker_pool_(raster_worker_pool.Pass()), | 247 raster_worker_pool_( |
| 248 new RasterWorkerPoolDelegate(raster_worker_pool.Pass(), | |
| 249 direct_raster_worker_pool.Pass())), | |
| 185 prioritized_tiles_dirty_(false), | 250 prioritized_tiles_dirty_(false), |
| 186 all_tiles_that_need_to_be_rasterized_have_memory_(true), | 251 all_tiles_that_need_to_be_rasterized_have_memory_(true), |
| 187 all_tiles_required_for_activation_have_memory_(true), | 252 all_tiles_required_for_activation_have_memory_(true), |
| 188 memory_required_bytes_(0), | 253 memory_required_bytes_(0), |
| 189 memory_nice_to_have_bytes_(0), | 254 memory_nice_to_have_bytes_(0), |
| 190 bytes_releasable_(0), | 255 bytes_releasable_(0), |
| 191 resources_releasable_(0), | 256 resources_releasable_(0), |
| 192 max_raster_usage_bytes_(max_raster_usage_bytes), | 257 max_raster_usage_bytes_(max_raster_usage_bytes), |
| 193 ever_exceeded_memory_budget_(false), | 258 ever_exceeded_memory_budget_(false), |
| 194 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 259 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 195 did_initialize_visible_tile_(false), | 260 did_initialize_visible_tile_(false), |
| 196 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 261 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| 197 use_rasterize_on_demand_(use_rasterize_on_demand) { | 262 use_rasterize_on_demand_(use_rasterize_on_demand) { |
| 198 raster_worker_pool_->SetClient(this); | 263 raster_worker_pool_->SetClient(this); |
| 199 } | 264 } |
| 200 | 265 |
| 201 TileManager::~TileManager() { | 266 TileManager::~TileManager() { |
| 202 // Reset global state and manage. This should cause | 267 // Reset global state and manage. This should cause |
| 203 // our memory usage to drop to zero. | 268 // our memory usage to drop to zero. |
| 204 global_state_ = GlobalStateThatImpactsTilePriority(); | 269 global_state_ = GlobalStateThatImpactsTilePriority(); |
| 205 | 270 |
| 206 CleanUpReleasedTiles(); | 271 CleanUpReleasedTiles(); |
| 207 DCHECK_EQ(0u, tiles_.size()); | 272 DCHECK_EQ(0u, tiles_.size()); |
| 208 | 273 |
| 209 RasterWorkerPool::RasterTask::Queue empty; | 274 RasterTaskQueue empty; |
| 210 raster_worker_pool_->ScheduleTasks(&empty); | 275 raster_worker_pool_->ScheduleTasks(&empty, &empty); |
| 211 | 276 |
| 212 // This should finish all pending tasks and release any uninitialized | 277 // This should finish all pending tasks and release any uninitialized |
| 213 // resources. | 278 // resources. |
| 214 raster_worker_pool_->Shutdown(); | 279 raster_worker_pool_->Shutdown(); |
| 215 raster_worker_pool_->CheckForCompletedTasks(); | 280 raster_worker_pool_->CheckForCompletedTasks(); |
| 216 | 281 |
| 217 DCHECK_EQ(0u, bytes_releasable_); | 282 DCHECK_EQ(0u, bytes_releasable_); |
| 218 DCHECK_EQ(0u, resources_releasable_); | 283 DCHECK_EQ(0u, resources_releasable_); |
| 219 } | 284 } |
| 220 | 285 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 const TreePriority tree_priority = global_state_.tree_priority; | 404 const TreePriority tree_priority = global_state_.tree_priority; |
| 340 | 405 |
| 341 // For each tree, bin into different categories of tiles. | 406 // For each tree, bin into different categories of tiles. |
| 342 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 407 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 343 Tile* tile = it->second; | 408 Tile* tile = it->second; |
| 344 ManagedTileState& mts = tile->managed_state(); | 409 ManagedTileState& mts = tile->managed_state(); |
| 345 | 410 |
| 346 const ManagedTileState::TileVersion& tile_version = | 411 const ManagedTileState::TileVersion& tile_version = |
| 347 tile->GetTileVersionForDrawing(); | 412 tile->GetTileVersionForDrawing(); |
| 348 bool tile_is_ready_to_draw = tile_version.IsReadyToDraw(); | 413 bool tile_is_ready_to_draw = tile_version.IsReadyToDraw(); |
| 349 bool tile_is_active = | 414 bool tile_is_active = tile_is_ready_to_draw || |
| 350 tile_is_ready_to_draw || | 415 mts.tile_versions[mts.raster_mode].raster_task_; |
| 351 !mts.tile_versions[mts.raster_mode].raster_task_.is_null(); | |
| 352 | 416 |
| 353 // Get the active priority and bin. | 417 // Get the active priority and bin. |
| 354 TilePriority active_priority = tile->priority(ACTIVE_TREE); | 418 TilePriority active_priority = tile->priority(ACTIVE_TREE); |
| 355 ManagedTileBin active_bin = BinFromTilePriority(active_priority); | 419 ManagedTileBin active_bin = BinFromTilePriority(active_priority); |
| 356 | 420 |
| 357 // Get the pending priority and bin. | 421 // Get the pending priority and bin. |
| 358 TilePriority pending_priority = tile->priority(PENDING_TREE); | 422 TilePriority pending_priority = tile->priority(PENDING_TREE); |
| 359 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); | 423 ManagedTileBin pending_bin = BinFromTilePriority(pending_priority); |
| 360 | 424 |
| 361 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION; | 425 bool pending_is_low_res = pending_priority.resolution == LOW_RESOLUTION; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 tile_resources++; | 721 tile_resources++; |
| 658 } | 722 } |
| 659 } | 723 } |
| 660 | 724 |
| 661 // Allow lower priority tiles with initialized resources to keep | 725 // Allow lower priority tiles with initialized resources to keep |
| 662 // their memory by only assigning memory to new raster tasks if | 726 // their memory by only assigning memory to new raster tasks if |
| 663 // they can be scheduled. | 727 // they can be scheduled. |
| 664 if (raster_bytes_if_rastered <= max_raster_bytes) { | 728 if (raster_bytes_if_rastered <= max_raster_bytes) { |
| 665 // If we don't have the required version, and it's not in flight | 729 // If we don't have the required version, and it's not in flight |
| 666 // then we'll have to pay to create a new task. | 730 // then we'll have to pay to create a new task. |
| 667 if (!tile_version.resource_ && tile_version.raster_task_.is_null()) { | 731 if (!tile_version.resource_ && !tile_version.raster_task_) { |
| 668 tile_bytes += bytes_if_allocated; | 732 tile_bytes += bytes_if_allocated; |
| 669 tile_resources++; | 733 tile_resources++; |
| 670 } | 734 } |
| 671 } | 735 } |
| 672 | 736 |
| 673 // Tile is OOM. | 737 // Tile is OOM. |
| 674 if (tile_bytes > bytes_left || tile_resources > resources_left) { | 738 if (tile_bytes > bytes_left || tile_resources > resources_left) { |
| 675 FreeResourcesForTile(tile); | 739 FreeResourcesForTile(tile); |
| 676 | 740 |
| 677 // This tile was already on screen and now its resources have been | 741 // This tile was already on screen and now its resources have been |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 | 833 |
| 770 void TileManager::ScheduleTasks( | 834 void TileManager::ScheduleTasks( |
| 771 const TileVector& tiles_that_need_to_be_rasterized) { | 835 const TileVector& tiles_that_need_to_be_rasterized) { |
| 772 TRACE_EVENT1("cc", | 836 TRACE_EVENT1("cc", |
| 773 "TileManager::ScheduleTasks", | 837 "TileManager::ScheduleTasks", |
| 774 "count", | 838 "count", |
| 775 tiles_that_need_to_be_rasterized.size()); | 839 tiles_that_need_to_be_rasterized.size()); |
| 776 | 840 |
| 777 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); | 841 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); |
| 778 | 842 |
| 779 raster_tasks_.Reset(); | 843 raster_queue_.Reset(); |
| 844 gpu_raster_queue_.Reset(); | |
| 780 | 845 |
| 781 // Build a new task queue containing all task currently needed. Tasks | 846 // Build a new task queue containing all task currently needed. Tasks |
| 782 // are added in order of priority, highest priority task first. | 847 // are added in order of priority, highest priority task first. |
| 783 for (TileVector::const_iterator it = tiles_that_need_to_be_rasterized.begin(); | 848 for (TileVector::const_iterator it = tiles_that_need_to_be_rasterized.begin(); |
| 784 it != tiles_that_need_to_be_rasterized.end(); | 849 it != tiles_that_need_to_be_rasterized.end(); |
| 785 ++it) { | 850 ++it) { |
| 786 Tile* tile = *it; | 851 Tile* tile = *it; |
| 787 ManagedTileState& mts = tile->managed_state(); | 852 ManagedTileState& mts = tile->managed_state(); |
| 788 ManagedTileState::TileVersion& tile_version = | 853 ManagedTileState::TileVersion& tile_version = |
| 789 mts.tile_versions[mts.raster_mode]; | 854 mts.tile_versions[mts.raster_mode]; |
| 790 | 855 |
| 791 DCHECK(tile_version.requires_resource()); | 856 DCHECK(tile_version.requires_resource()); |
| 792 DCHECK(!tile_version.resource_); | 857 DCHECK(!tile_version.resource_); |
| 793 | 858 |
| 794 if (tile_version.raster_task_.is_null()) | 859 if (!tile_version.raster_task_) |
| 795 tile_version.raster_task_ = CreateRasterTask(tile); | 860 tile_version.raster_task_ = CreateRasterTask(tile); |
| 796 | 861 |
| 797 raster_tasks_.Append(tile_version.raster_task_, | 862 if (tile->use_gpu_rasterization()) { |
| 798 tile->required_for_activation()); | 863 gpu_raster_queue_.tasks.push_back(RasterTaskQueue::Task( |
| 864 tile_version.raster_task_.get(), tile->required_for_activation())); | |
| 865 gpu_raster_queue_.required_for_activation_count += | |
| 866 tile->required_for_activation(); | |
| 867 } else { | |
| 868 raster_queue_.tasks.push_back(RasterTaskQueue::Task( | |
| 869 tile_version.raster_task_.get(), tile->required_for_activation())); | |
| 870 raster_queue_.required_for_activation_count += | |
| 871 tile->required_for_activation(); | |
| 872 } | |
| 799 } | 873 } |
| 800 | 874 |
| 801 // We must reduce the amount of unused resoruces before calling | 875 // We must reduce the amount of unused resoruces before calling |
| 802 // ScheduleTasks to prevent usage from rising above limits. | 876 // ScheduleTasks to prevent usage from rising above limits. |
| 803 resource_pool_->ReduceResourceUsage(); | 877 resource_pool_->ReduceResourceUsage(); |
| 804 | 878 |
| 805 // Schedule running of |raster_tasks_|. This replaces any previously | 879 // Schedule running of |raster_tasks_|. This replaces any previously |
| 806 // scheduled tasks and effectively cancels all tasks not present | 880 // scheduled tasks and effectively cancels all tasks not present |
| 807 // in |raster_tasks_|. | 881 // in |raster_tasks_|. |
| 808 raster_worker_pool_->ScheduleTasks(&raster_tasks_); | 882 raster_worker_pool_->ScheduleTasks(&raster_queue_, &gpu_raster_queue_); |
| 809 | 883 |
| 810 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 884 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
| 811 } | 885 } |
| 812 | 886 |
| 813 RasterWorkerPool::Task TileManager::CreateImageDecodeTask( | 887 scoped_refptr<internal::WorkerPoolTask> TileManager::CreateImageDecodeTask( |
| 814 Tile* tile, | 888 Tile* tile, |
| 815 SkPixelRef* pixel_ref) { | 889 SkPixelRef* pixel_ref) { |
| 816 return RasterWorkerPool::CreateImageDecodeTask( | 890 return RasterWorkerPool::CreateImageDecodeTask( |
| 817 pixel_ref, | 891 pixel_ref, |
| 818 tile->layer_id(), | 892 tile->layer_id(), |
| 819 rendering_stats_instrumentation_, | 893 rendering_stats_instrumentation_, |
| 820 base::Bind(&TileManager::OnImageDecodeTaskCompleted, | 894 base::Bind(&TileManager::OnImageDecodeTaskCompleted, |
| 821 base::Unretained(this), | 895 base::Unretained(this), |
| 822 tile->layer_id(), | 896 tile->layer_id(), |
| 823 base::Unretained(pixel_ref))); | 897 base::Unretained(pixel_ref))); |
| 824 } | 898 } |
| 825 | 899 |
| 826 RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { | 900 scoped_refptr<internal::RasterWorkerPoolTask> TileManager::CreateRasterTask( |
| 901 Tile* tile) { | |
| 827 ManagedTileState& mts = tile->managed_state(); | 902 ManagedTileState& mts = tile->managed_state(); |
| 828 | 903 |
| 829 scoped_ptr<ScopedResource> resource = | 904 scoped_ptr<ScopedResource> resource = |
| 830 resource_pool_->AcquireResource(tile->tile_size_.size()); | 905 resource_pool_->AcquireResource(tile->tile_size_.size()); |
| 831 const ScopedResource* const_resource = resource.get(); | 906 const ScopedResource* const_resource = resource.get(); |
| 832 | 907 |
| 833 // Create and queue all image decode tasks that this tile depends on. | 908 // Create and queue all image decode tasks that this tile depends on. |
| 834 RasterWorkerPool::Task::Set decode_tasks; | 909 internal::WorkerPoolTask::Vector decode_tasks; |
| 835 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; | 910 PixelRefTaskMap& existing_pixel_refs = image_decode_tasks_[tile->layer_id()]; |
| 836 for (PicturePileImpl::PixelRefIterator iter( | 911 for (PicturePileImpl::PixelRefIterator iter( |
| 837 tile->content_rect(), tile->contents_scale(), tile->picture_pile()); | 912 tile->content_rect(), tile->contents_scale(), tile->picture_pile()); |
| 838 iter; | 913 iter; |
| 839 ++iter) { | 914 ++iter) { |
| 840 SkPixelRef* pixel_ref = *iter; | 915 SkPixelRef* pixel_ref = *iter; |
| 841 uint32_t id = pixel_ref->getGenerationID(); | 916 uint32_t id = pixel_ref->getGenerationID(); |
| 842 | 917 |
| 843 // Append existing image decode task if available. | 918 // Append existing image decode task if available. |
| 844 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id); | 919 PixelRefTaskMap::iterator decode_task_it = existing_pixel_refs.find(id); |
| 845 if (decode_task_it != existing_pixel_refs.end()) { | 920 if (decode_task_it != existing_pixel_refs.end()) { |
| 846 decode_tasks.Insert(decode_task_it->second); | 921 decode_tasks.push_back(decode_task_it->second); |
| 847 continue; | 922 continue; |
| 848 } | 923 } |
| 849 | 924 |
| 850 // Create and append new image decode task for this pixel ref. | 925 // Create and append new image decode task for this pixel ref. |
| 851 RasterWorkerPool::Task decode_task = CreateImageDecodeTask(tile, pixel_ref); | 926 scoped_refptr<internal::WorkerPoolTask> decode_task = |
| 852 decode_tasks.Insert(decode_task); | 927 CreateImageDecodeTask(tile, pixel_ref); |
| 928 decode_tasks.push_back(decode_task); | |
| 853 existing_pixel_refs[id] = decode_task; | 929 existing_pixel_refs[id] = decode_task; |
| 854 } | 930 } |
| 855 | 931 |
| 856 return RasterWorkerPool::CreateRasterTask( | 932 return RasterWorkerPool::CreateRasterTask( |
| 857 const_resource, | 933 const_resource, |
| 858 tile->picture_pile(), | 934 tile->picture_pile(), |
| 859 tile->content_rect(), | 935 tile->content_rect(), |
| 860 tile->contents_scale(), | 936 tile->contents_scale(), |
| 861 mts.raster_mode, | 937 mts.raster_mode, |
| 862 mts.resolution, | 938 mts.resolution, |
| 863 tile->layer_id(), | 939 tile->layer_id(), |
| 864 static_cast<const void*>(tile), | 940 static_cast<const void*>(tile), |
| 865 tile->source_frame_number(), | 941 tile->source_frame_number(), |
| 866 tile->use_gpu_rasterization(), | |
| 867 rendering_stats_instrumentation_, | 942 rendering_stats_instrumentation_, |
| 868 base::Bind(&TileManager::OnRasterTaskCompleted, | 943 base::Bind(&TileManager::OnRasterTaskCompleted, |
| 869 base::Unretained(this), | 944 base::Unretained(this), |
| 870 tile->id(), | 945 tile->id(), |
| 871 base::Passed(&resource), | 946 base::Passed(&resource), |
| 872 mts.raster_mode), | 947 mts.raster_mode), |
| 873 &decode_tasks); | 948 &decode_tasks, |
| 949 context_provider_); | |
| 874 } | 950 } |
| 875 | 951 |
| 876 void TileManager::OnImageDecodeTaskCompleted(int layer_id, | 952 void TileManager::OnImageDecodeTaskCompleted(int layer_id, |
| 877 SkPixelRef* pixel_ref, | 953 SkPixelRef* pixel_ref, |
| 878 bool was_canceled) { | 954 bool was_canceled) { |
| 879 // If the task was canceled, we need to clean it up | 955 // If the task was canceled, we need to clean it up |
| 880 // from |image_decode_tasks_|. | 956 // from |image_decode_tasks_|. |
| 881 if (!was_canceled) | 957 if (!was_canceled) |
| 882 return; | 958 return; |
| 883 | 959 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 903 TileMap::iterator it = tiles_.find(tile_id); | 979 TileMap::iterator it = tiles_.find(tile_id); |
| 904 if (it == tiles_.end()) { | 980 if (it == tiles_.end()) { |
| 905 ++update_visible_tiles_stats_.canceled_count; | 981 ++update_visible_tiles_stats_.canceled_count; |
| 906 resource_pool_->ReleaseResource(resource.Pass()); | 982 resource_pool_->ReleaseResource(resource.Pass()); |
| 907 return; | 983 return; |
| 908 } | 984 } |
| 909 | 985 |
| 910 Tile* tile = it->second; | 986 Tile* tile = it->second; |
| 911 ManagedTileState& mts = tile->managed_state(); | 987 ManagedTileState& mts = tile->managed_state(); |
| 912 ManagedTileState::TileVersion& tile_version = mts.tile_versions[raster_mode]; | 988 ManagedTileState::TileVersion& tile_version = mts.tile_versions[raster_mode]; |
| 913 DCHECK(!tile_version.raster_task_.is_null()); | 989 DCHECK(tile_version.raster_task_); |
| 914 tile_version.raster_task_.Reset(); | 990 tile_version.raster_task_ = NULL; |
| 915 | 991 |
| 916 if (was_canceled) { | 992 if (was_canceled) { |
| 917 ++update_visible_tiles_stats_.canceled_count; | 993 ++update_visible_tiles_stats_.canceled_count; |
| 918 resource_pool_->ReleaseResource(resource.Pass()); | 994 resource_pool_->ReleaseResource(resource.Pass()); |
| 919 return; | 995 return; |
| 920 } | 996 } |
| 921 | 997 |
| 922 ++update_visible_tiles_stats_.completed_count; | 998 ++update_visible_tiles_stats_.completed_count; |
| 923 | 999 |
| 924 tile_version.set_has_text(analysis.has_text); | 1000 tile_version.set_has_text(analysis.has_text); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 flags)); | 1033 flags)); |
| 958 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 1034 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
| 959 | 1035 |
| 960 tiles_[tile->id()] = tile; | 1036 tiles_[tile->id()] = tile; |
| 961 used_layer_counts_[tile->layer_id()]++; | 1037 used_layer_counts_[tile->layer_id()]++; |
| 962 prioritized_tiles_dirty_ = true; | 1038 prioritized_tiles_dirty_ = true; |
| 963 return tile; | 1039 return tile; |
| 964 } | 1040 } |
| 965 | 1041 |
| 966 } // namespace cc | 1042 } // namespace cc |
| OLD | NEW |