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..966e337a6e1389b97878073fa030f5675950d38b 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,39 @@ 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()) { |
| + // if we have an empty map, the picture pile will never be rasterized and |
|
enne (OOO)
2014/08/26 17:03:40
I'd just early out without a comment here. I thin
|
| + // it doesn't matter if we treat this as solid or not. Choosing solid. |
| + is_solid_color_ = true; |
| + return; |
| + } |
| + |
| + PictureMap::const_iterator it = picture_map_.begin(); |
| + const Picture* picture = it->second.GetPicture(); |
| + |
| + // Missing recordings due to frequent invalidations or being too far away |
| + // from the interest rect will cause the a null picture to exist. |
| + 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 |