Stop rendering during idle state
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 10 Jun 2014 04:36:21 +0000 (13:36 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 11 Jun 2014 08:02:23 +0000 (09:02 +0100)
[problem] Sometimes rendering continues forever (even in idle state).
[cause] ScrollView AnimateInternalXTo is playing Animations with
invalid durations. It either uses a large duration which causes the
issue, otherwise it plays with duration zero (also incorrect).
[solution] Remove the redundant animation logic (since animating
mPropertyPrePosition to itself is a NOOP)

base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp
base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h

index 2779369..d0f05ae 100644 (file)
@@ -2223,7 +2223,9 @@ void ScrollView::OnScrollAnimationFinished( Animation& source )
       scrollingFinished = true;
     }
     mInternalXAnimation.Reset();
       scrollingFinished = true;
     }
     mInternalXAnimation.Reset();
-    SnapInternalXTo(mScrollPostPosition.x);
+
+    // erase current state flags
+    mScrollStateFlags &= ~SCROLL_X_STATE_MASK;
   }
 
   if( source == mInternalYAnimation )
   }
 
   if( source == mInternalYAnimation )
@@ -2233,7 +2235,9 @@ void ScrollView::OnScrollAnimationFinished( Animation& source )
       scrollingFinished = true;
     }
     mInternalYAnimation.Reset();
       scrollingFinished = true;
     }
     mInternalYAnimation.Reset();
-    SnapInternalYTo(mScrollPostPosition.y);
+
+    // erase current state flags
+    mScrollStateFlags &= ~SCROLL_Y_STATE_MASK;
   }
 
   if(scrollingFinished)
   }
 
   if(scrollingFinished)
@@ -2242,67 +2246,6 @@ void ScrollView::OnScrollAnimationFinished( Animation& source )
   }
 }
 
   }
 }
 
-void ScrollView::OnSnapInternalPositionFinished( Animation& source )
-{
-  Actor self = Self();
-  UpdateLocalScrollProperties();
-  if( source == mInternalXAnimation )
-  {
-    // clear internal x animation flags
-    mScrollStateFlags &= ~SCROLL_X_STATE_MASK;
-    mInternalXAnimation.Reset();
-    WrapPosition(mScrollPrePosition);
-  }
-  if( source == mInternalYAnimation )
-  {
-    mScrollStateFlags &= ~SCROLL_Y_STATE_MASK;
-    mInternalYAnimation.Reset();
-    WrapPosition(mScrollPrePosition);
-  }
-}
-
-void ScrollView::SnapInternalXTo(float position)
-{
-  Actor self = Self();
-
-  StopAnimation(mInternalXAnimation);
-
-  // erase current state flags
-  mScrollStateFlags &= ~SCROLL_X_STATE_MASK;
-
-  // if internal x not equal to inputed parameter, animate it
-  float current = self.GetProperty<Vector3>(mPropertyPrePosition).x;
-  float duration = fabsf(position - current);
-  mInternalXAnimation = Animation::New(duration);
-  mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
-  mInternalXAnimation.AnimateTo(Property(self, mPropertyPrePosition, 0), position);
-  mInternalXAnimation.Play();
-
-  // add internal animation state flag
-  mScrollStateFlags |= SnappingInternalX;
-}
-
-void ScrollView::SnapInternalYTo(float position)
-{
-  Actor self = Self();
-
-  StopAnimation(mInternalYAnimation);
-
-  // erase current state flags
-  mScrollStateFlags &= ~SCROLL_Y_STATE_MASK;
-
-  // if internal y not equal to inputed parameter, animate it
-  float current = self.GetProperty<Vector3>(mPropertyPrePosition).y;
-  float duration = fabsf(position - current);
-  mInternalYAnimation = Animation::New(duration);
-  mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
-  mInternalYAnimation.AnimateTo(Property(self, mPropertyPrePosition, 1), position);
-  mInternalYAnimation.Play();
-
-  // add internal animation state flag
-  mScrollStateFlags |= SnappingInternalY;
-}
-
 void ScrollView::GestureStarted()
 {
   // we handle the first gesture.
 void ScrollView::GestureStarted()
 {
   // we handle the first gesture.
@@ -2477,14 +2420,6 @@ void ScrollView::FinishTransform()
     Self().SetProperty(mPropertyScrolling, false);
     Vector3 currentScrollPosition = GetCurrentScrollPosition();
     mScrollCompletedSignalV2.Emit( currentScrollPosition );
     Self().SetProperty(mPropertyScrolling, false);
     Vector3 currentScrollPosition = GetCurrentScrollPosition();
     mScrollCompletedSignalV2.Emit( currentScrollPosition );
-    if( fabs(mScrollPrePosition.x - mScrollTargetPosition.x) > Math::MACHINE_EPSILON_10 )
-    {
-      SnapInternalXTo(mScrollTargetPosition.x);
-    }
-    if( fabs(mScrollPrePosition.y - mScrollTargetPosition.y) > Math::MACHINE_EPSILON_10 )
-    {
-      SnapInternalYTo(mScrollTargetPosition.y);
-    }
   }
 }
 
   }
 }
 
index 1591fb6..1315a66 100644 (file)
@@ -649,27 +649,6 @@ private:
   void OnScrollAnimationFinished( Animation& source );
 
   /**
   void OnScrollAnimationFinished( Animation& source );
 
   /**
-   * Called when either the X or Y internal scroll positions have finished snapping back to mPropertyPrePosition
-   *
-   * @param[in] source the Animation instance that has completed.
-   */
-  void OnSnapInternalPositionFinished( Animation& source );
-
-  /**
-   * Called whenever a snap animation on the x-axis has completed and we need to snap pre scroll
-   * position to our clamped position
-   * @param[in] position The x position to snap pre scroll property to
-   */
-  void SnapInternalXTo( float position );
-
-  /**
-   * Called whenever a snap animation on the y-axis has completed and we need to snap pre scroll
-   * position to our clamped position
-   * @param[in] position The y position to snap pre scroll property to
-   */
-  void SnapInternalYTo( float position );
-
-  /**
    * This is called internally whenever the Scroll Rulers are
    * modified. This will update the properties: 'scroll-position-min'
    * and 'scroll-position-max' to reflect the changes.
    * This is called internally whenever the Scroll Rulers are
    * modified. This will update the properties: 'scroll-position-min'
    * and 'scroll-position-max' to reflect the changes.