diff options
author | Zolnai Tamás <zolnaitamas2000@gmail.com> | 2015-02-21 19:48:33 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-03-02 16:12:50 +0000 |
commit | c31c3ea7afcb7dbe711c338ecceb072eadcc1012 (patch) | |
tree | 81617f4a156b5453c605fc861331c369658ad907 /svtools | |
parent | bf4150f1c5211c6ceb8221cb020beba2bd796d5d (diff) |
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@redhat.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/grfcache.cxx | 24 | ||||
-rw-r--r-- | svtools/source/graphic/grfcache.hxx | 1 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 7 | ||||
-rw-r--r-- | svtools/source/graphic/grfmgr2.cxx | 18 |
4 files changed, 8 insertions, 42 deletions
diff --git a/svtools/source/graphic/grfcache.cxx b/svtools/source/graphic/grfcache.cxx index ca4347e5e6c5..571d837cf767 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 ddb6f6b4eb4c..a1c990c08ea7 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 ec3c59bf0a6b..ef23607340a9 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 3aabb528f3b0..0c4e17b66b30 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, |