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>2020-11-26 10:33:59 +0100
commite2dfc4e3d1c5913c8686f2c80f78514b0eb37a03 (patch)
treef852b5243f4abc0d0de33b29efca756c9de3672b
parent26a79bc2dd2666c718a1ee09373f636fc5116009 (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 a2629902241f..98533c972f15 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -438,12 +438,14 @@ void GraphicTest::testSwappingPageNumber()
CPPUNIT_ASSERT_EQUAL(false, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
// Swapping out
- CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->ImplSwapOut());
- CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
- 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()->ImplSwapOut());
+ //CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->ImplIsSwapOut());
+ //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()->ImplIsSwapOut());
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index dc0122de050d..de3cbefc4d79 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1349,6 +1349,13 @@ bool ImpGraphic::ImplSwapOut()
{
bool bRet = false;
+ // Hack / Workaround - ignore swap out PDF files
+ if (maVectorGraphicData &&
+ maVectorGraphicData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+ {
+ return false;
+ }
+
if( !ImplIsSwapOut() )
{
::utl::TempFile aTempFile;
diff --git a/vcl/source/graphic/Manager.cxx b/vcl/source/graphic/Manager.cxx
index 5942b5cb8784..1be52a7e987c 100644
--- a/vcl/source/graphic/Manager.cxx
+++ b/vcl/source/graphic/Manager.cxx
@@ -109,6 +109,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();
}