| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/graphics/paint/PropertyTreeState.h" |
| 6 |
| 7 #include "platform/graphics/paint/GeometryMapper.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 bool PropertyTreeState::hasDirectCompositingReasons() const { |
| 12 switch (innermostNode()) { |
| 13 case Transform: |
| 14 return transform()->hasDirectCompositingReasons(); |
| 15 case Clip: |
| 16 return clip()->hasDirectCompositingReasons(); |
| 17 case Effect: |
| 18 return effect()->hasDirectCompositingReasons(); |
| 19 default: |
| 20 return false; |
| 21 } |
| 22 } |
| 23 |
| 24 template <typename PropertyNode> |
| 25 bool isAncestorOf(const PropertyNode* ancestor, const PropertyNode* child) { |
| 26 while (child && child != ancestor) { |
| 27 child = child->parent(); |
| 28 } |
| 29 return child == ancestor; |
| 30 } |
| 31 |
| 32 PropertyTreeState::InnermostNode PropertyTreeState::innermostNode() const { |
| 33 // TODO(chrishtr): this is very inefficient when innermostNode() is called |
| 34 // repeatedly. |
| 35 bool clipTransformStrictAncestorOfTransform = |
| 36 m_clip->localTransformSpace() != m_transform.get() && |
| 37 isAncestorOf<TransformPaintPropertyNode>(m_clip->localTransformSpace(), |
| 38 m_transform.get()); |
| 39 bool effectTransformStrictAncestorOfTransform = |
| 40 m_effect->localTransformSpace() != m_transform.get() && |
| 41 isAncestorOf<TransformPaintPropertyNode>(m_effect->localTransformSpace(), |
| 42 m_transform.get()); |
| 43 |
| 44 if (!m_transform->isRoot() && clipTransformStrictAncestorOfTransform && |
| 45 effectTransformStrictAncestorOfTransform) |
| 46 return Transform; |
| 47 |
| 48 bool clipAncestorOfEffect = |
| 49 isAncestorOf<ClipPaintPropertyNode>(m_clip.get(), m_effect->outputClip()); |
| 50 |
| 51 if (!m_effect->isRoot() && clipAncestorOfEffect) { |
| 52 return Effect; |
| 53 } |
| 54 if (!m_clip->isRoot()) |
| 55 return Clip; |
| 56 return None; |
| 57 } |
| 58 |
| 59 const PropertyTreeState* PropertyTreeStateIterator::next() { |
| 60 switch (m_properties.innermostNode()) { |
| 61 case PropertyTreeState::Transform: |
| 62 m_properties.setTransform(m_properties.transform()->parent()); |
| 63 return &m_properties; |
| 64 case PropertyTreeState::Clip: |
| 65 m_properties.setClip(m_properties.clip()->parent()); |
| 66 return &m_properties; |
| 67 case PropertyTreeState::Effect: |
| 68 m_properties.setEffect(m_properties.effect()->parent()); |
| 69 return &m_properties; |
| 70 case PropertyTreeState::None: |
| 71 return nullptr; |
| 72 } |
| 73 return nullptr; |
| 74 } |
| 75 |
| 76 } // namespace blink |
| OLD | NEW |