Merge "Blend Equation Advanced Supporting" into devel/master
authorSeungho BAEK <sbsh.baek@samsung.com>
Wed, 11 Nov 2020 03:07:08 +0000 (03:07 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 11 Nov 2020 03:07:08 +0000 (03:07 +0000)
23 files changed:
automated-tests/patch-coverage.pl
automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp
automated-tests/src/dali/dali-test-suite-utils/test-harness.h
automated-tests/src/dali/utc-Dali-Layer.cpp
automated-tests/src/dali/utc-Dali-Stage.cpp
dali/devel-api/common/owner-container.h
dali/integration-api/debug.cpp
dali/integration-api/debug.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/layer-impl.cpp
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animator-connector-base.h
dali/internal/event/animation/animator-connector.h
dali/internal/event/animation/key-frame-channel.h
dali/internal/event/animation/key-frames-impl.cpp
dali/internal/event/animation/key-frames-impl.h
dali/internal/event/common/stage-impl.cpp
dali/internal/update/animation/scene-graph-animation.cpp
dali/internal/update/animation/scene-graph-animator.h
dali/internal/update/manager/render-task-processor.cpp
dali/public-api/animation/key-frames.cpp
dali/public-api/dali-core-version.cpp
packaging/dali.spec

index 3a97dac..b3cf098 100755 (executable)
@@ -1105,7 +1105,7 @@ sub calc_patch_coverage_percentage
     my $percent = 0;
     if($total_exec > 0) { $percent = 100 * $total_covered_lines / $total_exec; }
 
-    return [ $total_exec, $percent ];
+    return [ $total_exec, $percent, $total_covered_lines ];
 }
 
 #
@@ -1417,6 +1417,7 @@ elsif( ! $opt_quiet )
     print RESET;
 }
 
+printf("Line Coverage: %d/%d\n", $percentref->[2], $percentref->[0]);
 printf("Percentage of change covered: %5.2f%\n", $percent);
 
 exit($percent<90);
index 0b814e7..b53630d 100644 (file)
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <testcase.h>
+
+#include <time.h>
 #include <unistd.h>
 
+#include <chrono>
 #include <cstring>
 #include <map>
 #include <vector>
@@ -31,6 +34,8 @@ namespace TestHarness
 {
 typedef std::map<int32_t, TestCase> RunningTestCases;
 
+const double MAXIMUM_CHILD_LIFETIME(60.0f); // 1 minute
+
 const char* basename(const char* path)
 {
   const char* ptr   = path;
@@ -247,25 +252,42 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
       else // Parent process
       {
         TestCase tc(nextTestCase, tc_array[nextTestCase].name);
+        tc.startTime = std::chrono::steady_clock::now();
+
         children[pid] = tc;
         nextTestCase++;
         numRunningChildren++;
       }
     }
 
-    // Wait for the next child to finish
-
+    // Check to see if any children have finished yet
     int32_t status   = 0;
-    int32_t childPid = waitpid(-1, &status, 0);
-    if(childPid == -1)
+    int32_t childPid = waitpid(-1, &status, WNOHANG);
+    if(childPid == 0)
+    {
+      // No children have finished.
+      // Check if any have exceeded execution time
+      auto endTime = std::chrono::steady_clock::now();
+
+      for(auto& tc : children)
+      {
+        std::chrono::steady_clock::duration timeSpan = endTime - tc.second.startTime;
+        std::chrono::duration<double>       seconds  = std::chrono::duration_cast<std::chrono::duration<double>>(timeSpan);
+        if(seconds.count() > MAXIMUM_CHILD_LIFETIME)
+        {
+          // Kill the child process. A subsequent call to waitpid will process signal result below.
+          kill(tc.first, SIGKILL);
+        }
+      }
+    }
+    else if(childPid == -1) // waitpid errored
     {
       perror("waitpid");
       exit(EXIT_STATUS_WAITPID_FAILED);
     }
-
-    if(WIFEXITED(status))
+    else // a child has finished
     {
-      if(childPid > 0)
+      if(WIFEXITED(status))
       {
         int32_t testResult = WEXITSTATUS(status);
         if(testResult)
@@ -280,14 +302,11 @@ int32_t RunAllInParallel(const char* processName, ::testcase tc_array[], bool re
         }
         numRunningChildren--;
       }
-    }
-
-    else if(WIFSIGNALED(status) || WIFSTOPPED(status))
-    {
-      status = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status);
 
-      if(childPid > 0)
+      else if(WIFSIGNALED(status) || WIFSTOPPED(status))
       {
+        status = WIFSIGNALED(status) ? WTERMSIG(status) : WSTOPSIG(status);
+
         RunningTestCases::iterator iter = children.find(childPid);
         if(iter != children.end())
         {
index c4b5e03..b210918 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <testcase.h>
 
+#include <chrono>
 #include <cstdint>
 
 namespace TestHarness
@@ -39,29 +40,34 @@ const int32_t MAX_NUM_CHILDREN(16);
 
 struct TestCase
 {
-  int32_t     testCase;
-  const char* testCaseName;
+  int32_t                               testCase;
+  const char*                           testCaseName;
+  std::chrono::steady_clock::time_point startTime;
 
   TestCase()
   : testCase(0),
-    testCaseName(NULL)
+    testCaseName(NULL),
+    startTime()
   {
   }
 
   TestCase(int32_t tc, const char* name)
   : testCase(tc),
-    testCaseName(name)
+    testCaseName(name),
+    startTime()
   {
   }
   TestCase(const TestCase& rhs)
   : testCase(rhs.testCase),
-    testCaseName(rhs.testCaseName)
+    testCaseName(rhs.testCaseName),
+    startTime(rhs.startTime)
   {
   }
   TestCase& operator=(const TestCase& rhs)
   {
     testCase     = rhs.testCase;
     testCaseName = rhs.testCaseName;
+    startTime    = rhs.startTime;
     return *this;
   }
 };
index c3b5410..a74a42f 100644 (file)
@@ -144,7 +144,7 @@ int UtcDaliLayerGetDepth(void)
   END_TEST;
 }
 
-int UtcDaliLayerRaise(void)
+int UtcDaliLayerRaise1(void)
 {
   tet_infoline("Testing Dali::Layer::Raise()");
   TestApplication application;
@@ -168,7 +168,34 @@ int UtcDaliLayerRaise(void)
   END_TEST;
 }
 
-int UtcDaliLayerLower(void)
+int UtcDaliLayerRaise2(void)
+{
+  tet_infoline("Testing Dali::Layer raise Action");
+  TestApplication application;
+  Layer           layer1 = Layer::New();
+  Layer           layer2 = Layer::New();
+
+  application.GetScene().Add(layer1);
+  application.GetScene().Add(layer2);
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+
+  layer1.Raise();
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
+
+  // get root
+  Layer root = application.GetScene().GetLayer(0);
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+
+  GetImplementation(root).DoAction("raise", Property::Map());
+
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+  END_TEST;
+}
+
+
+int UtcDaliLayerLower1(void)
 {
   tet_infoline("Testing Dali::Layer::Lower()");
   TestApplication application;
@@ -192,7 +219,33 @@ int UtcDaliLayerLower(void)
   END_TEST;
 }
 
-int UtcDaliLayerRaiseToTop(void)
+
+int UtcDaliLayerLower2(void)
+{
+  tet_infoline("Testing Dali::Layer lower Action");
+  TestApplication application;
+  Layer           layer1 = Layer::New();
+  Layer           layer2 = Layer::New();
+
+  application.GetScene().Add(layer1);
+  application.GetScene().Add(layer2);
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
+
+  layer2.Lower();
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+
+  // get root
+  Layer root = application.GetScene().GetLayer(0);
+  GetImplementation(root).DoAction("lower", Property::Map());
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+
+  GetImplementation(layer2).DoAction("lower", Property::Map());
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliLayerRaiseToTop1(void)
 {
   tet_infoline("Testing Dali::Layer::RaiseToTop()");
   TestApplication application;
@@ -218,7 +271,33 @@ int UtcDaliLayerRaiseToTop(void)
   END_TEST;
 }
 
-int UtcDaliLayerLowerToBottom(void)
+int UtcDaliLayerRaiseToTop2(void)
+{
+  tet_infoline("Testing Dali::Layer raiseToTop Action");
+  TestApplication application;
+  Layer           layer1 = Layer::New();
+  Layer           layer2 = Layer::New();
+  Layer           layer3 = Layer::New();
+
+  application.GetScene().Add(layer1);
+  application.GetScene().Add(layer2);
+  application.GetScene().Add(layer3);
+  Layer root = application.GetScene().GetLayer(0);
+
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
+
+  GetImplementation(layer1).DoAction("raiseToTop", Property::Map());
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
+
+  GetImplementation(root).DoAction("raiseToTop", Property::Map());
+  DALI_TEST_EQUALS(root.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliLayerLowerToBottom1(void)
 {
   tet_infoline("Testing Dali::Layer::LowerToBottom()");
   TestApplication application;
@@ -239,6 +318,28 @@ int UtcDaliLayerLowerToBottom(void)
   END_TEST;
 }
 
+int UtcDaliLayerLowerToBottom2(void)
+{
+  tet_infoline("Testing Dali::Layer lowerToBottom Action");
+  TestApplication application;
+  Layer           layer1 = Layer::New();
+  Layer           layer2 = Layer::New();
+  Layer           layer3 = Layer::New();
+
+  application.GetScene().Add(layer1);
+  application.GetScene().Add(layer2);
+  application.GetScene().Add(layer3);
+
+  DALI_TEST_EQUALS(layer1.GetProperty<int>(Layer::Property::DEPTH), 1u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer2.GetProperty<int>(Layer::Property::DEPTH), 2u, TEST_LOCATION);
+  DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 3u, TEST_LOCATION);
+
+  GetImplementation(layer3).DoAction("lowerToBottom", Property::Map());
+  DALI_TEST_EQUALS(layer3.GetProperty<int>(Layer::Property::DEPTH), 0u, TEST_LOCATION);
+  END_TEST;
+}
+
+
 int UtcDaliLayerSetClipping(void)
 {
   tet_infoline("Testing Dali::Layer::SetClipping()");
index 90fe393..303d672 100644 (file)
@@ -178,6 +178,8 @@ struct TouchFunctor
     signalData.receivedTouchEvent = handle;
   }
 
+  // Allows functor to be used for signal connection by string.
+  // No data stored, though, so quite useless.
   void operator()()
   {
     signalData.functorCalled = true;
@@ -222,6 +224,25 @@ struct WheelEventReceivedFunctor
   WheelEventSignalData& signalData;
 };
 
+// Functor that sets the data when wheel-event signal is received
+struct WheelEventReceivedVoidFunctor
+{
+  WheelEventReceivedVoidFunctor(WheelEventSignalData& data)
+  : signalData(data)
+  {
+  }
+
+  // Signals connected through BaseObject::DoConnectSignal can only take void() methods
+  bool operator()(void)
+  {
+    signalData.functorCalled = true;
+    return true;
+  }
+
+  WheelEventSignalData& signalData;
+};
+
+
 bool DummyTouchCallback(Actor actor, const TouchEvent& touch)
 {
   return true;
@@ -844,6 +865,27 @@ int UtcDaliStageEventProcessingFinishedP(void)
   END_TEST;
 }
 
+int UtcDaliStageEventProcessingFinishedP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+  tet_printf("UtcDaliStageEventProcessingFinishedSignalP2 - check event processing finished signal connection by name\n");
+
+  bool                           eventProcessingFinished = false;
+  EventProcessingFinishedFunctor functor(eventProcessingFinished);
+  GetImplementation(stage).ConnectSignal(&application, "eventProcessingFinished", functor);
+
+  Actor actor(Actor::New());
+  stage.Add(actor);
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK(eventProcessingFinished);
+
+  END_TEST;
+}
+
 int UtcDaliStageEventProcessingFinishedN(void)
 {
   TestApplication application;
@@ -1103,6 +1145,35 @@ int UtcDaliStageTouchedSignalP(void)
   END_TEST;
 }
 
+
+int UtcDaliStageTouchedSignalP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+  tet_printf("UtcDaliStageTouchedSignalP2 - check touched signal connection by name\n");
+
+  TouchedSignalData data;
+  TouchFunctor      functor(data);
+  GetImplementation(stage).ConnectSignal(&application, "touched", functor);
+
+  // Render and notify.
+  application.SendNotification();
+  application.Render();
+
+  // Basic test: No actors, single touch (down then up).
+  {
+    GenerateTouch(application, PointState::DOWN, Vector2(10.0f, 10.0f));
+
+    DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+    data.Reset();
+
+    GenerateTouch(application, PointState::UP, Vector2(10.0f, 10.0f));
+    DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+    data.Reset();
+  }
+  END_TEST;
+}
+
 int UtcDaliStageTouchedSignalN(void)
 {
   TestApplication application;
@@ -1226,6 +1297,32 @@ int UtcDaliStageSignalWheelEventP(void)
   END_TEST;
 }
 
+
+int UtcDaliStageSignalWheelEventP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+  tet_printf("UtcDaliStageSignalWheelEventP2 - check wheel signal connection by name\n");
+
+  WheelEventSignalData      data;
+  WheelEventReceivedVoidFunctor functor(data);
+  GetImplementation(stage).ConnectSignal(&application, "wheelEvent", functor);
+
+  Integration::WheelEvent event(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), 1, 1000u);
+  application.ProcessEvent(event);
+
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  // It's meaningless, since there's no data passed to the functor :/
+
+  data.Reset();
+
+  Integration::WheelEvent event2(Integration::WheelEvent::CUSTOM_WHEEL, 0, 0u, Vector2(0.0f, 0.0f), -1, 1000u);
+  application.ProcessEvent(event2);
+
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  END_TEST;
+}
+
 int UtcDaliStageContextLostSignalP(void)
 {
   TestApplication application;
@@ -1242,6 +1339,23 @@ int UtcDaliStageContextLostSignalP(void)
   END_TEST;
 }
 
