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