summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2015-02-21 19:48:33 +0100
committerZolnai Tamás <zolnaitamas2000@gmail.com>2015-02-22 11:59:20 +0100
commitab00ac3e88e0a28d0e38c5968c23014a6a8fb194 (patch)
treec41f00f24704ec0fe48ef87c8440f67662c9fb44
parent282161ff755c52cfc9f4ddf9fb0b139362b19522 (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
-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 42d9a708edb3..7e507506dc62 100644
--- a/include/svtools/grfmgr.hxx
+++ b/include/svtools/grfmgr.hxx
@@ -592,10 +592,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 f5baadb3e3e5..485dfed7f5e4 100644
--- a/svtools/source/graphic/grfcache.cxx
+++ b/svtools/source/graphic/grfcache.cxx
@@ -173,7 +173,6 @@ public:
void TryToSwapIn();
void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
- bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
};
@@ -371,19 +370,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 )
@@ -987,16 +973,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 e8259e7a54c5..968c31290bbd 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 32ec70728463..de571bf77e59 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,