OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "platform/graphics/paint/DisplayItemPropertyTreeBuilder.h" | 6 #include "platform/graphics/paint/DisplayItemPropertyTreeBuilder.h" |
7 | 7 |
8 #include "platform/graphics/paint/DisplayItem.h" | 8 #include "platform/graphics/paint/DisplayItem.h" |
9 #include "platform/graphics/paint/DisplayItemClipTree.h" | 9 #include "platform/graphics/paint/DisplayItemClipTree.h" |
10 #include "platform/graphics/paint/DisplayItemTransformTree.h" | 10 #include "platform/graphics/paint/DisplayItemTransformTree.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 processEndItem(displayItem); | 58 processEndItem(displayItem); |
59 m_currentIndex++; | 59 m_currentIndex++; |
60 } | 60 } |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 enum TransformKind { NotATransform = 0, Only2DTranslation, RequiresTransformNode
}; | 64 enum TransformKind { NotATransform = 0, Only2DTranslation, RequiresTransformNode
}; |
65 enum ClipKind { NotAClip = 0, RequiresClipNode }; | 65 enum ClipKind { NotAClip = 0, RequiresClipNode }; |
66 | 66 |
67 struct BeginDisplayItemClassification { | 67 struct BeginDisplayItemClassification { |
| 68 // |transformOrigin| is irrelevant unless a non-translation matrix is |
| 69 // provided. |
68 TransformKind transformKind = NotATransform; | 70 TransformKind transformKind = NotATransform; |
69 TransformationMatrix matrix; | 71 TransformationMatrix matrix; |
| 72 FloatPoint3D transformOrigin; |
| 73 |
70 ClipKind clipKind = NotAClip; | 74 ClipKind clipKind = NotAClip; |
71 FloatRect clipRect; | 75 FloatRect clipRect; |
72 }; | 76 }; |
73 | 77 |
74 // Classifies a begin display item based on how it affects the property trees. | 78 // Classifies a begin display item based on how it affects the property trees. |
75 static BeginDisplayItemClassification classifyBeginItem(const DisplayItem& begin
DisplayItem) | 79 static BeginDisplayItemClassification classifyBeginItem(const DisplayItem& begin
DisplayItem) |
76 { | 80 { |
77 ASSERT(beginDisplayItem.isBegin()); | 81 ASSERT(beginDisplayItem.isBegin()); |
78 | 82 |
79 BeginDisplayItemClassification result; | 83 BeginDisplayItemClassification result; |
80 DisplayItem::Type type = beginDisplayItem.type(); | 84 DisplayItem::Type type = beginDisplayItem.type(); |
81 if (DisplayItem::isTransform3DType(type)) { | 85 if (DisplayItem::isTransform3DType(type)) { |
82 const auto& begin3D = static_cast<const BeginTransform3DDisplayItem&>(be
ginDisplayItem); | 86 const auto& begin3D = static_cast<const BeginTransform3DDisplayItem&>(be
ginDisplayItem); |
83 result.matrix = begin3D.transform(); | 87 result.matrix = begin3D.transform(); |
| 88 result.transformOrigin = begin3D.transformOrigin(); |
84 result.transformKind = result.matrix.isIdentityOr2DTranslation() ? Only2
DTranslation : RequiresTransformNode; | 89 result.transformKind = result.matrix.isIdentityOr2DTranslation() ? Only2
DTranslation : RequiresTransformNode; |
85 } else if (type == DisplayItem::BeginTransform) { | 90 } else if (type == DisplayItem::BeginTransform) { |
86 const auto& begin2D = static_cast<const BeginTransformDisplayItem&>(begi
nDisplayItem); | 91 const auto& begin2D = static_cast<const BeginTransformDisplayItem&>(begi
nDisplayItem); |
87 result.matrix = begin2D.transform(); | 92 result.matrix = begin2D.transform(); |
88 result.transformKind = begin2D.transform().isIdentityOrTranslation() ? O
nly2DTranslation : RequiresTransformNode; | 93 result.transformKind = begin2D.transform().isIdentityOrTranslation() ? O
nly2DTranslation : RequiresTransformNode; |
89 } else if (DisplayItem::isScrollType(type)) { | 94 } else if (DisplayItem::isScrollType(type)) { |
90 const auto& beginScroll = static_cast<const BeginScrollDisplayItem&>(beg
inDisplayItem); | 95 const auto& beginScroll = static_cast<const BeginScrollDisplayItem&>(beg
inDisplayItem); |
91 const IntSize& offset = beginScroll.currentOffset(); | 96 const IntSize& offset = beginScroll.currentOffset(); |
92 result.matrix.translate(-offset.width(), -offset.height()); | 97 result.matrix.translate(-offset.width(), -offset.height()); |
93 result.transformKind = Only2DTranslation; | 98 result.transformKind = Only2DTranslation; |
(...skipping 19 matching lines...) Expand all Loading... |
113 switch (classification.transformKind) { | 118 switch (classification.transformKind) { |
114 case NotATransform: | 119 case NotATransform: |
115 break; | 120 break; |
116 case Only2DTranslation: | 121 case Only2DTranslation: |
117 // Adjust the offset associated with the current transform node. | 122 // Adjust the offset associated with the current transform node. |
118 newState.offset += classification.matrix.to2DTranslation(); | 123 newState.offset += classification.matrix.to2DTranslation(); |
119 break; | 124 break; |
120 case RequiresTransformNode: | 125 case RequiresTransformNode: |
121 // Emit a transform node. | 126 // Emit a transform node. |
122 newState.transformNode = m_transformTree->createNewNode( | 127 newState.transformNode = m_transformTree->createNewNode( |
123 newState.transformNode, classification.matrix); | 128 newState.transformNode, classification.matrix, classification.transf
ormOrigin); |
124 newState.offset = FloatSize(); | 129 newState.offset = FloatSize(); |
125 break; | 130 break; |
126 } | 131 } |
127 | 132 |
128 switch (classification.clipKind) { | 133 switch (classification.clipKind) { |
129 case NotAClip: | 134 case NotAClip: |
130 break; | 135 break; |
131 case RequiresClipNode: | 136 case RequiresClipNode: |
132 // Emit a clip node. | 137 // Emit a clip node. |
133 FloatRect adjustedClipRect = classification.clipRect; | 138 FloatRect adjustedClipRect = classification.clipRect; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 rangeRecord.clipNodeIndex = current.clipNode; | 171 rangeRecord.clipNodeIndex = current.clipNode; |
167 m_rangeRecords.append(rangeRecord); | 172 m_rangeRecords.append(rangeRecord); |
168 } | 173 } |
169 | 174 |
170 // The current display item is a boundary. | 175 // The current display item is a boundary. |
171 // The earliest the next range could begin is the next one. | 176 // The earliest the next range could begin is the next one. |
172 m_rangeBeginIndex = m_currentIndex + 1; | 177 m_rangeBeginIndex = m_currentIndex + 1; |
173 } | 178 } |
174 | 179 |
175 } // namespace blink | 180 } // namespace blink |
OLD | NEW |