vcl/qa/cppunit/GraphicTest.cxx |   10 ++++++----
 vcl/source/gdi/impgraph.cxx    |    7 +++++++
 vcl/source/graphic/Manager.cxx |    9 +++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit cb0f00e14c76a820e796732275cd3863c393b21e
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Nov 26 12:38:47 2020 +0900
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Fri Apr 9 12:57:13 2021 +0200

    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 <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

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();
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to