Image cache base class.
More...
#include <GUIImageCache.h>
◆ CopyCacheContents()
Copies the cache contents of one replacement policy to the other. This is needed for changing replacement policies at runtime. Used as a hook in the template methods SetFreeReplacgementPolicy and SetUsedReplacementPolicy.
- Parameters
-
pOldPolicy | old replacement policy object |
pNewPolicy | new replacement policy object |
Implemented in CGUIImageCacheImpl.
◆ CreateInstance()
Creates the only instance of this class.
- Parameters
-
uiSize | The initial size of the cache in bytes. Default is 100MB. |
eUsed | Policy for used images |
eFree | Policy for free images |
◆ FreeSpace()
virtual eC_Bool CGUIImageCache::FreeSpace |
( |
eC_UInt |
uiSpaceToFree | ) |
|
|
protectedpure virtual |
Deletes images from the cache until its size is reduced by uiBytes.
- Parameters
-
uiSpaceToFree | the amount of memory to be freed |
- Returns
- True if the full amount of memory could be freed. Freeing space can fail if not enough images are allowed to be unloaded. In case of failure the maximum possible amount of space is freed.
Implemented in CGUIImageCacheImpl.
◆ GetCacheSizeLimit()
eC_UInt CGUIImageCache::GetCacheSizeLimit |
( |
| ) |
const |
|
inline |
Returns the size limit for the image cache.
- Returns
- the maximum allowed size of the cache in bytes
◆ GetCurrentMemoryUsage()
virtual eC_UInt CGUIImageCache::GetCurrentMemoryUsage |
( |
| ) |
const |
|
pure virtual |
Determines the amount of memory used by the cached items.
- Returns
- used size in bytes
Implemented in CGUIImageCacheImpl.
◆ GetImageSize()
virtual eC_UInt CGUIImageCache::GetImageSize |
( |
const ImageResource_t & |
eImageID | ) |
const |
|
pure virtual |
Get the size of an image resource in memory.
- Parameters
-
- Returns
- Size of the image resource when loaded into memory
Implemented in CGUIImageCacheImpl.
◆ GetInstance()
Retrieves the only instance of this class.
- Returns
- pointer to the only instance
◆ LoadImg()
virtual eC_Bool CGUIImageCache::LoadImg |
( |
const eC_String & |
kPath, |
|
|
const ImageResource_t & |
eImageID |
|
) |
| |
|
protectedpure virtual |
Tries to load an image and adds it to the cache. Needed space is freed before adding, if necessary.
- Parameters
-
kPath | the path to the image file. Used for determining the size and for loading the image. |
eImageID | the image's ID |
- Returns
- True if the image was successfully loaded. Loading can fail if not enough space for the image can be freed.
Implemented in CGUIImageCacheImpl.
◆ MarkAsFree()
virtual void CGUIImageCache::MarkAsFree |
( |
const ImageResource_t & |
eImageID | ) |
|
|
protectedpure virtual |
Moves an (already loaded) image to the list of cached (but unused) images. The image is moved from the used list to the free list.
- Parameters
-
Implemented in CGUIImageCacheImpl.
◆ MarkAsUsed()
virtual void CGUIImageCache::MarkAsUsed |
( |
const ImageResource_t & |
eImageID | ) |
|
|
protectedpure virtual |
Marks an (already loaded) image as used. The image is moved from the free list to the used list.
- Parameters
-
Implemented in CGUIImageCacheImpl.
◆ NotifyImageAccess()
static void CGUIImageCache::NotifyImageAccess |
( |
const ImageResource_t & |
eImageID | ) |
|
|
inlinestaticprotected |
Notifies the cache about an access (e.g. blitting,...) to an image.
- Parameters
-
eImageID | the image that was accessed. |
◆ NotifyImageAccessInternal()
virtual void CGUIImageCache::NotifyImageAccessInternal |
( |
const ImageResource_t & |
eImageID | ) |
|
|
protectedpure virtual |
Notifies the cache about an access (e.g. blitting,...) to an image.
- Parameters
-
eImageID | the image that was accessed. |
Implemented in CGUIImageCacheImpl.
◆ PreloadImg()
virtual eC_Bool CGUIImageCache::PreloadImg |
( |
const eC_String & |
psPath, |
|
|
const ImageResource_t & |
eImageID |
|
) |
| |
|
protectedpure virtual |
Special version of LoadImage for preloading images at start-up. Once the cache is full, needed space is not freed.
- Parameters
-
psPath | the path to the image file used for determining the size and for the actual loading |
eImageID | the image's ID |
- Returns
- True if the image was successfully loaded. Loading fails if the cache is full.
Implemented in CGUIImageCacheImpl.
◆ ReadCacheSettingsFromFile()
virtual eC_Bool CGUIImageCache::ReadCacheSettingsFromFile |
( |
const eC_String & |
kPath | ) |
|
|
pure virtual |
Reads the cache settings from a file. GUIStreamReader has to be initialized.
- Parameters
-
kPath | to the destination file. |
- Returns
- True if the configuration was read successfully.
- See also
- CGUIStreamReader
Implemented in CGUIImageCacheImpl.
◆ SetCacheSizeLimit()
eC_Bool CGUIImageCache::SetCacheSizeLimit |
( |
eC_UInt |
uiCacheSizeLimit | ) |
|
Sets the size limit for the image cache.
- Parameters
-
uiCacheSizeLimit | the new maximum allowed size of the cache in bytes |
- Returns
- True if new size limit could be set. Setting of size limit can fail if
- not enough are allowed to be unloaded to decrease cache size or
- not enough memory left to increase cache size. In case of failure the size limit is set to the lowest (or highest, respectively) possible value.
◆ SetFreeReplacementPolicy()
Set the replacement policy for the image cache. If a previous policy exists, this method deletes it. Calling this when the cache already contains elements may result in undefined behavior. It is therefore advisable to only call this method once, at startup.
- Parameters
-
pPolicy | the replacement policy |
- Deprecated:
- Function call may result in undefined behaviour, use CreateInstance-parameters instead
◆ SetReadResolutionAppendix()
void CGUIImageCache::SetReadResolutionAppendix |
( |
const eC_String & |
kAppendString | ) |
|
|
inline |
Tells the image cache to append a string to the resolution when reading its configuration. The method ReadCacheSettingsFromFile() decides with configuration entry it reads by querying the screen resolution from the graphics wrapper and appending this string. Needs to be called before replacement policies are initialized.
- Parameters
-
kAppendString | the String to be appended to the resolution while reading the configuration. |
◆ SetUsedReplacementPolicy()
Set the replacement policy for the image cache. If a previous policy exists, this method deletes it. Calling this when the cache already contains elements may result in undefined behavior. It is therefore advisable to only call this method once, at startup.
- Parameters
-
pPolicy | the replacement policy |
- Deprecated:
- Function call may result in undefined behaviour, use CreateInstance-parameters instead
◆ UnloadSpecificImage()
virtual eC_Bool CGUIImageCache::UnloadSpecificImage |
( |
const ImageResource_t & |
eImageID | ) |
|
|
protectedpure virtual |
Unloads a specific image and removes it from the free list.
- Parameters
-
- Returns
- True if the image was successfully unloaded, False if it was not in memory in the first place.
Implemented in CGUIImageCacheImpl.
◆ CGfxWrap
The graphics wrapper calls NotifyImageAccess.
◆ CGUIBackgroundImageLoaderThread
friend class CGUIBackgroundImageLoaderThread |
|
friend |
◆ CGUIResourceManager
To access methods involved with loading and unloading of images, the Resource Manager must be a friend class.
The documentation for this class was generated from the following file: