| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/effect_tree_layer_list_iterator.h" | 5 #include "cc/layers/effect_tree_layer_list_iterator.h" |
| 6 | 6 |
| 7 namespace cc { | 7 namespace cc { |
| 8 | 8 |
| 9 EffectTreeLayerListIterator::EffectTreeLayerListIterator( | 9 EffectTreeLayerListIterator::EffectTreeLayerListIterator( |
| 10 LayerTreeImpl* layer_tree_impl) | 10 LayerTreeImpl* layer_tree_impl) |
| 11 : state_(EffectTreeLayerListIterator::State::END), | 11 : state_(EffectTreeLayerListIterator::State::END), |
| 12 current_effect_tree_index_(EffectTree::kInvalidNodeId), | 12 current_effect_tree_index_(EffectTree::kInvalidNodeId), |
| 13 next_effect_tree_index_(EffectTree::kInvalidNodeId), | 13 next_effect_tree_index_(EffectTree::kInvalidNodeId), |
| 14 lowest_common_effect_tree_ancestor_index_(EffectTree::kInvalidNodeId), | 14 lowest_common_effect_tree_ancestor_index_(EffectTree::kInvalidNodeId), |
| 15 layer_tree_impl_(layer_tree_impl), | 15 layer_tree_impl_(layer_tree_impl), |
| 16 effect_tree_(&layer_tree_impl->property_trees()->effect_tree) { | 16 effect_tree_(&layer_tree_impl->property_trees()->effect_tree) { |
| 17 layer_list_iterator_ = layer_tree_impl->rbegin(); | 17 layer_list_iterator_ = layer_tree_impl->rbegin(); |
| 18 | 18 |
| 19 // Find the front-most drawn layer. | 19 // Find the front-most drawn layer. |
| 20 while ( | 20 while (layer_list_iterator_ != layer_tree_impl->rend() && |
| 21 layer_list_iterator_ != layer_tree_impl->rend() && | 21 !(*layer_list_iterator_)->contributes_to_drawn_render_surface()) { |
| 22 !(*layer_list_iterator_)->is_drawn_render_surface_layer_list_member()) { | |
| 23 layer_list_iterator_++; | 22 layer_list_iterator_++; |
| 24 } | 23 } |
| 25 | 24 |
| 26 // If there are no drawn layers, start at the root render surface, if it | 25 // If there are no drawn layers, start at the root render surface, if it |
| 27 // exists. | 26 // exists. |
| 28 if (layer_list_iterator_ == layer_tree_impl->rend()) { | 27 if (layer_list_iterator_ == layer_tree_impl->rend()) { |
| 29 DCHECK(effect_tree_->size() > EffectTree::kContentsRootNodeId); | 28 DCHECK(effect_tree_->size() > EffectTree::kContentsRootNodeId); |
| 30 state_ = State::TARGET_SURFACE; | 29 state_ = State::TARGET_SURFACE; |
| 31 current_effect_tree_index_ = EffectTree::kContentsRootNodeId; | 30 current_effect_tree_index_ = EffectTree::kContentsRootNodeId; |
| 32 } else { | 31 } else { |
| 33 state_ = State::LAYER; | 32 state_ = State::LAYER; |
| 34 current_effect_tree_index_ = | 33 current_effect_tree_index_ = |
| 35 (*layer_list_iterator_)->render_target_effect_tree_index(); | 34 (*layer_list_iterator_)->render_target_effect_tree_index(); |
| 36 next_effect_tree_index_ = current_effect_tree_index_; | 35 next_effect_tree_index_ = current_effect_tree_index_; |
| 37 lowest_common_effect_tree_ancestor_index_ = current_effect_tree_index_; | 36 lowest_common_effect_tree_ancestor_index_ = current_effect_tree_index_; |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 EffectTreeLayerListIterator::EffectTreeLayerListIterator( | 40 EffectTreeLayerListIterator::EffectTreeLayerListIterator( |
| 42 const EffectTreeLayerListIterator& iterator) = default; | 41 const EffectTreeLayerListIterator& iterator) = default; |
| 43 | 42 |
| 44 EffectTreeLayerListIterator::~EffectTreeLayerListIterator() {} | 43 EffectTreeLayerListIterator::~EffectTreeLayerListIterator() {} |
| 45 | 44 |
| 46 void EffectTreeLayerListIterator::operator++() { | 45 void EffectTreeLayerListIterator::operator++() { |
| 47 switch (state_) { | 46 switch (state_) { |
| 48 case State::LAYER: | 47 case State::LAYER: |
| 49 // Find the next drawn layer. | 48 // Find the next drawn layer. |
| 50 layer_list_iterator_++; | 49 layer_list_iterator_++; |
| 51 while (layer_list_iterator_ != layer_tree_impl_->rend() && | 50 while (layer_list_iterator_ != layer_tree_impl_->rend() && |
| 52 !(*layer_list_iterator_) | 51 !(*layer_list_iterator_)->contributes_to_drawn_render_surface()) { |
| 53 ->is_drawn_render_surface_layer_list_member()) { | |
| 54 layer_list_iterator_++; | 52 layer_list_iterator_++; |
| 55 } | 53 } |
| 56 if (layer_list_iterator_ == layer_tree_impl_->rend()) { | 54 if (layer_list_iterator_ == layer_tree_impl_->rend()) { |
| 57 next_effect_tree_index_ = EffectTree::kInvalidNodeId; | 55 next_effect_tree_index_ = EffectTree::kInvalidNodeId; |
| 58 lowest_common_effect_tree_ancestor_index_ = EffectTree::kInvalidNodeId; | 56 lowest_common_effect_tree_ancestor_index_ = EffectTree::kInvalidNodeId; |
| 59 state_ = State::TARGET_SURFACE; | 57 state_ = State::TARGET_SURFACE; |
| 60 break; | 58 break; |
| 61 } | 59 } |
| 62 | 60 |
| 63 next_effect_tree_index_ = | 61 next_effect_tree_index_ = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // surface. | 115 // surface. |
| 118 state_ = State::TARGET_SURFACE; | 116 state_ = State::TARGET_SURFACE; |
| 119 } | 117 } |
| 120 break; | 118 break; |
| 121 case State::END: | 119 case State::END: |
| 122 NOTREACHED(); | 120 NOTREACHED(); |
| 123 } | 121 } |
| 124 } | 122 } |
| 125 | 123 |
| 126 } // namespace cc | 124 } // namespace cc |
| OLD | NEW |