summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-11-26 12:38:47 +0900
committerAndras Timar <andras.timar@collabora.com>2021-04-09 12:57:13 +0200
commitcb0f00e14c76a820e796732275cd3863c393b21e (patch)
treee6af7166164b7efd80a1fb09d0515a29a6ccdc56
parentf84c63d9727f620d31a2a1cc65df3b60b3c2cad0 (diff)
pdf: workaround to disable swapping of PDF graphic files
This is needed so that swapping doesn't create excesive amount of swap files, where each includes the original PDF file, which would take a lot of temp disk space. This happens because each graphic object swaps out the original PDF and we create one graphic object per page. In a problematic PDF this means it took 20MB (PDF file) * 700 (pages) ~ 14 GB ob disk space. Change-Id: Id5f720946ce6b3f5aca92bc6d1af388fe8dbcc64 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106651 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx10
-rw-r--r--vcl/source/gdi/impgraph.cxx7
-rw-r--r--vcl/source/graphic/Manager.cxx9
3 files changed, 22 insertions, 4 deletions
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 50ff4a133f86..e6c114bf28f3 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -455,12 +455,14 @@ void GraphicTest::testSwappingPageNumber()
CPPUNIT_ASSERT_EQUAL(false, aGraphic.ImplGetImpGraphic()->isSwappedOut());
// Swapping out
- CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->swapOut());
- CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->isSwappedOut());
- CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ // Following checks were commented out because of the PDF swap issues
+ // with PDF graphic where a lot of swap files were created.
+ //CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->swapOut());
+ //CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->isSwappedOut());
+ //CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
// Let's swap in
- CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+ //CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.makeAvailable());
CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
CPPUNIT_ASSERT_EQUAL(false, aGraphic.ImplGetImpGraphic()->isSwappedOut());
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 1d3e25418b5f..6b232d672c40 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1370,6 +1370,13 @@ bool ImpGraphic::swapOutContent(SvStream& rOStm)
bool ImpGraphic::swapOut()
{
+ // Hack / Workaround - ignore swap out PDF files
+ if (maVectorGraphicData &&
+ maVectorGraphicData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ {
+ return false;
+ }
+
if (isSwappedOut())
return false;
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index 88e1f6e622df..6bbe3b5e7c7d 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -112,6 +112,15 @@ sal_Int64 Manager::getGraphicSizeBytes(const ImpGraphic* pImpGraphic)
{
if (!pImpGraphic->isAvailable())
return 0;
+
+ // Hack / Workaround - don't count PDF vector graphic to preven swapping
+ if (pImpGraphic->getVectorGraphicData()
+ && pImpGraphic->getVectorGraphicData()->getVectorGraphicDataType()
+ == VectorGraphicDataType::Pdf)
+ {
+ return 0;
+ }
+
return pImpGraphic->ImplGetSizeBytes();
}