Chromium Code Reviews| 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..a7c1214d1eb29c93c05815b247ea808894d19e62 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::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_), |
| + picture_list_(NULL), |
| + current_pixel_ref_(NULL) { |
| + ++(*this); |
| +} |
| + |
| +PicturePileImpl::LazyPixelRefIterator::~LazyPixelRefIterator() { |
| +} |
| + |
| +PicturePileImpl::LazyPixelRefIterator& |
| + PicturePileImpl::LazyPixelRefIterator::operator++() { |
|
reveman
2013/04/23 14:33:24
please consider using a sentinel node and get rid
vmpstr
2013/04/23 20:02:23
This one I left as is. It's a bit harder in this c
|
| + 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::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; |
| + picture_list_iterator_ = picture_list_->begin(); |
| + } |
| + return *this; |
| +} |
| + |
| } // namespace cc |