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

Unified Diff: cc/resources/picture_pile_impl_unittest.cc

Issue 1050103003: Revert of Revert of Implement DisplayList GatherPixelRefs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « cc/resources/display_list_recording_source_unittest.cc ('k') | cc/resources/pixel_ref_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/picture_pile_impl_unittest.cc
diff --git a/cc/resources/picture_pile_impl_unittest.cc b/cc/resources/picture_pile_impl_unittest.cc
index 72a815868b561071efd798a32fa2ac4997280a2f..82f3608e5be99a28ddac2c7f083a3e327e048c49 100644
--- a/cc/resources/picture_pile_impl_unittest.cc
+++ b/cc/resources/picture_pile_impl_unittest.cc
@@ -32,7 +32,7 @@
recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
solid_paint);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -51,7 +51,7 @@
// Add one non-solid pixel and recreate the raster source.
recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
non_solid_paint);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
RasterSource::SolidColorAnalysis analysis;
@@ -97,7 +97,7 @@
recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
solid_paint);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -116,7 +116,7 @@
// Add one non-solid pixel and recreate the raster source.
recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
non_solid_paint);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
RasterSource::SolidColorAnalysis analysis;
@@ -157,257 +157,6 @@
EXPECT_TRUE(analysis.is_solid_color);
EXPECT_EQ(analysis.solid_color, SkColorSetARGB(0, 0, 0, 0));
-}
-
-TEST(PicturePileImplTest, PixelRefIteratorEmpty) {
- gfx::Size tile_size(128, 128);
- gfx::Size layer_bounds(256, 256);
-
- // Create a filled pile with no recording.
- scoped_refptr<FakePicturePileImpl> pile =
- FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
-
- // Tile sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 64, 64), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Shifted tile sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(140, 140, 128, 128), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(280, 280, 256, 256), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(70, 70, 64, 64), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Layer sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 512, 512), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
-}
-
-TEST(PicturePileImplTest, PixelRefIteratorNoDiscardableRefs) {
- gfx::Size tile_size(128, 128);
- gfx::Size layer_bounds(256, 256);
-
- scoped_ptr<FakePicturePile> recording_source =
- FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
- SkPaint simple_paint;
- simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34));
-
- SkBitmap non_discardable_bitmap;
- CreateBitmap(gfx::Size(128, 128), "notdiscardable", &non_discardable_bitmap);
-
- recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256),
- simple_paint);
- recording_source->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512),
- simple_paint);
- recording_source->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256),
- simple_paint);
- recording_source->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256),
- simple_paint);
- recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0));
- recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 128));
- recording_source->add_draw_bitmap(non_discardable_bitmap,
- gfx::Point(150, 150));
- recording_source->RerecordPile();
-
- scoped_refptr<FakePicturePileImpl> pile =
- FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
-
- // Tile sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 64, 64), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Shifted tile sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(140, 140, 128, 128), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(280, 280, 256, 256), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(70, 70, 64, 64), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Layer sized iterators.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 512, 512), 2.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 0.5, pile.get());
- EXPECT_FALSE(iterator);
- }
-}
-
-TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefs) {
- gfx::Size tile_size(128, 128);
- gfx::Size layer_bounds(256, 256);
-
- scoped_ptr<FakePicturePile> recording_source =
- FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
-
- SkBitmap discardable_bitmap[2][2];
- CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]);
- CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][0]);
- CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]);
-
- // Discardable pixel refs are found in the following cells:
- // |---|---|
- // | x | |
- // |---|---|
- // | x | x |
- // |---|---|
- recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
- recording_source->add_draw_bitmap(discardable_bitmap[1][0],
- gfx::Point(0, 130));
- recording_source->add_draw_bitmap(discardable_bitmap[1][1],
- gfx::Point(140, 140));
- recording_source->RerecordPile();
-
- scoped_refptr<FakePicturePileImpl> pile =
- FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
-
- // Tile sized iterators. These should find only one pixel ref.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 64, 64), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- // Shifted tile sized iterators. These should find only one pixel ref.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(140, 140, 128, 128), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(280, 280, 256, 256), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(70, 70, 64, 64), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- // Ensure there's no discardable pixel refs in the empty cell
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(140, 0, 128, 128), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Layer sized iterators. These should find all 3 pixel refs.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 512, 512), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
}
TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) {
@@ -433,7 +182,7 @@
gfx::Point(260, 0));
recording_source->add_draw_bitmap(discardable_bitmap[1][1],
gfx::Point(260, 260));
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -545,125 +294,6 @@
EXPECT_FALSE(++copy);
}
-TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) {
- gfx::Size tile_size(256, 256);
- gfx::Size layer_bounds(512, 512);
-
- scoped_ptr<FakePicturePile> recording_source =
- FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
-
- SkBitmap non_discardable_bitmap;
- CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_bitmap);
-
- SkBitmap discardable_bitmap[2][2];
- CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][0]);
- CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[0][1]);
- CreateBitmap(gfx::Size(128, 128), "discardable", &discardable_bitmap[1][1]);
-
- // One large non-discardable bitmap covers the whole grid.
- // Discardable pixel refs are found in the following cells:
- // |---|---|
- // | x | x |
- // |---|---|
- // | | x |
- // |---|---|
- recording_source->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0));
- recording_source->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
- recording_source->add_draw_bitmap(discardable_bitmap[0][1],
- gfx::Point(260, 0));
- recording_source->add_draw_bitmap(discardable_bitmap[1][1],
- gfx::Point(260, 260));
- recording_source->RerecordPile();
-
- scoped_refptr<FakePicturePileImpl> pile =
- FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
-
- // Tile sized iterators. These should find only one pixel ref.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 512, 512), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 128, 128), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- // Shifted tile sized iterators. These should find only one pixel ref.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(260, 260, 256, 256), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(520, 520, 512, 512), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(130, 130, 128, 128), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- // Ensure there's no discardable pixel refs in the empty cell
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 256, 256, 256), 1.0, pile.get());
- EXPECT_FALSE(iterator);
- }
- // Layer sized iterators. These should find three pixel ref.
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 512, 512), 1.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 1024, 1024), 2.0, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
- {
- PicturePileImpl::PixelRefIterator iterator(
- gfx::Rect(0, 0, 256, 256), 0.5, pile.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef());
- EXPECT_FALSE(++iterator);
- }
-}
-
TEST(PicturePileImplTest, RasterFullContents) {
gfx::Size tile_size(1000, 1000);
gfx::Size layer_bounds(3, 5);
@@ -685,7 +315,7 @@
white_paint);
recording_source->SetMinContentsScale(contents_scale);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -745,7 +375,7 @@
recording_source->SetRequiresClear(true);
recording_source->SetMinContentsScale(contents_scale);
recording_source->SetClearCanvasWithDebugColor(false);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -795,7 +425,7 @@
// Paint outside the layer to make sure that blending works.
recording_source->add_draw_rect_with_paint(
gfx::RectF(bigger_than_layer_bounds), color_paint);
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
@@ -856,7 +486,7 @@
bitmap_rects[i].origin());
}
- recording_source->RerecordPile();
+ recording_source->Rerecord();
scoped_refptr<FakePicturePileImpl> pile =
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
« no previous file with comments | « cc/resources/display_list_recording_source_unittest.cc ('k') | cc/resources/pixel_ref_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698