![]() |
Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.
|
Texture cache class for handling the caching of images. More...
#include <TextureCache.h>
Public Member Functions | |
void | Initialize () |
Initialize the texture cache. More... | |
void | Deinitialize () |
Deinitialize the texture cache. More... | |
std::string | CheckCachedImage (const std::string &image, bool &needsRecaching) |
Check whether we already have this image cached. More... | |
void | BackgroundCacheImage (const std::string &image) |
Cache image (if required) using a background job. More... | |
std::string | CacheImage (const std::string &image, CBaseTexture **texture=NULL, CTextureDetails *details=NULL) |
Cache an image to image cache, optionally return the texture. More... | |
bool | CacheImage (const std::string &image, CTextureDetails &details) |
Cache an image to image cache if not already cached, returning the image details. More... | |
bool | HasCachedImage (const std::string &image) |
Check whether an image is in the cache Note: If the image url won't normally be cached (eg a skin image) this function will return false. More... | |
void | ClearCachedImage (const std::string &image, bool deleteSource=false) |
clear the cached version of the given image More... | |
bool | ClearCachedImage (int textureID) |
clear the cached version of the image with given id More... | |
bool | AddCachedTexture (const std::string &image, const CTextureDetails &details) |
Add this image to the database Thread-safe wrapper of CTextureDatabase::AddCachedTexture. More... | |
bool | Export (const std::string &image, const std::string &destination, bool overwrite) |
Export a (possibly) cached image to a file. More... | |
bool | Export (const std::string &image, const std::string &destination) |
![]() | |
CJobQueue (bool lifo=false, unsigned int jobsAtOnce=1, CJob::PRIORITY priority=CJob::PRIORITY_LOW) | |
CJobQueue constructor. More... | |
~CJobQueue () override | |
CJobQueue destructor Cancels any in-process jobs, and destroys the job queue. More... | |
bool | AddJob (CJob *job) |
Add a job to the queue On completion of the job (or destruction of the job queue) the CJob object will be destroyed. More... | |
template<typename F > | |
void | Submit (F &&f) |
Add a function f to this job queue. More... | |
void | CancelJob (const CJob *job) |
Cancel a job in the queue Cancels a job in the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed. If the job is only queued then it will be removed from the queue and deleted. More... | |
void | CancelJobs () |
Cancel all jobs in the queue Removes all jobs from the queue. Any job currently being processed may complete after this call has completed, but OnJobComplete will not be performed. More... | |
bool | IsProcessing () const |
Check whether the queue is processing a job. More... | |
void | OnJobComplete (unsigned int jobID, bool success, CJob *job) override |
The callback used when a job completes. More... | |
![]() | |
virtual | ~IJobCallback ()=default |
Destructor for job call back objects. More... | |
Static Public Member Functions | |
static CTextureCache & | GetInstance () |
The only way through which the global instance of the CTextureCache should be accessed. More... | |
static std::string | GetCacheFile (const std::string &url) |
retrieve a cache file (relative to the cache path) to associate with the given image, excluding extension Use GetCachedPath(GetCacheFile(url)+extension) for the full path to the file. More... | |
static std::string | GetCachedPath (const std::string &file) |
retrieve the full path of the given cached file More... | |
static bool | CanCacheImageURL (const CURL &url) |
check whether an image:// URL may be cached More... | |
Additional Inherited Members | |
![]() | |
bool | QueueEmpty () const |
Returns if we still have jobs waiting to be processed NOTE: This function does not take into account the jobs that are currently processing. More... | |
Texture cache class for handling the caching of images.
Manages the caching of images for use as control textures. Images are cached both as originals (direct copies) and as .dds textures for fast loading. Images may be periodically checked for updates and may be purged from the cache if unused for a set period of time.
bool CTextureCache::AddCachedTexture | ( | const std::string & | image, |
const CTextureDetails & | details | ||
) |
Add this image to the database Thread-safe wrapper of CTextureDatabase::AddCachedTexture.
image | url of the original image |
details | the texture details to add |
void CTextureCache::BackgroundCacheImage | ( | const std::string & | image | ) |
Cache image (if required) using a background job.
Checks firstly whether an image is already cached, and return URL if so [see CheckCacheImage] If the image is not yet in the database, a background job is started to cache the image and add to the database [see CTextureCacheJob]
image | url of the image to cache |
std::string CTextureCache::CacheImage | ( | const std::string & | image, |
CBaseTexture ** | texture = NULL , |
||
CTextureDetails * | details = NULL |
||
) |
Cache an image to image cache, optionally return the texture.
Caches the given image, returning the texture if the caller wants it.
image | url of the image to cache |
texture | [out] the loaded image |
details | [out] details of the cached image |
bool CTextureCache::CacheImage | ( | const std::string & | image, |
CTextureDetails & | details | ||
) |
Cache an image to image cache if not already cached, returning the image details.
image | url of the image to cache. |
details | [out] the image details. |
|
static |
check whether an image:// URL may be cached
url | the URL to the image |
std::string CTextureCache::CheckCachedImage | ( | const std::string & | image, |
bool & | needsRecaching | ||
) |
Check whether we already have this image cached.
Check and return URL to cached image if it exists; If not, return empty string. If the image is cached, return URL (for original image or .dds version if requested)
image | url of the image to check |
needsRecaching | [out] whether the image needs recaching. |
void CTextureCache::ClearCachedImage | ( | const std::string & | image, |
bool | deleteSource = false |
||
) |
clear the cached version of the given image
image | url of the image |
bool CTextureCache::ClearCachedImage | ( | int | textureID | ) |
clear the cached version of the image with given id
database | id of the image |
void CTextureCache::Deinitialize | ( | ) |
Deinitialize the texture cache.
bool CTextureCache::Export | ( | const std::string & | image, |
const std::string & | destination | ||
) |
bool CTextureCache::Export | ( | const std::string & | image, |
const std::string & | destination, | ||
bool | overwrite | ||
) |
Export a (possibly) cached image to a file.
image | url of the original image |
destination | url of the destination image, excluding extension. |
overwrite | whether to overwrite the destination if it exists (TODO: Defaults to false) |
|
static |
retrieve the full path of the given cached file
file | name of the file |
|
static |
retrieve a cache file (relative to the cache path) to associate with the given image, excluding extension Use GetCachedPath(GetCacheFile(url)+extension) for the full path to the file.
url | location of the image |
|
static |
The only way through which the global instance of the CTextureCache should be accessed.
bool CTextureCache::HasCachedImage | ( | const std::string & | image | ) |
Check whether an image is in the cache Note: If the image url won't normally be cached (eg a skin image) this function will return false.
image | url of the image |