Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: cc/resources/picture_pile_unittest.cc

Issue 294163009: cc: Expand invalidation to full tile when recording is missing for the tile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pictureslow: doitinpicturepile Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/resources/picture_pile.cc ('K') | « cc/resources/picture_pile_base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_pile_unittest.cc
diff --git a/cc/resources/picture_pile_unittest.cc b/cc/resources/picture_pile_unittest.cc
index 03878630f6329831d46fa68ed629586c11f93697..e33a8f0676d5fa47986fc90c6ba04dc3dd8becab 100644
--- a/cc/resources/picture_pile_unittest.cc
+++ b/cc/resources/picture_pile_unittest.cc
@@ -51,20 +51,26 @@ class PicturePileTest : public testing::Test {
gfx::Rect tiling_rect() const { return pile_->tiling_rect(); }
- bool Update(const Region& invalidation, const gfx::Rect& visible_layer_rect) {
+ bool UpdateAndExpandInvalidation(Region* invalidation,
+ const gfx::Rect& visible_layer_rect) {
frame_number_++;
- return pile_->Update(&client_,
- background_color_,
- contents_opaque_,
- false,
- invalidation,
- visible_layer_rect,
- frame_number_,
- Picture::RECORD_NORMALLY,
- &stats_instrumentation_);
+ return pile_->UpdateAndExpandInvalidation(&client_,
+ invalidation,
+ background_color_,
+ contents_opaque_,
+ false,
+ visible_layer_rect,
+ frame_number_,
+ Picture::RECORD_NORMALLY,
+ &stats_instrumentation_);
}
- bool UpdateWholePile() { return Update(tiling_rect(), tiling_rect()); }
+ bool UpdateWholePile() {
+ Region invalidation = tiling_rect();
+ bool result = UpdateAndExpandInvalidation(&invalidation, tiling_rect());
+ EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString());
+ return result;
+ }
FakeContentLayerClient client_;
FakeRenderingStatsInstrumentation stats_instrumentation_;
@@ -79,8 +85,9 @@ TEST_F(PicturePileTest, SmallInvalidateInflated) {
UpdateWholePile();
// Invalidate something inside a tile.
- gfx::Rect invalidate_rect(50, 50, 1, 1);
- Update(invalidate_rect, tiling_rect());
+ Region invalidate_rect(gfx::Rect(50, 50, 1, 1));
+ UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect());
+ EXPECT_EQ(tiling_rect().ToString(), invalidate_rect.ToString());
EXPECT_EQ(1, pile_->tiling().num_tiles_x());
EXPECT_EQ(1, pile_->tiling().num_tiles_y());
@@ -102,8 +109,9 @@ TEST_F(PicturePileTest, LargeInvalidateInflated) {
UpdateWholePile();
// Invalidate something inside a tile.
- gfx::Rect invalidate_rect(50, 50, 100, 100);
- Update(invalidate_rect, tiling_rect());
+ Region invalidate_rect(gfx::Rect(50, 50, 100, 100));
+ UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect());
+ EXPECT_EQ(tiling_rect().ToString(), invalidate_rect.ToString());
EXPECT_EQ(1, pile_->tiling().num_tiles_x());
EXPECT_EQ(1, pile_->tiling().num_tiles_y());
@@ -143,12 +151,17 @@ TEST_F(PicturePileTest, InvalidateOnTileBoundaryInflated) {
// Invalidate something just over a tile boundary by a single pixel.
// This will invalidate the tile (1, 1), as well as 1 row of pixels in (1, 0).
- gfx::Rect invalidate_rect(
- pile_->tiling().TileBoundsWithBorder(0, 0).right(),
- pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1,
- 50,
- 50);
- Update(invalidate_rect, tiling_rect());
+ Region invalidate_rect(
+ gfx::Rect(pile_->tiling().TileBoundsWithBorder(0, 0).right(),
+ pile_->tiling().TileBoundsWithBorder(0, 0).bottom() - 1,
+ 50,
+ 50));
+ UpdateAndExpandInvalidation(&invalidate_rect, tiling_rect());
+
+ gfx::Rect expected_invalidation =
+ gfx::UnionRects(pile_->tiling().TileBoundsWithBorder(1, 1),
+ pile_->tiling().TileBoundsWithBorder(1, 0));
+ EXPECT_EQ(expected_invalidation.ToString(), invalidate_rect.ToString());
for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
@@ -197,9 +210,11 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) {
}
}
- // Update once more with a small viewport tiilng_rect.x(), tiilng_rect.y(),
- // tiling_rect.width() by 1
- Update(tiling_rect(), viewport);
+ // Update once more with a small viewport tiilng_rect.x(), tiling_rect.y(),
+ // tiling_rect.width() by 1.
+ Region invalidation = tiling_rect();
+ UpdateAndExpandInvalidation(&invalidation, viewport);
+ EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString());
for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
@@ -219,7 +234,9 @@ TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) {
}
// Now update with no invalidation and full viewport
- Update(gfx::Rect(), tiling_rect());
+ Region empty_invalidation;
+ UpdateAndExpandInvalidation(&empty_invalidation, tiling_rect());
+ EXPECT_EQ(Region().ToString(), empty_invalidation.ToString());
for (int i = 0; i < pile_->tiling().num_tiles_x(); ++i) {
for (int j = 0; j < pile_->tiling().num_tiles_y(); ++j) {
@@ -291,7 +308,9 @@ TEST_F(PicturePileTest, FrequentInvalidationCanRaster) {
// Update once more with a small viewport.
gfx::Rect viewport(0, 0, tiling_rect().width(), 1);
- Update(tiling_rect(), viewport);
+ Region invalidation(tiling_rect());
+ UpdateAndExpandInvalidation(&invalidation, viewport);
+ EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString());
// Sanity check some pictures exist and others don't.
EXPECT_TRUE(pile_->picture_map()
@@ -315,16 +334,62 @@ TEST_F(PicturePileTest, NoInvalidationValidViewport) {
EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
// No invalidation, same viewport.
- Update(gfx::Rect(), tiling_rect());
+ Region invalidation;
+ UpdateAndExpandInvalidation(&invalidation, tiling_rect());
EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
+ EXPECT_EQ(Region().ToString(), invalidation.ToString());
// Partial invalidation, same viewport.
- Update(gfx::Rect(gfx::Rect(0, 0, 1, 1)), tiling_rect());
+ invalidation = gfx::Rect(0, 0, 1, 1);
+ UpdateAndExpandInvalidation(&invalidation, tiling_rect());
EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
+ EXPECT_EQ(pile_->tiling().TileBounds(0, 0).ToString(),
+ invalidation.ToString());
// No invalidation, changing viewport.
- Update(gfx::Rect(), gfx::Rect(5, 5, 5, 5));
+ invalidation = Region();
+ UpdateAndExpandInvalidation(&invalidation, gfx::Rect(5, 5, 5, 5));
EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty());
+ EXPECT_EQ(Region().ToString(), invalidation.ToString());
+}
+
+TEST_F(PicturePileTest, InvalidateOutsideRecordingViewport) {
+ gfx::Rect huge_page(10000000, 20000000);
+ pile_->SetTilingRect(huge_page);
+
+ gfx::Rect viewport(8000, 9000, 2000, 2000);
+
+ // For no invalidation, only the recorded viewport should be
+ // considered as not-potentially-invalid.
+ Region invalidation;
+ UpdateAndExpandInvalidation(&invalidation, viewport);
+
+ gfx::Rect recording_viewport = pile_->recorded_viewport();
+ Region expected_invalidation = SubtractRegions(huge_page, recording_viewport);
+ EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString());
+
+ // With some invalidation, that should also be included and expanded to cover
+ // the entire recording tiles it overlaps.
+ gfx::Rect invalid_rect(7080, 10000, 200, 1000);
+ invalidation = invalid_rect;
+ UpdateAndExpandInvalidation(&invalidation, viewport);
+
+ int left_tile =
+ pile_->tiling().FirstBorderTileXIndexFromSrcCoord(invalid_rect.x());
+ int top_tile =
+ pile_->tiling().FirstBorderTileYIndexFromSrcCoord(invalid_rect.y());
+ int right_tile = pile_->tiling().LastBorderTileXIndexFromSrcCoord(
+ invalid_rect.right() - 1);
+ int bottom_tile = pile_->tiling().LastBorderTileYIndexFromSrcCoord(
+ invalid_rect.bottom() - 1);
+ int left = pile_->tiling().TileBoundsWithBorder(left_tile, top_tile).x();
+ int top = pile_->tiling().TileBoundsWithBorder(left_tile, top_tile).y();
+ int right =
+ pile_->tiling().TileBoundsWithBorder(right_tile, bottom_tile).right();
+ int bottom =
+ pile_->tiling().TileBoundsWithBorder(right_tile, bottom_tile).bottom();
+ expected_invalidation.Union(gfx::Rect(left, top, right - left, bottom - top));
+ EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString());
}
} // namespace
« cc/resources/picture_pile.cc ('K') | « cc/resources/picture_pile_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698