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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 size_t repeat_count) | 31 size_t repeat_count) |
32 : picture_pile_(picture_pile), | 32 : picture_pile_(picture_pile), |
33 content_rect_(content_rect), | 33 content_rect_(content_rect), |
34 contents_scale_(contents_scale), | 34 contents_scale_(contents_scale), |
35 repeat_count_(repeat_count), | 35 repeat_count_(repeat_count), |
36 is_solid_color_(false), | 36 is_solid_color_(false), |
37 best_time_(base::TimeDelta::Max()) {} | 37 best_time_(base::TimeDelta::Max()) {} |
38 | 38 |
39 // Overridden from Task: | 39 // Overridden from Task: |
40 virtual void RunOnWorkerThread() OVERRIDE { | 40 virtual void RunOnWorkerThread() OVERRIDE { |
41 PicturePileImpl* picture_pile = picture_pile_->GetCloneForDrawingOnThread( | |
42 RasterWorkerPool::GetPictureCloneIndexForCurrentThread()); | |
43 | |
44 // Parameters for LapTimer. | 41 // Parameters for LapTimer. |
45 const int kTimeLimitMillis = 1; | 42 const int kTimeLimitMillis = 1; |
46 const int kWarmupRuns = 0; | 43 const int kWarmupRuns = 0; |
47 const int kTimeCheckInterval = 1; | 44 const int kTimeCheckInterval = 1; |
48 | 45 |
49 for (size_t i = 0; i < repeat_count_; ++i) { | 46 for (size_t i = 0; i < repeat_count_; ++i) { |
50 // Run for a minimum amount of time to avoid problems with timer | 47 // Run for a minimum amount of time to avoid problems with timer |
51 // quantization when the layer is very small. | 48 // quantization when the layer is very small. |
52 LapTimer timer(kWarmupRuns, | 49 LapTimer timer(kWarmupRuns, |
53 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 50 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
54 kTimeCheckInterval); | 51 kTimeCheckInterval); |
55 do { | 52 do { |
56 SkBitmap bitmap; | 53 SkBitmap bitmap; |
57 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), | 54 bitmap.allocPixels(SkImageInfo::MakeN32Premul(content_rect_.width(), |
58 content_rect_.height())); | 55 content_rect_.height())); |
59 SkCanvas canvas(bitmap); | 56 SkCanvas canvas(bitmap); |
60 PicturePileImpl::Analysis analysis; | 57 PicturePileImpl::Analysis analysis; |
61 | 58 |
62 picture_pile->AnalyzeInRect( | 59 picture_pile_->AnalyzeInRect( |
63 content_rect_, contents_scale_, &analysis, NULL); | 60 content_rect_, contents_scale_, &analysis, NULL); |
64 picture_pile->RasterToBitmap( | 61 picture_pile_->RasterToBitmap( |
65 &canvas, content_rect_, contents_scale_, NULL); | 62 &canvas, content_rect_, contents_scale_, NULL); |
66 | 63 |
67 is_solid_color_ = analysis.is_solid_color; | 64 is_solid_color_ = analysis.is_solid_color; |
68 | 65 |
69 timer.NextLap(); | 66 timer.NextLap(); |
70 } while (!timer.HasTimeLimitExpired()); | 67 } while (!timer.HasTimeLimitExpired()); |
71 base::TimeDelta duration = | 68 base::TimeDelta duration = |
72 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); | 69 base::TimeDelta::FromMillisecondsD(timer.MsPerLap()); |
73 if (duration < best_time_) | 70 if (duration < best_time_) |
74 best_time_ = duration; | 71 best_time_ = duration; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 pixels_rasterized_with_non_solid_color(0), | 262 pixels_rasterized_with_non_solid_color(0), |
266 pixels_rasterized_as_opaque(0), | 263 pixels_rasterized_as_opaque(0), |
267 total_layers(0), | 264 total_layers(0), |
268 total_picture_layers(0), | 265 total_picture_layers(0), |
269 total_picture_layers_with_no_content(0), | 266 total_picture_layers_with_no_content(0), |
270 total_picture_layers_off_screen(0) {} | 267 total_picture_layers_off_screen(0) {} |
271 | 268 |
272 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} | 269 RasterizeAndRecordBenchmarkImpl::RasterizeResults::~RasterizeResults() {} |
273 | 270 |
274 } // namespace cc | 271 } // namespace cc |
OLD | NEW |