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 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const int kMinHeightForGpuRasteredTile = 128; | 50 const int kMinHeightForGpuRasteredTile = 128; |
51 | 51 |
52 // When making odd-sized tiles, round them up to increase the chances | 52 // When making odd-sized tiles, round them up to increase the chances |
53 // of using the same tile size. | 53 // of using the same tile size. |
54 const int kTileRoundUp = 64; | 54 const int kTileRoundUp = 64; |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 namespace cc { | 58 namespace cc { |
59 | 59 |
60 PictureLayerImpl::Pair::Pair() : active(NULL), pending(NULL) { | 60 PictureLayerImpl::Pair::Pair() : active(nullptr), pending(nullptr) { |
61 } | 61 } |
62 | 62 |
63 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, | 63 PictureLayerImpl::Pair::Pair(PictureLayerImpl* active_layer, |
64 PictureLayerImpl* pending_layer) | 64 PictureLayerImpl* pending_layer) |
65 : active(active_layer), pending(pending_layer) { | 65 : active(active_layer), pending(pending_layer) { |
66 } | 66 } |
67 | 67 |
68 PictureLayerImpl::Pair::~Pair() { | 68 PictureLayerImpl::Pair::~Pair() { |
69 } | 69 } |
70 | 70 |
71 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) | 71 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
72 : LayerImpl(tree_impl, id), | 72 : LayerImpl(tree_impl, id), |
73 twin_layer_(NULL), | 73 twin_layer_(nullptr), |
74 pile_(PicturePileImpl::Create()), | 74 pile_(PicturePileImpl::Create()), |
75 ideal_page_scale_(0.f), | 75 ideal_page_scale_(0.f), |
76 ideal_device_scale_(0.f), | 76 ideal_device_scale_(0.f), |
77 ideal_source_scale_(0.f), | 77 ideal_source_scale_(0.f), |
78 ideal_contents_scale_(0.f), | 78 ideal_contents_scale_(0.f), |
79 raster_page_scale_(0.f), | 79 raster_page_scale_(0.f), |
80 raster_device_scale_(0.f), | 80 raster_device_scale_(0.f), |
81 raster_source_scale_(0.f), | 81 raster_source_scale_(0.f), |
82 raster_contents_scale_(0.f), | 82 raster_contents_scale_(0.f), |
83 low_res_raster_contents_scale_(0.f), | 83 low_res_raster_contents_scale_(0.f), |
(...skipping 21 matching lines...) Expand all Loading... |
105 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { | 105 void PictureLayerImpl::PushPropertiesTo(LayerImpl* base_layer) { |
106 // It's possible this layer was never drawn or updated (e.g. because it was | 106 // It's possible this layer was never drawn or updated (e.g. because it was |
107 // a descendant of an opacity 0 layer). | 107 // a descendant of an opacity 0 layer). |
108 DoPostCommitInitializationIfNeeded(); | 108 DoPostCommitInitializationIfNeeded(); |
109 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); | 109 PictureLayerImpl* layer_impl = static_cast<PictureLayerImpl*>(base_layer); |
110 | 110 |
111 LayerImpl::PushPropertiesTo(base_layer); | 111 LayerImpl::PushPropertiesTo(base_layer); |
112 | 112 |
113 // When the pending tree pushes to the active tree, the pending twin | 113 // When the pending tree pushes to the active tree, the pending twin |
114 // becomes recycled. | 114 // becomes recycled. |
115 layer_impl->twin_layer_ = NULL; | 115 layer_impl->twin_layer_ = nullptr; |
116 twin_layer_ = NULL; | 116 twin_layer_ = nullptr; |
117 | 117 |
118 layer_impl->pile_ = pile_; | 118 layer_impl->pile_ = pile_; |
119 | 119 |
120 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); | 120 DCHECK(!pile_->is_solid_color() || !tilings_->num_tilings()); |
121 // Tilings would be expensive to push, so we swap. | 121 // Tilings would be expensive to push, so we swap. |
122 layer_impl->tilings_.swap(tilings_); | 122 layer_impl->tilings_.swap(tilings_); |
123 layer_impl->tilings_->SetClient(layer_impl); | 123 layer_impl->tilings_->SetClient(layer_impl); |
124 if (tilings_) | 124 if (tilings_) |
125 tilings_->SetClient(this); | 125 tilings_->SetClient(this); |
126 | 126 |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 return pile_.get(); | 629 return pile_.get(); |
630 } | 630 } |
631 | 631 |
632 const Region* PictureLayerImpl::GetInvalidation() { | 632 const Region* PictureLayerImpl::GetInvalidation() { |
633 return &invalidation_; | 633 return &invalidation_; |
634 } | 634 } |
635 | 635 |
636 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( | 636 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( |
637 const PictureLayerTiling* tiling) const { | 637 const PictureLayerTiling* tiling) const { |
638 if (!twin_layer_) | 638 if (!twin_layer_) |
639 return NULL; | 639 return nullptr; |
640 return twin_layer_->tilings_->TilingAtScale(tiling->contents_scale()); | 640 return twin_layer_->tilings_->TilingAtScale(tiling->contents_scale()); |
641 } | 641 } |
642 | 642 |
643 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( | 643 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( |
644 const PictureLayerTiling* tiling) { | 644 const PictureLayerTiling* tiling) { |
645 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); | 645 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); |
646 if (!recycled_twin || !recycled_twin->tilings_) | 646 if (!recycled_twin || !recycled_twin->tilings_) |
647 return NULL; | 647 return nullptr; |
648 return recycled_twin->tilings_->TilingAtScale(tiling->contents_scale()); | 648 return recycled_twin->tilings_->TilingAtScale(tiling->contents_scale()); |
649 } | 649 } |
650 | 650 |
651 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { | 651 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { |
652 return layer_tree_impl()->settings().max_tiles_for_interest_area; | 652 return layer_tree_impl()->settings().max_tiles_for_interest_area; |
653 } | 653 } |
654 | 654 |
655 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { | 655 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { |
656 float skewport_target_time_in_frames = | 656 float skewport_target_time_in_frames = |
657 layer_tree_impl()->use_gpu_rasterization() | 657 layer_tree_impl()->use_gpu_rasterization() |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 888 |
889 inline float PositiveRatio(float float1, float float2) { | 889 inline float PositiveRatio(float float1, float float2) { |
890 DCHECK_GT(float1, 0); | 890 DCHECK_GT(float1, 0); |
891 DCHECK_GT(float2, 0); | 891 DCHECK_GT(float2, 0); |
892 return float1 > float2 ? float1 / float2 : float2 / float1; | 892 return float1 > float2 ? float1 / float2 : float2 / float1; |
893 } | 893 } |
894 | 894 |
895 } // namespace | 895 } // namespace |
896 | 896 |
897 void PictureLayerImpl::AddTilingsForRasterScale() { | 897 void PictureLayerImpl::AddTilingsForRasterScale() { |
898 PictureLayerTiling* high_res = NULL; | 898 PictureLayerTiling* high_res = nullptr; |
899 PictureLayerTiling* low_res = NULL; | 899 PictureLayerTiling* low_res = nullptr; |
900 | 900 |
901 PictureLayerTiling* previous_low_res = NULL; | 901 PictureLayerTiling* previous_low_res = nullptr; |
902 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 902 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
903 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 903 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
904 if (tiling->contents_scale() == raster_contents_scale_) | 904 if (tiling->contents_scale() == raster_contents_scale_) |
905 high_res = tiling; | 905 high_res = tiling; |
906 if (tiling->contents_scale() == low_res_raster_contents_scale_) | 906 if (tiling->contents_scale() == low_res_raster_contents_scale_) |
907 low_res = tiling; | 907 low_res = tiling; |
908 if (tiling->resolution() == LOW_RESOLUTION) | 908 if (tiling->resolution() == LOW_RESOLUTION) |
909 previous_low_res = tiling; | 909 previous_low_res = tiling; |
910 | 910 |
911 // Reset all tilings to non-ideal until the end of this function. | 911 // Reset all tilings to non-ideal until the end of this function. |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 // from the tile. | 1394 // from the tile. |
1395 if (tiling->IsTileRequiredForActivation(tile) && !tile->IsReadyToDraw()) | 1395 if (tiling->IsTileRequiredForActivation(tile) && !tile->IsReadyToDraw()) |
1396 return false; | 1396 return false; |
1397 } | 1397 } |
1398 } | 1398 } |
1399 | 1399 |
1400 return true; | 1400 return true; |
1401 } | 1401 } |
1402 | 1402 |
1403 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator() | 1403 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator() |
1404 : layer_(NULL), current_stage_(arraysize(stages_)) { | 1404 : layer_(nullptr), current_stage_(arraysize(stages_)) { |
1405 } | 1405 } |
1406 | 1406 |
1407 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator( | 1407 PictureLayerImpl::LayerRasterTileIterator::LayerRasterTileIterator( |
1408 PictureLayerImpl* layer, | 1408 PictureLayerImpl* layer, |
1409 bool prioritize_low_res) | 1409 bool prioritize_low_res) |
1410 : layer_(layer), current_stage_(0) { | 1410 : layer_(layer), current_stage_(0) { |
1411 DCHECK(layer_); | 1411 DCHECK(layer_); |
1412 | 1412 |
1413 // Early out if the layer has no tilings. | 1413 // Early out if the layer has no tilings. |
1414 if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) { | 1414 if (!layer_->tilings_ || !layer_->tilings_->num_tilings()) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 IteratorType index = stages_[current_stage_].iterator_type; | 1513 IteratorType index = stages_[current_stage_].iterator_type; |
1514 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | 1514 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; |
1515 | 1515 |
1516 if (iterators_[index] && iterators_[index].get_type() == tile_type) | 1516 if (iterators_[index] && iterators_[index].get_type() == tile_type) |
1517 break; | 1517 break; |
1518 ++current_stage_; | 1518 ++current_stage_; |
1519 } | 1519 } |
1520 } | 1520 } |
1521 | 1521 |
1522 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator() | 1522 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator() |
1523 : layer_(NULL), | 1523 : layer_(nullptr), |
1524 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES), | 1524 tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES), |
1525 current_category_(PictureLayerTiling::EVENTUALLY), | 1525 current_category_(PictureLayerTiling::EVENTUALLY), |
1526 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), | 1526 current_tiling_range_type_(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES), |
1527 current_tiling_(0u) { | 1527 current_tiling_(0u) { |
1528 } | 1528 } |
1529 | 1529 |
1530 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( | 1530 PictureLayerImpl::LayerEvictionTileIterator::LayerEvictionTileIterator( |
1531 PictureLayerImpl* layer, | 1531 PictureLayerImpl* layer, |
1532 TreePriority tree_priority) | 1532 TreePriority tree_priority) |
1533 : layer_(layer), | 1533 : layer_(layer), |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1666 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1667 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1667 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1668 return tiling_range.end - 1 - current_tiling_range_offset; | 1668 return tiling_range.end - 1 - current_tiling_range_offset; |
1669 } | 1669 } |
1670 } | 1670 } |
1671 NOTREACHED(); | 1671 NOTREACHED(); |
1672 return 0; | 1672 return 0; |
1673 } | 1673 } |
1674 | 1674 |
1675 } // namespace cc | 1675 } // namespace cc |
OLD | NEW |