Merge branch 'opportunisticCacheCheck' of git://github.com/hippojay/xbmc into hippoja...
authorJonathan Marshall <jmarshall@never.you.mind>
Thu, 11 Aug 2011 20:43:27 +0000 (08:43 +1200)
committerJonathan Marshall <jmarshall@never.you.mind>
Thu, 11 Aug 2011 20:43:27 +0000 (08:43 +1200)
* 'opportunisticCacheCheck' of git://github.com/hippojay/xbmc:
  Broke out cache code from CacheAndCheck into dedicated function - CacheImageFile.
  Modified "Check and Cache" image function.  Check cache first befor URL validation.

Conflicts:
xbmc/GUILargeTextureManager.cpp

1  2 
xbmc/GUILargeTextureManager.cpp
xbmc/TextureCache.cpp

@@@ -48,26 -47,37 +48,37 @@@ CImageLoader::~CImageLoader(
  
  bool CImageLoader::DoWork()
  {
-   CFileItem file(m_path, false);
-   if (file.IsPicture() && !(file.IsZIP() || file.IsRAR() || file.IsCBR() || file.IsCBZ())) // ignore non-pictures
-   { // check for filename only (i.e. lookup in skin/media/)
-     CStdString loadPath = g_TextureManager.GetTexturePath(m_path);
+   CStdString texturePath = g_TextureManager.GetTexturePath(m_path);
+   CStdString loadPath = CTextureCache::Get().CheckCachedImage(texturePath); 
+   
+   // If empty, then go on to validate and cache image as appropriate
+   // If hit, continue down and load image
+   if (loadPath.IsEmpty())
+   {
+     CFileItem file(m_path, false);
  
-     // cache the image if necessary
-     loadPath = CTextureCache::Get().CheckAndCacheImage(loadPath);
-     if (loadPath.IsEmpty())
-       return false;
-     m_texture = new CTexture();
-     unsigned int start = XbmcThreads::SystemClockMillis();
-     if (!m_texture->LoadFromFile(loadPath, min(g_graphicsContext.GetWidth(), 2048), min(g_graphicsContext.GetHeight(), 1080), g_guiSettings.GetBool("pictures.useexifrotation")))
-     {
-       delete m_texture;
-       m_texture = NULL;
+     // Validate file URL to see if it is an image
+     if ((file.IsPicture() && !(file.IsZIP() || file.IsRAR() || file.IsCBR() || file.IsCBZ() )) 
+        || file.GetMimeType().Left(6).Equals("image/")) // ignore non-pictures
+     { 
+       // Cache the image if necessary
+       loadPath = CTextureCache::Get().CacheImageFile(texturePath);
+       if (loadPath.IsEmpty())
+         return false;
      }
-     else if (XbmcThreads::SystemClockMillis() - start > 100)
-       CLog::Log(LOGDEBUG, "%s - took %u ms to load %s", __FUNCTION__, XbmcThreads::SystemClockMillis() - start, loadPath.c_str());
+     else
+       return true;
+   }
+  
+   m_texture = new CTexture();
 -  DWORD start = CTimeUtils::GetTimeMS();
++  unsigned int start = XbmcThreads::SystemClockMillis();
+   if (!m_texture->LoadFromFile(loadPath, min(g_graphicsContext.GetWidth(), 2048), min(g_graphicsContext.GetHeight(), 1080), g_guiSettings.GetBool("pictures.useexifrotation")))
+   {
+     delete m_texture;
+     m_texture = NULL;
    }
 -  else if (CTimeUtils::GetTimeMS() - start > 100)
 -    CLog::Log(LOGDEBUG, "%s - took %d ms to load %s", __FUNCTION__, CTimeUtils::GetTimeMS() - start, loadPath.c_str());
++  else if (XbmcThreads::SystemClockMillis() - start > 100)
++    CLog::Log(LOGDEBUG, "%s - took %u ms to load %s", __FUNCTION__, XbmcThreads::SystemClockMillis() - start, loadPath.c_str());
  
    return true;
  }
Simple merge