diff options
Diffstat (limited to 'WebCore/svg/SVGAnimateElement.cpp')
-rw-r--r-- | WebCore/svg/SVGAnimateElement.cpp | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp index 2723804..df0c3bc 100644 --- a/WebCore/svg/SVGAnimateElement.cpp +++ b/WebCore/svg/SVGAnimateElement.cpp @@ -42,6 +42,7 @@ SVGAnimateElement::SVGAnimateElement(const QualifiedName& tagName, Document* doc , m_fromNumber(0) , m_toNumber(0) , m_animatedNumber(numeric_limits<double>::infinity()) + , m_animatedPathPointer(0) { } @@ -131,19 +132,31 @@ void SVGAnimateElement::calculateAnimatedValue(float percentage, unsigned repeat } AnimationMode animationMode = this->animationMode(); if (m_propertyType == PathProperty) { - if (percentage == 0) - results->m_animatedPath = m_fromPath; - else if (percentage == 1.f) - results->m_animatedPath = m_toPath; - else { - if (m_fromPath && m_toPath) - results->m_animatedPath = SVGPathSegList::createAnimated(m_fromPath.get(), m_toPath.get(), percentage); - else - results->m_animatedPath.clear(); + if (!percentage) { + ASSERT(m_fromPath); + ASSERT(percentage >= 0); + results->m_animatedPathPointer = m_fromPath.get(); + } else if (percentage == 1.f) { + ASSERT(m_toPath); + results->m_animatedPathPointer = m_toPath.get(); + } else { + if (m_fromPath && m_toPath) { + SVGPathParserFactory* factory = SVGPathParserFactory::self(); + if (!factory->buildAnimatedSVGPathByteStream(m_fromPath.get(), m_toPath.get(), results->m_animatedPath, percentage)) { + results->m_animatedPath.clear(); + results->m_animatedPathPointer = 0; + } else + results->m_animatedPathPointer = results->m_animatedPath.get(); + } else + results->m_animatedPathPointer = 0; // Fall back to discrete animation if the paths are not compatible - if (!results->m_animatedPath) - results->m_animatedPath = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f) - ? m_toPath : m_fromPath; + if (!results->m_animatedPathPointer) { + ASSERT(m_fromPath); + ASSERT(m_toPath); + ASSERT(!results->m_animatedPath); + results->m_animatedPathPointer = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f) + ? m_toPath.get() : m_fromPath.get(); + } } return; } else if (m_propertyType == PointsProperty) { @@ -189,11 +202,9 @@ bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, const return true; } } else if (m_propertyType == PathProperty) { - m_fromPath = SVGPathSegList::create(SVGNames::dAttr); SVGPathParserFactory* factory = SVGPathParserFactory::self(); - if (factory->buildSVGPathSegListFromString(fromString, m_fromPath.get(), UnalteredParsing)) { - m_toPath = SVGPathSegList::create(SVGNames::dAttr); - if (factory->buildSVGPathSegListFromString(toString, m_toPath.get(), UnalteredParsing)) + if (factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing)) { + if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing)) return true; } m_fromPath.clear(); @@ -256,6 +267,7 @@ void SVGAnimateElement::resetToBaseValue(const String& baseString) return; } else if (m_propertyType == PathProperty) { m_animatedPath.clear(); + m_animatedPathPointer = 0; return; } else if (m_propertyType == PointsProperty) { m_animatedPoints.clear(); @@ -272,7 +284,7 @@ void SVGAnimateElement::applyResultsToTarget() else if (m_propertyType == NumberProperty) valueToApply = String::number(m_animatedNumber) + m_numberUnit; else if (m_propertyType == PathProperty) { - if (!m_animatedPath || !m_animatedPath->numberOfItems()) + if (!m_animatedPathPointer || m_animatedPathPointer->isEmpty()) valueToApply = m_animatedString; else { // We need to keep going to string and back because we are currently only able to paint @@ -280,7 +292,7 @@ void SVGAnimateElement::applyResultsToTarget() // morphing needs to be done with unprocessed paths. // FIXME: This could be optimized if paths were not processed at parse time. SVGPathParserFactory* factory = SVGPathParserFactory::self(); - factory->buildStringFromSVGPathSegList(m_animatedPath.get(), valueToApply, UnalteredParsing); + factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing); } } else if (m_propertyType == PointsProperty) { if (!m_animatedPoints || !m_animatedPoints->numberOfItems()) |