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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 const gfx::Rect& invalid_content_rect, | 44 const gfx::Rect& invalid_content_rect, |
45 float contents_scale, | 45 float contents_scale, |
46 TileResolution tile_resolution, | 46 TileResolution tile_resolution, |
47 int layer_id, | 47 int layer_id, |
48 uint64_t source_prepare_tiles_id, | 48 uint64_t source_prepare_tiles_id, |
49 const void* tile, | 49 const void* tile, |
50 uint64_t new_content_id, | 50 uint64_t new_content_id, |
51 uint64_t previous_content_id, | 51 uint64_t previous_content_id, |
52 uint64_t resource_content_id, | 52 uint64_t resource_content_id, |
53 int source_frame_number, | 53 int source_frame_number, |
54 bool analyze_picture, | |
55 const base::Callback< | 54 const base::Callback< |
56 void(const DisplayListRasterSource::SolidColorAnalysis&, | 55 void(const DisplayListRasterSource::SolidColorAnalysis&, |
57 bool)>& reply, | 56 bool)>& reply, |
58 ImageDecodeTask::Vector* dependencies) | 57 ImageDecodeTask::Vector* dependencies) |
59 : RasterTask(dependencies), | 58 : RasterTask(dependencies), |
60 resource_(resource), | 59 resource_(resource), |
61 raster_source_(raster_source), | 60 raster_source_(raster_source), |
62 content_rect_(content_rect), | 61 content_rect_(content_rect), |
63 invalid_content_rect_(invalid_content_rect), | 62 invalid_content_rect_(invalid_content_rect), |
64 contents_scale_(contents_scale), | 63 contents_scale_(contents_scale), |
65 tile_resolution_(tile_resolution), | 64 tile_resolution_(tile_resolution), |
66 layer_id_(layer_id), | 65 layer_id_(layer_id), |
67 source_prepare_tiles_id_(source_prepare_tiles_id), | 66 source_prepare_tiles_id_(source_prepare_tiles_id), |
68 tile_(tile), | 67 tile_(tile), |
69 new_content_id_(new_content_id), | 68 new_content_id_(new_content_id), |
70 previous_content_id_(previous_content_id), | 69 previous_content_id_(previous_content_id), |
71 resource_content_id_(resource_content_id), | 70 resource_content_id_(resource_content_id), |
72 source_frame_number_(source_frame_number), | 71 source_frame_number_(source_frame_number), |
73 analyze_picture_(analyze_picture), | |
74 reply_(reply) {} | 72 reply_(reply) {} |
75 | 73 |
76 // Overridden from Task: | 74 // Overridden from Task: |
77 void RunOnWorkerThread() override { | 75 void RunOnWorkerThread() override { |
78 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 76 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
79 "source_prepare_tiles_id", source_prepare_tiles_id_); | 77 "source_prepare_tiles_id", source_prepare_tiles_id_); |
80 | 78 |
81 DCHECK(raster_source_.get()); | 79 DCHECK(raster_source_.get()); |
82 DCHECK(raster_buffer_); | 80 DCHECK(raster_buffer_); |
83 | 81 |
84 if (analyze_picture_) { | |
85 Analyze(raster_source_.get()); | |
86 if (analysis_.is_solid_color) | |
87 return; | |
88 } | |
89 | |
90 Raster(raster_source_.get()); | 82 Raster(raster_source_.get()); |
91 } | 83 } |
92 | 84 |
93 // Overridden from TileTask: | 85 // Overridden from TileTask: |
94 void ScheduleOnOriginThread(TileTaskClient* client) override { | 86 void ScheduleOnOriginThread(TileTaskClient* client) override { |
95 DCHECK(!raster_buffer_); | 87 DCHECK(!raster_buffer_); |
96 raster_buffer_ = client->AcquireBufferForRaster( | 88 raster_buffer_ = client->AcquireBufferForRaster( |
97 resource_, resource_content_id_, previous_content_id_); | 89 resource_, resource_content_id_, previous_content_id_); |
98 } | 90 } |
99 void CompleteOnOriginThread(TileTaskClient* client) override { | 91 void CompleteOnOriginThread(TileTaskClient* client) override { |
100 client->ReleaseBufferForRaster(std::move(raster_buffer_)); | 92 client->ReleaseBufferForRaster(std::move(raster_buffer_)); |
101 reply_.Run(analysis_, !HasFinishedRunning()); | 93 reply_.Run(analysis_, !HasFinishedRunning()); |
102 } | 94 } |
103 | 95 |
104 protected: | 96 protected: |
105 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 97 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } |
106 | 98 |
107 private: | 99 private: |
108 void Analyze(const DisplayListRasterSource* raster_source) { | |
109 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( | |
110 tile_, tile_resolution_, source_frame_number_, layer_id_); | |
111 | |
112 DCHECK(raster_source); | |
113 | |
114 raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_, | |
115 &analysis_); | |
116 // Clear the flag if we're not using the estimator. | |
117 analysis_.is_solid_color &= kUseColorEstimator; | |
118 } | |
119 | |
120 void Raster(const DisplayListRasterSource* raster_source) { | 100 void Raster(const DisplayListRasterSource* raster_source) { |
121 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 101 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
122 tile_, tile_resolution_, source_frame_number_, layer_id_); | 102 tile_, tile_resolution_, source_frame_number_, layer_id_); |
123 ScopedRasterTaskTimer timer; | 103 ScopedRasterTaskTimer timer; |
124 timer.SetArea(content_rect_.size().GetArea()); | 104 timer.SetArea(content_rect_.size().GetArea()); |
125 | 105 |
126 DCHECK(raster_source); | 106 DCHECK(raster_source); |
127 | 107 |
128 bool include_images = tile_resolution_ != LOW_RESOLUTION; | 108 bool include_images = tile_resolution_ != LOW_RESOLUTION; |
129 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 109 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
130 invalid_content_rect_, new_content_id_, | 110 invalid_content_rect_, new_content_id_, |
131 contents_scale_, include_images); | 111 contents_scale_, include_images); |
132 } | 112 } |
133 | 113 |
134 const Resource* resource_; | 114 const Resource* resource_; |
135 DisplayListRasterSource::SolidColorAnalysis analysis_; | 115 DisplayListRasterSource::SolidColorAnalysis analysis_; |
136 scoped_refptr<DisplayListRasterSource> raster_source_; | 116 scoped_refptr<DisplayListRasterSource> raster_source_; |
137 gfx::Rect content_rect_; | 117 gfx::Rect content_rect_; |
138 gfx::Rect invalid_content_rect_; | 118 gfx::Rect invalid_content_rect_; |
139 float contents_scale_; | 119 float contents_scale_; |
140 TileResolution tile_resolution_; | 120 TileResolution tile_resolution_; |
141 int layer_id_; | 121 int layer_id_; |
142 uint64_t source_prepare_tiles_id_; | 122 uint64_t source_prepare_tiles_id_; |
143 const void* tile_; | 123 const void* tile_; |
144 uint64_t new_content_id_; | 124 uint64_t new_content_id_; |
145 uint64_t previous_content_id_; | 125 uint64_t previous_content_id_; |
146 uint64_t resource_content_id_; | 126 uint64_t resource_content_id_; |
147 int source_frame_number_; | 127 int source_frame_number_; |
148 bool analyze_picture_; | |
149 const base::Callback<void(const DisplayListRasterSource::SolidColorAnalysis&, | 128 const base::Callback<void(const DisplayListRasterSource::SolidColorAnalysis&, |
150 bool)> reply_; | 129 bool)> reply_; |
151 scoped_ptr<RasterBuffer> raster_buffer_; | 130 scoped_ptr<RasterBuffer> raster_buffer_; |
152 | 131 |
153 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 132 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
154 }; | 133 }; |
155 | 134 |
156 // 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 |
157 // other remaining tasks. | 136 // other remaining tasks. |
158 const size_t kRequiredForActivationDoneTaskPriority = 1u; | 137 const size_t kRequiredForActivationDoneTaskPriority = 1u; |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 Tile* tile = prioritized_tile.tile(); | 558 Tile* tile = prioritized_tile.tile(); |
580 TilePriority priority = prioritized_tile.priority(); | 559 TilePriority priority = prioritized_tile.priority(); |
581 | 560 |
582 if (TilePriorityViolatesMemoryPolicy(priority)) { | 561 if (TilePriorityViolatesMemoryPolicy(priority)) { |
583 TRACE_EVENT_INSTANT0( | 562 TRACE_EVENT_INSTANT0( |
584 "cc", "TileManager::AssignGpuMemory tile violates memory policy", | 563 "cc", "TileManager::AssignGpuMemory tile violates memory policy", |
585 TRACE_EVENT_SCOPE_THREAD); | 564 TRACE_EVENT_SCOPE_THREAD); |
586 break; | 565 break; |
587 } | 566 } |
588 | 567 |
568 // We analyze for solid color here, to decide to continue | |
569 // or drop the tile for scheduling and raster. | |
570 SkColor color = SK_ColorTRANSPARENT; | |
vmpstr
2015/12/29 21:24:23
You'll need to skip this block if use_picture_anal
sohanjg
2015/12/30 12:45:47
Done.
| |
571 bool is_solid_color = | |
572 prioritized_tile.raster_source()->PerformSolidColorAnalysis( | |
573 tile->content_rect(), tile->contents_scale(), &color); | |
574 if (is_solid_color) { | |
575 tile->draw_info().set_solid_color(color); | |
576 continue; | |
577 } | |
578 | |
589 // We won't be able to schedule this tile, so break out early. | 579 // We won't be able to schedule this tile, so break out early. |
590 if (tiles_that_need_to_be_rasterized->size() >= | 580 if (tiles_that_need_to_be_rasterized->size() >= |
591 scheduled_raster_task_limit) { | 581 scheduled_raster_task_limit) { |
592 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 582 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
593 break; | 583 break; |
594 } | 584 } |
595 | 585 |
596 tile->scheduled_priority_ = schedule_priority++; | 586 tile->scheduled_priority_ = schedule_priority++; |
597 | 587 |
598 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || | 588 DCHECK(tile->draw_info().mode() == TileDrawInfo::OOM_MODE || |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( | 802 decode_tasks.push_back(image_decode_controller_.GetTaskForImage( |
813 image, tile->layer_id(), prepare_tiles_count_)); | 803 image, tile->layer_id(), prepare_tiles_count_)); |
814 } | 804 } |
815 | 805 |
816 return make_scoped_refptr(new RasterTaskImpl( | 806 return make_scoped_refptr(new RasterTaskImpl( |
817 resource, prioritized_tile.raster_source(), tile->content_rect(), | 807 resource, prioritized_tile.raster_source(), tile->content_rect(), |
818 tile->invalidated_content_rect(), tile->contents_scale(), | 808 tile->invalidated_content_rect(), tile->contents_scale(), |
819 prioritized_tile.priority().resolution, tile->layer_id(), | 809 prioritized_tile.priority().resolution, tile->layer_id(), |
820 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), | 810 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), |
821 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), | 811 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), |
822 tile->use_picture_analysis(), | |
823 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 812 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
824 tile->id(), resource), | 813 tile->id(), resource), |
825 &decode_tasks)); | 814 &decode_tasks)); |
826 } | 815 } |
827 | 816 |
828 void TileManager::OnRasterTaskCompleted( | 817 void TileManager::OnRasterTaskCompleted( |
829 Tile::Id tile_id, | 818 Tile::Id tile_id, |
830 Resource* resource, | 819 Resource* resource, |
831 const DisplayListRasterSource::SolidColorAnalysis& analysis, | 820 const DisplayListRasterSource::SolidColorAnalysis& analysis, |
832 bool was_canceled) { | 821 bool was_canceled) { |
(...skipping 18 matching lines...) Expand all Loading... | |
851 } | 840 } |
852 | 841 |
853 void TileManager::UpdateTileDrawInfo( | 842 void TileManager::UpdateTileDrawInfo( |
854 Tile* tile, | 843 Tile* tile, |
855 Resource* resource, | 844 Resource* resource, |
856 const DisplayListRasterSource::SolidColorAnalysis& analysis) { | 845 const DisplayListRasterSource::SolidColorAnalysis& analysis) { |
857 TileDrawInfo& draw_info = tile->draw_info(); | 846 TileDrawInfo& draw_info = tile->draw_info(); |
858 | 847 |
859 ++flush_stats_.completed_count; | 848 ++flush_stats_.completed_count; |
860 | 849 |
861 if (analysis.is_solid_color) { | 850 DCHECK(resource); |
862 draw_info.set_solid_color(analysis.solid_color); | 851 draw_info.set_use_resource(); |
863 if (resource) { | 852 draw_info.resource_ = resource; |
864 // TODO(ericrk): If more partial raster work is done in the future, it may | 853 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); |
865 // be worth returning the resource to the pool with its previous ID (not | 854 |
866 // currently tracked). crrev.com/1370333002/#ps40001 has a possible method | |
867 // of achieving this. | |
868 resource_pool_->ReleaseResource(resource, 0 /* content_id */); | |
869 } | |
870 } else { | |
871 DCHECK(resource); | |
872 draw_info.set_use_resource(); | |
873 draw_info.resource_ = resource; | |
874 draw_info.contents_swizzled_ = DetermineResourceRequiresSwizzle(tile); | |
875 } | |
876 DCHECK(draw_info.IsReadyToDraw()); | 855 DCHECK(draw_info.IsReadyToDraw()); |
877 draw_info.set_was_ever_ready_to_draw(); | 856 draw_info.set_was_ever_ready_to_draw(); |
878 | 857 |
879 client_->NotifyTileStateChanged(tile); | 858 client_->NotifyTileStateChanged(tile); |
880 } | 859 } |
881 | 860 |
882 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, | 861 ScopedTilePtr TileManager::CreateTile(const Tile::CreateInfo& info, |
883 int layer_id, | 862 int layer_id, |
884 int source_frame_number, | 863 int source_frame_number, |
885 int flags) { | 864 int flags) { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1164 void TileManager::Signals::reset() { | 1143 void TileManager::Signals::reset() { |
1165 ready_to_activate = false; | 1144 ready_to_activate = false; |
1166 did_notify_ready_to_activate = false; | 1145 did_notify_ready_to_activate = false; |
1167 ready_to_draw = false; | 1146 ready_to_draw = false; |
1168 did_notify_ready_to_draw = false; | 1147 did_notify_ready_to_draw = false; |
1169 all_tile_tasks_completed = false; | 1148 all_tile_tasks_completed = false; |
1170 did_notify_all_tile_tasks_completed = false; | 1149 did_notify_all_tile_tasks_completed = false; |
1171 } | 1150 } |
1172 | 1151 |
1173 } // namespace cc | 1152 } // namespace cc |
OLD | NEW |