| 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/tiles/tile_manager.h" | 5 #include "cc/tiles/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 "base/numerics/safe_conversions.h" | 15 #include "base/numerics/safe_conversions.h" |
| 16 #include "base/trace_event/trace_event_argument.h" | 16 #include "base/trace_event/trace_event_argument.h" |
| 17 #include "cc/base/histograms.h" | 17 #include "cc/base/histograms.h" |
| 18 #include "cc/debug/devtools_instrumentation.h" | 18 #include "cc/debug/devtools_instrumentation.h" |
| 19 #include "cc/debug/frame_viewer_instrumentation.h" | 19 #include "cc/debug/frame_viewer_instrumentation.h" |
| 20 #include "cc/debug/traced_value.h" | 20 #include "cc/debug/traced_value.h" |
| 21 #include "cc/layers/picture_layer_impl.h" | 21 #include "cc/layers/picture_layer_impl.h" |
| 22 #include "cc/raster/raster_buffer.h" | 22 #include "cc/raster/raster_buffer.h" |
| 23 #include "cc/raster/tile_task_runner.h" | 23 #include "cc/raster/tile_task_runner.h" |
| 24 #include "cc/tiles/tile.h" | 24 #include "cc/tiles/tile.h" |
| 25 #include "ui/gfx/geometry/rect_conversions.h" | 25 #include "ui/gfx/geometry/rect_conversions.h" |
| 26 | 26 |
| 27 #include "ui/gfx/transform.h" |
| 27 namespace cc { | 28 namespace cc { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // Flag to indicate whether we should try and detect that | 31 // Flag to indicate whether we should try and detect that |
| 31 // a tile is of solid color. | 32 // a tile is of solid color. |
| 32 const bool kUseColorEstimator = true; | 33 const bool kUseColorEstimator = true; |
| 33 | 34 |
| 34 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 35 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
| 35 ScopedRasterTaskTimer, | 36 ScopedRasterTaskTimer, |
| 36 "Compositing.%s.RasterTask.RasterUs", | 37 "Compositing.%s.RasterTask.RasterUs", |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 for (auto* tile : released_tiles_) { | 270 for (auto* tile : released_tiles_) { |
| 270 if (tile->HasRasterTask()) { | 271 if (tile->HasRasterTask()) { |
| 271 tiles_to_retain.push_back(tile); | 272 tiles_to_retain.push_back(tile); |
| 272 continue; | 273 continue; |
| 273 } | 274 } |
| 274 | 275 |
| 275 DCHECK(!tile->draw_info().has_resource()); | 276 DCHECK(!tile->draw_info().has_resource()); |
| 276 DCHECK(tiles_.find(tile->id()) != tiles_.end()); | 277 DCHECK(tiles_.find(tile->id()) != tiles_.end()); |
| 277 tiles_.erase(tile->id()); | 278 tiles_.erase(tile->id()); |
| 278 | 279 |
| 279 image_decode_controller_.SubtractLayerUsedCount(tile->layer_id()); | |
| 280 delete tile; | 280 delete tile; |
| 281 } | 281 } |
| 282 released_tiles_.swap(tiles_to_retain); | 282 released_tiles_.swap(tiles_to_retain); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) { | 285 void TileManager::DidFinishRunningTileTasks(TaskSet task_set) { |
| 286 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set", | 286 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTileTasks", "task_set", |
| 287 TaskSetName(task_set)); | 287 TaskSetName(task_set)); |
| 288 DCHECK(resource_pool_); | 288 DCHECK(resource_pool_); |
| 289 DCHECK(tile_task_runner_); | 289 DCHECK(tile_task_runner_); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 674 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
| 675 DetermineResourceFormat(tile)); | 675 DetermineResourceFormat(tile)); |
| 676 } | 676 } |
| 677 | 677 |
| 678 // Create and queue all image decode tasks that this tile depends on. | 678 // Create and queue all image decode tasks that this tile depends on. |
| 679 ImageDecodeTask::Vector decode_tasks; | 679 ImageDecodeTask::Vector decode_tasks; |
| 680 std::vector<PositionImage> images; | 680 std::vector<PositionImage> images; |
| 681 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 681 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 682 tile->enclosing_layer_rect(), &images); | 682 tile->enclosing_layer_rect(), &images); |
| 683 for (const auto& image : images) { | 683 for (const auto& image : images) { |
| 684 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( | 684 // The images we get have a matrix representing the ctm we would use if we |
| 685 image, tile->layer_id(), prepare_tiles_count_)); | 685 // were to rasterize at scale 1. However, we need to rasterize at |
| 686 // contents_scale, so we should adjust the matrix before querying the |
| 687 // controller. |
| 688 SkMatrix matrix = image.matrix; |
| 689 matrix.preScale(tile->contents_scale(), tile->contents_scale()); |
| 690 const PositionImage& scaled_image = PositionImage( |
| 691 image.image, image.image_rect, matrix, image.filter_quality); |
| 692 |
| 693 scoped_refptr<ImageDecodeTask> task = |
| 694 image_decode_controller_.GetTaskForImage(scaled_image, |
| 695 prepare_tiles_count_); |
| 696 if (task) |
| 697 decode_tasks.push_back(task); |
| 686 } | 698 } |
| 687 | 699 |
| 688 return make_scoped_refptr(new RasterTaskImpl( | 700 return make_scoped_refptr(new RasterTaskImpl( |
| 689 resource, prioritized_tile.raster_source(), tile->content_rect(), | 701 resource, prioritized_tile.raster_source(), tile->content_rect(), |
| 690 tile->invalidated_content_rect(), tile->contents_scale(), | 702 tile->invalidated_content_rect(), tile->contents_scale(), |
| 691 prioritized_tile.priority().resolution, tile->layer_id(), | 703 prioritized_tile.priority().resolution, tile->layer_id(), |
| 692 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), | 704 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), |
| 693 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), | 705 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), |
| 694 tile->use_picture_analysis(), | 706 tile->use_picture_analysis(), |
| 695 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 707 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 int source_frame_number, | 768 int source_frame_number, |
| 757 int flags) { | 769 int flags) { |
| 758 // We need to have a tile task worker pool to do anything meaningful with | 770 // We need to have a tile task worker pool to do anything meaningful with |
| 759 // tiles. | 771 // tiles. |
| 760 DCHECK(tile_task_runner_); | 772 DCHECK(tile_task_runner_); |
| 761 ScopedTilePtr tile( | 773 ScopedTilePtr tile( |
| 762 new Tile(this, info, layer_id, source_frame_number, flags)); | 774 new Tile(this, info, layer_id, source_frame_number, flags)); |
| 763 DCHECK(tiles_.find(tile->id()) == tiles_.end()); | 775 DCHECK(tiles_.find(tile->id()) == tiles_.end()); |
| 764 | 776 |
| 765 tiles_[tile->id()] = tile.get(); | 777 tiles_[tile->id()] = tile.get(); |
| 766 image_decode_controller_.AddLayerUsedCount(tile->layer_id()); | |
| 767 return tile; | 778 return tile; |
| 768 } | 779 } |
| 769 | 780 |
| 770 void TileManager::SetTileTaskRunnerForTesting( | 781 void TileManager::SetTileTaskRunnerForTesting( |
| 771 TileTaskRunner* tile_task_runner) { | 782 TileTaskRunner* tile_task_runner) { |
| 772 tile_task_runner_ = tile_task_runner; | 783 tile_task_runner_ = tile_task_runner; |
| 773 tile_task_runner_->SetClient(this); | 784 tile_task_runner_->SetClient(this); |
| 774 } | 785 } |
| 775 | 786 |
| 776 bool TileManager::AreRequiredTilesReadyToDraw( | 787 bool TileManager::AreRequiredTilesReadyToDraw( |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 void TileManager::Signals::reset() { | 1013 void TileManager::Signals::reset() { |
| 1003 ready_to_activate = false; | 1014 ready_to_activate = false; |
| 1004 did_notify_ready_to_activate = false; | 1015 did_notify_ready_to_activate = false; |
| 1005 ready_to_draw = false; | 1016 ready_to_draw = false; |
| 1006 did_notify_ready_to_draw = false; | 1017 did_notify_ready_to_draw = false; |
| 1007 all_tile_tasks_completed = false; | 1018 all_tile_tasks_completed = false; |
| 1008 did_notify_all_tile_tasks_completed = false; | 1019 did_notify_all_tile_tasks_completed = false; |
| 1009 } | 1020 } |
| 1010 | 1021 |
| 1011 } // namespace cc | 1022 } // namespace cc |
| OLD | NEW |