[Libreoffice-commits] core.git: vcl/inc vcl/source

Mark Hung (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 21 11:23:02 UTC 2021


 vcl/inc/sallayout.hxx        |    2 +-
 vcl/source/gdi/sallayout.cxx |   17 ++++++++++++++++-
 vcl/source/outdev/font.cxx   |   12 ++++++++----
 3 files changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 10ea27faec115d4cffd6f66cee8f688399e1e0b2
Author:     Mark Hung <marklh9 at gmail.com>
AuthorDate: Mon Jun 14 10:20:42 2021 +0800
Commit:     Mark Hung <marklh9 at gmail.com>
CommitDate: Mon Jun 21 13:22:23 2021 +0200

    tdf#142560 handle cached glpyh items in ImplGlyphFallbackLayout
    
    Fallback layout beyond level1 isn't generated because pre-caculated
    glyph items does not contain glyph items that needs to fallback, i.e.
    when calling ImplLayoutArgs::PrepareFallback. Hence it produce no
    maFallbackRuns and maRuns. The patch changes
    ImplLayoutArgs::PrepareFallback so that it use pre-caculated glyph
    items in the next level to create maRuns to ensure the same fallback
    layouts are genrated as layouts generated without pre-caculated glyph
    items.
    
    Change-Id: I672f3be6c4915892792b3cb968ad4a325465ccc0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117105
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 3852442eeadb..f6783f3cc1ca 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -114,7 +114,7 @@ public:
     // methods used by BiDi and glyph fallback
     bool        NeedFallback() const
                     { return !maFallbackRuns.IsEmpty(); }
-    bool        PrepareFallback();
+    bool        PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl);
 
 private:
     void        AddRun( int nMinCharPos, int nEndCharPos, bool bRTL );
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 9f4757148b36..7b8f2c2a2a05 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -486,8 +486,23 @@ void ImplLayoutArgs::AddRun( int nCharPos0, int nCharPos1, bool bRTL )
     maRuns.AddRun( nCharPos0, nCharPos1, bRTL );
 }
 
-bool ImplLayoutArgs::PrepareFallback()
+bool ImplLayoutArgs::PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl)
 {
+    // Generate runs with pre-calculated glyph items instead maFallbackRuns.
+    if( pGlyphsImpl != nullptr )
+    {
+        maRuns.Clear();
+        maFallbackRuns.Clear();
+
+        for (auto const& aGlyphItem : *pGlyphsImpl)
+        {
+            for(int i = aGlyphItem.charPos(); i < aGlyphItem.charPos() + aGlyphItem.charCount(); ++i)
+                maRuns.AddPos(i, aGlyphItem.IsRTLGlyph());
+        }
+
+        return !maRuns.IsEmpty();
+    }
+
     // short circuit if no fallback is needed
     if( maFallbackRuns.IsEmpty() )
     {
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index b6c7fcff82e3..6c761ec4bf07 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1254,7 +1254,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
     // prepare multi level glyph fallback
     std::unique_ptr<MultiSalLayout> pMultiSalLayout;
     ImplLayoutRuns aLayoutRuns = rLayoutArgs.maRuns;
-    rLayoutArgs.PrepareFallback();
+    rLayoutArgs.PrepareFallback(nullptr);
     rLayoutArgs.mnFlags |= SalLayoutFlags::ForFallback;
 
     // get list of code units that need glyph fallback
@@ -1267,13 +1267,14 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
     OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear();
 
     FontSelectPattern aFontSelData(mpFontInstance->GetFontSelectPattern());
+    SalLayoutGlyphsImpl* pGlyphsImpl = pGlyphs ? pGlyphs->Impl(1) : nullptr;
 
     // try if fallback fonts support the missing code units
     for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel )
     {
         rtl::Reference<LogicalFontInstance> pFallbackFont;
-        if(pGlyphs != nullptr && pGlyphs->Impl(nFallbackLevel) != nullptr)
-            pFallbackFont = pGlyphs->Impl(nFallbackLevel)->GetFont();
+        if(pGlyphsImpl != nullptr)
+            pFallbackFont = pGlyphsImpl->GetFont();
         // find a font family suited for glyph fallback
         // GetGlyphFallbackFont() needs a valid FontInstance
         // if the system-specific glyph fallback is active
@@ -1307,8 +1308,11 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
                 pMultiSalLayout->SetIncomplete(true);
         }
 
+        if (pGlyphs != nullptr)
+            pGlyphsImpl = pGlyphs->Impl(nFallbackLevel + 1);
+
         // break when this fallback was sufficient
-        if( !rLayoutArgs.PrepareFallback() )
+        if( !rLayoutArgs.PrepareFallback(pGlyphsImpl) )
             break;
     }
 


More information about the Libreoffice-commits mailing list