summaryrefslogtreecommitdiff
path: root/slideshow
diff options
context:
space:
mode:
authorMarco Cecchetti <mrcekets@gmail.com>2012-06-13 19:50:38 +0200
committerMarco Cecchetti <mrcekets@gmail.com>2012-06-28 12:28:06 +0200
commit372c47309a192e67220913309fa1ccffdff8cde1 (patch)
tree51c00837e31e21ea5f537c4114790b60a8e0488c /slideshow
parentb9cfef37900cea634dc6fb987498b840230399bd (diff)
Now to animations and repeated to animations are handled by the C++ presentation engine
as the SMIL spec describes.
Diffstat (limited to 'slideshow')
-rw-r--r--slideshow/source/engine/activities/activitiesfactory.cxx75
-rw-r--r--slideshow/source/engine/animationnodes/animationbasenode.cxx14
-rw-r--r--slideshow/source/engine/color.cxx25
-rw-r--r--slideshow/source/inc/hslcolor.hxx2
-rw-r--r--slideshow/source/inc/rgbcolor.hxx2
5 files changed, 108 insertions, 10 deletions
diff --git a/slideshow/source/engine/activities/activitiesfactory.cxx b/slideshow/source/engine/activities/activitiesfactory.cxx
index f142456b1562..a99a32a92041 100644
--- a/slideshow/source/engine/activities/activitiesfactory.cxx
+++ b/slideshow/source/engine/activities/activitiesfactory.cxx
@@ -167,6 +167,9 @@ public:
mpFormula( rParms.mpFormula ),
maStartValue(),
maEndValue(),
+ maPreviousValue(),
+ maStartInterpolationValue(),
+ mnIteration( 0 ),
mpAnim( rAnim ),
maInterpolator( rInterpolator ),
mbDynamicStartValue( false ),
@@ -220,6 +223,9 @@ public:
}
else
{
+ maStartValue = aAnimationStartValue;
+ maStartInterpolationValue = maStartValue;
+
// By or To animation. According to SMIL spec,
// the To value takes precedence over the By
// value, if both are specified
@@ -232,6 +238,7 @@ public:
// the to animation interpolates between
// the _running_ underlying value and the to value (as the end value)
mbDynamicStartValue = true;
+ maPreviousValue = maStartValue;
maEndValue = *maTo;
}
else if( maBy )
@@ -255,15 +262,61 @@ public:
{
if (this->isDisposed() || !mpAnim)
return;
- (*mpAnim)(
- getPresentationValue(
- accumulate( maEndValue,
- mbCumulative * nRepeatCount, // means: mbCumulative ? nRepeatCount : 0,
- maInterpolator( (mbDynamicStartValue
- ? mpAnim->getUnderlyingValue()
- : maStartValue),
- maEndValue,
- nModifiedTime ) ) ) );
+
+ // According to SMIL 3.0 spec 'to' animation if no other (lower priority)
+ // animations are active or frozen then a simple interpolation is performed.
+ // That is, the start interpolation value is constant while the animation
+ // is running, and is equal to the underlying value retrieved when
+ // the animation start.
+ // However if another animation is manipulating the underlying value,
+ // the 'to' animation will initially add to the effect of the lower priority
+ // 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;
@@ -316,6 +369,10 @@ private:
ValueType maStartValue;
ValueType maEndValue;
+ mutable ValueType maPreviousValue;
+ mutable ValueType maStartInterpolationValue;
+ mutable sal_uInt32 mnIteration;
+
::boost::shared_ptr< AnimationType > mpAnim;
Interpolator< ValueType > maInterpolator;
bool mbDynamicStartValue;
diff --git a/slideshow/source/engine/animationnodes/animationbasenode.cxx b/slideshow/source/engine/animationnodes/animationbasenode.cxx
index df1bcc5b9f83..ed6349522f22 100644
--- a/slideshow/source/engine/animationnodes/animationbasenode.cxx
+++ b/slideshow/source/engine/animationnodes/animationbasenode.cxx
@@ -33,6 +33,7 @@
#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/anytostring.hxx>
#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/AnimationAdditiveMode.hpp>
#include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
@@ -421,7 +422,18 @@ AnimationBaseNode::fillCommonParameters() const
else
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?
animations::Timing eTiming;
diff --git a/slideshow/source/engine/color.cxx b/slideshow/source/engine/color.cxx
index dc5092b1ef89..c9ce4f2a12c3 100644
--- a/slideshow/source/engine/color.cxx
+++ b/slideshow/source/engine/color.cxx
@@ -217,6 +217,19 @@ namespace slideshow
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 )
{
return HSLColor( rLHS.getHue() + rRHS.getHue(),
@@ -346,6 +359,18 @@ namespace slideshow
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 )
{
return RGBColor( rLHS.getRed() + rRHS.getRed(),
diff --git a/slideshow/source/inc/hslcolor.hxx b/slideshow/source/inc/hslcolor.hxx
index 66599232925f..15500c75988e 100644
--- a/slideshow/source/inc/hslcolor.hxx
+++ b/slideshow/source/inc/hslcolor.hxx
@@ -88,6 +88,8 @@ namespace slideshow
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*( double nFactor, const HSLColor& rRHS );
diff --git a/slideshow/source/inc/rgbcolor.hxx b/slideshow/source/inc/rgbcolor.hxx
index fc161f78a87c..844f324fd4cc 100644
--- a/slideshow/source/inc/rgbcolor.hxx
+++ b/slideshow/source/inc/rgbcolor.hxx
@@ -84,6 +84,8 @@ namespace slideshow
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*( double nFactor, const RGBColor& rRHS );