OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/picture_pile.h" | 5 #include "cc/resources/picture_pile.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "cc/base/region.h" | 11 #include "cc/base/region.h" |
11 #include "cc/debug/benchmark_instrumentation.h" | 12 #include "cc/debug/benchmark_instrumentation.h" |
| 13 #include "cc/debug/rendering_stats_instrumentation.h" |
12 #include "cc/resources/picture_pile_impl.h" | 14 #include "cc/resources/picture_pile_impl.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 // Maximum number of pictures that can overlap before we collapse them into | 17 // Maximum number of pictures that can overlap before we collapse them into |
16 // a larger one. | 18 // a larger one. |
17 const size_t kMaxOverlapping = 2; | 19 const size_t kMaxOverlapping = 2; |
18 // Maximum percentage area of the base picture another picture in the picture | 20 // Maximum percentage area of the base picture another picture in the picture |
19 // list can be. If higher, we destroy the list and recreate from scratch. | 21 // list can be. If higher, we destroy the list and recreate from scratch. |
20 const float kResetThreshold = 0.7f; | 22 const float kResetThreshold = 0.7f; |
21 // Layout pixel buffer around the visible layer rect to record. Any base | 23 // Layout pixel buffer around the visible layer rect to record. Any base |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 scoped_refptr<Picture> base_picture = Picture::Create(tile); | 109 scoped_refptr<Picture> base_picture = Picture::Create(tile); |
108 pic_list.push_back(base_picture); | 110 pic_list.push_back(base_picture); |
109 } | 111 } |
110 | 112 |
111 for (PictureList::iterator pic = pic_list.begin(); | 113 for (PictureList::iterator pic = pic_list.begin(); |
112 pic != pic_list.end(); ++pic) { | 114 pic != pic_list.end(); ++pic) { |
113 if (!(*pic)->HasRecording()) { | 115 if (!(*pic)->HasRecording()) { |
114 modified_pile = true; | 116 modified_pile = true; |
115 TRACE_EVENT0(benchmark_instrumentation::kCategory, | 117 TRACE_EVENT0(benchmark_instrumentation::kCategory, |
116 benchmark_instrumentation::kRecordLoop); | 118 benchmark_instrumentation::kRecordLoop); |
117 for (int i = 0; i < repeat_count; i++) | 119 base::TimeDelta total_duration = |
118 (*pic)->Record(painter, tile_grid_info_, stats_instrumentation); | 120 base::TimeDelta::FromInternalValue(0); |
| 121 base::TimeDelta best_duration = base::TimeDelta::FromInternalValue( |
| 122 std::numeric_limits<int64>::max()); |
| 123 for (int i = 0; i < repeat_count; i++) { |
| 124 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
| 125 (*pic)->Record(painter, tile_grid_info_); |
| 126 base::TimeDelta duration = |
| 127 stats_instrumentation->EndRecording(start_time); |
| 128 total_duration += duration; |
| 129 best_duration = std::min(duration, best_duration); |
| 130 } |
| 131 int painted_pixels = |
| 132 (*pic)->LayerRect().width() * (*pic)->LayerRect().height(); |
| 133 stats_instrumentation->AddRecord(total_duration, |
| 134 best_duration, |
| 135 painted_pixels); |
119 (*pic)->GatherPixelRefs(tile_grid_info_, stats_instrumentation); | 136 (*pic)->GatherPixelRefs(tile_grid_info_, stats_instrumentation); |
120 (*pic)->CloneForDrawing(num_raster_threads_); | 137 (*pic)->CloneForDrawing(num_raster_threads_); |
121 } | 138 } |
122 } | 139 } |
123 } | 140 } |
124 | 141 |
125 UpdateRecordedRegion(); | 142 UpdateRecordedRegion(); |
126 | 143 |
127 return modified_pile; | 144 return modified_pile; |
128 } | 145 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 185 |
169 FullyContainedPredicate pred(picture_rect); | 186 FullyContainedPredicate pred(picture_rect); |
170 picture_list.erase(std::remove_if(picture_list.begin(), | 187 picture_list.erase(std::remove_if(picture_list.begin(), |
171 picture_list.end(), | 188 picture_list.end(), |
172 pred), | 189 pred), |
173 picture_list.end()); | 190 picture_list.end()); |
174 picture_list.push_back(Picture::Create(picture_rect)); | 191 picture_list.push_back(Picture::Create(picture_rect)); |
175 } | 192 } |
176 | 193 |
177 } // namespace cc | 194 } // namespace cc |
OLD | NEW |