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_impl.h" | 5 #include "cc/debug/rasterize_and_record_benchmark_impl.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 10 matching lines...) Expand all Loading... |
21 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const int kDefaultRasterizeRepeatCount = 100; | 27 const int kDefaultRasterizeRepeatCount = 100; |
28 | 28 |
29 void RunBenchmark(RasterSource* raster_source, | 29 void RunBenchmark(RasterSource* raster_source, |
30 const gfx::Rect& content_rect, | 30 const gfx::Rect& content_rect, |
31 const gfx::SizeF& raster_scales, | 31 float raster_scale, |
32 size_t repeat_count, | 32 size_t repeat_count, |
33 base::TimeDelta* min_time, | 33 base::TimeDelta* min_time, |
34 bool* is_solid_color) { | 34 bool* is_solid_color) { |
35 // Parameters for LapTimer. | 35 // Parameters for LapTimer. |
36 const int kTimeLimitMillis = 1; | 36 const int kTimeLimitMillis = 1; |
37 const int kWarmupRuns = 0; | 37 const int kWarmupRuns = 0; |
38 const int kTimeCheckInterval = 1; | 38 const int kTimeCheckInterval = 1; |
39 | 39 |
40 *min_time = base::TimeDelta::Max(); | 40 *min_time = base::TimeDelta::Max(); |
41 for (size_t i = 0; i < repeat_count; ++i) { | 41 for (size_t i = 0; i < repeat_count; ++i) { |
42 // Run for a minimum amount of time to avoid problems with timer | 42 // Run for a minimum amount of time to avoid problems with timer |
43 // quantization when the layer is very small. | 43 // quantization when the layer is very small. |
44 LapTimer timer(kWarmupRuns, | 44 LapTimer timer(kWarmupRuns, |
45 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 45 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
46 kTimeCheckInterval); | 46 kTimeCheckInterval); |
47 SkColor color = SK_ColorTRANSPARENT; | 47 SkColor color = SK_ColorTRANSPARENT; |
48 *is_solid_color = raster_source->PerformSolidColorAnalysis( | 48 *is_solid_color = raster_source->PerformSolidColorAnalysis( |
49 content_rect, raster_scales, &color); | 49 content_rect, raster_scale, &color); |
50 | 50 |
51 do { | 51 do { |
52 SkBitmap bitmap; | 52 SkBitmap bitmap; |
53 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(), | 53 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(), |
54 content_rect.height())); | 54 content_rect.height())); |
55 SkCanvas canvas(bitmap); | 55 SkCanvas canvas(bitmap); |
56 | 56 |
57 DCHECK_EQ(raster_scales.width(), raster_scales.height()); | |
58 raster_source->PlaybackToCanvas(&canvas, content_rect, content_rect, | 57 raster_source->PlaybackToCanvas(&canvas, content_rect, content_rect, |
59 ScaleTranslate2d(raster_scales.width(), gf
x::Vector2dF()), | 58 ScaleTranslate2d(raster_scale, gfx::Vector
2dF()), |
60 RasterSource::PlaybackSettings()); | 59 RasterSource::PlaybackSettings()); |
61 | 60 |
62 timer.NextLap(); | 61 timer.NextLap(); |
63 } while (!timer.HasTimeLimitExpired()); | 62 } while (!timer.HasTimeLimitExpired()); |
64 base::TimeDelta duration = | 63 base::TimeDelta duration = |
65 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); | 64 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
66 if (duration < *min_time) | 65 if (duration < *min_time) |
67 *min_time = duration; | 66 *min_time = duration; |
68 } | 67 } |
69 } | 68 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // really matter. | 172 // really matter. |
174 const LayerTreeSettings& settings = layer->layer_tree_impl()->settings(); | 173 const LayerTreeSettings& settings = layer->layer_tree_impl()->settings(); |
175 std::unique_ptr<PictureLayerTilingSet> tiling_set = | 174 std::unique_ptr<PictureLayerTilingSet> tiling_set = |
176 PictureLayerTilingSet::Create( | 175 PictureLayerTilingSet::Create( |
177 layer->GetTree(), &client, settings.tiling_interest_area_padding, | 176 layer->GetTree(), &client, settings.tiling_interest_area_padding, |
178 settings.skewport_target_time_in_seconds, | 177 settings.skewport_target_time_in_seconds, |
179 settings.skewport_extrapolation_limit_in_screen_pixels, | 178 settings.skewport_extrapolation_limit_in_screen_pixels, |
180 settings.max_preraster_distance_in_screen_pixels); | 179 settings.max_preraster_distance_in_screen_pixels); |
181 | 180 |
182 PictureLayerTiling* tiling = | 181 PictureLayerTiling* tiling = |
183 tiling_set->AddTiling(1.f, layer->GetRasterSource()); | 182 tiling_set->AddTiling(ScaleTranslate2d(), layer->GetRasterSource()); |
184 tiling->set_resolution(HIGH_RESOLUTION); | 183 tiling->set_resolution(HIGH_RESOLUTION); |
185 tiling->CreateAllTilesForTesting(); | 184 tiling->CreateAllTilesForTesting(); |
186 RasterSource* raster_source = tiling->raster_source().get(); | 185 RasterSource* raster_source = tiling->raster_source().get(); |
187 for (PictureLayerTiling::CoverageIterator it(tiling, 1.f, | 186 for (PictureLayerTiling::CoverageIterator it(tiling, 1.f, |
188 layer->visible_layer_rect()); | 187 layer->visible_layer_rect()); |
189 it; ++it) { | 188 it; ++it) { |
190 DCHECK(*it); | 189 DCHECK(*it); |
191 | 190 |
192 gfx::Rect content_rect = (*it)->content_rect(); | 191 gfx::Rect content_rect = (*it)->content_rect(); |
193 const gfx::SizeF& raster_scales = (*it)->raster_scales(); | 192 float raster_scale = (*it)->raster_transform().scale(); |
| 193 DCHECK_EQ(1.f, raster_scale); |
194 | 194 |
195 base::TimeDelta min_time; | 195 base::TimeDelta min_time; |
196 bool is_solid_color = false; | 196 bool is_solid_color = false; |
197 RunBenchmark(raster_source, content_rect, raster_scales, | 197 RunBenchmark(raster_source, content_rect, raster_scale, |
198 rasterize_repeat_count_, &min_time, &is_solid_color); | 198 rasterize_repeat_count_, &min_time, &is_solid_color); |
199 | 199 |
200 int tile_size = content_rect.width() * content_rect.height(); | 200 int tile_size = content_rect.width() * content_rect.height(); |
201 if (layer->contents_opaque()) | 201 if (layer->contents_opaque()) |
202 rasterize_results_.pixels_rasterized_as_opaque += tile_size; | 202 rasterize_results_.pixels_rasterized_as_opaque += tile_size; |
203 | 203 |
204 if (!is_solid_color) | 204 if (!is_solid_color) |
205 rasterize_results_.pixels_rasterized_with_non_solid_color += tile_size; | 205 rasterize_results_.pixels_rasterized_with_non_solid_color += tile_size; |
206 | 206 |
207 rasterize_results_.pixels_rasterized += tile_size; | 207 rasterize_results_.pixels_rasterized += tile_size; |
(...skipping 12 matching lines...) Expand all Loading... |
220 total_memory_usage(0), | 220 total_memory_usage(0), |
221 total_layers(0), | 221 total_layers(0), |
222 total_picture_layers(0), | 222 total_picture_layers(0), |
223 total_picture_layers_with_no_content(0), | 223 total_picture_layers_with_no_content(0), |
224 total_picture_layers_off_screen(0) { | 224 total_picture_layers_off_screen(0) { |
225 } | 225 } |
226 | 226 |
227 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} | 227 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} |
228 | 228 |
229 } // namespace cc | 229 } // namespace cc |
OLD | NEW |