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 <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 Loading... | |
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(); | |
140 if (!picture) | 139 if (!picture) |
vmpstr
2015/04/07 17:43:14
This can be removed
| |
141 continue; | 140 continue; |
142 | 141 |
143 // This is intentionally *enclosed* rect, so that the clip is aligned on | 142 // 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 | 143 // 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 | 144 // 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 | 145 // enough buffer pixels have been added such that the enclosed rect |
147 // encompasses all invalidated pixels at any larger scale level. | 146 // encompasses all invalidated pixels at any larger scale level. |
148 gfx::Rect chunk_rect = PaddedRect(tile_iter.index()); | 147 gfx::Rect chunk_rect = PaddedRect(tile_iter.index()); |
149 gfx::Rect content_clip = | 148 gfx::Rect content_clip = |
150 gfx::ScaleToEnclosedRect(chunk_rect, contents_scale); | 149 gfx::ScaleToEnclosedRect(chunk_rect, contents_scale); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); | 261 skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording()); |
263 | 262 |
264 return picture; | 263 return picture; |
265 } | 264 } |
266 | 265 |
267 size_t PicturePileImpl::GetPictureMemoryUsage() const { | 266 size_t PicturePileImpl::GetPictureMemoryUsage() const { |
268 // Place all pictures in a set to de-dupe. | 267 // Place all pictures in a set to de-dupe. |
269 size_t total_size = 0; | 268 size_t total_size = 0; |
270 std::set<const Picture*> pictures_seen; | 269 std::set<const Picture*> pictures_seen; |
271 for (const auto& map_value : picture_map_) { | 270 for (const auto& map_value : picture_map_) { |
272 const Picture* picture = map_value.second.GetPicture(); | 271 const Picture* picture = map_value.second.get(); |
273 if (picture && pictures_seen.insert(picture).second) | 272 if (picture && pictures_seen.insert(picture).second) |
vmpstr
2015/04/07 17:43:14
"picture &&" can be removed, or DCHECKed
| |
274 total_size += picture->ApproximateMemoryUsage(); | 273 total_size += picture->ApproximateMemoryUsage(); |
275 } | 274 } |
276 | 275 |
277 return total_size; | 276 return total_size; |
278 } | 277 } |
279 | 278 |
280 void PicturePileImpl::PerformSolidColorAnalysis( | 279 void PicturePileImpl::PerformSolidColorAnalysis( |
281 const gfx::Rect& content_rect, | 280 const gfx::Rect& content_rect, |
282 float contents_scale, | 281 float contents_scale, |
283 RasterSource::SolidColorAnalysis* analysis) const { | 282 RasterSource::SolidColorAnalysis* analysis) const { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 } | 349 } |
351 | 350 |
352 bool PicturePileImpl::CanRasterSlowTileCheck( | 351 bool PicturePileImpl::CanRasterSlowTileCheck( |
353 const gfx::Rect& layer_rect) const { | 352 const gfx::Rect& layer_rect) const { |
354 bool include_borders = false; | 353 bool include_borders = false; |
355 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); | 354 for (TilingData::Iterator tile_iter(&tiling_, layer_rect, include_borders); |
356 tile_iter; ++tile_iter) { | 355 tile_iter; ++tile_iter) { |
357 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 356 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
358 if (map_iter == picture_map_.end()) | 357 if (map_iter == picture_map_.end()) |
359 return false; | 358 return false; |
360 if (!map_iter->second.GetPicture()) | 359 if (!map_iter->second.get()) |
vmpstr
2015/04/07 17:43:14
This can also be removed?
| |
361 return false; | 360 return false; |
362 } | 361 } |
363 return true; | 362 return true; |
364 } | 363 } |
365 | 364 |
366 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() { | 365 void PicturePileImpl::SetShouldAttemptToUseDistanceFieldText() { |
367 should_attempt_to_use_distance_field_text_ = true; | 366 should_attempt_to_use_distance_field_text_ = true; |
368 } | 367 } |
369 | 368 |
370 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const { | 369 bool PicturePileImpl::ShouldAttemptToUseDistanceFieldText() const { |
371 return should_attempt_to_use_distance_field_text_; | 370 return should_attempt_to_use_distance_field_text_; |
372 } | 371 } |
373 | 372 |
374 void PicturePileImpl::AsValueInto( | 373 void PicturePileImpl::AsValueInto( |
375 base::trace_event::TracedValue* pictures) const { | 374 base::trace_event::TracedValue* pictures) const { |
376 gfx::Rect tiling_rect(tiling_.tiling_size()); | 375 gfx::Rect tiling_rect(tiling_.tiling_size()); |
377 std::set<const void*> appended_pictures; | 376 std::set<const void*> appended_pictures; |
378 bool include_borders = true; | 377 bool include_borders = true; |
379 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); | 378 for (TilingData::Iterator tile_iter(&tiling_, tiling_rect, include_borders); |
380 tile_iter; ++tile_iter) { | 379 tile_iter; ++tile_iter) { |
381 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); | 380 PictureMap::const_iterator map_iter = picture_map_.find(tile_iter.index()); |
382 if (map_iter == picture_map_.end()) | 381 if (map_iter == picture_map_.end()) |
383 continue; | 382 continue; |
384 | 383 |
385 const Picture* picture = map_iter->second.GetPicture(); | 384 const Picture* picture = map_iter->second.get(); |
386 if (picture && (appended_pictures.count(picture) == 0)) { | 385 if (picture && (appended_pictures.count(picture) == 0)) { |
vmpstr
2015/04/07 17:43:14
Here as well.
| |
387 appended_pictures.insert(picture); | 386 appended_pictures.insert(picture); |
388 TracedValue::AppendIDRef(picture, pictures); | 387 TracedValue::AppendIDRef(picture, pictures); |
389 } | 388 } |
390 } | 389 } |
391 } | 390 } |
392 | 391 |
393 bool PicturePileImpl::CanUseLCDText() const { | 392 bool PicturePileImpl::CanUseLCDText() const { |
394 return can_use_lcd_text_; | 393 return can_use_lcd_text_; |
395 } | 394 } |
396 | 395 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 return *this; | 431 return *this; |
433 } | 432 } |
434 | 433 |
435 void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() { | 434 void PicturePileImpl::PixelRefIterator::AdvanceToTilePictureWithPixelRefs() { |
436 for (; tile_iterator_; ++tile_iterator_) { | 435 for (; tile_iterator_; ++tile_iterator_) { |
437 PictureMap::const_iterator it = | 436 PictureMap::const_iterator it = |
438 picture_pile_->picture_map_.find(tile_iterator_.index()); | 437 picture_pile_->picture_map_.find(tile_iterator_.index()); |
439 if (it == picture_pile_->picture_map_.end()) | 438 if (it == picture_pile_->picture_map_.end()) |
440 continue; | 439 continue; |
441 | 440 |
442 const Picture* picture = it->second.GetPicture(); | 441 const Picture* picture = it->second.get(); |
443 if (!picture || (processed_pictures_.count(picture) != 0) || | 442 if (!picture || (processed_pictures_.count(picture) != 0) || |
vmpstr
2015/04/07 17:43:14
Here as well.
| |
444 !picture->WillPlayBackBitmaps()) | 443 !picture->WillPlayBackBitmaps()) |
445 continue; | 444 continue; |
446 | 445 |
447 processed_pictures_.insert(picture); | 446 processed_pictures_.insert(picture); |
448 pixel_ref_iterator_ = picture->GetPixelRefMapIterator(layer_rect_); | 447 pixel_ref_iterator_ = picture->GetPixelRefMapIterator(layer_rect_); |
449 if (pixel_ref_iterator_) | 448 if (pixel_ref_iterator_) |
450 break; | 449 break; |
451 } | 450 } |
452 } | 451 } |
453 | 452 |
454 void PicturePileImpl::DidBeginTracing() { | 453 void PicturePileImpl::DidBeginTracing() { |
455 std::set<const void*> processed_pictures; | 454 std::set<const void*> processed_pictures; |
456 for (const auto& map_pair : picture_map_) { | 455 for (const auto& map_pair : picture_map_) { |
457 const Picture* picture = map_pair.second.GetPicture(); | 456 const Picture* picture = map_pair.second.get(); |
458 if (picture && (processed_pictures.count(picture) == 0)) { | 457 if (picture && (processed_pictures.count(picture) == 0)) { |
vmpstr
2015/04/07 17:43:14
Here as well.
| |
459 picture->EmitTraceSnapshot(); | 458 picture->EmitTraceSnapshot(); |
460 processed_pictures.insert(picture); | 459 processed_pictures.insert(picture); |
461 } | 460 } |
462 } | 461 } |
463 } | 462 } |
464 | 463 |
465 } // namespace cc | 464 } // namespace cc |
OLD | NEW |