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 "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 int round_up_to = avoid_pow2 ? 56 : 64; | 619 int round_up_to = avoid_pow2 ? 56 : 64; |
620 width = RoundUp(width, round_up_to); | 620 width = RoundUp(width, round_up_to); |
621 height = RoundUp(height, round_up_to); | 621 height = RoundUp(height, round_up_to); |
622 return gfx::Size(width, height); | 622 return gfx::Size(width, height); |
623 } | 623 } |
624 | 624 |
625 return default_tile_size; | 625 return default_tile_size; |
626 } | 626 } |
627 | 627 |
628 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | 628 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { |
| 629 TRACE_EVENT0("cc", "SyncFromActiveLayer"); |
629 DCHECK(!other->needs_post_commit_initialization_); | 630 DCHECK(!other->needs_post_commit_initialization_); |
630 DCHECK(other->tilings_); | 631 DCHECK(other->tilings_); |
631 | 632 |
632 if (!DrawsContent()) { | 633 if (!DrawsContent()) { |
633 RemoveAllTilings(); | 634 RemoveAllTilings(); |
634 return; | 635 return; |
635 } | 636 } |
636 | 637 |
637 raster_page_scale_ = other->raster_page_scale_; | 638 raster_page_scale_ = other->raster_page_scale_; |
638 raster_device_scale_ = other->raster_device_scale_; | 639 raster_device_scale_ = other->raster_device_scale_; |
639 raster_source_scale_ = other->raster_source_scale_; | 640 raster_source_scale_ = other->raster_source_scale_; |
640 raster_contents_scale_ = other->raster_contents_scale_; | 641 raster_contents_scale_ = other->raster_contents_scale_; |
641 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 642 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
642 | 643 |
643 // Add synthetic invalidations for any recordings that were dropped. As | |
644 // tiles are updated to point to this new pile, this will force the dropping | |
645 // of tiles that can no longer be rastered. This is not ideal, but is a | |
646 // trade-off for memory (use the same pile as much as possible, by switching | |
647 // during DidBecomeActive) and for time (don't bother checking every tile | |
648 // during activation to see if the new pile can still raster it). | |
649 for (int x = 0; x < pile_->num_tiles_x(); ++x) { | |
650 for (int y = 0; y < pile_->num_tiles_y(); ++y) { | |
651 bool previously_had = other->pile_->HasRecordingAt(x, y); | |
652 bool now_has = pile_->HasRecordingAt(x, y); | |
653 if (now_has || !previously_had) | |
654 continue; | |
655 gfx::Rect layer_rect = pile_->tile_bounds(x, y); | |
656 invalidation_.Union(layer_rect); | |
657 } | |
658 } | |
659 | |
660 // Union in the other newly exposed regions as invalid. | 644 // Union in the other newly exposed regions as invalid. |
661 Region difference_region = Region(gfx::Rect(bounds())); | 645 Region difference_region = Region(gfx::Rect(bounds())); |
662 difference_region.Subtract(gfx::Rect(other->bounds())); | 646 difference_region.Subtract(gfx::Rect(other->bounds())); |
663 invalidation_.Union(difference_region); | 647 invalidation_.Union(difference_region); |
664 | 648 |
665 bool synced_high_res_tiling = false; | 649 bool synced_high_res_tiling = false; |
666 if (CanHaveTilings()) { | 650 if (CanHaveTilings()) { |
667 synced_high_res_tiling = tilings_->SyncTilings( | 651 synced_high_res_tiling = tilings_->SyncTilings( |
668 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); | 652 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); |
669 } else { | 653 } else { |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 return iterator_index_ < iterators_.size(); | 1621 return iterator_index_ < iterators_.size(); |
1638 } | 1622 } |
1639 | 1623 |
1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1624 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1625 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1642 return it->get_type() == iteration_stage_ && | 1626 return it->get_type() == iteration_stage_ && |
1643 (**it)->required_for_activation() == required_for_activation_; | 1627 (**it)->required_for_activation() == required_for_activation_; |
1644 } | 1628 } |
1645 | 1629 |
1646 } // namespace cc | 1630 } // namespace cc |
OLD | NEW |