Example #1
0
bool SVGPathBlender::blendLineToVerticalSegment()
{
    float fromY;
    float toY;
    if (!m_fromSource->parseLineToVerticalSegment(fromY)
        || !m_toSource->parseLineToVerticalSegment(toY))
        return false;

    m_consumer->lineToVertical(blendAnimatedDimensonalFloat(fromY, toY, BlendVertical), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint.setY(m_fromMode == AbsoluteCoordinates ? fromY : m_fromCurrentPoint.y() + fromY);
    m_toCurrentPoint.setY(m_toMode == AbsoluteCoordinates ? toY : m_toCurrentPoint.y() + toY);
    return true;
}
Example #2
0
bool SVGPathBlender::blendLineToHorizontalSegment()
{
    float fromX;
    float toX;
    if (!m_fromSource->parseLineToHorizontalSegment(fromX)
        || !m_toSource->parseLineToHorizontalSegment(toX))
        return false;

    m_consumer->lineToHorizontal(blendAnimatedDimensonalFloat(fromX, toX, BlendHorizontal), m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint.setX(m_fromMode == AbsoluteCoordinates ? fromX : m_fromCurrentPoint.x() + fromX);
    m_toCurrentPoint.setX(m_toMode == AbsoluteCoordinates ? toX : m_toCurrentPoint.x() + toX);
    return true;
}
Example #3
0
bool SVGPathBlender::BlendState::blendSegments(
    const PathSegmentData& fromSeg,
    const PathSegmentData& toSeg,
    PathSegmentData& blendedSegment) {
  if (!canBlend(fromSeg, toSeg))
    return false;

  blendedSegment.command =
      m_isInFirstHalfOfAnimation ? fromSeg.command : toSeg.command;

  switch (toSeg.command) {
    case PathSegCurveToCubicRel:
    case PathSegCurveToCubicAbs:
      blendedSegment.point1 =
          blendAnimatedFloatPoint(fromSeg.point1, toSeg.point1);
    /* fall through */
    case PathSegCurveToCubicSmoothRel:
    case PathSegCurveToCubicSmoothAbs:
      blendedSegment.point2 =
          blendAnimatedFloatPoint(fromSeg.point2, toSeg.point2);
    /* fall through */
    case PathSegMoveToRel:
    case PathSegMoveToAbs:
    case PathSegLineToRel:
    case PathSegLineToAbs:
    case PathSegCurveToQuadraticSmoothRel:
    case PathSegCurveToQuadraticSmoothAbs:
      blendedSegment.targetPoint =
          blendAnimatedFloatPoint(fromSeg.targetPoint, toSeg.targetPoint);
      break;
    case PathSegLineToHorizontalRel:
    case PathSegLineToHorizontalAbs:
      blendedSegment.targetPoint.setX(blendAnimatedDimensonalFloat(
          fromSeg.targetPoint.x(), toSeg.targetPoint.x(), BlendHorizontal));
      break;
    case PathSegLineToVerticalRel:
    case PathSegLineToVerticalAbs:
      blendedSegment.targetPoint.setY(blendAnimatedDimensonalFloat(
          fromSeg.targetPoint.y(), toSeg.targetPoint.y(), BlendVertical));
      break;
    case PathSegClosePath:
      break;
    case PathSegCurveToQuadraticRel:
    case PathSegCurveToQuadraticAbs:
      blendedSegment.targetPoint =
          blendAnimatedFloatPoint(fromSeg.targetPoint, toSeg.targetPoint);
      blendedSegment.point1 =
          blendAnimatedFloatPoint(fromSeg.point1, toSeg.point1);
      break;
    case PathSegArcRel:
    case PathSegArcAbs:
      blendedSegment.targetPoint =
          blendAnimatedFloatPoint(fromSeg.targetPoint, toSeg.targetPoint);
      blendedSegment.point1 = blendAnimatedFloatPointSameCoordinates(
          fromSeg.arcRadii(), toSeg.arcRadii());
      blendedSegment.point2 =
          blendAnimatedFloatPointSameCoordinates(fromSeg.point2, toSeg.point2);
      if (m_addTypesCount) {
        blendedSegment.arcLarge = fromSeg.arcLarge || toSeg.arcLarge;
        blendedSegment.arcSweep = fromSeg.arcSweep || toSeg.arcSweep;
      } else {
        blendedSegment.arcLarge =
            m_isInFirstHalfOfAnimation ? fromSeg.arcLarge : toSeg.arcLarge;
        blendedSegment.arcSweep =
            m_isInFirstHalfOfAnimation ? fromSeg.arcSweep : toSeg.arcSweep;
      }
      break;
    default:
      ASSERT_NOT_REACHED();
  }

  updateCurrentPoint(m_fromSubPathPoint, m_fromCurrentPoint, fromSeg);
  updateCurrentPoint(m_toSubPathPoint, m_toCurrentPoint, toSeg);

  return true;
}