LibreOffice Module sd (master) 1
|
Provide and manage the preview bitmap caches for all slide sorter instances. More...
#include <SlsPageCacheManager.hxx>
Classes | |
class | Deleter |
class | PageCacheContainer |
Container for the active caches. More... | |
class | RecentlyUsedPageCaches |
The recently used caches are stored in one queue for each document. More... | |
Public Types | |
typedef std::vector< std::pair< Size, std::shared_ptr< BitmapCache > > > | BestFittingPageCaches |
typedef css::uno::Reference< css::uno::XInterface > | DocumentKey |
Public Member Functions | |
std::shared_ptr< BitmapCache > | GetCache (const DocumentKey &pDocument, const Size &rPreviewSize) |
Look up the cache for the given model in which the previews have the specified size. More... | |
void | ReleaseCache (const std::shared_ptr< BitmapCache > &rpCache) |
Tell the cache manager to release its own reference to the specified cache. More... | |
std::shared_ptr< BitmapCache > | ChangeSize (const std::shared_ptr< BitmapCache > &rpCache, const Size &rOldPreviewSize, const Size &rNewPreviewSize) |
This is an information to the cache manager that the size of preview bitmaps in the specified cache has changed. More... | |
bool | InvalidatePreviewBitmap (const DocumentKey &pDocument, const SdrPage *pPage) |
Invalidate the preview bitmap for one slide that belongs to the specified document. More... | |
void | InvalidateAllPreviewBitmaps (const DocumentKey &pDocument) |
Invalidate the preview bitmaps for all slides that belong to the specified document. More... | |
void | InvalidateAllCaches () |
Invalidate all the caches that are currently in use and destroy those that are not. More... | |
void | ReleasePreviewBitmap (const SdrPage *pPage) |
Call this method when a page has been deleted and its preview is not needed anymore. More... | |
Static Public Member Functions | |
static std::shared_ptr< PageCacheManager > | Instance () |
Return the one instance of the PageCacheManager class. More... | |
Private Member Functions | |
PageCacheManager () | |
~PageCacheManager () | |
std::shared_ptr< BitmapCache > | GetRecentlyUsedCache (const DocumentKey &pDocument, const Size &rSize) |
void | PutRecentlyUsedCache (DocumentKey const &pDocument, const Size &rPreviewSize, const std::shared_ptr< BitmapCache > &rpCache) |
Add the given cache to the list of recently used caches for the document. More... | |
void | Recycle (const std::shared_ptr< BitmapCache > &rpCache, const DocumentKey &pDocument, const Size &rPreviewSize) |
This method is used internally to initialize a newly created BitmapCache with already existing previews. More... | |
Private Attributes | |
std::unique_ptr< PageCacheContainer > | mpPageCaches |
std::unique_ptr< RecentlyUsedPageCaches > | mpRecentlyUsedPageCaches |
Static Private Attributes | |
static std::weak_ptr< PageCacheManager > | mpInstance |
Singleton instance of the cache manager. More... | |
static const sal_uInt32 | mnMaximalRecentlyCacheCount = 2 |
The maximal number of recently used caches that are kept alive after they have become inactive, i.e. More... | |
Friends | |
class | Deleter |
Provide and manage the preview bitmap caches for all slide sorter instances.
There is one cache per active slide sorter plus a small number of caches that are no longer in use. The later are kept to speed up the switching between views.
Definition at line 39 of file SlsPageCacheManager.hxx.
typedef std::vector< std::pair<Size, std::shared_ptr<BitmapCache> > > sd::slidesorter::cache::PageCacheManager::BestFittingPageCaches |
Definition at line 42 of file SlsPageCacheManager.hxx.
typedef css::uno::Reference<css::uno::XInterface> sd::slidesorter::cache::PageCacheManager::DocumentKey |
Definition at line 43 of file SlsPageCacheManager.hxx.
|
private |
Definition at line 183 of file SlsPageCacheManager.cxx.
Referenced by Instance().
|
private |
Definition at line 189 of file SlsPageCacheManager.cxx.
std::shared_ptr< BitmapCache > sd::slidesorter::cache::PageCacheManager::ChangeSize | ( | const std::shared_ptr< BitmapCache > & | rpCache, |
const Size & | rOldPreviewSize, | ||
const Size & | rNewPreviewSize | ||
) |
This is an information to the cache manager that the size of preview bitmaps in the specified cache has changed.
Definition at line 273 of file SlsPageCacheManager.cxx.
References comphelper::LibreOfficeKit::isActive(), and mpPageCaches.
std::shared_ptr< BitmapCache > sd::slidesorter::cache::PageCacheManager::GetCache | ( | const DocumentKey & | pDocument, |
const Size & | rPreviewSize | ||
) |
Look up the cache for the given model in which the previews have the specified size.
If no such cache exists, then one is created. When a new BitmapCache is created its Recycle() method is called with a sorted list of existing caches from which the new one initialize its previews.
Definition at line 193 of file SlsPageCacheManager.cxx.
References GetRecentlyUsedCache(), mpPageCaches, and Recycle().
|
private |
Definition at line 379 of file SlsPageCacheManager.cxx.
References mpRecentlyUsedPageCaches.
Referenced by GetCache().
|
static |
Return the one instance of the PageCacheManager class.
Definition at line 165 of file SlsPageCacheManager.cxx.
References mpInstance, and PageCacheManager().
Referenced by sd::slidesorter::cache::GenericPageCache::ChangePreviewSize(), sd::slidesorter::view::SlideSorterView::ConfigurationChanged(), sd::slidesorter::controller::Listener::HandleModelChange(), sd::slidesorter::controller::Listener::HandleShapeModification(), sd::slidesorter::controller::IMPL_LINK(), sd::slidesorter::cache::GenericPageCache::InvalidatePreviewBitmap(), sd::slidesorter::cache::GenericPageCache::ProvideCacheAndProcessor(), and sd::slidesorter::cache::GenericPageCache::~GenericPageCache().
void sd::slidesorter::cache::PageCacheManager::InvalidateAllCaches | ( | ) |
Invalidate all the caches that are currently in use and destroy those that are not.
This is used for example when the high contrast mode is turned on or off.
Definition at line 361 of file SlsPageCacheManager.cxx.
References mpPageCaches, and mpRecentlyUsedPageCaches.
void sd::slidesorter::cache::PageCacheManager::InvalidateAllPreviewBitmaps | ( | const DocumentKey & | pDocument | ) |
Invalidate the preview bitmaps for all slides that belong to the specified document.
This is necessary after model changes that affect e.g. page number fields.
Definition at line 340 of file SlsPageCacheManager.cxx.
References mpPageCaches, and mpRecentlyUsedPageCaches.
bool sd::slidesorter::cache::PageCacheManager::InvalidatePreviewBitmap | ( | const DocumentKey & | pDocument, |
const SdrPage * | pPage | ||
) |
Invalidate the preview bitmap for one slide that belongs to the specified document.
The bitmaps for this slide in all caches are marked as out-of-date and will be re-created when they are requested the next time.
Definition at line 313 of file SlsPageCacheManager.cxx.
References mpPageCaches, and mpRecentlyUsedPageCaches.
|
private |
Add the given cache to the list of recently used caches for the document.
There is one such list per document. Each least has at most mnMaximalRecentlyCacheCount members.
Definition at line 401 of file SlsPageCacheManager.cxx.
References mnMaximalRecentlyCacheCount, and mpRecentlyUsedPageCaches.
Referenced by ReleaseCache().
|
private |
This method is used internally to initialize a newly created BitmapCache with already existing previews.
Definition at line 224 of file SlsPageCacheManager.cxx.
References mpPageCaches, and mpRecentlyUsedPageCaches.
Referenced by GetCache().
void sd::slidesorter::cache::PageCacheManager::ReleaseCache | ( | const std::shared_ptr< BitmapCache > & | rpCache | ) |
Tell the cache manager to release its own reference to the specified cache.
After that the cache will live as long as the caller (and maybe others) holds its reference.
Definition at line 256 of file SlsPageCacheManager.cxx.
References mpPageCaches, and PutRecentlyUsedCache().
void sd::slidesorter::cache::PageCacheManager::ReleasePreviewBitmap | ( | const SdrPage * | pPage | ) |
Call this method when a page has been deleted and its preview is not needed anymore.
Definition at line 373 of file SlsPageCacheManager.cxx.
References mpPageCaches.
|
friend |
Definition at line 129 of file SlsPageCacheManager.hxx.
|
staticprivate |
The maximal number of recently used caches that are kept alive after they have become inactive, i.e.
after they are not used anymore by a slide sorter.
Definition at line 123 of file SlsPageCacheManager.hxx.
Referenced by PutRecentlyUsedCache().
|
staticprivate |
Singleton instance of the cache manager.
Note that this is a weak pointer. The (implementation class of) ViewShellBase holds a shared_ptr so that the cache manager has the same life time as the ViewShellBase.
Definition at line 109 of file SlsPageCacheManager.hxx.
Referenced by Instance().
|
private |
Definition at line 113 of file SlsPageCacheManager.hxx.
Referenced by ChangeSize(), GetCache(), InvalidateAllCaches(), InvalidateAllPreviewBitmaps(), InvalidatePreviewBitmap(), Recycle(), ReleaseCache(), and ReleasePreviewBitmap().
|
private |
Definition at line 117 of file SlsPageCacheManager.hxx.
Referenced by GetRecentlyUsedCache(), InvalidateAllCaches(), InvalidateAllPreviewBitmaps(), InvalidatePreviewBitmap(), PutRecentlyUsedCache(), and Recycle().