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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 std::unique_ptr<RasterBuffer> raster_buffer, | 91 std::unique_ptr<RasterBuffer> raster_buffer, |
92 TileTask::Vector* dependencies, | 92 TileTask::Vector* dependencies, |
93 bool is_gpu_rasterization) | 93 bool is_gpu_rasterization) |
94 : TileTask(!is_gpu_rasterization, dependencies), | 94 : TileTask(!is_gpu_rasterization, dependencies), |
95 tile_manager_(tile_manager), | 95 tile_manager_(tile_manager), |
96 tile_id_(tile->id()), | 96 tile_id_(tile->id()), |
97 resource_(resource), | 97 resource_(resource), |
98 raster_source_(std::move(raster_source)), | 98 raster_source_(std::move(raster_source)), |
99 content_rect_(tile->content_rect()), | 99 content_rect_(tile->content_rect()), |
100 invalid_content_rect_(invalidated_rect), | 100 invalid_content_rect_(invalidated_rect), |
101 raster_scales_(tile->raster_scales()), | 101 raster_scale_(tile->contents_scale()), |
102 playback_settings_(playback_settings), | 102 playback_settings_(playback_settings), |
103 tile_resolution_(tile_resolution), | 103 tile_resolution_(tile_resolution), |
104 layer_id_(tile->layer_id()), | 104 layer_id_(tile->layer_id()), |
105 source_prepare_tiles_id_(source_prepare_tiles_id), | 105 source_prepare_tiles_id_(source_prepare_tiles_id), |
106 tile_tracing_id_(static_cast<void*>(tile)), | 106 tile_tracing_id_(static_cast<void*>(tile)), |
107 new_content_id_(tile->id()), | 107 new_content_id_(tile->id()), |
108 source_frame_number_(tile->source_frame_number()), | 108 source_frame_number_(tile->source_frame_number()), |
109 is_gpu_rasterization_(is_gpu_rasterization), | 109 is_gpu_rasterization_(is_gpu_rasterization), |
110 raster_buffer_(std::move(raster_buffer)) { | 110 raster_buffer_(std::move(raster_buffer)) { |
111 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 111 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
112 } | 112 } |
113 | 113 |
114 // Overridden from Task: | 114 // Overridden from Task: |
115 void RunOnWorkerThread() override { | 115 void RunOnWorkerThread() override { |
116 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 116 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
117 "source_prepare_tiles_id", source_prepare_tiles_id_); | 117 "source_prepare_tiles_id", source_prepare_tiles_id_); |
118 | 118 |
119 DCHECK(raster_source_.get()); | 119 DCHECK(raster_source_.get()); |
120 DCHECK(raster_buffer_); | 120 DCHECK(raster_buffer_); |
121 | 121 |
122 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 122 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
123 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); | 123 tile_tracing_id_, tile_resolution_, source_frame_number_, layer_id_); |
124 ScopedRasterTaskTimer timer(is_gpu_rasterization_); | 124 ScopedRasterTaskTimer timer(is_gpu_rasterization_); |
125 timer.SetArea(content_rect_.size().GetArea()); | 125 timer.SetArea(content_rect_.size().GetArea()); |
126 | 126 |
127 DCHECK(raster_source_); | 127 DCHECK(raster_source_); |
128 | 128 |
129 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 129 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
130 invalid_content_rect_, new_content_id_, | 130 invalid_content_rect_, new_content_id_, |
131 raster_scales_, playback_settings_); | 131 raster_scale_, playback_settings_); |
132 } | 132 } |
133 | 133 |
134 // Overridden from TileTask: | 134 // Overridden from TileTask: |
135 void OnTaskCompleted() override { | 135 void OnTaskCompleted() override { |
136 DCHECK(origin_thread_checker_.CalledOnValidThread()); | 136 DCHECK(origin_thread_checker_.CalledOnValidThread()); |
137 | 137 |
138 // Here calling state().IsCanceled() is thread-safe, because this task is | 138 // Here calling state().IsCanceled() is thread-safe, because this task is |
139 // already concluded as FINISHED or CANCELLED and no longer will be worked | 139 // already concluded as FINISHED or CANCELLED and no longer will be worked |
140 // upon by task graph runner. | 140 // upon by task graph runner. |
141 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_id_, | 141 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_id_, |
(...skipping 13 matching lines...) Expand all Loading... |
155 // origin thread. These are not thread-safe and should be accessed only in | 155 // origin thread. These are not thread-safe and should be accessed only in |
156 // origin thread. Ensure their access by checking CalledOnValidThread(). | 156 // origin thread. Ensure their access by checking CalledOnValidThread(). |
157 TileManager* tile_manager_; | 157 TileManager* tile_manager_; |
158 Tile::Id tile_id_; | 158 Tile::Id tile_id_; |
159 Resource* resource_; | 159 Resource* resource_; |
160 | 160 |
161 // The following members should be used for running the task. | 161 // The following members should be used for running the task. |
162 scoped_refptr<RasterSource> raster_source_; | 162 scoped_refptr<RasterSource> raster_source_; |
163 gfx::Rect content_rect_; | 163 gfx::Rect content_rect_; |
164 gfx::Rect invalid_content_rect_; | 164 gfx::Rect invalid_content_rect_; |
165 gfx::SizeF raster_scales_; | 165 float raster_scale_; |
166 RasterSource::PlaybackSettings playback_settings_; | 166 RasterSource::PlaybackSettings playback_settings_; |
167 TileResolution tile_resolution_; | 167 TileResolution tile_resolution_; |
168 int layer_id_; | 168 int layer_id_; |
169 uint64_t source_prepare_tiles_id_; | 169 uint64_t source_prepare_tiles_id_; |
170 void* tile_tracing_id_; | 170 void* tile_tracing_id_; |
171 uint64_t new_content_id_; | 171 uint64_t new_content_id_; |
172 int source_frame_number_; | 172 int source_frame_number_; |
173 bool is_gpu_rasterization_; | 173 bool is_gpu_rasterization_; |
174 std::unique_ptr<RasterBuffer> raster_buffer_; | 174 std::unique_ptr<RasterBuffer> raster_buffer_; |
175 | 175 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 if (!tile->is_solid_color_analysis_performed() && | 651 if (!tile->is_solid_color_analysis_performed() && |
652 tile->use_picture_analysis() && kUseColorEstimator) { | 652 tile->use_picture_analysis() && kUseColorEstimator) { |
653 // We analyze for solid color here, to decide to continue | 653 // We analyze for solid color here, to decide to continue |
654 // or drop the tile for scheduling and raster. | 654 // or drop the tile for scheduling and raster. |
655 // TODO(sohanjg): Check if we could use a shared analysis | 655 // TODO(sohanjg): Check if we could use a shared analysis |
656 // canvas which is reset between tiles. | 656 // canvas which is reset between tiles. |
657 tile->set_solid_color_analysis_performed(true); | 657 tile->set_solid_color_analysis_performed(true); |
658 SkColor color = SK_ColorTRANSPARENT; | 658 SkColor color = SK_ColorTRANSPARENT; |
659 bool is_solid_color = | 659 bool is_solid_color = |
660 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | 660 prioritized_tile.raster_source()->PerformSolidColorAnalysis( |
661 tile->content_rect(), tile->raster_scales(), &color); | 661 tile->content_rect(), tile->contents_scale(), &color); |
662 if (is_solid_color) { | 662 if (is_solid_color) { |
663 tile->draw_info().set_solid_color(color); | 663 tile->draw_info().set_solid_color(color); |
664 tile->draw_info().set_was_ever_ready_to_draw(); | 664 tile->draw_info().set_was_ever_ready_to_draw(); |
665 if (!tile_is_needed_now) | 665 if (!tile_is_needed_now) |
666 tile->draw_info().set_was_a_prepaint_tile(); | 666 tile->draw_info().set_was_a_prepaint_tile(); |
667 client_->NotifyTileStateChanged(tile); | 667 client_->NotifyTileStateChanged(tile); |
668 continue; | 668 continue; |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 } | 892 } |
893 | 893 |
894 const std::vector<PrioritizedTile>& tiles_to_process_for_images = | 894 const std::vector<PrioritizedTile>& tiles_to_process_for_images = |
895 work_to_schedule.tiles_to_process_for_images; | 895 work_to_schedule.tiles_to_process_for_images; |
896 std::vector<DrawImage> new_locked_images; | 896 std::vector<DrawImage> new_locked_images; |
897 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { | 897 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { |
898 Tile* tile = prioritized_tile.tile(); | 898 Tile* tile = prioritized_tile.tile(); |
899 | 899 |
900 std::vector<DrawImage> images; | 900 std::vector<DrawImage> images; |
901 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 901 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
902 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 902 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
903 new_locked_images.insert(new_locked_images.end(), images.begin(), | 903 new_locked_images.insert(new_locked_images.end(), images.begin(), |
904 images.end()); | 904 images.end()); |
905 } | 905 } |
906 | 906 |
907 // TODO(vmpstr): SOON is misleading here, but these images can come from | 907 // TODO(vmpstr): SOON is misleading here, but these images can come from |
908 // several diffent tiles. Rethink what we actually want to trace here. Note | 908 // several diffent tiles. Rethink what we actually want to trace here. Note |
909 // that I'm using SOON, since it can't be NOW (these are prepaint). | 909 // that I'm using SOON, since it can't be NOW (these are prepaint). |
910 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, | 910 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, |
911 TilePriority::SOON); | 911 TilePriority::SOON); |
912 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = | 912 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 RasterSource::PlaybackSettings playback_settings; | 995 RasterSource::PlaybackSettings playback_settings; |
996 playback_settings.skip_images = | 996 playback_settings.skip_images = |
997 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 997 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
998 | 998 |
999 // Create and queue all image decode tasks that this tile depends on. | 999 // Create and queue all image decode tasks that this tile depends on. |
1000 TileTask::Vector decode_tasks; | 1000 TileTask::Vector decode_tasks; |
1001 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 1001 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
1002 images.clear(); | 1002 images.clear(); |
1003 if (!playback_settings.skip_images) { | 1003 if (!playback_settings.skip_images) { |
1004 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 1004 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
1005 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 1005 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
1006 } | 1006 } |
1007 | 1007 |
1008 // We can skip the image hijack canvas if we have no images. | 1008 // We can skip the image hijack canvas if we have no images. |
1009 playback_settings.use_image_hijack_canvas = !images.empty(); | 1009 playback_settings.use_image_hijack_canvas = !images.empty(); |
1010 | 1010 |
1011 // Get the tasks for the required images. | 1011 // Get the tasks for the required images. |
1012 ImageDecodeCache::TracingInfo tracing_info( | 1012 ImageDecodeCache::TracingInfo tracing_info( |
1013 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 1013 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
1014 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, | 1014 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, |
1015 tracing_info); | 1015 tracing_info); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 all_tile_tasks_completed = false; | 1371 all_tile_tasks_completed = false; |
1372 did_notify_all_tile_tasks_completed = false; | 1372 did_notify_all_tile_tasks_completed = false; |
1373 } | 1373 } |
1374 | 1374 |
1375 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1375 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
1376 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1376 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
1377 PrioritizedWorkToSchedule&& other) = default; | 1377 PrioritizedWorkToSchedule&& other) = default; |
1378 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1378 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
1379 | 1379 |
1380 } // namespace cc | 1380 } // namespace cc |
OLD | NEW |