[Libreoffice-commits] core.git: vcl/source

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Thu Jan 7 15:32:50 UTC 2021


 vcl/source/gdi/impgraph.cxx |   72 ++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 32 deletions(-)

New commits:
commit 4d682d5b9343c5d18ee6fc52e20a57644c050603
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Jan 5 16:43:04 2021 +0100
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Thu Jan 7 16:28:30 2021 +0100

    handle also !mbPrepared Graphic correctly when parallel loading
    
    GraphicFilter::MakeGraphicsAvailableThreaded() can cause loading
    of swapped out Graphic objects too (since def31e135e5e2c0adb1502?).
    So make sure those are processed the same way as they would be
    when swapped in.
    
    Change-Id: Ibc8eb34b2167e2e21ea2c0c5ce9da14b75f3b6f3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108814
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 02709008d31f..6a76e2f9f81f 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1350,17 +1350,45 @@ bool ImpGraphic::ensureAvailable() const
 
 void ImpGraphic::updateFromLoadedGraphic(ImpGraphic* graphic)
 {
-    GraphicExternalLink aLink = maGraphicExternalLink;
-    Size aPrefSize = maSwapInfo.maPrefSize;
-    MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
-    *this = *graphic;
-    if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == ImplGetPrefMapMode())
+    if( mbPrepared )
     {
-        // Use custom preferred size if it was set when the graphic was still unloaded.
-        // Only set the size in case the unloaded and loaded unit matches.
-        ImplSetPrefSize(aPrefSize);
+        GraphicExternalLink aLink = maGraphicExternalLink;
+        Size aPrefSize = maSwapInfo.maPrefSize;
+        MapMode aPrefMapMode = maSwapInfo.maPrefMapMode;
+        *this = *graphic;
+        if (aPrefSize.getWidth() && aPrefSize.getHeight() && aPrefMapMode == ImplGetPrefMapMode())
+        {
+            // Use custom preferred size if it was set when the graphic was still unloaded.
+            // Only set the size in case the unloaded and loaded unit matches.
+            ImplSetPrefSize(aPrefSize);
+        }
+        maGraphicExternalLink = aLink;
+    }
+    else
+    {
+        // Move over only graphic content
+        mpAnimation.reset();
+        if (graphic->mpAnimation)
+        {
+            mpAnimation = std::make_unique<Animation>(*graphic->mpAnimation);
+            maBitmapEx = mpAnimation->GetBitmapEx();
+        }
+        else
+        {
+            maBitmapEx = graphic->maBitmapEx;
+        }
+
+        maMetaFile = graphic->maMetaFile;
+        maVectorGraphicData = graphic->maVectorGraphicData;
+
+        // Set to 0, to force recalculation
+        mnSizeBytes = 0;
+        mnChecksum = 0;
+
+        restoreFromSwapInfo();
+
+        mbSwapOut = false;
     }
-    maGraphicExternalLink = aLink;
 }
 
 void ImpGraphic::restoreFromSwapInfo()
@@ -1398,34 +1426,14 @@ bool ImpGraphic::swapIn()
         if (!mpGfxLink->LoadNative(aGraphic))
             return false;
 
-        auto & rImpGraphic = *aGraphic.ImplGetImpGraphic();
+        ImpGraphic* pImpGraphic = aGraphic.ImplGetImpGraphic();
 
-        if (meType != rImpGraphic.meType)
+        if (meType != pImpGraphic->meType)
             return false;
 
-        // Move over only graphic content
-        mpAnimation.reset();
-        if (rImpGraphic.mpAnimation)
-        {
-            mpAnimation = std::make_unique<Animation>(*rImpGraphic.mpAnimation);
-            maBitmapEx = mpAnimation->GetBitmapEx();
-        }
-        else
-        {
-            maBitmapEx = rImpGraphic.maBitmapEx;
-        }
-
-        maMetaFile = rImpGraphic.maMetaFile;
-        maVectorGraphicData = rImpGraphic.maVectorGraphicData;
-
-        // Set to 0, to force recalculation
-        mnSizeBytes = 0;
-        mnChecksum = 0;
-
-        restoreFromSwapInfo();
+        updateFromLoadedGraphic(pImpGraphic);
 
         maLastUsed = std::chrono::high_resolution_clock::now();
-        mbSwapOut = false;
         bReturn = true;
     }
     else


More information about the Libreoffice-commits mailing list