X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fcommon%2Fanimatable-property.h;h=612af3f2e7f115914ff142da852cfb2c75a40225;hb=e3db7130bf8c89d8ca671bc3a42efcc7c5da2641;hp=a586a0d9f917646e5c1c8440771a759af66dfe42;hpb=80a17733af457e9c4609b2b86f6fa0ec90d53151;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index a586a0d..612af3f 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_ANIMATABLE_PROPERTY_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,26 +22,21 @@ #include // INTERNAL INCLUDES +#include + +#include +#include #include -#include #include #include -#include -#include -#include -#include -#include -#include +#include namespace Dali { - namespace Internal { - namespace SceneGraph { - /** * Dirty flags record whether an animatable property has changed. * In the frame following a change, the property is reset to a base value. @@ -55,8 +50,9 @@ namespace SceneGraph static const uint32_t CLEAN_FLAG = 0x00; ///< Indicates that the value did not change in this, or the previous frame static const uint32_t BAKED_FLAG = 0x01; ///< Indicates that the value was Baked during the previous frame static const uint32_t SET_FLAG = 0x02; ///< Indicates that the value was Set during the previous frame +static const uint32_t RESET_FLAG = 0x02; ///< Indicates that the value should be reset to the base value in the next two frames -template +template class AnimatableProperty; /** @@ -65,27 +61,25 @@ class AnimatableProperty; class AnimatablePropertyBase : public PropertyBase { public: - /** * Constructor, initialize the dirty flag */ AnimatablePropertyBase() : PropertyBase(), - mDirtyFlags( BAKED_FLAG ) - {} + mDirtyFlags(BAKED_FLAG) + { + } /** * Virtual destructor. */ - ~AnimatablePropertyBase() override - {} + ~AnimatablePropertyBase() override = default; protected: // for derived classes - /** * Flag that the property has been Set during the current frame. */ - void OnSet() + virtual void OnSet() { mDirtyFlags = SET_FLAG; } @@ -93,19 +87,27 @@ protected: // for derived classes /** * Flag that the property has been Baked during the current frame. */ - void OnBake() + virtual void OnBake() { mDirtyFlags = BAKED_FLAG; } -public: // From PropertyBase +public: + /** + * Mark the property as dirty so that it will be reset to the base value in the next two frames. + */ + void MarkAsDirty() + { + mDirtyFlags = RESET_FLAG; + } +public: // From PropertyBase /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean() */ bool IsClean() const override { - return ( CLEAN_FLAG == mDirtyFlags ); + return (CLEAN_FLAG == mDirtyFlags); } /** @@ -116,37 +118,31 @@ public: // From PropertyBase return true; // Animatable properties are always valid } -protected: // so that ResetToBaseValue can set it directly - +protected: // so that ResetToBaseValue can set it directly uint32_t mDirtyFlags; ///< Flag whether value changed during previous 2 frames - }; - /** * An boolean animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( bool initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(bool initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -161,20 +157,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::Internal::PropertyInputImpl::GetBoolean() */ - const bool& GetBoolean( BufferIndex bufferIndex ) const override + const bool& GetBoolean(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -186,7 +182,7 @@ public: void Set(BufferIndex bufferIndex, bool value) { // check if the value actually changed to avoid dirtying nodes unnecessarily - if( mValue[bufferIndex] != value ) + if(mValue[bufferIndex] != value) { mValue[bufferIndex] = value; @@ -203,7 +199,7 @@ public: { // check if the value actually changed to avoid dirtying nodes unnecessarily // false + false does not change value, true + false does not either - if( delta && !mValue[bufferIndex] ) + if(delta && !mValue[bufferIndex]) { mValue[bufferIndex] = delta; @@ -214,7 +210,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - bool& Get( BufferIndex bufferIndex ) + bool& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -222,7 +218,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const bool& Get( BufferIndex bufferIndex ) const + const bool& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -232,7 +228,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - bool& operator[]( BufferIndex bufferIndex ) + bool& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -242,7 +238,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const bool& operator[]( BufferIndex bufferIndex ) const + const bool& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -255,13 +251,13 @@ public: void Bake(BufferIndex bufferIndex, bool value) { // bake has to check the base value as current buffer value can be correct by constraint or something else - if( mBaseValue != value ) + if(mBaseValue != value) { mBaseValue = value; // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; OnBake(); } @@ -275,13 +271,12 @@ public: void BakeRelative(BufferIndex bufferIndex, bool delta) { mValue[bufferIndex] = mValue[bufferIndex] || delta; - mBaseValue = mValue[bufferIndex]; + mBaseValue = mValue[bufferIndex]; OnBake(); } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -289,37 +284,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - bool mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + bool mBaseValue; ///< Reset to this base value at the beginning of each frame }; - /** * An integer animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( int initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(int initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -334,20 +323,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::Internal::PropertyInputImpl::GetInteger() */ - const int& GetInteger( BufferIndex bufferIndex ) const override + const int& GetInteger(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -378,7 +367,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - int& Get( BufferIndex bufferIndex ) + int& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -386,7 +375,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const int& Get( BufferIndex bufferIndex ) const + const int& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -396,7 +385,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - int& operator[]( BufferIndex bufferIndex ) + int& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -406,7 +395,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const int& operator[]( BufferIndex bufferIndex ) const + const int& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -418,9 +407,9 @@ public: */ void Bake(BufferIndex bufferIndex, int value) { - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -433,7 +422,7 @@ public: void BakeRelative(BufferIndex bufferIndex, int delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; - mBaseValue = mValue[bufferIndex]; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -457,13 +446,12 @@ public: */ void SetInitialRelative(const int& delta) { - mValue[0] = mValue[0] + delta; - mValue[1] = mValue[0]; + mValue[0] = mValue[0] + delta; + mValue[1] = mValue[0]; mBaseValue = mValue[0]; } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -471,36 +459,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - int mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + int mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * An float animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( float initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(float initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -515,20 +498,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::Internal::PropertyInputImpl::GetFloat() */ - const float& GetFloat( BufferIndex bufferIndex ) const override + const float& GetFloat(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -559,7 +542,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - float& Get( BufferIndex bufferIndex ) + float& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -567,7 +550,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const float& Get( BufferIndex bufferIndex ) const + const float& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -577,7 +560,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - float& operator[]( BufferIndex bufferIndex ) + float& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -587,7 +570,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const float& operator[]( BufferIndex bufferIndex ) const + const float& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -601,9 +584,9 @@ public: { // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -616,7 +599,7 @@ public: void BakeRelative(BufferIndex bufferIndex, float delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; - mBaseValue = mValue[bufferIndex]; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -640,13 +623,12 @@ public: */ void SetInitialRelative(const float& delta) { - mValue[0] = mValue[0] + delta; - mValue[1] = mValue[0]; + mValue[0] = mValue[0] + delta; + mValue[1] = mValue[0]; mBaseValue = mValue[0]; } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -654,35 +636,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - float mBaseValue; ///< Reset to this base value at the beginning of each frame + DoubleBuffered mValue; ///< The double-buffered property value + float mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * An Vector2 animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Vector2& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Vector2& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -697,20 +675,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::PropertyInput::GetVector2() */ - const Vector2& GetVector2( BufferIndex bufferIndex ) const override + const Vector2& GetVector2(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -791,7 +769,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Vector2& Get( BufferIndex bufferIndex ) + Vector2& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -799,7 +777,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Vector2& Get( BufferIndex bufferIndex ) const + const Vector2& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -809,7 +787,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Vector2& operator[]( BufferIndex bufferIndex ) + Vector2& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -819,7 +797,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Vector2& operator[]( BufferIndex bufferIndex ) const + const Vector2& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -833,9 +811,9 @@ public: { // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = value; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = value; OnBake(); } @@ -847,9 +825,9 @@ public: */ void BakeX(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].x = value; - mValue[1-bufferIndex].x = value; - mBaseValue.x = value; + mValue[bufferIndex].x = value; + mValue[1 - bufferIndex].x = value; + mBaseValue.x = value; OnBake(); } @@ -861,9 +839,9 @@ public: */ void BakeY(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].y = value; - mValue[1-bufferIndex].y = value; - mBaseValue.y = value; + mValue[bufferIndex].y = value; + mValue[1 - bufferIndex].y = value; + mBaseValue.y = value; OnBake(); } @@ -908,7 +886,6 @@ public: } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -916,20 +893,17 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Vector2 mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * A Vector3 animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. */ @@ -943,18 +917,16 @@ public: * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Vector3& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Vector3& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -969,20 +941,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::PropertyInput::GetVector3() */ - const Vector3& GetVector3( BufferIndex bufferIndex ) const override + const Vector3& GetVector3(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -1088,7 +1060,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Vector3& Get( BufferIndex bufferIndex ) + Vector3& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1096,7 +1068,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Vector3& Get( BufferIndex bufferIndex ) const + const Vector3& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1106,7 +1078,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Vector3& operator[]( BufferIndex bufferIndex ) + Vector3& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1116,7 +1088,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Vector3& operator[]( BufferIndex bufferIndex ) const + const Vector3& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1128,9 +1100,9 @@ public: */ void Bake(BufferIndex bufferIndex, const Vector3& value) { - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = value; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = value; OnBake(); } @@ -1142,9 +1114,9 @@ public: */ void BakeX(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].x = value; - mValue[1-bufferIndex].x = value; - mBaseValue.x = value; + mValue[bufferIndex].x = value; + mValue[1 - bufferIndex].x = value; + mBaseValue.x = value; OnBake(); } @@ -1156,9 +1128,9 @@ public: */ void BakeY(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].y = value; - mValue[1-bufferIndex].y = value; - mBaseValue.y = value; + mValue[bufferIndex].y = value; + mValue[1 - bufferIndex].y = value; + mBaseValue.y = value; OnBake(); } @@ -1170,9 +1142,9 @@ public: */ void BakeZ(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].z = value; - mValue[1-bufferIndex].z = value; - mBaseValue.z = value; + mValue[bufferIndex].z = value; + mValue[1 - bufferIndex].z = value; + mBaseValue.z = value; OnBake(); } @@ -1243,7 +1215,6 @@ public: } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -1251,36 +1222,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Vector3 mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * A Vector4 animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Vector4& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Vector4& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1295,20 +1261,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::PropertyInput::GetVector4() */ - const Vector4& GetVector4( BufferIndex bufferIndex ) const override + const Vector4& GetVector4(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -1439,7 +1405,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Vector4& Get( BufferIndex bufferIndex ) + Vector4& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1447,7 +1413,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Vector4& Get( BufferIndex bufferIndex ) const + const Vector4& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1457,7 +1423,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Vector4& operator[]( BufferIndex bufferIndex ) + Vector4& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1467,7 +1433,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Vector4& operator[]( BufferIndex bufferIndex ) const + const Vector4& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1479,9 +1445,9 @@ public: */ void Bake(BufferIndex bufferIndex, const Vector4& value) { - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -1493,9 +1459,9 @@ public: */ void BakeX(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].x = value; - mValue[1-bufferIndex].x = value; - mBaseValue.x = mValue[bufferIndex].x; + mValue[bufferIndex].x = value; + mValue[1 - bufferIndex].x = value; + mBaseValue.x = mValue[bufferIndex].x; OnBake(); } @@ -1507,9 +1473,9 @@ public: */ void BakeY(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].y = value; - mValue[1-bufferIndex].y = value; - mBaseValue.y = mValue[bufferIndex].y; + mValue[bufferIndex].y = value; + mValue[1 - bufferIndex].y = value; + mBaseValue.y = mValue[bufferIndex].y; OnBake(); } @@ -1521,9 +1487,9 @@ public: */ void BakeZ(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].z = value; - mValue[1-bufferIndex].z = value; - mBaseValue.z = mValue[bufferIndex].z; + mValue[bufferIndex].z = value; + mValue[1 - bufferIndex].z = value; + mBaseValue.z = mValue[bufferIndex].z; OnBake(); } @@ -1535,9 +1501,9 @@ public: */ void BakeW(BufferIndex bufferIndex, float value) { - mValue[bufferIndex].w = value; - mValue[1-bufferIndex].w = value; - mBaseValue.w = mValue[bufferIndex].w; + mValue[bufferIndex].w = value; + mValue[1 - bufferIndex].w = value; + mBaseValue.w = mValue[bufferIndex].w; OnBake(); } @@ -1550,7 +1516,7 @@ public: void BakeRelative(BufferIndex bufferIndex, const Vector4& delta) { mValue[bufferIndex] = mValue[bufferIndex] + delta; - mBaseValue = mValue[bufferIndex]; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -1563,7 +1529,7 @@ public: void BakeXRelative(BufferIndex bufferIndex, float delta) { mValue[bufferIndex].x = mValue[bufferIndex].x + delta; - mBaseValue.x = mValue[bufferIndex].x; + mBaseValue.x = mValue[bufferIndex].x; OnBake(); } @@ -1576,7 +1542,7 @@ public: void BakeYRelative(BufferIndex bufferIndex, float delta) { mValue[bufferIndex].y = mValue[bufferIndex].y + delta; - mBaseValue.y = mValue[bufferIndex].y; + mBaseValue.y = mValue[bufferIndex].y; OnBake(); } @@ -1589,7 +1555,7 @@ public: void BakeZRelative(BufferIndex bufferIndex, float delta) { mValue[bufferIndex].z = mValue[bufferIndex].z + delta; - mBaseValue.z = mValue[bufferIndex].z; + mBaseValue.z = mValue[bufferIndex].z; OnBake(); } @@ -1602,7 +1568,7 @@ public: void BakeWRelative(BufferIndex bufferIndex, float delta) { mValue[bufferIndex].w = mValue[bufferIndex].w + delta; - mBaseValue.w = mValue[bufferIndex].w; + mBaseValue.w = mValue[bufferIndex].w; OnBake(); } @@ -1620,7 +1586,6 @@ public: } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -1628,19 +1593,16 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Vector4 mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * An Quaternion animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. */ @@ -1654,18 +1616,16 @@ public: * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Quaternion& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Quaternion& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1680,20 +1640,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::PropertyInput::GetQuaternion() */ - const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const override + const Quaternion& GetQuaternion(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -1724,7 +1684,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Quaternion& Get( BufferIndex bufferIndex ) + Quaternion& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1732,7 +1692,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Quaternion& Get( BufferIndex bufferIndex ) const + const Quaternion& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1742,7 +1702,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Quaternion& operator[]( BufferIndex bufferIndex ) + Quaternion& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1752,7 +1712,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Quaternion& operator[]( BufferIndex bufferIndex ) const + const Quaternion& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1766,9 +1726,9 @@ public: { // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = value; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = value; OnBake(); } @@ -1787,7 +1747,6 @@ public: } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -1795,36 +1754,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Quaternion mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * A Matrix animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Matrix& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Matrix& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -1839,20 +1793,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix() */ - const Matrix& GetMatrix( BufferIndex bufferIndex ) const override + const Matrix& GetMatrix(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -1867,7 +1821,6 @@ public: OnSet(); } - /** * Change the property value by a relative amount. * @param[in] bufferIndex The buffer to write. @@ -1876,7 +1829,7 @@ public: void SetRelative(BufferIndex bufferIndex, const Matrix& delta) { Matrix temp; - Matrix::Multiply(temp, mValue[bufferIndex], delta); + MatrixUtils::Multiply(temp, mValue[bufferIndex], delta); mValue[bufferIndex] = temp; OnSet(); @@ -1885,7 +1838,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Matrix& Get( BufferIndex bufferIndex ) + Matrix& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1893,7 +1846,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Matrix& Get( BufferIndex bufferIndex ) const + const Matrix& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1903,7 +1856,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Matrix& operator[]( BufferIndex bufferIndex ) + Matrix& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -1913,7 +1866,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Matrix& operator[]( BufferIndex bufferIndex ) const + const Matrix& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -1927,9 +1880,9 @@ public: { // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -1942,15 +1895,14 @@ public: void BakeRelative(BufferIndex bufferIndex, const Matrix& delta) { Matrix temp; - Matrix::Multiply(temp, mValue[bufferIndex], delta); + MatrixUtils::Multiply(temp, mValue[bufferIndex], delta); mValue[bufferIndex] = temp; - mBaseValue = temp; + mBaseValue = temp; OnBake(); } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -1958,36 +1910,31 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Matrix mBaseValue; ///< Reset to this base value at the beginning of each frame }; /** * A Matrix3 animatable property of a scene-graph object. */ -template <> +template<> class AnimatableProperty : public AnimatablePropertyBase { public: - /** * Create an animatable property. * @param [in] initialValue The initial value of the property. */ - AnimatableProperty( const Matrix3& initialValue ) - : mValue( initialValue ), - mBaseValue( initialValue ) + AnimatableProperty(const Matrix3& initialValue) + : mValue(initialValue), + mBaseValue(initialValue) { } /** * Virtual destructor. */ - ~AnimatableProperty() override - { - } + ~AnimatableProperty() override = default; /** * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType() @@ -2002,20 +1949,20 @@ public: */ void ResetToBaseValue(BufferIndex updateBufferIndex) override { - if (CLEAN_FLAG != mDirtyFlags) + if(CLEAN_FLAG != mDirtyFlags) { mValue[updateBufferIndex] = mBaseValue; - mDirtyFlags = ( mDirtyFlags >> 1 ); + mDirtyFlags = (mDirtyFlags >> 1); } } /** * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3() */ - const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const override + const Matrix3& GetMatrix3(BufferIndex bufferIndex) const override { - return mValue[ bufferIndex ]; + return mValue[bufferIndex]; } /** @@ -2038,7 +1985,7 @@ public: void SetRelative(BufferIndex bufferIndex, const Matrix3& delta) { Matrix3 temp; - Matrix3::Multiply(temp, mValue[bufferIndex], delta); + MatrixUtils::Multiply(temp, mValue[bufferIndex], delta); mValue[bufferIndex] = temp; OnSet(); } @@ -2046,7 +1993,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - Matrix3& Get( BufferIndex bufferIndex ) + Matrix3& Get(BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -2054,7 +2001,7 @@ public: /** * @copydoc Dali::SceneGraph::AnimatableProperty::Get() */ - const Matrix3& Get( BufferIndex bufferIndex ) const + const Matrix3& Get(BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -2064,7 +2011,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - Matrix3& operator[]( BufferIndex bufferIndex ) + Matrix3& operator[](BufferIndex bufferIndex) { return mValue[bufferIndex]; } @@ -2074,7 +2021,7 @@ public: * @param[in] bufferIndex The buffer to read. * @return The property value. */ - const Matrix3& operator[]( BufferIndex bufferIndex ) const + const Matrix3& operator[](BufferIndex bufferIndex) const { return mValue[bufferIndex]; } @@ -2088,9 +2035,9 @@ public: { // It's ok to bake both buffers as render is performed in same thread as update. Reading from event side // has never been atomically safe. - mValue[bufferIndex] = value; - mValue[1-bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; OnBake(); } @@ -2103,15 +2050,14 @@ public: void BakeRelative(BufferIndex bufferIndex, const Matrix3& delta) { Matrix3 temp; - Matrix3::Multiply(temp, mValue[bufferIndex], delta); + MatrixUtils::Multiply(temp, mValue[bufferIndex], delta); mValue[bufferIndex] = temp; - mBaseValue = temp; + mBaseValue = temp; OnBake(); } private: - // Undefined AnimatableProperty(const AnimatableProperty& property); @@ -2119,112 +2065,12 @@ private: AnimatableProperty& operator=(const AnimatableProperty& rhs); private: - - DoubleBuffered mValue; ///< The double-buffered property value - Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame - + DoubleBuffered mValue; ///< The double-buffered property value + Matrix3 mBaseValue; ///< Reset to this base value at the beginning of each frame }; } // namespace SceneGraph -// Messages for AnimatableProperty - -template -void BakeMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType< T >::PassingType newValue ) -{ - using LocalType = MessageDoubleBuffered1, T>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::Bake, - newValue ); -} - -template -void BakeRelativeMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - const T& delta ) -{ - using LocalType = MessageDoubleBuffered1, const T&>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::BakeRelative, - delta ); -} - -template -void SetXComponentMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType< float >::PassingType newValue ) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::BakeX, - newValue ); -} - -template -void SetYComponentMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType< float >::PassingType newValue ) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::BakeY, - newValue ); -} - -template -void SetZComponentMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType< float >::PassingType newValue ) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::BakeZ, - newValue ); -} - -template -void SetWComponentMessage( EventThreadServices& eventThreadServices, - const SceneGraph::AnimatableProperty& property, - typename ParameterType< float >::PassingType newValue ) -{ - using LocalType = MessageDoubleBuffered1, float>; - - // Reserve some memory inside the message queue - uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &property, - &SceneGraph::AnimatableProperty::BakeW, - newValue ); -} - } // namespace Internal } // namespace Dali