Kaydet (Commit) daccbc1e authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Tor Lillqvist

Convert from tools/list.hxx to std::list in GraphicCache

Change-Id: I020a2e9ef8485549d0c66798c8b651641319e17a
üst 016918cf
...@@ -867,7 +867,7 @@ GraphicCache::GraphicCache( GraphicManager& rMgr, sal_uLong nDisplayCacheSize, s ...@@ -867,7 +867,7 @@ GraphicCache::GraphicCache( GraphicManager& rMgr, sal_uLong nDisplayCacheSize, s
GraphicCache::~GraphicCache() GraphicCache::~GraphicCache()
{ {
DBG_ASSERT( !maGraphicCache.size(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in cache" ); DBG_ASSERT( !maGraphicCache.size(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in cache" );
DBG_ASSERT( !maDisplayCache.Count(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in display cache" ); DBG_ASSERT( maDisplayCache.empty(), "GraphicCache::~GraphicCache(): there are some GraphicObjects in display cache" );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -993,19 +993,18 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj ) ...@@ -993,19 +993,18 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
{ {
// if graphic cache entry has no more references, // if graphic cache entry has no more references,
// the corresponding display cache object can be removed // the corresponding display cache object can be removed
GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First(); GraphicDisplayCacheEntryList::iterator it2 = maDisplayCache.begin();
while( it2 != maDisplayCache.end() )
while( pDisplayEntry )
{ {
GraphicDisplayCacheEntry* pDisplayEntry = *it2;
if( pDisplayEntry->GetReferencedCacheEntry() == *it ) if( pDisplayEntry->GetReferencedCacheEntry() == *it )
{ {
mnUsedDisplaySize -= pDisplayEntry->GetCacheSize(); mnUsedDisplaySize -= pDisplayEntry->GetCacheSize();
maDisplayCache.Remove( pDisplayEntry ); it2 = maDisplayCache.erase( it2 );
delete pDisplayEntry; delete pDisplayEntry;
pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.GetCurObject();
} }
else else
pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next(); ++it2;
} }
// delete graphic cache entry // delete graphic cache entry
...@@ -1082,19 +1081,18 @@ void GraphicCache::SetMaxObjDisplayCacheSize( sal_uLong nNewMaxObjSize, sal_Bool ...@@ -1082,19 +1081,18 @@ void GraphicCache::SetMaxObjDisplayCacheSize( sal_uLong nNewMaxObjSize, sal_Bool
if( bDestroy ) if( bDestroy )
{ {
GraphicDisplayCacheEntry* pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.First(); GraphicDisplayCacheEntryList::iterator it = maDisplayCache.begin();
while( it != maDisplayCache.end() )
while( pCacheObj )
{ {
GraphicDisplayCacheEntry* pCacheObj = *it;
if( pCacheObj->GetCacheSize() > mnMaxObjDisplaySize ) if( pCacheObj->GetCacheSize() > mnMaxObjDisplaySize )
{ {
mnUsedDisplaySize -= pCacheObj->GetCacheSize(); mnUsedDisplaySize -= pCacheObj->GetCacheSize();
maDisplayCache.Remove( pCacheObj ); it = maDisplayCache.erase( it );
delete pCacheObj; delete pCacheObj;
pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.GetCurObject();
} }
else else
pCacheObj = (GraphicDisplayCacheEntry*) maDisplayCache.Next(); ++it;
} }
} }
} }
...@@ -1105,7 +1103,6 @@ void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds ) ...@@ -1105,7 +1103,6 @@ void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds )
{ {
if( mnReleaseTimeoutSeconds != nTimeoutSeconds ) if( mnReleaseTimeoutSeconds != nTimeoutSeconds )
{ {
GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First();
::salhelper::TTimeValue aReleaseTime; ::salhelper::TTimeValue aReleaseTime;
if( ( mnReleaseTimeoutSeconds = nTimeoutSeconds ) != 0 ) if( ( mnReleaseTimeoutSeconds = nTimeoutSeconds ) != 0 )
...@@ -1114,10 +1111,10 @@ void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds ) ...@@ -1114,10 +1111,10 @@ void GraphicCache::SetCacheTimeout( sal_uLong nTimeoutSeconds )
aReleaseTime.addTime( ::salhelper::TTimeValue( nTimeoutSeconds, 0 ) ); aReleaseTime.addTime( ::salhelper::TTimeValue( nTimeoutSeconds, 0 ) );
} }
while( pDisplayEntry ) for( GraphicDisplayCacheEntryList::const_iterator it = maDisplayCache.begin();
it != maDisplayCache.end(); ++it )
{ {
pDisplayEntry->SetReleaseTime( aReleaseTime ); (*it)->SetReleaseTime( aReleaseTime );
pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next();
} }
} }
} }
...@@ -1139,14 +1136,16 @@ sal_Bool GraphicCache::IsInDisplayCache( OutputDevice* pOut, const Point& rPt, c ...@@ -1139,14 +1136,16 @@ sal_Bool GraphicCache::IsInDisplayCache( OutputDevice* pOut, const Point& rPt, c
const Point aPtPixel( pOut->LogicToPixel( rPt ) ); const Point aPtPixel( pOut->LogicToPixel( rPt ) );
const Size aSzPixel( pOut->LogicToPixel( rSz ) ); const Size aSzPixel( pOut->LogicToPixel( rSz ) );
const GraphicCacheEntry* pCacheEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj ); const GraphicCacheEntry* pCacheEntry = ( (GraphicCache*) this )->ImplGetCacheEntry( rObj );
//GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) ( (GraphicCache*) this )->maDisplayCache.First(); // -Wall removed ....
sal_Bool bFound = sal_False; sal_Bool bFound = sal_False;
if( pCacheEntry ) if( pCacheEntry )
{ {
for( long i = 0, nCount = maDisplayCache.Count(); !bFound && ( i < nCount ); i++ ) for( GraphicDisplayCacheEntryList::const_iterator it = maDisplayCache.begin();
if( ( (GraphicDisplayCacheEntry*) maDisplayCache.GetObject( i ) )->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) ) !bFound && ( it != maDisplayCache.end() ); ++it )
{
if( (*it)->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) )
bFound = sal_True; bFound = sal_True;
}
} }
return bFound; return bFound;
...@@ -1198,7 +1197,7 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r ...@@ -1198,7 +1197,7 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
pNewEntry->SetReleaseTime( aReleaseTime ); pNewEntry->SetReleaseTime( aReleaseTime );
} }
maDisplayCache.Insert( pNewEntry, LIST_APPEND ); maDisplayCache.push_back( pNewEntry );
mnUsedDisplaySize += pNewEntry->GetCacheSize(); mnUsedDisplaySize += pNewEntry->GetCacheSize();
bRet = sal_True; bRet = sal_True;
} }
...@@ -1232,7 +1231,7 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r ...@@ -1232,7 +1231,7 @@ sal_Bool GraphicCache::CreateDisplayCacheObj( OutputDevice* pOut, const Point& r
pNewEntry->SetReleaseTime( aReleaseTime ); pNewEntry->SetReleaseTime( aReleaseTime );
} }
maDisplayCache.Insert( pNewEntry, LIST_APPEND ); maDisplayCache.push_back( pNewEntry );
mnUsedDisplaySize += pNewEntry->GetCacheSize(); mnUsedDisplaySize += pNewEntry->GetCacheSize();
bRet = sal_True; bRet = sal_True;
} }
...@@ -1248,17 +1247,20 @@ sal_Bool GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt ...@@ -1248,17 +1247,20 @@ sal_Bool GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt
const Point aPtPixel( pOut->LogicToPixel( rPt ) ); const Point aPtPixel( pOut->LogicToPixel( rPt ) );
const Size aSzPixel( pOut->LogicToPixel( rSz ) ); const Size aSzPixel( pOut->LogicToPixel( rSz ) );
const GraphicCacheEntry* pCacheEntry = ImplGetCacheEntry( rObj ); const GraphicCacheEntry* pCacheEntry = ImplGetCacheEntry( rObj );
GraphicDisplayCacheEntry* pDisplayCacheEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First(); GraphicDisplayCacheEntry* pDisplayCacheEntry = NULL;
sal_Bool bRet = sal_False; GraphicDisplayCacheEntryList::iterator it = maDisplayCache.begin();
sal_Bool bRet = sal_False;
while( !bRet && pDisplayCacheEntry ) while( !bRet && it != maDisplayCache.end() )
{ {
pDisplayCacheEntry = *it;
if( pDisplayCacheEntry->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) ) if( pDisplayCacheEntry->Matches( pOut, aPtPixel, aSzPixel, pCacheEntry, rAttr ) )
{ {
::salhelper::TTimeValue aReleaseTime; ::salhelper::TTimeValue aReleaseTime;
// put found object at last used position // put found object at last used position
maDisplayCache.Insert( maDisplayCache.Remove( pDisplayCacheEntry ), LIST_APPEND ); it = maDisplayCache.erase( it );
maDisplayCache.push_back( pDisplayCacheEntry );
if( GetCacheTimeout() ) if( GetCacheTimeout() )
{ {
...@@ -1270,7 +1272,7 @@ sal_Bool GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt ...@@ -1270,7 +1272,7 @@ sal_Bool GraphicCache::DrawDisplayCacheObj( OutputDevice* pOut, const Point& rPt
bRet = sal_True; bRet = sal_True;
} }
else else
pDisplayCacheEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next(); ++it;
} }
if( bRet ) if( bRet )
...@@ -1287,24 +1289,22 @@ sal_Bool GraphicCache::ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree ) ...@@ -1287,24 +1289,22 @@ sal_Bool GraphicCache::ImplFreeDisplayCacheSpace( sal_uLong nSizeToFree )
if( nSizeToFree ) if( nSizeToFree )
{ {
void* pObj = maDisplayCache.First(); GraphicDisplayCacheEntryList::iterator it = maDisplayCache.begin();
if( nSizeToFree > mnUsedDisplaySize ) if( nSizeToFree > mnUsedDisplaySize )
nSizeToFree = mnUsedDisplaySize; nSizeToFree = mnUsedDisplaySize;
while( pObj ) while( it != maDisplayCache.end() )
{ {
GraphicDisplayCacheEntry* pCacheObj = (GraphicDisplayCacheEntry*) pObj; GraphicDisplayCacheEntry* pCacheObj = *it;
nFreedSize += pCacheObj->GetCacheSize(); nFreedSize += pCacheObj->GetCacheSize();
mnUsedDisplaySize -= pCacheObj->GetCacheSize(); mnUsedDisplaySize -= pCacheObj->GetCacheSize();
maDisplayCache.Remove( pObj ); it = maDisplayCache.erase( it );
delete pCacheObj; delete pCacheObj;
if( nFreedSize >= nSizeToFree ) if( nFreedSize >= nSizeToFree )
break; break;
else
pObj = maDisplayCache.GetCurObject();
} }
} }
...@@ -1337,23 +1337,23 @@ IMPL_LINK( GraphicCache, ReleaseTimeoutHdl, Timer*, pTimer ) ...@@ -1337,23 +1337,23 @@ IMPL_LINK( GraphicCache, ReleaseTimeoutHdl, Timer*, pTimer )
pTimer->Stop(); pTimer->Stop();
::salhelper::TTimeValue aCurTime; ::salhelper::TTimeValue aCurTime;
GraphicDisplayCacheEntry* pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.First(); GraphicDisplayCacheEntryList::iterator it = maDisplayCache.begin();
osl_getSystemTime( &aCurTime ); osl_getSystemTime( &aCurTime );
while( pDisplayEntry ) while( it != maDisplayCache.end() )
{ {
GraphicDisplayCacheEntry* pDisplayEntry = *it;
const ::salhelper::TTimeValue& rReleaseTime = pDisplayEntry->GetReleaseTime(); const ::salhelper::TTimeValue& rReleaseTime = pDisplayEntry->GetReleaseTime();
if( !rReleaseTime.isEmpty() && ( rReleaseTime < aCurTime ) ) if( !rReleaseTime.isEmpty() && ( rReleaseTime < aCurTime ) )
{ {
mnUsedDisplaySize -= pDisplayEntry->GetCacheSize(); mnUsedDisplaySize -= pDisplayEntry->GetCacheSize();
maDisplayCache.Remove( pDisplayEntry ); it = maDisplayCache.erase( it );
delete pDisplayEntry; delete pDisplayEntry;
pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.GetCurObject();
} }
else else
pDisplayEntry = (GraphicDisplayCacheEntry*) maDisplayCache.Next(); ++it;
} }
pTimer->Start(); pTimer->Start();
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
#include <tools/list.hxx>
#include <svtools/grfmgr.hxx> #include <svtools/grfmgr.hxx>
#include <list> #include <list>
...@@ -40,16 +39,18 @@ ...@@ -40,16 +39,18 @@
// ----------------------- // -----------------------
class GraphicCacheEntry; class GraphicCacheEntry;
class GraphicDisplayCacheEntry;
class GraphicCache class GraphicCache
{ {
private: private:
typedef std::list< GraphicCacheEntry* > GraphicCacheEntryList; typedef std::list< GraphicCacheEntry* > GraphicCacheEntryList;
typedef std::list< GraphicDisplayCacheEntry* > GraphicDisplayCacheEntryList;
GraphicManager& mrMgr; GraphicManager& mrMgr;
Timer maReleaseTimer; Timer maReleaseTimer;
GraphicCacheEntryList maGraphicCache; GraphicCacheEntryList maGraphicCache;
List maDisplayCache; GraphicDisplayCacheEntryList maDisplayCache;
sal_uLong mnReleaseTimeoutSeconds; sal_uLong mnReleaseTimeoutSeconds;
sal_uLong mnMaxDisplaySize; sal_uLong mnMaxDisplaySize;
sal_uLong mnMaxObjDisplaySize; sal_uLong mnMaxObjDisplaySize;
......
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