LibreOffice Module sd (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
sd::slidesorter::cache::GenericPageCache Class Reference

This basically is the implementation class for the PageCache class. More...

#include <SlsGenericPageCache.hxx>

Collaboration diagram for sd::slidesorter::cache::GenericPageCache:
[legend]

Public Member Functions

 GenericPageCache (const Size &rPreviewSize, const bool bDoSuperSampling, const SharedCacheContext &rpCacheContext)
 The page cache is created with a reference to the SlideSorter and thus has access to both view and model. More...
 
 ~GenericPageCache ()
 
void ChangePreviewSize (const Size &rPreviewSize, const bool bDoSuperSampling)
 Change the size of the preview bitmaps. More...
 
BitmapEx GetPreviewBitmap (const CacheKey aKey, const bool bResize)
 Request a preview bitmap for the specified page object in the specified size. More...
 
BitmapEx GetMarkedPreviewBitmap (const CacheKey aKey)
 
void SetMarkedPreviewBitmap (const CacheKey aKey, const BitmapEx &rMarkedBitmap)
 
void RequestPreviewBitmap (const CacheKey aKey, const bool bMayBeUpToDate)
 When the requested preview bitmap does not yet exist or is not up-to-date then the rendering of one is scheduled. More...
 
bool InvalidatePreviewBitmap (const CacheKey aKey)
 Tell the cache to replace the bitmap associated with the given request data with a new one that reflects recent changes in the content of the page object. More...
 
void InvalidateCache ()
 Call this method when all preview bitmaps have to be generated anew. More...
 
void SetPreciousFlag (const CacheKey aKey, const bool bIsPrecious)
 With the precious flag you can control whether a bitmap can be removed from the cache or reduced in size to make room for other bitmaps or is so precious that it will not be touched. More...
 
void Pause ()
 
void Resume ()
 

Private Member Functions

void ProvideCacheAndProcessor ()
 Both bitmap cache and queue processor are created on demand by this method. More...
 

Private Attributes

std::shared_ptr< BitmapCachempBitmapCache
 
RequestQueue maRequestQueue
 
std::unique_ptr< QueueProcessormpQueueProcessor
 
SharedCacheContext mpCacheContext
 
Size maPreviewSize
 The current size of preview bitmaps. More...
 
bool mbDoSuperSampling
 

Detailed Description

This basically is the implementation class for the PageCache class.

Definition at line 34 of file SlsGenericPageCache.hxx.

Constructor & Destructor Documentation

◆ GenericPageCache()

sd::slidesorter::cache::GenericPageCache::GenericPageCache ( const Size rPreviewSize,
const bool  bDoSuperSampling,
const SharedCacheContext rpCacheContext 
)

The page cache is created with a reference to the SlideSorter and thus has access to both view and model.

This allows the cache to fill itself with requests for all pages or just the visible ones.

Parameters
rPreviewSizeThe size of the previews is expected in pixel values.
bDoSuperSamplingWhen <TRUE> the previews are rendered larger and then scaled down to the requested size to improve image quality.

Definition at line 31 of file SlsGenericPageCache.cxx.

References DBG_ASSERT, Size::Height(), maPreviewSize, and Size::Width().

◆ ~GenericPageCache()

sd::slidesorter::cache::GenericPageCache::~GenericPageCache ( )

Member Function Documentation

◆ ChangePreviewSize()

void sd::slidesorter::cache::GenericPageCache::ChangePreviewSize ( const Size rPreviewSize,
const bool  bDoSuperSampling 
)

Change the size of the preview bitmaps.

This may be caused by a resize of the slide sorter window or a change of the number of columns.

Definition at line 75 of file SlsGenericPageCache.cxx.

References DBG_ASSERT, Size::Height(), sd::slidesorter::cache::PageCacheManager::Instance(), maPreviewSize, mbDoSuperSampling, mpBitmapCache, mpQueueProcessor, and Size::Width().

◆ GetMarkedPreviewBitmap()

BitmapEx sd::slidesorter::cache::GenericPageCache::GetMarkedPreviewBitmap ( const CacheKey  aKey)

◆ GetPreviewBitmap()

BitmapEx sd::slidesorter::cache::GenericPageCache::GetPreviewBitmap ( const CacheKey  aKey,
const bool  bResize 
)

Request a preview bitmap for the specified page object in the specified size.

The returned bitmap may be a preview of the preview, i.e. either a scaled (up or down) version of a previous preview (of the wrong size) or an empty bitmap. In this case a request for the generation of a new preview is created and inserted into the request queue. When the preview is available the page shape will be told to paint itself again. When it then calls this method again if receives the correctly sized preview bitmap.

Parameters
rRequestDataThis data is used to determine the preview.
bResizeWhen <TRUE> then when the available bitmap has not the requested size, it is scaled before it is returned. When <FALSE> then the bitmap is returned in the wrong size and it is the task of the caller to scale it.
Returns
Returns a bitmap that is either empty, contains a scaled (up or down) version or is the requested bitmap.

Definition at line 102 of file SlsGenericPageCache.cxx.

References BitmapEx::GetSizePixel(), Size::IsEmpty(), maPreviewSize, mpBitmapCache, mpCacheContext, ProvideCacheAndProcessor(), RequestPreviewBitmap(), and BitmapEx::Scale().

◆ InvalidateCache()

void sd::slidesorter::cache::GenericPageCache::InvalidateCache ( )

Call this method when all preview bitmaps have to be generated anew.

This is the case when the size of the page objects on the screen has changed or when the model has changed.

Definition at line 215 of file SlsGenericPageCache.cxx.

References sd::slidesorter::cache::RequestQueue::Clear(), maRequestQueue, mpBitmapCache, mpCacheContext, and mpQueueProcessor.

◆ InvalidatePreviewBitmap()

bool sd::slidesorter::cache::GenericPageCache::InvalidatePreviewBitmap ( const CacheKey  aKey)

Tell the cache to replace the bitmap associated with the given request data with a new one that reflects recent changes in the content of the page object.

Returns
When the key is known then return <TRUE>.

Definition at line 200 of file SlsGenericPageCache.cxx.

References sd::slidesorter::cache::PageCacheManager::Instance(), mpBitmapCache, and mpCacheContext.

◆ Pause()

void sd::slidesorter::cache::GenericPageCache::Pause ( )

Definition at line 262 of file SlsGenericPageCache.cxx.

References mpQueueProcessor, and ProvideCacheAndProcessor().

◆ ProvideCacheAndProcessor()

void sd::slidesorter::cache::GenericPageCache::ProvideCacheAndProcessor ( )
private

◆ RequestPreviewBitmap()

void sd::slidesorter::cache::GenericPageCache::RequestPreviewBitmap ( const CacheKey  aKey,
const bool  bMayBeUpToDate 
)

When the requested preview bitmap does not yet exist or is not up-to-date then the rendering of one is scheduled.

Otherwise this method does nothing.

Parameters
rRequestDataThis data is used to determine the preview.
bMayBeUpToDateThis flag helps the method to determine whether an existing preview that matches the request is up to date. If the caller knows that it is not then by passing <FALSE> he tells us that we do not have to check the up-to-date flag a second time. If unsure use <TRUE>.

Definition at line 163 of file SlsGenericPageCache.cxx.

References sd::slidesorter::cache::RequestQueue::AddRequest(), BitmapEx::GetSizePixel(), BitmapEx::IsEmpty(), maPreviewSize, maRequestQueue, mpBitmapCache, mpCacheContext, mpQueueProcessor, sd::slidesorter::cache::NOT_VISIBLE, ProvideCacheAndProcessor(), sd::slidesorter::cache::VISIBLE_NO_PREVIEW, and sd::slidesorter::cache::VISIBLE_OUTDATED_PREVIEW.

Referenced by GetPreviewBitmap().

◆ Resume()

void sd::slidesorter::cache::GenericPageCache::Resume ( )

Definition at line 269 of file SlsGenericPageCache.cxx.

References mpQueueProcessor, and ProvideCacheAndProcessor().

◆ SetMarkedPreviewBitmap()

void sd::slidesorter::cache::GenericPageCache::SetMarkedPreviewBitmap ( const CacheKey  aKey,
const BitmapEx rMarkedBitmap 
)

◆ SetPreciousFlag()

void sd::slidesorter::cache::GenericPageCache::SetPreciousFlag ( const CacheKey  aKey,
const bool  bIsPrecious 
)

With the precious flag you can control whether a bitmap can be removed from the cache or reduced in size to make room for other bitmaps or is so precious that it will not be touched.

A typical use is to set the precious flag for the visible pages.

Definition at line 233 of file SlsGenericPageCache.cxx.

References sd::slidesorter::cache::RequestQueue::ChangeClass(), maRequestQueue, mpBitmapCache, mpCacheContext, sd::slidesorter::cache::NOT_VISIBLE, ProvideCacheAndProcessor(), sd::slidesorter::cache::RequestQueue::RemoveRequest(), sd::slidesorter::cache::VISIBLE_NO_PREVIEW, and sd::slidesorter::cache::VISIBLE_OUTDATED_PREVIEW.

Member Data Documentation

◆ maPreviewSize

Size sd::slidesorter::cache::GenericPageCache::maPreviewSize
private

The current size of preview bitmaps.

Definition at line 140 of file SlsGenericPageCache.hxx.

Referenced by ChangePreviewSize(), GenericPageCache(), GetPreviewBitmap(), ProvideCacheAndProcessor(), and RequestPreviewBitmap().

◆ maRequestQueue

RequestQueue sd::slidesorter::cache::GenericPageCache::maRequestQueue
private

◆ mbDoSuperSampling

bool sd::slidesorter::cache::GenericPageCache::mbDoSuperSampling
private

Definition at line 142 of file SlsGenericPageCache.hxx.

Referenced by ChangePreviewSize(), and ProvideCacheAndProcessor().

◆ mpBitmapCache

std::shared_ptr<BitmapCache> sd::slidesorter::cache::GenericPageCache::mpBitmapCache
private

◆ mpCacheContext

SharedCacheContext sd::slidesorter::cache::GenericPageCache::mpCacheContext
private

◆ mpQueueProcessor

std::unique_ptr<QueueProcessor> sd::slidesorter::cache::GenericPageCache::mpQueueProcessor
private

The documentation for this class was generated from the following files: