From b96bf0ffad92e6191c53f0ab32730cac118f356e Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Fri, 3 Nov 2023 16:42:30 +0900 Subject: [PATCH] Register some text property one time. + Shrink custom property count Change-Id: Ib9508a59dcbeed74d2b9ac5ddd69dbaffd100762 Signed-off-by: Eunki, Hong --- .../visuals/animated-gradient/animated-gradient-visual.cpp | 4 ++-- dali-toolkit/internal/visuals/text/text-visual.cpp | 8 +++++--- dali-toolkit/internal/visuals/text/text-visual.h | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp b/dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp index d85d6ed..61f1b4d 100644 --- a/dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-gradient/animated-gradient-visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 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. @@ -35,7 +35,7 @@ namespace Internal { namespace { -const int CUSTOM_PROPERTY_COUNT(12); // 5 transform properties + Start point/color, end point/color, rotate center/angle, offset +const int CUSTOM_PROPERTY_COUNT(7); // Start point/color, end point/color, rotate center/angle, offset DALI_ENUM_TO_STRING_TABLE_BEGIN(GRADIENT_TYPE) DALI_ENUM_TO_STRING_WITH_SCOPE(Toolkit::DevelAnimatedGradientVisual::GradientType, LINEAR) diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index b7bdbfb..b3801f6 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -53,7 +53,7 @@ namespace { DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_PERFORMANCE_MARKER, false); -const int CUSTOM_PROPERTY_COUNT(5); // anim,premul,size,offset,multicol +const int CUSTOM_PROPERTY_COUNT(2); // uTextColorAnimatable, uHasMultipleTextColors /** * Return Property index for the given string key @@ -256,6 +256,7 @@ TextVisual::TextVisual(VisualFactoryCache& factoryCache, TextVisualShaderFactory mTypesetter(Text::Typesetter::New(mController->GetTextModel())), mTextVisualShaderFactory(shaderFactory), mTextShaderFeatureCache(), + mHasMultipleTextColorsIndex(Property::INVALID_INDEX), mAnimatableTextColorPropertyIndex(Property::INVALID_INDEX), mTextColorAnimatableIndex(Property::INVALID_INDEX), mRendererUpdateNeeded(false) @@ -275,6 +276,7 @@ void TextVisual::OnInitialize() mImpl->mRenderer = VisualRenderer::New(geometry, shader); mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); + mHasMultipleTextColorsIndex = mImpl->mRenderer.RegisterUniqueProperty("uHasMultipleTextColors", false); } void TextVisual::DoSetProperties(const Property::Map& propertyMap) @@ -643,7 +645,7 @@ void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sa // Enable the pre-multiplied alpha to improve the text quality renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true); - renderer.RegisterProperty(PREMULTIPLIED_ALPHA, 1.0f); + renderer.SetProperty(VisualRenderer::Property::VISUAL_PRE_MULTIPLIED_ALPHA, true); // Set size and offset for the tiling. renderer.SetProperty(VisualRenderer::Property::TRANSFORM_SIZE, Vector2(info.width, info.height)); @@ -672,7 +674,7 @@ void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultiple mImpl->mRenderer.SetTextures(textureSet); //Register transform properties mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); - mImpl->mRenderer.RegisterProperty("uHasMultipleTextColors", static_cast(hasMultipleTextColors)); + mImpl->mRenderer.SetProperty(mHasMultipleTextColorsIndex, static_cast(hasMultipleTextColors)); mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON); mRendererList.push_back(mImpl->mRenderer); diff --git a/dali-toolkit/internal/visuals/text/text-visual.h b/dali-toolkit/internal/visuals/text/text-visual.h index 1b1930d..7be059c 100644 --- a/dali-toolkit/internal/visuals/text/text-visual.h +++ b/dali-toolkit/internal/visuals/text/text-visual.h @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H /* - * Copyright (c) 2022 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. @@ -315,6 +315,7 @@ private: WeakHandle mControl; ///< The control where the renderer is added. Constraint mColorConstraint{}; ///< Color constraint Constraint mOpacityConstraint{}; ///< Opacity constraint + Property::Index mHasMultipleTextColorsIndex; ///< The index of uHasMultipleTextColors proeprty. 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. -- 2.7.4