+int UtcDaliStageContextLostSignalP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+  tet_printf("UtcDaliStageContextLostSignalP2 - check context loss signal connection by name\n");
+
+  bool                 contextLost = false;
+  ContextStatusFunctor contextLostFunctor(contextLost);
+  GetImplementation(stage).ConnectSignal(&application, "contextLost", contextLostFunctor);
+
+  Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
+  notifier->NotifyContextLost();
+  DALI_TEST_EQUALS(contextLost, true, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliStageContextLostSignalN(void)
 {
   TestApplication application;
@@ -1283,6 +1397,27 @@ int UtcDaliStageContextRegainedSignalP(void)
   END_TEST;
 }
 
+int UtcDaliStageContextRegainedSignalP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+  tet_printf("UtcDaliStageContextRegainedSignalP2 - check context regained signal connection by name\n");
+
+  bool                 contextRegained = false;
+  ContextStatusFunctor contextRegainedFunctor(contextRegained);
+  GetImplementation(stage).ConnectSignal(&application, "contextRegained", contextRegainedFunctor);
+
+  Integration::ContextNotifierInterface* notifier = application.GetCore().GetContextNotifier();
+  notifier->NotifyContextLost();
+  notifier->NotifyContextRegained();
+  DALI_TEST_EQUALS(contextRegained, true, TEST_LOCATION);
+
+  END_TEST;
+}
+
+
+
+
 int UtcDaliStageContextRegainedSignalN(void)
 {
   TestApplication application;
@@ -1323,6 +1458,22 @@ int UtcDaliStageSceneCreatedSignalP(void)
   END_TEST;
 }
 
