| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010, 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010, 2011. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 float animValue = blend(from, m_fromMode == AbsoluteCoordinates ? to + toVal
ue : to - toValue, m_progress); | 70 float animValue = blend(from, m_fromMode == AbsoluteCoordinates ? to + toVal
ue : to - toValue, m_progress); |
| 71 | 71 |
| 72 if (m_isInFirstHalfOfAnimation) | 72 if (m_isInFirstHalfOfAnimation) |
| 73 return animValue; | 73 return animValue; |
| 74 | 74 |
| 75 // Transform the animated point to the coordinate mode, needed for the curre
nt progress. | 75 // Transform the animated point to the coordinate mode, needed for the curre
nt progress. |
| 76 float currentValue = blend(fromValue, toValue, m_progress); | 76 float currentValue = blend(fromValue, toValue, m_progress); |
| 77 return m_toMode == AbsoluteCoordinates ? animValue + currentValue : animValu
e - currentValue; | 77 return m_toMode == AbsoluteCoordinates ? animValue + currentValue : animValu
e - currentValue; |
| 78 } | 78 } |
| 79 | 79 |
| 80 FloatPoint SVGPathBlender::blendAnimatedFloatPointSameCoordinates(const FloatPoi
nt& fromPoint, const FloatPoint& toPoint) |
| 81 { |
| 82 if (m_addTypesCount) { |
| 83 FloatPoint repeatedToPoint = toPoint; |
| 84 repeatedToPoint.scale(m_addTypesCount, m_addTypesCount); |
| 85 return fromPoint + repeatedToPoint; |
| 86 } |
| 87 return blendFloatPoint(fromPoint, toPoint, m_progress); |
| 88 } |
| 89 |
| 80 FloatPoint SVGPathBlender::blendAnimatedFloatPoint(const FloatPoint& fromPoint,
const FloatPoint& toPoint) | 90 FloatPoint SVGPathBlender::blendAnimatedFloatPoint(const FloatPoint& fromPoint,
const FloatPoint& toPoint) |
| 81 { | 91 { |
| 82 if (m_addTypesCount) { | |
| 83 ASSERT(m_fromMode == m_toMode); | |
| 84 FloatPoint repeatedToPoint = toPoint; | |
| 85 repeatedToPoint.scale(m_addTypesCount, m_addTypesCount); | |
| 86 return fromPoint + repeatedToPoint; | |
| 87 } | |
| 88 | |
| 89 if (m_fromMode == m_toMode) | 92 if (m_fromMode == m_toMode) |
| 90 return blendFloatPoint(fromPoint, toPoint, m_progress); | 93 return blendAnimatedFloatPointSameCoordinates(fromPoint, toPoint); |
| 91 | 94 |
| 92 // Transform toPoint to the coordinate mode of fromPoint | 95 // Transform toPoint to the coordinate mode of fromPoint |
| 93 FloatPoint animatedPoint = toPoint; | 96 FloatPoint animatedPoint = toPoint; |
| 94 if (m_fromMode == AbsoluteCoordinates) | 97 if (m_fromMode == AbsoluteCoordinates) |
| 95 animatedPoint += m_toCurrentPoint; | 98 animatedPoint += m_toCurrentPoint; |
| 96 else | 99 else |
| 97 animatedPoint.move(-m_toCurrentPoint.x(), -m_toCurrentPoint.y()); | 100 animatedPoint.move(-m_toCurrentPoint.x(), -m_toCurrentPoint.y()); |
| 98 | 101 |
| 99 animatedPoint = blendFloatPoint(fromPoint, animatedPoint, m_progress); | 102 animatedPoint = blendFloatPoint(fromPoint, animatedPoint, m_progress); |
| 100 | 103 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 float toRx = 0; | 251 float toRx = 0; |
| 249 float toRy = 0; | 252 float toRy = 0; |
| 250 float toAngle = 0; | 253 float toAngle = 0; |
| 251 bool toLargeArc = false; | 254 bool toLargeArc = false; |
| 252 bool toSweep = false; | 255 bool toSweep = false; |
| 253 FloatPoint toTargetPoint; | 256 FloatPoint toTargetPoint; |
| 254 if ((m_fromSource->hasMoreData() && !m_fromSource->parseArcToSegment(fromRx,
fromRy, fromAngle, fromLargeArc, fromSweep, fromTargetPoint)) | 257 if ((m_fromSource->hasMoreData() && !m_fromSource->parseArcToSegment(fromRx,
fromRy, fromAngle, fromLargeArc, fromSweep, fromTargetPoint)) |
| 255 || !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSwe
ep, toTargetPoint)) | 258 || !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSwe
ep, toTargetPoint)) |
| 256 return false; | 259 return false; |
| 257 | 260 |
| 261 ASSERT(!m_addTypesCount || m_fromMode == m_toMode); |
| 262 |
| 263 FloatPoint blendedRadii = blendAnimatedFloatPointSameCoordinates(FloatPoint(
fromRx, fromRy), FloatPoint(toRx, toRy)); |
| 264 float blendedAngle = blendAnimatedFloatPointSameCoordinates(FloatPoint(fromA
ngle, 0), FloatPoint(toAngle, 0)).x(); |
| 265 bool blendedLargeArc; |
| 266 bool blendedSweep; |
| 267 |
| 258 if (m_addTypesCount) { | 268 if (m_addTypesCount) { |
| 259 ASSERT(m_fromMode == m_toMode); | 269 blendedLargeArc = fromLargeArc || toLargeArc; |
| 260 FloatPoint scaledToTargetPoint = toTargetPoint; | 270 blendedSweep = fromSweep || toSweep; |
| 261 scaledToTargetPoint.scale(m_addTypesCount, m_addTypesCount); | |
| 262 m_consumer->arcTo(fromRx + toRx * m_addTypesCount, | |
| 263 fromRy + toRy * m_addTypesCount, | |
| 264 fromAngle + toAngle * m_addTypesCount, | |
| 265 fromLargeArc || toLargeArc, | |
| 266 fromSweep || toSweep, | |
| 267 fromTargetPoint + scaledToTargetPoint, | |
| 268 m_fromMode); | |
| 269 } else { | 271 } else { |
| 270 m_consumer->arcTo(blend(fromRx, toRx, m_progress), | 272 blendedLargeArc = m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc
; |
| 271 blend(fromRy, toRy, m_progress), | 273 blendedSweep = m_isInFirstHalfOfAnimation ? fromSweep : toSweep; |
| 272 blend(fromAngle, toAngle, m_progress), | |
| 273 m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc
, | |
| 274 m_isInFirstHalfOfAnimation ? fromSweep : toSweep, | |
| 275 blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint
), | |
| 276 m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); | |
| 277 } | 274 } |
| 275 |
| 276 m_consumer->arcTo( |
| 277 blendedRadii.x(), blendedRadii.y(), blendedAngle, blendedLargeArc, blend
edSweep, |
| 278 blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), |
| 279 m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode); |
| 280 |
| 278 m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m
_fromCurrentPoint + fromTargetPoint; | 281 m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m
_fromCurrentPoint + fromTargetPoint; |
| 279 m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCur
rentPoint + toTargetPoint; | 282 m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCur
rentPoint + toTargetPoint; |
| 280 return true; | 283 return true; |
| 281 } | 284 } |
| 282 | 285 |
| 283 static inline PathCoordinateMode coordinateModeOfCommand(const SVGPathSegType& t
ype) | 286 static inline PathCoordinateMode coordinateModeOfCommand(const SVGPathSegType& t
ype) |
| 284 { | 287 { |
| 285 if (type < PathSegMoveToAbs) | 288 if (type < PathSegMoveToAbs) |
| 286 return AbsoluteCoordinates; | 289 return AbsoluteCoordinates; |
| 287 | 290 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 if (m_fromSource->hasMoreData() != m_toSource->hasMoreData()) | 393 if (m_fromSource->hasMoreData() != m_toSource->hasMoreData()) |
| 391 return false; | 394 return false; |
| 392 if (!m_fromSource->hasMoreData() || !m_toSource->hasMoreData()) | 395 if (!m_fromSource->hasMoreData() || !m_toSource->hasMoreData()) |
| 393 return true; | 396 return true; |
| 394 } | 397 } |
| 395 | 398 |
| 396 return true; | 399 return true; |
| 397 } | 400 } |
| 398 | 401 |
| 399 } | 402 } |
| OLD | NEW |