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

Unified Diff: cc/resources/picture_unittest.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress 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/picture_pile_impl.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_unittest.cc
diff --git a/cc/resources/picture_unittest.cc b/cc/resources/picture_unittest.cc
index 1e2ba44fe3bc0619f45d70f1ce9d2dfa53915792..b53765cfc7ce2ffe71e819bc4f1f3baa7a4fcd1a 100644
--- a/cc/resources/picture_unittest.cc
+++ b/cc/resources/picture_unittest.cc
@@ -85,269 +85,6 @@ TEST(PictureTest, AsBase64String) {
EXPECT_EQ(0, memcmp(two_rect_buffer, two_rect_buffer_check, 4 * 100 * 100));
}
-TEST(PictureTest, PixelRefIterator) {
- gfx::Rect layer_rect(2048, 2048);
-
- gfx::Size tile_grid_size(512, 512);
-
- FakeContentLayerClient content_layer_client;
-
- // Discardable pixel refs are found in the following grids:
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- SkBitmap discardable_bitmap[4][4];
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- if ((x + y) & 1) {
- CreateBitmap(
- gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]);
- SkPaint paint;
- content_layer_client.add_draw_bitmap(
- discardable_bitmap[y][x],
- gfx::Point(x * 512 + 6, y * 512 + 6), paint);
- }
- }
- }
-
- scoped_refptr<Picture> picture =
- Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true,
- RecordingSource::RECORD_NORMALLY);
-
- // Default iterator does not have any pixel refs
- {
- Picture::PixelRefIterator iterator;
- EXPECT_FALSE(iterator);
- }
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- Picture::PixelRefIterator iterator(gfx::Rect(x * 512, y * 512, 500, 500),
- picture.get());
- if ((x + y) & 1) {
- EXPECT_TRUE(iterator) << x << " " << y;
- EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef()) << x <<
- " " << y;
- EXPECT_FALSE(++iterator) << x << " " << y;
- } else {
- EXPECT_FALSE(iterator) << x << " " << y;
- }
- }
- }
- // Capture 4 pixel refs.
- {
- Picture::PixelRefIterator iterator(gfx::Rect(512, 512, 2048, 2048),
- picture.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++iterator);
- }
-
- // Copy test.
- Picture::PixelRefIterator iterator(gfx::Rect(512, 512, 2048, 2048),
- picture.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef());
-
- // copy now points to the same spot as iterator,
- // but both can be incremented independently.
- Picture::PixelRefIterator copy = iterator;
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++iterator);
-
- EXPECT_TRUE(copy);
- EXPECT_TRUE(*copy == discardable_bitmap[2][1].pixelRef());
- EXPECT_TRUE(++copy);
- EXPECT_TRUE(*copy == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++copy);
- EXPECT_TRUE(*copy == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++copy);
-}
-
-TEST(PictureTest, PixelRefIteratorNonZeroLayer) {
- gfx::Rect layer_rect(1024, 0, 2048, 2048);
-
- gfx::Size tile_grid_size(512, 512);
-
- FakeContentLayerClient content_layer_client;
-
- // Discardable pixel refs are found in the following grids:
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- SkBitmap discardable_bitmap[4][4];
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- if ((x + y) & 1) {
- CreateBitmap(
- gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]);
- SkPaint paint;
- content_layer_client.add_draw_bitmap(
- discardable_bitmap[y][x],
- gfx::Point(1024 + x * 512 + 6, y * 512 + 6), paint);
- }
- }
- }
-
- scoped_refptr<Picture> picture =
- Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true,
- RecordingSource::RECORD_NORMALLY);
-
- // Default iterator does not have any pixel refs
- {
- Picture::PixelRefIterator iterator;
- EXPECT_FALSE(iterator);
- }
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- Picture::PixelRefIterator iterator(
- gfx::Rect(1024 + x * 512, y * 512, 500, 500), picture.get());
- if ((x + y) & 1) {
- EXPECT_TRUE(iterator) << x << " " << y;
- EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef());
- EXPECT_FALSE(++iterator) << x << " " << y;
- } else {
- EXPECT_FALSE(iterator) << x << " " << y;
- }
- }
- }
- // Capture 4 pixel refs.
- {
- Picture::PixelRefIterator iterator(gfx::Rect(1024 + 512, 512, 2048, 2048),
- picture.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++iterator);
- }
-
- // Copy test.
- {
- Picture::PixelRefIterator iterator(gfx::Rect(1024 + 512, 512, 2048, 2048),
- picture.get());
- EXPECT_TRUE(iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef());
-
- // copy now points to the same spot as iterator,
- // but both can be incremented independently.
- Picture::PixelRefIterator copy = iterator;
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++iterator);
- EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++iterator);
-
- EXPECT_TRUE(copy);
- EXPECT_TRUE(*copy == discardable_bitmap[2][1].pixelRef());
- EXPECT_TRUE(++copy);
- EXPECT_TRUE(*copy == discardable_bitmap[2][3].pixelRef());
- EXPECT_TRUE(++copy);
- EXPECT_TRUE(*copy == discardable_bitmap[3][2].pixelRef());
- EXPECT_FALSE(++copy);
- }
-
- // Non intersecting rects
- {
- Picture::PixelRefIterator iterator(gfx::Rect(0, 0, 1000, 1000),
- picture.get());
- EXPECT_FALSE(iterator);
- }
- {
- Picture::PixelRefIterator iterator(gfx::Rect(3500, 0, 1000, 1000),
- picture.get());
- EXPECT_FALSE(iterator);
- }
- {
- Picture::PixelRefIterator iterator(gfx::Rect(0, 1100, 1000, 1000),
- picture.get());
- EXPECT_FALSE(iterator);
- }
- {
- Picture::PixelRefIterator iterator(gfx::Rect(3500, 1100, 1000, 1000),
- picture.get());
- EXPECT_FALSE(iterator);
- }
-}
-
-TEST(PictureTest, PixelRefIteratorOnePixelQuery) {
- gfx::Rect layer_rect(2048, 2048);
-
- gfx::Size tile_grid_size(512, 512);
-
- FakeContentLayerClient content_layer_client;
-
- // Discardable pixel refs are found in the following grids:
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- // | | x | | x |
- // |---|---|---|---|
- // | x | | x | |
- // |---|---|---|---|
- SkBitmap discardable_bitmap[4][4];
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- if ((x + y) & 1) {
- CreateBitmap(
- gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]);
- SkPaint paint;
- content_layer_client.add_draw_bitmap(
- discardable_bitmap[y][x],
- gfx::Point(x * 512 + 6, y * 512 + 6), paint);
- }
- }
- }
-
- scoped_refptr<Picture> picture =
- Picture::Create(layer_rect, &content_layer_client, tile_grid_size, true,
- RecordingSource::RECORD_NORMALLY);
-
- for (int y = 0; y < 4; ++y) {
- for (int x = 0; x < 4; ++x) {
- Picture::PixelRefIterator iterator(
- gfx::Rect(x * 512, y * 512 + 256, 1, 1), picture.get());
- if ((x + y) & 1) {
- EXPECT_TRUE(iterator) << x << " " << y;
- EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef());
- EXPECT_FALSE(++iterator) << x << " " << y;
- } else {
- EXPECT_FALSE(iterator) << x << " " << y;
- }
- }
- }
-}
-
TEST(PictureTest, CreateFromSkpValue) {
SkGraphics::Init();
« no previous file with comments | « cc/resources/picture_pile_impl.cc ('k') | cc/resources/pixel_ref_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698