| 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 6e9afc7fda851cb6d642008763146066bc0e0422..72a815868b561071efd798a32fa2ac4997280a2f 100644
|
| --- a/cc/resources/picture_pile_impl_unittest.cc
|
| +++ b/cc/resources/picture_pile_impl_unittest.cc
|
| @@ -19,21 +19,25 @@ TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) {
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(400, 400);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
|
|
| - SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
|
| SkPaint solid_paint;
|
| + SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
|
| solid_paint.setColor(solid_color);
|
|
|
| SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
|
| SkPaint non_solid_paint;
|
| non_solid_paint.setColor(non_solid_color);
|
|
|
| - pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), solid_paint);
|
| - pile->RerecordPile();
|
| + recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
|
| + solid_paint);
|
| + recording_source->RerecordPile();
|
| +
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| - // Ensure everything is solid
|
| + // Ensure everything is solid.
|
| for (int y = 0; y <= 300; y += 100) {
|
| for (int x = 0; x <= 300; x += 100) {
|
| RasterSource::SolidColorAnalysis analysis;
|
| @@ -44,9 +48,11 @@ TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) {
|
| }
|
| }
|
|
|
| - // One pixel non solid
|
| - pile->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), non_solid_paint);
|
| - pile->RerecordPile();
|
| + // 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();
|
| + pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| RasterSource::SolidColorAnalysis analysis;
|
| pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis);
|
| @@ -56,7 +62,7 @@ TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) {
|
| EXPECT_TRUE(analysis.is_solid_color);
|
| EXPECT_EQ(analysis.solid_color, solid_color);
|
|
|
| - // Boundaries should be clipped
|
| + // Boundaries should be clipped.
|
| analysis.is_solid_color = false;
|
| pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis);
|
| EXPECT_TRUE(analysis.is_solid_color);
|
| @@ -78,8 +84,8 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
|
| gfx::Size tile_size(100, 100);
|
| gfx::Size layer_bounds(400, 400);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
|
|
| SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
|
| SkPaint solid_paint;
|
| @@ -89,10 +95,14 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
|
| SkPaint non_solid_paint;
|
| non_solid_paint.setColor(non_solid_color);
|
|
|
| - pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400), solid_paint);
|
| - pile->RerecordPile();
|
| + recording_source->add_draw_rect_with_paint(gfx::Rect(0, 0, 400, 400),
|
| + solid_paint);
|
| + recording_source->RerecordPile();
|
|
|
| - // Ensure everything is solid
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
| +
|
| + // Ensure everything is solid.
|
| for (int y = 0; y <= 30; y += 10) {
|
| for (int x = 0; x <= 30; x += 10) {
|
| RasterSource::SolidColorAnalysis analysis;
|
| @@ -103,9 +113,11 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
|
| }
|
| }
|
|
|
| - // One pixel non solid
|
| - pile->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1), non_solid_paint);
|
| - pile->RerecordPile();
|
| + // 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();
|
| + pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| RasterSource::SolidColorAnalysis analysis;
|
| pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis);
|
| @@ -115,7 +127,7 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
|
| EXPECT_TRUE(analysis.is_solid_color);
|
| EXPECT_EQ(analysis.solid_color, solid_color);
|
|
|
| - // Boundaries should be clipped
|
| + // Boundaries should be clipped.
|
| analysis.is_solid_color = false;
|
| pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis);
|
| EXPECT_TRUE(analysis.is_solid_color);
|
| @@ -209,24 +221,30 @@ TEST(PicturePileImplTest, PixelRefIteratorNoDiscardableRefs) {
|
| gfx::Size tile_size(128, 128);
|
| gfx::Size layer_bounds(256, 256);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| -
|
| + 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);
|
|
|
| - pile->add_draw_rect_with_paint(gfx::Rect(0, 0, 256, 256), simple_paint);
|
| - pile->add_draw_rect_with_paint(gfx::Rect(128, 128, 512, 512), simple_paint);
|
| - pile->add_draw_rect_with_paint(gfx::Rect(512, 0, 256, 256), simple_paint);
|
| - pile->add_draw_rect_with_paint(gfx::Rect(0, 512, 256, 256), simple_paint);
|
| - pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(128, 0));
|
| - pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 128));
|
| - pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(150, 150));
|
| + 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();
|
|
|
| - pile->RerecordPile();
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| // Tile sized iterators.
|
| {
|
| @@ -282,8 +300,8 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefs) {
|
| gfx::Size tile_size(128, 128);
|
| gfx::Size layer_bounds(256, 256);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + 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]);
|
| @@ -296,11 +314,15 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefs) {
|
| // |---|---|
|
| // | x | x |
|
| // |---|---|
|
| - pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[1][0], gfx::Point(0, 130));
|
| - pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(140, 140));
|
| + 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();
|
|
|
| - pile->RerecordPile();
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| // Tile sized iterators. These should find only one pixel ref.
|
| {
|
| @@ -392,8 +414,8 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) {
|
| gfx::Size tile_size(256, 256);
|
| gfx::Size layer_bounds(512, 512);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + 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]);
|
| @@ -406,11 +428,15 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsOneTile) {
|
| // |---|---|
|
| // | | x |
|
| // |---|---|
|
| - pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[0][1], gfx::Point(260, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(260, 260));
|
| + 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();
|
|
|
| - pile->RerecordPile();
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| // Tile sized iterators. These should find only one pixel ref.
|
| {
|
| @@ -523,8 +549,8 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) {
|
| gfx::Size tile_size(256, 256);
|
| gfx::Size layer_bounds(512, 512);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
|
|
| SkBitmap non_discardable_bitmap;
|
| CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_bitmap);
|
| @@ -541,12 +567,16 @@ TEST(PicturePileImplTest, PixelRefIteratorDiscardableRefsBaseNonDiscardable) {
|
| // |---|---|
|
| // | | x |
|
| // |---|---|
|
| - pile->add_draw_bitmap(non_discardable_bitmap, gfx::Point(0, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[0][0], gfx::Point(0, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[0][1], gfx::Point(260, 0));
|
| - pile->add_draw_bitmap(discardable_bitmap[1][1], gfx::Point(260, 260));
|
| + 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();
|
|
|
| - pile->RerecordPile();
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| // Tile sized iterators. These should find only one pixel ref.
|
| {
|
| @@ -640,19 +670,25 @@ TEST(PicturePileImplTest, RasterFullContents) {
|
| float contents_scale = 1.5f;
|
| float raster_divisions = 2.f;
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
| + recording_source->SetBackgroundColor(SK_ColorBLACK);
|
| + recording_source->SetIsSolidColor(false);
|
| + recording_source->SetRequiresClear(false);
|
| + recording_source->SetClearCanvasWithDebugColor(false);
|
| +
|
| // Because the caller sets content opaque, it also promises that it
|
| // has at least filled in layer_bounds opaquely.
|
| SkPaint white_paint;
|
| white_paint.setColor(SK_ColorWHITE);
|
| - pile->add_draw_rect_with_paint(gfx::Rect(layer_bounds), white_paint);
|
| + recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds),
|
| + white_paint);
|
|
|
| - pile->SetMinContentsScale(contents_scale);
|
| - pile->set_background_color(SK_ColorBLACK);
|
| - pile->SetRequiresClear(false);
|
| - pile->set_clear_canvas_with_debug_color(false);
|
| - pile->RerecordPile();
|
| + recording_source->SetMinContentsScale(contents_scale);
|
| + recording_source->RerecordPile();
|
| +
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
|
|
| gfx::Size content_bounds(
|
| gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
|
| @@ -703,14 +739,16 @@ TEST(PicturePileImpl, RasterContentsTransparent) {
|
| gfx::Size layer_bounds(5, 3);
|
| float contents_scale = 0.5f;
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| - pile->set_background_color(SK_ColorTRANSPARENT);
|
| - pile->SetRequiresClear(true);
|
| - pile->SetMinContentsScale(contents_scale);
|
| - pile->set_clear_canvas_with_debug_color(false);
|
| - pile->RerecordPile();
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
| + recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
|
| + recording_source->SetRequiresClear(true);
|
| + recording_source->SetMinContentsScale(contents_scale);
|
| + recording_source->SetClearCanvasWithDebugColor(false);
|
| + recording_source->RerecordPile();
|
|
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
| gfx::Size content_bounds(
|
| gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
|
|
|
| @@ -743,21 +781,24 @@ TEST_P(OverlapTest, NoOverlap) {
|
| // Pick an opaque color to not have to deal with premultiplication off-by-one.
|
| SkColor test_color = SkColorSetARGB(255, 45, 56, 67);
|
|
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| - pile->set_background_color(SK_ColorTRANSPARENT);
|
| - pile->SetRequiresClear(true);
|
| - pile->SetMinContentsScale(MinContentsScale());
|
| - pile->set_clear_canvas_with_debug_color(true);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
| + recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
|
| + recording_source->SetRequiresClear(true);
|
| + recording_source->SetMinContentsScale(MinContentsScale());
|
| + recording_source->SetClearCanvasWithDebugColor(true);
|
| +
|
| SkPaint color_paint;
|
| color_paint.setColor(test_color);
|
| // Additive paint, so that if two paints overlap, the color will change.
|
| color_paint.setXfermodeMode(SkXfermode::kPlus_Mode);
|
| // Paint outside the layer to make sure that blending works.
|
| - pile->add_draw_rect_with_paint(gfx::RectF(bigger_than_layer_bounds),
|
| - color_paint);
|
| - pile->RerecordPile();
|
| + recording_source->add_draw_rect_with_paint(
|
| + gfx::RectF(bigger_than_layer_bounds), color_paint);
|
| + recording_source->RerecordPile();
|
|
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
| gfx::Size content_bounds(
|
| gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
|
|
|
| @@ -793,25 +834,33 @@ TEST(PicturePileImplTest, PixelRefIteratorBorders) {
|
| gfx::Size tile_size(128, 128);
|
| gfx::Size layer_bounds(320, 128);
|
|
|
| - // Fake picture pile impl uses a tile grid the size of the tile. So,
|
| + // Fake picture pile uses a tile grid the size of the tile. So,
|
| // any iteration that intersects with a tile will return all pixel refs
|
| // inside of it.
|
| - scoped_refptr<FakePicturePileImpl> pile =
|
| - FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
|
| - pile->SetMinContentsScale(0.5f);
|
| + scoped_ptr<FakePicturePile> recording_source =
|
| + FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
|
| + recording_source->SetMinContentsScale(0.5f);
|
|
|
| // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders
|
| // of adjacent tiles.
|
| - gfx::Rect bitmap_rects[] = {pile->tiling().TileBounds(0, 0),
|
| - pile->tiling().TileBounds(1, 0),
|
| - pile->tiling().TileBounds(2, 0), };
|
| + gfx::Rect bitmap_rects[] = {
|
| + recording_source->tiling().TileBounds(0, 0),
|
| + recording_source->tiling().TileBounds(1, 0),
|
| + recording_source->tiling().TileBounds(2, 0),
|
| + };
|
| SkBitmap discardable_bitmap[arraysize(bitmap_rects)];
|
|
|
| for (size_t i = 0; i < arraysize(bitmap_rects); ++i) {
|
| CreateBitmap(bitmap_rects[i].size(), "discardable", &discardable_bitmap[i]);
|
| - pile->add_draw_bitmap(discardable_bitmap[i], bitmap_rects[i].origin());
|
| + recording_source->add_draw_bitmap(discardable_bitmap[i],
|
| + bitmap_rects[i].origin());
|
| }
|
|
|
| + recording_source->RerecordPile();
|
| +
|
| + scoped_refptr<FakePicturePileImpl> pile =
|
| + FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
|
| +
|
| // Sanity check that bitmaps 0-2 intersect the borders of their adjacent
|
| // tiles, but not the actual tiles.
|
| EXPECT_TRUE(
|
| @@ -827,8 +876,6 @@ TEST(PicturePileImplTest, PixelRefIteratorBorders) {
|
| bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
|
| EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0)));
|
|
|
| - pile->RerecordPile();
|
| -
|
| // Tile-sized iterators.
|
| {
|
| // Because tile 0's borders extend onto tile 1, it will include both
|
|
|