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/base/math_util.h" | |
15 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
16 #include "cc/debug/traced_value.h" | 17 #include "cc/debug/traced_value.h" |
17 #include "cc/layers/picture_layer_impl.h" | 18 #include "cc/layers/picture_layer_impl.h" |
18 #include "cc/resources/direct_raster_worker_pool.h" | 19 #include "cc/resources/direct_raster_worker_pool.h" |
19 #include "cc/resources/image_raster_worker_pool.h" | 20 #include "cc/resources/image_raster_worker_pool.h" |
20 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 21 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
21 #include "cc/resources/raster_worker_pool_delegate.h" | 22 #include "cc/resources/raster_worker_pool_delegate.h" |
22 #include "cc/resources/tile.h" | 23 #include "cc/resources/tile.h" |
23 #include "skia/ext/paint_simplifier.h" | 24 #include "skia/ext/paint_simplifier.h" |
24 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 456 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
456 did_initialize_visible_tile_(false), | 457 did_initialize_visible_tile_(false), |
457 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 458 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
458 use_rasterize_on_demand_(use_rasterize_on_demand) { | 459 use_rasterize_on_demand_(use_rasterize_on_demand) { |
459 RasterWorkerPool* raster_worker_pools[NUM_RASTER_WORKER_POOL_TYPES] = { | 460 RasterWorkerPool* raster_worker_pools[NUM_RASTER_WORKER_POOL_TYPES] = { |
460 raster_worker_pool_.get(), // RASTER_WORKER_POOL_TYPE_DEFAULT | 461 raster_worker_pool_.get(), // RASTER_WORKER_POOL_TYPE_DEFAULT |
461 direct_raster_worker_pool_.get() // RASTER_WORKER_POOL_TYPE_DIRECT | 462 direct_raster_worker_pool_.get() // RASTER_WORKER_POOL_TYPE_DIRECT |
462 }; | 463 }; |
463 raster_worker_pool_delegate_ = RasterWorkerPoolDelegate::Create( | 464 raster_worker_pool_delegate_ = RasterWorkerPoolDelegate::Create( |
464 this, raster_worker_pools, arraysize(raster_worker_pools)); | 465 this, raster_worker_pools, arraysize(raster_worker_pools)); |
466 damage_rect_ = gfx::Rect(0, 0, 0, 0); | |
465 } | 467 } |
466 | 468 |
467 TileManager::~TileManager() { | 469 TileManager::~TileManager() { |
468 // Reset global state and manage. This should cause | 470 // Reset global state and manage. This should cause |
469 // our memory usage to drop to zero. | 471 // our memory usage to drop to zero. |
470 global_state_ = GlobalStateThatImpactsTilePriority(); | 472 global_state_ = GlobalStateThatImpactsTilePriority(); |
471 | 473 |
472 CleanUpReleasedTiles(); | 474 CleanUpReleasedTiles(); |
473 DCHECK_EQ(0u, tiles_.size()); | 475 DCHECK_EQ(0u, tiles_.size()); |
474 | 476 |
475 RasterTaskQueue empty[NUM_RASTER_WORKER_POOL_TYPES]; | 477 RasterTaskQueue empty[NUM_RASTER_WORKER_POOL_TYPES]; |
476 raster_worker_pool_delegate_->ScheduleTasks(empty); | 478 raster_worker_pool_delegate_->ScheduleTasks(empty); |
477 orphan_raster_tasks_.clear(); | 479 orphan_raster_tasks_.clear(); |
478 | 480 |
479 // This should finish all pending tasks and release any uninitialized | 481 // This should finish all pending tasks and release any uninitialized |
480 // resources. | 482 // resources. |
481 raster_worker_pool_delegate_->Shutdown(); | 483 raster_worker_pool_delegate_->Shutdown(); |
482 raster_worker_pool_delegate_->CheckForCompletedTasks(); | 484 raster_worker_pool_delegate_->CheckForCompletedTasks(); |
483 | 485 |
484 DCHECK_EQ(0u, bytes_releasable_); | 486 DCHECK_EQ(0u, bytes_releasable_); |
485 DCHECK_EQ(0u, resources_releasable_); | 487 DCHECK_EQ(0u, resources_releasable_); |
486 | 488 |
487 for (std::vector<PictureLayerImpl*>::iterator it = layers_.begin(); | 489 for (std::vector<PictureLayerImpl*>::iterator it = layers_.begin(); |
488 it != layers_.end(); | 490 it != layers_.end(); |
489 ++it) { | 491 ++it) { |
490 (*it)->DidUnregisterLayer(); | 492 (*it)->DidUnregisterLayer(); |
491 } | 493 } |
492 layers_.clear(); | 494 layers_.clear(); |
495 tilemap_.clear(); | |
493 } | 496 } |
494 | 497 |
495 void TileManager::Release(Tile* tile) { | 498 void TileManager::Release(Tile* tile) { |
496 prioritized_tiles_dirty_ = true; | 499 prioritized_tiles_dirty_ = true; |
497 released_tiles_.push_back(tile); | 500 released_tiles_.push_back(tile); |
498 } | 501 } |
499 | 502 |
503 void TileManager::ResetTileRectLayerMap() { | |
504 for (std::map<int, gfx::Rect>::iterator it = tilemap_.begin(); | |
505 it != tilemap_.end(); | |
506 ++it) { | |
507 it->second = gfx::Rect(0, 0, 0, 0); | |
508 } | |
509 } | |
reveman
2014/04/11 18:11:34
all this tilemap stuff is confusing and inefficien
sohanjg
2014/04/14 10:16:11
Done.
| |
510 | |
511 std::map<int, gfx::Rect> TileManager::GetTileRectLayerMap() { return tilemap_; } | |
512 | |
500 void TileManager::DidChangeTilePriority(Tile* tile) { | 513 void TileManager::DidChangeTilePriority(Tile* tile) { |
501 prioritized_tiles_dirty_ = true; | 514 prioritized_tiles_dirty_ = true; |
502 } | 515 } |
503 | 516 |
504 bool TileManager::ShouldForceTasksRequiredForActivationToComplete() const { | 517 bool TileManager::ShouldForceTasksRequiredForActivationToComplete() const { |
505 return global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY; | 518 return global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY; |
506 } | 519 } |
507 | 520 |
508 void TileManager::CleanUpReleasedTiles() { | 521 void TileManager::CleanUpReleasedTiles() { |
509 for (std::vector<Tile*>::iterator it = released_tiles_.begin(); | 522 for (std::vector<Tile*>::iterator it = released_tiles_.begin(); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1225 DCHECK(tile_version.raster_task_); | 1238 DCHECK(tile_version.raster_task_); |
1226 orphan_raster_tasks_.push_back(tile_version.raster_task_); | 1239 orphan_raster_tasks_.push_back(tile_version.raster_task_); |
1227 tile_version.raster_task_ = NULL; | 1240 tile_version.raster_task_ = NULL; |
1228 | 1241 |
1229 if (was_canceled) { | 1242 if (was_canceled) { |
1230 ++update_visible_tiles_stats_.canceled_count; | 1243 ++update_visible_tiles_stats_.canceled_count; |
1231 resource_pool_->ReleaseResource(resource.Pass()); | 1244 resource_pool_->ReleaseResource(resource.Pass()); |
1232 return; | 1245 return; |
1233 } | 1246 } |
1234 | 1247 |
1248 // Maintain a map of unioned intialized tile rect and layer-id. | |
1249 tilemap_[tile->layer_id()] = | |
1250 gfx::UnionRects(tilemap_[tile->layer_id()], tile->content_rect()); | |
1251 | |
1235 ++update_visible_tiles_stats_.completed_count; | 1252 ++update_visible_tiles_stats_.completed_count; |
1236 | 1253 |
1237 tile_version.set_has_text(analysis.has_text); | 1254 tile_version.set_has_text(analysis.has_text); |
1238 if (analysis.is_solid_color) { | 1255 if (analysis.is_solid_color) { |
1239 tile_version.set_solid_color(analysis.solid_color); | 1256 tile_version.set_solid_color(analysis.solid_color); |
1240 resource_pool_->ReleaseResource(resource.Pass()); | 1257 resource_pool_->ReleaseResource(resource.Pass()); |
1241 } else { | 1258 } else { |
1242 tile_version.set_use_resource(); | 1259 tile_version.set_use_resource(); |
1243 tile_version.resource_ = resource.Pass(); | 1260 tile_version.resource_ = resource.Pass(); |
1244 | 1261 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1526 b_tile->priority(b_pair.second), | 1543 b_tile->priority(b_pair.second), |
1527 false /* prioritize low res */); | 1544 false /* prioritize low res */); |
1528 } | 1545 } |
1529 | 1546 |
1530 NOTREACHED(); | 1547 NOTREACHED(); |
1531 // Keep the compiler happy. | 1548 // Keep the compiler happy. |
1532 return false; | 1549 return false; |
1533 } | 1550 } |
1534 | 1551 |
1535 } // namespace cc | 1552 } // namespace cc |
OLD | NEW |