From db765297ffcb69bff573cf14d138835b37afb697 Mon Sep 17 00:00:00 2001 From: Abdulleh Ghujeh Date: Wed, 13 Apr 2022 09:02:35 +0300 Subject: [PATCH] Enhance texteditor background drawing performance Change-Id: Ib2e2bce28431e4845adcfc0328844765bc8df1a7 --- dali-toolkit/internal/text/text-controller-background-actor.cpp | 3 +-- dali-toolkit/internal/text/visual-model-impl.cpp | 6 ++++++ dali-toolkit/internal/text/visual-model-impl.h | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dali-toolkit/internal/text/text-controller-background-actor.cpp b/dali-toolkit/internal/text/text-controller-background-actor.cpp index 7def7e8..bc7c79b 100644 --- a/dali-toolkit/internal/text/text-controller-background-actor.cpp +++ b/dali-toolkit/internal/text/text-controller-background-actor.cpp @@ -112,7 +112,6 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr Length yLineOffset = 0; Length prevLineIndex = 0; LineIndex lineIndex; - Length numberOfLines; for(uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i) { @@ -125,7 +124,7 @@ Actor CreateControllerBackgroundActor(const View& textView, const VisualModelPtr const bool isDefaultBackgroundColor = (0u == backgroundColorIndex); const Vector4& backgroundColor = isDefaultBackgroundColor ? defaultBackgroundColor : *(backgroundColorsBuffer + backgroundColorIndex - 1u); - textVisualModel->GetNumberOfLines(i, 1, lineIndex, numberOfLines); + lineIndex = textVisualModel->GetLineOfGlyph(i); Length lineHeight = CalculateBackgroundLineHeight(lineRun[lineIndex]); if(lineIndex != prevLineIndex) diff --git a/dali-toolkit/internal/text/visual-model-impl.cpp b/dali-toolkit/internal/text/visual-model-impl.cpp index 5ef2b50..490bae3 100644 --- a/dali-toolkit/internal/text/visual-model-impl.cpp +++ b/dali-toolkit/internal/text/visual-model-impl.cpp @@ -254,6 +254,12 @@ void VisualModel::GetNumberOfLines(GlyphIndex glyphIndex, } } +LineIndex VisualModel::GetLineOfGlyph( GlyphIndex glyphIndex ) +{ + const CharacterIndex characterIndex = *(mGlyphsToCharacters.Begin() + glyphIndex); + return GetLineOfCharacter(characterIndex); +} + void VisualModel::GetLinesOfGlyphRange(LineRun* lines, GlyphIndex glyphIndex, Length numberOfGlyphs) const diff --git a/dali-toolkit/internal/text/visual-model-impl.h b/dali-toolkit/internal/text/visual-model-impl.h index 9c0af3a..eebbe18 100644 --- a/dali-toolkit/internal/text/visual-model-impl.h +++ b/dali-toolkit/internal/text/visual-model-impl.h @@ -144,6 +144,15 @@ public: Length& numberOfLines) const; /** + * @brief Retrieves the line index where the glyph is laid-out. + * + * @param[in] glyphIndex The glyph's index. + * + * @return The line index. + */ + LineIndex GetLineOfGlyph(GlyphIndex glyphIndex); + + /** * @brief Retrieves the lines where the given range of glyphs is laid out. * * The size of the @p lines buffer needs to be big enough to copy the @p numberOfLines. -- 2.7.4