[ooo-build-commit] .: slideshow/source

Michael Meeks mmeeks at kemper.freedesktop.org
Tue Sep 28 07:18:23 PDT 2010


 slideshow/source/engine/transitions/randomwipe.cxx |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

New commits:
commit dd02232bdac59b1fa6181140bee72b1eba3e4db4
Author: NeilBrown <neilb at suse.de>
Date:   Tue Sep 28 21:39:19 2010 +1000

    Improve randomisation in 'dissolve' transition.
    
    The loop for randomizing a list in the dissolve transition is poor.
    
    It randomly chooses two element and swaps them, and does this N/2 times.
    Thus a total of N elements are moved.
    It is probable that several elements will be swapped multiple times,
    leaving it probable that several other elements will not be swapped at all.
    
    This fact is quite visible when transitioning between two very different
    slides (e.g. 2 photos).  While there is a lot of randomness, there is a
    clearly perceptible top-to-bottom 'wipe' happening at the same time.
    
    So change the loop to provide true randomness.
    We randomly choose an element for the last position.
    Then randomly choose one of the remaining elements for the second
    last position, etc.
    
    Signed-off-by: NeilBrown <neilb at suse.de>

diff --git a/slideshow/source/engine/transitions/randomwipe.cxx b/slideshow/source/engine/transitions/randomwipe.cxx
index af0698d..0d5a0d6 100644
--- a/slideshow/source/engine/transitions/randomwipe.cxx
+++ b/slideshow/source/engine/transitions/randomwipe.cxx
@@ -68,10 +68,9 @@ RandomWipe::RandomWipe( sal_Int32 nElements, bool randomBars )
     m_rect.transform( aTransform );
     
     // mix up:
-    for ( sal_Int32 i = (nElements / 2); i--; )
+    for ( sal_Int32 pos1 = nElements ; i-- ; )
     {
-        const sal_Int32 pos1 = getRandomOrdinal(nElements);
-        const sal_Int32 pos2 = getRandomOrdinal(nElements);
+        const sal_Int32 pos2 = getRandomOrdinal(pos1+1);
         const ::basegfx::B2DPoint point( m_positions[ pos1 ] );
         m_positions[ pos1 ] = m_positions[ pos2 ];
         m_positions[ pos2 ] = point;


More information about the ooo-build-commit mailing list