From d4352c3f7e0bf6350a005737b6a69721b2bd8d38 Mon Sep 17 00:00:00 2001 From: Richard Underhill Date: Wed, 3 Dec 2014 16:26:37 +0000 Subject: [PATCH] Single tap results on text-input controls was very slow Needs https://review.tizen.org/gerrit/#/c/31306/ Change-Id: I37aa5fbf0f54fce93f6531c1a0428cf58652ad93 Signed-off-by: Richard Underhill --- .../src/dali/utc-Dali-TapGestureDetector.cpp | 10 +++--- .../event/events/tap-gesture-processor.cpp | 36 +++++++++++++--------- dali/internal/event/events/tap-gesture-processor.h | 3 ++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index d19bc08..2f6109c 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -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); diff --git a/dali/internal/event/events/tap-gesture-processor.cpp b/dali/internal/event/events/tap-gesture-processor.cpp index 0845511..7ae30e5 100644 --- a/dali/internal/event/events/tap-gesture-processor.cpp +++ b/dali/internal/event/events/tap-gesture-processor.cpp @@ -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" ); diff --git a/dali/internal/event/events/tap-gesture-processor.h b/dali/internal/event/events/tap-gesture-processor.h index 84b90a4..0f7c6ca 100644 --- a/dali/internal/event/events/tap-gesture-processor.h +++ b/dali/internal/event/events/tap-gesture-processor.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#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 -- 2.7.4