Browse files

cleanup: remove unused texturecache functions

  • Loading branch information...
1 parent 46e6b0b commit d2038249c23dbda5fc04272da95ee8e5bb4e3d95 Jonathan Marshall committed May 12, 2012
Showing with 4 additions and 97 deletions.
  1. +0 −66 xbmc/TextureCache.cpp
  2. +4 −31 xbmc/TextureCache.h
@@ -149,17 +149,6 @@ CStdString CTextureCache::CheckCachedImage(const CStdString &url, bool returnDDS
return "";
-CStdString CTextureCache::CheckAndCacheImage(const CStdString &url, bool returnDDS)
- bool needsRecaching = false;
- CStdString path(CheckCachedImage(url, returnDDS, needsRecaching));
- if (!path.IsEmpty())
- {
- return path;
- }
- return CacheImageFile(url);
void CTextureCache::BackgroundCacheImage(const CStdString &url)
CStdString cacheHash;
@@ -201,50 +190,6 @@ CStdString CTextureCache::CacheTexture(const CStdString &image, CBaseTexture **t
return GetCachedImage(url, cachedHash);
-CStdString CTextureCache::CacheImageFile(const CStdString &url)
- return CacheTexture(url);
- // TODO: In the future we need a cache job to callback when the image is loaded
- // thus automatically updating the images. We'd also need fallback code inside
- // the CGUITexture class to display something from this point on.
- // Have this caching stuff be a lifo stack, and bump things up the stack when we should (check whether
- // CJobQueue does this...) That way we can have a bunch of "cache thumb kthxpls" run from a background
- // thread, and all we do here is cache from the size we've already been given. If we haven't been
- // given a size, we must assume that the user wants fullsize. We could, in fact, add the sizing of it
- // into the URL scheme using options... i.e. http://my.thumb/file|width=blah|height=foo
- // that gives us sizing goodness, plus pre-caching goodness where we know shit should be cached
- // all with the fandangled jobmanager....
- // We almost need a better interface on the loading side of things - i.e. we need the textures to
- // request a particular image and to get some (immediate?) recognition as to whether it's cached
- // so that a fallback image can be specified. Perhaps the texture updating routines (i.e.
- // UpdateInfo and/or SetFileName) might handle this? The procedure would be to hit the db
- // to see if this image is available or not. If it isn't, then we simply load the fallback or
- // "loading..." image, but keep testing to see if the image has been cached or not. Hmm,
- // that's inefficient as well - at the very least a string compare or 12 per frame as it tests
- // a list of caching jobs, or (more inefficiently) a db query every frame.
- // The "best" method is the callback technique - this can be done quite easily though if the texture
- // is the one that makes the request I think? At least when one texture is involved - we pass in our
- // pointer to the callback list. In fact, we could generalize this somewhat with the texture
- // manager handling those pointers - after all, it already handles reference counting, so why not
- // count using the callback pointers instead? We then wouldn't have to call AllocResources() all
- // the time. When the texture is loaded it's moved from the queued to the allocated list, and at
- // that point we could have an interim list (loaded) that we then run the callbacks on once a frame.
- // There'd be a "LOADING" enum for allocation of the image and the texture could then show a fallback?
- // Main problem with this is CGUITexture doesn't have any concept of a fallback: CGUIImage does instead.
- // The main fallback mechanism we use is LISTITEM_ICON vs LISTITEM_THUMB - with the former we actually
- // use the thumb if it's available, and drop back to the icon if it's not. In either case, having
- // a "loading" fallback would be useful even if it wasn't the icon. I guess this could be a property
- // of CGUITexture similar to how background="true" is? The loading texture would be displayed if
- // and only if there is an image being loaded. Need to talk to Jezz_X about this - eg if you have
- // a current image and a new one is loading we currently hold on to the current one and render
- // the current one faded out - we'd need to change this so that the fading only happened once it
- // was ready to render.
void CTextureCache::ClearCachedImage(const CStdString &url, bool deleteSource /*= false */)
// TODO: This can be removed when the texture cache covers everything.
@@ -354,17 +299,6 @@ void CTextureCache::OnJobProgress(unsigned int jobID, unsigned int progress, uns
CJobQueue::OnJobProgress(jobID, progress, total, job);
-CStdString CTextureCache::GetUniqueImage(const CStdString &url, const CStdString &extension)
- Crc32 crc;
- crc.ComputeFromLowerCase(url);
- CStdString hex;
- hex.Format("%08x", (unsigned int)crc);
- CStdString hash;
- hash.Format("generated/%c/%s%s", hex[0], hex.c_str(), extension.c_str());
- return GetCachedPath(hash);
bool CTextureCache::Export(const CStdString &image, const CStdString &destination)
CStdString cachedImage(GetCachedImage(image));
@@ -70,24 +70,14 @@ class CTextureCache : public CJobQueue
CStdString CheckCachedImage(const CStdString &image, bool returnDDS, bool &needsRecaching);
- /*! \brief This function is a wrapper around CheckCacheImage and CacheImageFile.
- Checks firstly whether an image is already cached, and return URL if so [see CheckCacheImage]
- If the image is not yet in the database it is cached and added to the database [see CacheImageFile]
- \param image url of the image to check and cache
- \param returnDDS if we're allowed to return a DDS version, defaults to true
- \return cached url of this image
- \sa CheckCacheImage
- */
- CStdString CheckAndCacheImage(const CStdString &image, bool returnDDS = true);
/*! \brief Cache image (if required) using a background job
- Essentially a threaded version of CheckAndCacheImage.
+ 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]
\param image url of the image to cache
- \sa CheckAndCacheImage
+ \sa CacheImage
void BackgroundCacheImage(const CStdString &image);
@@ -102,16 +92,6 @@ class CTextureCache : public CJobQueue
CStdString CacheTexture(const CStdString &url, CBaseTexture **texture = NULL);
- /*! \brief Take image URL and add it to image cache
- Takes the URL to an image. Caches and adds to the database.
- \param image url of the image to cache
- \return cached url of this image
- \sa CTextureCacheJob::DoWork
- */
- CStdString CacheImageFile(const CStdString &url);
/*! \brief retrieve the cached version of the given image (if it exists)
\param image url of the image
\return cached url of this image, empty if none exists
@@ -147,13 +127,6 @@ class CTextureCache : public CJobQueue
static CStdString GetWrappedImageURL(const CStdString &image, const CStdString &type = "", const CStdString &options = "");
static CStdString GetWrappedThumbURL(const CStdString &image);
- /*! \brief get a unique image path to associate with the given URL, useful for caching images
- \param url path to retrieve a unique image for
- \param extension type of file we want
- \return a "unique" path to an image with the appropriate extension
- */
- static CStdString GetUniqueImage(const CStdString &url, const CStdString &extension);
/*! \brief Add this image to the database
Thread-safe wrapper of CTextureDatabase::AddCachedTexture
\param image url of the original image

0 comments on commit d203824

Please sign in to comment.