namespace sd::slidesorter::cache
{ class CacheCompactor; class BitmapCompressor;
/** This low level cache is the actual bitmap container. It supports a preciousflagforeverypreviewbitmapandkeepstrackoftotalsizes forallpreviewswith/withoutthisflag.Thepreciousflagisusedby compactionalgorithmstodeterminewhichpreviewsmaybecompressedor evendiscardedandwhichhavetoremainintheiroriginalform.The preciousflagisusuallysetforthevisiblepreviews.
Additionallytotheactualpreviewthereisanoptionalmarkedpreview. Thisisusedforslidesexcludedfromtheslideshowwhichhaveapreview thatshowsamark(somesortofbitmapoverlay)tothateffect.
*/ class BitmapCache
{ public: /** The key for looking up preview bitmaps is a pointer to an SdrPage object.TheprioruseofPageObjectViewObjectContactobjects(which ultimatelyusethem)turnedouttobelesssuitablebecausetheir lifetimeisshorterthenthatofthepageobjects.Frequent destructionandre-creationofthepreviewbitmapswastheresult.
*/ typedefconst SdrPage* CacheKey; class CacheEntry; class CacheBitmapContainer; typedef ::std::vector<CacheKey> CacheIndex;
/** Create a new cache for bitmap objects. Thedefaultvaluefromtheconfigurationisused. Whenthatdoesnotexistthenaninternaldefaultvalueis used.
*/ explicit BitmapCache();
/** The destructor clears the cache and releases all bitmaps still in it.
*/
~BitmapCache();
/** Remove all preview bitmaps from the cache. After this call the cacheisempty.
*/ void Clear();
/** Return <TRUE/> when the cache is full, i.e. the cache compactor had toberun.
*/ bool IsFull() const { return mbIsFull; }
/** Return the memory size that is occupied by all non-precious bitmaps inthecache.
*/
sal_Int32 GetSize() const { return mnNormalCacheSize; }
/** Return <TRUE/> when a preview bitmap exists for the given key.
*/ bool HasBitmap(const CacheKey& rKey);
/** Return <TRUE/> when a preview bitmap exists for the given key and whenitisup-to-date.
*/ bool BitmapIsUpToDate(const CacheKey& rKey);
/** Return the preview bitmap for the given contact object.
*/
BitmapEx GetBitmap(const CacheKey& rKey);
/** Return the marked preview bitmap for the given contact object.
*/
BitmapEx GetMarkedBitmap(const CacheKey& rKey);
/** Release the reference to the preview bitmap that is associated with thegivenkey.
*/ void ReleaseBitmap(const CacheKey& rKey);
/** Mark the specified preview bitmap as not being up-to-date anymore. @return Whenthekeyreferencesapageinthecachethen return<TRUE/>.Whenthekeyisnotknownthen<FALSE/> isreturned.
*/ bool InvalidateBitmap(const CacheKey& rKey);
/** Mark all preview bitmaps as not being up-to-date anymore.
*/ void InvalidateCache();
/** Add or replace a bitmap for the given key.
*/ void SetBitmap(const CacheKey& rKey, const BitmapEx& rPreview, bool bIsPrecious);
/** Add or replace a marked bitmap for the given key.
*/ void SetMarkedBitmap(const CacheKey& rKey, const BitmapEx& rPreview);
/** Mark the specified preview bitmap as precious, i.e. that it must not becompressedorotherwiseremovedfromthecache.
*/ void SetPrecious(const CacheKey& rKey, bool bIsPrecious);
/** Calculate the cache size. This should rarely be necessary because thecachesizeistrackedwitheachmodificationofpreview bitmaps.
*/ void ReCalculateTotalCacheSize();
/** Use the previews in the given cache to initialize missing previews.
*/ void Recycle(const BitmapCache& rCache);
/** Return a list of sorted cache keys that represent an index into (a partof)thecache.Theentriesoftheindexaresortedaccording tolastaccesstimeswiththeleastrecentlyaccesstimefirst. Entrieswiththepreciousflagsetareomitted. Entrieswiththathavenopreviewbitmapsareomitted.
*/
CacheIndex GetCacheIndex() const;
/** Compress the specified preview bitmap with the given bitmap compressor.Areferencetothecompressorisstoredforlater decompression.
*/ void Compress(const CacheKey& rKey, const std::shared_ptr<BitmapCompressor>& rpCompressor);
/** Total size of bytes that are occupied by bitmaps in the cache for whomtheslidesarecurrentlynotinsidethevisiblearea.
*/
sal_Int32 mnNormalCacheSize;
/** Total size of bytes that are occupied by bitmaps in the cache for whomtheslidesarecurrentlyvisible.
*/
sal_Int32 mnPreciousCacheSize;
/** At the moment the access time is not an actual time or date value butacounterthatisincreasedwitheveryaccess.Itthusdefines thesameorderingasatruetime.
*/
sal_Int32 mnCurrentAccessTime;
/** The maximal cache size for the off-screen preview bitmaps. When mnNormalCacheSizegrowslargerthanthisvaluethenthe mpCacheCompactormemberisusedtoreducethecachesize.
*/
sal_Int32 mnMaximalNormalCacheSize;
/** The cache compactor is used to reduce the number of bytes used by off-screenpreviewbitmaps.
*/
::std::unique_ptr<CacheCompactor> mpCacheCompactor;
/** This flag stores if the cache is or recently was full, i.e. the cachecompactorhasorhadtoberuninordertoreducethecache sizetotheallowedvalue.
*/ bool mbIsFull;
/** Update mnNormalCacheSize or mnPreciousCacheSize according to the preciousflagofthespecifiedpreviewbitmapandthespecified operation.
*/ enum CacheOperation
{
ADD,
REMOVE
}; void UpdateCacheSize(std::unique_lock<std::mutex>& rGuard, const CacheEntry& rKey,
CacheOperation eOperation);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.