Kaydet (Commit) 372c4730 authored tarafından Marco Cecchetti's avatar Marco Cecchetti

Now to animations and repeated to animations are handled by the C++ presentation engine

as the SMIL spec describes.
üst b9cfef37
...@@ -167,6 +167,9 @@ public: ...@@ -167,6 +167,9 @@ public:
mpFormula( rParms.mpFormula ), mpFormula( rParms.mpFormula ),
maStartValue(), maStartValue(),
maEndValue(), maEndValue(),
maPreviousValue(),
maStartInterpolationValue(),
mnIteration( 0 ),
mpAnim( rAnim ), mpAnim( rAnim ),
maInterpolator( rInterpolator ), maInterpolator( rInterpolator ),
mbDynamicStartValue( false ), mbDynamicStartValue( false ),
...@@ -220,6 +223,9 @@ public: ...@@ -220,6 +223,9 @@ public:
} }
else else
{ {
maStartValue = aAnimationStartValue;
maStartInterpolationValue = maStartValue;
// By or To animation. According to SMIL spec, // By or To animation. According to SMIL spec,
// the To value takes precedence over the By // the To value takes precedence over the By
// value, if both are specified // value, if both are specified
...@@ -232,6 +238,7 @@ public: ...@@ -232,6 +238,7 @@ public:
// the to animation interpolates between // the to animation interpolates between
// the _running_ underlying value and the to value (as the end value) // the _running_ underlying value and the to value (as the end value)
mbDynamicStartValue = true; mbDynamicStartValue = true;
maPreviousValue = maStartValue;
maEndValue = *maTo; maEndValue = *maTo;
} }
else if( maBy ) else if( maBy )
...@@ -255,15 +262,61 @@ public: ...@@ -255,15 +262,61 @@ public:
{ {
if (this->isDisposed() || !mpAnim) if (this->isDisposed() || !mpAnim)
return; return;
(*mpAnim)(
getPresentationValue( // According to SMIL 3.0 spec 'to' animation if no other (lower priority)
accumulate( maEndValue, // animations are active or frozen then a simple interpolation is performed.
mbCumulative * nRepeatCount, // means: mbCumulative ? nRepeatCount : 0, // That is, the start interpolation value is constant while the animation
maInterpolator( (mbDynamicStartValue // is running, and is equal to the underlying value retrieved when
? mpAnim->getUnderlyingValue() // the animation start.
: maStartValue), // However if another animation is manipulating the underlying value,
maEndValue, // the 'to' animation will initially add to the effect of the lower priority
nModifiedTime ) ) ) ); // animation, and increasingly dominate it as it nears the end of the
// simple duration, eventually overriding it completely.
// That is, each time the underlying value is changed between two
// computations of the animation function the new underlying value is used
// as start value for the interpolation.
// See:
// http://www.w3.org/TR/SMIL3/smil-animation.html#animationNS-ToAnimation
// (Figure 6 - Effect of Additive to animation example)
// Moreover when a 'to' animation is repeated, at each new iteration
// the start interpolation value is reset to the underlying value
// of the animated property when the animation started,
// as it is shown in the example provided by the SMIL 3.0 spec.
// This is exactly as Firefox performs SVG 'to' animations.
if( mbDynamicStartValue )
{
if( mnIteration != nRepeatCount )
{
mnIteration = nRepeatCount;
maStartInterpolationValue = maStartValue;
}
else
{
ValueType aActualValue = mpAnim->getUnderlyingValue();
if( aActualValue != maPreviousValue )
maStartInterpolationValue = aActualValue;
}
}
ValueType aValue = maInterpolator( maStartInterpolationValue,
maEndValue, nModifiedTime );
// According to the SMIL spec:
// Because 'to' animation is defined in terms of absolute values of
// the target attribute, cumulative animation is not defined.
if( mbCumulative && !mbDynamicStartValue )
{
// aValue = this.aEndValue * nRepeatCount + aValue;
aValue = accumulate( maEndValue, nRepeatCount, aValue );
}
(*mpAnim)( getPresentationValue( aValue ) );
if( mbDynamicStartValue )
{
maPreviousValue = mpAnim->getUnderlyingValue();
}
} }
using BaseType::perform; using BaseType::perform;
...@@ -316,6 +369,10 @@ private: ...@@ -316,6 +369,10 @@ private:
ValueType maStartValue; ValueType maStartValue;
ValueType maEndValue; ValueType maEndValue;
mutable ValueType maPreviousValue;
mutable ValueType maStartInterpolationValue;
mutable sal_uInt32 mnIteration;
::boost::shared_ptr< AnimationType > mpAnim; ::boost::shared_ptr< AnimationType > mpAnim;
Interpolator< ValueType > maInterpolator; Interpolator< ValueType > maInterpolator;
bool mbDynamicStartValue; bool mbDynamicStartValue;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <comphelper/anytostring.hxx> #include <comphelper/anytostring.hxx>
#include <com/sun/star/presentation/ParagraphTarget.hpp> #include <com/sun/star/presentation/ParagraphTarget.hpp>
#include <com/sun/star/animations/AnimationNodeType.hpp>
#include <com/sun/star/animations/Timing.hpp> #include <com/sun/star/animations/Timing.hpp>
#include <com/sun/star/animations/AnimationAdditiveMode.hpp> #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
#include <com/sun/star/presentation/ShapeAnimationSubType.hpp> #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
...@@ -421,7 +422,18 @@ AnimationBaseNode::fillCommonParameters() const ...@@ -421,7 +422,18 @@ AnimationBaseNode::fillCommonParameters() const
else else
aRepeats.reset( nRepeats / nDuration ); aRepeats.reset( nRepeats / nDuration );
} }
else { // This is a temporary workaround:
// as the repeatCount attribute is defined on the <par> parent node
// and activities are created only for animation node leaves, that
// actual performs a shape effect, we get the repeatCount value
// from the parent node.
else if( ( getXAnimationNode()->getType() != animations::AnimationNodeType::SET )
&& (getParentNode()->getXAnimationNode()->getRepeatCount() >>= nRepeats) )
{
aRepeats.reset( nRepeats );
}
else
{
// no double value for both values - Timing::INDEFINITE? // no double value for both values - Timing::INDEFINITE?
animations::Timing eTiming; animations::Timing eTiming;
......
...@@ -217,6 +217,19 @@ namespace slideshow ...@@ -217,6 +217,19 @@ namespace slideshow
return maHSLTriple.mnLuminance; return maHSLTriple.mnLuminance;
} }
sal_Bool operator==( const HSLColor& rLHS, const HSLColor& rRHS )
{
return ( rLHS.getHue() == rRHS.getHue() &&
rLHS.getSaturation() == rRHS.getSaturation() &&
rLHS.getLuminance() == rRHS.getLuminance() );
}
sal_Bool operator!=( const HSLColor& rLHS, const HSLColor& rRHS )
{
return !( rLHS == rRHS );
}
HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS ) HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS )
{ {
return HSLColor( rLHS.getHue() + rRHS.getHue(), return HSLColor( rLHS.getHue() + rRHS.getHue(),
...@@ -346,6 +359,18 @@ namespace slideshow ...@@ -346,6 +359,18 @@ namespace slideshow
255 ); 255 );
} }
sal_Bool operator==( const RGBColor& rLHS, const RGBColor& rRHS )
{
return ( rLHS.getRed() == rRHS.getRed() &&
rLHS.getGreen() == rRHS.getGreen() &&
rLHS.getBlue() == rRHS.getBlue() );
}
sal_Bool operator!=( const RGBColor& rLHS, const RGBColor& rRHS )
{
return !( rLHS == rRHS );
}
RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS ) RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS )
{ {
return RGBColor( rLHS.getRed() + rRHS.getRed(), return RGBColor( rLHS.getRed() + rRHS.getRed(),
......
...@@ -88,6 +88,8 @@ namespace slideshow ...@@ -88,6 +88,8 @@ namespace slideshow
double mnMagicValue; double mnMagicValue;
}; };
sal_Bool operator==( const HSLColor& rLHS, const HSLColor& rRHS );
sal_Bool operator!=( const HSLColor& rLHS, const HSLColor& rRHS );
HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS ); HSLColor operator+( const HSLColor& rLHS, const HSLColor& rRHS );
HSLColor operator*( const HSLColor& rLHS, const HSLColor& rRHS ); HSLColor operator*( const HSLColor& rLHS, const HSLColor& rRHS );
HSLColor operator*( double nFactor, const HSLColor& rRHS ); HSLColor operator*( double nFactor, const HSLColor& rRHS );
......
...@@ -84,6 +84,8 @@ namespace slideshow ...@@ -84,6 +84,8 @@ namespace slideshow
RGBTriple maRGBTriple; RGBTriple maRGBTriple;
}; };
sal_Bool operator==( const RGBColor& rLHS, const RGBColor& rRHS );
sal_Bool operator!=( const RGBColor& rLHS, const RGBColor& rRHS );
RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS ); RGBColor operator+( const RGBColor& rLHS, const RGBColor& rRHS );
RGBColor operator*( const RGBColor& rLHS, const RGBColor& rRHS ); RGBColor operator*( const RGBColor& rLHS, const RGBColor& rRHS );
RGBColor operator*( double nFactor, const RGBColor& rRHS ); RGBColor operator*( double nFactor, const RGBColor& rRHS );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment