summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-04-07 12:06:27 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-04-08 21:29:19 +0200
commit3e5863605881c6de6ad130fe06883c176ca1c69f (patch)
tree9e7863107a162eba8952710af00c281b91a12633 /vcl
parent53fe4a26c7c4691fcf9d07d022adfd45247d176b (diff)
use just one shared global SalLayoutGlyphsCache
Now the cache should be capable of detecting what needs to stay the same for having the same result, so it should be enough to have just one cache that can reuse results even between callers from different places. Change-Id: Ibdc0303f5b727d1a1d7be91d61db9465ed95e1c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132673 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/pdf/pdfwriter_impl.hxx3
-rw-r--r--vcl/source/gdi/impglyphitem.cxx20
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx10
3 files changed, 24 insertions, 9 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 69570fa84afb..b8bdc3825eee 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -53,7 +53,6 @@
#include <comphelper/hash.hxx>
#include <tools/stream.hxx>
#include <vcl/BinaryDataContainer.hxx>
-#include <vcl/glyphitemcache.hxx>
#include <vcl/filter/pdfobjectcontainer.hxx>
#include <pdf/ExternalPDFStreams.hxx>
@@ -765,8 +764,6 @@ private:
::comphelper::Hash m_DocDigest;
- SalLayoutGlyphsCache m_layoutGlyphsCache;
-
/*
variables for PDF security
i12626
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 01654cfddcbc..86284c256e64 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -20,8 +20,10 @@
#include <impglyphitem.hxx>
#include <vcl/glyphitemcache.hxx>
#include <vcl/vcllayout.hxx>
+#include <vcl/lazydelete.hxx>
#include <tools/stream.hxx>
#include <TextLayoutCache.hxx>
+#include <config_fuzzers.h>
SalLayoutGlyphs::SalLayoutGlyphs() {}
@@ -95,6 +97,12 @@ bool SalLayoutGlyphsImpl::IsValid() const
return true;
}
+SalLayoutGlyphsCache* SalLayoutGlyphsCache::self()
+{
+ static vcl::DeleteOnDeinit<SalLayoutGlyphsCache> cache(1000);
+ return cache.get();
+}
+
const SalLayoutGlyphs*
SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const OutputDevice> outputDevice, const OUString& text,
sal_Int32 nIndex, sal_Int32 nLen, tools::Long nLogicWidth,
@@ -119,9 +127,15 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr<const OutputDevice> outputDevice, c
tmpLayoutCache = OutputDevice::CreateTextLayoutCache(text);
layoutCache = tmpLayoutCache.get();
}
- std::unique_ptr<SalLayout> layout
- = outputDevice->ImplLayout(text, nIndex, nLen, Point(0, 0), nLogicWidth, {},
- SalLayoutFlags::GlyphItemsOnly, layoutCache);
+#if !ENABLE_FUZZERS
+ const SalLayoutFlags glyphItemsOnlyLayout = SalLayoutFlags::GlyphItemsOnly;
+#else
+ // ofz#39150 skip detecting bidi directions
+ const SalLayoutFlags glyphItemsOnlyLayout
+ = SalLayoutFlags::GlyphItemsOnly | SalLayoutFlags::BiDiStrong;
+#endif
+ std::unique_ptr<SalLayout> layout = outputDevice->ImplLayout(
+ text, nIndex, nLen, Point(0, 0), nLogicWidth, {}, glyphItemsOnlyLayout, layoutCache);
if (layout)
{
mCachedGlyphs.insert(std::make_pair(key, layout->GetGlyphs()));
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1853fe544eeb..7e01ed70dc58 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -61,6 +61,7 @@
#include <vcl/canvastools.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/fontcharmap.hxx>
+#include <vcl/glyphitemcache.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/metric.hxx>
#include <vcl/settings.hxx>
@@ -6499,7 +6500,8 @@ void PDFWriterImpl::drawText( const Point& rPos, const OUString& rText, sal_Int3
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- const SalLayoutGlyphs* layoutGlyphs = m_layoutGlyphsCache.GetLayoutGlyphs( this, rText, nIndex, nLen );
+ const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->
+ GetLayoutGlyphs( this, rText, nIndex, nLen );
std::unique_ptr<SalLayout> pLayout = ImplLayout( rText, nIndex, nLen, rPos,
0, {}, SalLayoutFlags::NONE, nullptr, layoutGlyphs );
if( pLayout )
@@ -6516,7 +6518,8 @@ void PDFWriterImpl::drawTextArray( const Point& rPos, const OUString& rText, o3t
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- const SalLayoutGlyphs* layoutGlyphs = m_layoutGlyphsCache.GetLayoutGlyphs( this, rText, nIndex, nLen );
+ const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->
+ GetLayoutGlyphs( this, rText, nIndex, nLen );
std::unique_ptr<SalLayout> pLayout = ImplLayout( rText, nIndex, nLen, rPos, 0, pDXArray,
SalLayoutFlags::NONE, nullptr, layoutGlyphs );
if( pLayout )
@@ -6533,7 +6536,8 @@ void PDFWriterImpl::drawStretchText( const Point& rPos, sal_uLong nWidth, const
// get a layout from the OutputDevice's SalGraphics
// this also enforces font substitution and sets the font on SalGraphics
- const SalLayoutGlyphs* layoutGlyphs = m_layoutGlyphsCache.GetLayoutGlyphs( this, rText, nIndex, nLen, nWidth );
+ const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->
+ GetLayoutGlyphs( this, rText, nIndex, nLen, nWidth );
std::unique_ptr<SalLayout> pLayout = ImplLayout( rText, nIndex, nLen, rPos, nWidth,
{}, SalLayoutFlags::NONE, nullptr, layoutGlyphs );
if( pLayout )