Chromium Code Reviews| 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; | |
| 143 recording_source.SetGenerateDiscardableImagesMetadata(true); | |
|
vmpstr
2017/04/27 17:41:45
This part is going away in a patch that is current
Khushal
2017/04/27 17:56:33
The patch that removes this has landed. :P
| |
| 142 | 144 |
| 143 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; | 145 for (int mode_index = 0; mode_index < RecordingSource::RECORDING_MODE_COUNT; |
| 144 mode_index++) { | 146 mode_index++) { |
| 145 ContentLayerClient::PaintingControlSetting painting_control = | 147 ContentLayerClient::PaintingControlSetting painting_control = |
| 146 RecordingModeToPaintingControlSetting( | 148 RecordingModeToPaintingControlSetting( |
| 147 static_cast<RecordingSource::RecordingMode>(mode_index)); | 149 static_cast<RecordingSource::RecordingMode>(mode_index)); |
| 148 base::TimeDelta min_time = base::TimeDelta::Max(); | 150 base::TimeDelta min_time = base::TimeDelta::Max(); |
| 149 size_t memory_used = 0; | 151 size_t memory_used = 0; |
| 150 | 152 |
| 151 scoped_refptr<DisplayItemList> display_list; | 153 scoped_refptr<DisplayItemList> display_list; |
| 152 for (int i = 0; i < record_repeat_count_; ++i) { | 154 for (int i = 0; i < record_repeat_count_; ++i) { |
| 153 // Run for a minimum amount of time to avoid problems with timer | 155 // Run for a minimum amount of time to avoid problems with timer |
| 154 // quantization when the layer is very small. | 156 // quantization when the layer is very small. |
| 155 LapTimer timer(kWarmupRuns, | 157 LapTimer timer(kWarmupRuns, |
| 156 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 158 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 157 kTimeCheckInterval); | 159 kTimeCheckInterval); |
| 158 | 160 |
| 159 do { | 161 do { |
| 160 display_list = painter->PaintContentsToDisplayList(painting_control); | 162 display_list = painter->PaintContentsToDisplayList(painting_control); |
| 161 if (display_list->ShouldBeAnalyzedForSolidColor()) { | 163 recording_source.UpdateDisplayItemList( |
| 162 gfx::Size layer_size = layer->paint_properties().bounds; | 164 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 | 165 |
| 167 if (memory_used) { | 166 if (memory_used) { |
| 168 // Verify we are recording the same thing each time. | 167 // Verify we are recording the same thing each time. |
| 169 DCHECK_EQ(memory_used, display_list->ApproximateMemoryUsage()); | 168 DCHECK_EQ(memory_used, display_list->ApproximateMemoryUsage()); |
| 170 } else { | 169 } else { |
| 171 memory_used = display_list->ApproximateMemoryUsage(); | 170 memory_used = display_list->ApproximateMemoryUsage(); |
| 172 } | 171 } |
| 173 | 172 |
| 174 timer.NextLap(); | 173 timer.NextLap(); |
| 175 } while (!timer.HasTimeLimitExpired()); | 174 } while (!timer.HasTimeLimitExpired()); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 188 record_results_.total_best_time[mode_index] += min_time; | 187 record_results_.total_best_time[mode_index] += min_time; |
| 189 } | 188 } |
| 190 } | 189 } |
| 191 | 190 |
| 192 RasterizeAndRecordBenchmark::RecordResults::RecordResults() | 191 RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
| 193 : pixels_recorded(0), bytes_used(0) {} | 192 : pixels_recorded(0), bytes_used(0) {} |
| 194 | 193 |
| 195 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} | 194 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |
| 196 | 195 |
| 197 } // namespace cc | 196 } // namespace cc |
| OLD | NEW |