add base type of enum to reduce class size. 31/245331/2
authorSubhransu Mohanty <sub.mohanty@samsung.com>
Wed, 7 Oct 2020 06:47:29 +0000 (15:47 +0900)
committerSubhransu Mohanty <sub.mohanty@samsung.com>
Thu, 8 Oct 2020 02:03:07 +0000 (11:03 +0900)
with base type and structure packing the Animation class size reduced by 16byte.
Also added class member-initializer rather than updating default value in constructor.

Change-Id: I0153e8aefc6bb0128f185996389ba7d85f689049

dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animation-impl.h
dali/public-api/animation/animation.h

index db41040..0a05d70 100644 (file)
@@ -137,7 +137,6 @@ void ValidateParameters( Property::Type propertyType, Property::Type destination
 
 } // anonymous namespace
 
-
 AnimationPtr Animation::New(float durationSeconds)
 {
   if( durationSeconds < 0.0f )
@@ -155,26 +154,13 @@ AnimationPtr Animation::New(float durationSeconds)
   return animation;
 }
 
-Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
-: mAnimation( nullptr ),
-  mEventThreadServices( eventThreadServices ),
-  mPlaylist( playlist ),
-  mFinishedSignal(),
-  mConnectors(),
-  mConnectorTargetValues(),
-  mPlayRange( Vector2(0.0f,1.0f)),
-  mDurationSeconds( durationSeconds ),
-  mSpeedFactor(1.0f),
-  mNotificationCount( 0 ),
-  mLoopCount(1),
-  mCurrentLoop(0),
-  mEndAction( endAction ),
-  mDisconnectAction( disconnectAction ),
-  mDefaultAlpha( defaultAlpha ),
-  mState(Dali::Animation::STOPPED),
-  mProgressReachedMarker( 0.0f ),
-  mDelaySeconds( 0.0f ),
-  mAutoReverseEnabled( false )
+Animation::Animation(EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha)
+: mEventThreadServices(eventThreadServices),
+  mPlaylist(playlist),
+  mDefaultAlpha(defaultAlpha),
+  mDurationSeconds(durationSeconds),
+  mEndAction(endAction),
+  mDisconnectAction(disconnectAction)
 {
 }
 
index 3820ade..6d715fe 100644 (file)
@@ -61,12 +61,11 @@ using AnimationConstIter = AnimationContainer::const_iterator;
 class Animation : public BaseObject
 {
 public:
-
-  enum Type
+  enum Type : uint8_t
   {
-    TO,      ///< Animating TO the given value
-    BY,      ///< Animating BY the given value
-    BETWEEN  ///< Animating BETWEEN key-frames
+    TO,     ///< Animating TO the given value
+    BY,     ///< Animating BY the given value
+    BETWEEN ///< Animating BETWEEN key-frames
   };
 
   using EndAction     = Dali::Animation::EndAction;
@@ -492,7 +491,7 @@ private:
     Animation::Type animatorType{TO};
   };
 
-  enum class Notify
+  enum class Notify : uint8_t
   {
     USE_CURRENT_VALUE,   ///< Set the current value for the property
     USE_TARGET_VALUE,    ///< Set the animator's target value for the property
@@ -521,36 +520,33 @@ private:
   void SendFinalProgressNotificationMessage();
 
 private:
+  using AnimatorConnectorContainer     = OwnerContainer<AnimatorConnectorBase*>;
+  using ConnectorTargetValuesContainer = std::vector<ConnectorTargetValues>;
 
-  const SceneGraph::Animation* mAnimation;
+  const SceneGraph::Animation* mAnimation{ nullptr };
 
   EventThreadServices& mEventThreadServices;
-  AnimationPlaylist& mPlaylist;
-
-  Dali::Animation::AnimationSignalType mFinishedSignal;
-
-  Dali::Animation::AnimationSignalType mProgressReachedSignal;
-
-  using AnimatorConnectorContainer = OwnerContainer<AnimatorConnectorBase*>;
-  AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
-
-  using ConnectorTargetValuesContainer = std::vector<ConnectorTargetValues>;
-  ConnectorTargetValuesContainer mConnectorTargetValues; //< Used to store animating property target value information
-
-  Vector2 mPlayRange;
-
-  float mDurationSeconds;
-  float mSpeedFactor;
-  int32_t mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
-  int32_t mLoopCount;
-  int32_t mCurrentLoop;
-  EndAction mEndAction;
-  EndAction mDisconnectAction;
-  AlphaFunction mDefaultAlpha;
-  Dali::Animation::State mState;
-  float mProgressReachedMarker;
-  float mDelaySeconds;
-  bool mAutoReverseEnabled;  ///< Flag to identify that the looping mode is auto reverse.
+  AnimationPlaylist&   mPlaylist;
+
+  Dali::Animation::AnimationSignalType mFinishedSignal{};
+  Dali::Animation::AnimationSignalType mProgressReachedSignal{};
+
+  AnimatorConnectorContainer     mConnectors{};            ///< Owned by the Animation
+  ConnectorTargetValuesContainer mConnectorTargetValues{}; //< Used to store animating property target value information
+
+  AlphaFunction          mDefaultAlpha;
+  Vector2                mPlayRange{0.0f, 1.0f};
+  float                  mDurationSeconds;
+  float                  mSpeedFactor{1.0f};
+  int32_t                mNotificationCount{0}; ///< Keep track of how many Finished signals have been emitted.
+  int32_t                mLoopCount{1};
+  int32_t                mCurrentLoop{0};
+  float                  mProgressReachedMarker{0.0f};
+  float                  mDelaySeconds{0.0f};
+  EndAction              mEndAction;
+  EndAction              mDisconnectAction;
+  Dali::Animation::State mState{Dali::Animation::STOPPED};
+  bool                   mAutoReverseEnabled{false}; ///< Flag to identify that the looping mode is auto reverse.
 };
 
 } // namespace Internal
index f7ba6bc..73599f4 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <cstdint> // uint32_t
+#include <cstdint> // uint32_t, uint8_t
 
 // INTERNAL INCLUDES
 #include <dali/public-api/animation/alpha-function.h>
@@ -131,7 +131,7 @@ public:
    * @brief Enumeration for what to do when the animation ends, is stopped, or is destroyed.
    * @SINCE_1_0.0
    */
-  enum EndAction
+  enum EndAction : uint8_t
   {
     BAKE,      ///< When the animation ends, the animated property values are saved. @SINCE_1_0.0
     DISCARD,   ///< When the animation ends, the animated property values are forgotten. @SINCE_1_0.0
@@ -142,7 +142,7 @@ public:
    * @brief Enumeration for what interpolation method to use on key-frame animations.
    * @SINCE_1_0.0
    */
-  enum Interpolation
+  enum Interpolation : uint8_t
   {
     LINEAR, ///< Values in between key frames are interpolated using a linear polynomial. (Default) @SINCE_1_0.0
     CUBIC   ///< Values in between key frames are interpolated using a cubic polynomial. @SINCE_1_0.0
@@ -155,7 +155,7 @@ public:
    *
    * @SINCE_1_1.21
    */
-  enum State
+  enum State : uint8_t
   {
     STOPPED, ///< Animation has stopped @SINCE_1_1.21
     PLAYING, ///< The animation is playing @SINCE_1_1.21
@@ -167,7 +167,7 @@ public:
    *
    * @SINCE_1_2.60
    */
-  enum LoopingMode
+  enum LoopingMode : uint8_t
   {
     RESTART,     ///< When the animation arrives at the end in looping mode, the animation restarts from the beginning. @SINCE_1_2.60
     AUTO_REVERSE ///< When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again. @SINCE_1_2.60