bool SVGAnimateElement::isAdditive() { if (animationMode() == ByAnimation || animationMode() == FromByAnimation) if (!animatedPropertyTypeSupportsAddition()) return false; return SVGAnimationElement::isAdditive(); }
void SVGAnimationElement::calculateKeyTimesForCalcModePaced() { ASSERT(calcMode() == CalcModePaced); ASSERT(animationMode() == ValuesAnimation); unsigned valuesCount = m_values.size(); ASSERT(valuesCount >= 1); if (valuesCount == 1) return; // FIXME, webkit.org/b/109010: m_keyTimes should not be modified in this function. m_keyTimes.clear(); Vector<float> keyTimesForPaced; float totalDistance = 0; keyTimesForPaced.append(0); for (unsigned n = 0; n < valuesCount - 1; ++n) { // Distance in any units float distance = calculateDistance(m_values[n], m_values[n + 1]); if (distance < 0) return; totalDistance += distance; keyTimesForPaced.append(distance); } if (!totalDistance) return; // Normalize. for (unsigned n = 1; n < keyTimesForPaced.size() - 1; ++n) keyTimesForPaced[n] = keyTimesForPaced[n - 1] + keyTimesForPaced[n] / totalDistance; keyTimesForPaced[keyTimesForPaced.size() - 1] = 1; // Use key times calculated based on pacing instead of the user provided ones. m_keyTimes = keyTimesForPaced; }
void SVGAnimationElement::updateAnimation(float percent, unsigned repeat, SVGSMILElement *resultElement) { if (!m_animationValid) { return; } float effectivePercent; if (animationMode() == ValuesAnimation) { String from; String to; currentValuesForValuesAnimation(percent, effectivePercent, from, to); if (from != m_lastValuesAnimationFrom || to != m_lastValuesAnimationTo) { m_animationValid = calculateFromAndToValues(from, to); if (!m_animationValid) { return; } m_lastValuesAnimationFrom = from; m_lastValuesAnimationTo = to; } } else if (!m_keyPoints.isEmpty() && calcMode() != CalcModePaced) { effectivePercent = calculatePercentFromKeyPoints(percent); } else { effectivePercent = percent; } calculateAnimatedValue(effectivePercent, repeat, resultElement); }
void SVGAnimationElement::calculateKeyTimesForCalcModePaced() { ASSERT(calcMode() == CalcModePaced); ASSERT(animationMode() == ValuesAnimation); unsigned valuesCount = m_values.size(); ASSERT(valuesCount > 1); Vector<float> keyTimesForPaced; float totalDistance = 0; keyTimesForPaced.append(0); for (unsigned n = 0; n < valuesCount - 1; ++n) { // Distance in any units float distance = calculateDistance(m_values[n], m_values[n + 1]); if (distance < 0) { return; } totalDistance += distance; keyTimesForPaced.append(distance); } if (!totalDistance) { return; } // Normalize. for (unsigned n = 1; n < keyTimesForPaced.size() - 1; ++n) { keyTimesForPaced[n] = keyTimesForPaced[n - 1] + keyTimesForPaced[n] / totalDistance; } keyTimesForPaced[keyTimesForPaced.size() - 1] = 1.f; // Use key times calculated based on pacing instead of the user provided ones. m_keyTimes.swap(keyTimesForPaced); }
bool SVGAnimateElement::isAdditive() const { if (animationMode() == ByAnimation || animationMode() == FromByAnimation) { // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties. switch (m_animatedPropertyType) { case AnimatedBoolean: case AnimatedEnumeration: case AnimatedPreserveAspectRatio: case AnimatedString: case AnimatedUnknown: return false; default: break; } } return SVGAnimationElement::isAdditive(); }
bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString) { SVGElement* targetElement = this->targetElement(); if (!targetElement) return false; if (animationMode() == ByAnimation && !isAdditive()) return false; // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes). if (animationMode() == FromByAnimation && !animatedPropertyTypeSupportsAddition()) return false; ASSERT(!isSVGSetElement(*this)); determinePropertyValueTypes(fromString, byString); ensureAnimator()->calculateFromAndByValues(m_fromProperty, m_toProperty, fromString, byString); return true; }
bool SVGAnimateMotionElement::calculateFromAndByValues(const String& fromString, const String& byString) { m_hasToPointAtEndOfDuration = false; if (animationMode() == ByAnimation && !isAdditive()) return false; parsePoint(fromString, m_fromPoint); FloatPoint byPoint; parsePoint(byString, byPoint); m_toPoint = FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y()); return true; }
bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, const String& byString) { SVGElement* targetElement = this->targetElement(); if (!targetElement) return false; if (animationMode() == ByAnimation && !isAdditive()) return false; ASSERT(!hasTagName(SVGNames::setTag)); determinePropertyValueTypes(fromString, byString); ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString); ASSERT(m_animatedPropertyType == m_animator->type()); return true; }
// run() is the interrupt function void displayBuffer::run() { displayOff(); switch(mode) { case OFF: break; case CLOCK: clockMode(); break; case ANIMATION: animationMode(); break; } }
void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement*) { SVGElement* targetElement = this->targetElement(); if (!targetElement) return; AffineTransform* transform = targetElement->supplementalTransform(); if (!transform) return; if (RenderObject* targetRenderer = targetElement->renderer()) targetRenderer->setNeedsTransformUpdate(); if (!isAdditive()) transform->makeIdentity(); if (animationMode() != PathAnimation) { FloatPoint toPointAtEndOfDuration = m_toPoint; if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration) toPointAtEndOfDuration = m_toPointAtEndOfDuration; float animatedX = 0; animateAdditiveNumber(percentage, repeatCount, m_fromPoint.x(), m_toPoint.x(), toPointAtEndOfDuration.x(), animatedX); float animatedY = 0; animateAdditiveNumber(percentage, repeatCount, m_fromPoint.y(), m_toPoint.y(), toPointAtEndOfDuration.y(), animatedY); transform->translate(animatedX, animatedY); return; } buildTransformForProgress(transform, percentage); // Handle accumulate="sum". if (isAccumulated() && repeatCount) { for (unsigned i = 0; i < repeatCount; ++i) buildTransformForProgress(transform, 1); } }
void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned, SVGSMILElement*) { SVGElement* targetElement = this->targetElement(); if (!targetElement) return; AffineTransform* transform = targetElement->supplementalTransform(); if (!transform) return; if (RenderObject* targetRenderer = targetElement->renderer()) targetRenderer->setNeedsTransformUpdate(); if (!isAdditive()) transform->makeIdentity(); // FIXME: Implement accumulate. if (animationMode() == PathAnimation) { ASSERT(!animationPath().isEmpty()); Path path = animationPath(); float positionOnPath = path.length() * percentage; bool ok; FloatPoint position = path.pointAtLength(positionOnPath, ok); if (ok) { transform->translate(position.x(), position.y()); RotateMode rotateMode = this->rotateMode(); if (rotateMode == RotateAuto || rotateMode == RotateAutoReverse) { float angle = path.normalAngleAtLength(positionOnPath, ok); if (rotateMode == RotateAutoReverse) angle += 180; transform->rotate(angle); } } return; } FloatSize diff = m_toPoint - m_fromPoint; transform->translate(diff.width() * percentage + m_fromPoint.x(), diff.height() * percentage + m_fromPoint.y()); }
bool SVGAnimationElement::isAdditive() const { static const AtomicString sum("sum"); const AtomicString &value = getAttribute(SVGNames::additiveAttr); return value == sum || animationMode() == ByAnimation; }
bool SVGAnimationElement::isAdditive() const { static NeverDestroyed<const AtomicString> sum("sum", AtomicString::ConstructFromLiteral); const AtomicString& value = attributeWithoutSynchronization(SVGNames::additiveAttr); return value == sum || animationMode() == ByAnimation; }
bool SVGAnimationElement::isAccumulated() const { DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::ConstructFromLiteral)); const AtomicString& value = fastGetAttribute(SVGNames::accumulateAttr); return value == sum && animationMode() != ToAnimation; }
bool SVGAnimationElement::isAdditive() const { DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, sum, ("sum", AtomicString::ConstructFromLiteral)); const AtomicString& value = fastGetAttribute(SVGNames::additiveAttr); return value == sum || animationMode() == ByAnimation; }
bool SVGAnimationElement::isAccumulated() const { static NeverDestroyed<const AtomicString> sum("sum", AtomicString::ConstructFromLiteral); const AtomicString& value = attributeWithoutSynchronization(SVGNames::accumulateAttr); return value == sum && animationMode() != ToAnimation; }
bool SVGAnimationElement::isAccumulated() const { static const AtomicString sum("sum"); const AtomicString &value = getAttribute(SVGNames::accumulateAttr); return value == sum && animationMode() != ToAnimation; }