From: Heeyong Song Date: Thu, 4 Nov 2021 02:21:04 +0000 (+0900) Subject: Fix text visual issue X-Git-Tag: dali_2.0.52~8 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=ec0f0792f651f58e887bf53801da23a6d76de0e0;hp=-c Fix text visual issue uTextColorAnimatable property should always be registered. Change-Id: I3ffbccc896f6abe4665a6f133b5be22df64df043 --- ec0f0792f651f58e887bf53801da23a6d76de0e0 diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index ee31d1f..a4903c5 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -239,6 +239,7 @@ TextVisual::TextVisual(VisualFactoryCache& factoryCache) mController(Text::Controller::New()), mTypesetter(Text::Typesetter::New(mController->GetTextModel())), mAnimatableTextColorPropertyIndex(Property::INVALID_INDEX), + mTextColorAnimatableIndex(Property::INVALID_INDEX), mRendererUpdateNeeded(false) { } @@ -290,29 +291,36 @@ void TextVisual::DoSetOnScene(Actor& actor) // Enable the pre-multiplied alpha to improve the text quality EnablePreMultipliedAlpha(true); - if(mAnimatableTextColorPropertyIndex != Property::INVALID_INDEX) + const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor(); + if(mTextColorAnimatableIndex == Property::INVALID_INDEX) + { + mTextColorAnimatableIndex = mImpl->mRenderer.RegisterProperty("uTextColorAnimatable", defaultColor); + } + else { - const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor(); - Dali::Property::Index shaderTextColorIndex = mImpl->mRenderer.RegisterProperty("uTextColorAnimatable", defaultColor); + mImpl->mRenderer.SetProperty(mTextColorAnimatableIndex, defaultColor); + } + if(mAnimatableTextColorPropertyIndex != Property::INVALID_INDEX) + { // Create constraint for the animatable text's color Property with uTextColorAnimatable in the renderer. - if(shaderTextColorIndex != Property::INVALID_INDEX) + if(mTextColorAnimatableIndex != Property::INVALID_INDEX) { if(!mColorConstraint) { - mColorConstraint = Constraint::New(mImpl->mRenderer, shaderTextColorIndex, TextColorConstraint); + mColorConstraint = Constraint::New(mImpl->mRenderer, mTextColorAnimatableIndex, TextColorConstraint); mColorConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); } mColorConstraint.Apply(); + } - // Make zero if the alpha value of text color is zero to skip rendering text - if(!mOpacityConstraint) - { - mOpacityConstraint = Constraint::New(mImpl->mRenderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint); - mOpacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); - } - mOpacityConstraint.Apply(); + // Make zero if the alpha value of text color is zero to skip rendering text + if(!mOpacityConstraint) + { + mOpacityConstraint = Constraint::New(mImpl->mRenderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint); + mOpacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex)); } + mOpacityConstraint.Apply(); } // Renderer needs textures and to be added to control diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index 7304f0f..f9d6c79 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -336,6 +336,7 @@ private: Constraint mColorConstraint{}; ///< Color constraint Constraint mOpacityConstraint{}; ///< Opacity constraint Property::Index mAnimatableTextColorPropertyIndex; ///< The index of animatable text color property registered by the control. + Property::Index mTextColorAnimatableIndex; ///< The index of uTextColorAnimatable property. bool mRendererUpdateNeeded : 1; ///< The flag to indicate whether the renderer needs to be updated. RendererContainer mRendererList; };