diff options
author | Luboš Luňák <l.lunak@centrum.cz> | 2021-04-07 14:51:32 +0000 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-04-07 19:47:19 +0200 |
commit | 2736f7693a3099469599a0f9ebb132fe69651649 (patch) | |
tree | 5f2e161329e0d38c62b3387ae3857e0caf3accc3 /vcl | |
parent | ae08aa8a095832ae2a88eac14f9680ac8d3a13b6 (diff) |
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@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 16 |
1 files changed, 12 insertions, 4 deletions
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; } |