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"); | |
630 DCHECK(!other->needs_post_commit_initialization_); | 629 DCHECK(!other->needs_post_commit_initialization_); |
631 DCHECK(other->tilings_); | 630 DCHECK(other->tilings_); |
632 | 631 |
633 if (!DrawsContent()) { | 632 if (!DrawsContent()) { |
634 RemoveAllTilings(); | 633 RemoveAllTilings(); |
635 return; | 634 return; |
636 } | 635 } |
637 | 636 |
638 raster_page_scale_ = other->raster_page_scale_; | 637 raster_page_scale_ = other->raster_page_scale_; |
639 raster_device_scale_ = other->raster_device_scale_; | 638 raster_device_scale_ = other->raster_device_scale_; |
640 raster_source_scale_ = other->raster_source_scale_; | 639 raster_source_scale_ = other->raster_source_scale_; |
641 raster_contents_scale_ = other->raster_contents_scale_; | 640 raster_contents_scale_ = other->raster_contents_scale_; |
642 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 641 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
643 | 642 |
| 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 |
644 // Union in the other newly exposed regions as invalid. | 660 // Union in the other newly exposed regions as invalid. |
645 Region difference_region = Region(gfx::Rect(bounds())); | 661 Region difference_region = Region(gfx::Rect(bounds())); |
646 difference_region.Subtract(gfx::Rect(other->bounds())); | 662 difference_region.Subtract(gfx::Rect(other->bounds())); |
647 invalidation_.Union(difference_region); | 663 invalidation_.Union(difference_region); |
648 | 664 |
649 bool synced_high_res_tiling = false; | 665 bool synced_high_res_tiling = false; |
650 if (CanHaveTilings()) { | 666 if (CanHaveTilings()) { |
651 synced_high_res_tiling = tilings_->SyncTilings( | 667 synced_high_res_tiling = tilings_->SyncTilings( |
652 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); | 668 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); |
653 } else { | 669 } else { |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 return iterator_index_ < iterators_.size(); | 1637 return iterator_index_ < iterators_.size(); |
1622 } | 1638 } |
1623 | 1639 |
1624 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1640 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1625 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1641 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1626 return it->get_type() == iteration_stage_ && | 1642 return it->get_type() == iteration_stage_ && |
1627 (**it)->required_for_activation() == required_for_activation_; | 1643 (**it)->required_for_activation() == required_for_activation_; |
1628 } | 1644 } |
1629 | 1645 |
1630 } // namespace cc | 1646 } // namespace cc |
OLD | NEW |