Chromium Code Reviews| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 { | 61 { |
| 62 FloatSize adjustedOffset((m_direction == ApplyTransformDirection) ? offset : -offset); | 62 FloatSize adjustedOffset((m_direction == ApplyTransformDirection) ? offset : -offset); |
| 63 if (m_mapPoint) | 63 if (m_mapPoint) |
| 64 m_lastPlanarPoint.move(adjustedOffset); | 64 m_lastPlanarPoint.move(adjustedOffset); |
| 65 if (m_mapQuad) | 65 if (m_mapQuad) |
| 66 m_lastPlanarQuad.move(adjustedOffset); | 66 m_lastPlanarQuad.move(adjustedOffset); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void TransformState::move(const LayoutSize& offset, TransformAccumulation accumu late) | 69 void TransformState::move(const LayoutSize& offset, TransformAccumulation accumu late) |
| 70 { | 70 { |
| 71 if (m_forceAccumulatingTransform) | |
| 72 accumulate = AccumulateTransform; | |
| 73 | |
| 71 if (accumulate == FlattenTransform || !m_accumulatedTransform) { | 74 if (accumulate == FlattenTransform || !m_accumulatedTransform) { |
| 72 m_accumulatedOffset += offset; | 75 m_accumulatedOffset += offset; |
| 73 } else { | 76 } else { |
| 74 applyAccumulatedOffset(); | 77 applyAccumulatedOffset(); |
| 75 if (m_accumulatingTransform && m_accumulatedTransform) { | 78 if (m_accumulatingTransform && m_accumulatedTransform) { |
| 76 // If we're accumulating into an existing transform, apply the trans lation. | 79 // If we're accumulating into an existing transform, apply the trans lation. |
| 77 translateTransform(offset); | 80 translateTransform(offset); |
| 78 } else { | 81 } else { |
| 79 // Just move the point and/or quad. | 82 // Just move the point and/or quad. |
| 80 translateMappedCoordinates(offset); | 83 translateMappedCoordinates(offset); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 101 void TransformState::applyTransform(const AffineTransform& transformFromContaine r, TransformAccumulation accumulate, bool* wasClamped) | 104 void TransformState::applyTransform(const AffineTransform& transformFromContaine r, TransformAccumulation accumulate, bool* wasClamped) |
| 102 { | 105 { |
| 103 applyTransform(transformFromContainer.toTransformationMatrix(), accumulate, wasClamped); | 106 applyTransform(transformFromContainer.toTransformationMatrix(), accumulate, wasClamped); |
| 104 } | 107 } |
| 105 | 108 |
| 106 void TransformState::applyTransform(const TransformationMatrix& transformFromCon tainer, TransformAccumulation accumulate, bool* wasClamped) | 109 void TransformState::applyTransform(const TransformationMatrix& transformFromCon tainer, TransformAccumulation accumulate, bool* wasClamped) |
| 107 { | 110 { |
| 108 if (wasClamped) | 111 if (wasClamped) |
| 109 *wasClamped = false; | 112 *wasClamped = false; |
| 110 | 113 |
| 114 if (m_forceAccumulatingTransform) | |
| 115 accumulate = AccumulateTransform; | |
| 116 | |
| 111 if (transformFromContainer.isIntegerTranslation()) { | 117 if (transformFromContainer.isIntegerTranslation()) { |
| 112 move(LayoutSize(LayoutUnit(transformFromContainer.e()), LayoutUnit(trans formFromContainer.f())), accumulate); | 118 move(LayoutSize(LayoutUnit(transformFromContainer.e()), LayoutUnit(trans formFromContainer.f())), accumulate); |
| 113 return; | 119 return; |
| 114 } | 120 } |
| 115 | 121 |
| 116 applyAccumulatedOffset(); | 122 applyAccumulatedOffset(); |
|
szager1
2016/03/08 23:34:15
I think this needs to be wrappend in a (accumulate
dmazzoni
2016/03/09 18:14:59
I don't think it's needed because the accumulated
szager1
2016/03/09 18:44:14
Right you are, this is fine.
| |
| 117 | 123 |
| 118 // If we have an accumulated transform from last time, multiply in this tran sform | 124 // If we have an accumulated transform from last time, multiply in this tran sform |
| 119 if (m_accumulatedTransform) { | 125 if (m_accumulatedTransform) { |
| 120 if (m_direction == ApplyTransformDirection) | 126 if (m_direction == ApplyTransformDirection) |
| 121 m_accumulatedTransform = TransformationMatrix::create(transformFromC ontainer * *m_accumulatedTransform); | 127 m_accumulatedTransform = TransformationMatrix::create(transformFromC ontainer * *m_accumulatedTransform); |
| 122 else | 128 else |
| 123 m_accumulatedTransform->multiply(transformFromContainer); | 129 m_accumulatedTransform->multiply(transformFromContainer); |
| 124 } else if (accumulate == AccumulateTransform) { | 130 } else if (accumulate == AccumulateTransform) { |
| 125 // Make one if we started to accumulate | 131 // Make one if we started to accumulate |
| 126 m_accumulatedTransform = TransformationMatrix::create(transformFromConta iner); | 132 m_accumulatedTransform = TransformationMatrix::create(transformFromConta iner); |
| 127 } | 133 } |
| 128 | 134 |
| 129 if (accumulate == FlattenTransform) { | 135 if (accumulate == FlattenTransform) { |
| 130 const TransformationMatrix* finalTransform = m_accumulatedTransform ? m_ accumulatedTransform.get() : &transformFromContainer; | 136 const TransformationMatrix* finalTransform = m_accumulatedTransform ? m_ accumulatedTransform.get() : &transformFromContainer; |
| 131 flattenWithTransform(*finalTransform, wasClamped); | 137 flattenWithTransform(*finalTransform, wasClamped); |
| 132 } | 138 } |
| 133 m_accumulatingTransform = accumulate == AccumulateTransform; | 139 m_accumulatingTransform = accumulate == AccumulateTransform; |
| 134 } | 140 } |
| 135 | 141 |
| 136 void TransformState::flatten(bool* wasClamped) | 142 void TransformState::flatten(bool* wasClamped) |
| 137 { | 143 { |
| 144 ASSERT(!m_forceAccumulatingTransform); | |
| 138 if (wasClamped) | 145 if (wasClamped) |
| 139 *wasClamped = false; | 146 *wasClamped = false; |
| 140 | 147 |
| 141 applyAccumulatedOffset(); | 148 applyAccumulatedOffset(); |
| 142 | 149 |
| 143 if (!m_accumulatedTransform) { | 150 if (!m_accumulatedTransform) { |
| 144 m_accumulatingTransform = false; | 151 m_accumulatingTransform = false; |
| 145 return; | 152 return; |
| 146 } | 153 } |
| 147 | 154 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 173 quad.move(FloatSize((m_direction == ApplyTransformDirection) ? m_accumulated Offset : -m_accumulatedOffset)); | 180 quad.move(FloatSize((m_direction == ApplyTransformDirection) ? m_accumulated Offset : -m_accumulatedOffset)); |
| 174 if (!m_accumulatedTransform) | 181 if (!m_accumulatedTransform) |
| 175 return quad; | 182 return quad; |
| 176 | 183 |
| 177 if (m_direction == ApplyTransformDirection) | 184 if (m_direction == ApplyTransformDirection) |
| 178 return m_accumulatedTransform->mapQuad(quad); | 185 return m_accumulatedTransform->mapQuad(quad); |
| 179 | 186 |
| 180 return m_accumulatedTransform->inverse().projectQuad(quad, wasClamped); | 187 return m_accumulatedTransform->inverse().projectQuad(quad, wasClamped); |
| 181 } | 188 } |
| 182 | 189 |
| 190 const TransformationMatrix& TransformState::accumulatedTransform() const | |
| 191 { | |
| 192 ASSERT(m_forceAccumulatingTransform && m_accumulatingTransform); | |
| 193 return *m_accumulatedTransform; | |
| 194 } | |
| 195 | |
| 183 void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* w asClamped) | 196 void TransformState::flattenWithTransform(const TransformationMatrix& t, bool* w asClamped) |
| 184 { | 197 { |
| 185 if (m_direction == ApplyTransformDirection) { | 198 if (m_direction == ApplyTransformDirection) { |
| 186 if (m_mapPoint) | 199 if (m_mapPoint) |
| 187 m_lastPlanarPoint = t.mapPoint(m_lastPlanarPoint); | 200 m_lastPlanarPoint = t.mapPoint(m_lastPlanarPoint); |
| 188 if (m_mapQuad) | 201 if (m_mapQuad) |
| 189 m_lastPlanarQuad = t.mapQuad(m_lastPlanarQuad); | 202 m_lastPlanarQuad = t.mapQuad(m_lastPlanarQuad); |
| 190 } else { | 203 } else { |
| 191 TransformationMatrix inverseTransform = t.inverse(); | 204 TransformationMatrix inverseTransform = t.inverse(); |
| 192 if (m_mapPoint) | 205 if (m_mapPoint) |
| 193 m_lastPlanarPoint = inverseTransform.projectPoint(m_lastPlanarPoint) ; | 206 m_lastPlanarPoint = inverseTransform.projectPoint(m_lastPlanarPoint) ; |
| 194 if (m_mapQuad) | 207 if (m_mapQuad) |
| 195 m_lastPlanarQuad = inverseTransform.projectQuad(m_lastPlanarQuad, wa sClamped); | 208 m_lastPlanarQuad = inverseTransform.projectQuad(m_lastPlanarQuad, wa sClamped); |
| 196 } | 209 } |
| 197 | 210 |
| 198 // We could throw away m_accumulatedTransform if we wanted to here, but that | 211 // We could throw away m_accumulatedTransform if we wanted to here, but that |
| 199 // would cause thrash when traversing hierarchies with alternating | 212 // would cause thrash when traversing hierarchies with alternating |
| 200 // preserve-3d and flat elements. | 213 // preserve-3d and flat elements. |
| 201 if (m_accumulatedTransform) | 214 if (m_accumulatedTransform) |
| 202 m_accumulatedTransform->makeIdentity(); | 215 m_accumulatedTransform->makeIdentity(); |
| 203 m_accumulatingTransform = false; | 216 m_accumulatingTransform = false; |
| 204 } | 217 } |
| 205 | 218 |
| 206 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |