Exemplo n.º 1
0
bool SVGPathBlender::blendArcToSegment()
{
    float fromRx;
    float fromRy;
    float fromAngle;
    bool fromLargeArc;
    bool fromSweep;
    FloatPoint fromTargetPoint;
    float toRx;
    float toRy;
    float toAngle;
    bool toLargeArc;
    bool toSweep;
    FloatPoint toTargetPoint;
    if (!m_fromSource->parseArcToSegment(fromRx, fromRy, fromAngle, fromLargeArc, fromSweep, fromTargetPoint)
        || !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSweep, toTargetPoint))
        return false;

    m_consumer->arcTo(blendAnimatedFloat(fromRx, toRx, m_progress),
                      blendAnimatedFloat(fromRy, toRy, m_progress),
                      blendAnimatedFloat(fromAngle, toAngle, m_progress),
                      m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc,
                      m_isInFirstHalfOfAnimation ? fromSweep : toSweep,
                      blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
                      m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
    return true;
}
Exemplo n.º 2
0
bool SVGPathBlender::blendCurveToQuadraticSegment()
{
    FloatPoint fromTargetPoint;
    FloatPoint fromPoint1;
    FloatPoint toTargetPoint;
    FloatPoint toPoint1;
    if (!m_fromSource->parseCurveToQuadraticSegment(fromPoint1, fromTargetPoint)
        || !m_toSource->parseCurveToQuadraticSegment(toPoint1, toTargetPoint))
        return false;

    m_consumer->curveToQuadratic(blendAnimatedFloatPoint(fromPoint1, toPoint1),
                                 blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
                                 m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
    return true;
}
Exemplo n.º 3
0
bool SVGPathBlender::blendCurveToCubicSmoothSegment()
{
    FloatPoint fromTargetPoint;
    FloatPoint fromPoint2;
    FloatPoint toTargetPoint;
    FloatPoint toPoint2;
    if ((m_fromSource->hasMoreData() && !m_fromSource->parseCurveToCubicSmoothSegment(fromPoint2, fromTargetPoint))
        || !m_toSource->parseCurveToCubicSmoothSegment(toPoint2, toTargetPoint))
        return false;

    m_consumer->curveToCubicSmooth(blendAnimatedFloatPoint(fromPoint2, toPoint2),
                                   blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
                                   m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
    return true;
}
Exemplo n.º 4
0
bool SVGPathBlender::blendMoveToSegment()
{
    FloatPoint fromTargetPoint;
    FloatPoint toTargetPoint;
    if (!m_fromSource->parseMoveToSegment(fromTargetPoint)
        || !m_toSource->parseMoveToSegment(toTargetPoint))
        return false;

    m_consumer->moveTo(blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint), false, m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
    return true;
}
Exemplo n.º 5
0
bool SVGPathBlender::blendArcToSegment()
{
    float fromRx = 0;
    float fromRy = 0;
    float fromAngle = 0;
    bool fromLargeArc = false;
    bool fromSweep = false;
    FloatPoint fromTargetPoint;
    float toRx = 0;
    float toRy = 0;
    float toAngle = 0;
    bool toLargeArc = false;
    bool toSweep = false;
    FloatPoint toTargetPoint;
    if ((m_fromSource->hasMoreData() && !m_fromSource->parseArcToSegment(fromRx, fromRy, fromAngle, fromLargeArc, fromSweep, fromTargetPoint))
        || !m_toSource->parseArcToSegment(toRx, toRy, toAngle, toLargeArc, toSweep, toTargetPoint))
        return false;

    if (m_addTypesCount) {
        ASSERT(m_fromMode == m_toMode);
        FloatPoint scaledToTargetPoint = toTargetPoint;
        scaledToTargetPoint.scale(m_addTypesCount, m_addTypesCount);
        m_consumer->arcTo(fromRx + toRx * m_addTypesCount,
                          fromRy + toRy * m_addTypesCount,
                          fromAngle + toAngle * m_addTypesCount,
                          fromLargeArc || toLargeArc,
                          fromSweep || toSweep,
                          fromTargetPoint + scaledToTargetPoint,
                          m_fromMode);
    } else {
        m_consumer->arcTo(blend(fromRx, toRx, m_progress),
                          blend(fromRy, toRy, m_progress),
                          blend(fromAngle, toAngle, m_progress),
                          m_isInFirstHalfOfAnimation ? fromLargeArc : toLargeArc,
                          m_isInFirstHalfOfAnimation ? fromSweep : toSweep,
                          blendAnimatedFloatPoint(fromTargetPoint, toTargetPoint),
                          m_isInFirstHalfOfAnimation ? m_fromMode : m_toMode);
    }
    m_fromCurrentPoint = m_fromMode == AbsoluteCoordinates ? fromTargetPoint : m_fromCurrentPoint + fromTargetPoint;
    m_toCurrentPoint = m_toMode == AbsoluteCoordinates ? toTargetPoint : m_toCurrentPoint + toTargetPoint;
    return true;
}
Exemplo n.º 6
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;
}