[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - include/svtools svtools/source

Zolnai Tamás zolnaitamas2000 at gmail.com
Mon Mar 2 08:13:20 PST 2015


 include/svtools/grfmgr.hxx          |    4 ----
 svtools/source/graphic/grfcache.cxx |   24 ------------------------
 svtools/source/graphic/grfcache.hxx |    1 -
 svtools/source/graphic/grfmgr.cxx   |    7 -------
 svtools/source/graphic/grfmgr2.cxx  |   18 ++++++++----------
 5 files changed, 8 insertions(+), 46 deletions(-)

New commits:
commit c31c3ea7afcb7dbe711c338ecceb072eadcc1012
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Sat Feb 21 19:48:33 2015 +0100

    More improvements of graphic cache size handling
    
    * ImplFillSwappedGraphicObject method is part of
    the old caching mechanism which interferes with
    the newer one, so remove this method.
    * Use Graphic size directly becuase in some case
    it does not match with the GraphicObject's
    size.
    * Assertions to avoid underflow of mnUsedSize
    
    Change-Id: I3381f49ca05e3e5d565848c8af24c78e7b9ac3af
    (cherry picked from commit ab00ac3e88e0a28d0e38c5968c23014a6a8fb194)
    Reviewed-on: https://gerrit.libreoffice.org/14699
    Tested-by: Michael Stahl <mstahl at redhat.com>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 234ec9a..7c6f419 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -593,10 +593,6 @@ private:
 
                     // Only used in swap case by GraphicObject
     void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj );
-    bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject(
-                            const GraphicObject& rObj,
-                            Graphic& rSubstitute
-                        );
     void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj );
 
     OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const;
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx
index ca4347e..571d837 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -174,7 +174,6 @@ public:
 
     void                TryToSwapIn();
     void                GraphicObjectWasSwappedOut( const GraphicObject& rObj );
-    bool                FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
     void                GraphicObjectWasSwappedIn( const GraphicObject& rObj );
 };
 
@@ -375,19 +374,6 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( const GraphicObject& /*rObj*
     }
 }
 
-bool GraphicCacheEntry::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
-{
-    bool bRet = false;
-
-    if( !mbSwappedAll && rObj.IsSwappedOut() )
-    {
-        ImplFillSubstitute( rSubstitute );
-        bRet = true;
-    }
-
-    return bRet;
-}
-
 void GraphicCacheEntry::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
 {
     if( mbSwappedAll )
@@ -991,16 +977,6 @@ void GraphicCache::GraphicObjectWasSwappedOut( const GraphicObject& rObj )
         pEntry->GraphicObjectWasSwappedOut( rObj );
 }
 
-bool GraphicCache::FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
-{
-    GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
-
-    if( !pEntry )
-        return false;
-
-    return pEntry->FillSwappedGraphicObject( rObj, rSubstitute );
-}
-
 void GraphicCache::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
 {
     GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
diff --git a/svtools/source/graphic/grfcache.hxx b/svtools/source/graphic/grfcache.hxx
index ddb6f6b..a1c990c 100644
--- a/svtools/source/graphic/grfcache.hxx
+++ b/svtools/source/graphic/grfcache.hxx
@@ -74,7 +74,6 @@ public:
     void                    ReleaseGraphicObject( const GraphicObject& rObj );
 
     void                    GraphicObjectWasSwappedOut( const GraphicObject& rObj );
-    bool                FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
     void                    GraphicObjectWasSwappedIn( const GraphicObject& rObj );
 
     OString            GetUniqueID( const GraphicObject& rObj ) const;
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx
index ec3c59b..ef23607 100644
--- a/svtools/source/graphic/grfmgr.cxx
+++ b/svtools/source/graphic/grfmgr.cxx
@@ -210,9 +210,6 @@ void GraphicObject::ImplAutoSwapIn()
 {
     if( IsSwappedOut() )
     {
-        if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
-            mbAutoSwapped = false;
-        else
         {
             mbIsInSwapIn = true;
 
@@ -1037,10 +1034,6 @@ bool GraphicObject::SwapIn()
         ImplAutoSwapIn();
         bRet = true;
     }
-    else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
-    {
-        bRet = true;
-    }
     else
     {
         bRet = maGraphic.SwapIn();
diff --git a/svtools/source/graphic/grfmgr2.cxx b/svtools/source/graphic/grfmgr2.cxx
index 3aabb52..0c4e17b 100644
--- a/svtools/source/graphic/grfmgr2.cxx
+++ b/svtools/source/graphic/grfmgr2.cxx
@@ -157,19 +157,21 @@ void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubst
     maObjList.push_back( (GraphicObject*)&rObj );
     mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj );
     if( !rObj.IsSwappedOut() )
-        mnUsedSize += rObj.GetSizeBytes();
+        mnUsedSize += rObj.maGraphic.GetSizeBytes();
 }
 
 void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
 {
     mpCache->ReleaseGraphicObject( rObj );
+    if( !rObj.IsSwappedOut() )
+    {
+        assert(mnUsedSize >= rObj.maGraphic.GetSizeBytes());
+        mnUsedSize -= rObj.maGraphic.GetSizeBytes();
+    }
     for( GraphicObjectList_impl::iterator it = maObjList.begin(); it != maObjList.end(); ++it )
     {
         if ( *it == &rObj ) {
             maObjList.erase( it );
-
-            if( !rObj.IsSwappedOut() )
-                mnUsedSize -= rObj.GetSizeBytes();
             return;
         }
     }
@@ -179,6 +181,7 @@ void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
 void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj )
 {
     mpCache->GraphicObjectWasSwappedOut( rObj );
+    assert(mnUsedSize >= rObj.GetSizeBytes());
     mnUsedSize -= rObj.GetSizeBytes();
 }
 
@@ -236,15 +239,10 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGrap
     }
 }
 
-bool GraphicManager::ImplFillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute )
-{
-    return mpCache->FillSwappedGraphicObject(rObj, rSubstitute);
-}
-
 void GraphicManager::ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj )
 {
     mpCache->GraphicObjectWasSwappedIn( rObj );
-    mnUsedSize += rObj.GetSizeBytes();
+    mnUsedSize += rObj.maGraphic.GetSizeBytes();
 }
 
 bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,


More information about the Libreoffice-commits mailing list