| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/paint/PropertyTreeState.h" | 5 #include "platform/graphics/paint/PropertyTreeState.h" |
| 6 | 6 |
| 7 #include "platform/graphics/paint/GeometryMapper.h" | 7 #include "platform/graphics/paint/GeometryMapper.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 template <typename PropertyNode> | 33 template <typename PropertyNode> |
| 34 bool IsAncestorOf(const PropertyNode* ancestor, const PropertyNode* child) { | 34 bool IsAncestorOf(const PropertyNode* ancestor, const PropertyNode* child) { |
| 35 while (child && child != ancestor) { | 35 while (child && child != ancestor) { |
| 36 child = child->Parent(); | 36 child = child->Parent(); |
| 37 } | 37 } |
| 38 return child == ancestor; | 38 return child == ancestor; |
| 39 } | 39 } |
| 40 | 40 |
| 41 const CompositorElementId PropertyTreeState::GetCompositorElementId() const { | 41 const CompositorElementId PropertyTreeState::GetCompositorElementId( |
| 42 const CompositorElementIdSet& element_ids) const { |
| 42 // The effect or transform nodes could have a compositor element id. The order | 43 // The effect or transform nodes could have a compositor element id. The order |
| 43 // doesn't matter as the element id should be the same on all that have a | 44 // doesn't matter as the element id should be the same on all that have a |
| 44 // non-default CompositorElementId. | 45 // non-default CompositorElementId. |
| 46 // |
| 47 // Note that PropertyTreeState acts as a context that accumulates state as we |
| 48 // traverse the tree building layers. This means that we could see a compositor |
| 49 // element id 'A' for a parent layer in conjunction with a compositor element id |
| 50 // 'B' for a child layer. To preserve uniqueness of element ids, then, we check |
| 51 // for presence in the |element_ids| set (which represents element ids already |
| 52 // previously attached to a layer). This is an interim step while we pursue |
| 53 // broader rework of animation subsystem noted in http://crbug.com/709137. |
| 45 #if DCHECK_IS_ON() | 54 #if DCHECK_IS_ON() |
| 46 CompositorElementId expected_element_id; | 55 CompositorElementId expected_element_id; |
| 47 if (CompositorElementId actual_element_id = | 56 CompositorElementId effect_element_id = Effect()->GetCompositorElementId(); |
| 48 Effect()->GetCompositorElementId()) { | 57 if (effect_element_id && !element_ids.Contains(effect_element_id)) { |
| 49 expected_element_id = actual_element_id; | 58 expected_element_id = effect_element_id; |
| 50 } | 59 } |
| 51 if (CompositorElementId actual_element_id = | 60 CompositorElementId transform_element_id = |
| 52 Transform()->GetCompositorElementId()) { | 61 Transform()->GetCompositorElementId(); |
| 53 if (expected_element_id) | 62 if (expected_element_id && transform_element_id && |
| 54 DCHECK_EQ(expected_element_id, actual_element_id); | 63 !element_ids.Contains(transform_element_id)) { |
| 64 DCHECK_EQ(expected_element_id, transform_element_id); |
| 55 } | 65 } |
| 56 #endif | 66 #endif |
| 57 if (Effect()->GetCompositorElementId()) | 67 if (Effect()->GetCompositorElementId() && |
| 68 !element_ids.Contains(Effect()->GetCompositorElementId())) |
| 58 return Effect()->GetCompositorElementId(); | 69 return Effect()->GetCompositorElementId(); |
| 59 if (Transform()->GetCompositorElementId()) | 70 if (Transform()->GetCompositorElementId() && |
| 71 !element_ids.Contains(Transform()->GetCompositorElementId())) |
| 60 return Transform()->GetCompositorElementId(); | 72 return Transform()->GetCompositorElementId(); |
| 61 return CompositorElementId(); | 73 return CompositorElementId(); |
| 62 } | 74 } |
| 63 | 75 |
| 64 PropertyTreeState::InnermostNode PropertyTreeState::GetInnermostNode() const { | 76 PropertyTreeState::InnermostNode PropertyTreeState::GetInnermostNode() const { |
| 65 // TODO(chrishtr): this is very inefficient when innermostNode() is called | 77 // TODO(chrishtr): this is very inefficient when innermostNode() is called |
| 66 // repeatedly. | 78 // repeatedly. |
| 67 bool clip_transform_strict_ancestor_of_transform = | 79 bool clip_transform_strict_ancestor_of_transform = |
| 68 clip_->LocalTransformSpace() != transform_.Get() && | 80 clip_->LocalTransformSpace() != transform_.Get() && |
| 69 IsAncestorOf<TransformPaintPropertyNode>(clip_->LocalTransformSpace(), | 81 IsAncestorOf<TransformPaintPropertyNode>(clip_->LocalTransformSpace(), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 #if DCHECK_IS_ON() | 120 #if DCHECK_IS_ON() |
| 109 | 121 |
| 110 String PropertyTreeState::ToTreeString() const { | 122 String PropertyTreeState::ToTreeString() const { |
| 111 return Transform()->ToTreeString() + "\n" + Clip()->ToTreeString() + "\n" + | 123 return Transform()->ToTreeString() + "\n" + Clip()->ToTreeString() + "\n" + |
| 112 Effect()->ToTreeString(); | 124 Effect()->ToTreeString(); |
| 113 } | 125 } |
| 114 | 126 |
| 115 #endif | 127 #endif |
| 116 | 128 |
| 117 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |