/*
* Copyright (C) 2005-2013 Team XBMC
- * http://www.xbmc.org
+ * http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
using namespace std;
-CImageLoader::CImageLoader(const CStdString &path)
+CImageLoader::CImageLoader(const CStdString &path, const bool useCache)
{
m_path = path;
m_texture = NULL;
+ m_use_cache = useCache;
}
CImageLoader::~CImageLoader()
bool CImageLoader::DoWork()
{
bool needsChecking = false;
+ CStdString loadPath;
CStdString texturePath = g_TextureManager.GetTexturePath(m_path);
- CStdString loadPath = CTextureCache::Get().CheckCachedImage(texturePath, true, needsChecking);
+ if (m_use_cache)
+ loadPath = CTextureCache::Get().CheckCachedImage(texturePath, true, needsChecking);
+ else
+ loadPath = texturePath;
- if (loadPath.IsEmpty())
+ if (m_use_cache && loadPath.empty())
{
// not in our texture cache, so try and load directly and then cache the result
loadPath = CTextureCache::Get().CacheImage(texturePath, &m_texture);
if (m_texture)
return true; // we're done
}
- if (!loadPath.IsEmpty())
+ if (!m_use_cache || !loadPath.empty())
{
// direct route - load the image
unsigned int start = XbmcThreads::SystemClockMillis();
// if available, increment reference count, and return the image.
// else, add to the queue list if appropriate.
-bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest)
+bool CGUILargeTextureManager::GetImage(const CStdString &path, CTextureArray &texture, bool firstRequest, const bool useCache)
{
CSingleLock lock(m_listSection);
for (listIterator it = m_allocated.begin(); it != m_allocated.end(); ++it)
}
if (firstRequest)
- QueueImage(path);
+ QueueImage(path, useCache);
return true;
}
}
// queue the image, and start the background loader if necessary
-void CGUILargeTextureManager::QueueImage(const CStdString &path)
+void CGUILargeTextureManager::QueueImage(const CStdString &path, bool useCache)
{
CSingleLock lock(m_listSection);
for (queueIterator it = m_queued.begin(); it != m_queued.end(); ++it)
// queue the item
CLargeTexture *image = new CLargeTexture(path);
- unsigned int jobID = CJobManager::GetInstance().AddJob(new CImageLoader(path), this, CJob::PRIORITY_NORMAL);
+ unsigned int jobID = CJobManager::GetInstance().AddJob(new CImageLoader(path, useCache), this, CJob::PRIORITY_NORMAL);
m_queued.push_back(make_pair(jobID, image));
}