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( | 41 CompositorElementId PropertyTreeState::GetCompositorElementId( |
42 const CompositorElementIdSet& element_ids) const { | 42 const CompositorElementIdSet& element_ids) const { |
43 // 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 |
44 // 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 |
45 // non-default CompositorElementId. | 45 // non-default CompositorElementId. |
46 // | 46 // |
47 // Note that PropertyTreeState acts as a context that accumulates state as we | 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 | 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 | 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 | 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 | 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 | 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. | 53 // broader rework of animation subsystem noted in http://crbug.com/709137. |
54 #if DCHECK_IS_ON() | 54 #if DCHECK_IS_ON() |
55 CompositorElementId expected_element_id; | 55 CompositorElementId expected_element_id = kInvalidElementId; |
56 CompositorElementId effect_element_id = Effect()->GetCompositorElementId(); | 56 CompositorElementId effect_element_id = Effect()->GetCompositorElementId(); |
57 if (effect_element_id && !element_ids.Contains(effect_element_id)) { | 57 if (effect_element_id && !element_ids.Contains(effect_element_id)) { |
58 expected_element_id = effect_element_id; | 58 expected_element_id = effect_element_id; |
59 } | 59 } |
60 CompositorElementId transform_element_id = | 60 CompositorElementId transform_element_id = |
61 Transform()->GetCompositorElementId(); | 61 Transform()->GetCompositorElementId(); |
62 if (expected_element_id && transform_element_id && | 62 if (expected_element_id && transform_element_id && |
63 !element_ids.Contains(transform_element_id)) { | 63 !element_ids.Contains(transform_element_id)) { |
64 DCHECK_EQ(expected_element_id, transform_element_id); | 64 DCHECK_EQ(expected_element_id, transform_element_id); |
65 } | 65 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 #if DCHECK_IS_ON() | 125 #if DCHECK_IS_ON() |
126 | 126 |
127 String PropertyTreeState::ToTreeString() const { | 127 String PropertyTreeState::ToTreeString() const { |
128 return Transform()->ToTreeString() + "\n" + Clip()->ToTreeString() + "\n" + | 128 return Transform()->ToTreeString() + "\n" + Clip()->ToTreeString() + "\n" + |
129 Effect()->ToTreeString(); | 129 Effect()->ToTreeString(); |
130 } | 130 } |
131 | 131 |
132 #endif | 132 #endif |
133 | 133 |
134 } // namespace blink | 134 } // namespace blink |
OLD | NEW |