diff options
author | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-04-22 15:29:12 +0200 |
---|---|---|
committer | Matthias Huetsch [mhu] <matthias.huetsch@sun.com> | 2010-04-22 15:29:12 +0200 |
commit | e483e893b8b1dd980df9a23c813263e70f88abc7 (patch) | |
tree | abea067bcfdedabac1752e879a3d21ce96dbca3a /slideshow/source/engine/activities | |
parent | 7c3b569b76e1a1691c06b4cff8e81134570b8c37 (diff) | |
parent | b316ddbb7c819779c7fca6ef7a86dfe4fd66324a (diff) |
Update from master repository (DEV300m77).
Diffstat (limited to 'slideshow/source/engine/activities')
4 files changed, 30 insertions, 69 deletions
diff --git a/slideshow/source/engine/activities/activitybase.cxx b/slideshow/source/engine/activities/activitybase.cxx index 06cc0739fe6b..479715b5ccd8 100644 --- a/slideshow/source/engine/activities/activitybase.cxx +++ b/slideshow/source/engine/activities/activitybase.cxx @@ -159,7 +159,7 @@ namespace slideshow // ================================ // clamp nT to permissible [0,1] range - nT = ::canvas::tools::clamp( nT, 0.0, 1.0 ); + nT = ::basegfx::clamp( nT, 0.0, 1.0 ); // take acceleration/deceleration into account. if the sum // of mnAccelerationFraction and mnDecelerationFraction diff --git a/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx b/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx index 11a8463d87f3..5c6943614437 100644 --- a/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx +++ b/slideshow/source/engine/activities/continuouskeytimeactivitybase.cxx @@ -35,6 +35,7 @@ #include <continuouskeytimeactivitybase.hxx> +#include <boost/tuple/tuple.hpp> #include <algorithm> #include <iterator> @@ -45,34 +46,14 @@ namespace slideshow { ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase( const ActivityParameters& rParms ) : SimpleContinuousActivityBase( rParms ), - maKeyTimes( rParms.maDiscreteTimes ), - mnLastIndex( 0 ) + maLerper( rParms.maDiscreteTimes ) { - ENSURE_OR_THROW( maKeyTimes.size() > 1, + ENSURE_OR_THROW( rParms.maDiscreteTimes.size() > 1, "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector must have two entries or more" ); - -#ifdef DBG_UTIL - // check parameters: rKeyTimes must be sorted in - // ascending order, and contain values only from the range - // [0,1] - for( ::std::size_t i=1, len=maKeyTimes.size(); i<len; ++i ) - { - if( maKeyTimes[i] < 0.0 || - maKeyTimes[i] > 1.0 || - maKeyTimes[i-1] < 0.0 || - maKeyTimes[i-1] > 1.0 ) - { - ENSURE_OR_THROW( false, "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): time values not within [0,1] range!" ); - } - - if( maKeyTimes[i-1] > maKeyTimes[i] ) - { - ENSURE_OR_THROW( false, "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): time vector is not sorted in ascending order!" ); - } - } - - // TODO(E2): check this also in production code? -#endif + ENSURE_OR_THROW( rParms.maDiscreteTimes.front() == 0.0, + "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector first entry must be zero" ); + ENSURE_OR_THROW( rParms.maDiscreteTimes.back() <= 1.0, + "ContinuousKeyTimeActivityBase::ContinuousKeyTimeActivityBase(): key times vector last entry must be less or equal 1" ); } void ContinuousKeyTimeActivityBase::simplePerform( double nSimpleTime, @@ -81,40 +62,14 @@ namespace slideshow // calc simple time from global time - sweep through the // array multiple times for repeated animations (according to // SMIL spec). - const double nT( calcAcceleratedTime( nSimpleTime ) ); - - // determine position within key times vector from - // current simple time - - // shortcut: cached value still okay? - if( maKeyTimes[ mnLastIndex ] < nT || - maKeyTimes[ mnLastIndex+1 ] >= nT ) - { - // nope, find new index - mnLastIndex = ::std::min< ::std::ptrdiff_t >( - maKeyTimes.size()-2, - // range is ensured by max below - ::std::max< ::std::ptrdiff_t >( - 0, - ::std::distance( maKeyTimes.begin(), - ::std::lower_bound( maKeyTimes.begin(), - maKeyTimes.end(), - nT ) ) - 1 ) ); - } - - OSL_ENSURE( mnLastIndex+1 < maKeyTimes.size(), - "ContinuousKeyTimeActivityBase::simplePerform(): index out of range" ); - - // mnLastIndex is now valid and up-to-date + double fAlpha( calcAcceleratedTime( nSimpleTime ) ); + std::ptrdiff_t nIndex; - // calc current simple time, as a fractional value ([0,1] range). - // I.e. the relative position between the two index times. - const double nCurrFractionalSimplTime( (nT - maKeyTimes[ mnLastIndex ]) / - (maKeyTimes[ mnLastIndex+1 ] - maKeyTimes[ mnLastIndex ]) ); + boost::tuples::tie(nIndex,fAlpha) = maLerper.lerp(fAlpha); perform( - mnLastIndex, - nCurrFractionalSimplTime, + nIndex, + fAlpha, nRepeatCount ); } } diff --git a/slideshow/source/engine/activities/continuouskeytimeactivitybase.hxx b/slideshow/source/engine/activities/continuouskeytimeactivitybase.hxx index a0267188a02d..cb851bab3730 100644 --- a/slideshow/source/engine/activities/continuouskeytimeactivitybase.hxx +++ b/slideshow/source/engine/activities/continuouskeytimeactivitybase.hxx @@ -29,6 +29,8 @@ #define INCLUDED_SLIDESHOW_CONTINUOUSKEYTIMEACTIVITYBASE_HXX #include "simplecontinuousactivitybase.hxx" + +#include <basegfx/tools/keystoplerp.hxx> #include <vector> @@ -73,10 +75,7 @@ namespace slideshow sal_uInt32 nRepeatCount ) const; private: - const ::std::vector< double > maKeyTimes; - - /// last active index in maKeyTimes (to avoid frequent searching) - mutable ::std::size_t mnLastIndex; + const ::basegfx::tools::KeyStopLerp maLerper; }; } } diff --git a/slideshow/source/engine/activities/interpolation.hxx b/slideshow/source/engine/activities/interpolation.hxx index 620a019f661d..9409965c8846 100644 --- a/slideshow/source/engine/activities/interpolation.hxx +++ b/slideshow/source/engine/activities/interpolation.hxx @@ -28,11 +28,11 @@ #ifndef INCLUDED_SLIDESHOW_INTERPOLATION_HXX #define INCLUDED_SLIDESHOW_INTERPOLATION_HXX -#include "lerp.hxx" +#include <basegfx/tools/lerp.hxx> -namespace slideshow +namespace basegfx { - namespace internal + namespace tools { // Interpolator specializations // ============================ @@ -42,9 +42,10 @@ namespace slideshow // not-straight-forward-interpolatable types /// Specialization for RGBColor, to employ color-specific interpolator - template<> RGBColor lerp< RGBColor >( const RGBColor& rFrom, - const RGBColor& rTo, - double t ) + template<> ::slideshow::internal::RGBColor lerp< ::slideshow::internal::RGBColor >( + const ::slideshow::internal::RGBColor& rFrom, + const ::slideshow::internal::RGBColor& rTo, + double t ) { return interpolate( rFrom, rTo, t ); } @@ -78,14 +79,20 @@ namespace slideshow "lerp<bool> called" ); return rTo; } + } +} +namespace slideshow +{ + namespace internal + { template< typename ValueType > struct Interpolator { ValueType operator()( const ValueType& rFrom, const ValueType& rTo, double t ) const { - return lerp( rFrom, rTo, t ); + return basegfx::tools::lerp( rFrom, rTo, t ); } }; |