| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 std::unique_ptr<RasterBuffer> raster_buffer, | 92 std::unique_ptr<RasterBuffer> raster_buffer, |
| 93 TileTask::Vector* dependencies, | 93 TileTask::Vector* dependencies, |
| 94 bool is_gpu_rasterization) | 94 bool is_gpu_rasterization) |
| 95 : TileTask(!is_gpu_rasterization, dependencies), | 95 : TileTask(!is_gpu_rasterization, dependencies), |
| 96 tile_manager_(tile_manager), | 96 tile_manager_(tile_manager), |
| 97 tile_(tile), | 97 tile_(tile), |
| 98 resource_(resource), | 98 resource_(resource), |
| 99 raster_source_(std::move(raster_source)), | 99 raster_source_(std::move(raster_source)), |
| 100 content_rect_(tile->content_rect()), | 100 content_rect_(tile->content_rect()), |
| 101 invalid_content_rect_(invalidated_rect), | 101 invalid_content_rect_(invalidated_rect), |
| 102 raster_scales_(tile->raster_scales()), | 102 raster_transform_(tile->raster_transform()), |
| 103 playback_settings_(playback_settings), | 103 playback_settings_(playback_settings), |
| 104 tile_resolution_(tile_resolution), | 104 tile_resolution_(tile_resolution), |
| 105 layer_id_(tile->layer_id()), | 105 layer_id_(tile->layer_id()), |
| 106 source_prepare_tiles_id_(source_prepare_tiles_id), | 106 source_prepare_tiles_id_(source_prepare_tiles_id), |
| 107 tile_tracing_id_(static_cast<void*>(tile)), | 107 tile_tracing_id_(static_cast<void*>(tile)), |
| 108 new_content_id_(tile->id()), | 108 new_content_id_(tile->id()), |
| 109 source_frame_number_(tile->source_frame_number()), | 109 source_frame_number_(tile->source_frame_number()), |
| 110 is_gpu_rasterization_(is_gpu_rasterization), | 110 is_gpu_rasterization_(is_gpu_rasterization), |
| 111 raster_buffer_(std::move(raster_buffer)) { | 111 raster_buffer_(std::move(raster_buffer)) { |
| 112 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 112 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Overridden from Task: | 115 // Overridden from Task: |
| 116 void RunOnWorkerThread() override { | 116 void RunOnWorkerThread() override { |
| 117 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 117 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
| 118 "source_prepare_tiles_id", source_prepare_tiles_id_); | 118 "source_prepare_tiles_id", source_prepare_tiles_id_); |
| 119 | 119 |
| 120 DCHECK(raster_source_.get()); | 120 DCHECK(raster_source_.get()); |
| 121 DCHECK(raster_buffer_); | 121 DCHECK(raster_buffer_); |
| 122 | 122 |
| 123 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 123 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
| 124 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); | 124 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); |
| 125 ScopedRasterTaskTimer timer(is_gpu_rasterization_); | 125 ScopedRasterTaskTimer timer(is_gpu_rasterization_); |
| 126 timer.SetArea(content_rect_.size().GetArea()); | 126 timer.SetArea(content_rect_.size().GetArea()); |
| 127 | 127 |
| 128 DCHECK(raster_source_); | 128 DCHECK(raster_source_); |
| 129 | 129 |
| 130 DCHECK_EQ(raster_scales_.width(), raster_scales_.height()); | |
| 131 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 130 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
| 132 invalid_content_rect_, new_content_id_, | 131 invalid_content_rect_, new_content_id_, |
| 133 ScaleTranslate2d(raster_scales_.width(), gfx::Vecto
r2dF()), playback_settings_); | 132 raster_transform_, playback_settings_); |
| 134 } | 133 } |
| 135 | 134 |
| 136 // Overridden from TileTask: | 135 // Overridden from TileTask: |
| 137 void OnTaskCompleted() override { | 136 void OnTaskCompleted() override { |
| 138 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 137 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
| 139 | 138 |
| 140 // Here calling state().IsCanceled() is thread-safe, because this task is | 139 // Here calling state().IsCanceled() is thread-safe, because this task is |
| 141 // already concluded as FINISHED or CANCELLED and no longer will be worked | 140 // already concluded as FINISHED or CANCELLED and no longer will be worked |
| 142 // upon by task graph runner. | 141 // upon by task graph runner. |
| 143 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, | 142 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 157 // origin thread. These are not thread-safe and should be accessed only in | 156 // origin thread. These are not thread-safe and should be accessed only in |
| 158 // origin thread. Ensure their access by checking CalledOnValidThread(). | 157 // origin thread. Ensure their access by checking CalledOnValidThread(). |
| 159 TileManager* tile_manager_; | 158 TileManager* tile_manager_; |
| 160 Tile* tile_; | 159 Tile* tile_; |
| 161 Resource* resource_; | 160 Resource* resource_; |
| 162 | 161 |
| 163 // The following members should be used for running the task. | 162 // The following members should be used for running the task. |
| 164 scoped_refptr<RasterSource> raster_source_; | 163 scoped_refptr<RasterSource> raster_source_; |
| 165 gfx::Rect content_rect_; | 164 gfx::Rect content_rect_; |
| 166 gfx::Rect invalid_content_rect_; | 165 gfx::Rect invalid_content_rect_; |
| 167 gfx::SizeF raster_scales_; | 166 ScaleTranslate2d raster_transform_; |
| 168 RasterSource::PlaybackSettings playback_settings_; | 167 RasterSource::PlaybackSettings playback_settings_; |
| 169 TileResolution tile_resolution_; | 168 TileResolution tile_resolution_; |
| 170 int layer_id_; | 169 int layer_id_; |
| 171 uint64_t source_prepare_tiles_id_; | 170 uint64_t source_prepare_tiles_id_; |
| 172 void* tile_tracing_id_; | 171 void* tile_tracing_id_; |
| 173 uint64_t new_content_id_; | 172 uint64_t new_content_id_; |
| 174 int source_frame_number_; | 173 int source_frame_number_; |
| 175 bool is_gpu_rasterization_; | 174 bool is_gpu_rasterization_; |
| 176 std::unique_ptr<RasterBuffer> raster_buffer_; | 175 std::unique_ptr<RasterBuffer> raster_buffer_; |
| 177 | 176 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 670 |
| 672 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; | 671 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; |
| 673 if (!tile->is_solid_color_analysis_performed() && | 672 if (!tile->is_solid_color_analysis_performed() && |
| 674 tile->use_picture_analysis() && kUseColorEstimator) { | 673 tile->use_picture_analysis() && kUseColorEstimator) { |
| 675 // We analyze for solid color here, to decide to continue | 674 // We analyze for solid color here, to decide to continue |
| 676 // or drop the tile for scheduling and raster. | 675 // or drop the tile for scheduling and raster. |
| 677 // TODO(sohanjg): Check if we could use a shared analysis | 676 // TODO(sohanjg): Check if we could use a shared analysis |
| 678 // canvas which is reset between tiles. | 677 // canvas which is reset between tiles. |
| 679 tile->set_solid_color_analysis_performed(true); | 678 tile->set_solid_color_analysis_performed(true); |
| 680 SkColor color = SK_ColorTRANSPARENT; | 679 SkColor color = SK_ColorTRANSPARENT; |
| 680 gfx::RectF layer_rect = tile->raster_transform().TransformRectReverse( |
| 681 gfx::RectF(tile->content_rect())); |
| 681 bool is_solid_color = | 682 bool is_solid_color = |
| 682 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | 683 prioritized_tile.raster_source()->PerformSolidColorAnalysis( |
| 683 tile->content_rect(), tile->raster_scales(), &color); | 684 gfx::ToEnclosingRect(layer_rect), 1.f, &color); |
| 684 if (is_solid_color) { | 685 if (is_solid_color) { |
| 685 tile->draw_info().set_solid_color(color); | 686 tile->draw_info().set_solid_color(color); |
| 686 tile->draw_info().set_was_ever_ready_to_draw(); | 687 tile->draw_info().set_was_ever_ready_to_draw(); |
| 687 if (!tile_is_needed_now) | 688 if (!tile_is_needed_now) |
| 688 tile->draw_info().set_was_a_prepaint_tile(); | 689 tile->draw_info().set_was_a_prepaint_tile(); |
| 689 client_->NotifyTileStateChanged(tile); | 690 client_->NotifyTileStateChanged(tile); |
| 690 continue; | 691 continue; |
| 691 } | 692 } |
| 692 } | 693 } |
| 693 | 694 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 } | 880 } |
| 880 | 881 |
| 881 const std::vector<PrioritizedTile>& tiles_to_process_for_images = | 882 const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
| 882 work_to_schedule.tiles_to_process_for_images; | 883 work_to_schedule.tiles_to_process_for_images; |
| 883 std::vector<DrawImage> new_locked_images; | 884 std::vector<DrawImage> new_locked_images; |
| 884 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { | 885 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
| 885 Tile* tile = prioritized_tile.tile(); | 886 Tile* tile = prioritized_tile.tile(); |
| 886 | 887 |
| 887 std::vector<DrawImage> images; | 888 std::vector<DrawImage> images; |
| 888 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 889 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 889 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 890 tile->enclosing_layer_rect(), tile->raster_transform().scale(), &images)
; |
| 890 new_locked_images.insert(new_locked_images.end(), images.begin(), | 891 new_locked_images.insert(new_locked_images.end(), images.begin(), |
| 891 images.end()); | 892 images.end()); |
| 892 } | 893 } |
| 893 | 894 |
| 894 // TODO(vmpstr): SOON is misleading here, but these images can come from | 895 // TODO(vmpstr): SOON is misleading here, but these images can come from |
| 895 // several diffent tiles. Rethink what we actually want to trace here. Note | 896 // several diffent tiles. Rethink what we actually want to trace here. Note |
| 896 // that I'm using SOON, since it can't be NOW (these are prepaint). | 897 // that I'm using SOON, since it can't be NOW (these are prepaint). |
| 897 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, | 898 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, |
| 898 TilePriority::SOON); | 899 TilePriority::SOON); |
| 899 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = | 900 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 RasterSource::PlaybackSettings playback_settings; | 983 RasterSource::PlaybackSettings playback_settings; |
| 983 playback_settings.skip_images = | 984 playback_settings.skip_images = |
| 984 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 985 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
| 985 | 986 |
| 986 // Create and queue all image decode tasks that this tile depends on. | 987 // Create and queue all image decode tasks that this tile depends on. |
| 987 TileTask::Vector decode_tasks; | 988 TileTask::Vector decode_tasks; |
| 988 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 989 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
| 989 images.clear(); | 990 images.clear(); |
| 990 if (!playback_settings.skip_images) { | 991 if (!playback_settings.skip_images) { |
| 991 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 992 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 992 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 993 tile->enclosing_layer_rect(), tile->raster_transform().scale(), &images)
; |
| 993 } | 994 } |
| 994 | 995 |
| 995 // We can skip the image hijack canvas if we have no images. | 996 // We can skip the image hijack canvas if we have no images. |
| 996 playback_settings.use_image_hijack_canvas = !images.empty(); | 997 playback_settings.use_image_hijack_canvas = !images.empty(); |
| 997 | 998 |
| 998 // Get the tasks for the required images. | 999 // Get the tasks for the required images. |
| 999 ImageDecodeCache::TracingInfo tracing_info( | 1000 ImageDecodeCache::TracingInfo tracing_info( |
| 1000 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1001 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 1001 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); | 1002 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); |
| 1002 | 1003 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 all_tile_tasks_completed = false; | 1343 all_tile_tasks_completed = false; |
| 1343 did_notify_all_tile_tasks_completed = false; | 1344 did_notify_all_tile_tasks_completed = false; |
| 1344 } | 1345 } |
| 1345 | 1346 |
| 1346 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1347 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1347 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1348 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1348 PrioritizedWorkToSchedule&& other) = default; | 1349 PrioritizedWorkToSchedule&& other) = default; |
| 1349 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1350 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1350 | 1351 |
| 1351 } // namespace cc | 1352 } // namespace cc |
| OLD | NEW |