From 1b593dbc62dc2ceebc3f8be30d7221c916098f6d Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Wed, 6 Apr 2022 18:52:21 +0200 Subject: use vcl::text::TextLayoutCache in SalLayoutGlyphsCache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0ec22fe53e05319dec15456a916b10e97ea91a75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132668 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- include/vcl/glyphitemcache.hxx | 17 ++++++++++------- vcl/source/gdi/impglyphitem.cxx | 14 +++++++++++--- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/vcl/glyphitemcache.hxx b/include/vcl/glyphitemcache.hxx index 8c7cd01bbadc..83c77309a632 100644 --- a/include/vcl/glyphitemcache.hxx +++ b/include/vcl/glyphitemcache.hxx @@ -44,15 +44,18 @@ public: : mCachedGlyphs(size) { } - const SalLayoutGlyphs* GetLayoutGlyphs(VclPtr outputDevice, - const OUString& text) const + const SalLayoutGlyphs* + GetLayoutGlyphs(VclPtr outputDevice, const OUString& text, + const vcl::text::TextLayoutCache* layoutCache = nullptr) const { - return GetLayoutGlyphs(outputDevice, text, 0, text.getLength()); + return GetLayoutGlyphs(outputDevice, text, 0, text.getLength(), Point(0, 0), 0, + layoutCache); } - const SalLayoutGlyphs* GetLayoutGlyphs(VclPtr outputDevice, - const OUString& text, sal_Int32 nIndex, sal_Int32 nLen, - const Point& rLogicPos = Point(0, 0), - tools::Long nLogicWidth = 0) const; + const SalLayoutGlyphs* + GetLayoutGlyphs(VclPtr outputDevice, const OUString& text, sal_Int32 nIndex, + sal_Int32 nLen, const Point& rLogicPos = Point(0, 0), + tools::Long nLogicWidth = 0, + const vcl::text::TextLayoutCache* layoutCache = nullptr) const; void clear() { mCachedGlyphs.clear(); } private: diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx index 3853691d7d00..eaf8cf5c8453 100644 --- a/vcl/source/gdi/impglyphitem.cxx +++ b/vcl/source/gdi/impglyphitem.cxx @@ -97,7 +97,8 @@ bool SalLayoutGlyphsImpl::IsValid() const const SalLayoutGlyphs* SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr outputDevice, const OUString& text, sal_Int32 nIndex, sal_Int32 nLen, const Point& rLogicPos, - tools::Long nLogicWidth) const + tools::Long nLogicWidth, + const vcl::text::TextLayoutCache* layoutCache) const { if (nLen == 0) return nullptr; @@ -112,8 +113,15 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr outputDevice, c // So in that case this is a cached failure. return nullptr; } - std::unique_ptr layout = outputDevice->ImplLayout( - text, nIndex, nLen, rLogicPos, nLogicWidth, {}, SalLayoutFlags::GlyphItemsOnly); + std::shared_ptr tmpLayoutCache; + if (layoutCache == nullptr) + { + tmpLayoutCache = OutputDevice::CreateTextLayoutCache(text); + layoutCache = tmpLayoutCache.get(); + } + std::unique_ptr layout + = outputDevice->ImplLayout(text, nIndex, nLen, rLogicPos, nLogicWidth, {}, + SalLayoutFlags::GlyphItemsOnly, layoutCache); if (layout) { mCachedGlyphs.insert(std::make_pair(key, layout->GetGlyphs())); -- cgit