Chromium Code Reviews| Index: cc/resources/picture_pile.cc |
| diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc |
| index 27c58a1ff44dc109db0e233c259c2612a5e9458d..ca3916cf1898b77a1227e18a8c65214d0f5c290b 100644 |
| --- a/cc/resources/picture_pile.cc |
| +++ b/cc/resources/picture_pile.cc |
| @@ -146,15 +146,16 @@ PicturePile::PicturePile() : is_suitable_for_gpu_rasterization_(true) {} |
| PicturePile::~PicturePile() { |
| } |
| -bool PicturePile::Update(ContentLayerClient* painter, |
| - SkColor background_color, |
| - bool contents_opaque, |
| - bool contents_fill_bounds_completely, |
| - const Region& invalidation, |
| - const gfx::Rect& visible_layer_rect, |
| - int frame_number, |
| - Picture::RecordingMode recording_mode, |
| - RenderingStatsInstrumentation* stats_instrumentation) { |
| +bool PicturePile::UpdateAndExpandInvalidation( |
| + ContentLayerClient* painter, |
| + Region* invalidation, |
| + SkColor background_color, |
| + bool contents_opaque, |
| + bool contents_fill_bounds_completely, |
| + const gfx::Rect& visible_layer_rect, |
| + int frame_number, |
| + Picture::RecordingMode recording_mode, |
| + RenderingStatsInstrumentation* stats_instrumentation) { |
| background_color_ = background_color; |
| contents_opaque_ = contents_opaque; |
| contents_fill_bounds_completely_ = contents_fill_bounds_completely; |
| @@ -169,12 +170,12 @@ bool PicturePile::Update(ContentLayerClient* painter, |
| recorded_viewport_.Intersect(tiling_rect()); |
| bool invalidated = false; |
| - for (Region::Iterator i(invalidation); i.has_rect(); i.next()) { |
| - gfx::Rect invalidation = i.rect(); |
| + for (Region::Iterator i(*invalidation); i.has_rect(); i.next()) { |
| + gfx::Rect invalid_rect = i.rect(); |
| // Split this inflated invalidation across tile boundaries and apply it |
| // to all tiles that it touches. |
| bool include_borders = true; |
| - for (TilingData::Iterator iter(&tiling_, invalidation, include_borders); |
| + for (TilingData::Iterator iter(&tiling_, invalid_rect, include_borders); |
| iter; |
| ++iter) { |
| const PictureMapKey& key = iter.index(); |
| @@ -188,6 +189,21 @@ bool PicturePile::Update(ContentLayerClient* painter, |
| } |
| } |
| + // Expand invalidation that is outside tiles that intersect the interest rect. |
| + // These tiles are no longer valid so should be considerered fully invalid, so |
| + // we can know to not keep around raster tiles that intersect with these |
| + // recording tiles. |
| + gfx::Rect interest_rect_over_tiles = |
| + tiling_.ExpandRectToTileBounds(interest_rect); |
| + Region invalidation_outside_interest_rect_tiles = |
| + SubtractRegions(*invalidation, interest_rect_over_tiles); |
|
enne (OOO)
2014/06/17 00:02:54
Region ops like this make me sad, but this is prob
danakj
2014/06/17 18:51:34
For now I used Rect::Subtract instead, which may i
|
| + for (Region::Iterator i(invalidation_outside_interest_rect_tiles); |
| + i.has_rect(); |
| + i.next()) { |
| + gfx::Rect invalid_rect = i.rect(); |
| + invalidation->Union(tiling_.ExpandRectToTileBounds(invalid_rect)); |
| + } |
| + |
| // Make a list of all invalid tiles; we will attempt to |
| // cluster these into multiple invalidation regions. |
| std::vector<gfx::Rect> invalid_tiles; |
| @@ -204,12 +220,19 @@ bool PicturePile::Update(ContentLayerClient* painter, |
| if (info.NeedsRecording(frame_number, distance_to_visible)) { |
| gfx::Rect tile = tiling_.TileBounds(key.first, key.second); |
| invalid_tiles.push_back(tile); |
| - } else if (!info.GetPicture() && recorded_viewport_.Intersects(rect)) { |
| - // Recorded viewport is just an optimization for a fully recorded |
| - // interest rect. In this case, a tile in that rect has declined |
| - // to be recorded (probably due to frequent invalidations). |
| - // TODO(enne): Shrink the recorded_viewport_ rather than clearing. |
| - recorded_viewport_ = gfx::Rect(); |
| + } else if (!info.GetPicture()) { |
| + if (recorded_viewport_.Intersects(rect)) { |
| + // Recorded viewport is just an optimization for a fully recorded |
| + // interest rect. In this case, a tile in that rect has declined |
| + // to be recorded (probably due to frequent invalidations). |
| + // TODO(enne): Shrink the recorded_viewport_ rather than clearing. |
| + recorded_viewport_ = gfx::Rect(); |
| + } |
| + |
| + // If a tile in the interest rect is not recorded, the entire tile needs |
| + // to be considered invalid, so that we know not to keep around raster |
| + // tiles that intersect this recording tile. |
| + invalidation->Union(tiling_.TileBounds(it.index_x(), it.index_y())); |
| } |
| } |