summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2015-02-21 19:48:33 +0100
committerMichael Stahl <mstahl@redhat.com>2015-03-02 16:12:50 +0000
commitc31c3ea7afcb7dbe711c338ecceb072eadcc1012 (patch)
tree81617f4a156b5453c605fc861331c369658ad907
parentbf4150f1c5211c6ceb8221cb020beba2bd796d5d (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>
-rw-r--r--include/svtools/grfmgr.hxx4
-rw-r--r--svtools/source/graphic/grfcache.cxx24
-rw-r--r--svtools/source/graphic/grfcache.hxx1
-rw-r--r--svtools/source/graphic/grfmgr.cxx7
-rw-r--r--svtools/source/graphic/grfmgr2.cxx18
5 files changed, 8 insertions, 46 deletions
diff --git a/include/svtools/grfmgr.hxx b/include/svtools/grfmgr.hxx
index 234ec9a844e0..7c6f419e913d 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 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,