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> |
11 | 11 |
12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "cc/base/scale_translate2d.h" |
13 #include "cc/debug/lap_timer.h" | 14 #include "cc/debug/lap_timer.h" |
14 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
15 #include "cc/layers/picture_layer_impl.h" | 16 #include "cc/layers/picture_layer_impl.h" |
16 #include "cc/raster/raster_buffer_provider.h" | 17 #include "cc/raster/raster_buffer_provider.h" |
17 #include "cc/trees/layer_tree_host_common.h" | 18 #include "cc/trees/layer_tree_host_common.h" |
18 #include "cc/trees/layer_tree_host_impl.h" | 19 #include "cc/trees/layer_tree_host_impl.h" |
19 #include "cc/trees/layer_tree_impl.h" | 20 #include "cc/trees/layer_tree_impl.h" |
20 #include "ui/gfx/geometry/rect.h" | 21 #include "ui/gfx/geometry/rect.h" |
21 | 22 |
22 namespace cc { | 23 namespace cc { |
(...skipping 23 matching lines...) Expand all Loading... |
46 SkColor color = SK_ColorTRANSPARENT; | 47 SkColor color = SK_ColorTRANSPARENT; |
47 *is_solid_color = raster_source->PerformSolidColorAnalysis( | 48 *is_solid_color = raster_source->PerformSolidColorAnalysis( |
48 content_rect, contents_scale, &color); | 49 content_rect, contents_scale, &color); |
49 | 50 |
50 do { | 51 do { |
51 SkBitmap bitmap; | 52 SkBitmap bitmap; |
52 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(), | 53 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect.width(), |
53 content_rect.height())); | 54 content_rect.height())); |
54 SkCanvas canvas(bitmap); | 55 SkCanvas canvas(bitmap); |
55 | 56 |
56 raster_source->PlaybackToCanvas(&canvas, content_rect, content_rect, | 57 raster_source->PlaybackToCanvas( |
57 contents_scale, | 58 &canvas, content_rect, content_rect, |
58 RasterSource::PlaybackSettings()); | 59 ScaleTranslate2d(contents_scale, gfx::Vector2dF()), |
| 60 RasterSource::PlaybackSettings()); |
59 | 61 |
60 timer.NextLap(); | 62 timer.NextLap(); |
61 } while (!timer.HasTimeLimitExpired()); | 63 } while (!timer.HasTimeLimitExpired()); |
62 base::TimeDelta duration = | 64 base::TimeDelta duration = |
63 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); | 65 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
64 if (duration < *min_time) | 66 if (duration < *min_time) |
65 *min_time = duration; | 67 *min_time = duration; |
66 } | 68 } |
67 } | 69 } |
68 | 70 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // it takes to rasterize content. As such, the actual settings used here don't | 172 // it takes to rasterize content. As such, the actual settings used here don't |
171 // really matter. | 173 // really matter. |
172 const LayerTreeSettings& settings = layer->layer_tree_impl()->settings(); | 174 const LayerTreeSettings& settings = layer->layer_tree_impl()->settings(); |
173 std::unique_ptr<PictureLayerTilingSet> tiling_set = | 175 std::unique_ptr<PictureLayerTilingSet> tiling_set = |
174 PictureLayerTilingSet::Create( | 176 PictureLayerTilingSet::Create( |
175 layer->GetTree(), &client, settings.tiling_interest_area_padding, | 177 layer->GetTree(), &client, settings.tiling_interest_area_padding, |
176 settings.skewport_target_time_in_seconds, | 178 settings.skewport_target_time_in_seconds, |
177 settings.skewport_extrapolation_limit_in_screen_pixels); | 179 settings.skewport_extrapolation_limit_in_screen_pixels); |
178 | 180 |
179 PictureLayerTiling* tiling = | 181 PictureLayerTiling* tiling = |
180 tiling_set->AddTiling(1.f, layer->GetRasterSource()); | 182 tiling_set->AddTiling(ScaleTranslate2d(), layer->GetRasterSource()); |
181 tiling->set_resolution(HIGH_RESOLUTION); | 183 tiling->set_resolution(HIGH_RESOLUTION); |
182 tiling->CreateAllTilesForTesting(); | 184 tiling->CreateAllTilesForTesting(); |
183 RasterSource* raster_source = tiling->raster_source().get(); | 185 RasterSource* raster_source = tiling->raster_source().get(); |
184 for (PictureLayerTiling::CoverageIterator it(tiling, 1.f, | 186 for (PictureLayerTiling::CoverageIterator it(tiling, 1.f, |
185 layer->visible_layer_rect()); | 187 layer->visible_layer_rect()); |
186 it; ++it) { | 188 it; ++it) { |
187 DCHECK(*it); | 189 DCHECK(*it); |
188 | 190 |
189 gfx::Rect content_rect = (*it)->content_rect(); | 191 gfx::Rect content_rect = (*it)->content_rect(); |
190 float contents_scale = (*it)->contents_scale(); | 192 float contents_scale = (*it)->contents_transform().pre_scale(); |
| 193 DCHECK_EQ(1.f, contents_scale); |
191 | 194 |
192 base::TimeDelta min_time; | 195 base::TimeDelta min_time; |
193 bool is_solid_color = false; | 196 bool is_solid_color = false; |
194 RunBenchmark(raster_source, content_rect, contents_scale, | 197 RunBenchmark(raster_source, content_rect, contents_scale, |
195 rasterize_repeat_count_, &min_time, &is_solid_color); | 198 rasterize_repeat_count_, &min_time, &is_solid_color); |
196 | 199 |
197 int tile_size = content_rect.width() * content_rect.height(); | 200 int tile_size = content_rect.width() * content_rect.height(); |
198 if (layer->contents_opaque()) | 201 if (layer->contents_opaque()) |
199 rasterize_results_.pixels_rasterized_as_opaque += tile_size; | 202 rasterize_results_.pixels_rasterized_as_opaque += tile_size; |
200 | 203 |
(...skipping 16 matching lines...) Expand all Loading... |
217 total_memory_usage(0), | 220 total_memory_usage(0), |
218 total_layers(0), | 221 total_layers(0), |
219 total_picture_layers(0), | 222 total_picture_layers(0), |
220 total_picture_layers_with_no_content(0), | 223 total_picture_layers_with_no_content(0), |
221 total_picture_layers_off_screen(0) { | 224 total_picture_layers_off_screen(0) { |
222 } | 225 } |
223 | 226 |
224 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} | 227 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} |
225 | 228 |
226 } // namespace cc | 229 } // namespace cc |
OLD | NEW |