OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 #include "cc/base/region.h" | 6 #include "cc/base/region.h" |
7 #include "cc/debug/debug_colors.h" | 7 #include "cc/debug/debug_colors.h" |
8 #include "cc/debug/rendering_stats.h" | 8 #include "cc/debug/rendering_stats.h" |
9 #include "cc/resources/picture_pile_impl.h" | 9 #include "cc/resources/picture_pile_impl.h" |
10 #include "skia/ext/analysis_canvas.h" | 10 #include "skia/ext/analysis_canvas.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 #endif // NDEBUG | 191 #endif // NDEBUG |
192 | 192 |
193 // We should always paint some part of |content_rect|. | 193 // We should always paint some part of |content_rect|. |
194 DCHECK(!unclipped.Contains(content_rect)); | 194 DCHECK(!unclipped.Contains(content_rect)); |
195 | 195 |
196 canvas->restore(); | 196 canvas->restore(); |
197 | 197 |
198 return total_pixels_rasterized; | 198 return total_pixels_rasterized; |
199 } | 199 } |
200 | 200 |
201 void PicturePileImpl::GatherPixelRefs( | |
202 gfx::Rect content_rect, | |
203 float contents_scale, | |
204 std::list<skia::LazyPixelRef*>& pixel_refs) { | |
205 std::list<skia::LazyPixelRef*> result; | |
206 | |
207 gfx::Rect layer_rect = gfx::ToEnclosingRect( | |
208 gfx::ScaleRect(content_rect, 1.f / contents_scale)); | |
209 | |
210 for (TilingData::Iterator tile_iter(&tiling_, layer_rect); | |
211 tile_iter; ++tile_iter) { | |
212 PictureListMap::iterator map_iter = | |
213 picture_list_map_.find(tile_iter.index()); | |
214 if (map_iter == picture_list_map_.end()) | |
215 continue; | |
216 | |
217 PictureList& pic_list = map_iter->second; | |
218 for (PictureList::const_iterator i = pic_list.begin(); | |
219 i != pic_list.end(); ++i) { | |
220 (*i)->GatherPixelRefs(layer_rect, result); | |
221 pixel_refs.splice(pixel_refs.end(), result); | |
222 } | |
223 } | |
224 } | |
225 | |
226 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { | 201 skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
227 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); | 202 TRACE_EVENT0("cc", "PicturePileImpl::GetFlattenedPicture"); |
228 | 203 |
229 gfx::Rect layer_rect(tiling_.total_size()); | 204 gfx::Rect layer_rect(tiling_.total_size()); |
230 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); | 205 skia::RefPtr<SkPicture> picture = skia::AdoptRef(new SkPicture); |
231 if (layer_rect.IsEmpty()) | 206 if (layer_rect.IsEmpty()) |
232 return picture; | 207 return picture; |
233 | 208 |
234 SkCanvas* canvas = picture->beginRecording( | 209 SkCanvas* canvas = picture->beginRecording( |
235 layer_rect.width(), | 210 layer_rect.width(), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 PicturePileImpl::Analysis::Analysis() | 245 PicturePileImpl::Analysis::Analysis() |
271 : is_solid_color(false), | 246 : is_solid_color(false), |
272 is_transparent(false), | 247 is_transparent(false), |
273 has_text(false), | 248 has_text(false), |
274 is_cheap_to_raster(false) { | 249 is_cheap_to_raster(false) { |
275 } | 250 } |
276 | 251 |
277 PicturePileImpl::Analysis::~Analysis() { | 252 PicturePileImpl::Analysis::~Analysis() { |
278 } | 253 } |
279 | 254 |
255 PicturePileImpl::PixelRefIterator::PixelRefIterator( | |
256 gfx::Rect content_rect, | |
257 float contents_scale, | |
258 const PicturePileImpl* picture_pile) | |
259 : picture_pile_(picture_pile), | |
260 layer_rect_(gfx::ToEnclosingRect( | |
261 gfx::ScaleRect(content_rect, 1.f / contents_scale))), | |
262 tile_iterator_(&picture_pile_->tiling_, layer_rect_), | |
263 picture_list_(NULL), | |
264 current_pixel_ref_(NULL) { | |
265 ++(*this); | |
266 } | |
267 | |
268 PicturePileImpl::PixelRefIterator::~PixelRefIterator() { | |
269 } | |
270 | |
271 PicturePileImpl::PixelRefIterator& | |
272 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
| |
273 while (true) { | |
274 // If there are still pixel refs on the current picture, | |
275 // advance the picture refs iterator. | |
276 if (picture_refs_iterator_) { | |
277 current_pixel_ref_ = *picture_refs_iterator_; | |
278 ++picture_refs_iterator_; | |
279 break; | |
280 } | |
281 | |
282 // If there are pictures left in the current tile's list, process them. | |
283 if (picture_list_ && | |
284 picture_list_iterator_ != picture_list_->end()) { | |
285 scoped_refptr<Picture> picture = *picture_list_iterator_; | |
286 ++picture_list_iterator_; | |
287 picture_refs_iterator_ = Picture::PixelRefIterator( | |
288 layer_rect_, | |
289 picture.get()); | |
290 continue; | |
291 } | |
292 | |
293 // If we're out of tiles, we're done. | |
294 if (!tile_iterator_) { | |
295 current_pixel_ref_ = NULL; | |
296 break; | |
297 } | |
298 | |
299 // Grab a new picture list from the current tile, | |
300 // and advance the tile iterator. | |
301 PictureListMap::const_iterator map_iterator = | |
302 picture_pile_->picture_list_map_.find(tile_iterator_.index()); | |
303 ++tile_iterator_; | |
304 if (map_iterator == picture_pile_->picture_list_map_.end()) | |
305 continue; | |
306 | |
307 picture_list_ = &map_iterator->second; | |
308 picture_list_iterator_ = picture_list_->begin(); | |
309 } | |
310 return *this; | |
311 } | |
312 | |
280 } // namespace cc | 313 } // namespace cc |
OLD | NEW |