| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 236 |
| 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); |
| 246 // Note the '&&' with previous is-suitable state. |
| 247 // This means that once a picture-pile becomes unsuitable for gpu |
| 248 // rasterization due to some content, it will continue to be unsuitable |
| 249 // even if that content is replaced by gpu-friendly content. |
| 250 // This is an optimization to avoid iterating though all pictures in |
| 251 // the pile after each invalidation. |
| 252 is_suitable_for_gpu_rasterization_ &= |
| 253 picture->IsSuitableForGpuRasterization(); |
| 247 base::TimeDelta duration = | 254 base::TimeDelta duration = |
| 248 stats_instrumentation->EndRecording(start_time); | 255 stats_instrumentation->EndRecording(start_time); |
| 249 best_duration = std::min(duration, best_duration); | 256 best_duration = std::min(duration, best_duration); |
| 250 } | 257 } |
| 251 int recorded_pixel_count = | 258 int recorded_pixel_count = |
| 252 picture->LayerRect().width() * picture->LayerRect().height(); | 259 picture->LayerRect().width() * picture->LayerRect().height(); |
| 253 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); | 260 stats_instrumentation->AddRecord(best_duration, recorded_pixel_count); |
| 254 } | 261 } |
| 255 | 262 |
| 256 bool found_tile_for_recorded_picture = false; | 263 bool found_tile_for_recorded_picture = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 268 } | 275 } |
| 269 DCHECK(found_tile_for_recorded_picture); | 276 DCHECK(found_tile_for_recorded_picture); |
| 270 } | 277 } |
| 271 | 278 |
| 272 has_any_recordings_ = true; | 279 has_any_recordings_ = true; |
| 273 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 280 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
| 274 return true; | 281 return true; |
| 275 } | 282 } |
| 276 | 283 |
| 277 } // namespace cc | 284 } // namespace cc |
| OLD | NEW |