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/resources/tile_manager.h" | 5 #include "cc/resources/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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 protected: | 89 protected: |
90 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 90 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } |
91 | 91 |
92 private: | 92 private: |
93 void Analyze(const RasterSource* raster_source) { | 93 void Analyze(const RasterSource* raster_source) { |
94 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( | 94 frame_viewer_instrumentation::ScopedAnalyzeTask analyze_task( |
95 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 95 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
96 | 96 |
97 DCHECK(raster_source); | 97 DCHECK(raster_source); |
98 | 98 |
99 raster_source->PerformSolidColorAnalysis( | 99 raster_source->PerformSolidColorAnalysis(content_rect_, contents_scale_, |
100 content_rect_, contents_scale_, &analysis_, rendering_stats_); | 100 &analysis_); |
101 | 101 |
102 // Record the solid color prediction. | 102 // Record the solid color prediction. |
103 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", | 103 UMA_HISTOGRAM_BOOLEAN("Renderer4.SolidColorTilesAnalyzed", |
104 analysis_.is_solid_color); | 104 analysis_.is_solid_color); |
105 | 105 |
106 // Clear the flag if we're not using the estimator. | 106 // Clear the flag if we're not using the estimator. |
107 analysis_.is_solid_color &= kUseColorEstimator; | 107 analysis_.is_solid_color &= kUseColorEstimator; |
108 } | 108 } |
109 | 109 |
110 void Raster(const RasterSource* raster_source) { | 110 void Raster(const RasterSource* raster_source) { |
111 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 111 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
112 tile_id_, tile_resolution_, source_frame_number_, layer_id_); | 112 tile_id_, tile_resolution_, source_frame_number_, layer_id_); |
113 devtools_instrumentation::ScopedLayerTask layer_task( | 113 devtools_instrumentation::ScopedLayerTask layer_task( |
114 devtools_instrumentation::kRasterTask, layer_id_); | 114 devtools_instrumentation::kRasterTask, layer_id_); |
115 | 115 |
116 base::TimeDelta prev_rasterize_time = | |
117 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | |
118 | |
119 // Only record rasterization time for highres tiles, because | |
120 // lowres tiles are not required for activation and therefore | |
121 // introduce noise in the measurement (sometimes they get rasterized | |
122 // before we draw and sometimes they aren't) | |
123 RenderingStatsInstrumentation* stats = | |
124 tile_resolution_ == HIGH_RESOLUTION ? rendering_stats_ : NULL; | |
125 DCHECK(raster_source); | 116 DCHECK(raster_source); |
126 | 117 |
127 raster_buffer_->Playback( | 118 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
128 raster_source_.get(), content_rect_, contents_scale_, stats); | 119 contents_scale_); |
129 | |
130 if (rendering_stats_->record_rendering_stats()) { | |
131 base::TimeDelta current_rasterize_time = | |
132 rendering_stats_->impl_thread_rendering_stats().rasterize_time; | |
133 LOCAL_HISTOGRAM_CUSTOM_COUNTS( | |
134 "Renderer4.PictureRasterTimeUS", | |
135 (current_rasterize_time - prev_rasterize_time).InMicroseconds(), | |
136 0, | |
137 100000, | |
138 100); | |
139 } | |
140 } | 120 } |
141 | 121 |
142 RasterSource::SolidColorAnalysis analysis_; | 122 RasterSource::SolidColorAnalysis analysis_; |
143 scoped_refptr<RasterSource> raster_source_; | 123 scoped_refptr<RasterSource> raster_source_; |
144 gfx::Rect content_rect_; | 124 gfx::Rect content_rect_; |
145 float contents_scale_; | 125 float contents_scale_; |
146 TileResolution tile_resolution_; | 126 TileResolution tile_resolution_; |
147 int layer_id_; | 127 int layer_id_; |
148 const void* tile_id_; | 128 const void* tile_id_; |
149 int source_frame_number_; | 129 int source_frame_number_; |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 | 554 |
575 // We won't be able to schedule this tile, so break out early. | 555 // We won't be able to schedule this tile, so break out early. |
576 if (tiles_that_need_to_be_rasterized->size() >= | 556 if (tiles_that_need_to_be_rasterized->size() >= |
577 scheduled_raster_task_limit_) { | 557 scheduled_raster_task_limit_) { |
578 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 558 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
579 break; | 559 break; |
580 } | 560 } |
581 | 561 |
582 ManagedTileState& mts = tile->managed_state(); | 562 ManagedTileState& mts = tile->managed_state(); |
583 mts.scheduled_priority = schedule_priority++; | 563 mts.scheduled_priority = schedule_priority++; |
| 564 mts.resolution = priority.resolution; |
584 | 565 |
585 DCHECK(mts.draw_info.mode() == | 566 DCHECK(mts.draw_info.mode() == |
586 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || | 567 ManagedTileState::DrawInfo::PICTURE_PILE_MODE || |
587 !mts.draw_info.IsReadyToDraw()); | 568 !mts.draw_info.IsReadyToDraw()); |
588 | 569 |
589 // If the tile already has a raster_task, then the memory used by it is | 570 // If the tile already has a raster_task, then the memory used by it is |
590 // already accounted for in memory_usage. Otherwise, we'll have to acquire | 571 // already accounted for in memory_usage. Otherwise, we'll have to acquire |
591 // more memory to create a raster task. | 572 // more memory to create a raster task. |
592 MemoryUsage memory_required_by_tile_to_be_scheduled; | 573 MemoryUsage memory_required_by_tile_to_be_scheduled; |
593 if (!mts.raster_task.get()) { | 574 if (!mts.raster_task.get()) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 used_layer_counts_[tile->layer_id()]++; | 830 used_layer_counts_[tile->layer_id()]++; |
850 return tile; | 831 return tile; |
851 } | 832 } |
852 | 833 |
853 void TileManager::SetRasterizerForTesting(Rasterizer* rasterizer) { | 834 void TileManager::SetRasterizerForTesting(Rasterizer* rasterizer) { |
854 rasterizer_ = rasterizer; | 835 rasterizer_ = rasterizer; |
855 rasterizer_->SetClient(this); | 836 rasterizer_->SetClient(this); |
856 } | 837 } |
857 | 838 |
858 bool TileManager::IsReadyToActivate() const { | 839 bool TileManager::IsReadyToActivate() const { |
| 840 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
859 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 841 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); |
860 | 842 |
861 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); | 843 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); |
862 it != layers.end(); | 844 it != layers.end(); |
863 ++it) { | 845 ++it) { |
864 if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) | 846 if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) |
865 return false; | 847 return false; |
866 } | 848 } |
867 | 849 |
868 return true; | 850 return true; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 result -= other; | 904 result -= other; |
923 return result; | 905 return result; |
924 } | 906 } |
925 | 907 |
926 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 908 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
927 return memory_bytes_ > limit.memory_bytes_ || | 909 return memory_bytes_ > limit.memory_bytes_ || |
928 resource_count_ > limit.resource_count_; | 910 resource_count_ > limit.resource_count_; |
929 } | 911 } |
930 | 912 |
931 } // namespace cc | 913 } // namespace cc |
OLD | NEW |