[Libreoffice-commits] core.git: vcl/win

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 7 17:47:57 UTC 2021


 vcl/win/gdi/winlayout.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 2736f7693a3099469599a0f9ebb132fe69651649
Author:     Luboš Luňák <l.lunak at centrum.cz>
AuthorDate: Wed Apr 7 14:51:32 2021 +0000
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Wed Apr 7 19:47:19 2021 +0200

    cache also GetFontData() failures
    
    When drawing some documents such as tdf#141278 GetFontData() is
    30+% of CPU time.
    While at it, also fix the broken refcounting because of missing
    operator=.
    
    Change-Id: Ie62328b8e1c4ff700558796609f4bc6ad7e03a85
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113745
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index e4baa93f55eb..a246ae7096c1 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -186,11 +186,18 @@ struct BlobReference
     {
         hb_blob_reference(mpBlob);
     }
-    BlobReference(BlobReference const& other)
+    BlobReference(BlobReference&& other)
         : mpBlob(other.mpBlob)
     {
-        hb_blob_reference(mpBlob);
+        other.mpBlob = nullptr;
+    }
+    BlobReference& operator=(BlobReference&& other)
+    {
+        std::swap(mpBlob, other.mpBlob);
+        return *this;
     }
+    BlobReference(const BlobReference& other) = delete;
+    BlobReference& operator=(BlobReference& other) = delete;
     ~BlobReference() { hb_blob_destroy(mpBlob); }
 };
 }
@@ -242,13 +249,14 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU
     SelectObject(hDC, hOrigFont);
 
     if (!pBuffer)
+    { // Cache also failures.
+        gCache.insert({ cacheKey, BlobReference(nullptr) });
         return nullptr;
+    }
 
     hb_blob_t* pBlob
         = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY,
                          pBuffer, [](void* data) { delete[] static_cast<unsigned char*>(data); });
-    if (!pBlob)
-        return pBlob;
     gCache.insert({ cacheKey, BlobReference(pBlob) });
     return pBlob;
 }


More information about the Libreoffice-commits mailing list