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

Side by Side 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: review 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 unified diff | Download patch
OLDNEW
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
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
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 // Early out if there isn't a single tile.
265 if (!tile_iterator_)
266 return;
267
268 if (AdvanceToTileWithPictures())
269 AdvanceToPictureWithPixelRefs();
270 }
271
272 PicturePileImpl::PixelRefIterator::~PixelRefIterator() {
273 }
274
275 PicturePileImpl::PixelRefIterator&
276 PicturePileImpl::PixelRefIterator::operator++() {
277 ++pixel_ref_iterator_;
278 if (pixel_ref_iterator_)
279 return *this;
280
281 ++picture_list_iterator_;
282 AdvanceToPictureWithPixelRefs();
283 return *this;
284 }
285
286 bool PicturePileImpl::PixelRefIterator::AdvanceToTileWithPictures() {
287 for (; tile_iterator_; ++tile_iterator_) {
288 PictureListMap::const_iterator map_iterator =
289 picture_pile_->picture_list_map_.find(tile_iterator_.index());
290 if (map_iterator != picture_pile_->picture_list_map_.end()) {
291 picture_list_ = &map_iterator->second;
292 picture_list_iterator_ = picture_list_->begin();
293 return true;
294 }
295 }
296
297 return false;
298 }
299
300 void PicturePileImpl::PixelRefIterator::AdvanceToPictureWithPixelRefs() {
301 DCHECK(tile_iterator_);
302 do {
303 for (;
304 picture_list_iterator_ != picture_list_->end();
305 ++picture_list_iterator_) {
306 pixel_ref_iterator_ = Picture::PixelRefIterator(
307 layer_rect_,
308 *picture_list_iterator_);
309 if (pixel_ref_iterator_)
310 return;
311 }
312 ++tile_iterator_;
313 } while (AdvanceToTileWithPictures());
314 }
315
280 } // namespace cc 316 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698