Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
#endif
-DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_PERFORMANCE_MARKER, false);
+DALI_INIT_TRACE_FILTER(gTraceFilter, DALI_TRACE_TEXT_PERFORMANCE_MARKER, false);
+DALI_INIT_TRACE_FILTER(gTraceFilter2, DALI_TRACE_PERFORMANCE_MARKER, false);
constexpr float MAX_FLOAT = std::numeric_limits<float>::max();
if(!isEditable)
{
+ if(NO_OPERATION != (VALIDATE_FONTS & operationsPending) &&
+ textUpdateInfo.mCharacterIndex == static_cast<CharacterIndex>(-1))
+ {
+ impl.ClearFontData();
+ updateInfoCharIndexBackup = textUpdateInfo.mCharacterIndex;
+ }
+
impl.UpdateModel(onlyOnceOperations);
// Layout the text for the new width.
Vector3 Controller::Relayouter::GetNaturalSize(Controller& controller)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::GetNaturalSize\n");
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_TEXT_GET_NATURAL_SIZE");
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_GET_NATURAL_SIZE");
Vector3 naturalSizeVec3;
// Make sure the model is up-to-date before layouting
naturalSizeVec3.x = ConvertToEven(naturalSizeVec3.x);
naturalSizeVec3.y = ConvertToEven(naturalSizeVec3.y);
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_GET_NATURAL_SIZE");
-
return naturalSizeVec3;
}
textUpdateInfo.Clear();
textUpdateInfo.mClearAll = true;
- if(textSize.width >= layoutSize.width || textSize.height >= layoutSize.height)
+ if(textSize.width > layoutSize.width || textSize.height > layoutSize.height)
{
return false;
}
const OperationsMask operations = impl.mOperationsPending;
if(NO_OPERATION != (UPDATE_LAYOUT_SIZE & operations) || impl.mTextFitContentSize != layoutSize)
{
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_TEXT_FIT_LAYOUT");
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_FIT_LAYOUT");
ModelPtr& model = impl.mModel;
- bool actualellipsis = model->mElideEnabled;
- float minPointSize = impl.mTextFitMinSize;
- float maxPointSize = impl.mTextFitMaxSize;
- float pointInterval = impl.mTextFitStepSize;
- float currentFitPointSize = impl.mFontDefaults->mFitPointSize;
+ bool actualellipsis = model->mElideEnabled;
+ float minPointSize = impl.mTextFitMinSize;
+ float maxPointSize = impl.mTextFitMaxSize;
+ float pointInterval = impl.mTextFitStepSize;
+ float currentFitPointSize = impl.mFontDefaults->mFitPointSize;
+ float currentDefaultLineSize = impl.mLayoutEngine.GetDefaultLineSize();
+ // Instead of using the LineSize of the current TextLabel, the LineSize set in TextFit is used.
+ impl.SetDefaultLineSize(impl.mTextFitLineSize);
model->mElideEnabled = false;
{
impl.mTextFitChanged = true;
}
+ // Revert back to the original TextLabel LineSize.
+ impl.SetDefaultLineSize(currentDefaultLineSize);
impl.mFontDefaults->mFitPointSize = bestPointSize;
impl.mFontDefaults->sizeDefined = true;
impl.ClearFontData();
-
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_FIT_LAYOUT");
}
}
float Controller::Relayouter::GetHeightForWidth(Controller& controller, float width)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::GetHeightForWidth %p width %f\n", &controller, width);
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_TEXT_GET_HEIGHT_FOR_WIDTH");
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_GET_HEIGHT_FOR_WIDTH");
// Make sure the model is up-to-date before layouting
EventHandler::ProcessModifyEvents(controller);
VisualModelPtr& visualModel = model->mVisualModel;
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
- Size layoutSize;
+ // Get cached value.
+ Size layoutSize = visualModel->GetHeightForWidth();
- if(fabsf(width - visualModel->mControlSize.width) > Math::MACHINE_EPSILON_1000 ||
+ if(fabsf(width - layoutSize.width) > Math::MACHINE_EPSILON_1000 ||
textUpdateInfo.mFullRelayoutNeeded ||
textUpdateInfo.mClearAll)
{
layoutSize = CalculateLayoutSizeOnRequiredControllerSize(controller, sizeRequestedWidthAndMaxHeight, requestedOperationsMask);
+ // The calculated layout width may not be the same as the requested width.
+ // For cache efficiency, the requested width is stored.
+ layoutSize.width = width;
+ visualModel->SetHeightForWidth(layoutSize);
+
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth calculated %f\n", layoutSize.height);
}
else
{
- layoutSize = visualModel->GetLayoutSize();
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::GetHeightForWidth cached %f\n", layoutSize.height);
}
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_GET_HEIGHT_FOR_WIDTH");
-
return layoutSize.height;
}
TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::Relayout %p size %f,%f, autoScroll[%s]\n", &controller, size.width, size.height, impl.mIsAutoScrollEnabled ? "true" : "false");
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_TEXT_RELAYOUT");
+ DALI_TRACE_SCOPE(gTraceFilter, "DALI_TEXT_RELAYOUT");
UpdateTextType updateTextType = NONE_UPDATED;
// Not worth to relayout if width or height is equal to zero.
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::Relayout (skipped)\n");
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_RELAYOUT");
return updateTextType;
}
// Clear the update info. This info will be set the next time the text is updated.
textUpdateInfo.Clear();
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::Relayout\n");
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_RELAYOUT");
return updateTextType;
}
bool Controller::Relayouter::DoRelayout(Controller::Impl& impl, const Size& size, OperationsMask operationsRequired, Size& layoutSize)
{
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "-->Controller::Relayouter::DoRelayout %p size %f,%f\n", &impl, size.width, size.height);
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_TEXT_DORELAYOUT");
+ DALI_TRACE_SCOPE(gTraceFilter2, "DALI_TEXT_DORELAYOUT");
bool viewUpdated(false);
// Calculate the operations to be done.
DALI_LOG_ERROR("Current text is: %s\n", currentText.c_str());
DALI_LOG_ERROR("startIndex: %u, lastIndex: %u, requestedNumberOfCharacters: %u, charactersToGlyph.Count = %lu, glyphsPerCharacter.Count = %lu\n", startIndex, lastIndex, requestedNumberOfCharacters, charactersToGlyph.Count(), glyphsPerCharacter.Count());
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_DORELAYOUT");
-
return false;
}
// Nothing else to do if there is no glyphs.
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::DoRelayout no glyphs, view updated true\n");
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_DORELAYOUT");
return true;
}
DALI_LOG_INFO(gLogFilter, Debug::Concise, "Controller::Relayouter::DoRelayout [%p] mImpl->mIsTextDirectionRTL[%s] [%s]\n", &impl, (impl.mIsTextDirectionRTL) ? "true" : "false", currentText.c_str());
#endif
DALI_LOG_INFO(gLogFilter, Debug::Verbose, "<--Controller::Relayouter::DoRelayout, view updated %s\n", (viewUpdated ? "true" : "false"));
- DALI_TRACE_END(gTraceFilter, "DALI_TEXT_DORELAYOUT");
return viewUpdated;
}