summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-06 18:52:21 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-08 21:27:59 +0200
commit1b593dbc62dc2ceebc3f8be30d7221c916098f6d (patch)
tree2921d0a6f833e46605f093ae20d0b48e0fd7dd86
parentea3f08b91d70587400011e7a34fd9df259542e85 (diff)
use vcl::text::TextLayoutCache in SalLayoutGlyphsCache
Change-Id: I0ec22fe53e05319dec15456a916b10e97ea91a75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132668 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--include/vcl/glyphitemcache.hxx17
-rw-r--r--vcl/source/gdi/impglyphitem.cxx14
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<const OutputDevice> outputDevice,
- const OUString& text) const
+ const SalLayoutGlyphs*
+ GetLayoutGlyphs(VclPtr<const OutputDevice> 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<const OutputDevice> 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<const OutputDevice> 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<const OutputDevice> 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<const OutputDevice> outputDevice, c
// So in that case this is a cached failure.
return nullptr;
}
- std::unique_ptr<SalLayout> layout = outputDevice->ImplLayout(
- text, nIndex, nLen, rLogicPos, nLogicWidth, {}, SalLayoutFlags::GlyphItemsOnly);
+ std::shared_ptr<const vcl::text::TextLayoutCache> tmpLayoutCache;
+ if (layoutCache == nullptr)
+ {
+ tmpLayoutCache = OutputDevice::CreateTextLayoutCache(text);
+ layoutCache = tmpLayoutCache.get();
+ }
+ std::unique_ptr<SalLayout> layout
+ = outputDevice->ImplLayout(text, nIndex, nLen, rLogicPos, nLogicWidth, {},
+ SalLayoutFlags::GlyphItemsOnly, layoutCache);
if (layout)
{
mCachedGlyphs.insert(std::make_pair(key, layout->GetGlyphs()));