| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 std::unique_ptr<RasterBuffer> raster_buffer, | 55 std::unique_ptr<RasterBuffer> raster_buffer, |
| 56 TileTask::Vector* dependencies, | 56 TileTask::Vector* dependencies, |
| 57 bool supports_concurrent_execution) | 57 bool supports_concurrent_execution) |
| 58 : TileTask(supports_concurrent_execution, dependencies), | 58 : TileTask(supports_concurrent_execution, dependencies), |
| 59 tile_manager_(tile_manager), | 59 tile_manager_(tile_manager), |
| 60 tile_(tile), | 60 tile_(tile), |
| 61 resource_(resource), | 61 resource_(resource), |
| 62 raster_source_(std::move(raster_source)), | 62 raster_source_(std::move(raster_source)), |
| 63 content_rect_(tile->content_rect()), | 63 content_rect_(tile->content_rect()), |
| 64 invalid_content_rect_(invalidated_rect), | 64 invalid_content_rect_(invalidated_rect), |
| 65 contents_scale_(tile->contents_scale()), | 65 contents_transform_(tile->contents_transform()), |
| 66 playback_settings_(playback_settings), | 66 playback_settings_(playback_settings), |
| 67 tile_resolution_(tile_resolution), | 67 tile_resolution_(tile_resolution), |
| 68 layer_id_(tile->layer_id()), | 68 layer_id_(tile->layer_id()), |
| 69 source_prepare_tiles_id_(source_prepare_tiles_id), | 69 source_prepare_tiles_id_(source_prepare_tiles_id), |
| 70 tile_tracing_id_(static_cast<void*>(tile)), | 70 tile_tracing_id_(static_cast<void*>(tile)), |
| 71 new_content_id_(tile->id()), | 71 new_content_id_(tile->id()), |
| 72 source_frame_number_(tile->source_frame_number()), | 72 source_frame_number_(tile->source_frame_number()), |
| 73 raster_buffer_(std::move(raster_buffer)) { | 73 raster_buffer_(std::move(raster_buffer)) { |
| 74 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 74 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Overridden from Task: | 77 // Overridden from Task: |
| 78 void RunOnWorkerThread() override { | 78 void RunOnWorkerThread() override { |
| 79 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 79 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
| 80 "source_prepare_tiles_id", source_prepare_tiles_id_); | 80 "source_prepare_tiles_id", source_prepare_tiles_id_); |
| 81 | 81 |
| 82 DCHECK(raster_source_.get()); | 82 DCHECK(raster_source_.get()); |
| 83 DCHECK(raster_buffer_); | 83 DCHECK(raster_buffer_); |
| 84 | 84 |
| 85 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 85 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 86 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); | 86 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 87 ScopedRasterTaskTimer timer; | 87 ScopedRasterTaskTimer timer; |
| 88 timer.SetArea(content_rect_.size().GetArea()); | 88 timer.SetArea(content_rect_.size().GetArea()); |
| 89 | 89 |
| 90 DCHECK(raster_source_); | 90 DCHECK(raster_source_); |
| 91 | 91 |
| 92 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 92 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
| 93 invalid_content_rect_, new_content_id_, | 93 invalid_content_rect_, new_content_id_, |
| 94 contents_scale_, playback_settings_); | 94 contents_transform_, playback_settings_); |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Overridden from TileTask: | 97 // Overridden from TileTask: |
| 98 void OnTaskCompleted() override { | 98 void OnTaskCompleted() override { |
| 99 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 99 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 100 | 100 |
| 101 // Here calling state().IsCanceled() is thread-safe, because this task is | 101 // Here calling state().IsCanceled() is thread-safe, because this task is |
| 102 // already concluded as FINISHED or CANCELLED and no longer will be worked | 102 // already concluded as FINISHED or CANCELLED and no longer will be worked |
| 103 // upon by task graph runner. | 103 // upon by task graph runner. |
| 104 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, | 104 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 118 // origin thread. These are not thread-safe and should be accessed only in | 118 // origin thread. These are not thread-safe and should be accessed only in |
| 119 // origin thread. Ensure their access by checking CalledOnValidThread(). | 119 // origin thread. Ensure their access by checking CalledOnValidThread(). |
| 120 TileManager* tile_manager_; | 120 TileManager* tile_manager_; |
| 121 Tile* tile_; | 121 Tile* tile_; |
| 122 Resource* resource_; | 122 Resource* resource_; |
| 123 | 123 |
| 124 // The following members should be used for running the task. | 124 // The following members should be used for running the task. |
| 125 scoped_refptr<RasterSource> raster_source_; | 125 scoped_refptr<RasterSource> raster_source_; |
| 126 gfx::Rect content_rect_; | 126 gfx::Rect content_rect_; |
| 127 gfx::Rect invalid_content_rect_; | 127 gfx::Rect invalid_content_rect_; |
| 128 float contents_scale_; | 128 ScaleTranslate2d contents_transform_; |
| 129 RasterSource::PlaybackSettings playback_settings_; | 129 RasterSource::PlaybackSettings playback_settings_; |
| 130 TileResolution tile_resolution_; | 130 TileResolution tile_resolution_; |
| 131 int layer_id_; | 131 int layer_id_; |
| 132 uint64_t source_prepare_tiles_id_; | 132 uint64_t source_prepare_tiles_id_; |
| 133 void* tile_tracing_id_; | 133 void* tile_tracing_id_; |
| 134 uint64_t new_content_id_; | 134 uint64_t new_content_id_; |
| 135 int source_frame_number_; | 135 int source_frame_number_; |
| 136 std::unique_ptr<RasterBuffer> raster_buffer_; | 136 std::unique_ptr<RasterBuffer> raster_buffer_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 138 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 break; | 634 break; |
| 635 } | 635 } |
| 636 | 636 |
| 637 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; | 637 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; |
| 638 if (tile->use_picture_analysis() && kUseColorEstimator) { | 638 if (tile->use_picture_analysis() && kUseColorEstimator) { |
| 639 // We analyze for solid color here, to decide to continue | 639 // We analyze for solid color here, to decide to continue |
| 640 // or drop the tile for scheduling and raster. | 640 // or drop the tile for scheduling and raster. |
| 641 // TODO(sohanjg): Check if we could use a shared analysis | 641 // TODO(sohanjg): Check if we could use a shared analysis |
| 642 // canvas which is reset between tiles. | 642 // canvas which is reset between tiles. |
| 643 SkColor color = SK_ColorTRANSPARENT; | 643 SkColor color = SK_ColorTRANSPARENT; |
| 644 gfx::RectF layer_rect = tile->contents_transform().TransformReverse( |
| 645 gfx::RectF(tile->content_rect())); |
| 644 bool is_solid_color = | 646 bool is_solid_color = |
| 645 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | 647 prioritized_tile.raster_source()->PerformSolidColorAnalysis( |
| 646 tile->content_rect(), tile->contents_scale(), &color); | 648 gfx::ToEnclosingRect(layer_rect), 1.f, &color); |
| 647 if (is_solid_color) { | 649 if (is_solid_color) { |
| 648 tile->draw_info().set_solid_color(color); | 650 tile->draw_info().set_solid_color(color); |
| 649 tile->draw_info().set_was_ever_ready_to_draw(); | 651 tile->draw_info().set_was_ever_ready_to_draw(); |
| 650 if (!tile_is_needed_now) | 652 if (!tile_is_needed_now) |
| 651 tile->draw_info().set_was_a_prepaint_tile(); | 653 tile->draw_info().set_was_a_prepaint_tile(); |
| 652 client_->NotifyTileStateChanged(tile); | 654 client_->NotifyTileStateChanged(tile); |
| 653 continue; | 655 continue; |
| 654 } | 656 } |
| 655 } | 657 } |
| 656 | 658 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 } | 839 } |
| 838 | 840 |
| 839 const std::vector<PrioritizedTile>& tiles_to_process_for_images = | 841 const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
| 840 work_to_schedule.tiles_to_process_for_images; | 842 work_to_schedule.tiles_to_process_for_images; |
| 841 std::vector<std::pair<DrawImage, scoped_refptr<TileTask>>> new_locked_images; | 843 std::vector<std::pair<DrawImage, scoped_refptr<TileTask>>> new_locked_images; |
| 842 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { | 844 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
| 843 Tile* tile = prioritized_tile.tile(); | 845 Tile* tile = prioritized_tile.tile(); |
| 844 | 846 |
| 845 std::vector<DrawImage> images; | 847 std::vector<DrawImage> images; |
| 846 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 848 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 847 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 849 tile->enclosing_layer_rect(), tile->contents_transform().pre_scale(), |
| 850 &images); |
| 848 ImageDecodeController::TracingInfo tracing_info( | 851 ImageDecodeController::TracingInfo tracing_info( |
| 849 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 852 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 850 for (DrawImage& draw_image : images) { | 853 for (DrawImage& draw_image : images) { |
| 851 scoped_refptr<TileTask> task; | 854 scoped_refptr<TileTask> task; |
| 852 bool need_to_unref_when_finished = | 855 bool need_to_unref_when_finished = |
| 853 image_decode_controller_->GetTaskForImageAndRef(draw_image, | 856 image_decode_controller_->GetTaskForImageAndRef(draw_image, |
| 854 tracing_info, &task); | 857 tracing_info, &task); |
| 855 // We only care about images that need to be locked (ie they need to be | 858 // We only care about images that need to be locked (ie they need to be |
| 856 // unreffed later). | 859 // unreffed later). |
| 857 if (!need_to_unref_when_finished) | 860 if (!need_to_unref_when_finished) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 RasterSource::PlaybackSettings playback_settings; | 956 RasterSource::PlaybackSettings playback_settings; |
| 954 playback_settings.skip_images = | 957 playback_settings.skip_images = |
| 955 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 958 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
| 956 | 959 |
| 957 // Create and queue all image decode tasks that this tile depends on. | 960 // Create and queue all image decode tasks that this tile depends on. |
| 958 TileTask::Vector decode_tasks; | 961 TileTask::Vector decode_tasks; |
| 959 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 962 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 960 images.clear(); | 963 images.clear(); |
| 961 if (!playback_settings.skip_images) { | 964 if (!playback_settings.skip_images) { |
| 962 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 965 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 963 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 966 tile->enclosing_layer_rect(), tile->contents_transform().pre_scale(), |
| 967 &images); |
| 964 } | 968 } |
| 965 | 969 |
| 966 // We can skip the image hijack canvas if we have no images. | 970 // We can skip the image hijack canvas if we have no images. |
| 967 playback_settings.use_image_hijack_canvas = !images.empty(); | 971 playback_settings.use_image_hijack_canvas = !images.empty(); |
| 968 ImageDecodeController::TracingInfo tracing_info( | 972 ImageDecodeController::TracingInfo tracing_info( |
| 969 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 973 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 970 for (auto it = images.begin(); it != images.end();) { | 974 for (auto it = images.begin(); it != images.end();) { |
| 971 scoped_refptr<TileTask> task; | 975 scoped_refptr<TileTask> task; |
| 972 bool need_to_unref_when_finished = | 976 bool need_to_unref_when_finished = |
| 973 image_decode_controller_->GetTaskForImageAndRef(*it, tracing_info, | 977 image_decode_controller_->GetTaskForImageAndRef(*it, tracing_info, |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 all_tile_tasks_completed = false; | 1338 all_tile_tasks_completed = false; |
| 1335 did_notify_all_tile_tasks_completed = false; | 1339 did_notify_all_tile_tasks_completed = false; |
| 1336 } | 1340 } |
| 1337 | 1341 |
| 1338 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1342 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1339 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1343 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1340 PrioritizedWorkToSchedule&& other) = default; | 1344 PrioritizedWorkToSchedule&& other) = default; |
| 1341 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1345 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1342 | 1346 |
| 1343 } // namespace cc | 1347 } // namespace cc |
| OLD | NEW |