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..8f124c1677bd5f206d0d4a27696c629bcb276849 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), |
|
vmpstr
2014/08/19 23:55:37
I'd prefer default to be false, since.. paranoia.
hendrikw
2014/08/20 00:34:05
Not sure, my thinking was that an uninit'd picture
|
| + 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,31 @@ 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 |
| + PictureMap::const_iterator it = picture_map_.begin(); |
| + Picture* picture = it->second.GetPicture(); |
| + if (it == picture_map_.end() || NULL == picture) { |
|
vmpstr
2014/08/19 23:55:37
You can't get the picture from |it|, and then chec
hendrikw
2014/08/20 00:34:05
Woops, bad!~ I didn't use your code, I want to fi
|
| + is_solid_color_ = true; // no pictures, we're solid 100% transparent |
| + } else { |
| + const int kOpCountThatIsOkToAnalyze = 10; // TODO(hendrikw) good value? |
| + // don't bother doing more work if the first image is too complicated |
| + if (picture->approximateOpCount() <= kOpCountThatIsOkToAnalyze) { |
| + // make sure all of the mapped images point to the same picture |
| + while (++it != picture_map_.end()) { |
| + if (it->second.GetPicture() != picture) { |
|
vmpstr
2014/08/19 23:55:37
nit: braces optional
|
| + return; |
| + } |
| + } |
| + skia::AnalysisCanvas canvas(recorded_viewport_.width(), |
| + recorded_viewport_.height()); |
| + picture->AnalysisRaster(&canvas, NULL); |
| + is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| + } |
| + } |
| +} |
| + |
| } // namespace cc |