[Libreoffice-commits] .: slideshow/source

David Tardon dtardon at kemper.freedesktop.org
Tue Aug 14 06:16:40 PDT 2012


 slideshow/source/engine/transitions/slidechangebase.cxx        |   10 +
 slideshow/source/engine/transitions/slidechangebase.hxx        |   12 +
 slideshow/source/engine/transitions/slidetransitionfactory.cxx |   95 +++++-----
 3 files changed, 71 insertions(+), 46 deletions(-)

New commits:
commit 2e8b2e6de14d325863d9bc419a461b75c3aaf3d0
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Aug 14 14:44:18 2012 +0200

    fix "uncover" slide transitions with presenter console
    
    It turns out it is really not a good idea to render _anything_ on the
    first run of performIn/performOut in classes derived from
    SlideChangeBase. That is because the functions are called separetely for
    every view, so, if there is more than one view, like when the presenter
    console is active, it will be done only for the first of them. This
    commit introduces another function, prepareForRun, that can be used
    reliably for that purpose.
    
    Change-Id: I2c690fb145ccc05a680d4c2991c73900336e6f42

diff --git a/slideshow/source/engine/transitions/slidechangebase.cxx b/slideshow/source/engine/transitions/slidechangebase.cxx
index 3b9c70d..56d7887 100644
--- a/slideshow/source/engine/transitions/slidechangebase.cxx
+++ b/slideshow/source/engine/transitions/slidechangebase.cxx
@@ -199,6 +199,10 @@ void SlideChangeBase::start( const AnimatableShapeSharedPtr&     rShape,
 
     prefetch(rShape,rLayer); // no-op, if already done
 
+    // get the subclasses a chance to do any specific initialization before run
+    for ( ViewsVecT::const_iterator aCurr( beginViews() ), aEnd( endViews() ); aCurr != aEnd; ++aCurr )
+        prepareForRun( *aCurr, aCurr->mpView->getCanvas() );
+
     // start accompanying sound effect, if any
     if( mpSoundPlayer )
     {
@@ -356,6 +360,12 @@ bool SlideChangeBase::operator()( double nValue )
     return true;
 }
 
+void SlideChangeBase::prepareForRun(
+    const ViewEntry& /* rViewEntry */,
+    const boost::shared_ptr<cppcanvas::Canvas>& /* rDestinationCanvas */ )
+{
+}
+
 void SlideChangeBase::performIn(
     const cppcanvas::CustomSpriteSharedPtr&   /*rSprite*/,
     const ViewEntry&                          /*rViewEntry*/,
diff --git a/slideshow/source/engine/transitions/slidechangebase.hxx b/slideshow/source/engine/transitions/slidechangebase.hxx
index 586bc8e..396c03a 100644
--- a/slideshow/source/engine/transitions/slidechangebase.hxx
+++ b/slideshow/source/engine/transitions/slidechangebase.hxx
@@ -126,6 +126,18 @@ protected:
     void renderBitmap( SlideBitmapSharedPtr const&                 pSlideBitmap,
                        boost::shared_ptr<cppcanvas::Canvas> const& pCanvas );
 
+    /** Called on derived classes to perform actions before first run.
+
+        This typically involves rendering of the initial slide content.
+
+        @param rViewEntry the view entry
+
+        @param rDestinationCanvas the canvas to render on
+     */
+    virtual void prepareForRun(
+            const ViewEntry& rViewEntry,
+            const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
+
     /** Called on derived classes to implement actual slide change.
 
         This method is called with the sprite of the slide coming 'in'
diff --git a/slideshow/source/engine/transitions/slidetransitionfactory.cxx b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
index 47491c1..f61a5da 100644
--- a/slideshow/source/engine/transitions/slidetransitionfactory.cxx
+++ b/slideshow/source/engine/transitions/slidetransitionfactory.cxx
@@ -393,10 +393,13 @@ public:
                            rViewContainer,
                            rScreenUpdater,
                            rEventMultiplexer ),
-          maFadeColor( rFadeColor ),
-          mbFirstTurn( true )
+          maFadeColor( rFadeColor )
         {}
 
+    virtual void prepareForRun(
+        const ViewEntry& rViewEntry,
+        const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
+
     virtual void performIn(
         const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
         const ViewEntry&                            rViewEntry,
@@ -411,9 +414,19 @@ public:
 
 private:
     const boost::optional< RGBColor >               maFadeColor;
-    bool                                            mbFirstTurn;
 };
 
+void FadingSlideChange::prepareForRun(
+    const ViewEntry& rViewEntry,
+    const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
+{
+    // clear page to given fade color. 'Leaving' slide is
+    // painted atop of that, but slowly fading out.
+    fillPage( rDestinationCanvas,
+              ::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
+              *maFadeColor );
+}
+
 void FadingSlideChange::performIn(
     const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
     const ViewEntry&                            /*rViewEntry*/,
@@ -434,7 +447,7 @@ void FadingSlideChange::performIn(
 
 void FadingSlideChange::performOut(
     const ::cppcanvas::CustomSpriteSharedPtr&  rSprite,
-    const ViewEntry&                           rViewEntry,
+    const ViewEntry&                           /* rViewEntry */,
     const ::cppcanvas::CanvasSharedPtr&        rDestinationCanvas,
     double                                     t )
 {
@@ -448,17 +461,6 @@ void FadingSlideChange::performOut(
     // only needed for color fades
     if( maFadeColor )
     {
-        if( mbFirstTurn )
-        {
-            mbFirstTurn = false;
-
-            // clear page to given fade color. 'Leaving' slide is
-            // painted atop of that, but slowly fading out.
-            fillPage( rDestinationCanvas,
-                      ::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
-                      *maFadeColor );
-        }
-
         // Until half of the active time, fade out old
         // slide. After half of the active time, old slide
         // will be invisible.
@@ -486,10 +488,13 @@ public:
                            rViewContainer,
                            rScreenUpdater,
                            rEventMultiplexer ),
-          maFadeColor( rFadeColor ),
-          mbFirstTurn( true )
+          maFadeColor( rFadeColor )
         {}
 
+    virtual void prepareForRun(
+        const ViewEntry& rViewEntry,
+        const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
+
     virtual void performIn(
         const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
         const ViewEntry&                            rViewEntry,
@@ -504,9 +509,19 @@ public:
 
 private:
     RGBColor maFadeColor;
-    bool    mbFirstTurn;
 };
 
+void CutSlideChange::prepareForRun(
+    const ViewEntry& rViewEntry,
+    const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
+{
+    // clear page to given fade color. 'Leaving' slide is
+    // painted atop of that
+    fillPage( rDestinationCanvas,
+              ::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
+              maFadeColor );
+}
+
 void CutSlideChange::performIn(
     const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
     const ViewEntry&                            /*rViewEntry*/,
@@ -523,7 +538,7 @@ void CutSlideChange::performIn(
 
 void CutSlideChange::performOut(
     const ::cppcanvas::CustomSpriteSharedPtr&  rSprite,
-    const ViewEntry&                           rViewEntry,
+    const ViewEntry&                           /* rViewEntry */,
     const ::cppcanvas::CanvasSharedPtr&        rDestinationCanvas,
     double                                     t )
 {
@@ -534,17 +549,6 @@ void CutSlideChange::performOut(
         rDestinationCanvas,
         "FadingSlideChange::performOut(): Invalid dest canvas" );
 
-    if( mbFirstTurn )
-    {
-        mbFirstTurn = false;
-
-        // clear page to given fade color. 'Leaving' slide is
-        // painted atop of that
-        fillPage( rDestinationCanvas,
-                  ::basegfx::B2DSize( getEnteringSlideSizePixel( rViewEntry.mpView ) ),
-                  maFadeColor );
-    }
-
     // Until 1/3rd of the active time, display old slide.
     rSprite->setAlpha( t > 1/3.0 ? 0.0 : 1.0 );
 }
@@ -557,8 +561,6 @@ class MovingSlideChange : public SlideChangeBase
     /// Direction vector for entering slide,
     const ::basegfx::B2DVector  maEnteringDirection;
 
-    bool                        mbFirstPerformCall;
-
 public:
     /** Create a new SlideChanger, for the given entering slide
         bitmaps, which performes a moving slide change effect
@@ -600,10 +602,13 @@ public:
           // TODO(F1): calc correct length of direction
           // vector. Directions not strictly horizontal or vertical
           // must travel a longer distance.
-          maEnteringDirection( rEnteringDirection ),
-          mbFirstPerformCall( true )
+          maEnteringDirection( rEnteringDirection )
         {}
 
+    virtual void prepareForRun(
+        const ViewEntry& rViewEntry,
+        const cppcanvas::CanvasSharedPtr& rDestinationCanvas );
+
     virtual void performIn(
         const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
         const ViewEntry&                            rViewEntry,
@@ -617,6 +622,16 @@ public:
         double                                     t );
 };
 
+void MovingSlideChange::prepareForRun(
+    const ViewEntry& rViewEntry,
+    const cppcanvas::CanvasSharedPtr& rDestinationCanvas )
+{
+    if ( maLeavingDirection.equalZero() )
+        renderBitmap( getLeavingBitmap( rViewEntry ), rDestinationCanvas );
+    else if ( maEnteringDirection.equalZero() )
+        renderBitmap( getEnteringBitmap( rViewEntry ), rDestinationCanvas );
+}
+
 void MovingSlideChange::performIn(
     const ::cppcanvas::CustomSpriteSharedPtr&   rSprite,
     const ViewEntry&                            rViewEntry,
@@ -632,12 +647,6 @@ void MovingSlideChange::performIn(
         rDestinationCanvas,
         "MovingSlideChange::performIn(): Invalid dest canvas" );
 
-    if (mbFirstPerformCall && maLeavingDirection.equalZero())
-    {
-        mbFirstPerformCall = false;
-        renderBitmap( getLeavingBitmap(rViewEntry), rDestinationCanvas );
-    }
-
     // TODO(F1): This does not account for non-translational
     // transformations! If the canvas is rotated, we still
     // move the sprite unrotated (which might or might not
@@ -670,12 +679,6 @@ void MovingSlideChange::performOut(
         rDestinationCanvas,
         "MovingSlideChange::performOut(): Invalid dest canvas" );
 
-    if (mbFirstPerformCall && maEnteringDirection.equalZero())
-    {
-        mbFirstPerformCall = false;
-        renderBitmap( getEnteringBitmap(rViewEntry), rDestinationCanvas );
-    }
-
     // TODO(F1): This does not account for non-translational
     // transformations! If the canvas is rotated, we still
     // move the sprite unrotated (which might or might not


More information about the Libreoffice-commits mailing list