Single tap results on text-input controls was very slow 08/31308/4
authorRichard Underhill <r.underhill@partner.samsung.com>
Wed, 3 Dec 2014 16:26:37 +0000 (16:26 +0000)
committerRichard Underhill <r.underhill@partner.samsung.com>
Mon, 19 Jan 2015 14:54:01 +0000 (06:54 -0800)
Needs https://review.tizen.org/gerrit/#/c/31306/

Change-Id: I37aa5fbf0f54fce93f6531c1a0428cf58652ad93
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp
dali/internal/event/events/tap-gesture-processor.cpp
dali/internal/event/events/tap-gesture-processor.h

index d19bc08..2f6109c 100644 (file)
@@ -857,26 +857,26 @@ int UtcDaliTapGestureSignalReceptionDifferentPossible(void)
   application.SendNotification();
   application.Render();
 
-  // Emit Started event, we should not receive the long press.
+  // Emit Started event, we should not receive the tap.
   application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
 
-  // LongPress possible in empty area.
+  // Tap possible in empty area.
   application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
 
-  // Move actor in to the long press position.
+  // Move actor in to the tap position.
   actor.SetPosition( 0.0f, 0.0f );
 
   // Render and notify
   application.SendNotification();
   application.Render();
 
-  // Emit Started event, we should not receive the long press.
+  // Emit Started event, we should not receive the tap.
   application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
 
-  // Normal long press in actor's area for completeness.
+  // Normal tap in actor's area for completeness.
   application.ProcessEvent(GenerateTap(Gesture::Possible, 1u, 1u, Vector2(50.0f, 10.0f)));
   application.ProcessEvent(GenerateTap(Gesture::Started, 1u, 1u, Vector2(50.0f, 10.0f)));
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
index 0845511..7ae30e5 100644 (file)
@@ -81,7 +81,8 @@ TapGestureProcessor::TapGestureProcessor( Stage& stage, Integration::GestureMana
   mMaxTapsRequired( 1 ),
   mMinTouchesRequired( 1 ),
   mMaxTouchesRequired( 1 ),
-  mCurrentTapEvent( NULL )
+  mCurrentTapEvent( NULL ),
+  mPossibleProcessed( false )
 {
 }
 
@@ -95,40 +96,47 @@ void TapGestureProcessor::Process( const Integration::TapGestureEvent& tapEvent
   {
     case Gesture::Possible:
     {
-      ResetActor();
-
+      // Do a hit test and if an actor has been hit then save to see if tap event is still valid on a tap( same actor being hit )
       HitTestAlgorithm::Results hitTestResults;
-      if( HitTest( mStage, tapEvent.point, hitTestResults ) )
+      if ( HitTest( mStage, tapEvent.point, hitTestResults ) )
       {
-        // Only sets the actor if we have a hit.
         SetActor( &GetImplementation( hitTestResults.actor ) );
+        mCurrentTapActor.SetActor( GetCurrentGesturedActor() );
+
+        // Indicate that we've processed a touch down. Bool should be sufficient as a change in actor will result in a cancellation
+        mPossibleProcessed = true;
+      }
+      else
+      {
+        ResetActor();
       }
       break;
     }
 
     case Gesture::Started:
     {
-      if ( GetCurrentGesturedActor() )
+      // Ensure that we're processing a hit on the current actor and that we've already processed a touch down
+      HitTestAlgorithm::Results hitTestResults;
+      if ( GetCurrentGesturedActor() && HitTest( mStage, tapEvent.point, hitTestResults ) && mPossibleProcessed )
       {
-        HitTestAlgorithm::Results hitTestResults;
-        HitTest( mStage, tapEvent.point, hitTestResults );
-
-        if ( hitTestResults.actor && ( GetCurrentGesturedActor() == &GetImplementation( hitTestResults.actor ) ) )
+        // Check that this actor is still the one that was used for the last touch down ?
+        if ( mCurrentTapActor.GetActor() == &GetImplementation( hitTestResults.actor ) )
         {
-          // Set mCurrentTapEvent to use inside overridden methods called from ProcessAndEmit()
           mCurrentTapEvent = &tapEvent;
           ProcessAndEmit( hitTestResults );
-          mCurrentTapEvent = NULL;
         }
-
-        ResetActor();
+        mCurrentTapEvent = NULL;
+        mPossibleProcessed = false;
       }
       break;
     }
 
     case Gesture::Cancelled:
+    {
+      mPossibleProcessed = false;
       ResetActor();
       break;
+    }
 
     case Gesture::Continuing:
       DALI_ASSERT_ALWAYS( false && "Incorrect state received from Integration layer: Continuing\n" );
index 84b90a4..0f7c6ca 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/event/events/tap-gesture-detector-impl.h>
 #include <dali/internal/event/events/gesture-processor.h>
+#include "actor-observer.h"
 
 namespace Dali
 {
@@ -133,7 +134,9 @@ private:
   unsigned int mMinTouchesRequired;
   unsigned int mMaxTouchesRequired;
 
+  ActorObserver mCurrentTapActor; ///< Observer for the current gesture actor
   const Integration::TapGestureEvent* mCurrentTapEvent; ///< Pointer to current TapEvent, used when calling ProcessAndEmit()
+  bool mPossibleProcessed; ///< Indication of whether we've processed a touch down for this gestuee
 };
 
 } // namespace Internal