Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: cc/tiles/tile_manager.cc

Issue 2566613002: [4/5] Add translated rasterization support for PictureLayerTilingSet & below (Closed)
Patch Set: still need that rebaseline Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_id_(tile->id()), 97 tile_id_(tile->id()),
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_scale_(tile->contents_scale()), 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 raster_buffer_->Playback( 130 raster_buffer_->Playback(raster_source_.get(), content_rect_,
131 raster_source_.get(), content_rect_, invalid_content_rect_, 131 invalid_content_rect_, new_content_id_,
132 new_content_id_, gfx::AxisTransform2d(raster_scale_, gfx::Vector2dF()), 132 raster_transform_, playback_settings_);
133 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_id_, 142 tile_manager_->OnRasterTaskCompleted(std::move(raster_buffer_), tile_id_,
(...skipping 13 matching lines...) Expand all
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::Id tile_id_; 159 Tile::Id tile_id_;
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 float raster_scale_; 166 gfx::AxisTransform2d 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 658
660 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; 659 bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW;
661 if (!tile->is_solid_color_analysis_performed() && 660 if (!tile->is_solid_color_analysis_performed() &&
662 tile->use_picture_analysis() && kUseColorEstimator) { 661 tile->use_picture_analysis() && kUseColorEstimator) {
663 // We analyze for solid color here, to decide to continue 662 // We analyze for solid color here, to decide to continue
664 // or drop the tile for scheduling and raster. 663 // or drop the tile for scheduling and raster.
665 // TODO(sohanjg): Check if we could use a shared analysis 664 // TODO(sohanjg): Check if we could use a shared analysis
666 // canvas which is reset between tiles. 665 // canvas which is reset between tiles.
667 tile->set_solid_color_analysis_performed(true); 666 tile->set_solid_color_analysis_performed(true);
668 SkColor color = SK_ColorTRANSPARENT; 667 SkColor color = SK_ColorTRANSPARENT;
668 gfx::RectF layer_rect = tile->raster_transform().InverseMapRect(
669 gfx::RectF(tile->content_rect()));
669 bool is_solid_color = 670 bool is_solid_color =
670 prioritized_tile.raster_source()->PerformSolidColorAnalysis( 671 prioritized_tile.raster_source()->PerformSolidColorAnalysis(
671 tile->content_rect(), tile->contents_scale(), &color); 672 gfx::ToEnclosingRect(layer_rect), 1.f, &color);
672 if (is_solid_color) { 673 if (is_solid_color) {
673 tile->draw_info().set_solid_color(color); 674 tile->draw_info().set_solid_color(color);
674 client_->NotifyTileStateChanged(tile); 675 client_->NotifyTileStateChanged(tile);
675 continue; 676 continue;
676 } 677 }
677 } 678 }
678 679
679 // Prepaint tiles that are far away are only processed for images. 680 // Prepaint tiles that are far away are only processed for images.
680 if (!tile->required_for_activation() && !tile->required_for_draw() && 681 if (!tile->required_for_activation() && !tile->required_for_draw() &&
681 prioritized_tile.is_process_for_images_only()) { 682 prioritized_tile.is_process_for_images_only()) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 const std::vector<PrioritizedTile>& tiles_to_process_for_images = 859 const std::vector<PrioritizedTile>& tiles_to_process_for_images =
859 work_to_schedule.tiles_to_process_for_images; 860 work_to_schedule.tiles_to_process_for_images;
860 std::vector<DrawImage> new_locked_images; 861 std::vector<DrawImage> new_locked_images;
861 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { 862 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) {
862 Tile* tile = prioritized_tile.tile(); 863 Tile* tile = prioritized_tile.tile();
863 864
864 // TODO(khushalsagar): Send these images to the ImageDecodeService, through 865 // TODO(khushalsagar): Send these images to the ImageDecodeService, through
865 // the CheckerImageTracker as well. See crbug.com/691087. 866 // the CheckerImageTracker as well. See crbug.com/691087.
866 std::vector<DrawImage> images; 867 std::vector<DrawImage> images;
867 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 868 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
868 tile->enclosing_layer_rect(), tile->contents_scale(), 869 tile->enclosing_layer_rect(), tile->raster_transform().scale(),
869 raster_color_space, &images); 870 raster_color_space, &images);
870 new_locked_images.insert(new_locked_images.end(), images.begin(), 871 new_locked_images.insert(new_locked_images.end(), images.begin(),
871 images.end()); 872 images.end());
872 } 873 }
873 874
874 // TODO(vmpstr): SOON is misleading here, but these images can come from 875 // TODO(vmpstr): SOON is misleading here, but these images can come from
875 // several diffent tiles. Rethink what we actually want to trace here. Note 876 // several diffent tiles. Rethink what we actually want to trace here. Note
876 // that I'm using SOON, since it can't be NOW (these are prepaint). 877 // that I'm using SOON, since it can't be NOW (these are prepaint).
877 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, 878 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_,
878 TilePriority::SOON); 879 TilePriority::SOON);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 playback_settings.skip_images = 964 playback_settings.skip_images =
964 prioritized_tile.priority().resolution == LOW_RESOLUTION; 965 prioritized_tile.priority().resolution == LOW_RESOLUTION;
965 966
966 // Create and queue all image decode tasks that this tile depends on. 967 // Create and queue all image decode tasks that this tile depends on.
967 TileTask::Vector decode_tasks; 968 TileTask::Vector decode_tasks;
968 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; 969 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()];
969 ImageIdFlatSet images_to_skip; 970 ImageIdFlatSet images_to_skip;
970 images.clear(); 971 images.clear();
971 if (!playback_settings.skip_images) { 972 if (!playback_settings.skip_images) {
972 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 973 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
973 tile->enclosing_layer_rect(), tile->contents_scale(), color_space, 974 tile->enclosing_layer_rect(), tile->raster_transform().scale(),
974 &images); 975 color_space, &images);
975 checker_image_tracker_.FilterImagesForCheckeringForTile( 976 checker_image_tracker_.FilterImagesForCheckeringForTile(
976 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree()); 977 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree());
977 } 978 }
978 979
979 // We can skip the image hijack canvas if we have no images, or no images to 980 // We can skip the image hijack canvas if we have no images, or no images to
980 // skip during raster. 981 // skip during raster.
981 playback_settings.use_image_hijack_canvas = 982 playback_settings.use_image_hijack_canvas =
982 !images.empty() || !images_to_skip.empty(); 983 !images.empty() || !images_to_skip.empty();
983 playback_settings.images_to_skip = std::move(images_to_skip); 984 playback_settings.images_to_skip = std::move(images_to_skip);
984 985
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 1378
1378 // Use a custom tile_as_value, instead of Tile::AsValueInto, since we don't 1379 // Use a custom tile_as_value, instead of Tile::AsValueInto, since we don't
1379 // need all of the state that would be captured by other functions. 1380 // need all of the state that would be captured by other functions.
1380 auto tile_as_value = [](const PrioritizedTile& prioritized_tile, 1381 auto tile_as_value = [](const PrioritizedTile& prioritized_tile,
1381 base::trace_event::TracedValue* value) { 1382 base::trace_event::TracedValue* value) {
1382 Tile* tile = prioritized_tile.tile(); 1383 Tile* tile = prioritized_tile.tile();
1383 TilePriority priority = prioritized_tile.priority(); 1384 TilePriority priority = prioritized_tile.priority();
1384 1385
1385 value->SetInteger("id", tile->id()); 1386 value->SetInteger("id", tile->id());
1386 value->SetString("content_rect", tile->content_rect().ToString()); 1387 value->SetString("content_rect", tile->content_rect().ToString());
1387 value->SetDouble("contents_scale", tile->contents_scale()); 1388 value->SetDouble("contents_scale", tile->contents_scale_key());
1388 value->SetBoolean("is_ready_to_draw", tile->draw_info().IsReadyToDraw()); 1389 value->SetBoolean("is_ready_to_draw", tile->draw_info().IsReadyToDraw());
1389 value->SetString("resolution", TileResolutionToString(priority.resolution)); 1390 value->SetString("resolution", TileResolutionToString(priority.resolution));
1390 value->SetString("priority_bin", 1391 value->SetString("priority_bin",
1391 TilePriorityBinToString(priority.priority_bin)); 1392 TilePriorityBinToString(priority.priority_bin));
1392 value->SetDouble("distance_to_visible", priority.distance_to_visible); 1393 value->SetDouble("distance_to_visible", priority.distance_to_visible);
1393 value->SetBoolean("required_for_activation", 1394 value->SetBoolean("required_for_activation",
1394 tile->required_for_activation()); 1395 tile->required_for_activation());
1395 value->SetBoolean("required_for_draw", tile->required_for_draw()); 1396 value->SetBoolean("required_for_draw", tile->required_for_draw());
1396 }; 1397 };
1397 1398
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 all_tile_tasks_completed = false; 1498 all_tile_tasks_completed = false;
1498 did_notify_all_tile_tasks_completed = false; 1499 did_notify_all_tile_tasks_completed = false;
1499 } 1500 }
1500 1501
1501 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; 1502 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
1502 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( 1503 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
1503 PrioritizedWorkToSchedule&& other) = default; 1504 PrioritizedWorkToSchedule&& other) = default;
1504 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; 1505 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;
1505 1506
1506 } // namespace cc 1507 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile.cc ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698