OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void TransformState::move(const LayoutSize& offset, | 69 void TransformState::move(const LayoutSize& offset, |
70 TransformAccumulation accumulate) { | 70 TransformAccumulation accumulate) { |
71 if (m_forceAccumulatingTransform) | 71 if (m_forceAccumulatingTransform) |
72 accumulate = AccumulateTransform; | 72 accumulate = AccumulateTransform; |
73 | 73 |
74 if (accumulate == FlattenTransform || !m_accumulatedTransform) { | 74 if (accumulate == FlattenTransform || !m_accumulatedTransform) { |
75 m_accumulatedOffset += offset; | 75 m_accumulatedOffset += offset; |
76 } else { | 76 } else { |
77 applyAccumulatedOffset(); | 77 applyAccumulatedOffset(); |
78 if (m_accumulatingTransform && m_accumulatedTransform) { | 78 if (m_accumulatingTransform && m_accumulatedTransform) { |
79 // If we're accumulating into an existing transform, apply the translation
. | 79 // If we're accumulating into an existing transform, apply the |
| 80 // translation. |
80 translateTransform(offset); | 81 translateTransform(offset); |
81 } else { | 82 } else { |
82 // Just move the point and/or quad. | 83 // Just move the point and/or quad. |
83 translateMappedCoordinates(offset); | 84 translateMappedCoordinates(offset); |
84 } | 85 } |
85 } | 86 } |
86 m_accumulatingTransform = accumulate == AccumulateTransform; | 87 m_accumulatingTransform = accumulate == AccumulateTransform; |
87 } | 88 } |
88 | 89 |
89 void TransformState::applyAccumulatedOffset() { | 90 void TransformState::applyAccumulatedOffset() { |
90 LayoutSize offset = m_accumulatedOffset; | 91 LayoutSize offset = m_accumulatedOffset; |
91 m_accumulatedOffset = LayoutSize(); | 92 m_accumulatedOffset = LayoutSize(); |
92 if (!offset.isZero()) { | 93 if (!offset.isZero()) { |
93 if (m_accumulatedTransform) { | 94 if (m_accumulatedTransform) { |
94 translateTransform(offset); | 95 translateTransform(offset); |
95 flatten(); | 96 flatten(); |
96 } else { | 97 } else { |
97 translateMappedCoordinates(offset); | 98 translateMappedCoordinates(offset); |
98 } | 99 } |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 // FIXME: We transform AffineTransform to TransformationMatrix. This is rather i
nefficient. | 103 // FIXME: We transform AffineTransform to TransformationMatrix. This is rather |
| 104 // inefficient. |
103 void TransformState::applyTransform( | 105 void TransformState::applyTransform( |
104 const AffineTransform& transformFromContainer, | 106 const AffineTransform& transformFromContainer, |
105 TransformAccumulation accumulate, | 107 TransformAccumulation accumulate, |
106 bool* wasClamped) { | 108 bool* wasClamped) { |
107 applyTransform(transformFromContainer.toTransformationMatrix(), accumulate, | 109 applyTransform(transformFromContainer.toTransformationMatrix(), accumulate, |
108 wasClamped); | 110 wasClamped); |
109 } | 111 } |
110 | 112 |
111 void TransformState::applyTransform( | 113 void TransformState::applyTransform( |
112 const TransformationMatrix& transformFromContainer, | 114 const TransformationMatrix& transformFromContainer, |
113 TransformAccumulation accumulate, | 115 TransformAccumulation accumulate, |
114 bool* wasClamped) { | 116 bool* wasClamped) { |
115 if (wasClamped) | 117 if (wasClamped) |
116 *wasClamped = false; | 118 *wasClamped = false; |
117 | 119 |
118 if (transformFromContainer.isIntegerTranslation()) { | 120 if (transformFromContainer.isIntegerTranslation()) { |
119 move(LayoutSize(LayoutUnit(transformFromContainer.e()), | 121 move(LayoutSize(LayoutUnit(transformFromContainer.e()), |
120 LayoutUnit(transformFromContainer.f())), | 122 LayoutUnit(transformFromContainer.f())), |
121 accumulate); | 123 accumulate); |
122 return; | 124 return; |
123 } | 125 } |
124 | 126 |
125 applyAccumulatedOffset(); | 127 applyAccumulatedOffset(); |
126 | 128 |
127 // If we have an accumulated transform from last time, multiply in this transf
orm | 129 // If we have an accumulated transform from last time, multiply in this |
| 130 // transform |
128 if (m_accumulatedTransform) { | 131 if (m_accumulatedTransform) { |
129 if (m_direction == ApplyTransformDirection) | 132 if (m_direction == ApplyTransformDirection) |
130 m_accumulatedTransform = TransformationMatrix::create( | 133 m_accumulatedTransform = TransformationMatrix::create( |
131 transformFromContainer * *m_accumulatedTransform); | 134 transformFromContainer * *m_accumulatedTransform); |
132 else | 135 else |
133 m_accumulatedTransform->multiply(transformFromContainer); | 136 m_accumulatedTransform->multiply(transformFromContainer); |
134 } else if (accumulate == AccumulateTransform) { | 137 } else if (accumulate == AccumulateTransform) { |
135 // Make one if we started to accumulate | 138 // Make one if we started to accumulate |
136 m_accumulatedTransform = | 139 m_accumulatedTransform = |
137 TransformationMatrix::create(transformFromContainer); | 140 TransformationMatrix::create(transformFromContainer); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 225 |
223 // We could throw away m_accumulatedTransform if we wanted to here, but that | 226 // We could throw away m_accumulatedTransform if we wanted to here, but that |
224 // would cause thrash when traversing hierarchies with alternating | 227 // would cause thrash when traversing hierarchies with alternating |
225 // preserve-3d and flat elements. | 228 // preserve-3d and flat elements. |
226 if (m_accumulatedTransform) | 229 if (m_accumulatedTransform) |
227 m_accumulatedTransform->makeIdentity(); | 230 m_accumulatedTransform->makeIdentity(); |
228 m_accumulatingTransform = false; | 231 m_accumulatingTransform = false; |
229 } | 232 } |
230 | 233 |
231 } // namespace blink | 234 } // namespace blink |
OLD | NEW |