summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-07-12 13:40:34 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-07-13 04:22:05 +0200
commit4c8f88bef948b18f3d810c29a7f83496367758a9 (patch)
tree04a2797a16a1ca58f10904a89ee4940e4e39da8d /vcl
parent08e117def0dc8541c177a2a1a0700fac9635f0fc (diff)
tdf#92064 sw: Improve Tibetan layout performance
This change includes the following scalability improvements for documents containing extremely long paragraphs: - Reduces the size of layout contexts to account for line breaks. - Disables a misbehaving glyph cache performance optimization for long strings. Change-Id: Ie9a3365076c0d112a7a655988d672a9f4609b42b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170420 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/impglyphitem.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 300127de6b7a..184e9f819b5a 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -364,6 +364,13 @@ const SalLayoutGlyphs* SalLayoutGlyphsCache::GetLayoutGlyphs(
// part being underlined. Doing this for any two segments allows this optimization
// even when the prefix of the string would use a different font.
// TODO: Can those font differences be ignored?
+
+ // Shaping performance seems to scale poorly with respect to string length. Certain
+ // writing systems involve extremely long strings (for example, Tibetan: tdf#92064).
+ // In such cases, this optimization would be a net loss, and must be disabled.
+ constexpr sal_Int32 nOptLengthThreshold = 20000;
+ bool bEnableOptimization = (text.getLength() < nOptLengthThreshold);
+
// Writer layouts tests enable SAL_NON_APPLICATION_FONT_USE=abort in order
// to make PrintFontManager::Substitute() abort if font fallback happens. When
// laying out the entire string the chance this happens increases (e.g. testAbi11870
@@ -374,7 +381,7 @@ const SalLayoutGlyphs* SalLayoutGlyphsCache::GetLayoutGlyphs(
const char* pEnv = getenv("SAL_NON_APPLICATION_FONT_USE");
return pEnv && strcmp(pEnv, "abort") == 0;
}();
- if (mLastSubstringKey.has_value() && !bAbortOnFontSubstitute)
+ if (bEnableOptimization && mLastSubstringKey.has_value() && !bAbortOnFontSubstitute)
{
sal_Int32 pos = nIndex;
if (mLastSubstringKey->len < pos && pos > 0 && text[pos - 1] == nbSpace)