| 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/debug/rasterize_and_record_benchmark.h" | 5 #include "cc/debug/rasterize_and_record_benchmark.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 layer->RunMicroBenchmark(this); | 101 layer->RunMicroBenchmark(this); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { | 104 void RasterizeAndRecordBenchmark::RunOnLayer(PictureLayer* layer) { |
| 105 ContentLayerClient* painter = layer->client(); | 105 ContentLayerClient* painter = layer->client(); |
| 106 gfx::Size content_bounds = layer->content_bounds(); | 106 gfx::Size content_bounds = layer->content_bounds(); |
| 107 | 107 |
| 108 DCHECK(host_); | 108 DCHECK(host_); |
| 109 gfx::Size tile_grid_size = host_->settings().default_tile_size; | 109 gfx::Size tile_grid_size = host_->settings().default_tile_size; |
| 110 | 110 |
| 111 SkTileGridFactory::TileGridInfo tile_grid_info; | |
| 112 PicturePile::ComputeTileGridInfo(tile_grid_size, &tile_grid_info); | |
| 113 | |
| 114 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( | 111 gfx::Rect visible_content_rect = gfx::ScaleToEnclosingRect( |
| 115 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); | 112 layer->visible_content_rect(), 1.f / layer->contents_scale_x()); |
| 116 if (visible_content_rect.IsEmpty()) | 113 if (visible_content_rect.IsEmpty()) |
| 117 return; | 114 return; |
| 118 | 115 |
| 119 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; | 116 for (int mode_index = 0; mode_index < Picture::RECORDING_MODE_COUNT; |
| 120 mode_index++) { | 117 mode_index++) { |
| 121 Picture::RecordingMode mode = | 118 Picture::RecordingMode mode = |
| 122 static_cast<Picture::RecordingMode>(mode_index); | 119 static_cast<Picture::RecordingMode>(mode_index); |
| 123 base::TimeDelta min_time = base::TimeDelta::Max(); | 120 base::TimeDelta min_time = base::TimeDelta::Max(); |
| 124 size_t memory_used = 0; | 121 size_t memory_used = 0; |
| 125 | 122 |
| 126 // Parameters for LapTimer. | 123 // Parameters for LapTimer. |
| 127 const int kTimeLimitMillis = 1; | 124 const int kTimeLimitMillis = 1; |
| 128 const int kWarmupRuns = 0; | 125 const int kWarmupRuns = 0; |
| 129 const int kTimeCheckInterval = 1; | 126 const int kTimeCheckInterval = 1; |
| 130 | 127 |
| 131 for (int i = 0; i < record_repeat_count_; ++i) { | 128 for (int i = 0; i < record_repeat_count_; ++i) { |
| 132 // Run for a minimum amount of time to avoid problems with timer | 129 // Run for a minimum amount of time to avoid problems with timer |
| 133 // quantization when the layer is very small. | 130 // quantization when the layer is very small. |
| 134 LapTimer timer(kWarmupRuns, | 131 LapTimer timer(kWarmupRuns, |
| 135 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 132 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 136 kTimeCheckInterval); | 133 kTimeCheckInterval); |
| 137 scoped_refptr<Picture> picture; | 134 scoped_refptr<Picture> picture; |
| 138 do { | 135 do { |
| 139 picture = Picture::Create(visible_content_rect, painter, tile_grid_info, | 136 picture = Picture::Create(visible_content_rect, painter, tile_grid_size, |
| 140 false, mode); | 137 false, mode); |
| 141 timer.NextLap(); | 138 timer.NextLap(); |
| 142 } while (!timer.HasTimeLimitExpired()); | 139 } while (!timer.HasTimeLimitExpired()); |
| 143 base::TimeDelta duration = | 140 base::TimeDelta duration = |
| 144 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); | 141 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
| 145 if (duration < min_time) | 142 if (duration < min_time) |
| 146 min_time = duration; | 143 min_time = duration; |
| 147 memory_used = picture->ApproximateMemoryUsage(); | 144 memory_used = picture->ApproximateMemoryUsage(); |
| 148 } | 145 } |
| 149 | 146 |
| 150 if (mode == Picture::RECORD_NORMALLY) { | 147 if (mode == Picture::RECORD_NORMALLY) { |
| 151 record_results_.bytes_used += memory_used; | 148 record_results_.bytes_used += memory_used; |
| 152 record_results_.pixels_recorded += | 149 record_results_.pixels_recorded += |
| 153 visible_content_rect.width() * visible_content_rect.height(); | 150 visible_content_rect.width() * visible_content_rect.height(); |
| 154 } | 151 } |
| 155 record_results_.total_best_time[mode_index] += min_time; | 152 record_results_.total_best_time[mode_index] += min_time; |
| 156 } | 153 } |
| 157 } | 154 } |
| 158 | 155 |
| 159 RasterizeAndRecordBenchmark::RecordResults::RecordResults() | 156 RasterizeAndRecordBenchmark::RecordResults::RecordResults() |
| 160 : pixels_recorded(0), bytes_used(0) { | 157 : pixels_recorded(0), bytes_used(0) { |
| 161 } | 158 } |
| 162 | 159 |
| 163 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} | 160 RasterizeAndRecordBenchmark::RecordResults::~RecordResults() {} |
| 164 | 161 |
| 165 } // namespace cc | 162 } // namespace cc |
| OLD | NEW |