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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 } | 139 } |
140 | 140 |
141 *record_rects = vertical_clustering; | 141 *record_rects = vertical_clustering; |
142 return vertical_density; | 142 return vertical_density; |
143 } | 143 } |
144 | 144 |
145 } // namespace | 145 } // namespace |
146 | 146 |
147 namespace cc { | 147 namespace cc { |
148 | 148 |
149 PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} | 149 PicturePile::PicturePile() |
150 : is_suitable_for_gpu_rasterization_(true), | |
151 is_solid_color_(true), | |
152 solid_color_(SK_ColorTRANSPARENT) { | |
153 } | |
150 | 154 |
151 PicturePile::~PicturePile() { | 155 PicturePile::~PicturePile() { |
152 } | 156 } |
153 | 157 |
154 bool PicturePile::UpdateAndExpandInvalidation( | 158 bool PicturePile::UpdateAndExpandInvalidation( |
155 ContentLayerClient* painter, | 159 ContentLayerClient* painter, |
156 Region* invalidation, | 160 Region* invalidation, |
157 SkColor background_color, | 161 SkColor background_color, |
158 bool contents_opaque, | 162 bool contents_opaque, |
159 bool contents_fill_bounds_completely, | 163 bool contents_fill_bounds_completely, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; | 390 for (TilingData::Iterator it(&tiling_, record_rect, include_borders); it; |
387 ++it) { | 391 ++it) { |
388 const PictureMapKey& key = it.index(); | 392 const PictureMapKey& key = it.index(); |
389 gfx::Rect tile = PaddedRect(key); | 393 gfx::Rect tile = PaddedRect(key); |
390 if (record_rect.Contains(tile)) { | 394 if (record_rect.Contains(tile)) { |
391 PictureInfo& info = picture_map_[key]; | 395 PictureInfo& info = picture_map_[key]; |
392 info.SetPicture(picture); | 396 info.SetPicture(picture); |
393 found_tile_for_recorded_picture = true; | 397 found_tile_for_recorded_picture = true; |
394 } | 398 } |
395 } | 399 } |
400 DetermineIfSolidColor(); | |
396 DCHECK(found_tile_for_recorded_picture); | 401 DCHECK(found_tile_for_recorded_picture); |
397 } | 402 } |
398 | 403 |
399 has_any_recordings_ = true; | 404 has_any_recordings_ = true; |
400 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); | 405 DCHECK(CanRasterSlowTileCheck(recorded_viewport_)); |
401 return true; | 406 return true; |
402 } | 407 } |
403 | 408 |
404 void PicturePile::SetEmptyBounds() { | 409 void PicturePile::SetEmptyBounds() { |
405 tiling_.SetTilingSize(gfx::Size()); | 410 tiling_.SetTilingSize(gfx::Size()); |
406 picture_map_.clear(); | 411 picture_map_.clear(); |
407 has_any_recordings_ = false; | 412 has_any_recordings_ = false; |
408 recorded_viewport_ = gfx::Rect(); | 413 recorded_viewport_ = gfx::Rect(); |
409 } | 414 } |
410 | 415 |
416 void PicturePile::DetermineIfSolidColor() { | |
417 is_solid_color_ = false; | |
418 solid_color_ = SK_ColorTRANSPARENT; | |
419 | |
420 // determine if the entire picture map is pointing to the same image | |
vmpstr
2014/08/20 16:12:00
style nit: Comments should be proper sentences (ca
hendrikw
2014/08/20 20:46:55
Done.
| |
421 if (picture_map_.empty()) { | |
vmpstr
2014/08/20 16:12:00
We talked briefly about this yesterday: Is it poss
hendrikw
2014/08/20 20:46:55
I think there are situations where the map could b
| |
422 is_solid_color_ = true; // no pictures, we're solid 100% transparent | |
423 return; | |
424 } | |
425 | |
426 const int kOpCountThatIsOkToAnalyze = 10; // TODO(hendrikw) good value? | |
vmpstr
2014/08/20 16:12:00
Looks like a good enough value. Can you put this i
hendrikw
2014/08/20 20:46:55
Done.
| |
427 PictureMap::const_iterator it = picture_map_.begin(); | |
428 Picture* picture = it->second.GetPicture(); | |
429 DCHECK(picture); | |
430 | |
431 // don't bother doing more work if the first image is too complicated | |
432 if (picture->GetApproximateOpCount() > kOpCountThatIsOkToAnalyze) | |
433 return; | |
434 | |
435 // make sure all of the mapped images point to the same picture | |
436 while (++it != picture_map_.end()) { | |
vmpstr
2014/08/20 16:12:00
I'd still prefer a for loop here:
for (++it; it !
hendrikw
2014/08/20 20:46:55
Done.
| |
437 if (it->second.GetPicture() != picture) | |
438 return; | |
439 } | |
440 skia::AnalysisCanvas canvas(recorded_viewport_.width(), | |
441 recorded_viewport_.height()); | |
442 picture->RasterForAnalysis(&canvas); | |
443 is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); | |
444 } | |
445 | |
411 } // namespace cc | 446 } // namespace cc |
OLD | NEW |