Kaydet (Commit) ab00ac3e authored tarafından Zolnai Tamás's avatar Zolnai Tamás

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
üst 282161ff
...@@ -592,10 +592,6 @@ private: ...@@ -592,10 +592,6 @@ private:
// Only used in swap case by GraphicObject // Only used in swap case by GraphicObject
void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj ); void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj );
bool SVT_DLLPRIVATE ImplFillSwappedGraphicObject(
const GraphicObject& rObj,
Graphic& rSubstitute
);
void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj ); void SVT_DLLPRIVATE ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj );
OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const; OString SVT_DLLPRIVATE ImplGetUniqueID( const GraphicObject& rObj ) const;
......
...@@ -173,7 +173,6 @@ public: ...@@ -173,7 +173,6 @@ public:
void TryToSwapIn(); void TryToSwapIn();
void GraphicObjectWasSwappedOut( const GraphicObject& rObj ); void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
void GraphicObjectWasSwappedIn( const GraphicObject& rObj ); void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
}; };
...@@ -371,19 +370,6 @@ void GraphicCacheEntry::GraphicObjectWasSwappedOut( 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 ) void GraphicCacheEntry::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
{ {
if( mbSwappedAll ) if( mbSwappedAll )
...@@ -987,16 +973,6 @@ void GraphicCache::GraphicObjectWasSwappedOut( const GraphicObject& rObj ) ...@@ -987,16 +973,6 @@ void GraphicCache::GraphicObjectWasSwappedOut( const GraphicObject& rObj )
pEntry->GraphicObjectWasSwappedOut( 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 ) void GraphicCache::GraphicObjectWasSwappedIn( const GraphicObject& rObj )
{ {
GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj ); GraphicCacheEntry* pEntry = ImplGetCacheEntry( rObj );
......
...@@ -74,7 +74,6 @@ public: ...@@ -74,7 +74,6 @@ public:
void ReleaseGraphicObject( const GraphicObject& rObj ); void ReleaseGraphicObject( const GraphicObject& rObj );
void GraphicObjectWasSwappedOut( const GraphicObject& rObj ); void GraphicObjectWasSwappedOut( const GraphicObject& rObj );
bool FillSwappedGraphicObject( const GraphicObject& rObj, Graphic& rSubstitute );
void GraphicObjectWasSwappedIn( const GraphicObject& rObj ); void GraphicObjectWasSwappedIn( const GraphicObject& rObj );
OString GetUniqueID( const GraphicObject& rObj ) const; OString GetUniqueID( const GraphicObject& rObj ) const;
......
...@@ -210,9 +210,6 @@ void GraphicObject::ImplAutoSwapIn() ...@@ -210,9 +210,6 @@ void GraphicObject::ImplAutoSwapIn()
{ {
if( IsSwappedOut() ) if( IsSwappedOut() )
{ {
if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
mbAutoSwapped = false;
else
{ {
mbIsInSwapIn = true; mbIsInSwapIn = true;
...@@ -1037,10 +1034,6 @@ bool GraphicObject::SwapIn() ...@@ -1037,10 +1034,6 @@ bool GraphicObject::SwapIn()
ImplAutoSwapIn(); ImplAutoSwapIn();
bRet = true; bRet = true;
} }
else if( mpMgr && mpMgr->ImplFillSwappedGraphicObject( *this, maGraphic ) )
{
bRet = true;
}
else else
{ {
bRet = maGraphic.SwapIn(); bRet = maGraphic.SwapIn();
......
...@@ -157,19 +157,21 @@ void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubst ...@@ -157,19 +157,21 @@ void GraphicManager::ImplRegisterObj( const GraphicObject& rObj, Graphic& rSubst
maObjList.push_back( (GraphicObject*)&rObj ); maObjList.push_back( (GraphicObject*)&rObj );
mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj ); mpCache->AddGraphicObject( rObj, rSubstitute, pID, pCopyObj );
if( !rObj.IsSwappedOut() ) if( !rObj.IsSwappedOut() )
mnUsedSize += rObj.GetSizeBytes(); mnUsedSize += rObj.maGraphic.GetSizeBytes();
} }
void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj ) void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
{ {
mpCache->ReleaseGraphicObject( 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 ) for( GraphicObjectList_impl::iterator it = maObjList.begin(); it != maObjList.end(); ++it )
{ {
if ( *it == &rObj ) { if ( *it == &rObj ) {
maObjList.erase( it ); maObjList.erase( it );
if( !rObj.IsSwappedOut() )
mnUsedSize -= rObj.GetSizeBytes();
return; return;
} }
} }
...@@ -179,6 +181,7 @@ void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj ) ...@@ -179,6 +181,7 @@ void GraphicManager::ImplUnregisterObj( const GraphicObject& rObj )
void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj ) void GraphicManager::ImplGraphicObjectWasSwappedOut( const GraphicObject& rObj )
{ {
mpCache->GraphicObjectWasSwappedOut( rObj ); mpCache->GraphicObjectWasSwappedOut( rObj );
assert(mnUsedSize >= rObj.GetSizeBytes());
mnUsedSize -= rObj.GetSizeBytes(); mnUsedSize -= rObj.GetSizeBytes();
} }
...@@ -236,15 +239,10 @@ void GraphicManager::ImplCheckSizeOfSwappedInGraphics(const GraphicObject* pGrap ...@@ -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 ) void GraphicManager::ImplGraphicObjectWasSwappedIn( const GraphicObject& rObj )
{ {
mpCache->GraphicObjectWasSwappedIn( rObj ); mpCache->GraphicObjectWasSwappedIn( rObj );
mnUsedSize += rObj.GetSizeBytes(); mnUsedSize += rObj.maGraphic.GetSizeBytes();
} }
bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt, bool GraphicManager::ImplDraw( OutputDevice* pOut, const Point& rPt,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment