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

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: more reviews 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..b3d711f5e74789ef74121067b42c500724c00948 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,62 @@ PicturePileImpl::Analysis::Analysis()
PicturePileImpl::Analysis::~Analysis() {
}
+PicturePileImpl::PixelRefIterator::PixelRefIterator(
+ 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_),
+ picture_list_(NULL),
+ current_pixel_ref_(NULL) {
+ ++(*this);
+}
+
+PicturePileImpl::PixelRefIterator::~PixelRefIterator() {
+}
+
+PicturePileImpl::PixelRefIterator&
+ PicturePileImpl::PixelRefIterator::operator++() {
reveman 2013/04/24 14:10:52 I feel like this could be cleaner. It's hard to fo
vmpstr 2013/04/24 21:11:10 I played around with it, and settled to something
+ 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_ &&
+ picture_list_iterator_ != picture_list_->end()) {
+ scoped_refptr<Picture> picture = *picture_list_iterator_;
+ ++picture_list_iterator_;
+ picture_refs_iterator_ = Picture::PixelRefIterator(
+ 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;
+ picture_list_iterator_ = picture_list_->begin();
+ }
+ return *this;
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698