[Libreoffice-commits] core.git: officecfg/registry vcl/source
Thorsten Behrens (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 29 07:23:43 UTC 2020
officecfg/registry/schema/org/openoffice/Office/Common.xcs | 8 ++++++++
vcl/source/gdi/pdfwriter_impl.cxx | 3 +++
vcl/source/gdi/pdfwriter_impl.hxx | 5 +++++
vcl/source/gdi/pdfwriter_impl2.cxx | 10 +++-------
4 files changed, 19 insertions(+), 7 deletions(-)
New commits:
commit f9598b27815dbf9fa4010eda24e4f3f7cc90e3f2
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Wed Apr 29 02:02:08 2020 +0200
Commit: Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Apr 29 09:23:04 2020 +0200
improve: pdf export caching of jpeg bitmaps
* make cache size configurable (defaults to 15)
* have one cache object per PDFWriter instance, thus avoiding
accidentally caching JPEGs with different compression settings
Change-Id: I6664fc09b382f471cbe7c3e7aaedb3ebb5883b47
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93112
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index b405ea981d53..f55a7ce1280e 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -908,6 +908,14 @@
</info>
<value>25</value>
</prop>
+ <prop oor:name="PDFExportImageCacheSize" oor:type="xs:int" oor:nillable="false">
+ <info>
+ <desc>Specifies number of PDF image instances to cache on
+ export - can save potentially huge amount of CPU time on
+ re-compressing the same JPEG image over and over again.</desc>
+ </info>
+ <value>15</value>
+ </prop>
</group>
<group oor:name="InternalMSExport">
<info>
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index cb7f4cc17027..10758d84d639 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -41,6 +41,7 @@
#include <cppuhelper/implbase.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <o3tl/numeric.hxx>
+#include <officecfg/Office/Common.hxx>
#include <osl/file.hxx>
#include <osl/thread.h>
#include <rtl/digest.h>
@@ -1152,6 +1153,8 @@ PDFWriterImpl::PDFWriterImpl( const PDFWriter::PDFWriterContext& rContext,
m_nCurrentStructElement( 0 ),
m_bEmitStructure( true ),
m_nNextFID( 1 ),
+ m_aPDFBmpCache(
+ officecfg::Office::Common::VCL::PDFExportImageCacheSize::get() ),
m_nCurrentPage( -1 ),
m_nCatalogObject(0),
m_nSignatureObject( -1 ),
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index e775fc92a4af..6261a391ba3c 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -46,6 +46,7 @@
#include <vcl/wall.hxx>
#include <o3tl/safeint.hxx>
#include <o3tl/typed_flags_set.hxx>
+#include <o3tl/lru_map.hxx>
#include <comphelper/hash.hxx>
#include <tools/stream.hxx>
@@ -709,6 +710,10 @@ private:
sal_Int32 m_nNextFID;
PDFFontCache m_aFontCache;
+ /// Cache some most recent bitmaps we've exported, in case we encounter them again..
+ o3tl::lru_map<BitmapChecksum,
+ std::shared_ptr<SvMemoryStream>> m_aPDFBmpCache;
+
sal_Int32 m_nCurrentPage;
sal_Int32 m_nCatalogObject;
diff --git a/vcl/source/gdi/pdfwriter_impl2.cxx b/vcl/source/gdi/pdfwriter_impl2.cxx
index f84ab684c24c..443e51e3aebb 100644
--- a/vcl/source/gdi/pdfwriter_impl2.cxx
+++ b/vcl/source/gdi/pdfwriter_impl2.cxx
@@ -43,7 +43,6 @@
#include <com/sun/star/beans/XMaterialHolder.hpp>
#include <cppuhelper/implbase.hxx>
-#include <o3tl/lru_map.hxx>
#include <sal/log.hxx>
#include <memory>
@@ -55,9 +54,6 @@ using namespace com::sun::star::beans;
static bool lcl_canUsePDFAxialShading(const Gradient& rGradient);
-/// Cache some last 15 bitmaps we've exported, in case we encounter them again..
-static o3tl::lru_map<BitmapChecksum, std::shared_ptr<SvMemoryStream>> lcl_PDFBmpCache(15);
-
void PDFWriterImpl::implWriteGradient( const tools::PolyPolygon& i_rPolyPoly, const Gradient& i_rGradient,
VirtualDevice* i_pDummyVDev, const vcl::PDFWriter::PlayMetafileContext& i_rContext )
{
@@ -182,9 +178,9 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
// from trying conversion & stores before...
if ( !aBitmapEx.IsTransparent() )
{
- const auto& rCacheEntry=lcl_PDFBmpCache.find(
+ const auto& rCacheEntry=m_aPDFBmpCache.find(
aBitmapEx.GetChecksum());
- if ( rCacheEntry != lcl_PDFBmpCache.end() )
+ if ( rCacheEntry != m_aPDFBmpCache.end() )
{
m_rOuterFace.DrawJPGBitmap( *rCacheEntry->second, true, aSizePixel,
tools::Rectangle( aPoint, aSize ), aMask, i_Graphic );
@@ -266,7 +262,7 @@ void PDFWriterImpl::implWriteBitmapEx( const Point& i_rPoint, const Size& i_rSiz
if (!aBitmapEx.IsTransparent() && bTrueColorJPG)
{
// Cache last jpeg export
- lcl_PDFBmpCache.insert(
+ m_aPDFBmpCache.insert(
{aBitmapEx.GetChecksum(), pStrm});
}
}
More information about the Libreoffice-commits
mailing list