Chromium Code Reviews| Index: cc/resources/picture_pile.cc |
| diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc |
| index 30375217b5825ab628c63861bb4ae1193294b87b..d4af28c73d3cc7e3762aaf9f592a3a0cbaf39740 100644 |
| --- a/cc/resources/picture_pile.cc |
| +++ b/cc/resources/picture_pile.cc |
| @@ -146,7 +146,11 @@ float ClusterTiles(const std::vector<gfx::Rect>& invalid_tiles, |
| namespace cc { |
| -PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} |
| +PicturePile::PicturePile() |
| + : is_suitable_for_gpu_rasterization_(true), |
| + is_solid_color_(true), |
| + solid_color_(SK_ColorTRANSPARENT) { |
| +} |
| PicturePile::~PicturePile() { |
| } |
| @@ -393,6 +397,7 @@ bool PicturePile::UpdateAndExpandInvalidation( |
| found_tile_for_recorded_picture = true; |
| } |
| } |
| + DetermineIfSolidColor(); |
| DCHECK(found_tile_for_recorded_picture); |
| } |
| @@ -408,4 +413,34 @@ void PicturePile::SetEmptyBounds() { |
| recorded_viewport_ = gfx::Rect(); |
| } |
| +void PicturePile::DetermineIfSolidColor() { |
| + is_solid_color_ = false; |
| + solid_color_ = SK_ColorTRANSPARENT; |
| + |
| + // 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.
|
| + 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
|
| + is_solid_color_ = true; // no pictures, we're solid 100% transparent |
| + return; |
| + } |
| + |
| + 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.
|
| + PictureMap::const_iterator it = picture_map_.begin(); |
| + Picture* picture = it->second.GetPicture(); |
| + DCHECK(picture); |
| + |
| + // don't bother doing more work if the first image is too complicated |
| + if (picture->GetApproximateOpCount() > kOpCountThatIsOkToAnalyze) |
| + return; |
| + |
| + // make sure all of the mapped images point to the same picture |
| + 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.
|
| + if (it->second.GetPicture() != picture) |
| + return; |
| + } |
| + skia::AnalysisCanvas canvas(recorded_viewport_.width(), |
| + recorded_viewport_.height()); |
| + picture->RasterForAnalysis(&canvas); |
| + is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| +} |
| + |
| } // namespace cc |