Add trace log for touch, wheel and gesture
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture / tap-gesture-processor.cpp
index 39dd060..0c43d8f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/common/scene-impl.h>
 #include <dali/internal/event/events/gesture-requests.h>
@@ -41,6 +42,9 @@ namespace Internal
 {
 namespace
 {
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+constexpr uint32_t DEFAULT_MAXIMUM_ALLOWED_TIME = 500u;
+
 /**
  * Creates a TapGesture and asks the specified detector to emit its detected signal.
  * @param[in]  actor             The actor on which a tap has occurred.
@@ -60,7 +64,8 @@ void EmitTapSignal(
   tap->SetNumberOfTouches(tapEvent.numberOfTouches);
   tap->SetScreenPoint(tapEvent.point);
   tap->SetLocalPoint(localPoint);
-  tap->SetGestureSourceType(tapEvent.gestureSourceType);
+  tap->SetSourceType(tapEvent.sourceType);
+  tap->SetSourceData(tapEvent.sourceData);
 
   Dali::Actor                                    actorHandle(actor);
   const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
@@ -80,7 +85,8 @@ TapGestureProcessor::TapGestureProcessor()
   mMinTouchesRequired(1),
   mMaxTouchesRequired(1),
   mCurrentTapEvent(nullptr),
-  mPossibleProcessed(false)
+  mPossibleProcessed(false),
+  mMaximumAllowedTime(DEFAULT_MAXIMUM_ALLOWED_TIME)
 {
 }
 
@@ -88,6 +94,7 @@ TapGestureProcessor::~TapGestureProcessor() = default;
 
 void TapGestureProcessor::Process(Scene& scene, const TapGestureEvent& tapEvent)
 {
+  DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_TAP_GESTURE");
   switch(tapEvent.state)
   {
     case GestureState::POSSIBLE:
@@ -180,7 +187,7 @@ void TapGestureProcessor::AddGestureDetector(TapGestureDetector* gestureDetector
     request.maxTouches = mMaxTouchesRequired;
 
     Size size          = scene.GetSize();
-    mGestureRecognizer = new TapGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const TapGestureRequest&>(request));
+    mGestureRecognizer = new TapGestureRecognizer(*this, Vector2(size.width, size.height), static_cast<const TapGestureRequest&>(request), mMaximumAllowedTime);
   }
   else
   {
@@ -242,6 +249,28 @@ void TapGestureProcessor::GestureDetectorUpdated(TapGestureDetector* gestureDete
   UpdateDetection();
 }
 
+void TapGestureProcessor::SetMaximumAllowedTime(uint32_t time)
+{
+  if(time == 0u)
+  {
+    DALI_LOG_WARNING("MaximumAllowedTime must be greater than zero.");
+    return;
+  }
+  if(mMaximumAllowedTime != time)
+  {
+    mMaximumAllowedTime = time;
+
+    if(mGestureRecognizer)
+    {
+      TapGestureRecognizer* tapRecognizer = dynamic_cast<TapGestureRecognizer*>(mGestureRecognizer.Get());
+      if(tapRecognizer)
+      {
+        tapRecognizer->SetMaximumAllowedTime(time);
+      }
+    }
+  }
+}
+
 void TapGestureProcessor::UpdateDetection()
 {
   DALI_ASSERT_DEBUG(!mTapGestureDetectors.empty());
@@ -287,8 +316,7 @@ bool TapGestureProcessor::CheckGestureDetector(GestureDetector* detector, Actor*
 
   TapGestureDetector* tapDetector(static_cast<TapGestureDetector*>(detector));
 
-  return ((tapDetector->GetMinimumTapsRequired() <= mCurrentTapEvent->numberOfTaps) && (tapDetector->GetMaximumTapsRequired() >= mCurrentTapEvent->numberOfTaps)) &&
-         (tapDetector->GetTouchesRequired() == mCurrentTapEvent->numberOfTouches);
+  return (tapDetector->GetMinimumTapsRequired() <= mCurrentTapEvent->numberOfTaps) && (tapDetector->GetTouchesRequired() == mCurrentTapEvent->numberOfTouches);
 }
 
 void TapGestureProcessor::EmitGestureSignal(Actor* actor, const GestureDetectorContainer& gestureDetectors, Vector2 actorCoordinates)