diff options
Diffstat (limited to 'cc/resources')
-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 |
9 files changed, 157 insertions, 154 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(); |