vcl/source/gdi/impglyphitem.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit e544febe2108d0bbe99936ce7373a22f32fe08a7
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed May 25 17:25:35 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed May 25 22:06:13 2022 +0200

    don't try glyph subsets if cloneCharRange() would return anyway
    
    A small optimization.
    
    Change-Id: I21786ce713bd39d14c075a941d83c060d04b8886
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134949
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index ffed4d56c743..bdedb263778e 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -103,6 +103,7 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
     // the subset may not quite match what would a real layout call give (e.g. 
some characters with neutral
     // direction such as space might have different LTR/RTL flag). It seems 
bailing out here mostly
     // avoid relatively rare corner cases and doesn't matter for performance.
+    // This is also checked in SalLayoutGlyphsCache::GetLayoutGlyphs() below.
     if (!(GetFlags() & SalLayoutFlags::BiDiStrong)
         || rtl != bool(GetFlags() & SalLayoutFlags::BiDiRtl))
         return nullptr;
@@ -317,7 +318,10 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const 
OutputDevice> outputDevice, c
     }
     bool resetLastSubstringKey = true;
     const sal_Unicode nbSpace = 0xa0; // non-breaking space
-    if (nIndex != 0 || nLen != text.getLength())
+    // SalLayoutGlyphsImpl::cloneCharRange() requires BiDiStrong, so if not 
set, do not even try.
+    bool skipGlyphSubsets
+        = !(outputDevice->GetLayoutMode() & 
vcl::text::ComplexTextLayoutFlags::BiDiStrong);
+    if ((nIndex != 0 || nLen != text.getLength()) && !skipGlyphSubsets)
     {
         // The glyphs functions are often called first for an entire string
         // and then with an increasing starting index until the end of the 
string.

Reply via email to