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 2d33b76b53631611afcdca87de43383caf4ae1dd..14b06eecd5d3c49f3499a94b599b92d190ef7dae 100644 |
--- a/cc/resources/picture_pile_impl_unittest.cc |
+++ b/cc/resources/picture_pile_impl_unittest.cc |
@@ -32,7 +32,7 @@ TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) { |
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 @@ TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) { |
// 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 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) { |
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 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) { |
// 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; |
@@ -159,257 +159,6 @@ TEST(PicturePileImplTest, AnalyzeIsSolidEmpty) { |
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) { |
gfx::Size tile_size(256, 256); |
gfx::Size layer_bounds(512, 512); |
@@ -433,7 +182,8 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) { |
gfx::Point(260, 0)); |
recording_source->add_draw_bitmap(discardable_bitmap[1][1], |
gfx::Point(260, 260)); |
- recording_source->RerecordPile(); |
+ recording_source->SetGatherPixelRefs(true); |
+ recording_source->Rerecord(); |
scoped_refptr<FakePicturePileImpl> pile = |
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |
@@ -545,125 +295,6 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) { |
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 +316,7 @@ TEST(PicturePileImplTest, RasterFullContents) { |
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 +376,7 @@ TEST(PicturePileImpl, RasterContentsTransparent) { |
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 +426,7 @@ TEST_P(OverlapTest, NoOverlap) { |
// 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 +487,8 @@ TEST(PicturePileImplTest, PixelRefIteratorBorders) { |
bitmap_rects[i].origin()); |
} |
- recording_source->RerecordPile(); |
+ recording_source->SetGatherPixelRefs(true); |
+ recording_source->Rerecord(); |
scoped_refptr<FakePicturePileImpl> pile = |
FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr); |