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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 SkColor color = SK_ColorTRANSPARENT; | |
575 bool is_solid_color = | |
576 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | |
ericrk
2016/01/07 18:18:10
There's a comment in the bug that we might be spen
sohanjg
2016/01/08 11:47:56
Acknowledged.
| |
577 tile->content_rect(), tile->contents_scale(), &color); | |
578 if (is_solid_color) { | |
579 tile->draw_info().set_solid_color(color); | |
vmpstr
2016/01/07 22:36:02
nit: call tile->draw_info().set_was_ever_ready_to_
sohanjg
2016/01/08 11:47:56
Done.
| |
580 continue; | |
581 } | |
582 } | |
583 | |
596 // We won't be able to schedule this tile, so break out early. | 584 // We won't be able to schedule this tile, so break out early. |
597 if (tiles_that_need_to_be_rasterized->size() >= | 585 if (tiles_that_need_to_be_rasterized->size() >= |
598 scheduled_raster_task_limit) { | 586 scheduled_raster_task_limit) { |
599 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 587 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
600 break; | 588 break; |
601 } | 589 } |
602 | 590 |
603 tile->scheduled_priority_ = schedule_priority++; | 591 tile->scheduled_priority_ = schedule_priority++; |
604 | 592 |
605 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || | 593 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( | 807 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( |
820 image, tile->layer_id(), prepare_tiles_count_)); | 808 image, tile->layer_id(), prepare_tiles_count_)); |
821 } | 809 } |
822 | 810 |
823 return make_scoped_refptr(new RasterTaskImpl( | 811 return make_scoped_refptr(new RasterTaskImpl( |
824 resource, prioritized_tile.raster_source(), tile->content_rect(), | 812 resource, prioritized_tile.raster_source(), tile->content_rect(), |
825 tile->invalidated_content_rect(), tile->contents_scale(), | 813 tile->invalidated_content_rect(), tile->contents_scale(), |
826 prioritized_tile.priority().resolution, tile->layer_id(), | 814 prioritized_tile.priority().resolution, tile->layer_id(), |
827 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), | 815 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), |
828 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), | 816 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), |
829 tile->use_picture_analysis(), | |
830 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 817 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
831 tile->id(), resource), | 818 tile->id(), resource), |
832 &decode_tasks)); | 819 &decode_tasks)); |
833 } | 820 } |
834 | 821 |
835 void TileManager::OnRasterTaskCompleted( | 822 void TileManager::OnRasterTaskCompleted( |
836 Tile::Id tile_id, | 823 Tile::Id tile_id, |
837 Resource* resource, | 824 Resource* resource, |
838 const DisplayListRasterSource::SolidColorAnalysis& analysis, | |
839 bool was_canceled) { | 825 bool was_canceled) { |
840 DCHECK(tiles_.find(tile_id) != tiles_.end()); | 826 DCHECK(tiles_.find(tile_id) != tiles_.end()); |
841 | 827 |
842 Tile* tile = tiles_[tile_id]; | 828 Tile* tile = tiles_[tile_id]; |
843 DCHECK(tile->raster_task_.get()); | 829 DCHECK(tile->raster_task_.get()); |
844 orphan_tasks_.push_back(tile->raster_task_); | 830 orphan_tasks_.push_back(tile->raster_task_); |
845 tile->raster_task_ = nullptr; | 831 tile->raster_task_ = nullptr; |
846 | 832 |
847 if (was_canceled) { | 833 if (was_canceled) { |
848 ++flush_stats_.canceled_count; | 834 ++flush_stats_.canceled_count; |
849 // TODO(ericrk): If more partial raster work is done in the future, it may | 835 // 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 | 836 // be worth returning the resource to the pool with its previous ID (not |
851 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method | 837 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method |
852 // of achieving this. | 838 // of achieving this. |
853 resource_pool_->ReleaseResource(resource, 0 /* content_id */); | 839 resource_pool_->ReleaseResource(resource, 0 /* content_id */); |
854 return; | 840 return; |
855 } | 841 } |
856 | 842 |
857 UpdateTileDrawInfo(tile, resource, analysis); | 843 UpdateTileDrawInfo(tile, resource); |
vmpstr
2016/01/07 22:36:02
nit: since a lot of the logic of UpdateTileDrawInf
sohanjg
2016/01/08 11:47:56
Done.
| |
858 } | 844 } |
859 | 845 |
860 void TileManager::UpdateTileDrawInfo( | 846 void TileManager::UpdateTileDrawInfo(Tile* tile, Resource* resource) { |
861 Tile* tile, | |
862 Resource* resource, | |
863 const DisplayListRasterSource::SolidColorAnalysis& analysis) { | |
864 TileDrawInfo& draw_info = tile->draw_info(); | 847 TileDrawInfo& draw_info = tile->draw_info(); |
865 | 848 |
866 ++flush_stats_.completed_count; | 849 ++flush_stats_.completed_count; |
867 | 850 |
868 if (analysis.is_solid_color) { | 851 DCHECK(resource); |
869 draw_info.set_solid_color(analysis.solid_color); | 852 draw_info.set_use_resource(); |
870 if (resource) { | 853 draw_info.resource_ = resource; |
871 // TODO(ericrk): If more partial raster work is done in the future, it may | 854 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); |
872 // be worth returning the resource to the pool with its previous ID (not | 855 |
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()); | 856 DCHECK(draw_info.IsReadyToDraw()); |
884 draw_info.set_was_ever_ready_to_draw(); | 857 draw_info.set_was_ever_ready_to_draw(); |
885 | 858 |
886 client_->NotifyTileStateChanged(tile); | 859 client_->NotifyTileStateChanged(tile); |
887 } | 860 } |
888 | 861 |
889 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, | 862 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, |
890 int layer_id, | 863 int layer_id, |
891 int source_frame_number, | 864 int source_frame_number, |
892 int flags) { | 865 int flags) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 void TileManager::Signals::reset() { | 1144 void TileManager::Signals::reset() { |
1172 ready_to_activate = false; | 1145 ready_to_activate = false; |
1173 did_notify_ready_to_activate = false; | 1146 did_notify_ready_to_activate = false; |
1174 ready_to_draw = false; | 1147 ready_to_draw = false; |
1175 did_notify_ready_to_draw = false; | 1148 did_notify_ready_to_draw = false; |
1176 all_tile_tasks_completed = false; | 1149 all_tile_tasks_completed = false; |
1177 did_notify_all_tile_tasks_completed = false; | 1150 did_notify_all_tile_tasks_completed = false; |
1178 } | 1151 } |
1179 | 1152 |
1180 } // namespace cc | 1153 } // namespace cc |
OLD | NEW |