OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/benchmarks/rasterize_and_record_benchmark.h" | 5 #include "cc/benchmarks/rasterize_and_record_benchmark.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 weak_ptr_factory_.GetWeakPtr()))); | 132 weak_ptr_factory_.GetWeakPtr()))); |
133 } | 133 } |
134 | 134 |
135 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { | 135 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
136 DCHECK(layer_tree_host_); | 136 DCHECK(layer_tree_host_); |
137 | 137 |
138 if (!layer->DrawsContent()) | 138 if (!layer->DrawsContent()) |
139 return; | 139 return; |
140 | 140 |
141 ContentLayerClient* painter = layer->client(); | 141 ContentLayerClient* painter = layer->client(); |
| 142 RecordingSource recording_source; |
142 | 143 |
143 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; | 144 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; |
144 mode_index++) { | 145 mode_index++) { |
145 ContentLayerClient::PaintingControlSetting painting_control = | 146 ContentLayerClient::PaintingControlSetting painting_control = |
146 RecordingModeToPaintingControlSetting( | 147 RecordingModeToPaintingControlSetting( |
147 static_cast<RecordingSource::RecordingMode>(mode_index)); | 148 static_cast<RecordingSource::RecordingMode>(mode_index)); |
148 base::TimeDelta min_time = base::TimeDelta::Max(); | 149 base::TimeDelta min_time = base::TimeDelta::Max(); |
149 size_t memory_used = 0; | 150 size_t memory_used = 0; |
150 | 151 |
151 scoped_refptr<DisplayItemList> display_list; | 152 scoped_refptr<DisplayItemList> display_list; |
152 for (int i = 0; i < record_repeat_count_; ++i) { | 153 for (int i = 0; i < record_repeat_count_; ++i) { |
153 // Run for a minimum amount of time to avoid problems with timer | 154 // Run for a minimum amount of time to avoid problems with timer |
154 // quantization when the layer is very small. | 155 // quantization when the layer is very small. |
155 LapTimer timer(kWarmupRuns, | 156 LapTimer timer(kWarmupRuns, |
156 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 157 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
157 kTimeCheckInterval); | 158 kTimeCheckInterval); |
158 | 159 |
159 do { | 160 do { |
160 display_list = painter->PaintContentsToDisplayList(painting_control); | 161 display_list = painter->PaintContentsToDisplayList(painting_control); |
161 if (display_list->ShouldBeAnalyzedForSolidColor()) { | 162 recording_source.UpdateDisplayItemList( |
162 gfx::Size layer_size = layer->paint_properties().bounds; | 163 display_list, painter->GetApproximateUnsharedMemoryUsage()); |
163 skia::AnalysisCanvas canvas(layer_size.width(), layer_size.height()); | |
164 display_list->Raster(&canvas, nullptr, gfx::Rect(layer_size), 1.f); | |
165 } | |
166 | 164 |
167 if (memory_used) { | 165 if (memory_used) { |
168 // Verify we are recording the same thing each time. | 166 // Verify we are recording the same thing each time. |
169 DCHECK_EQ(memory_used, display_list->ApproximateMemoryUsage()); | 167 DCHECK_EQ(memory_used, display_list->ApproximateMemoryUsage()); |
170 } else { | 168 } else { |
171 memory_used = display_list->ApproximateMemoryUsage(); | 169 memory_used = display_list->ApproximateMemoryUsage(); |
172 } | 170 } |
173 | 171 |
174 timer.NextLap(); | 172 timer.NextLap(); |
175 } while (!timer.HasTimeLimitExpired()); | 173 } while (!timer.HasTimeLimitExpired()); |
(...skipping 12 matching lines...) Expand all Loading... |
188 record_results_.total_best_time[mode_index] += min_time; | 186 record_results_.total_best_time[mode_index] += min_time; |
189 } | 187 } |
190 } | 188 } |
191 | 189 |
192 RasterizeAndRecordBenchmark::RecordResults::RecordResults() | 190 RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
193 : pixels_recorded(0), bytes_used(0) {} | 191 : pixels_recorded(0), bytes_used(0) {} |
194 | 192 |
195 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} | 193 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |
196 | 194 |
197 } // namespace cc | 195 } // namespace cc |
OLD | NEW |