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

Side by Side Diff: cc/resources/picture_pile_impl.cc

Issue 1061203002: cc: Remove invalidation history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address vmpstr comments Created 5 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
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <limits> 6 #include <limits>
7 #include <set> 7 #include <set>
8 8
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "cc/base/region.h" 10 #include "cc/base/region.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // that and subtract chunk rects to get the region that we need to subtract 128 // that and subtract chunk rects to get the region that we need to subtract
129 // from the canvas. Then, we can use clipRect with difference op to subtract 129 // from the canvas. Then, we can use clipRect with difference op to subtract
130 // each rect in the region. 130 // each rect in the region.
131 bool include_borders = true; 131 bool include_borders = true;
132 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); 132 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders);
133 tile_iter; 133 tile_iter;
134 ++tile_iter) { 134 ++tile_iter) {
135 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); 135 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
136 if (map_iter == picture_map_.end()) 136 if (map_iter == picture_map_.end())
137 continue; 137 continue;
138 const PictureInfo& info = map_iter->second; 138 const Picture* picture = map_iter->second.get();
139 const Picture* picture = info.GetPicture(); 139 DCHECK(picture);
140 if (!picture)
141 continue;
142 140
143 // This is intentionally *enclosed* rect, so that the clip is aligned on 141 // This is intentionally *enclosed* rect, so that the clip is aligned on
144 // integral post-scale content pixels and does not extend past the edges 142 // integral post-scale content pixels and does not extend past the edges
145 // of the picture chunk's layer rect. The min_contents_scale enforces that 143 // of the picture chunk's layer rect. The min_contents_scale enforces that
146 // enough buffer pixels have been added such that the enclosed rect 144 // enough buffer pixels have been added such that the enclosed rect
147 // encompasses all invalidated pixels at any larger scale level. 145 // encompasses all invalidated pixels at any larger scale level.
148 gfx::Rect chunk_rect = PaddedRect(tile_iter.index()); 146 gfx::Rect chunk_rect = PaddedRect(tile_iter.index());
149 gfx::Rect content_clip = 147 gfx::Rect content_clip =
150 gfx::ScaleToEnclosedRect(chunk_rect, contents_scale); 148 gfx::ScaleToEnclosedRect(chunk_rect, contents_scale);
151 DCHECK(!content_clip.IsEmpty()) << "Layer rect: " 149 DCHECK(!content_clip.IsEmpty()) << "Layer rect: "
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); 260 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
263 261
264 return picture; 262 return picture;
265 } 263 }
266 264
267 size_t PicturePileImpl::GetPictureMemoryUsage() const { 265 size_t PicturePileImpl::GetPictureMemoryUsage() const {
268 // Place all pictures in a set to de-dupe. 266 // Place all pictures in a set to de-dupe.
269 size_t total_size = 0; 267 size_t total_size = 0;
270 std::set<const Picture*> pictures_seen; 268 std::set<const Picture*> pictures_seen;
271 for (const auto& map_value : picture_map_) { 269 for (const auto& map_value : picture_map_) {
272 const Picture* picture = map_value.second.GetPicture(); 270 const Picture* picture = map_value.second.get();
273 if (picture && pictures_seen.insert(picture).second) 271 if (pictures_seen.insert(picture).second)
274 total_size += picture->ApproximateMemoryUsage(); 272 total_size += picture->ApproximateMemoryUsage();
275 } 273 }
276 274
277 return total_size; 275 return total_size;
278 } 276 }
279 277
280 void PicturePileImpl::PerformSolidColorAnalysis( 278 void PicturePileImpl::PerformSolidColorAnalysis(
281 const gfx::Rect& content_rect, 279 const gfx::Rect& content_rect,
282 float contents_scale, 280 float contents_scale,
283 RasterSource::SolidColorAnalysis* analysis) const { 281 RasterSource::SolidColorAnalysis* analysis) const {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 348 }
351 349
352 bool PicturePileImpl::CanRasterSlowTileCheck( 350 bool PicturePileImpl::CanRasterSlowTileCheck(
353 const gfx::Rect& layer_rect) const { 351 const gfx::Rect& layer_rect) const {
354 bool include_borders = false; 352 bool include_borders = false;
355 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); 353 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders);
356 tile_iter; ++tile_iter) { 354 tile_iter; ++tile_iter) {
357 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); 355 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
358 if (map_iter == picture_map_.end()) 356 if (map_iter == picture_map_.end())
359 return false; 357 return false;
360 if (!map_iter->second.GetPicture())
361 return false;
362 } 358 }
363 return true; 359 return true;
364 } 360 }
365 361
366 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() { 362 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() {
367 should_attempt_to_use_distance_field_text_ = true; 363 should_attempt_to_use_distance_field_text_ = true;
368 } 364 }
369 365
370 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const { 366 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const {
371 return should_attempt_to_use_distance_field_text_; 367 return should_attempt_to_use_distance_field_text_;
372 } 368 }
373 369
374 void PicturePileImpl::AsValueInto( 370 void PicturePileImpl::AsValueInto(
375 base::trace_event::TracedValue* pictures) const { 371 base::trace_event::TracedValue* pictures) const {
376 gfx::Rect tiling_rect(tiling_.tiling_size()); 372 gfx::Rect tiling_rect(tiling_.tiling_size());
377 std::set<const void*> appended_pictures; 373 std::set<const void*> appended_pictures;
378 bool include_borders = true; 374 bool include_borders = true;
379 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); 375 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders);
380 tile_iter; ++tile_iter) { 376 tile_iter; ++tile_iter) {
381 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); 377 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index());
382 if (map_iter == picture_map_.end()) 378 if (map_iter == picture_map_.end())
383 continue; 379 continue;
384 380
385 const Picture* picture = map_iter->second.GetPicture(); 381 const Picture* picture = map_iter->second.get();
386 if (picture && (appended_pictures.count(picture) == 0)) { 382 if (appended_pictures.count(picture) == 0) {
387 appended_pictures.insert(picture); 383 appended_pictures.insert(picture);
388 TracedValue::AppendIDRef(picture, pictures); 384 TracedValue::AppendIDRef(picture, pictures);
389 } 385 }
390 } 386 }
391 } 387 }
392 388
393 bool PicturePileImpl::CanUseLCDText() const { 389 bool PicturePileImpl::CanUseLCDText() const {
394 return can_use_lcd_text_; 390 return can_use_lcd_text_;
395 } 391 }
396 392
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 return *this; 428 return *this;
433 } 429 }
434 430
435 void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() { 431 void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() {
436 for (; tile_iterator_; ++tile_iterator_) { 432 for (; tile_iterator_; ++tile_iterator_) {
437 PictureMap::const_iterator it = 433 PictureMap::const_iterator it =
438 picture_pile_->picture_map_.find(tile_iterator_.index()); 434 picture_pile_->picture_map_.find(tile_iterator_.index());
439 if (it == picture_pile_->picture_map_.end()) 435 if (it == picture_pile_->picture_map_.end())
440 continue; 436 continue;
441 437
442 const Picture* picture = it->second.GetPicture(); 438 const Picture* picture = it->second.get();
443 if (!picture || (processed_pictures_.count(picture) != 0) || 439 if ((processed_pictures_.count(picture) != 0) ||
444 !picture->WillPlayBackBitmaps()) 440 !picture->WillPlayBackBitmaps())
445 continue; 441 continue;
446 442
447 processed_pictures_.insert(picture); 443 processed_pictures_.insert(picture);
448 pixel_ref_iterator_ = picture->GetPixelRefMapIterator(layer_rect_); 444 pixel_ref_iterator_ = picture->GetPixelRefMapIterator(layer_rect_);
449 if (pixel_ref_iterator_) 445 if (pixel_ref_iterator_)
450 break; 446 break;
451 } 447 }
452 } 448 }
453 449
454 void PicturePileImpl::DidBeginTracing() { 450 void PicturePileImpl::DidBeginTracing() {
455 std::set<const void*> processed_pictures; 451 std::set<const void*> processed_pictures;
456 for (const auto& map_pair : picture_map_) { 452 for (const auto& map_pair : picture_map_) {
457 const Picture* picture = map_pair.second.GetPicture(); 453 const Picture* picture = map_pair.second.get();
458 if (picture && (processed_pictures.count(picture) == 0)) { 454 if (processed_pictures.count(picture) == 0) {
459 picture->EmitTraceSnapshot(); 455 picture->EmitTraceSnapshot();
460 processed_pictures.insert(picture); 456 processed_pictures.insert(picture);
461 } 457 }
462 } 458 }
463 } 459 }
464 460
465 } // namespace cc 461 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_pile_impl.h ('k') | cc/resources/picture_pile_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698