Chromium Code Reviews| Index: cc/resources/picture_pile.cc |
| diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc |
| index 128b1491714dcd1d33c2585bd0d4d726389a6195..254d2b7ee6301bec20957487a87c9bd16117634c 100644 |
| --- a/cc/resources/picture_pile.cc |
| +++ b/cc/resources/picture_pile.cc |
| @@ -19,6 +19,9 @@ namespace { |
| // picture that intersects the visible layer rect expanded by this distance |
| // will be recorded. |
| const int kPixelDistanceToRecord = 8000; |
| +// We don't perform solid color analysis on images that have more than 10 skia |
| +// operations. |
| +const int kOpCountThatIsOkToAnalyze = 10; |
| // TODO(humper): The density threshold here is somewhat arbitrary; need a |
| // way to set // this from the command line so we can write a benchmark |
| @@ -146,7 +149,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() { |
| } |
| @@ -501,6 +508,7 @@ bool PicturePile::UpdateAndExpandInvalidation( |
| found_tile_for_recorded_picture = true; |
| } |
| } |
| + DetermineIfSolidColor(); |
| DCHECK(found_tile_for_recorded_picture); |
| } |
| @@ -516,4 +524,37 @@ 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. |
| + if (picture_map_.empty()) { |
| + is_solid_color_ = true; // No pictures? Then we're solid 100% transparent. |
|
enne (OOO)
2014/08/25 23:21:07
Is this true? I think the map being empty is maybe
hendrikw
2014/08/26 00:12:38
I don't think we should ever rasterize a picture_p
|
| + return; |
| + } |
| + |
| + PictureMap::const_iterator it = picture_map_.begin(); |
| + const Picture* picture = it->second.GetPicture(); |
| + |
| + // There are situations where the first picture is NULL, we'll assume not |
|
enne (OOO)
2014/08/25 23:21:07
"There are situations where the first picture is N
hendrikw
2014/08/26 00:12:37
Done.
|
| + // solid in this case. |
| + if (!picture) |
| + return; |
| + |
| + // Don't bother doing more work if the first image is too complicated. |
| + if (picture->ApproximateOpCount() > kOpCountThatIsOkToAnalyze) |
| + return; |
| + |
| + // Make sure all of the mapped images point to the same picture. |
| + for (++it; it != picture_map_.end(); ++it) { |
| + if (it->second.GetPicture() != picture) |
| + return; |
| + } |
| + skia::AnalysisCanvas canvas(recorded_viewport_.width(), |
| + recorded_viewport_.height()); |
| + picture->Raster(&canvas, NULL, Region(), 1.0f); |
| + is_solid_color_ = canvas.GetColorIfSolid(&solid_color_); |
| +} |
| + |
| } // namespace cc |