diff options
-rw-r--r-- | cc/resources/picture.cc | 10 | ||||
-rw-r--r-- | cc/resources/picture.h | 10 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl.h | 4 | ||||
-rw-r--r-- | cc/resources/picture_pile_impl_unittest.cc | 181 | ||||
-rw-r--r-- | cc/resources/picture_unittest.cc | 78 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.cc | 12 | ||||
-rw-r--r-- | cc/resources/raster_worker_pool.h | 6 | ||||
-rw-r--r-- | cc/resources/tile_manager.cc | 6 | ||||
-rw-r--r-- | cc/resources/tile_manager.h | 4 | ||||
-rw-r--r-- | cc/test/skia_common.cc | 35 | ||||
-rw-r--r-- | cc/test/skia_common.h | 20 | ||||
-rw-r--r-- | chrome/chrome_tests_unit.gypi | 2 | ||||
-rw-r--r-- | skia/ext/lazy_pixel_ref_utils.h | 33 | ||||
-rw-r--r-- | skia/ext/pixel_ref_utils.cc (renamed from skia/ext/lazy_pixel_ref_utils.cc) | 43 | ||||
-rw-r--r-- | skia/ext/pixel_ref_utils.h | 32 | ||||
-rw-r--r-- | skia/ext/pixel_ref_utils_unittest.cc (renamed from skia/ext/lazy_pixel_ref_utils_unittest.cc) | 203 | ||||
-rw-r--r-- | skia/skia_chrome.gypi | 4 |
17 files changed, 315 insertions, 368 deletions
diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc index 8c3be9c..f01772b 100644 --- a/cc/resources/picture.cc +++ b/cc/resources/picture.cc @@ -16,7 +16,7 @@ #include "cc/debug/traced_picture.h" #include "cc/debug/traced_value.h" #include "cc/layers/content_layer_client.h" -#include "skia/ext/lazy_pixel_ref_utils.h" +#include "skia/ext/pixel_ref_utils.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkData.h" #include "third_party/skia/include/core/SkDrawFilter.h" @@ -263,9 +263,9 @@ void Picture::GatherPixelRefs( int max_x = 0; int max_y = 0; - skia::LazyPixelRefList pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture_.get(), &pixel_refs); - for (skia::LazyPixelRefList::const_iterator it = pixel_refs.begin(); + skia::DiscardablePixelRefList pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture_.get(), &pixel_refs); + for (skia::DiscardablePixelRefList::const_iterator it = pixel_refs.begin(); it != pixel_refs.end(); ++it) { gfx::Point min( @@ -282,7 +282,7 @@ void Picture::GatherPixelRefs( for (int y = min.y(); y <= max.y(); y += cell_size_.height()) { for (int x = min.x(); x <= max.x(); x += cell_size_.width()) { PixelRefMapKey key(x, y); - pixel_refs_[key].push_back(it->lazy_pixel_ref); + pixel_refs_[key].push_back(it->pixel_ref); } } diff --git a/cc/resources/picture.h b/cc/resources/picture.h index 085fb6a..9facb43 100644 --- a/cc/resources/picture.h +++ b/cc/resources/picture.h @@ -18,12 +18,12 @@ #include "base/memory/scoped_ptr.h" #include "cc/base/cc_export.h" #include "cc/base/region.h" -#include "skia/ext/lazy_pixel_ref.h" #include "skia/ext/refptr.h" -#include "third_party/skia/include/core/SkPixelRef.h" #include "third_party/skia/include/core/SkTileGridPicture.h" #include "ui/gfx/rect.h" +class SkPixelRef; + namespace base { class Value; } @@ -40,7 +40,7 @@ class CC_EXPORT Picture : public base::RefCountedThreadSafe<Picture> { public: typedef std::pair<int, int> PixelRefMapKey; - typedef std::vector<skia::LazyPixelRef*> PixelRefs; + typedef std::vector<SkPixelRef*> PixelRefs; typedef base::hash_map<PixelRefMapKey, PixelRefs> PixelRefMap; static scoped_refptr<Picture> Create(gfx::Rect layer_rect); @@ -87,12 +87,12 @@ class CC_EXPORT Picture PixelRefIterator(gfx::Rect layer_rect, const Picture* picture); ~PixelRefIterator(); - skia::LazyPixelRef* operator->() const { + SkPixelRef* operator->() const { DCHECK_LT(current_index_, current_pixel_refs_->size()); return (*current_pixel_refs_)[current_index_]; } - skia::LazyPixelRef* operator*() const { + SkPixelRef* operator*() const { DCHECK_LT(current_index_, current_pixel_refs_->size()); return (*current_pixel_refs_)[current_index_]; } diff --git a/cc/resources/picture_pile_impl.h b/cc/resources/picture_pile_impl.h index 180dba2..2bc9da8 100644 --- a/cc/resources/picture_pile_impl.h +++ b/cc/resources/picture_pile_impl.h @@ -87,8 +87,8 @@ class CC_EXPORT PicturePileImpl : public PicturePileBase { const PicturePileImpl* picture_pile); ~PixelRefIterator(); - skia::LazyPixelRef* operator->() const { return *pixel_ref_iterator_; } - skia::LazyPixelRef* operator*() const { return *pixel_ref_iterator_; } + SkPixelRef* operator->() const { return *pixel_ref_iterator_; } + SkPixelRef* operator*() const { return *pixel_ref_iterator_; } PixelRefIterator& operator++(); operator bool() const { return pixel_ref_iterator_; } diff --git a/cc/resources/picture_pile_impl_unittest.cc b/cc/resources/picture_pile_impl_unittest.cc index e5691e3..5f144ad 100644 --- a/cc/resources/picture_pile_impl_unittest.cc +++ b/cc/resources/picture_pile_impl_unittest.cc @@ -6,7 +6,6 @@ #include "cc/test/fake_picture_pile_impl.h" #include "cc/test/fake_rendering_stats_instrumentation.h" #include "cc/test/skia_common.h" -#include "skia/ext/lazy_pixel_ref.h" #include "skia/ext/refptr.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkPixelRef.h" @@ -206,7 +205,7 @@ TEST(PicturePileImplTest, PixelRefIteratorEmpty) { } } -TEST(PicturePileImplTest, PixelRefIteratorNoLazyRefs) { +TEST(PicturePileImplTest, PixelRefIteratorNoDiscardableRefs) { gfx::Size tile_size(128, 128); gfx::Size layer_bounds(256, 256); @@ -216,16 +215,16 @@ TEST(PicturePileImplTest, PixelRefIteratorNoLazyRefs) { SkPaint simple_paint; simple_paint.setColor(SkColorSetARGB(255, 12, 23, 34)); - SkBitmap non_lazy_bitmap; - CreateBitmap(gfx::Size(128, 128), "notlazy", &non_lazy_bitmap); + 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_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)); + 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)); pile->RerecordPile(); @@ -279,27 +278,27 @@ TEST(PicturePileImplTest, PixelRefIteratorNoLazyRefs) { } } -TEST(PicturePileImplTest, PixelRefIteratorLazyRefs) { +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); - 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]); + 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]); - // Lazy pixel refs are found in the following cells: + // Discardable 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)); + 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)); pile->RerecordPile(); @@ -308,21 +307,21 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefs) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 128, 128), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_FALSE(++iterator); } // Shifted tile sized iterators. These should find only one pixel ref. @@ -330,24 +329,24 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefs) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(140, 140, 128, 128), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } - // Ensure there's no lazy pixel refs in the empty cell + // Ensure there's no discardable pixel refs in the empty cell { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(140, 0, 128, 128), 1.0, pile.get()); @@ -358,58 +357,58 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefs) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } } -TEST(PicturePileImplTest, PixelRefIteratorLazyRefsOneTile) { +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); - 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]); + SkBitmap discardable_bitmap[2][2]; + CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][0]); + CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[0][1]); + CreateBitmap(gfx::Size(32, 32), "discardable", &discardable_bitmap[1][1]); - // Lazy pixel refs are found in the following cells: + // Discardable 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)); + 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)); pile->RerecordPile(); @@ -418,21 +417,21 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsOneTile) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_FALSE(++iterator); } // Shifted tile sized iterators. These should find only one pixel ref. @@ -440,24 +439,24 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsOneTile) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(260, 260, 256, 256), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } - // Ensure there's no lazy pixel refs in the empty cell + // Ensure there's no discardable pixel refs in the empty cell { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 256, 256, 256), 1.0, pile.get()); @@ -468,33 +467,33 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsOneTile) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 512, 512), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } @@ -502,50 +501,50 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsOneTile) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 512, 512), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); // copy now points to the same spot as iterator, // but both can be incremented independently. PicturePileImpl::PixelRefIterator copy = iterator; EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); EXPECT_TRUE(copy); - EXPECT_TRUE(*copy == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++copy); - EXPECT_TRUE(*copy == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++copy); } -TEST(PicturePileImplTest, PixelRefIteratorLazyRefsBaseNonLazy) { +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); - SkBitmap non_lazy_bitmap; - CreateBitmap(gfx::Size(512, 512), "notlazy", &non_lazy_bitmap); + SkBitmap non_discardable_bitmap; + CreateBitmap(gfx::Size(512, 512), "notdiscardable", &non_discardable_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]); + 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-lazy bitmap covers the whole grid. - // Lazy pixel refs are found in the following cells: + // One large non-discardable bitmap covers the whole grid. + // Discardable 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)); + 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)); pile->RerecordPile(); @@ -554,21 +553,21 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsBaseNonLazy) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 256, 256), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_FALSE(++iterator); } // Shifted tile sized iterators. These should find only one pixel ref. @@ -576,24 +575,24 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsBaseNonLazy) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(260, 260, 256, 256), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } - // Ensure there's no lazy pixel refs in the empty cell + // Ensure there's no discardable pixel refs in the empty cell { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 256, 256, 256), 1.0, pile.get()); @@ -604,33 +603,33 @@ TEST(PicturePileImplTest, PixelRefIteratorLazyRefsBaseNonLazy) { PicturePileImpl::PixelRefIterator iterator( gfx::Rect(0, 0, 512, 512), 1.0, pile.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + 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 == lazy_bitmap[0][0].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][0].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[0][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[0][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][1].pixelRef()); EXPECT_FALSE(++iterator); } } diff --git a/cc/resources/picture_unittest.cc b/cc/resources/picture_unittest.cc index f279a99..a7cde02 100644 --- a/cc/resources/picture_unittest.cc +++ b/cc/resources/picture_unittest.cc @@ -110,7 +110,7 @@ TEST(PictureTest, PixelRefIterator) { FakeContentLayerClient content_layer_client; - // Lazy pixel refs are found in the following grids: + // Discardable pixel refs are found in the following grids: // |---|---|---|---| // | | x | | x | // |---|---|---|---| @@ -120,14 +120,15 @@ TEST(PictureTest, PixelRefIterator) { // |---|---|---|---| // | x | | x | | // |---|---|---|---| - SkBitmap lazy_bitmap[4][4]; + 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), "lazy", &lazy_bitmap[y][x]); + CreateBitmap( + gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]); SkPaint paint; content_layer_client.add_draw_bitmap( - lazy_bitmap[y][x], + discardable_bitmap[y][x], gfx::Point(x * 512 + 6, y * 512 + 6), paint); } } @@ -149,7 +150,8 @@ TEST(PictureTest, PixelRefIterator) { picture.get()); if ((x + y) & 1) { EXPECT_TRUE(iterator) << x << " " << y; - EXPECT_TRUE(*iterator == lazy_bitmap[y][x].pixelRef()) << x << " " << y; + EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef()) << x << + " " << y; EXPECT_FALSE(++iterator) << x << " " << y; } else { EXPECT_FALSE(iterator) << x << " " << y; @@ -161,13 +163,13 @@ TEST(PictureTest, PixelRefIterator) { Picture::PixelRefIterator iterator(gfx::Rect(512, 512, 2048, 2048), picture.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++iterator); } @@ -175,25 +177,25 @@ TEST(PictureTest, PixelRefIterator) { Picture::PixelRefIterator iterator(gfx::Rect(512, 512, 2048, 2048), picture.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][1].pixelRef()); + 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 == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++iterator); EXPECT_TRUE(copy); - EXPECT_TRUE(*copy == lazy_bitmap[2][1].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[2][1].pixelRef()); EXPECT_TRUE(++copy); - EXPECT_TRUE(*copy == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++copy); - EXPECT_TRUE(*copy == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++copy); } @@ -207,7 +209,7 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { FakeContentLayerClient content_layer_client; - // Lazy pixel refs are found in the following grids: + // Discardable pixel refs are found in the following grids: // |---|---|---|---| // | | x | | x | // |---|---|---|---| @@ -217,14 +219,15 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { // |---|---|---|---| // | x | | x | | // |---|---|---|---| - SkBitmap lazy_bitmap[4][4]; + 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), "lazy", &lazy_bitmap[y][x]); + CreateBitmap( + gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]); SkPaint paint; content_layer_client.add_draw_bitmap( - lazy_bitmap[y][x], + discardable_bitmap[y][x], gfx::Point(1024 + x * 512 + 6, y * 512 + 6), paint); } } @@ -246,7 +249,7 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { gfx::Rect(1024 + x * 512, y * 512, 500, 500), picture.get()); if ((x + y) & 1) { EXPECT_TRUE(iterator) << x << " " << y; - EXPECT_TRUE(*iterator == lazy_bitmap[y][x].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef()); EXPECT_FALSE(++iterator) << x << " " << y; } else { EXPECT_FALSE(iterator) << x << " " << y; @@ -258,13 +261,13 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { Picture::PixelRefIterator iterator(gfx::Rect(1024 + 512, 512, 2048, 2048), picture.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][1].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][1].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++iterator); } @@ -273,25 +276,25 @@ TEST(PictureTest, PixelRefIteratorNonZeroLayer) { Picture::PixelRefIterator iterator(gfx::Rect(1024 + 512, 512, 2048, 2048), picture.get()); EXPECT_TRUE(iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[1][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[1][2].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[2][1].pixelRef()); + 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 == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++iterator); - EXPECT_TRUE(*iterator == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++iterator); EXPECT_TRUE(copy); - EXPECT_TRUE(*copy == lazy_bitmap[2][1].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[2][1].pixelRef()); EXPECT_TRUE(++copy); - EXPECT_TRUE(*copy == lazy_bitmap[2][3].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[2][3].pixelRef()); EXPECT_TRUE(++copy); - EXPECT_TRUE(*copy == lazy_bitmap[3][2].pixelRef()); + EXPECT_TRUE(*copy == discardable_bitmap[3][2].pixelRef()); EXPECT_FALSE(++copy); } @@ -328,7 +331,7 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { FakeContentLayerClient content_layer_client; - // Lazy pixel refs are found in the following grids: + // Discardable pixel refs are found in the following grids: // |---|---|---|---| // | | x | | x | // |---|---|---|---| @@ -338,14 +341,15 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { // |---|---|---|---| // | x | | x | | // |---|---|---|---| - SkBitmap lazy_bitmap[4][4]; + 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), "lazy", &lazy_bitmap[y][x]); + CreateBitmap( + gfx::Size(500, 500), "discardable", &discardable_bitmap[y][x]); SkPaint paint; content_layer_client.add_draw_bitmap( - lazy_bitmap[y][x], + discardable_bitmap[y][x], gfx::Point(x * 512 + 6, y * 512 + 6), paint); } } @@ -362,7 +366,7 @@ TEST(PictureTest, PixelRefIteratorOnePixelQuery) { gfx::Rect(x * 512, y * 512 + 256, 1, 1), picture.get()); if ((x + y) & 1) { EXPECT_TRUE(iterator) << x << " " << y; - EXPECT_TRUE(*iterator == lazy_bitmap[y][x].pixelRef()); + EXPECT_TRUE(*iterator == discardable_bitmap[y][x].pixelRef()); EXPECT_FALSE(++iterator) << x << " " << y; } else { EXPECT_FALSE(iterator) << x << " " << y; diff --git a/cc/resources/raster_worker_pool.cc b/cc/resources/raster_worker_pool.cc index 06fd18e..06a78a8 100644 --- a/cc/resources/raster_worker_pool.cc +++ b/cc/resources/raster_worker_pool.cc @@ -10,9 +10,9 @@ #include "cc/debug/devtools_instrumentation.h" #include "cc/debug/traced_value.h" #include "cc/resources/picture_pile_impl.h" -#include "skia/ext/lazy_pixel_ref.h" #include "skia/ext/paint_simplifier.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "third_party/skia/include/core/SkPixelRef.h" namespace cc { @@ -253,7 +253,7 @@ class RasterWorkerPoolTaskImpl : public internal::RasterWorkerPoolTask { class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { public: - ImageDecodeWorkerPoolTaskImpl(skia::LazyPixelRef* pixel_ref, + ImageDecodeWorkerPoolTaskImpl(SkPixelRef* pixel_ref, int layer_id, RenderingStatsInstrumentation* rendering_stats, const RasterWorkerPool::Task::Reply& reply) @@ -267,7 +267,9 @@ class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { TRACE_EVENT0("cc", "ImageDecodeWorkerPoolTaskImpl::RunOnWorkerThread"); devtools_instrumentation::ScopedImageDecodeTask image_decode_task( pixel_ref_.get()); - pixel_ref_->Decode(); + // This will cause the image referred to by pixel ref to be decoded. + pixel_ref_->lockPixels(); + pixel_ref_->unlockPixels(); } virtual void CompleteOnOriginThread() OVERRIDE { reply_.Run(!HasFinishedRunning()); @@ -277,7 +279,7 @@ class ImageDecodeWorkerPoolTaskImpl : public internal::WorkerPoolTask { virtual ~ImageDecodeWorkerPoolTaskImpl() {} private: - skia::RefPtr<skia::LazyPixelRef> pixel_ref_; + skia::RefPtr<SkPixelRef> pixel_ref_; int layer_id_; RenderingStatsInstrumentation* rendering_stats_; const RasterWorkerPool::Task::Reply reply_; @@ -451,7 +453,7 @@ RasterWorkerPool::RasterTask RasterWorkerPool::CreateRasterTask( // static RasterWorkerPool::Task RasterWorkerPool::CreateImageDecodeTask( - skia::LazyPixelRef* pixel_ref, + SkPixelRef* pixel_ref, int layer_id, RenderingStatsInstrumentation* stats_instrumentation, const Task::Reply& reply) { diff --git a/cc/resources/raster_worker_pool.h b/cc/resources/raster_worker_pool.h index fac2fd8..21ed060 100644 --- a/cc/resources/raster_worker_pool.h +++ b/cc/resources/raster_worker_pool.h @@ -17,9 +17,7 @@ #include "cc/resources/worker_pool.h" #include "third_party/khronos/GLES2/gl2.h" -namespace skia { -class LazyPixelRef; -} +class SkPixelRef; namespace cc { namespace internal { @@ -204,7 +202,7 @@ class CC_EXPORT RasterWorkerPool : public WorkerPool { Task::Set* dependencies); static Task CreateImageDecodeTask( - skia::LazyPixelRef* pixel_ref, + SkPixelRef* pixel_ref, int layer_id, RenderingStatsInstrumentation* stats_instrumentation, const Task::Reply& reply); diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 2fbb6d1..e929561 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -834,7 +834,7 @@ void TileManager::ScheduleTasks( } RasterWorkerPool::Task TileManager::CreateImageDecodeTask( - Tile* tile, skia::LazyPixelRef* pixel_ref) { + Tile* tile, SkPixelRef* pixel_ref) { return RasterWorkerPool::CreateImageDecodeTask( pixel_ref, tile->layer_id(), @@ -859,7 +859,7 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { tile->contents_scale(), tile->picture_pile()); iter; ++iter) { - skia::LazyPixelRef* pixel_ref = *iter; + SkPixelRef* pixel_ref = *iter; uint32_t id = pixel_ref->getGenerationID(); // Append existing image decode task if available. @@ -897,7 +897,7 @@ RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { void TileManager::OnImageDecodeTaskCompleted( int layer_id, - skia::LazyPixelRef* pixel_ref, + SkPixelRef* pixel_ref, bool was_canceled) { // If the task was canceled, we need to clean it up // from |image_decode_tasks_|. diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index 78beb1b..c92746a 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -154,7 +154,7 @@ class CC_EXPORT TileManager : public RasterWorkerPoolClient, private: void OnImageDecodeTaskCompleted( int layer_id, - skia::LazyPixelRef* pixel_ref, + SkPixelRef* pixel_ref, bool was_canceled); void OnRasterTaskCompleted(Tile::Id tile, scoped_ptr<ScopedResource> resource, @@ -172,7 +172,7 @@ class CC_EXPORT TileManager : public RasterWorkerPoolClient, void FreeResourcesForTile(Tile* tile); void FreeUnusedResourcesForTile(Tile* tile); RasterWorkerPool::Task CreateImageDecodeTask( - Tile* tile, skia::LazyPixelRef* pixel_ref); + Tile* tile, SkPixelRef* pixel_ref); RasterWorkerPool::RasterTask CreateRasterTask(Tile* tile); scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; void UpdatePrioritizedTileSetIfNeeded(); diff --git a/cc/test/skia_common.cc b/cc/test/skia_common.cc index d8d61a8..de2733d 100644 --- a/cc/test/skia_common.cc +++ b/cc/test/skia_common.cc @@ -31,33 +31,6 @@ SkPixelRef* TestPixelRef::deepCopy( } -TestLazyPixelRef::TestLazyPixelRef(const SkImageInfo& info) - : skia::LazyPixelRef(info), - pixels_(new char[4 * info.fWidth * info.fHeight]) {} - -TestLazyPixelRef::~TestLazyPixelRef() {} - -SkFlattenable::Factory TestLazyPixelRef::getFactory() const { return NULL; } - -void* TestLazyPixelRef::onLockPixels(SkColorTable** color_table) { - return pixels_.get(); -} - -bool TestLazyPixelRef::PrepareToDecode(const PrepareParams& params) { - return true; -} - -bool TestLazyPixelRef::MaybeDecoded() { - return true; -} - -SkPixelRef* TestLazyPixelRef::deepCopy( - SkBitmap::Config config, - const SkIRect* subset) { - this->ref(); - return this; -} - void DrawPicture(unsigned char* buffer, gfx::Rect layer_rect, scoped_refptr<Picture> picture) { @@ -80,12 +53,12 @@ void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { kPremul_SkAlphaType }; - skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = - skia::AdoptRef(new TestLazyPixelRef(info)); - lazy_pixel_ref->setURI(uri); + skia::RefPtr<TestPixelRef> pixel_ref = + skia::AdoptRef(new TestPixelRef(info)); + pixel_ref->setURI(uri); bitmap->setConfig(info); - bitmap->setPixelRef(lazy_pixel_ref.get()); + bitmap->setPixelRef(pixel_ref.get()); } diff --git a/cc/test/skia_common.h b/cc/test/skia_common.h index 8762f32..853fb5d 100644 --- a/cc/test/skia_common.h +++ b/cc/test/skia_common.h @@ -7,9 +7,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "skia/ext/lazy_pixel_ref.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkFlattenable.h" +#include "third_party/skia/include/core/SkPixelRef.h" namespace gfx { class Rect; @@ -34,24 +34,6 @@ class TestPixelRef : public SkPixelRef { scoped_ptr<char[]> pixels_; }; -class TestLazyPixelRef : public skia::LazyPixelRef { - public: - explicit TestLazyPixelRef(const SkImageInfo& info); - virtual ~TestLazyPixelRef(); - - virtual SkFlattenable::Factory getFactory() const OVERRIDE; - virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE; - virtual void onUnlockPixels() OVERRIDE {} - virtual bool PrepareToDecode(const PrepareParams& params) OVERRIDE; - virtual bool MaybeDecoded() OVERRIDE; - virtual SkPixelRef* deepCopy( - SkBitmap::Config config, - const SkIRect* subset) OVERRIDE; - virtual void Decode() OVERRIDE {} - private: - scoped_ptr<char[]> pixels_; -}; - void DrawPicture(unsigned char* buffer, gfx::Rect layer_rect, scoped_refptr<Picture> picture); diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 94ac3ba..91fe9ff 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -1982,7 +1982,7 @@ '../skia/ext/bitmap_platform_device_mac_unittest.cc', '../skia/ext/convolver_unittest.cc', '../skia/ext/image_operations_unittest.cc', - '../skia/ext/lazy_pixel_ref_utils_unittest.cc', + '../skia/ext/pixel_ref_utils_unittest.cc', '../skia/ext/platform_canvas_unittest.cc', '../skia/ext/recursive_gaussian_convolution_unittest.cc', '../skia/ext/refptr_unittest.cc', diff --git a/skia/ext/lazy_pixel_ref_utils.h b/skia/ext/lazy_pixel_ref_utils.h deleted file mode 100644 index 33fe039..0000000 --- a/skia/ext/lazy_pixel_ref_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef SKIA_EXT_LAZY_PIXEL_REF_UTILS_H_ -#define SKIA_EXT_LAZY_PIXEL_REF_UTILS_H_ - -#include <vector> - -#include "SkPicture.h" -#include "SkRect.h" - -namespace skia { - -class LazyPixelRef; -class SK_API LazyPixelRefUtils { - public: - - struct PositionLazyPixelRef { - skia::LazyPixelRef* lazy_pixel_ref; - SkRect pixel_ref_rect; - }; - - static void GatherPixelRefs( - SkPicture* picture, - std::vector<PositionLazyPixelRef>* lazy_pixel_refs); -}; - -typedef std::vector<LazyPixelRefUtils::PositionLazyPixelRef> LazyPixelRefList; - -} // namespace skia - -#endif diff --git a/skia/ext/lazy_pixel_ref_utils.cc b/skia/ext/pixel_ref_utils.cc index 4b3d297..417295e 100644 --- a/skia/ext/lazy_pixel_ref_utils.cc +++ b/skia/ext/pixel_ref_utils.cc @@ -1,12 +1,11 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "skia/ext/lazy_pixel_ref_utils.h" +#include "skia/ext/pixel_ref_utils.h" #include <algorithm> -#include "skia/ext/lazy_pixel_ref.h" #include "third_party/skia/include/core/SkBitmapDevice.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkData.h" @@ -21,35 +20,35 @@ namespace skia { namespace { -// URI label for a lazily decoded SkPixelRef. -const char kLabelLazyDecoded[] = "lazy"; +// URI label for a discardable SkPixelRef. +const char kLabelDiscardable[] = "discardable"; -class LazyPixelRefSet { +class DiscardablePixelRefSet { public: - LazyPixelRefSet( - std::vector<LazyPixelRefUtils::PositionLazyPixelRef>* pixel_refs) + DiscardablePixelRefSet( + std::vector<PixelRefUtils::PositionPixelRef>* pixel_refs) : pixel_refs_(pixel_refs) {} void Add(SkPixelRef* pixel_ref, const SkRect& rect) { - // Only save lazy pixel refs. + // Only save discardable pixel refs. if (pixel_ref->getURI() && - !strcmp(pixel_ref->getURI(), kLabelLazyDecoded)) { - LazyPixelRefUtils::PositionLazyPixelRef position_pixel_ref; - position_pixel_ref.lazy_pixel_ref = - static_cast<skia::LazyPixelRef*>(pixel_ref); + !strcmp(pixel_ref->getURI(), kLabelDiscardable)) { + PixelRefUtils::PositionPixelRef position_pixel_ref; + position_pixel_ref.pixel_ref = pixel_ref; position_pixel_ref.pixel_ref_rect = rect; pixel_refs_->push_back(position_pixel_ref); } } private: - std::vector<LazyPixelRefUtils::PositionLazyPixelRef>* pixel_refs_; + std::vector<PixelRefUtils::PositionPixelRef>* pixel_refs_; }; class GatherPixelRefDevice : public SkBitmapDevice { public: - GatherPixelRefDevice(const SkBitmap& bm, LazyPixelRefSet* lazy_pixel_ref_set) - : SkBitmapDevice(bm), lazy_pixel_ref_set_(lazy_pixel_ref_set) {} + GatherPixelRefDevice(const SkBitmap& bm, + DiscardablePixelRefSet* pixel_ref_set) + : SkBitmapDevice(bm), pixel_ref_set_(pixel_ref_set) {} virtual void clear(SkColor color) SK_OVERRIDE {} virtual void writePixels(const SkBitmap& bitmap, @@ -327,13 +326,13 @@ class GatherPixelRefDevice : public SkBitmapDevice { } private: - LazyPixelRefSet* lazy_pixel_ref_set_; + DiscardablePixelRefSet* pixel_ref_set_; void AddBitmap(const SkBitmap& bm, const SkRect& rect) { SkRect canvas_rect = SkRect::MakeWH(width(), height()); SkRect paint_rect = SkRect::MakeEmpty(); paint_rect.intersect(rect, canvas_rect); - lazy_pixel_ref_set_->Add(bm.pixelRef(), paint_rect); + pixel_ref_set_->Add(bm.pixelRef(), paint_rect); } bool GetBitmapFromPaint(const SkPaint& paint, SkBitmap* bm) { @@ -389,11 +388,11 @@ class NoSaveLayerCanvas : public SkCanvas { } // namespace -void LazyPixelRefUtils::GatherPixelRefs( +void PixelRefUtils::GatherDiscardablePixelRefs( SkPicture* picture, - std::vector<PositionLazyPixelRef>* lazy_pixel_refs) { - lazy_pixel_refs->clear(); - LazyPixelRefSet pixel_ref_set(lazy_pixel_refs); + std::vector<PositionPixelRef>* pixel_refs) { + pixel_refs->clear(); + DiscardablePixelRefSet pixel_ref_set(pixel_refs); SkBitmap empty_bitmap; empty_bitmap.setConfig( diff --git a/skia/ext/pixel_ref_utils.h b/skia/ext/pixel_ref_utils.h new file mode 100644 index 0000000..2b36dfc --- /dev/null +++ b/skia/ext/pixel_ref_utils.h @@ -0,0 +1,32 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef SKIA_EXT_PIXEL_REF_UTILS_H_ +#define SKIA_EXT_PIXEL_REF_UTILS_H_ + +#include <vector> + +#include "SkPicture.h" +#include "SkRect.h" + +namespace skia { + +class SK_API PixelRefUtils { + public: + + struct PositionPixelRef { + SkPixelRef* pixel_ref; + SkRect pixel_ref_rect; + }; + + static void GatherDiscardablePixelRefs( + SkPicture* picture, + std::vector<PositionPixelRef>* pixel_refs); +}; + +typedef std::vector<PixelRefUtils::PositionPixelRef> DiscardablePixelRefList; + +} // namespace skia + +#endif diff --git a/skia/ext/lazy_pixel_ref_utils_unittest.cc b/skia/ext/pixel_ref_utils_unittest.cc index caa83dd..43801b1 100644 --- a/skia/ext/lazy_pixel_ref_utils_unittest.cc +++ b/skia/ext/pixel_ref_utils_unittest.cc @@ -1,17 +1,17 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" #include "cc/test/geometry_test_utils.h" -#include "skia/ext/lazy_pixel_ref.h" -#include "skia/ext/lazy_pixel_ref_utils.h" +#include "skia/ext/pixel_ref_utils.h" #include "skia/ext/refptr.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkFlattenableBuffers.h" +#include "third_party/skia/include/core/SkPixelRef.h" #include "third_party/skia/include/core/SkPoint.h" #include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/src/core/SkOrderedReadBuffer.h" @@ -24,29 +24,28 @@ namespace { void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap); -class TestLazyPixelRef : public skia::LazyPixelRef { +class TestPixelRef : public SkPixelRef { public: - TestLazyPixelRef(const SkImageInfo& info); - virtual ~TestLazyPixelRef(); + TestPixelRef(const SkImageInfo& info); + virtual ~TestPixelRef(); virtual SkFlattenable::Factory getFactory() const OVERRIDE; virtual void* onLockPixels(SkColorTable** color_table) OVERRIDE; virtual void onUnlockPixels() OVERRIDE {} - virtual bool PrepareToDecode(const PrepareParams& params) OVERRIDE; - virtual bool MaybeDecoded() OVERRIDE; virtual SkPixelRef* deepCopy(SkBitmap::Config config, const SkIRect* subset) OVERRIDE; - virtual void Decode() OVERRIDE {} private: scoped_ptr<char[]> pixels_; }; -class TestLazyShader : public SkShader { +class TestDiscardableShader : public SkShader { public: - TestLazyShader() { CreateBitmap(gfx::Size(50, 50), "lazy", &bitmap_); } + TestDiscardableShader() { + CreateBitmap(gfx::Size(50, 50), "discardable", &bitmap_); + } - TestLazyShader(SkFlattenableReadBuffer& flattenable_buffer) { + TestDiscardableShader(SkFlattenableReadBuffer& flattenable_buffer) { SkOrderedReadBuffer& buffer = static_cast<SkOrderedReadBuffer&>(flattenable_buffer); SkReader32* reader = buffer.getReader32(); @@ -55,7 +54,7 @@ class TestLazyShader : public SkShader { uint32_t toSkip = reader->readU32(); reader->skip(toSkip); - CreateBitmap(gfx::Size(50, 50), "lazy", &bitmap_); + CreateBitmap(gfx::Size(50, 50), "discardable", &bitmap_); } virtual SkShader::BitmapType asABitmap(SkBitmap* bitmap, @@ -68,34 +67,26 @@ class TestLazyShader : public SkShader { // Pure virtual implementaiton. virtual void shadeSpan(int x, int y, SkPMColor[], int count) OVERRIDE {} - SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestLazyShader); + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(TestDiscardableShader); private: SkBitmap bitmap_; }; -TestLazyPixelRef::TestLazyPixelRef(const SkImageInfo& info) - : skia::LazyPixelRef(info), +TestPixelRef::TestPixelRef(const SkImageInfo& info) + : SkPixelRef(info), pixels_(new char[4 * info.fWidth * info.fHeight]) {} -TestLazyPixelRef::~TestLazyPixelRef() {} +TestPixelRef::~TestPixelRef() {} -SkFlattenable::Factory TestLazyPixelRef::getFactory() const { return NULL; } +SkFlattenable::Factory TestPixelRef::getFactory() const { return NULL; } -void* TestLazyPixelRef::onLockPixels(SkColorTable** color_table) { +void* TestPixelRef::onLockPixels(SkColorTable** color_table) { return pixels_.get(); } -bool TestLazyPixelRef::PrepareToDecode(const PrepareParams& params) { - return true; -} - -bool TestLazyPixelRef::MaybeDecoded() { - return true; -} - -SkPixelRef* TestLazyPixelRef::deepCopy(SkBitmap::Config config, - const SkIRect* subset) { +SkPixelRef* TestPixelRef::deepCopy(SkBitmap::Config config, + const SkIRect* subset) { this->ref(); return this; } @@ -104,13 +95,12 @@ void CreateBitmap(gfx::Size size, const char* uri, SkBitmap* bitmap) { const SkImageInfo info = { size.width(), size.height(), kPMColor_SkColorType, kPremul_SkAlphaType }; - - skia::RefPtr<TestLazyPixelRef> lazy_pixel_ref = - skia::AdoptRef(new TestLazyPixelRef(info)); - lazy_pixel_ref->setURI(uri); + skia::RefPtr<TestPixelRef> pixel_ref = + skia::AdoptRef(new TestPixelRef(info)); + pixel_ref->setURI(uri); bitmap->setConfig(info); - bitmap->setPixelRef(lazy_pixel_ref.get()); + bitmap->setPixelRef(pixel_ref.get()); } SkCanvas* StartRecording(SkPicture* picture, gfx::Rect layer_rect) { @@ -135,21 +125,21 @@ void StopRecording(SkPicture* picture, SkCanvas* canvas) { } // namespace -TEST(LazyPixelRefUtilsTest, DrawPaint) { +TEST(PixelRefUtilsTest, DrawPaint) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -162,8 +152,8 @@ TEST(LazyPixelRefUtilsTest, DrawPaint) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 256, 256), @@ -174,21 +164,21 @@ TEST(LazyPixelRefUtilsTest, DrawPaint) { gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawPoints) { +TEST(PixelRefUtilsTest, DrawPoints) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -215,8 +205,8 @@ TEST(LazyPixelRefUtilsTest, DrawPoints) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), @@ -227,21 +217,21 @@ TEST(LazyPixelRefUtilsTest, DrawPoints) { gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawRect) { +TEST(PixelRefUtilsTest, DrawRect) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -261,8 +251,8 @@ TEST(LazyPixelRefUtilsTest, DrawRect) { // (50, 50, 50, 50) canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), @@ -273,21 +263,21 @@ TEST(LazyPixelRefUtilsTest, DrawRect) { gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawRRect) { +TEST(PixelRefUtilsTest, DrawRRect) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -312,8 +302,8 @@ TEST(LazyPixelRefUtilsTest, DrawRRect) { // (50, 50, 50, 50) canvas->drawRRect(rrect, third_paint); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 20, 30, 40), @@ -324,21 +314,21 @@ TEST(LazyPixelRefUtilsTest, DrawRRect) { gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawOval) { +TEST(PixelRefUtilsTest, DrawOval) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -362,8 +352,8 @@ TEST(LazyPixelRefUtilsTest, DrawOval) { // (50, 50, 50, 50) canvas->drawRect(SkRect::MakeXYWH(0, 0, 100, 100), third_paint); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(20, 10, 60, 20), @@ -374,17 +364,17 @@ TEST(LazyPixelRefUtilsTest, DrawOval) { gfx::SkRectToRectF(pixel_refs[2].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawPath) { +TEST(PixelRefUtilsTest, DrawPath) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); @@ -406,8 +396,8 @@ TEST(LazyPixelRefUtilsTest, DrawPath) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(2u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(12, 13, 38, 88), @@ -416,22 +406,22 @@ TEST(LazyPixelRefUtilsTest, DrawPath) { gfx::SkRectToRectF(pixel_refs[1].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawBitmap) { +TEST(PixelRefUtilsTest, DrawBitmap) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); SkBitmap first; - CreateBitmap(gfx::Size(50, 50), "lazy", &first); + CreateBitmap(gfx::Size(50, 50), "discardable", &first); SkBitmap second; - CreateBitmap(gfx::Size(50, 50), "lazy", &second); + CreateBitmap(gfx::Size(50, 50), "discardable", &second); SkBitmap third; - CreateBitmap(gfx::Size(50, 50), "lazy", &third); + CreateBitmap(gfx::Size(50, 50), "discardable", &third); SkBitmap fourth; - CreateBitmap(gfx::Size(50, 1), "lazy", &fourth); + CreateBitmap(gfx::Size(50, 1), "discardable", &fourth); SkBitmap fifth; - CreateBitmap(gfx::Size(10, 10), "lazy", &fifth); + CreateBitmap(gfx::Size(10, 10), "discardable", &fifth); canvas->save(); @@ -460,8 +450,8 @@ TEST(LazyPixelRefUtilsTest, DrawBitmap) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(5u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50), @@ -477,33 +467,34 @@ TEST(LazyPixelRefUtilsTest, DrawBitmap) { } -TEST(LazyPixelRefUtilsTest, DrawBitmapRect) { +TEST(PixelRefUtilsTest, DrawBitmapRect) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); SkBitmap first; - CreateBitmap(gfx::Size(50, 50), "lazy", &first); + CreateBitmap(gfx::Size(50, 50), "discardable", &first); SkBitmap second; - CreateBitmap(gfx::Size(50, 50), "lazy", &second); + CreateBitmap(gfx::Size(50, 50), "discardable", &second); SkBitmap third; - CreateBitmap(gfx::Size(50, 50), "lazy", &third); + CreateBitmap(gfx::Size(50, 50), "discardable", &third); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - SkPaint non_lazy_paint; + SkPaint non_discardable_paint; canvas->save(); // (0, 0, 100, 100). - canvas->drawBitmapRect(first, SkRect::MakeWH(100, 100), &non_lazy_paint); + canvas->drawBitmapRect( + first, SkRect::MakeWH(100, 100), &non_discardable_paint); canvas->translate(25, 0); // (75, 50, 10, 10). canvas->drawBitmapRect( - second, SkRect::MakeXYWH(50, 50, 10, 10), &non_lazy_paint); + second, SkRect::MakeXYWH(50, 50, 10, 10), &non_discardable_paint); canvas->translate(5, 50); // (0, 30, 100, 100). One from bitmap, one from paint. canvas->drawBitmapRect( @@ -513,8 +504,8 @@ TEST(LazyPixelRefUtilsTest, DrawBitmapRect) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(4u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), @@ -527,22 +518,22 @@ TEST(LazyPixelRefUtilsTest, DrawBitmapRect) { gfx::SkRectToRectF(pixel_refs[3].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawSprite) { +TEST(PixelRefUtilsTest, DrawSprite) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); SkBitmap first; - CreateBitmap(gfx::Size(50, 50), "lazy", &first); + CreateBitmap(gfx::Size(50, 50), "discardable", &first); SkBitmap second; - CreateBitmap(gfx::Size(50, 50), "lazy", &second); + CreateBitmap(gfx::Size(50, 50), "discardable", &second); SkBitmap third; - CreateBitmap(gfx::Size(50, 50), "lazy", &third); + CreateBitmap(gfx::Size(50, 50), "discardable", &third); SkBitmap fourth; - CreateBitmap(gfx::Size(50, 50), "lazy", &fourth); + CreateBitmap(gfx::Size(50, 50), "discardable", &fourth); SkBitmap fifth; - CreateBitmap(gfx::Size(50, 50), "lazy", &fifth); + CreateBitmap(gfx::Size(50, 50), "discardable", &fifth); canvas->save(); @@ -566,7 +557,7 @@ TEST(LazyPixelRefUtilsTest, DrawSprite) { canvas->restore(); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); @@ -576,8 +567,8 @@ TEST(LazyPixelRefUtilsTest, DrawSprite) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(6u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 50), @@ -594,13 +585,13 @@ TEST(LazyPixelRefUtilsTest, DrawSprite) { gfx::SkRectToRectF(pixel_refs[5].pixel_ref_rect)); } -TEST(LazyPixelRefUtilsTest, DrawText) { +TEST(PixelRefUtilsTest, DrawText) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); @@ -621,27 +612,27 @@ TEST(LazyPixelRefUtilsTest, DrawText) { canvas->drawPosText("text", 4, points, first_paint); canvas->drawTextOnPath("text", 4, path, NULL, first_paint); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); } -TEST(LazyPixelRefUtilsTest, DrawVertices) { +TEST(PixelRefUtilsTest, DrawVertices) { gfx::Rect layer_rect(0, 0, 256, 256); skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); SkCanvas* canvas = StartRecording(picture.get(), layer_rect); - TestLazyShader first_shader; + TestDiscardableShader first_shader; SkPaint first_paint; first_paint.setShader(&first_shader); - TestLazyShader second_shader; + TestDiscardableShader second_shader; SkPaint second_paint; second_paint.setShader(&second_shader); - TestLazyShader third_shader; + TestDiscardableShader third_shader; SkPaint third_paint; third_paint.setShader(&third_shader); @@ -694,8 +685,8 @@ TEST(LazyPixelRefUtilsTest, DrawVertices) { StopRecording(picture.get(), canvas); - std::vector<skia::LazyPixelRefUtils::PositionLazyPixelRef> pixel_refs; - skia::LazyPixelRefUtils::GatherPixelRefs(picture.get(), &pixel_refs); + std::vector<skia::PixelRefUtils::PositionPixelRef> pixel_refs; + skia::PixelRefUtils::GatherDiscardablePixelRefs(picture.get(), &pixel_refs); EXPECT_EQ(3u, pixel_refs.size()); EXPECT_FLOAT_RECT_EQ(gfx::RectF(10, 10, 90, 90), diff --git a/skia/skia_chrome.gypi b/skia/skia_chrome.gypi index 6dcc665..aa6e273 100644 --- a/skia/skia_chrome.gypi +++ b/skia/skia_chrome.gypi @@ -41,12 +41,12 @@ 'ext/image_operations.h', 'ext/lazy_pixel_ref.cc', 'ext/lazy_pixel_ref.h', - 'ext/lazy_pixel_ref_utils.cc', - 'ext/lazy_pixel_ref_utils.h', 'ext/opacity_draw_filter.cc', 'ext/opacity_draw_filter.h', 'ext/paint_simplifier.cc', 'ext/paint_simplifier.h', + 'ext/pixel_ref_utils.cc', + 'ext/pixel_ref_utils.h', 'ext/platform_canvas.cc', 'ext/platform_canvas.h', 'ext/platform_device.cc', |