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::LazyPixelRefIterator::LazyPixelRefIterator( | |
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 current_pixel_ref_(NULL) { | |
264 ++(*this); | |
265 } | |
266 | |
267 PicturePileImpl::LazyPixelRefIterator::~LazyPixelRefIterator() { | |
268 } | |
269 | |
270 PicturePileImpl::LazyPixelRefIterator& | |
271 PicturePileImpl::LazyPixelRefIterator::operator++() { | |
272 while (true) { | |
273 // If there are still pixel refs on the current picture, | |
274 // advance the picture refs iterator. | |
275 if (picture_refs_iterator_) { | |
276 current_pixel_ref_ = *picture_refs_iterator_; | |
277 ++picture_refs_iterator_; | |
278 break; | |
279 } | |
280 | |
281 // If there are pictures left in the current tile's list, process them. | |
282 if (!picture_list_.empty()) { | |
283 scoped_refptr<Picture> picture = picture_list_.front(); | |
284 picture_list_.pop_front(); | |
285 picture_refs_iterator_ = Picture::LazyPixelRefIterator( | |
286 layer_rect_, | |
287 picture.get()); | |
288 continue; | |
289 } | |
290 | |
291 // If we're out of tiles, we're done. | |
292 if (!tile_iterator_) { | |
293 current_pixel_ref_ = NULL; | |
294 break; | |
295 } | |
296 | |
297 // Grab a new picture list from the current tile, | |
298 // and advance the tile iterator. | |
299 PictureListMap::const_iterator map_iterator = | |
300 picture_pile_->picture_list_map_.find(tile_iterator_.index()); | |
301 ++tile_iterator_; | |
302 if (map_iterator == picture_pile_->picture_list_map_.end()) | |
303 continue; | |
304 | |
305 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.
| |
306 } | |
307 return *this; | |
308 } | |
309 | |
280 } // namespace cc | 310 } // namespace cc |
OLD | NEW |