Пример #1
0
void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned, OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated)
{
    ASSERT(m_animationElement);
    ASSERT(m_contextElement);

    SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
    AnimationMode animationMode = animationElement->animationMode();

    SVGPathByteStream* toPath = to->path();
    ASSERT(toPath);

    SVGPathByteStream* fromPath = from->path();
    ASSERT(fromPath);

    SVGPathByteStream* animatedPath = animated->path();
    ASSERT(animatedPath);

    if (animationMode == ToAnimation)
        fromPath->initializeFrom(animatedPath);

    if (!percentage) {
        animatedPath->initializeFrom(fromPath);
        return;
    }

    if (percentage == 1) {
        animatedPath->initializeFrom(toPath);
        return;
    }

    OwnPtr<SVGPathByteStream> newAnimatedPath = adoptPtr(animatedPath);
    bool success = SVGPathParserFactory::self()->buildAnimatedSVGPathByteStream(fromPath, toPath, newAnimatedPath, percentage);
    animatedPath = newAnimatedPath.leakPtr();
    if (success)
        return;

    if ((animationMode == FromToAnimation && percentage > 0.5) || animationMode == ToAnimation)
        animatedPath->initializeFrom(toPath);
    else
        animatedPath->initializeFrom(fromPath);
}