From c56d06b256aa71ead3b7a1920494c1426788ee9b Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 19 Jun 2024 18:57:05 +0900 Subject: [PATCH] [Tizen] Call OnBake(), OnSet only if the value is really changed Let we check the current value and inputed value, so if they are same, ignore. It will be useful when we don't want to mark dirty for animatable property doesn't changed. For performance issue, let we just check only for bool / int / float. TODO : Chould we check them also at Vector2,3,4? Change-Id: I70b36eab97585a09c2c021da4f37a1d983a771af Signed-off-by: Eunki, Hong --- dali/internal/update/common/animatable-property.h | 60 ++++++++++++++++------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/dali/internal/update/common/animatable-property.h b/dali/internal/update/common/animatable-property.h index deef70c..5e1e6bb 100644 --- a/dali/internal/update/common/animatable-property.h +++ b/dali/internal/update/common/animatable-property.h @@ -379,9 +379,13 @@ public: */ void Set(BufferIndex bufferIndex, int value) { - mValue[bufferIndex] = value; + // check if the value actually changed to avoid dirtying nodes unnecessarily + if(mValue[bufferIndex] != value) + { + mValue[bufferIndex] = value; - OnSet(); + OnSet(); + } } /** @@ -391,9 +395,13 @@ public: */ void SetRelative(BufferIndex bufferIndex, int delta) { - mValue[bufferIndex] = mValue[bufferIndex] + delta; + // check if the value actually changed to avoid dirtying nodes unnecessarily + if(delta) + { + mValue[bufferIndex] = mValue[bufferIndex] + delta; - OnSet(); + OnSet(); + } } /** @@ -439,11 +447,15 @@ public: */ void Bake(BufferIndex bufferIndex, int value) { - mValue[bufferIndex] = value; - mValue[1 - bufferIndex] = value; - mBaseValue = mValue[bufferIndex]; + // bake has to check the base value as current buffer value can be correct by constraint or something else + if(mBaseValue != value) + { + mValue[bufferIndex] = value; + mValue[1 - bufferIndex] = value; + mBaseValue = mValue[bufferIndex]; - OnBake(); + OnBake(); + } } /** @@ -570,9 +582,13 @@ public: */ void Set(BufferIndex bufferIndex, float value) { - mValue[bufferIndex] = value; + // check if the value actually changed to avoid dirtying nodes unnecessarily + if(!Dali::Equals(mValue[bufferIndex], value)) + { + mValue[bufferIndex] = value; - OnSet(); + OnSet(); + } } /** @@ -582,9 +598,13 @@ public: */ void SetRelative(BufferIndex bufferIndex, float delta) { - mValue[bufferIndex] = mValue[bufferIndex] + delta; + // check if the value actually changed to avoid dirtying nodes unnecessarily + if(!Dali::EqualsZero(delta)) + { + mValue[bufferIndex] = mValue[bufferIndex] + delta; - OnSet(); + OnSet(); + } } /** @@ -630,13 +650,17 @@ public: */ void Bake(BufferIndex bufferIndex, float 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; - mBaseValue = mValue[bufferIndex]; + // bake has to check the base value as current buffer value can be correct by constraint or something else + if(!Dali::Equals(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; + mBaseValue = mValue[bufferIndex]; - OnBake(); + OnBake(); + } } /** -- 2.7.4