+int UtcDaliStageSceneCreatedSignalP2(void)
+{
+  TestApplication application;
+  Stage           stage = Stage::GetCurrent();
+
+  bool                      signalCalled = false;
+  SceneCreatedStatusFunctor sceneCreatedFunctor(signalCalled);
+  GetImplementation(stage).ConnectSignal(&application, "sceneCreated", sceneCreatedFunctor);
+
+  Integration::Core& core = application.GetCore();
+  core.SceneCreated();
+  DALI_TEST_EQUALS(signalCalled, true, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliStageSceneCreatedSignalN(void)
 {
   TestApplication application;
index 6890656..c8c37d5 100644 (file)
@@ -86,6 +86,21 @@ public:
   }
 
   /**
+   * Erases a range of elements.(delete from heap).
+   */
+  Iterator Erase(Iterator first, Iterator last)
+  {
+    auto itr = first;
+    while(itr < last)
+    {
+      Delete(*itr);
+      ++itr;
+    }
+
+    return Vector<T>::Erase(first, last);
+  }
+
+  /**
    * Erase an object from OwnerContainer
    * @param object to remove
    */
index 53df468..ebbc339 100644 (file)
 #include <dali/integration-api/debug.h>
 
 // EXTERNAL INCLUDES
+#include <chrono>
 #include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <ctime>
-#include <iomanip>
-#include <sstream>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/public-api/common/constants.h>
-#include <dali/public-api/math/matrix.h>
-#include <dali/public-api/math/matrix3.h>
-#include <dali/public-api/math/quaternion.h>
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/vector4.h>
 
 namespace Dali
 {
@@ -46,12 +32,6 @@ Dali::DebugPropertyValueMap   gValueMap;
 
 #endif
 
-namespace // unnamed namespace
-{
-const uint64_t NANOSECONDS_PER_SECOND = 1e+9;
-
-}
-
 namespace Integration
 {
 namespace Log
@@ -253,15 +233,20 @@ std::string FormatToString(const char* format, ...)
   return s;
 }
 
+#ifdef DEBUG_ENABLED
+
 void GetNanoseconds(uint64_t& timeInNanoseconds)
 {
-  timespec timeSpec;
-  clock_gettime(CLOCK_MONOTONIC, &timeSpec);
+  // Get the time of a monotonic clock since its epoch.
+  auto epoch = std::chrono::steady_clock::now().time_since_epoch();
+
+  auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(epoch);
 
-  // Convert all values to uint64_t to match our return type
-  timeInNanoseconds = (static_cast<uint64_t>(timeSpec.tv_sec) * NANOSECONDS_PER_SECOND) + static_cast<uint64_t>(timeSpec.tv_nsec);
+  timeInNanoseconds = static_cast<uint64_t>(duration.count());
 }
 
+#endif // DEBUG_ENABLED
+
 } // namespace Log
 
 } // namespace Integration
index 5b2f40c..fe6c0d7 100644 (file)
@@ -467,9 +467,15 @@ public:                                    \
 /********************************************************************************
  *                            Time instrumentation                              *
  ********************************************************************************/
-
 #if defined(DEBUG_ENABLED)
 
+ /**
+  * @brief Get the monotonic time since the clock's epoch.
+  *
+  * @param[out]  timeInNanoseconds  The time in nanoseconds since the reference point.
+  *
+  * @note The maximum value timeInNanoseconds can hold is 0xFFFFFFFFFFFFFFFF which is 1.844674407e+19. Therefore, this can overflow after approximately 584 years.
+  */
 void GetNanoseconds(uint64_t& timeInNanoseconds);
 
 #define DALI_LOG_TIMER_START(timeVariable) \
index 35131c1..b6960ed 100755 (executable)
@@ -150,21 +150,21 @@ DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultPropert
 
 // Signals
 
-const char* const SIGNAL_HOVERED = "hovered";
-const char* const SIGNAL_WHEEL_EVENT = "wheelEvent";
-const char* const SIGNAL_ON_SCENE = "onScene";
-const char* const SIGNAL_OFF_SCENE = "offScene";
-const char* const SIGNAL_ON_RELAYOUT = "onRelayout";
-const char* const SIGNAL_TOUCHED = "touched";
-const char* const SIGNAL_VISIBILITY_CHANGED = "visibilityChanged";
-const char* const SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
-const char* const SIGNAL_CHILD_ADDED = "childAdded";
-const char* const SIGNAL_CHILD_REMOVED = "childRemoved";
+static constexpr std::string_view SIGNAL_HOVERED                  = "hovered";
+static constexpr std::string_view SIGNAL_WHEEL_EVENT              = "wheelEvent";
+static constexpr std::string_view SIGNAL_ON_SCENE                 = "onScene";
+static constexpr std::string_view SIGNAL_OFF_SCENE                = "offScene";
+static constexpr std::string_view SIGNAL_ON_RELAYOUT              = "onRelayout";
+static constexpr std::string_view SIGNAL_TOUCHED                  = "touched";
+static constexpr std::string_view SIGNAL_VISIBILITY_CHANGED       = "visibilityChanged";
+static constexpr std::string_view SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
+static constexpr std::string_view SIGNAL_CHILD_ADDED              = "childAdded";
+static constexpr std::string_view SIGNAL_CHILD_REMOVED            = "childRemoved";
 
 // Actions
 
-const char* const ACTION_SHOW = "show";
-const char* const ACTION_HIDE = "hide";
+static constexpr std::string_view ACTION_SHOW = "show";
+static constexpr std::string_view ACTION_HIDE = "hide";
 
 BaseHandle CreateActor()
 {
@@ -173,19 +173,19 @@ BaseHandle CreateActor()
 
 TypeRegistration mType( typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties );
 
-SignalConnectorType signalConnector2( mType, SIGNAL_HOVERED, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector3( mType, SIGNAL_WHEEL_EVENT, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector4( mType, SIGNAL_ON_SCENE, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector5( mType, SIGNAL_OFF_SCENE, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector6( mType, SIGNAL_ON_RELAYOUT, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector7( mType, SIGNAL_TOUCHED, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector8( mType, SIGNAL_VISIBILITY_CHANGED, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector9( mType, SIGNAL_LAYOUT_DIRECTION_CHANGED, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector10( mType, SIGNAL_CHILD_ADDED, &Actor::DoConnectSignal );
-SignalConnectorType signalConnector11( mType, SIGNAL_CHILD_REMOVED, &Actor::DoConnectSignal );
+SignalConnectorType signalConnector2(mType, std::string(SIGNAL_HOVERED), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector3(mType, std::string(SIGNAL_WHEEL_EVENT), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector4(mType, std::string(SIGNAL_ON_SCENE), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector5(mType, std::string(SIGNAL_OFF_SCENE), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector6(mType, std::string(SIGNAL_ON_RELAYOUT), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector7(mType, std::string(SIGNAL_TOUCHED), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector8(mType, std::string(SIGNAL_VISIBILITY_CHANGED), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector9(mType, std::string(SIGNAL_LAYOUT_DIRECTION_CHANGED), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector10(mType, std::string(SIGNAL_CHILD_ADDED), &Actor::DoConnectSignal);
+SignalConnectorType signalConnector11(mType, std::string(SIGNAL_CHILD_REMOVED), &Actor::DoConnectSignal);
 
-TypeAction a1( mType, ACTION_SHOW, &Actor::DoAction );
-TypeAction a2( mType, ACTION_HIDE, &Actor::DoAction );
+TypeAction a1(mType, std::string(ACTION_SHOW), &Actor::DoAction);
+TypeAction a2(mType, std::string(ACTION_HIDE), &Actor::DoAction);
 
 /**
  * @brief Extract a given dimension from a Vector2
@@ -1409,43 +1409,45 @@ bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
   bool connected( true );
   Actor* actor = static_cast< Actor* >( object ); // TypeRegistry guarantees that this is the correct type.
 
-  if( 0 == signalName.compare( SIGNAL_HOVERED ) )
+  std::string_view name(signalName);
+
+  if(name == SIGNAL_HOVERED)
   {
     actor->HoveredSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_WHEEL_EVENT ) )
+  else if(signalName == SIGNAL_WHEEL_EVENT)
   {
     actor->WheelEventSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_ON_SCENE ) )
+  else if(name == SIGNAL_ON_SCENE)
   {
     actor->OnSceneSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_OFF_SCENE ) )
+  else if(name == SIGNAL_OFF_SCENE)
   {
     actor->OffSceneSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_ON_RELAYOUT ) )
+  else if(name == SIGNAL_ON_RELAYOUT)
   {
     actor->OnRelayoutSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_TOUCHED ) )
+  else if(name == SIGNAL_TOUCHED)
   {
     actor->TouchedSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_VISIBILITY_CHANGED ) )
+  else if(name == SIGNAL_VISIBILITY_CHANGED)
   {
     actor->VisibilityChangedSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_LAYOUT_DIRECTION_CHANGED ) )
+  else if(name == SIGNAL_LAYOUT_DIRECTION_CHANGED)
   {
     actor->LayoutDirectionChangedSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_CHILD_ADDED ) )
+  else if(name == SIGNAL_CHILD_ADDED)
   {
     actor->ChildAddedSignal().Connect( tracker, functor );
   }
-  else if( 0 == signalName.compare( SIGNAL_CHILD_REMOVED ) )
+  else if(name == SIGNAL_CHILD_REMOVED)
   {
     actor->ChildRemovedSignal().Connect( tracker, functor );
   }
@@ -1908,12 +1910,13 @@ bool Actor::DoAction( BaseObject* object, const std::string& actionName, const P
 
   if( actor )
   {
-    if( 0 == actionName.compare( ACTION_SHOW ) )
+    std::string_view name(actionName);
+    if(name == ACTION_SHOW)
     {
       actor->SetVisible( true );
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_HIDE ) )
+    else if(name == ACTION_HIDE)
     {
       actor->SetVisible( false );
       done = true;
index dfb3011..d164abb 100644 (file)
@@ -67,10 +67,10 @@ DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, LayerDefaul
 
 // Actions
 
-const char* const ACTION_RAISE =           "raise";
-const char* const ACTION_LOWER =           "lower";
-const char* const ACTION_RAISE_TO_TOP =    "raiseToTop";
-const char* const ACTION_LOWER_TO_BOTTOM = "lowerToBottom";
+static constexpr std::string_view ACTION_RAISE           = "raise";
+static constexpr std::string_view ACTION_LOWER           = "lower";
+static constexpr std::string_view ACTION_RAISE_TO_TOP    = "raiseToTop";
+static constexpr std::string_view ACTION_LOWER_TO_BOTTOM = "lowerToBottom";
 
 BaseHandle Create()
 {
@@ -79,10 +79,10 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create, LayerDefaultProperties );
 
-TypeAction a1( mType, ACTION_RAISE, &Layer::DoAction );
-TypeAction a2( mType, ACTION_LOWER, &Layer::DoAction );
-TypeAction a3( mType, ACTION_RAISE_TO_TOP, &Layer::DoAction );
-TypeAction a4( mType, ACTION_LOWER_TO_BOTTOM, &Layer::DoAction );
+TypeAction a1(mType, std::string(ACTION_RAISE), &Layer::DoAction);
+TypeAction a2(mType, std::string(ACTION_LOWER), &Layer::DoAction);
+TypeAction a3(mType, std::string(ACTION_RAISE_TO_TOP), &Layer::DoAction);
+TypeAction a4(mType, std::string(ACTION_LOWER_TO_BOTTOM), &Layer::DoAction);
 
 } // unnamed namespace
 
@@ -507,22 +507,24 @@ bool Layer::DoAction( BaseObject* object, const std::string& actionName, const P
 
   if( layer )
   {
-    if( 0 == actionName.compare( ACTION_RAISE ) )
+    std::string_view name(actionName);
+
+    if(name == ACTION_RAISE)
     {
       layer->Raise();
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_LOWER ) )
+    else if(name == ACTION_LOWER)
     {
       layer->Lower();
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_RAISE_TO_TOP ) )
+    else if(name == ACTION_RAISE_TO_TOP)
     {
       layer->RaiseToTop();
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_LOWER_TO_BOTTOM ) )
+    else if(name == ACTION_LOWER_TO_BOTTOM)
     {
       layer->LowerToBottom();
       done = true;
index 0a05d70..e9d7578 100644 (file)
@@ -56,13 +56,13 @@ namespace
 
 // Signals
 
-const char* const SIGNAL_FINISHED = "finished";
+static constexpr std::string_view SIGNAL_FINISHED = "finished";
 
 // Actions
 
-const char* const ACTION_PLAY =     "play";
-const char* const ACTION_STOP =     "stop";
-const char* const ACTION_PAUSE =    "pause";
+static constexpr std::string_view ACTION_PLAY  = "play";
+static constexpr std::string_view ACTION_STOP  = "stop";
+static constexpr std::string_view ACTION_PAUSE = "pause";
 
 BaseHandle Create()
 {
@@ -71,11 +71,11 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid( Dali::Animation ), typeid( Dali::BaseHandle ), Create );
 
-SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &Animation::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, std::string(SIGNAL_FINISHED), &Animation::DoConnectSignal);
 
-TypeAction action1( mType, ACTION_PLAY,  &Animation::DoAction );
-TypeAction action2( mType, ACTION_STOP,  &Animation::DoAction );
-TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction );
+TypeAction action1(mType, std::string(ACTION_PLAY), &Animation::DoAction);
+TypeAction action2(mType, std::string(ACTION_STOP), &Animation::DoAction);
+TypeAction action3(mType, std::string(ACTION_PAUSE), &Animation::DoAction);
 
 const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::BAKE );
 const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BAKE_FINAL );
@@ -443,67 +443,67 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha
   {
     case Property::BOOLEAN:
     {
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new AnimateByBoolean(relativeValue.Get<bool>()),
-                                                          alpha,
-                                                          period ) );
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        AnimateByBoolean(relativeValue.Get<bool>()),
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByInteger(relativeValue.Get<int32_t>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByInteger(relativeValue.Get<int32_t>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::FLOAT:
     {
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new AnimateByFloat(relativeValue.Get<float>()),
-                                                           alpha,
-                                                           period ) );
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         AnimateByFloat(relativeValue.Get<float>()),
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Property::VECTOR2:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector2(relativeValue.Get<Vector2>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector2(relativeValue.Get<Vector2>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR3:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector3(relativeValue.Get<Vector3>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector3(relativeValue.Get<Vector3>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR4:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateByVector4(relativeValue.Get<Vector4>()),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateByVector4(relativeValue.Get<Vector4>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
@@ -511,12 +511,12 @@ void Animation::AnimateBy(Property& target, Property::Value relativeValue, Alpha
     {
       AngleAxis angleAxis = relativeValue.Get<AngleAxis>();
 
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
-                                                                alpha,
-                                                                period ) );
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -564,78 +564,78 @@ void Animation::AnimateTo(Property& target, Property::Value destinationValue, Al
   {
     case Property::BOOLEAN:
     {
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new AnimateToBoolean( destinationValue.Get<bool>() ),
-                                                          alpha,
-                                                          period ) );
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        AnimateToBoolean(destinationValue.Get<bool>()),
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Property::INTEGER:
     {
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToInteger( destinationValue.Get<int32_t>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToInteger(destinationValue.Get<int32_t>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::FLOAT:
     {
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new AnimateToFloat( destinationValue.Get<float>() ),
-                                                           alpha,
-                                                           period ) );
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         AnimateToFloat(destinationValue.Get<float>()),
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Property::VECTOR2:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector2( destinationValue.Get<Vector2>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector2(destinationValue.Get<Vector2>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR3:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector3( destinationValue.Get<Vector3>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector3(destinationValue.Get<Vector3>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::VECTOR4:
     {
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new AnimateToVector4( destinationValue.Get<Vector4>() ),
-                                                             alpha,
-                                                             period ) );
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           AnimateToVector4(destinationValue.Get<Vector4>()),
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Property::ROTATION:
     {
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new RotateToQuaternion( destinationValue.Get<Quaternion>() ),
-                                                                alpha,
-                                                                period ) );
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              RotateToQuaternion(destinationValue.Get<Quaternion>()),
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -703,99 +703,85 @@ void Animation::AnimateBetween( Property target, const KeyFrames& keyFrames, Alp
   {
     case Dali::Property::BOOLEAN:
     {
-      const KeyFrameBoolean* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameBooleanPtr kfCopy = KeyFrameBoolean::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<bool>::New( object,
-                                                          target.propertyIndex,
-                                                          target.componentIndex,
-                                                          new KeyFrameBooleanFunctor(kfCopy),
-                                                          alpha,
-                                                          period ) );
+      auto kf = GetSpecialization<const KeyFrameBoolean*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<bool>::New(object,
+                                                        target.propertyIndex,
+                                                        target.componentIndex,
+                                                        KeyFrameBooleanFunctor(*kf), // takes a copy of the keyframe
+                                                        alpha,
+                                                        period));
       break;
     }
 
     case Dali::Property::INTEGER:
     {
-      const KeyFrameInteger* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<int32_t>::New( object,
-                                                         target.propertyIndex,
-                                                         target.componentIndex,
-                                                         new KeyFrameIntegerFunctor(kfCopy,interpolation),
-                                                         alpha,
-                                                         period ) );
+      auto kf = GetSpecialization<const KeyFrameInteger*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<int32_t>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameIntegerFunctor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::FLOAT:
     {
-      const KeyFrameNumber* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<float>::New( object,
-                                                           target.propertyIndex,
-                                                           target.componentIndex,
-                                                           new KeyFrameNumberFunctor(kfCopy,interpolation),
-                                                           alpha,
-                                                           period ) );
+      auto kf = GetSpecialization<const KeyFrameNumber*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<float>::New(object,
+                                                         target.propertyIndex,
+                                                         target.componentIndex,
+                                                         KeyFrameNumberFunctor(*kf, interpolation), // takes a copy of the keyframe
+                                                         alpha,
+                                                         period));
       break;
     }
 
     case Dali::Property::VECTOR2:
     {
-      const KeyFrameVector2* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector2Ptr kfCopy = KeyFrameVector2::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector2Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector2*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector2>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector2Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::VECTOR3:
     {
-      const KeyFrameVector3* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector3Ptr kfCopy = KeyFrameVector3::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector3Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector3*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector3>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector3Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::VECTOR4:
     {
-      const KeyFrameVector4* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameVector4Ptr kfCopy = KeyFrameVector4::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
-                                                             target.propertyIndex,
-                                                             target.componentIndex,
-                                                             new KeyFrameVector4Functor(kfCopy,interpolation),
-                                                             alpha,
-                                                             period ) );
+      auto kf = GetSpecialization<const KeyFrameVector4*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Vector4>::New(object,
+                                                           target.propertyIndex,
+                                                           target.componentIndex,
+                                                           KeyFrameVector4Functor(*kf, interpolation), // takes a copy of the keyframe
+                                                           alpha,
+                                                           period));
       break;
     }
 
     case Dali::Property::ROTATION:
     {
-      const KeyFrameQuaternion* kf;
-      GetSpecialization(keyFrames, kf);
-      KeyFrameQuaternionPtr kfCopy = KeyFrameQuaternion::Clone(*kf);
-      AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
-                                                                target.propertyIndex,
-                                                                target.componentIndex,
-                                                                new KeyFrameQuaternionFunctor(kfCopy),
-                                                                alpha,
-                                                                period ) );
+      auto kf = GetSpecialization<const KeyFrameQuaternion*>(keyFrames);
+      AddAnimatorConnector(AnimatorConnector<Quaternion>::New(object,
+                                                              target.propertyIndex,
+                                                              target.componentIndex,
+                                                              KeyFrameQuaternionFunctor(*kf), // takes a copy of the keyframe
+                                                              alpha,
+                                                              period));
       break;
     }
 
@@ -860,7 +846,7 @@ bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface*
   bool connected( false );
   Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
 
-  if( 0 == signalName.compare( SIGNAL_FINISHED ) )
+  if(SIGNAL_FINISHED == signalName)
   {
     animation->FinishedSignal().Connect( tracker, functor );
     connected = true;
@@ -900,23 +886,23 @@ void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward,
   PathPtr pathCopy = Path::Clone(path);
 
   //Position animation
-  AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
-                                                         Dali::Actor::Property::POSITION,
-                                                         Property::INVALID_COMPONENT_INDEX,
-                                                         new PathPositionFunctor( pathCopy ),
-                                                         alpha,
-                                                         period ) );
+  AddAnimatorConnector(AnimatorConnector<Vector3>::New(actor,
+                                                       Dali::Actor::Property::POSITION,
+                                                       Property::INVALID_COMPONENT_INDEX,
+                                                       PathPositionFunctor(pathCopy),
+                                                       alpha,
+                                                       period));
 
   //If forward is zero, PathRotationFunctor will always return the unit quaternion
   if( forward != Vector3::ZERO )
   {
     //Rotation animation
-    AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
-                                                              Dali::Actor::Property::ORIENTATION,
-                                                              Property::INVALID_COMPONENT_INDEX,
-                                                              new PathRotationFunctor( pathCopy, forward ),
-                                                              alpha,
-                                                              period ) );
+    AddAnimatorConnector(AnimatorConnector<Quaternion>::New(actor,
+                                                            Dali::Actor::Property::ORIENTATION,
+                                                            Property::INVALID_COMPONENT_INDEX,
+                                                            PathRotationFunctor(pathCopy, forward),
+                                                            alpha,
+                                                            period));
   }
 }
 
@@ -924,24 +910,24 @@ void Animation::Show(Actor& actor, float delaySeconds)
 {
   ExtendDuration( TimePeriod(delaySeconds, 0) );
 
-  AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
-                                                      Dali::Actor::Property::VISIBLE,
-                                                      Property::INVALID_COMPONENT_INDEX,
-                                                      new AnimateToBoolean(SHOW_VALUE),
-                                                      mDefaultAlpha,
-                                                      TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
+  AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
+                                                    Dali::Actor::Property::VISIBLE,
+                                                    Property::INVALID_COMPONENT_INDEX,
+                                                    AnimateToBoolean(SHOW_VALUE),
+                                                    mDefaultAlpha,
+                                                    TimePeriod(delaySeconds, 0.0f /*immediate*/)));
 }
 
 void Animation::Hide(Actor& actor, float delaySeconds)
 {
   ExtendDuration( TimePeriod(delaySeconds, 0) );
 
-  AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
-                                                      Dali::Actor::Property::VISIBLE,
-                                                      Property::INVALID_COMPONENT_INDEX,
-                                                      new AnimateToBoolean(HIDE_VALUE),
-                                                      mDefaultAlpha,
-                                                      TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
+  AddAnimatorConnector(AnimatorConnector<bool>::New(actor,
+                                                    Dali::Actor::Property::VISIBLE,
+                                                    Property::INVALID_COMPONENT_INDEX,
+                                                    AnimateToBoolean(HIDE_VALUE),
+                                                    mDefaultAlpha,
+                                                    TimePeriod(delaySeconds, 0.0f /*immediate*/)));
 }
 
 bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
@@ -951,7 +937,9 @@ bool Animation::DoAction( BaseObject* object, const std::string& actionName, con
 
   if( animation )
   {
-    if( 0 == actionName.compare( ACTION_PLAY ) )
+    std::string_view name(actionName);
+
+    if(name == ACTION_PLAY)
     {
       if( Property::Value* value = attributes.Find("duration", Property::FLOAT) )
       {
@@ -961,12 +949,12 @@ bool Animation::DoAction( BaseObject* object, const std::string& actionName, con
       animation->Play();
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_STOP ) )
+    else if(name == ACTION_STOP)
     {
       animation->Stop();
       done = true;
     }
-    else if( 0 == actionName.compare( ACTION_PAUSE ) )
+    else if(name == ACTION_PAUSE)
     {
       animation->Pause();
       done = true;
index 8e839fb..8699012 100644 (file)
@@ -49,21 +49,16 @@ public:
   /**
    * Constructor.
    */
-  AnimatorConnectorBase(
-      Object& object,
-      Property::Index propertyIndex,
-      int32_t componentIndex,
-      Internal::AnimatorFunctionBase* animatorFunction,
-      AlphaFunction alpha,
-      const TimePeriod& period)
-  : mParent( nullptr ),
-    mObject( &object ),
-    mAnimator( nullptr ),
-    mAnimatorFunction( animatorFunction ),
+  AnimatorConnectorBase(Object&           object,
+                        Property::Index   propertyIndex,
+                        int32_t           componentIndex,
+                        AlphaFunction     alpha,
+                        const TimePeriod& period)
+  : mObject(&object),
     mAlphaFunction(alpha),
     mTimePeriod(period),
-    mPropertyIndex( propertyIndex ),
-    mComponentIndex( componentIndex )
+    mPropertyIndex(propertyIndex),
+    mComponentIndex(componentIndex)
   {
     object.AddObserver( *this );
   }
@@ -77,13 +72,6 @@ public:
     {
       mObject->RemoveObserver( *this );
     }
-
-    // If there is not a SceneGraph::Animator, the AnimatorConnector is responsible for deleting the mAnimatorFunction
-    // otherwise, the animator function ownership is transferred to the SceneGraph::Animator
-    if( !mAnimator )
-    {
-      delete mAnimatorFunction;
-    }
   }
 
   /**
@@ -96,7 +84,6 @@ public:
   void CreateAnimator()
   {
     DALI_ASSERT_DEBUG( mAnimator == nullptr );
-    DALI_ASSERT_DEBUG( mAnimatorFunction != nullptr );
     DALI_ASSERT_DEBUG( mParent != nullptr );
 
     //Get the PropertyOwner the animator is going to animate
@@ -206,18 +193,15 @@ private:
   }
 
 protected:
-
-  Animation* mParent; ///< The parent owns the connector.
-  Object* mObject; ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called.
-  SceneGraph::AnimatorBase* mAnimator;
-  Internal::AnimatorFunctionBase* mAnimatorFunction;  ///< Owned by the animator connector until an Scenegraph::Animator is created
+  Animation*                mParent{nullptr}; ///< The parent owns the connector.
+  Object*                   mObject;          ///< Not owned by the animator connector. Valid until ObjectDestroyed() is called.
+  SceneGraph::AnimatorBase* mAnimator{nullptr};
 
   AlphaFunction mAlphaFunction;
-  TimePeriod mTimePeriod;
+  TimePeriod    mTimePeriod;
 
   Property::Index mPropertyIndex;
-  int32_t mComponentIndex;
-
+  int32_t         mComponentIndex;
 };
 
 } // namespace Internal
index 48bd693..434fdc9 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+//EXTERNAL INCLUDES
+#include <functional>
+
 // INTERNAL INCLUDES
 #include <dali/internal/event/animation/animator-connector-base.h>
 #include <dali/internal/event/animation/animation-impl.h>
@@ -41,6 +44,10 @@ namespace Internal
 template < typename PropertyType >
 class AnimatorConnector : public AnimatorConnectorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   using AnimatorType = SceneGraph::Animator< PropertyType, PropertyAccessor<PropertyType> >;
@@ -56,19 +63,19 @@ public:
    * @param[in] period The time period of the animator.
    * @return A pointer to a newly allocated animator connector.
    */
-  static AnimatorConnectorBase* New( Object& object,
-                                     Property::Index propertyIndex,
-                                     int32_t componentIndex,
-                                     AnimatorFunctionBase* animatorFunction,
-                                     AlphaFunction alpha,
-                                     const TimePeriod& period )
+  static AnimatorConnectorBase* New(Object&           object,
+                                    Property::Index   propertyIndex,
+                                    int32_t           componentIndex,
+                                    AnimatorFunction  animatorFunction,
+                                    AlphaFunction     alpha,
+                                    const TimePeriod& period)
   {
-    return new AnimatorConnector( object,
-                                  propertyIndex,
-                                  componentIndex,
-                                  animatorFunction,
-                                  alpha,
-                                  period );
+    return new AnimatorConnector(object,
+                                 propertyIndex,
+                                 componentIndex,
+                                 std::move(animatorFunction),
+                                 alpha,
+                                 period);
   }
 
   /**
@@ -81,13 +88,14 @@ private:
   /**
    * Private constructor; see also AnimatorConnector::New().
    */
-  AnimatorConnector( Object& object,
-                     Property::Index propertyIndex,
-                     int32_t componentIndex,
-                     Internal::AnimatorFunctionBase* animatorFunction,
-                     AlphaFunction alpha,
-                     const TimePeriod& period )
-  : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period )
+  AnimatorConnector(Object&           object,
+                    Property::Index   propertyIndex,
+                    int32_t           componentIndex,
+                    AnimatorFunction  animatorFunction,
+                    AlphaFunction     alpha,
+                    const TimePeriod& period)
+  : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period),
+    mAnimatorFunction(std::move(animatorFunction))
   {
   }
 
@@ -113,7 +121,11 @@ private:
     {
       if( baseProperty.IsTransformManagerProperty() )
       {
-        mAnimator = SceneGraph::AnimatorTransformProperty< PropertyType,TransformManagerPropertyAccessor<PropertyType> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+        mAnimator = SceneGraph::AnimatorTransformProperty<PropertyType, TransformManagerPropertyAccessor<PropertyType> >::New(propertyOwner,
+                                                                                                                              baseProperty,
+                                                                                                                              std::move(mAnimatorFunction),
+                                                                                                                              mAlphaFunction,
+                                                                                                                              mTimePeriod);
         // Don't reset transform manager properties - TransformManager will do it more efficiently
       }
       else
@@ -124,8 +136,12 @@ private:
     else
     {
       // Create the animator and resetter
-      mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction,
-                                     mAlphaFunction, mTimePeriod );
+      mAnimator = AnimatorType::New(propertyOwner,
+                                    *animatableProperty,
+                                    std::move(mAnimatorFunction),
+                                    mAlphaFunction,
+                                    mTimePeriod);
+
       resetterRequired = true;
     }
     return resetterRequired;
@@ -138,6 +154,10 @@ private:
 template <>
 class AnimatorConnector< float > : public AnimatorConnectorBase
 {
+  using AnimatorFunction = std::function<float(float, const float&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   using AnimatorType = SceneGraph::Animator< float, PropertyAccessor<float> >;
@@ -153,19 +173,19 @@ public:
    * @param[in] period The time period of the animator.
    * @return A pointer to a newly allocated animator connector.
    */
-  static AnimatorConnectorBase* New( Object& object,
-                                     Property::Index propertyIndex,
-                                     int32_t componentIndex,
-                                     AnimatorFunctionBase* animatorFunction,
-                                     AlphaFunction alpha,
-                                     const TimePeriod& period )
+  static AnimatorConnectorBase* New(Object&           object,
+                                    Property::Index   propertyIndex,
+                                    int32_t           componentIndex,
+                                    AnimatorFunction  animatorFunction,
+                                    AlphaFunction     alpha,
+                                    const TimePeriod& period)
   {
-    return new AnimatorConnector( object,
-                                  propertyIndex,
-                                  componentIndex,
-                                  animatorFunction,
-                                  alpha,
-                                  period );
+    return new AnimatorConnector(object,
+                                 propertyIndex,
+                                 componentIndex,
+                                 std::move(animatorFunction),
+                                 alpha,
+                                 period);
   }
 
   /**
@@ -178,13 +198,14 @@ private:
   /**
    * Private constructor; see also AnimatorConnector::New().
    */
-  AnimatorConnector( Object& object,
-                     Property::Index propertyIndex,
-                     int32_t componentIndex,
-                     Internal::AnimatorFunctionBase* animatorFunction,
-                     AlphaFunction alpha,
-                     const TimePeriod& period )
-  : AnimatorConnectorBase( object, propertyIndex, componentIndex, animatorFunction, alpha, period )
+  AnimatorConnector(Object&           object,
+                    Property::Index   propertyIndex,
+                    int32_t           componentIndex,
+                    AnimatorFunction  animatorFunction,
+                    AlphaFunction     alpha,
+                    const TimePeriod& period)
+  : AnimatorConnectorBase(object, propertyIndex, componentIndex, alpha, period),
+    mAnimatorFunction(std::move(animatorFunction))
   {
   }
 
@@ -210,7 +231,11 @@ private:
       {
         if( baseProperty.IsTransformManagerProperty() )
         {
-          mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyAccessor<float> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+          mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyAccessor<float> >::New(propertyOwner,
+                                                                                                                  baseProperty,
+                                                                                                                  std::move(mAnimatorFunction),
+                                                                                                                  mAlphaFunction,
+                                                                                                                  mTimePeriod);
           // Don't reset transform manager properties - TransformManager will do it more efficiently
         }
         else
@@ -221,8 +246,12 @@ private:
       else
       {
         // Create the animator and resetter
-        mAnimator = AnimatorType::New( propertyOwner, *animatableProperty, mAnimatorFunction,
-                                       mAlphaFunction, mTimePeriod );
+        mAnimator = AnimatorType::New(propertyOwner,
+                                      *animatableProperty,
+                                      std::move(mAnimatorFunction),
+                                      mAlphaFunction,
+                                      mTimePeriod);
+
         resetterRequired = true;
       }
     }
@@ -242,20 +271,20 @@ private:
           {
             case 0:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector2> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector2> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 1:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector2> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector2> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             default:
@@ -279,15 +308,27 @@ private:
             {
               if( mComponentIndex == 0 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,0> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 0> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
               else if( mComponentIndex == 1 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,1> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 1> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
               else if( mComponentIndex == 2 )
               {
-                mAnimator = SceneGraph::AnimatorTransformProperty< float,TransformManagerPropertyComponentAccessor<Vector3,2> >::New( propertyOwner, baseProperty, mAnimatorFunction, mAlphaFunction, mTimePeriod );
+                mAnimator = SceneGraph::AnimatorTransformProperty<float, TransformManagerPropertyComponentAccessor<Vector3, 2> >::New(propertyOwner,
+                                                                                                                                      baseProperty,
+                                                                                                                                      std::move(mAnimatorFunction),
+                                                                                                                                      mAlphaFunction,
+                                                                                                                                      mTimePeriod);
               }
             }
             else
@@ -305,29 +346,29 @@ private:
             {
               case 0:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               case 1:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               case 2:
               {
-                mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector3> >::New( propertyOwner,
-                                                                                                     *animatableProperty,
-                                                                                                     mAnimatorFunction,
-                                                                                                     mAlphaFunction,
-                                                                                                     mTimePeriod );
+                mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorZ<Vector3> >::New(propertyOwner,
+                                                                                                   *animatableProperty,
+                                                                                                   std::move(mAnimatorFunction),
+                                                                                                   mAlphaFunction,
+                                                                                                   mTimePeriod);
                 break;
               }
               default:
@@ -353,38 +394,38 @@ private:
           {
             case 0:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorX<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorX<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 1:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorY<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorY<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 2:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorZ<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorZ<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
             case 3:
             {
-              mAnimator = SceneGraph::Animator< float, PropertyComponentAccessorW<Vector4> >::New( propertyOwner,
-                                                                                                   *animatableProperty,
-                                                                                                   mAnimatorFunction,
-                                                                                                   mAlphaFunction,
-                                                                                                   mTimePeriod );
+              mAnimator = SceneGraph::Animator<float, PropertyComponentAccessorW<Vector4> >::New(propertyOwner,
+                                                                                                 *animatableProperty,
+                                                                                                 std::move(mAnimatorFunction),
+                                                                                                 mAlphaFunction,
+                                                                                                 mTimePeriod);
               break;
             }
 
index 820340c..c7f0444 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <algorithm>
+
 // INTERNAL INCLUDES
 #include <dali/internal/event/animation/progress-value.h>
 #include <dali/public-api/animation/animation.h>
@@ -27,171 +30,76 @@ namespace Dali
 {
 namespace Internal
 {
-
-class KeyFrameChannelBase
-{
-public:
-  enum KeyFrameChannelId
-  {
-    Translate, Rotate, Scale,
-  };
-
-  KeyFrameChannelBase(KeyFrameChannelId channel_id)
-  : mChannelId(channel_id)
-  {
-  }
-
-  virtual ~KeyFrameChannelBase() = default;
-
-  KeyFrameChannelId GetId() const
-  {
-    return mChannelId;
-  }
-
-  virtual bool IsActive(float progress) = 0;
-
-protected:
-  KeyFrameChannelId       mChannelId;
-};
-
-
-template <typename V>
-class KeyFrameChannel : public KeyFrameChannelBase
+template<typename V>
+struct KeyFrameChannel
 {
-public:
-  using ProgressValues = std::vector<ProgressValue<V> >;
-
-  KeyFrameChannel(KeyFrameChannelId channel_id, ProgressValues& values )
-  : KeyFrameChannelBase(channel_id),
-    mValues(values)
-  {
-  }
-
-  ~KeyFrameChannel() override = default;
-
-  bool IsActive (float progress) override;
+  using ProgressValues = std::vector<ProgressValue<V>>;
 
-  V GetValue(float progress, Dali::Animation::Interpolation interpolation) const;
-
-  bool FindInterval(typename ProgressValues::iterator& start,
-                    typename ProgressValues::iterator& end,
-                    float progress) const;
-
-  ProgressValues& mValues;
-};
-
-template <class V>
-bool KeyFrameChannel<V>::IsActive (float progress)
-{
-  bool active = false;
-  if(!mValues.empty())
+  bool IsActive(float progress) const
   {
-    ProgressValue<V>& first = mValues.front();
-
-    if( progress >= first.GetProgress() )
+    if(!mValues.empty() && (progress >= mValues[0].GetProgress()))
     {
-      active = true;
+      return true;
     }
+    return false;
   }
-  return active;
-}
 
-/**
- * Use a linear search to find the interval containing progress
- */
-template <class V>
-bool KeyFrameChannel<V>::FindInterval(
-  typename ProgressValues::iterator& start,
-  typename ProgressValues::iterator& end,
-  float progress) const
-{
-  bool found = false;
-  typename std::vector<ProgressValue<V> >::iterator iter = mValues.begin();
-  typename std::vector<ProgressValue<V> >::iterator prevIter = iter;
-
-  while(iter != mValues.end() && iter->GetProgress() <= progress)
-  {
-    prevIter = iter;
-    ++iter;
-  }
-
-  if(iter == mValues.end())
-  {
-    --prevIter;
-    --iter;
-  }
-
-  if(prevIter->GetProgress() <= progress
-     &&
-     iter->GetProgress() > progress)
+  V GetValue(float progress, Dali::Animation::Interpolation interpolation) const
   {
-    found = true;
-    start = prevIter;
-    end   = iter;
-  }
+    V interpolatedV{};
 
-  return found;
-}
-
-template <class V>
-V KeyFrameChannel<V>::GetValue (float progress, Dali::Animation::Interpolation interpolation) const
-{
-  ProgressValue<V>&  firstPV =  mValues.front();
-
-  typename std::vector<ProgressValue<V> >::iterator start;
-  typename std::vector<ProgressValue<V> >::iterator end;
-
-  V interpolatedV = firstPV.GetValue();
-  if(progress >= mValues.back().GetProgress() )
-  {
-    interpolatedV = mValues.back().GetValue(); // This should probably be last value...
-  }
-  else if(FindInterval(start, end, progress))
-  {
-    float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
-
-    if( interpolation == Dali::Animation::LINEAR )
+    if(progress >= mValues.back().GetProgress())
     {
-      Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress);
+      interpolatedV = mValues.back().GetValue();
     }
     else
     {
-      //Calculate prev and next values
-      V prev;
-      if( start != mValues.begin() )
-      {
-        prev = (start-1)->GetValue();
-      }
-      else
-      {
-        //Project next value through start point
-        prev = start->GetValue() + (start->GetValue()-(start+1)->GetValue());
-      }
+      auto end   = std::find_if(mValues.begin(), mValues.end(), [=](const auto& element) { return element.GetProgress() > progress; });
+      auto start = end - 1;
 
-      V next;
-      if( end != mValues.end()-1)
-      {
-        next = (end+1)->GetValue();
-      }
-      else
+      const bool validInterval = (end != mValues.end()) && (start->GetProgress() <= progress);
+
+      if(validInterval)
       {
-        //Project prev value through end point
-        next = end->GetValue() + (end->GetValue()-(end-1)->GetValue());
+        float frameProgress = (progress - start->GetProgress()) / (end->GetProgress() - start->GetProgress());
+        if(interpolation == Dali::Animation::LINEAR)
+        {
+          Interpolate(interpolatedV, start->GetValue(), end->GetValue(), frameProgress);
+        }
+        else
+        {
+          //Calculate prev and next values
+          V prev;
+          if(start != mValues.begin())
+          {
+            prev = (start - 1)->GetValue();
+          }
+          else
+          {
+            //Project next value through start point
+            prev = start->GetValue() + (start->GetValue() - (start + 1)->GetValue());
+          }
+
+          V next;
+          if(end != mValues.end() - 1)
+          {
+            next = (end + 1)->GetValue();
+          }
+          else
+          {
+            //Project prev value through end point
+            next = end->GetValue() + (end->GetValue() - (end - 1)->GetValue());
+          }
+
+          CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress);
+        }
       }
-
-      CubicInterpolate(interpolatedV, prev, start->GetValue(), end->GetValue(), next, frameProgress);
     }
+    return interpolatedV;
   }
 
-  return interpolatedV;
-}
-
-using KeyFrameChannelNumber     = KeyFrameChannel<float>;
-using KeyFrameChannelVector2    = KeyFrameChannel<Vector2>;
-using KeyFrameChannelVector3    = KeyFrameChannel<Vector3>;
-using KeyFrameChannelVector4    = KeyFrameChannel<Vector4>;
-using KeyFrameChannelQuaternion = KeyFrameChannel<Quaternion>;
-using KeyFrameChannelAngleAxis  = KeyFrameChannel<AngleAxis>;
+  ProgressValues mValues;
+};
 
 } // Internal
 } // namespace Dali
index fa265cc..7ecfd6b 100644 (file)
@@ -28,14 +28,6 @@ KeyFrames* KeyFrames::New()
   return new KeyFrames();
 }
 
-KeyFrames::KeyFrames()
-  : mType(Property::NONE),
-    mKeyFrames(nullptr)
-{
-}
-
-KeyFrames::~KeyFrames() = default;
-
 void KeyFrames::CreateKeyFramesSpec(Property::Type type)
 {
   mType = type;
@@ -44,37 +36,37 @@ void KeyFrames::CreateKeyFramesSpec(Property::Type type)
   {
     case Property::BOOLEAN:
     {
-      mKeyFrames = Internal::KeyFrameBoolean::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameBoolean>();
       break;
     }
     case Property::INTEGER:
     {
-      mKeyFrames = Internal::KeyFrameInteger::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameInteger>();
       break;
     }
     case Property::FLOAT:
     {
-      mKeyFrames = Internal::KeyFrameNumber::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameNumber>();
       break;
     }
     case Property::VECTOR2:
     {
-      mKeyFrames = Internal::KeyFrameVector2::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector2>();
       break;
     }
     case Property::VECTOR3:
     {
-      mKeyFrames = Internal::KeyFrameVector3::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector3>();
       break;
     }
     case Property::VECTOR4:
     {
-      mKeyFrames = Internal::KeyFrameVector4::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameVector4>();
       break;
     }
     case Property::ROTATION:
     {
-      mKeyFrames = Internal::KeyFrameQuaternion::New();
+      mKeyFrames = std::make_unique<Internal::KeyFrameQuaternion>();
       break;
     }
     default:
@@ -90,7 +82,7 @@ Property::Type KeyFrames::GetType() const
   return mType;
 }
 
-void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
+void KeyFrames::Add(float time, const Property::Value& value, AlphaFunction alpha)
 {
   if(mType == Property::NONE)
   {
@@ -100,49 +92,51 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
   // Once we have created a type, can only add values of the same type
   DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
 
-  DALI_ASSERT_DEBUG(mKeyFrames);
+  auto keyframes = mKeyFrames.get();
+
+  DALI_ASSERT_DEBUG(keyframes);
 
   switch(mType)
   {
     case Property::BOOLEAN:
     {
-      Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
+      Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(keyframes);
       kf->AddKeyFrame(time, value.Get<bool>(), alpha);
       break;
     }
     case Property::INTEGER:
     {
-      Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
+      Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(keyframes);
       kf->AddKeyFrame(time, value.Get<int>(), alpha);
       break;
     }
     case Property::FLOAT:
     {
-      Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
+      Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(keyframes);
       kf->AddKeyFrame(time, value.Get<float>(), alpha);
       break;
     }
     case Property::VECTOR2:
     {
-      Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
+      Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
       break;
     }
     case Property::VECTOR3:
     {
-      Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
+      Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
       break;
     }
     case Property::VECTOR4:
     {
-      Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
+      Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
       break;
     }
     case Property::ROTATION:
     {
-      Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
+      Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(keyframes);
       kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
       break;
     }
@@ -154,7 +148,7 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
 
 KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
 {
-  return mKeyFrames.Get();
+  return mKeyFrames.get();
 }
 
 Property::Value KeyFrames::GetLastKeyFrameValue() const
index 989e481..1f21625 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <memory>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/animation/key-frames.h>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/animation/alpha-function.h>
-#include <dali/internal/event/animation/progress-value.h>
 #include <dali/internal/event/animation/key-frame-channel.h>
 
 namespace Dali
@@ -32,7 +34,6 @@ namespace Internal
 {
 class KeyFrameSpec;
 class KeyFrames;
-using KeyFramesPtr = IntrusivePtr<KeyFrames>;
 
 /**
  * KeyFrames class is responsible for creating and building a specialized KeyFrame class
@@ -43,24 +44,7 @@ class KeyFrames : public BaseObject
 public:
   static KeyFrames* New();
 
-  /**
-   * Instantiate an empty KeyFrames object
-   */
-  KeyFrames();
-
-protected:
-  ~KeyFrames() override;
-
 private:
-  /**
-   * Don't allow copy constructor
-   */
-  KeyFrames(const KeyFrames& rhs);
-
-  /**
-   * Don't allow copy operator
-   */
-  KeyFrames& operator=(const KeyFrames& rhs);
 
   /**
    * Create a specialization from the given type, and store it to the mSpec
@@ -86,7 +70,7 @@ public:
    * @param[in] alpha An alpha function to blend between this key frame and the
    * next key frame.
    */
-  void Add(float time, Property::Value value, AlphaFunction alpha);
+  void Add(float time, const Property::Value& value, AlphaFunction alpha);
 
   /**
    * Return the key frames without specialization. The GetSpecialization methods
@@ -100,22 +84,18 @@ public:
   Dali::Property::Value GetLastKeyFrameValue() const;
 
 private:
-  Dali::Property::Type mType; // Type of the specialization
-  IntrusivePtr<KeyFrameSpec> mKeyFrames;   // Pointer to the specialized key frame object
+  Dali::Property::Type          mType{Property::NONE}; // Type of the specialization
+  std::unique_ptr<KeyFrameSpec> mKeyFrames;            // Pointer to the specialized key frame object
 };
 
-
 /**
  * This is the base class for the individual template specializations, allowing a ptr to be
- * stored in the handle object above. It inherits from RefObject to allow smart pointers
- * to be used for the specializations. Note that the derived template class below
- * allows for a copy constructor so that the specialization object can be cloned before
- * being passed to the scene-graph for animation.
+ * stored in the handle object above.
  */
-class KeyFrameSpec : public RefObject
+class KeyFrameSpec
 {
 public:
-  KeyFrameSpec() = default;
+  virtual ~KeyFrameSpec() = default;
 
   virtual std::size_t GetNumberOfKeyFrames() const = 0;
 
@@ -125,85 +105,19 @@ public:
    * @param[out] value The value of the given key frame
    */
   virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0;
-
-protected:
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  ~KeyFrameSpec() override = default;
 };
 
-
 /**
- * The base template class for each key frame specialization. It stores a vector of
- * ProgressValue pairs in mPVs, and uses the existing interface for KeyFrameChannel
- * to point at this vector.
+ * The base template class for each key frame specialization.
  */
 template<typename V>
 class KeyFrameBaseSpec : public KeyFrameSpec
 {
-private:
-  using PV          = ProgressValue<V>;
-  using PVContainer = std::vector<PV>;
-
-  PVContainer                    mPVs;       // The ProgressValue pairs
-  KeyFrameChannel<V>*            mKeyFrames; // The key frame interpolator
+  KeyFrameChannel<V> mChannel; // The key frame channel
 
 public:
-  static KeyFrameBaseSpec<V>* New()
-  {
-    return new KeyFrameBaseSpec<V>();
-  }
-
-  static KeyFrameBaseSpec<V>* Clone(const KeyFrameBaseSpec<V>& keyFrames)
-  {
-    return new KeyFrameBaseSpec<V>(keyFrames);
-  }
-
   /**
-   * Constructor
-   */
-  KeyFrameBaseSpec<V>()
-  {
-    mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-  }
-
-protected:
-  /**
-   * Copy Constructor
-   * Allow cloning of this object
-   */
-  KeyFrameBaseSpec<V>(const KeyFrameBaseSpec<V>& keyFrames)
-  : mPVs(keyFrames.mPVs)
-  {
-    mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-  }
-
-  KeyFrameBaseSpec<V>& operator=( const KeyFrameBaseSpec<V>& keyFrames )
-  {
-    if( this != &keyFrames )
-    {
-      mPVs.clear();
-      mPVs = keyFrames.mPVs;
-      delete mKeyFrames;
-      mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
-    }
-    return *this;
-  }
-
-  /**
-   * Destructor. Ensure progress value pairs are cleared down
-   */
-  ~KeyFrameBaseSpec<V>() override
-  {
-    delete mKeyFrames;
-    mPVs.clear();
-  }
-
-public:
-  /**
-   * Add a key frame to the progress value vector. Key frames should be added
+   * Add a key frame to the channel. Key frames should be added
    * in time order (this method does not sort the vector by time)
    * @param[in] t - progress
    * @param[in] v - value
@@ -211,16 +125,16 @@ public:
    */
   void AddKeyFrame(float t, V v, AlphaFunction alpha)
   {
-    mPVs.push_back(PV(t, v));
+    mChannel.mValues.push_back({t, v});
   }
 
   /**
    * Get the number of key frames
-   * @return The size of the progress value vector
+   * @return Channel size
    */
   std::size_t GetNumberOfKeyFrames() const override
   {
-    return mPVs.size();
+    return mChannel.mValues.size();
   }
 
   /**
@@ -229,11 +143,12 @@ public:
    * @param[out] time The progress of the given key frame
    * @param[out] value The value of the given key frame
    */
-  virtual void GetKeyFrame(unsigned int index, float& time, V& value) const
+  void GetKeyFrame(unsigned int index, float& time, V& value) const
   {
-    DALI_ASSERT_ALWAYS( index < mPVs.size() && "KeyFrame index is out of bounds" );
-    time  = mPVs[index].mProgress;
-    value = mPVs[index].mValue;
+    DALI_ASSERT_ALWAYS(index < mChannel.mValues.size() && "KeyFrame index is out of bounds");
+    const auto& element = mChannel.mValues[index];
+    time                = element.mProgress;
+    value               = element.mValue;
   }
 
   /**
@@ -241,7 +156,7 @@ public:
    */
   void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override
   {
-    value = mPVs[index].mValue;
+    value = mChannel.mValues[index].mValue;
   }
 
   /**
@@ -252,7 +167,7 @@ public:
    */
   bool IsActive(float progress) const
   {
-    return mKeyFrames->IsActive(progress);
+    return mChannel.IsActive(progress);
   }
 
   /**
@@ -262,7 +177,7 @@ public:
    */
   V GetValue(float progress, Dali::Animation::Interpolation interpolation) const
   {
-    return mKeyFrames->GetValue(progress, interpolation);
+    return mChannel.GetValue(progress, interpolation);
   }
 };
 
@@ -274,82 +189,10 @@ using KeyFrameVector3    = KeyFrameBaseSpec<Vector3>;
 using KeyFrameVector4    = KeyFrameBaseSpec<Vector4>;
 using KeyFrameQuaternion = KeyFrameBaseSpec<Quaternion>;
 
-using KeyFrameBooleanPtr    = IntrusivePtr<KeyFrameBoolean>;
-using KeyFrameNumberPtr     = IntrusivePtr<KeyFrameNumber>;
-using KeyFrameIntegerPtr    = IntrusivePtr<KeyFrameInteger>;
-using KeyFrameVector2Ptr    = IntrusivePtr<KeyFrameVector2>;
-using KeyFrameVector3Ptr    = IntrusivePtr<KeyFrameVector3>;
-using KeyFrameVector4Ptr    = IntrusivePtr<KeyFrameVector4>;
-using KeyFrameQuaternionPtr = IntrusivePtr<KeyFrameQuaternion>;
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameBoolean*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameBoolean*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameBoolean*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameNumber*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameNumber*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameNumber*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameInteger*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameInteger*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector2*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector3*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector3*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector3*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector3*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector4*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameVector4*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameVector4*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<const Internal::KeyFrameVector4*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameQuaternion*& keyFrameSpec)
-{
-  keyFrameSpec = static_cast<Internal::KeyFrameQuaternion*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameQuaternion*& keyFrameSpec)
+template<typename DeriveClass>
+auto GetSpecialization(const Internal::KeyFrames& keyFrames)
 {
-  keyFrameSpec = static_cast<const Internal::KeyFrameQuaternion*>(keyFrames.GetKeyFramesBase());
+  return static_cast<DeriveClass>(keyFrames.GetKeyFramesBase());
 }
 
 } // Internal
index 87c2d37..804008f 100644 (file)
@@ -62,25 +62,25 @@ namespace
 
 // Signals
 
-const char* const SIGNAL_KEY_EVENT =                 "keyEvent";
-const char* const SIGNAL_KEY_EVENT_GENERATED =       "keyEventGenerated";
-const char* const SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished";
-const char* const SIGNAL_TOUCHED =                   "touched";
-const char* const SIGNAL_WHEEL_EVENT =               "wheelEvent";
-const char* const SIGNAL_CONTEXT_LOST =              "contextLost";
-const char* const SIGNAL_CONTEXT_REGAINED =          "contextRegained";
-const char* const SIGNAL_SCENE_CREATED =             "sceneCreated";
+static constexpr std::string_view SIGNAL_KEY_EVENT                 = "keyEvent";
+static constexpr std::string_view SIGNAL_KEY_EVENT_GENERATED       = "keyEventGenerated";
+static constexpr std::string_view SIGNAL_EVENT_PROCESSING_FINISHED = "eventProcessingFinished";
+static constexpr std::string_view SIGNAL_TOUCHED                   = "touched";
+static constexpr std::string_view SIGNAL_WHEEL_EVENT               = "wheelEvent";
+static constexpr std::string_view SIGNAL_CONTEXT_LOST              = "contextLost";
+static constexpr std::string_view SIGNAL_CONTEXT_REGAINED          = "contextRegained";
+static constexpr std::string_view SIGNAL_SCENE_CREATED             = "sceneCreated";
 
 TypeRegistration mType( typeid(Dali::Stage), typeid(Dali::BaseHandle), nullptr );
 
-SignalConnectorType signalConnector1( mType, SIGNAL_KEY_EVENT,                 &Stage::DoConnectSignal );
-SignalConnectorType signalConnector2( mType, SIGNAL_EVENT_PROCESSING_FINISHED, &Stage::DoConnectSignal );
-SignalConnectorType signalConnector4( mType, SIGNAL_WHEEL_EVENT,               &Stage::DoConnectSignal );
-SignalConnectorType signalConnector5( mType, SIGNAL_CONTEXT_LOST,              &Stage::DoConnectSignal );
-SignalConnectorType signalConnector6( mType, SIGNAL_CONTEXT_REGAINED,          &Stage::DoConnectSignal );
-SignalConnectorType signalConnector7( mType, SIGNAL_SCENE_CREATED,             &Stage::DoConnectSignal );
-SignalConnectorType signalConnector8( mType, SIGNAL_KEY_EVENT_GENERATED,       &Stage::DoConnectSignal );
-SignalConnectorType signalConnector9( mType, SIGNAL_TOUCHED,                   &Stage::DoConnectSignal );
+SignalConnectorType signalConnector1(mType, std::string(SIGNAL_KEY_EVENT), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector2(mType, std::string(SIGNAL_EVENT_PROCESSING_FINISHED), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector4(mType, std::string(SIGNAL_WHEEL_EVENT), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector5(mType, std::string(SIGNAL_CONTEXT_LOST), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector6(mType, std::string(SIGNAL_CONTEXT_REGAINED), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector7(mType, std::string(SIGNAL_SCENE_CREATED), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector8(mType, std::string(SIGNAL_KEY_EVENT_GENERATED), &Stage::DoConnectSignal);
+SignalConnectorType signalConnector9(mType, std::string(SIGNAL_TOUCHED), &Stage::DoConnectSignal);
 
 } // unnamed namespace
 
@@ -218,36 +218,37 @@ bool Stage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tra
 {
   bool connected( true );
   Stage* stage = static_cast< Stage* >(object); // TypeRegistry guarantees that this is the correct type.
+  std::string_view name(signalName);
 
-  if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT ) )
+  if(name == SIGNAL_KEY_EVENT)
   {
     stage->KeyEventSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_KEY_EVENT_GENERATED ) )
+  else if(name == SIGNAL_KEY_EVENT_GENERATED)
   {
     stage->KeyEventGeneratedSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_EVENT_PROCESSING_FINISHED ) )
+  else if(name == SIGNAL_EVENT_PROCESSING_FINISHED)
   {
     stage->EventProcessingFinishedSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_TOUCHED ) )
+  else if(name == SIGNAL_TOUCHED)
   {
     stage->TouchedSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_WHEEL_EVENT ) )
+  else if(name == SIGNAL_WHEEL_EVENT)
   {
     stage->WheelEventSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_LOST ) )
+  else if(name == SIGNAL_CONTEXT_LOST)
   {
     stage->ContextLostSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_CONTEXT_REGAINED ) )
+  else if(name == SIGNAL_CONTEXT_REGAINED)
   {
     stage->ContextRegainedSignal().Connect( tracker, functor );
   }
-  else if( 0 == strcmp( signalName.c_str(), SIGNAL_SCENE_CREATED ) )
+  else if(name == SIGNAL_SCENE_CREATED)
   {
     stage->SceneCreatedSignal().Connect( tracker, functor );
   }
index aa01b10..10a735f 100644 (file)
@@ -430,60 +430,53 @@ void Animation::UpdateAnimators( BufferIndex bufferIndex, bool bake, bool animat
   const Vector2 playRange( mPlayRange * mDurationSeconds );
   float elapsedSecondsClamped = Clamp( mElapsedSeconds, playRange.x, playRange.y );
 
+  //Remove animators whose PropertyOwner has been destroyed
+  mAnimators.Erase(std::remove_if(mAnimators.begin(),
+                                  mAnimators.end(),
+                                  [](auto animator) { return animator->Orphan(); }),
+                   mAnimators.end());
+
   //Loop through all animators
-  bool applied(true);
-  for ( auto&& iter = mAnimators.Begin(); iter != mAnimators.End(); )
+  for(auto& animator : mAnimators)
   {
-    AnimatorBase *animator = *iter;
-
-    if( animator->Orphan() )
-    {
-      //Remove animators whose PropertyOwner has been destroyed
-      iter = mAnimators.Erase(iter);
-    }
-    else
+    bool applied(true);
+    if(animator->IsEnabled())
     {
-      if( animator->IsEnabled() )
-      {
-        const float intervalDelay( animator->GetIntervalDelay() );
+      const float intervalDelay(animator->GetIntervalDelay());
 
-        if( elapsedSecondsClamped >= intervalDelay )
+      if(elapsedSecondsClamped >= intervalDelay)
+      {
+        // Calculate a progress specific to each individual animator
+        float       progress(1.0f);
+        const float animatorDuration = animator->GetDuration();
+        if(animatorDuration > 0.0f) // animators can be "immediate"
         {
-          // Calculate a progress specific to each individual animator
-          float progress(1.0f);
-          const float animatorDuration = animator->GetDuration();
-          if (animatorDuration > 0.0f) // animators can be "immediate"
-          {
-            progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f , 1.0f );
-          }
-          animator->Update(bufferIndex, progress, bake);
-
-          if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
-          {
-            mIsActive[bufferIndex] = true;
-          }
+          progress = Clamp((elapsedSecondsClamped - intervalDelay) / animatorDuration, 0.0f, 1.0f);
         }
-        applied = true;
-      }
-      else
-      {
-        applied = false;
-      }
+        animator->Update(bufferIndex, progress, bake);
 
-      if ( animationFinished )
-      {
-        animator->SetActive( false );
+        if (animatorDuration > 0.0f && (elapsedSecondsClamped - intervalDelay) <= animatorDuration)
+        {
+          mIsActive[bufferIndex] = true;
+        }
       }
+      applied = true;
+    }
+    else
+    {
+      applied = false;
+    }
 
-      if (applied)
-      {
-        INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
-      }
+    if(animationFinished)
+    {
+      animator->SetActive(false);
+    }
 
-      ++iter;
+    if(applied)
+    {
+      INCREASE_COUNTER(PerformanceMonitor::ANIMATORS_APPLIED);
     }
   }
-
 }
 
 } // namespace SceneGraph
index 56ed6c4..3ff3144 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <cmath>
+#include <functional>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/animation/alpha-function.h>
@@ -45,59 +46,6 @@ namespace Internal
 
 using Interpolation = Dali::Animation::Interpolation;
 
-/**
- * AnimatorFunction base class.
- * Needs to be declared first so AnimatorBase knows about it's destructor
- * All update functions must inherit from AnimatorFunctionBase and overload the appropiate "()" operator
- */
-struct AnimatorFunctionBase
-{
-  /**
-   * Constructor
-   */
-  AnimatorFunctionBase() = default;
-
-  /*
-   * Virtual destructor (Intended as base class)
-   */
-  virtual ~AnimatorFunctionBase() = default;
-
-  ///Stub "()" operators.
-  virtual bool operator()(float progress, const bool& property)
-  {
-    return property;
-  }
-
-  virtual float operator()(float progress, const int32_t& property)
-  {
-    return static_cast<float>( property );
-  }
-
-  virtual float operator()(float progress, const float& property)
-  {
-    return property;
-  }
-
-  virtual Vector2 operator()(float progress, const Vector2& property)
-  {
-    return property;
-  }
-
-  virtual Vector3 operator()(float progress, const Vector3& property)
-  {
-    return property;
-  }
-
-  virtual Vector4 operator()(float progress, const Vector4& property)
-  {
-    return property;
-  }
-
-  virtual Quaternion operator()(float progress, const Quaternion& property)
-  {
-    return property;
-  }
-};
 
 namespace SceneGraph
 {
@@ -135,17 +83,14 @@ public:
    * Constructor.
    */
   AnimatorBase( PropertyOwner* propertyOwner,
-                AnimatorFunctionBase* animatorFunction,
                 AlphaFunction alphaFunction,
                 const TimePeriod& timePeriod )
   : mLifecycleObserver( nullptr ),
     mPropertyOwner( propertyOwner ),
-    mAnimatorFunction( animatorFunction ),
     mDurationSeconds( timePeriod.durationSeconds ),
     mIntervalDelaySeconds( timePeriod.delaySeconds ),
     mSpeedFactor( 1.0f ),
     mCurrentProgress( 0.f ),
-    mLoopCount( 1 ),
     mAlphaFunction( alphaFunction ),
     mDisconnectAction( Dali::Animation::BAKE_FINAL ),
     mAnimationPlaying( false ),
@@ -160,7 +105,6 @@ public:
    */
   ~AnimatorBase() override
   {
-    delete mAnimatorFunction;
     if (mPropertyOwner && mConnectedToSceneGraph)
     {
       mPropertyOwner->RemoveObserver(*this);
@@ -560,16 +504,15 @@ protected:
 
   LifecycleObserver* mLifecycleObserver;
   PropertyOwner* mPropertyOwner;
-  AnimatorFunctionBase* mAnimatorFunction;
+
   float mDurationSeconds;
   float mIntervalDelaySeconds;
   float mSpeedFactor;
   float mCurrentProgress;
 
-  int32_t mLoopCount;
-
   AlphaFunction mAlphaFunction;
 
+  int32_t                    mLoopCount{1};
   Dali::Animation::EndAction mDisconnectAction;     ///< EndAction to apply when target object gets disconnected from the stage.
   bool mAnimationPlaying:1;                         ///< whether disconnect has been applied while it's running.
   bool mEnabled:1;                                  ///< Animator is "enabled" while its target object is valid and on the stage.
@@ -580,9 +523,13 @@ protected:
 /**
  * An animator for a specific property type PropertyType.
  */
-template < typename PropertyType, typename PropertyAccessorType >
-class Animator : public AnimatorBase
+template<typename PropertyType, typename PropertyAccessorType>
+class Animator final : public AnimatorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   /**
@@ -593,26 +540,21 @@ public:
    * @param[in] timePeriod The time period of this animation.
    * @return A newly allocated animator.
    */
-  static AnimatorBase* New( const PropertyOwner& propertyOwner,
-                            const PropertyBase& property,
-                            AnimatorFunctionBase* animatorFunction,
-                            AlphaFunction alphaFunction,
-                            const TimePeriod& timePeriod )
+  static AnimatorBase* New(const PropertyOwner& propertyOwner,
+                           const PropertyBase&  property,
+                           AnimatorFunction     animatorFunction,
+                           AlphaFunction        alphaFunction,
+                           const TimePeriod&    timePeriod)
   {
     // The property was const in the actor-thread, but animators are used in the scene-graph thread.
-    return new Animator( const_cast<PropertyOwner*>( &propertyOwner ),
-                                  const_cast<PropertyBase*>( &property ),
-                                  animatorFunction,
-                                  alphaFunction,
-                                  timePeriod );
+    return new Animator(const_cast<PropertyOwner*>(&propertyOwner),
+                        const_cast<PropertyBase*>(&property),
+                        std::move(animatorFunction),
+                        alphaFunction,
+                        timePeriod);
   }
 
   /**
-   * Virtual destructor.
-   */
-  ~Animator() override = default;
-
-  /**
    * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
    */
   void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
@@ -620,7 +562,7 @@ public:
     const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
 
     // need to cast the return value in case property is integer
-    const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
+    const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
 
     if ( bake )
     {
@@ -637,13 +579,14 @@ private:
   /**
    * Private constructor; see also Animator::New().
    */
-  Animator( PropertyOwner* propertyOwner,
-            PropertyBase* property,
-            AnimatorFunctionBase* animatorFunction,
-            AlphaFunction alphaFunction,
-            const TimePeriod& timePeriod )
-  : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
-    mPropertyAccessor( property )
+  Animator(PropertyOwner*    propertyOwner,
+           PropertyBase*     property,
+           AnimatorFunction  animatorFunction,
+           AlphaFunction     alphaFunction,
+           const TimePeriod& timePeriod)
+  : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
+    mAnimatorFunction(std::move(animatorFunction)),
+    mPropertyAccessor(property)
   {
     // WARNING - this object is created in the event-thread
     // The scene-graph mPropertyOwner object cannot be observed here
@@ -666,9 +609,13 @@ protected:
 /**
  * An animator for a specific property type PropertyType.
  */
-template <typename PropertyType, typename PropertyAccessorType>
-class AnimatorTransformProperty : public AnimatorBase
+template<typename PropertyType, typename PropertyAccessorType>
+class AnimatorTransformProperty final : public AnimatorBase
 {
+  using AnimatorFunction = std::function<PropertyType(float, const PropertyType&)>;
+
+  AnimatorFunction mAnimatorFunction;
+
 public:
 
   /**
@@ -679,27 +626,22 @@ public:
    * @param[in] timePeriod The time period of this animation.
    * @return A newly allocated animator.
    */
-  static AnimatorBase* New( const PropertyOwner& propertyOwner,
-                            const PropertyBase& property,
-                            AnimatorFunctionBase* animatorFunction,
-                            AlphaFunction alphaFunction,
-                            const TimePeriod& timePeriod )
+  static AnimatorBase* New(const PropertyOwner& propertyOwner,
+                           const PropertyBase&  property,
+                           AnimatorFunction     animatorFunction,
+                           AlphaFunction        alphaFunction,
+                           const TimePeriod&    timePeriod)
   {
 
     // The property was const in the actor-thread, but animators are used in the scene-graph thread.
-    return new AnimatorTransformProperty( const_cast<PropertyOwner*>( &propertyOwner ),
-                                                                         const_cast<PropertyBase*>( &property ),
-                                                                         animatorFunction,
-                                                                         alphaFunction,
-                                                                         timePeriod );
+    return new AnimatorTransformProperty(const_cast<PropertyOwner*>(&propertyOwner),
+                                         const_cast<PropertyBase*>(&property),
+                                         std::move(animatorFunction),
+                                         alphaFunction,
+                                         timePeriod);
   }
 
   /**
-   * Virtual destructor.
-   */
-  ~AnimatorTransformProperty() override = default;
-
-  /**
    * @copydoc AnimatorBase::DoUpdate( BufferIndex bufferIndex, bool bake, float alpha )
    */
   void DoUpdate( BufferIndex bufferIndex, bool bake, float alpha ) final
@@ -707,7 +649,7 @@ public:
     const PropertyType& current = mPropertyAccessor.Get( bufferIndex );
 
     // need to cast the return value in case property is integer
-    const PropertyType result = static_cast<PropertyType>( (*mAnimatorFunction)( alpha, current ) );
+    const PropertyType result = static_cast<PropertyType>(mAnimatorFunction(alpha, current));
 
     if ( bake )
     {
@@ -724,13 +666,14 @@ private:
   /**
    * Private constructor; see also Animator::New().
    */
-  AnimatorTransformProperty( PropertyOwner* propertyOwner,
-            PropertyBase* property,
-            AnimatorFunctionBase* animatorFunction,
-            AlphaFunction alphaFunction,
-            const TimePeriod& timePeriod )
-  : AnimatorBase( propertyOwner, animatorFunction, alphaFunction, timePeriod ),
-    mPropertyAccessor( property )
+  AnimatorTransformProperty(PropertyOwner*    propertyOwner,
+                            PropertyBase*     property,
+                            AnimatorFunction  animatorFunction,
+                            AlphaFunction     alphaFunction,
+                            const TimePeriod& timePeriod)
+  : AnimatorBase(propertyOwner, alphaFunction, timePeriod),
+    mAnimatorFunction(std::move(animatorFunction)),
+    mPropertyAccessor(property)
   {
     // WARNING - this object is created in the event-thread
     // The scene-graph mPropertyOwner object cannot be observed here
@@ -751,15 +694,14 @@ protected:
 
 // Update functions
 
-struct AnimateByInteger : public AnimatorFunctionBase
+struct AnimateByInteger
 {
   AnimateByInteger(const int& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const int32_t& property) override
+  float operator()(float alpha, const int32_t& property)
   {
     // integers need to be correctly rounded
     return roundf(static_cast<float>( property ) + static_cast<float>( mRelative ) * alpha );
@@ -768,15 +710,14 @@ struct AnimateByInteger : public AnimatorFunctionBase
   int32_t mRelative;
 };
 
-struct AnimateToInteger : public AnimatorFunctionBase
+struct AnimateToInteger
 {
   AnimateToInteger(const int& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const int32_t& property) override
+  float operator()(float alpha, const int32_t& property)
   {
     // integers need to be correctly rounded
     return roundf(static_cast<float>( property ) + (static_cast<float>(mTarget - property) * alpha) );
@@ -785,15 +726,14 @@ struct AnimateToInteger : public AnimatorFunctionBase
   int32_t mTarget;
 };
 
-struct AnimateByFloat : public AnimatorFunctionBase
+struct AnimateByFloat
 {
   AnimateByFloat(const float& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const float& property) override
+  float operator()(float alpha, const float& property)
   {
     return float(property + mRelative * alpha);
   }
@@ -801,15 +741,14 @@ struct AnimateByFloat : public AnimatorFunctionBase
   float mRelative;
 };
 
-struct AnimateToFloat : public AnimatorFunctionBase
+struct AnimateToFloat
 {
   AnimateToFloat(const float& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float alpha, const float& property) override
+  float operator()(float alpha, const float& property)
   {
     return float(property + ((mTarget - property) * alpha));
   }
@@ -817,15 +756,14 @@ struct AnimateToFloat : public AnimatorFunctionBase
   float mTarget;
 };
 
-struct AnimateByVector2 : public AnimatorFunctionBase
+struct AnimateByVector2
 {
   AnimateByVector2(const Vector2& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float alpha, const Vector2& property) override
+  Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + mRelative * alpha);
   }
@@ -833,15 +771,14 @@ struct AnimateByVector2 : public AnimatorFunctionBase
   Vector2 mRelative;
 };
 
-struct AnimateToVector2 : public AnimatorFunctionBase
+struct AnimateToVector2
 {
   AnimateToVector2(const Vector2& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float alpha, const Vector2& property) override
+  Vector2 operator()(float alpha, const Vector2& property)
   {
     return Vector2(property + ((mTarget - property) * alpha));
   }
@@ -849,15 +786,14 @@ struct AnimateToVector2 : public AnimatorFunctionBase
   Vector2 mTarget;
 };
 
-struct AnimateByVector3 : public AnimatorFunctionBase
+struct AnimateByVector3
 {
   AnimateByVector3(const Vector3& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float alpha, const Vector3& property) override
+  Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + mRelative * alpha);
   }
@@ -865,15 +801,14 @@ struct AnimateByVector3 : public AnimatorFunctionBase
   Vector3 mRelative;
 };
 
-struct AnimateToVector3 : public AnimatorFunctionBase
+struct AnimateToVector3
 {
   AnimateToVector3(const Vector3& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float alpha, const Vector3& property) override
+  Vector3 operator()(float alpha, const Vector3& property)
   {
     return Vector3(property + ((mTarget - property) * alpha));
   }
@@ -881,15 +816,14 @@ struct AnimateToVector3 : public AnimatorFunctionBase
   Vector3 mTarget;
 };
 
-struct AnimateByVector4 : public AnimatorFunctionBase
+struct AnimateByVector4
 {
   AnimateByVector4(const Vector4& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + mRelative * alpha);
   }
@@ -897,15 +831,14 @@ struct AnimateByVector4 : public AnimatorFunctionBase
   Vector4 mRelative;
 };
 
-struct AnimateToVector4 : public AnimatorFunctionBase
+struct AnimateToVector4
 {
   AnimateToVector4(const Vector4& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     return Vector4(property + ((mTarget - property) * alpha));
   }
@@ -913,15 +846,14 @@ struct AnimateToVector4 : public AnimatorFunctionBase
   Vector4 mTarget;
 };
 
-struct AnimateByOpacity : public AnimatorFunctionBase
+struct AnimateByOpacity
 {
   AnimateByOpacity(const float& relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
     result.a += mRelative * alpha;
@@ -932,15 +864,14 @@ struct AnimateByOpacity : public AnimatorFunctionBase
   float mRelative;
 };
 
-struct AnimateToOpacity : public AnimatorFunctionBase
+struct AnimateToOpacity
 {
   AnimateToOpacity(const float& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float alpha, const Vector4& property) override
+  Vector4 operator()(float alpha, const Vector4& property)
   {
     Vector4 result(property);
     result.a = property.a + ((mTarget - property.a) * alpha);
@@ -951,15 +882,14 @@ struct AnimateToOpacity : public AnimatorFunctionBase
   float mTarget;
 };
 
-struct AnimateByBoolean : public AnimatorFunctionBase
+struct AnimateByBoolean
 {
   AnimateByBoolean(bool relativeValue)
   : mRelative(relativeValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float alpha, const bool& property) override
+  bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
     return bool(alpha >= 1.0f ? (property || mRelative) : property);
@@ -968,15 +898,14 @@ struct AnimateByBoolean : public AnimatorFunctionBase
   bool mRelative;
 };
 
-struct AnimateToBoolean : public AnimatorFunctionBase
+struct AnimateToBoolean
 {
   AnimateToBoolean(bool targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float alpha, const bool& property) override
+  bool operator()(float alpha, const bool& property)
   {
     // Alpha is not useful here, just keeping to the same template as other update functors
     return bool(alpha >= 1.0f ? mTarget : property);
@@ -985,7 +914,7 @@ struct AnimateToBoolean : public AnimatorFunctionBase
   bool mTarget;
 };
 
-struct RotateByAngleAxis : public AnimatorFunctionBase
+struct RotateByAngleAxis
 {
   RotateByAngleAxis(const Radian& angleRadians, const Vector3& axis)
   : mAngleRadians( angleRadians ),
@@ -993,8 +922,7 @@ struct RotateByAngleAxis : public AnimatorFunctionBase
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float alpha, const Quaternion& rotation) override
+  Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     if (alpha > 0.0f)
     {
@@ -1008,15 +936,14 @@ struct RotateByAngleAxis : public AnimatorFunctionBase
   Vector3 mAxis;
 };
 
-struct RotateToQuaternion : public AnimatorFunctionBase
+struct RotateToQuaternion
 {
   RotateToQuaternion(const Quaternion& targetValue)
   : mTarget(targetValue)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float alpha, const Quaternion& rotation) override
+  Quaternion operator()(float alpha, const Quaternion& rotation)
   {
     return Quaternion::Slerp(rotation, mTarget, alpha);
   }
@@ -1024,162 +951,157 @@ struct RotateToQuaternion : public AnimatorFunctionBase
   Quaternion mTarget;
 };
 
-
-struct KeyFrameBooleanFunctor : public AnimatorFunctionBase
+struct KeyFrameBooleanFunctor
 {
-  KeyFrameBooleanFunctor(KeyFrameBooleanPtr keyFrames)
-  : mKeyFrames(keyFrames)
+  KeyFrameBooleanFunctor(KeyFrameBoolean keyFrames)
+  : mKeyFrames(std::move(keyFrames))
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  bool operator()(float progress, const bool& property) override
+  bool operator()(float progress, const bool& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR);
+      return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
     }
     return property;
   }
 
-  KeyFrameBooleanPtr mKeyFrames;
+  KeyFrameBoolean mKeyFrames;
 };
 
-struct KeyFrameIntegerFunctor : public AnimatorFunctionBase
+struct KeyFrameIntegerFunctor
 {
-  KeyFrameIntegerFunctor(KeyFrameIntegerPtr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameIntegerFunctor(KeyFrameInteger keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float progress, const int32_t& property) override
+  float operator()(float progress, const int32_t& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return static_cast<float>( mKeyFrames->GetValue(progress, mInterpolation) );
+      return static_cast<float>(mKeyFrames.GetValue(progress, mInterpolation));
     }
     return static_cast<float>( property );
   }
 
-  KeyFrameIntegerPtr mKeyFrames;
+  KeyFrameInteger mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameNumberFunctor : public AnimatorFunctionBase
+struct KeyFrameNumberFunctor
 {
-  KeyFrameNumberFunctor(KeyFrameNumberPtr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameNumberFunctor(KeyFrameNumber keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  float operator()(float progress, const float& property) override
+  float operator()(float progress, const float& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameNumberPtr mKeyFrames;
+  KeyFrameNumber mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameVector2Functor : public AnimatorFunctionBase
+struct KeyFrameVector2Functor
 {
-  KeyFrameVector2Functor(KeyFrameVector2Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector2Functor(KeyFrameVector2 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector2 operator()(float progress, const Vector2& property) override
+  Vector2 operator()(float progress, const Vector2& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector2Ptr mKeyFrames;
+  KeyFrameVector2 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-
-struct KeyFrameVector3Functor : public AnimatorFunctionBase
+struct KeyFrameVector3Functor
 {
-  KeyFrameVector3Functor(KeyFrameVector3Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector3Functor(KeyFrameVector3 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float progress, const Vector3& property) override
+  Vector3 operator()(float progress, const Vector3& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector3Ptr mKeyFrames;
+  KeyFrameVector3 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameVector4Functor : public AnimatorFunctionBase
+struct KeyFrameVector4Functor
 {
-  KeyFrameVector4Functor(KeyFrameVector4Ptr keyFrames, Interpolation interpolation)
-  : mKeyFrames(keyFrames),mInterpolation(interpolation)
+  KeyFrameVector4Functor(KeyFrameVector4 keyFrames, Interpolation interpolation)
+  : mKeyFrames(std::move(keyFrames)),
+    mInterpolation(interpolation)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector4 operator()(float progress, const Vector4& property) override
+  Vector4 operator()(float progress, const Vector4& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, mInterpolation);
+      return mKeyFrames.GetValue(progress, mInterpolation);
     }
     return property;
   }
 
-  KeyFrameVector4Ptr mKeyFrames;
+  KeyFrameVector4 mKeyFrames;
   Interpolation mInterpolation;
 };
 
-struct KeyFrameQuaternionFunctor : public AnimatorFunctionBase
+struct KeyFrameQuaternionFunctor
 {
-  KeyFrameQuaternionFunctor(KeyFrameQuaternionPtr keyFrames)
-  : mKeyFrames(keyFrames)
+  KeyFrameQuaternionFunctor(KeyFrameQuaternion keyFrames)
+  : mKeyFrames(std::move(keyFrames))
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float progress, const Quaternion& property) override
+  Quaternion operator()(float progress, const Quaternion& property)
   {
-    if(mKeyFrames->IsActive(progress))
+    if(mKeyFrames.IsActive(progress))
     {
-      return mKeyFrames->GetValue(progress, Dali::Animation::LINEAR);
+      return mKeyFrames.GetValue(progress, Dali::Animation::LINEAR);
     }
     return property;
   }
 
-  KeyFrameQuaternionPtr mKeyFrames;
+  KeyFrameQuaternion mKeyFrames;
 };
 
-struct PathPositionFunctor : public AnimatorFunctionBase
+struct PathPositionFunctor
 {
   PathPositionFunctor( PathPtr path )
   : mPath(path)
   {
   }
 
-  using AnimatorFunctionBase::operator();
-  Vector3 operator()(float progress, const Vector3& property) override
+  Vector3 operator()(float progress, const Vector3& property)
   {
     Vector3 position(property);
     static_cast<void>( mPath->SamplePosition(progress, position) );
@@ -1189,7 +1111,7 @@ struct PathPositionFunctor : public AnimatorFunctionBase
   PathPtr mPath;
 };
 
-struct PathRotationFunctor : public AnimatorFunctionBase
+struct PathRotationFunctor
 {
   PathRotationFunctor( PathPtr path, const Vector3& forward )
   : mPath(path),
@@ -1198,8 +1120,7 @@ struct PathRotationFunctor : public AnimatorFunctionBase
     mForward.Normalize();
   }
 
-  using AnimatorFunctionBase::operator();
-  Quaternion operator()(float progress, const Quaternion& property) override
+  Quaternion operator()(float progress, const Quaternion& property)
   {
     Vector3 tangent;
     if( mPath->SampleTangent(progress, tangent) )
index 0079c2c..f74337b 100644 (file)
@@ -167,24 +167,14 @@ bool AddRenderablesForTask( BufferIndex updateBufferIndex,
   // Set the information in the node.
   node.SetClippingInformation( currentClippingId, clippingDepth, scissorDepth );
 
+  RenderableContainer& target = DALI_LIKELY( inheritedDrawMode == DrawMode::NORMAL ) ?
+    layer->colorRenderables : layer->overlayRenderables;
   for( uint32_t i = 0; i < count; ++i )
   {
     SceneGraph::Renderer* renderer = node.GetRendererAt( i );
+    target.PushBack( Renderable( &node, renderer ) );
 
-    // Normal is the more-likely draw mode to occur.
-    if( DALI_LIKELY( inheritedDrawMode == DrawMode::NORMAL ) )
-    {
-      layer->colorRenderables.PushBack( Renderable( &node, renderer ) );
-    }
-    else
-    {
-      layer->overlayRenderables.PushBack( Renderable( &node, renderer ) );
-    }
-
-    if( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY )
-    {
-      keepRendering = true;
-    }
+    keepRendering = keepRendering || ( renderer->GetRenderingBehavior() == DevelRenderer::Rendering::CONTINUOUSLY );
   }
 
   // Recurse children.
index dbf21e1..bff6040 100644 (file)
@@ -56,7 +56,7 @@ Property::Type KeyFrames::GetType() const
 
 void KeyFrames::Add(float time, Property::Value value)
 {
-  Add(time, value, AlphaFunction::DEFAULT);
+  Add(time, std::move(value), AlphaFunction::DEFAULT);
 }
 
 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
index 31df5f5..ed5005d 100644 (file)
@@ -25,9 +25,9 @@
 
 namespace Dali
 {
-const uint32_t    CORE_MAJOR_VERSION = 1;
-const uint32_t    CORE_MINOR_VERSION = 9;
-const uint32_t    CORE_MICRO_VERSION = 35;
+const uint32_t    CORE_MAJOR_VERSION = 2;
+const uint32_t    CORE_MINOR_VERSION = 0;
+const uint32_t    CORE_MICRO_VERSION = 0;
 const char* const CORE_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 739acb3..236122e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2
 Summary:    DALi 3D Engine
-Version:    1.9.35
+Version:    2.0.0
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT