X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fcommon%2Fproperty-condition-variable-step-functions.cpp;h=e1943294af976a3b9925fc7a3eaeca436b3b260a;hb=e3db7130bf8c89d8ca671bc3a42efcc7c5da2641;hp=60fca7bc4dabec2fb980ec8c12757c6c4dae375a;hpb=6e611d3be935ab4de2f4cfecc5082295260b6a30;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/common/property-condition-variable-step-functions.cpp b/dali/internal/update/common/property-condition-variable-step-functions.cpp index 60fca7b..e194329 100644 --- a/dali/internal/update/common/property-condition-variable-step-functions.cpp +++ b/dali/internal/update/common/property-condition-variable-step-functions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -15,36 +15,32 @@ * */ +#include #include #include #include #include #include -#include namespace Dali { - namespace Internal { - namespace SceneGraph { - namespace { +const int32_t ARGINDEX_STEP_INDEX = 0; +const int32_t ARGINDEX_LIST_SIZE = 1; +const int32_t ARGINDEX_LIST_START = 2; -const int ARGINDEX_STEP_INDEX = 0; -const int ARGINDEX_LIST_SIZE = 1; -const int ARGINDEX_LIST_START = 2; - -} +} // namespace -ConditionFunction VariableStep::GetFunction( Property::Type valueType ) +ConditionFunction VariableStep::GetFunction(Property::Type valueType) { - ConditionFunction function = NULL; + ConditionFunction function = nullptr; - switch( valueType ) + switch(valueType) { case Property::INTEGER: { @@ -81,23 +77,23 @@ ConditionFunction VariableStep::GetFunction( Property::Type valueType ) return function; } -bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::Evaluate(const float propertyValue, PropertyNotification::RawArgumentContainer& arg) { - const int currentIndex = arg[ARGINDEX_STEP_INDEX]; - const int numSteps = arg[ARGINDEX_LIST_SIZE]; - const float first = arg[ARGINDEX_LIST_START]; - const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)]; - const bool ascending = (last > first) ? true : false; - int newIndex = currentIndex; + const int32_t currentIndex = static_cast(arg[ARGINDEX_STEP_INDEX]); // truncated + const int32_t numSteps = static_cast(arg[ARGINDEX_LIST_SIZE]); // truncated + const float first = arg[ARGINDEX_LIST_START]; + const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)]; + const bool ascending = (last > first) ? true : false; + int32_t newIndex = currentIndex; // avoid loop if property currently not within any of the range values - if( ascending ) + if(ascending) { - if( propertyValue < first ) + if(propertyValue < first) { newIndex = -1; } - else if( propertyValue >= last ) + else if(propertyValue >= last) { newIndex = numSteps - 1; } @@ -105,24 +101,23 @@ bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::Ra else { // increments are in negative direction - if( propertyValue > first ) + if(propertyValue > first) { newIndex = -1; } - else if( propertyValue <= last ) + else if(propertyValue <= last) { newIndex = numSteps - 1; } } - int i = 0; - for( i = 0 ; i < numSteps - 1 ; ++i ) + int32_t i = 0; + for(i = 0; i < numSteps - 1; ++i) { const float arg1 = arg[ARGINDEX_LIST_START + i]; const float arg2 = arg[ARGINDEX_LIST_START + (i + 1)]; - if( ascending ) + if(ascending) { - if( ( propertyValue >= arg1 ) - && ( propertyValue < arg2 ) ) + if((propertyValue >= arg1) && (propertyValue < arg2)) { newIndex = i; break; @@ -131,15 +126,14 @@ bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::Ra else { // increments are in negative direction - if( ( propertyValue > arg2 ) - && ( propertyValue <= arg1 ) ) + if((propertyValue > arg2) && (propertyValue <= arg1)) { newIndex = i; break; } } } - if( newIndex != currentIndex ) + if(newIndex != currentIndex) { // have changed to new step arg[ARGINDEX_STEP_INDEX] = static_cast(newIndex); @@ -148,37 +142,37 @@ bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::Ra return false; } -bool VariableStep::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalInteger(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { - const float propertyValue = static_cast( value.GetInteger() ); - return Evaluate( propertyValue, arg ); + const float propertyValue = static_cast(value.GetInteger()); + return Evaluate(propertyValue, arg); } -bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalFloat(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { const float propertyValue = value.GetFloat(); - return Evaluate( propertyValue, arg ); + return Evaluate(propertyValue, arg); } -bool VariableStep::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalVector2(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { const float propertyValue = value.GetVector2().LengthSquared(); - return Evaluate( propertyValue, arg ); + return Evaluate(propertyValue, arg); } -bool VariableStep::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalVector3(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { float propertyValue = value.GetVector3().LengthSquared(); - return Evaluate( propertyValue, arg ); + return Evaluate(propertyValue, arg); } -bool VariableStep::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalVector4(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { const float propertyValue = value.GetVector4().LengthSquared(); - return Evaluate( propertyValue, arg ); + return Evaluate(propertyValue, arg); } -bool VariableStep::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg ) +bool VariableStep::EvalDefault(const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg) { return false; }