Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
b737e34d
Kaydet (Commit)
b737e34d
authored
Agu 22, 2011
tarafından
Joseph Powers
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Replace List with std::list< GraphicCacheEntry* >
üst
97499b29
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
40 deletions
+64
-40
grfcache.cxx
svtools/source/graphic/grfcache.cxx
+61
-39
grfcache.hxx
svtools/source/graphic/grfcache.hxx
+3
-1
No files found.
svtools/source/graphic/grfcache.cxx
Dosyayı görüntüle @
b737e34d
...
@@ -577,41 +577,54 @@ GraphicCache::GraphicCache( GraphicManager& rMgr, sal_uLong nDisplayCacheSize, s
...
@@ -577,41 +577,54 @@ GraphicCache::GraphicCache( GraphicManager& rMgr, sal_uLong nDisplayCacheSize, s
GraphicCache
::~
GraphicCache
()
GraphicCache
::~
GraphicCache
()
{
{
DBG_ASSERT
(
!
maGraphicCache
.
Count
(),
"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
.
Count
(),
"GraphicCache::~GraphicCache(): there are some GraphicObjects in display cache"
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
GraphicCache
::
AddGraphicObject
(
const
GraphicObject
&
rObj
,
Graphic
&
rSubstitute
,
void
GraphicCache
::
AddGraphicObject
(
const
ByteString
*
pID
,
const
GraphicObject
*
pCopyObj
)
const
GraphicObject
&
rObj
,
Graphic
&
rSubstitute
,
const
ByteString
*
pID
,
const
GraphicObject
*
pCopyObj
)
{
{
sal_Bool
bInserted
=
sal_False
;
sal_Bool
bInserted
=
sal_False
;
if
(
!
rObj
.
IsSwappedOut
()
&&
if
(
!
rObj
.
IsSwappedOut
()
(
pID
||
(
pCopyObj
&&
(
pCopyObj
->
GetType
()
!=
GRAPHIC_NONE
)
)
||
(
rObj
.
GetType
()
!=
GRAPHIC_NONE
)
)
)
&&
(
pID
||
(
pCopyObj
&&
(
pCopyObj
->
GetType
()
!=
GRAPHIC_NONE
)
)
||
(
rObj
.
GetType
()
!=
GRAPHIC_NONE
)
)
)
{
{
if
(
pCopyObj
)
if
(
pCopyObj
&&
!
maGraphicCache
.
empty
()
)
{
{
GraphicCacheEntry
*
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
First
()
);
GraphicCacheEntryList
::
iterator
it
=
maGraphicCache
.
begin
();
while
(
!
bInserted
while
(
!
bInserted
&&
pEntry
)
&&
(
it
!=
maGraphicCache
.
end
()
)
)
{
{
if
(
pEntry
->
HasGraphicObjectReference
(
*
pCopyObj
)
)
if
(
(
*
it
)
->
HasGraphicObjectReference
(
*
pCopyObj
)
)
{
{
pEntry
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
(
*
it
)
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
bInserted
=
sal_True
;
bInserted
=
sal_True
;
}
}
else
else
{
{
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
Next
()
)
;
++
it
;
}
}
}
}
}
}
if
(
!
bInserted
)
if
(
!
bInserted
)
{
{
GraphicCacheEntry
*
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
First
()
);
GraphicCacheEntry
List
::
iterator
it
=
maGraphicCache
.
begin
(
);
::
std
::
auto_ptr
<
GraphicID
>
apID
;
::
std
::
auto_ptr
<
GraphicID
>
apID
;
if
(
!
pID
)
if
(
!
pID
)
...
@@ -619,35 +632,38 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
...
@@ -619,35 +632,38 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
apID
.
reset
(
new
GraphicID
(
rObj
)
);
apID
.
reset
(
new
GraphicID
(
rObj
)
);
}
}
while
(
!
bInserted
&&
pEntry
)
while
(
!
bInserted
&&
(
it
!=
maGraphicCache
.
end
()
)
)
{
{
const
GraphicID
&
rEntryID
=
pEntry
->
GetID
();
const
GraphicID
&
rEntryID
=
(
*
it
)
->
GetID
();
if
(
pID
)
if
(
pID
)
{
{
if
(
rEntryID
.
GetIDString
()
==
*
pID
)
if
(
rEntryID
.
GetIDString
()
==
*
pID
)
{
{
pEntry
->
TryToSwapIn
();
(
*
it
)
->
TryToSwapIn
();
// since pEntry->TryToSwapIn can modify our current list, we have to
// since pEntry->TryToSwapIn can modify our current list, we have to
// iterate from beginning to add a reference to the appropriate
// iterate from beginning to add a reference to the appropriate
// CacheEntry object; after this, quickly jump out of the outer iteration
// CacheEntry object; after this, quickly jump out of the outer iteration
for
(
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
First
()
);
for
(
GraphicCacheEntryList
::
iterator
jt
=
maGraphicCache
.
begin
();
!
bInserted
&&
pEntry
;
!
bInserted
&&
jt
!=
maGraphicCache
.
end
();
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
Next
()
)
)
++
jt
)
{
{
const
GraphicID
&
rID
=
pEntry
->
GetID
();
const
GraphicID
&
rID
=
(
*
jt
)
->
GetID
();
if
(
rID
.
GetIDString
()
==
*
pID
)
if
(
rID
.
GetIDString
()
==
*
pID
)
{
{
pEntry
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
(
*
jt
)
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
bInserted
=
sal_True
;
bInserted
=
sal_True
;
}
}
}
}
if
(
!
bInserted
)
if
(
!
bInserted
)
{
{
maGraphicCache
.
Insert
(
new
GraphicCacheEntry
(
rObj
),
LIST_APPEND
);
maGraphicCache
.
push_back
(
new
GraphicCacheEntry
(
rObj
)
);
bInserted
=
sal_True
;
bInserted
=
sal_True
;
}
}
}
}
...
@@ -656,19 +672,19 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
...
@@ -656,19 +672,19 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
{
{
if
(
rEntryID
==
*
apID
)
if
(
rEntryID
==
*
apID
)
{
{
pEntry
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
(
*
it
)
->
AddGraphicObjectReference
(
rObj
,
rSubstitute
);
bInserted
=
sal_True
;
bInserted
=
sal_True
;
}
}
}
}
if
(
!
bInserted
)
if
(
!
bInserted
)
pEntry
=
static_cast
<
GraphicCacheEntry
*
>
(
maGraphicCache
.
Next
()
)
;
++
it
;
}
}
}
}
}
}
if
(
!
bInserted
)
if
(
!
bInserted
)
maGraphicCache
.
Insert
(
new
GraphicCacheEntry
(
rObj
),
LIST_APPEND
);
maGraphicCache
.
push_back
(
new
GraphicCacheEntry
(
rObj
)
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -676,16 +692,18 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
...
@@ -676,16 +692,18 @@ void GraphicCache::AddGraphicObject( const GraphicObject& rObj, Graphic& rSubsti
void
GraphicCache
::
ReleaseGraphicObject
(
const
GraphicObject
&
rObj
)
void
GraphicCache
::
ReleaseGraphicObject
(
const
GraphicObject
&
rObj
)
{
{
// Release cached object
// Release cached object
GraphicCacheEntry
*
pEntry
=
(
GraphicCacheEntry
*
)
maGraphicCache
.
First
();
bool
bRemoved
=
false
;
bool
bRemoved
=
false
;
while
(
!
bRemoved
&&
pEntry
)
for
(
{
GraphicCacheEntryList
::
iterator
it
=
maGraphicCache
.
begin
();
bRemoved
=
pEntry
->
ReleaseGraphicObjectReference
(
rObj
);
!
bRemoved
&&
it
!=
maGraphicCache
.
end
();
++
it
)
{
bRemoved
=
(
*
it
)
->
ReleaseGraphicObjectReference
(
rObj
);
if
(
bRemoved
)
if
(
bRemoved
)
{
{
if
(
0
==
pEntry
->
GetGraphicObjectReferenceCount
()
)
if
(
0
==
(
*
it
)
->
GetGraphicObjectReferenceCount
()
)
{
{
// 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
...
@@ -693,7 +711,7 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
...
@@ -693,7 +711,7 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
while
(
pDisplayEntry
)
while
(
pDisplayEntry
)
{
{
if
(
pDisplayEntry
->
GetReferencedCacheEntry
()
==
pEntry
)
if
(
pDisplayEntry
->
GetReferencedCacheEntry
()
==
*
it
)
{
{
mnUsedDisplaySize
-=
pDisplayEntry
->
GetCacheSize
();
mnUsedDisplaySize
-=
pDisplayEntry
->
GetCacheSize
();
maDisplayCache
.
Remove
(
pDisplayEntry
);
maDisplayCache
.
Remove
(
pDisplayEntry
);
...
@@ -705,12 +723,10 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
...
@@ -705,12 +723,10 @@ void GraphicCache::ReleaseGraphicObject( const GraphicObject& rObj )
}
}
// delete graphic cache entry
// delete graphic cache entry
maGraphicCache
.
Remove
(
(
void
*
)
pEntry
)
;
delete
*
it
;
delete
pEntry
;
it
=
maGraphicCache
.
erase
(
it
)
;
}
}
}
}
else
pEntry
=
(
GraphicCacheEntry
*
)
maGraphicCache
.
Next
();
}
}
DBG_ASSERT
(
bRemoved
,
"GraphicCache::ReleaseGraphicObject(...): GraphicObject not found in cache"
);
DBG_ASSERT
(
bRemoved
,
"GraphicCache::ReleaseGraphicObject(...): GraphicObject not found in cache"
);
...
@@ -1013,9 +1029,15 @@ GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const GraphicObject& rObj )
...
@@ -1013,9 +1029,15 @@ GraphicCacheEntry* GraphicCache::ImplGetCacheEntry( const GraphicObject& rObj )
{
{
GraphicCacheEntry
*
pRet
=
NULL
;
GraphicCacheEntry
*
pRet
=
NULL
;
for
(
void
*
pObj
=
maGraphicCache
.
First
();
!
pRet
&&
pObj
;
pObj
=
maGraphicCache
.
Next
()
)
for
(
if
(
(
(
GraphicCacheEntry
*
)
pObj
)
->
HasGraphicObjectReference
(
rObj
)
)
GraphicCacheEntryList
::
iterator
it
=
maGraphicCache
.
begin
();
pRet
=
(
GraphicCacheEntry
*
)
pObj
;
!
pRet
&&
it
!=
maGraphicCache
.
end
();
++
it
)
{
if
(
(
*
it
)
->
HasGraphicObjectReference
(
rObj
)
)
{
pRet
=
*
it
;
}
}
return
pRet
;
return
pRet
;
}
}
...
...
svtools/source/graphic/grfcache.hxx
Dosyayı görüntüle @
b737e34d
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
#include <vcl/graph.hxx>
#include <vcl/graph.hxx>
#include <vcl/timer.hxx>
#include <vcl/timer.hxx>
#include <svtools/grfmgr.hxx>
#include <svtools/grfmgr.hxx>
#include <list>
// -----------------------
// -----------------------
// - GraphicManagerCache -
// - GraphicManagerCache -
...
@@ -42,10 +43,11 @@ class GraphicCacheEntry;
...
@@ -42,10 +43,11 @@ class GraphicCacheEntry;
class
GraphicCache
class
GraphicCache
{
{
private
:
private
:
typedef
std
::
list
<
GraphicCacheEntry
*
>
GraphicCacheEntryList
;
GraphicManager
&
mrMgr
;
GraphicManager
&
mrMgr
;
Timer
maReleaseTimer
;
Timer
maReleaseTimer
;
List
maGraphicCache
;
GraphicCacheEntryList
maGraphicCache
;
List
maDisplayCache
;
List
maDisplayCache
;
sal_uLong
mnReleaseTimeoutSeconds
;
sal_uLong
mnReleaseTimeoutSeconds
;
sal_uLong
mnMaxDisplaySize
;
sal_uLong
mnMaxDisplaySize
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment