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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 PicturePileImpl::Analysis::Analysis() | 244 PicturePileImpl::Analysis::Analysis() |
270 : is_solid_color(false), | 245 : is_solid_color(false), |
271 is_transparent(false), | 246 is_transparent(false), |
272 has_text(false), | 247 has_text(false), |
273 is_cheap_to_raster(false) { | 248 is_cheap_to_raster(false) { |
274 } | 249 } |
275 | 250 |
276 PicturePileImpl::Analysis::~Analysis() { | 251 PicturePileImpl::Analysis::~Analysis() { |
277 } | 252 } |
278 | 253 |
| 254 PicturePileImpl::LazyPixelRefsIterator::LazyPixelRefsIterator( |
| 255 gfx::Rect content_rect, |
| 256 float contents_scale, |
| 257 const PicturePileImpl* picture_pile) |
| 258 : picture_pile_(picture_pile), |
| 259 layer_rect_(gfx::ToEnclosingRect( |
| 260 gfx::ScaleRect(content_rect, 1.f / contents_scale))), |
| 261 tile_iterator_(&picture_pile_->tiling_, layer_rect_), |
| 262 current_pixel_ref_(NULL) { |
| 263 ++(*this); |
| 264 } |
| 265 |
| 266 PicturePileImpl::LazyPixelRefsIterator::~LazyPixelRefsIterator() { |
| 267 } |
| 268 |
| 269 PicturePileImpl::LazyPixelRefsIterator& |
| 270 PicturePileImpl::LazyPixelRefsIterator::operator++() { |
| 271 while (true) { |
| 272 // If there are still pixel refs on the current picture, |
| 273 // advance the picture refs iterator. |
| 274 if (picture_refs_iterator_) { |
| 275 current_pixel_ref_ = *picture_refs_iterator_; |
| 276 ++picture_refs_iterator_; |
| 277 break; |
| 278 } |
| 279 |
| 280 // If there are pictures left in the current tile's list, process them. |
| 281 if (!picture_list_.empty()) { |
| 282 scoped_refptr<Picture> picture = picture_list_.front(); |
| 283 picture_list_.pop_front(); |
| 284 picture_refs_iterator_ = Picture::LazyPixelRefsIterator( |
| 285 layer_rect_, |
| 286 picture.get()); |
| 287 continue; |
| 288 } |
| 289 |
| 290 // If we're out of tiles, we're done. |
| 291 if (!tile_iterator_) { |
| 292 current_pixel_ref_ = NULL; |
| 293 break; |
| 294 } |
| 295 |
| 296 // Grab a new picture list from the current tile, |
| 297 // and advance the tile iterator. |
| 298 PictureListMap::const_iterator map_iterator = |
| 299 picture_pile_->picture_list_map_.find(tile_iterator_.index()); |
| 300 ++tile_iterator_; |
| 301 if (map_iterator == picture_pile_->picture_list_map_.end()) |
| 302 continue; |
| 303 |
| 304 picture_list_ = map_iterator->second; |
| 305 } |
| 306 return *this; |
| 307 } |
| 308 |
279 } // namespace cc | 309 } // namespace cc |
OLD | NEW |