[Tizen] Add FeedTouch api to GestureDetector.
[platform/core/uifw/dali-core.git] / dali / internal / event / events / pan-gesture / pan-gesture-processor.cpp
index c548833..3a471d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 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.
@@ -27,6 +27,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/trace.h>
 #include <dali/internal/event/common/scene-impl.h>
 #include <dali/internal/event/events/gesture-requests.h>
 #include <dali/internal/event/events/multi-point-event-util.h>
@@ -47,6 +48,7 @@ namespace Internal
 {
 namespace // unnamed namespace
 {
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_PAN_PROCESSOR");
 
@@ -141,7 +143,7 @@ PanGestureProcessor::~PanGestureProcessor()
   mSceneObject = nullptr; // mSceneObject is owned and destroyed by update manager (there is only one of these for now)
 }
 
-void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent)
+void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent, Actor* actor)
 {
 #if defined(DEBUG_ENABLED)
   DALI_LOG_TRACE_METHOD(gLogFilter);
@@ -151,6 +153,8 @@ void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent)
   DALI_LOG_INFO(gLogFilter, Debug::General, "      Positions: Current: (%.0f, %.0f), Previous: (%.0f, %.0f)\n", panEvent.currentPosition.x, panEvent.currentPosition.y, panEvent.previousPosition.x, panEvent.previousPosition.y);
 #endif
 
+  DALI_TRACE_SCOPE(gTraceFilter, "DALI_PROCESS_PAN_GESTURE");
+
   switch(panEvent.state)
   {
     case GestureState::POSSIBLE:
@@ -159,7 +163,12 @@ void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent)
       ResetActor();
 
       HitTestAlgorithm::Results hitTestResults;
-      if(HitTest(scene, panEvent.currentPosition, hitTestResults))
+      if(actor)
+      {
+        SetActor(actor);
+        mPossiblePanPosition = panEvent.currentPosition;
+      }
+      else if(HitTest(scene, panEvent.currentPosition, hitTestResults))
       {
         SetActor(&GetImplementation(hitTestResults.actor));
         mPossiblePanPosition = panEvent.currentPosition;
@@ -176,7 +185,19 @@ void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent)
       // it can be told when the gesture ends as well.
 
       HitTestAlgorithm::Results hitTestResults;
-      HitTest(scene, panEvent.previousPosition, hitTestResults); // Hit Test previous position
+      if(actor)
+      {
+        hitTestResults.actor = Dali::Actor(actor);
+        hitTestResults.renderTask = panEvent.renderTask;
+
+        Vector2 actorCoords;
+        actor->ScreenToLocal(*hitTestResults.renderTask.Get(), actorCoords.x, actorCoords.y, panEvent.currentPosition.x, panEvent.currentPosition.y);
+        hitTestResults.actorCoordinates = actorCoords;
+      }
+      else
+      {
+        HitTest(scene, panEvent.previousPosition, hitTestResults); // Hit Test previous position
+      }
 
       if(hitTestResults.actor)
       {
@@ -192,7 +213,14 @@ void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent)
 
         // Set mCurrentPanEvent to use inside overridden methods called in ProcessAndEmit()
         mCurrentPanEvent = &panEvent;
-        ProcessAndEmit(hitTestResults);
+        if(actor)
+        {
+          ProcessAndEmitActor(hitTestResults);
+        }
+        else
+        {
+          ProcessAndEmit(hitTestResults);
+        }
         mCurrentPanEvent = nullptr;
       }
       else
@@ -567,6 +595,10 @@ void PanGestureProcessor::EmitPanSignal(Actor*                          actor,
       mSceneObject->AddGesture(*pan.Get());
     }
 
+    DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_EMIT_PAN_GESTURE_SIGNAL", [&](std::ostringstream& oss) {
+      oss << "[" << gestureDetectors.size() << "]";
+    });
+
     Dali::Actor actorHandle(actor);
 
     const GestureDetectorContainer::const_iterator endIter = gestureDetectors.end();
@@ -574,6 +606,10 @@ void PanGestureProcessor::EmitPanSignal(Actor*                          actor,
     {
       static_cast<PanGestureDetector*>(*iter)->EmitPanGestureSignal(actorHandle, Dali::PanGesture(pan.Get()));
     }
+
+    DALI_TRACE_END_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_EMIT_PAN_GESTURE_SIGNAL", [&](std::ostringstream& oss) {
+      oss << "[" << gestureDetectors.size() << "]";
+    });
   }
 }