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

Unified Diff: cc/resources/picture_pile_impl_unittest.cc

Issue 14230007: cc: Do GatherPixelRefs from skia at record time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated unittests Created 7 years, 8 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
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 13a24fd9b0fe4c3de80215bca1ccd835e6e659fd..fdbf259e974d76e7dc4125475599554bf8cdfdaf 100644
--- a/cc/resources/picture_pile_impl_unittest.cc
+++ b/cc/resources/picture_pile_impl_unittest.cc
@@ -2,13 +2,72 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/memory/scoped_ptr.h"
#include "cc/test/fake_picture_pile_impl.h"
+#include "skia/ext/lazy_pixel_ref.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/skia/include/core/SkPixelRef.h"
+#include "third_party/skia/include/core/SkShader.h"
#include "ui/gfx/rect.h"
namespace cc {
namespace {
+class TestPixelRef : public SkPixelRef {
+ public:
+ // Pure virtual implementation.
+ TestPixelRef(int width, int height)
+ : pixels_(new char[4 * width * height]) {}
+ virtual SkFlattenable::Factory getFactory() OVERRIDE { return NULL; }
+ virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE {
+ return pixels_.get();
+ }
+ virtual void onUnlockPixels() OVERRIDE {}
+ virtual SkPixelRef* deepCopy(
+ SkBitmap::Config config,
+ const SkIRect* subset) OVERRIDE {
+ this->ref();
+ return this;
+ }
+ private:
+ scoped_ptr<char[]> pixels_;
+};
+
+class TestLazyPixelRef : public skia::LazyPixelRef {
+ public:
+ // Pure virtual implementation.
+ TestLazyPixelRef(int width, int height)
+ : pixels_(new char[4 * width * height]) {}
+ virtual SkFlattenable::Factory getFactory() OVERRIDE { return NULL; }
+ virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE {
+ return pixels_.get();
+ }
+ virtual void onUnlockPixels() OVERRIDE {}
+ virtual bool PrepareToDecode(const PrepareParams& params) OVERRIDE {
+ return true;
+ }
+ virtual SkPixelRef* deepCopy(
+ SkBitmap::Config config,
+ const SkIRect* subset) OVERRIDE {
+ this->ref();
+ return this;
+ }
+ virtual void Decode() OVERRIDE {}
+ private:
+ scoped_ptr<char[]> pixels_;
+};
+
+void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) {
+ SkAutoTUnref<TestLazyPixelRef> lazy_pixel_ref;
+ lazy_pixel_ref.reset(new TestLazyPixelRef(size.width(), size.height()));
+ lazy_pixel_ref->setURI(uri);
+
+ bitmap->setConfig(SkBitmap::kARGB_8888_Config,
+ size.width(),
+ size.height());
+ bitmap->setPixelRef(lazy_pixel_ref);
+}
+
void RerecordPile(scoped_refptr<FakePicturePileImpl> pile) {
for (int y = 0; y < pile->num_tiles_y(); ++y) {
for (int x = 0; x < pile->num_tiles_x(); ++x) {
@@ -134,6 +193,604 @@ TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
EXPECT_EQ(analysis.solid_color, solid_color);
}
+TEST(PicturePileImplTest, LazyPixelRefIteratorEmpty) {
+ 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::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ // Shifted tile sized iterators.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(140, 140, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(280, 280, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(70, 70, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ // Layer sized iterators.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+}
+
+TEST(PicturePileImplTest, LazyPixelRefIteratorNoLazyRefs) {
+ gfx::Size tile_size(128, 128);
+ gfx::Size layer_bounds(256, 256);
+
+ scoped_refptr<FakePicturePileImpl> pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ SkPaint simple_paint;
+ simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34));
+
+ SkBitmap non_lazy_bitmap;
+ CreateBitmap(gfx::Size(128, 128), "notlazy", &non_lazy_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_lazy_bitmap, gfx::Point(128, 0));
+ pile->add_draw_bitmap(non_lazy_bitmap, gfx::Point(0, 128));
+ pile->add_draw_bitmap(non_lazy_bitmap, gfx::Point(150, 150));
+
+ RerecordPile(pile);
+
+ // Tile sized iterators.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ // Shifted tile sized iterators.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(140, 140, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(280, 280, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(70, 70, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ // Layer sized iterators.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_FALSE(iterator);
+ }
+}
+
+TEST(PicturePileImplTest, LazyPixelRefIteratorLazyRefs) {
+ gfx::Size tile_size(128, 128);
+ gfx::Size layer_bounds(256, 256);
+
+ scoped_refptr<FakePicturePileImpl> pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ SkBitmap lazy_bitmap[2][2];
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[0][0]);
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[1][0]);
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[1][1]);
+
+ // Lazy pixel refs are found in the following cells:
+ // |---|---|
+ // | x | |
+ // |---|---|
+ // | x | x |
+ // |---|---|
+ pile->add_draw_bitmap(lazy_bitmap[0][0], gfx::Point(0, 0));
+ pile->add_draw_bitmap(lazy_bitmap[1][0], gfx::Point(0, 130));
+ pile->add_draw_bitmap(lazy_bitmap[1][1], gfx::Point(140, 140));
+
+ RerecordPile(pile);
+
+ // Tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Shifted tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(140, 140, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(280, 280, 256, 256),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(70, 70, 64, 64),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Ensure there's no lazy pixel refs in the empty cell
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(140, 0, 128, 128),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ // Ensure we can increment the iterator with no change
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ }
+ // Layer sized iterators. These should find all 3 pixel refs.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+}
+
+TEST(PicturePileImplTest, LazyPixelRefIteratorLazyRefsOneTile) {
+ gfx::Size tile_size(256, 256);
+ gfx::Size layer_bounds(512, 512);
+
+ scoped_refptr<FakePicturePileImpl> pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ SkBitmap lazy_bitmap[2][2];
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[0][0]);
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[0][1]);
+ CreateBitmap(gfx::Size(32, 32), "lazy", &lazy_bitmap[1][1]);
+
+ // Lazy pixel refs are found in the following cells:
+ // |---|---|
+ // | x | x |
+ // |---|---|
+ // | | x |
+ // |---|---|
+ pile->add_draw_bitmap(lazy_bitmap[0][0], gfx::Point(0, 0));
+ pile->add_draw_bitmap(lazy_bitmap[0][1], gfx::Point(260, 0));
+ pile->add_draw_bitmap(lazy_bitmap[1][1], gfx::Point(260, 260));
+
+ RerecordPile(pile);
+
+ // Tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Shifted tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(260, 260, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(520, 520, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(130, 130, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Ensure there's no lazy pixel refs in the empty cell
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 256, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ // Ensure we can increment the iterator with no change
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ }
+ // Layer sized iterators. These should find three pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 1024, 1024),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+
+ // Copy test.
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+
+ // copy now points to the same spot as iterator,
+ // but both can be incremented independently.
+ PicturePileImpl::LazyPixelRefIterator copy = iterator;
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+
+ EXPECT_TRUE(copy);
+ EXPECT_TRUE(*copy == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++copy);
+ EXPECT_TRUE(*copy == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++copy);
+}
+
+TEST(PicturePileImplTest, LazyPixelRefIteratorLazyRefsBaseNonLazy) {
+ gfx::Size tile_size(256, 256);
+ gfx::Size layer_bounds(512, 512);
+
+ scoped_refptr<FakePicturePileImpl> pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ SkBitmap non_lazy_bitmap;
+ CreateBitmap(gfx::Size(512, 512), "notlazy", &non_lazy_bitmap);
+
+ SkBitmap lazy_bitmap[2][2];
+ CreateBitmap(gfx::Size(128, 128), "lazy", &lazy_bitmap[0][0]);
+ CreateBitmap(gfx::Size(128, 128), "lazy", &lazy_bitmap[0][1]);
+ CreateBitmap(gfx::Size(128, 128), "lazy", &lazy_bitmap[1][1]);
+
+ // One large non-lazy bitmap covers the whole grid.
+ // Lazy pixel refs are found in the following cells:
+ // |---|---|
+ // | x | x |
+ // |---|---|
+ // | | x |
+ // |---|---|
+ pile->add_draw_bitmap(non_lazy_bitmap, gfx::Point(0, 0));
+ pile->add_draw_bitmap(lazy_bitmap[0][0], gfx::Point(0, 0));
+ pile->add_draw_bitmap(lazy_bitmap[0][1], gfx::Point(260, 0));
+ pile->add_draw_bitmap(lazy_bitmap[1][1], gfx::Point(260, 260));
+
+ RerecordPile(pile);
+
+ // Tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Shifted tile sized iterators. These should find only one pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(260, 260, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(520, 520, 512, 512),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(130, 130, 128, 128),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ // Ensure there's no lazy pixel refs in the empty cell
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 256, 256, 256),
+ 1.0,
+ pile);
+ EXPECT_FALSE(iterator);
+ // Ensure we can increment the iterator with no change
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ EXPECT_FALSE(++iterator);
+ }
+ // Layer sized iterators. These should find three pixel ref.
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 512, 512),
+ 1.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 1024, 1024),
+ 2.0,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+ {
+ PicturePileImpl::LazyPixelRefIterator iterator(
+ gfx::Rect(0, 0, 256, 256),
+ 0.5,
+ pile);
+ EXPECT_TRUE(iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef());
+ EXPECT_TRUE(++iterator);
+ EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef());
+ EXPECT_FALSE(++iterator);
+ }
+}
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698