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

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

Issue 1531013004: cc: Do solid color analysis before scheduling tiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test updated. Created 4 years, 11 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_manager.h ('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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 const gfx::Rect& invalid_content_rect, 48 const gfx::Rect& invalid_content_rect,
49 float contents_scale, 49 float contents_scale,
50 TileResolution tile_resolution, 50 TileResolution tile_resolution,
51 int layer_id, 51 int layer_id,
52 uint64_t source_prepare_tiles_id, 52 uint64_t source_prepare_tiles_id,
53 const void* tile, 53 const void* tile,
54 uint64_t new_content_id, 54 uint64_t new_content_id,
55 uint64_t previous_content_id, 55 uint64_t previous_content_id,
56 uint64_t resource_content_id, 56 uint64_t resource_content_id,
57 int source_frame_number, 57 int source_frame_number,
58 bool analyze_picture, 58 const base::Callback<void(bool)>& reply,
59 const base::Callback<
60 void(const DisplayListRasterSource::SolidColorAnalysis&,
61 bool)>& reply,
62 ImageDecodeTask::Vector* dependencies) 59 ImageDecodeTask::Vector* dependencies)
63 : RasterTask(dependencies), 60 : RasterTask(dependencies),
64 resource_(resource), 61 resource_(resource),
65 raster_source_(raster_source), 62 raster_source_(raster_source),
66 content_rect_(content_rect), 63 content_rect_(content_rect),
67 invalid_content_rect_(invalid_content_rect), 64 invalid_content_rect_(invalid_content_rect),
68 contents_scale_(contents_scale), 65 contents_scale_(contents_scale),
69 tile_resolution_(tile_resolution), 66 tile_resolution_(tile_resolution),
70 layer_id_(layer_id), 67 layer_id_(layer_id),
71 source_prepare_tiles_id_(source_prepare_tiles_id), 68 source_prepare_tiles_id_(source_prepare_tiles_id),
72 tile_(tile), 69 tile_(tile),
73 new_content_id_(new_content_id), 70 new_content_id_(new_content_id),
74 previous_content_id_(previous_content_id), 71 previous_content_id_(previous_content_id),
75 resource_content_id_(resource_content_id), 72 resource_content_id_(resource_content_id),
76 source_frame_number_(source_frame_number), 73 source_frame_number_(source_frame_number),
77 analyze_picture_(analyze_picture),
78 reply_(reply) {} 74 reply_(reply) {}
79 75
80 // Overridden from Task: 76 // Overridden from Task:
81 void RunOnWorkerThread() override { 77 void RunOnWorkerThread() override {
82 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", 78 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread",
83 "source_prepare_tiles_id", source_prepare_tiles_id_); 79 "source_prepare_tiles_id", source_prepare_tiles_id_);
84 80
85 DCHECK(raster_source_.get()); 81 DCHECK(raster_source_.get());
86 DCHECK(raster_buffer_); 82 DCHECK(raster_buffer_);
87 83
88 if (analyze_picture_) {
89 Analyze(raster_source_.get());
90 if (analysis_.is_solid_color)
91 return;
92 }
93
94 Raster(raster_source_.get()); 84 Raster(raster_source_.get());
95 } 85 }
96 86
97 // Overridden from TileTask: 87 // Overridden from TileTask:
98 void ScheduleOnOriginThread(TileTaskClient* client) override { 88 void ScheduleOnOriginThread(TileTaskClient* client) override {
99 DCHECK(!raster_buffer_); 89 DCHECK(!raster_buffer_);
100 raster_buffer_ = client->AcquireBufferForRaster( 90 raster_buffer_ = client->AcquireBufferForRaster(
101 resource_, resource_content_id_, previous_content_id_); 91 resource_, resource_content_id_, previous_content_id_);
102 } 92 }
103 void CompleteOnOriginThread(TileTaskClient* client) override { 93 void CompleteOnOriginThread(TileTaskClient* client) override {
104 client->ReleaseBufferForRaster(std::move(raster_buffer_)); 94 client->ReleaseBufferForRaster(std::move(raster_buffer_));
105 reply_.Run(analysis_, !HasFinishedRunning()); 95 reply_.Run(!HasFinishedRunning());
106 } 96 }
107 97
108 protected: 98 protected:
109 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } 99 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); }
110 100
111 private: 101 private:
112 void Analyze(const DisplayListRasterSource* raster_source) {
113 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task(
114 tile_, tile_resolution_, source_frame_number_, layer_id_);
115
116 DCHECK(raster_source);
117
118 raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_,
119 &analysis_);
120 // Clear the flag if we're not using the estimator.
121 analysis_.is_solid_color &= kUseColorEstimator;
122 }
123
124 void Raster(const DisplayListRasterSource* raster_source) { 102 void Raster(const DisplayListRasterSource* raster_source) {
125 frame_viewer_instrumentation::ScopedRasterTask raster_task( 103 frame_viewer_instrumentation::ScopedRasterTask raster_task(
126 tile_, tile_resolution_, source_frame_number_, layer_id_); 104 tile_, tile_resolution_, source_frame_number_, layer_id_);
127 ScopedRasterTaskTimer timer; 105 ScopedRasterTaskTimer timer;
128 timer.SetArea(content_rect_.size().GetArea()); 106 timer.SetArea(content_rect_.size().GetArea());
129 107
130 DCHECK(raster_source); 108 DCHECK(raster_source);
131 109
132 bool include_images = tile_resolution_ != LOW_RESOLUTION; 110 bool include_images = tile_resolution_ != LOW_RESOLUTION;
133 raster_buffer_->Playback(raster_source_.get(), content_rect_, 111 raster_buffer_->Playback(raster_source_.get(), content_rect_,
134 invalid_content_rect_, new_content_id_, 112 invalid_content_rect_, new_content_id_,
135 contents_scale_, include_images); 113 contents_scale_, include_images);
136 } 114 }
137 115
138 const Resource* resource_; 116 const Resource* resource_;
139 DisplayListRasterSource::SolidColorAnalysis analysis_;
140 scoped_refptr<DisplayListRasterSource> raster_source_; 117 scoped_refptr<DisplayListRasterSource> raster_source_;
141 gfx::Rect content_rect_; 118 gfx::Rect content_rect_;
142 gfx::Rect invalid_content_rect_; 119 gfx::Rect invalid_content_rect_;
143 float contents_scale_; 120 float contents_scale_;
144 TileResolution tile_resolution_; 121 TileResolution tile_resolution_;
145 int layer_id_; 122 int layer_id_;
146 uint64_t source_prepare_tiles_id_; 123 uint64_t source_prepare_tiles_id_;
147 const void* tile_; 124 const void* tile_;
148 uint64_t new_content_id_; 125 uint64_t new_content_id_;
149 uint64_t previous_content_id_; 126 uint64_t previous_content_id_;
150 uint64_t resource_content_id_; 127 uint64_t resource_content_id_;
151 int source_frame_number_; 128 int source_frame_number_;
152 bool analyze_picture_; 129 const base::Callback<void(bool)> reply_;
153 const base::Callback<void(const DisplayListRasterSource::SolidColorAnalysis&,
154 bool)> reply_;
155 scoped_ptr<RasterBuffer> raster_buffer_; 130 scoped_ptr<RasterBuffer> raster_buffer_;
156 131
157 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); 132 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl);
158 }; 133 };
159 134
160 // Task priorities that make sure that the task set done tasks run before any 135 // Task priorities that make sure that the task set done tasks run before any
161 // other remaining tasks. 136 // other remaining tasks.
162 const size_t kRequiredForActivationDoneTaskPriority = 1u; 137 const size_t kRequiredForActivationDoneTaskPriority = 1u;
163 const size_t kRequiredForDrawDoneTaskPriority = 2u; 138 const size_t kRequiredForDrawDoneTaskPriority = 2u;
164 const size_t kAllDoneTaskPriority = 3u; 139 const size_t kAllDoneTaskPriority = 3u;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 Tile* tile = prioritized_tile.tile(); 561 Tile* tile = prioritized_tile.tile();
587 TilePriority priority = prioritized_tile.priority(); 562 TilePriority priority = prioritized_tile.priority();
588 563
589 if (TilePriorityViolatesMemoryPolicy(priority)) { 564 if (TilePriorityViolatesMemoryPolicy(priority)) {
590 TRACE_EVENT_INSTANT0( 565 TRACE_EVENT_INSTANT0(
591 "cc", "TileManager::AssignGpuMemory tile violates memory policy", 566 "cc", "TileManager::AssignGpuMemory tile violates memory policy",
592 TRACE_EVENT_SCOPE_THREAD); 567 TRACE_EVENT_SCOPE_THREAD);
593 break; 568 break;
594 } 569 }
595 570
571 if (tile->use_picture_analysis() && kUseColorEstimator) {
572 // We analyze for solid color here, to decide to continue
573 // or drop the tile for scheduling and raster.
574 // TODO(sohanjg): Check if we could use a shared analysis
575 // canvas which is reset between tiles.
576 SkColor color = SK_ColorTRANSPARENT;
577 bool is_solid_color =
578 prioritized_tile.raster_source()->PerformSolidColorAnalysis(
579 tile->content_rect(), tile->contents_scale(), &color);
580 if (is_solid_color) {
581 tile->draw_info().set_solid_color(color);
582 tile->draw_info().set_was_ever_ready_to_draw();
583 client_->NotifyTileStateChanged(tile);
584 continue;
585 }
586 }
587
596 // We won't be able to schedule this tile, so break out early. 588 // We won't be able to schedule this tile, so break out early.
597 if (tiles_that_need_to_be_rasterized->size() >= 589 if (tiles_that_need_to_be_rasterized->size() >=
598 scheduled_raster_task_limit) { 590 scheduled_raster_task_limit) {
599 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; 591 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false;
600 break; 592 break;
601 } 593 }
602 594
603 tile->scheduled_priority_ = schedule_priority++; 595 tile->scheduled_priority_ = schedule_priority++;
604 596
605 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || 597 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE ||
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( 811 decode_tasks.push_back(image_decode_controller_.GetTaskForImage(
820 image, tile->layer_id(), prepare_tiles_count_)); 812 image, tile->layer_id(), prepare_tiles_count_));
821 } 813 }
822 814
823 return make_scoped_refptr(new RasterTaskImpl( 815 return make_scoped_refptr(new RasterTaskImpl(
824 resource, prioritized_tile.raster_source(), tile->content_rect(), 816 resource, prioritized_tile.raster_source(), tile->content_rect(),
825 tile->invalidated_content_rect(), tile->contents_scale(), 817 tile->invalidated_content_rect(), tile->contents_scale(),
826 prioritized_tile.priority().resolution, tile->layer_id(), 818 prioritized_tile.priority().resolution, tile->layer_id(),
827 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), 819 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(),
828 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), 820 tile->invalidated_id(), resource_content_id, tile->source_frame_number(),
829 tile->use_picture_analysis(),
830 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), 821 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this),
831 tile->id(), resource), 822 tile->id(), resource),
832 &decode_tasks)); 823 &decode_tasks));
833 } 824 }
834 825
835 void TileManager::OnRasterTaskCompleted( 826 void TileManager::OnRasterTaskCompleted(
836 Tile::Id tile_id, 827 Tile::Id tile_id,
837 Resource* resource, 828 Resource* resource,
838 const DisplayListRasterSource::SolidColorAnalysis& analysis,
839 bool was_canceled) { 829 bool was_canceled) {
840 DCHECK(tiles_.find(tile_id) != tiles_.end()); 830 DCHECK(tiles_.find(tile_id) != tiles_.end());
841 831
842 Tile* tile = tiles_[tile_id]; 832 Tile* tile = tiles_[tile_id];
833 TileDrawInfo& draw_info = tile->draw_info();
843 DCHECK(tile->raster_task_.get()); 834 DCHECK(tile->raster_task_.get());
844 orphan_tasks_.push_back(tile->raster_task_); 835 orphan_tasks_.push_back(tile->raster_task_);
845 tile->raster_task_ = nullptr; 836 tile->raster_task_ = nullptr;
846 837
847 if (was_canceled) { 838 if (was_canceled) {
848 ++flush_stats_.canceled_count; 839 ++flush_stats_.canceled_count;
849 // TODO(ericrk): If more partial raster work is done in the future, it may 840 // TODO(ericrk): If more partial raster work is done in the future, it may
850 // be worth returning the resource to the pool with its previous ID (not 841 // be worth returning the resource to the pool with its previous ID (not
851 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method 842 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method
852 // of achieving this. 843 // of achieving this.
853 resource_pool_->ReleaseResource(resource, 0 /* content_id */); 844 resource_pool_->ReleaseResource(resource, 0 /* content_id */);
854 return; 845 return;
855 } 846 }
856 847
857 UpdateTileDrawInfo(tile, resource, analysis);
858 }
859
860 void TileManager::UpdateTileDrawInfo(
861 Tile* tile,
862 Resource* resource,
863 const DisplayListRasterSource::SolidColorAnalysis& analysis) {
864 TileDrawInfo& draw_info = tile->draw_info();
865
866 ++flush_stats_.completed_count; 848 ++flush_stats_.completed_count;
867 849
868 if (analysis.is_solid_color) { 850 draw_info.set_use_resource();
869 draw_info.set_solid_color(analysis.solid_color); 851 draw_info.resource_ = resource;
870 if (resource) { 852 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile);
871 // TODO(ericrk): If more partial raster work is done in the future, it may 853
872 // be worth returning the resource to the pool with its previous ID (not
873 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method
874 // of achieving this.
875 resource_pool_->ReleaseResource(resource, 0 /* content_id */);
876 }
877 } else {
878 DCHECK(resource);
879 draw_info.set_use_resource();
880 draw_info.resource_ = resource;
881 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile);
882 }
883 DCHECK(draw_info.IsReadyToDraw()); 854 DCHECK(draw_info.IsReadyToDraw());
884 draw_info.set_was_ever_ready_to_draw(); 855 draw_info.set_was_ever_ready_to_draw();
885 856
886 client_->NotifyTileStateChanged(tile); 857 client_->NotifyTileStateChanged(tile);
887 } 858 }
888 859
889 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, 860 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info,
890 int layer_id, 861 int layer_id,
891 int source_frame_number, 862 int source_frame_number,
892 int flags) { 863 int flags) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 void TileManager::Signals::reset() { 1142 void TileManager::Signals::reset() {
1172 ready_to_activate = false; 1143 ready_to_activate = false;
1173 did_notify_ready_to_activate = false; 1144 did_notify_ready_to_activate = false;
1174 ready_to_draw = false; 1145 ready_to_draw = false;
1175 did_notify_ready_to_draw = false; 1146 did_notify_ready_to_draw = false;
1176 all_tile_tasks_completed = false; 1147 all_tile_tasks_completed = false;
1177 did_notify_all_tile_tasks_completed = false; 1148 did_notify_all_tile_tasks_completed = false;
1178 } 1149 }
1179 1150
1180 } // namespace cc 1151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698