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 <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 *record_rects = vertical_clustering; | 136 *record_rects = vertical_clustering; |
137 return vertical_density; | 137 return vertical_density; |
138 } | 138 } |
139 | 139 |
140 } // namespace | 140 } // namespace |
141 | 141 |
142 namespace cc { | 142 namespace cc { |
143 | 143 |
144 PicturePile::PicturePile() { | 144 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} |
145 } | |
146 | 145 |
147 PicturePile::~PicturePile() { | 146 PicturePile::~PicturePile() { |
148 } | 147 } |
149 | 148 |
150 bool PicturePile::Update(ContentLayerClient* painter, | 149 bool PicturePile::Update(ContentLayerClient* painter, |
151 SkColor background_color, | 150 SkColor background_color, |
152 bool contents_opaque, | 151 bool contents_opaque, |
153 bool contents_fill_bounds_completely, | 152 bool contents_fill_bounds_completely, |
154 const Region& invalidation, | 153 const Region& invalidation, |
155 const gfx::Rect& visible_layer_rect, | 154 const gfx::Rect& visible_layer_rect, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 { | 237 { |
239 base::TimeDelta best_duration = base::TimeDelta::Max(); | 238 base::TimeDelta best_duration = base::TimeDelta::Max(); |
240 for (int i = 0; i < repeat_count; i++) { | 239 for (int i = 0; i < repeat_count; i++) { |
241 base::TimeTicks start_time = stats_instrumentation->StartRecording(); | 240 base::TimeTicks start_time = stats_instrumentation->StartRecording(); |
242 picture = Picture::Create(record_rect, | 241 picture = Picture::Create(record_rect, |
243 painter, | 242 painter, |
244 tile_grid_info_, | 243 tile_grid_info_, |
245 gather_pixel_refs, | 244 gather_pixel_refs, |
246 num_raster_threads, | 245 num_raster_threads, |
247 Picture::RECORD_NORMALLY); | 246 Picture::RECORD_NORMALLY); |
| 247 // Note the '&&' with previous is-suitable state. |
| 248 // This means that once a picture-pile becomes unsuitable for gpu |
| 249 // rasterization due to some content, it will continue to be unsuitable |
| 250 // even if that content is replaced by gpu-friendly content. |
| 251 // This is an optimization to avoid iterating though all pictures in |
| 252 // the pile after each invalidation. |
| 253 is_suitable_for_gpu_rasterization_ &= |
| 254 picture->IsSuitableForGpuRasterization(); |
248 base::TimeDelta duration = | 255 base::TimeDelta duration = |
249 stats_instrumentation->EndRecording(start_time); | 256 stats_instrumentation->EndRecording(start_time); |
250 best_duration = std::min(duration, best_duration); | 257 best_duration = std::min(duration, best_duration); |
251 } | 258 } |
252 int recorded_pixel_count = | 259 int recorded_pixel_count = |
253 picture->LayerRect().width() * picture->LayerRect().height(); | 260 picture->LayerRect().width() * picture->LayerRect().height(); |
254 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 261 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
255 } | 262 } |
256 | 263 |
257 bool found_tile_for_recorded_picture = false; | 264 bool found_tile_for_recorded_picture = false; |
(...skipping 11 matching lines...) Expand all Loading... |
269 } | 276 } |
270 DCHECK(found_tile_for_recorded_picture); | 277 DCHECK(found_tile_for_recorded_picture); |
271 } | 278 } |
272 | 279 |
273 has_any_recordings_ = true; | 280 has_any_recordings_ = true; |
274 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 281 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
275 return true; | 282 return true; |
276 } | 283 } |
277 | 284 |
278 } // namespace cc | 285 } // namespace cc |
OLD | NEW |