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

Unified Diff: cc/resources/picture_pile_impl.cc

Issue 14230007: cc: Do GatherPixelRefs from skia at record time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unittests + enne's review Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/picture_pile_impl.cc
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc
index dd30ede82a80d8a7fe20e416d671725fde8a66c4..b22c360c957d67a2485395412e21031996a8c399 100644
--- a/cc/resources/picture_pile_impl.cc
+++ b/cc/resources/picture_pile_impl.cc
@@ -198,31 +198,6 @@ int64 PicturePileImpl::Raster(
return total_pixels_rasterized;
}
-void PicturePileImpl::GatherPixelRefs(
- gfx::Rect content_rect,
- float contents_scale,
- std::list<skia::LazyPixelRef*>& pixel_refs) {
- std::list<skia::LazyPixelRef*> result;
-
- gfx::Rect layer_rect = gfx::ToEnclosingRect(
- gfx::ScaleRect(content_rect, 1.f / contents_scale));
-
- for (TilingData::Iterator tile_iter(&tiling_, layer_rect);
- tile_iter; ++tile_iter) {
- PictureListMap::iterator map_iter =
- picture_list_map_.find(tile_iter.index());
- if (map_iter == picture_list_map_.end())
- continue;
-
- PictureList& pic_list = map_iter->second;
- for (PictureList::const_iterator i = pic_list.begin();
- i != pic_list.end(); ++i) {
- (*i)->GatherPixelRefs(layer_rect, result);
- pixel_refs.splice(pixel_refs.end(), result);
- }
- }
-}
-
skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() {
TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture");
@@ -277,4 +252,59 @@ PicturePileImpl::Analysis::Analysis()
PicturePileImpl::Analysis::~Analysis() {
}
+PicturePileImpl::LazyPixelRefIterator::LazyPixelRefIterator(
+ gfx::Rect content_rect,
+ float contents_scale,
+ const PicturePileImpl* picture_pile)
+ : picture_pile_(picture_pile),
+ layer_rect_(gfx::ToEnclosingRect(
+ gfx::ScaleRect(content_rect, 1.f / contents_scale))),
+ tile_iterator_(&picture_pile_->tiling_, layer_rect_),
+ current_pixel_ref_(NULL) {
+ ++(*this);
+}
+
+PicturePileImpl::LazyPixelRefIterator::~LazyPixelRefIterator() {
+}
+
+PicturePileImpl::LazyPixelRefIterator&
+ PicturePileImpl::LazyPixelRefIterator::operator++() {
+ while (true) {
+ // If there are still pixel refs on the current picture,
+ // advance the picture refs iterator.
+ if (picture_refs_iterator_) {
+ current_pixel_ref_ = *picture_refs_iterator_;
+ ++picture_refs_iterator_;
+ break;
+ }
+
+ // If there are pictures left in the current tile's list, process them.
+ if (!picture_list_.empty()) {
+ scoped_refptr<Picture> picture = picture_list_.front();
+ picture_list_.pop_front();
+ picture_refs_iterator_ = Picture::LazyPixelRefIterator(
+ layer_rect_,
+ picture.get());
+ continue;
+ }
+
+ // If we're out of tiles, we're done.
+ if (!tile_iterator_) {
+ current_pixel_ref_ = NULL;
+ break;
+ }
+
+ // Grab a new picture list from the current tile,
+ // and advance the tile iterator.
+ PictureListMap::const_iterator map_iterator =
+ picture_pile_->picture_list_map_.find(tile_iterator_.index());
+ ++tile_iterator_;
+ if (map_iterator == picture_pile_->picture_list_map_.end())
+ continue;
+
+ picture_list_ = map_iterator->second;
reveman 2013/04/22 19:56:06 Lets try to avoid copying a list here as well.
vmpstr 2013/04/22 22:38:16 Done.
+ }
+ return *this;
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698