From 2a895690e5ece087235802c6c37912c37a2bb8a1 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 9 Jul 2024 13:04:23 +0900 Subject: [PATCH] Add async related properties to text label ASYNC_LOAD: Enables/disables the async text laod AUTO_ASYNC_LOAD: For automatically requests an asynchronous text load in OnRelayout ASYNC_PROPERTY_UPDATED: A flag that indicates that new rendering is needed due to a property change in async mode. Change-Id: I1804f832d043010af42d42cedcabf1985edd21f4 Signed-off-by: Bowon Ryu --- .../controls/text-controls/text-label-devel.h | 24 +++++++++++ .../controls/text-controls/text-label-impl.cpp | 49 ++++++++++++++++++++-- .../text/controller/text-controller-impl.h | 4 +- .../internal/text/controller/text-controller.cpp | 10 +++++ .../internal/text/controller/text-controller.h | 20 +++++++++ 5 files changed, 103 insertions(+), 4 deletions(-) diff --git a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h index 4c00662..162962f 100644 --- a/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h +++ b/dali-toolkit/devel-api/controls/text-controls/text-label-devel.h @@ -236,6 +236,30 @@ enum Type * @details Name "cutout", type Property::BOOLEAN. */ CUTOUT, + + /** + * @brief Whether to enable the async text load. + * @details Name "asyncLoad", type Property::BOOLEAN. + * @note Enables/disables the async text laod. + */ + ASYNC_LOAD, + + /** + * @brief Whether to enable the auto async text load. + * @details Name "autoAsyncLoad", type Property::BOOLEAN. + * @note If True, automatically requests an asynchronous text load in OnRelayout. + * This will only be effective when AsyncTextLoadEnabled is set to true. + */ + AUTO_ASYNC_LOAD, + + /** + * @brief Whether to property updated on async mode. + * @details Name "asyncPropertyUpdated", type Property::BOOLEAN. + * @note When the text property changes, the asyncPropertyUpdated flag becomes true, + * indicating that a new rendering needs to be performed. + * Once the new rendering is completed, this property is set back to false. + */ + ASYNC_PROPERTY_UPDATED, }; } // namespace Property diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 3bcc076..d9be4bd 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -148,6 +148,9 @@ DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "anchorClickedCol DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "removeFrontInset", BOOLEAN, REMOVE_FRONT_INSET ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "removeBackInset", BOOLEAN, REMOVE_BACK_INSET ) DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "cutout", BOOLEAN, CUTOUT ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "asyncLoad", BOOLEAN, ASYNC_LOAD ) +DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextLabel, "autoAsyncLoad", BOOLEAN, AUTO_ASYNC_LOAD ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(Toolkit, TextLabel, "asyncPropertyUpdated", BOOLEAN, ASYNC_PROPERTY_UPDATED ) DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR ) DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR, 0) @@ -643,6 +646,28 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro impl.mIsPropertyUpdated = true; break; } + case Toolkit::DevelTextLabel::Property::ASYNC_LOAD: + { + const bool enable = value.Get(); + if(impl.mController->IsAsyncTextLoadEnabled() != enable) + { + impl.mController->SetAsyncTextLoadEnabled(enable); + } + break; + } + case Toolkit::DevelTextLabel::Property::AUTO_ASYNC_LOAD: + { + const bool enable = value.Get(); + if(impl.mController->IsAutoAsyncTextLoadEnabled() != enable) + { + impl.mController->SetAutoAsyncTextLoadEnabled(enable); + if(enable) + { + impl.mIsPropertyUpdated = true; + } + } + break; + } } // Request relayout when text update is needed. It's necessary to call it @@ -933,6 +958,21 @@ Property::Value TextLabel::GetProperty(BaseObject* object, Property::Index index value = impl.mController->IsTextCutout(); break; } + case Toolkit::DevelTextLabel::Property::ASYNC_LOAD: + { + value = impl.mController->IsAsyncTextLoadEnabled(); + break; + } + case Toolkit::DevelTextLabel::Property::AUTO_ASYNC_LOAD: + { + value = impl.mController->IsAutoAsyncTextLoadEnabled(); + break; + } + case Toolkit::DevelTextLabel::Property::ASYNC_PROPERTY_UPDATED: + { + value = impl.mIsPropertyUpdated; + break; + } } } @@ -1208,6 +1248,11 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container) { DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::OnRelayout\n"); + if(mController->IsAsyncTextLoadEnabled() && !mController->IsAutoAsyncTextLoadEnabled()) + { + return; + } + if(mTextScroller && mTextScroller->IsStop()) { // When auto scroll is playing, it triggers a relayout only when an update is absolutely necessary. @@ -1230,9 +1275,6 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container) std::swap(padding.start, padding.end); } - // FOR TEST - mController->SetAsyncTextLoadEnabled(true); - if(mController->IsAsyncTextLoadEnabled()) { if(mController->IsAutoScrollEnabled() && mTextScroller && mTextScroller->IsScrolling() && !mTextUpdateNeeded) @@ -1240,6 +1282,7 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container) // When auto scroll is playing, a text load request is made only if a text update is absolutely necessary. return; } + if(!mIsPropertyUpdated) { return; diff --git a/dali-toolkit/internal/text/controller/text-controller-impl.h b/dali-toolkit/internal/text/controller/text-controller-impl.h index d20ad8a..b669b85 100644 --- a/dali-toolkit/internal/text/controller/text-controller-impl.h +++ b/dali-toolkit/internal/text/controller/text-controller-impl.h @@ -377,7 +377,8 @@ struct Controller::Impl mIsUserInteractionEnabled(true), mProcessorRegistered(false), mTextCutout(false), - mAsyncTextLoadEnabled(false) + mAsyncTextLoadEnabled(false), + mAutoAsyncTextLoadEnabled(true) { mModel = Model::New(); @@ -1114,6 +1115,7 @@ public: bool mProcessorRegistered : 1; ///< Whether the text controller registered into processor or not. bool mTextCutout : 1; ///< Whether the text cutout enabled. bool mAsyncTextLoadEnabled : 1; ///< Whether the async text load is enabled. + bool mAutoAsyncTextLoadEnabled : 1; ///< Whether the auto async text load is enabled. private: friend ControllerImplEventHandler; diff --git a/dali-toolkit/internal/text/controller/text-controller.cpp b/dali-toolkit/internal/text/controller/text-controller.cpp index 573f938..e8ad50e 100644 --- a/dali-toolkit/internal/text/controller/text-controller.cpp +++ b/dali-toolkit/internal/text/controller/text-controller.cpp @@ -385,6 +385,16 @@ bool Controller::IsAsyncTextLoadEnabled() const return mImpl->mAsyncTextLoadEnabled; } +void Controller::SetAutoAsyncTextLoadEnabled(bool enable) +{ + mImpl->mAutoAsyncTextLoadEnabled = enable; +} + +bool Controller::IsAutoAsyncTextLoadEnabled() const +{ + return mImpl->mAutoAsyncTextLoadEnabled; +} + void Controller::SetLineWrapMode(Text::LineWrap::Mode lineWrapMode) { mImpl->SetLineWrapMode(lineWrapMode); diff --git a/dali-toolkit/internal/text/controller/text-controller.h b/dali-toolkit/internal/text/controller/text-controller.h index e4be641..16cc388 100644 --- a/dali-toolkit/internal/text/controller/text-controller.h +++ b/dali-toolkit/internal/text/controller/text-controller.h @@ -2031,6 +2031,26 @@ public: // Queries & retrieves. */ bool IsAsyncTextLoadEnabled() const; + /** + * @brief Enables/disables the auto async text laod. + * + * If True, automatically requests an asynchronous text load in OnRelayout. + * This will only be effective when AsyncTextLoadEnabled is set to true. + * By default is enabled. + * + * @param[in] enable Whether to enable the auto async text load. + */ + void SetAutoAsyncTextLoadEnabled(bool enable); + + /** + * @brief Retrieves whether the auto async text load is enabled. + * + * By default is enabled. + * + * @return @e true if the auto async text load is enabled, otherwise returns @e false. + */ + bool IsAutoAsyncTextLoadEnabled() const; + public: // Relayout. /** * @brief Triggers a relayout which updates View (if necessary). -- 2.7.4