if(parameters.renderType == AsyncTextParameters::FIXED_WIDTH || parameters.renderType == AsyncTextParameters::CONSTRAINT)
{
- uint32_t height = ComputeHeightForWidth(parameters, parameters.textWidth);
+ // In case of CONSTRAINT, the natural size has already been calculated.
+ // So we can skip Initialize and Update at this stage.
+ // Only the layout is newly calculated to obtain the height.
+ bool layoutOnly = (parameters.renderType == AsyncTextParameters::CONSTRAINT);
+ float height = ComputeHeightForWidth(parameters, parameters.textWidth, layoutOnly);
- // textHeight is heightConstraint
+ // textHeight is heightConstraint.
if(parameters.textHeight < height)
{
bool layoutUpdated = false;
return Render(parameters);
}
-uint32_t AsyncTextLoader::ComputeHeightForWidth(AsyncTextParameters& parameters, uint32_t width)
+float AsyncTextLoader::ComputeHeightForWidth(AsyncTextParameters& parameters, float width, bool layoutOnly)
{
DALI_LOG_RELEASE_INFO("-->AsyncTextLoader::ComputeHeightForWidth\n");
parameters.textWidth = width;
parameters.textHeight = MAX_FLOAT;
- Initialize();
- Update(parameters);
- bool layoutUpdated = false;
+ if(!layoutOnly)
+ {
+ Initialize();
+ Update(parameters);
+ }
+ bool layoutUpdated = false;
Size layoutSize = Layout(parameters, layoutUpdated);
// Restore actual size.
if(parameters.renderType == AsyncTextParameters::FIXED_WIDTH || parameters.renderType == AsyncTextParameters::CONSTRAINT)
{
- uint32_t height = ComputeHeightForWidth(parameters, parameters.textWidth);
+ // In case of CONSTRAINT, the natural size has already been calculated.
+ // So we can skip Initialize and Update at this stage.
+ // Only the layout is newly calculated to obtain the height.
+ bool layoutOnly = (parameters.renderType == AsyncTextParameters::CONSTRAINT);
+ float height = ComputeHeightForWidth(parameters, parameters.textWidth, layoutOnly);
// textHeight is heightConstraint
if(parameters.textHeight > height)
*
* @param[in] parameters All options required to compute height of text.
* @param[in] width The width of text to compute.
+ * @param[in] layoutOnly If there is no need to Initialize/Update, only the Layout is performed.
*
* @return The height for width of text.
*/
- uint32_t ComputeHeightForWidth(AsyncTextParameters& parameters, uint32_t width);
+ float ComputeHeightForWidth(AsyncTextParameters& parameters, float width, bool layoutOnly);
/**
* @brief Check if the text fits.