bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture) { // unwrap the URL as required std::string additional_info; unsigned int width, height; CPictureScalingAlgorithm::Algorithm scalingAlgorithm; std::string image = DecodeImageURL(m_url, width, height, scalingAlgorithm, additional_info); m_details.updateable = additional_info != "music" && UpdateableURL(image); // generate the hash m_details.hash = GetImageHash(image); if (m_details.hash.empty()) return false; else if (m_details.hash == m_oldHash) return true; #if defined(HAS_OMXPLAYER) if (COMXImage::CreateThumb(image, width, height, additional_info, CTextureCache::GetCachedPath(m_cachePath + ".jpg"))) { m_details.width = width; m_details.height = height; m_details.file = m_cachePath + ".jpg"; if (out_texture) *out_texture = LoadImage(CTextureCache::GetCachedPath(m_details.file), width, height, "" /* already flipped */); CLog::Log(LOGDEBUG, "Fast %s image '%s' to '%s': %p", m_oldHash.empty() ? "Caching" : "Recaching", CURL::GetRedacted(image).c_str(), m_details.file.c_str(), out_texture); return true; } #endif CBaseTexture *texture = LoadImage(image, width, height, additional_info, true); if (texture) { if (texture->HasAlpha()) m_details.file = m_cachePath + ".png"; else m_details.file = m_cachePath + ".jpg"; CLog::Log(LOGDEBUG, "%s image '%s' to '%s':", m_oldHash.empty() ? "Caching" : "Recaching", CURL::GetRedacted(image).c_str(), m_details.file.c_str()); if (CPicture::CacheTexture(texture, width, height, CTextureCache::GetCachedPath(m_details.file), scalingAlgorithm)) { m_details.width = width; m_details.height = height; if (out_texture) // caller wants the texture *out_texture = texture; else delete texture; return true; } } delete texture; return false; }
bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture) { // unwrap the URL as required bool flipped; unsigned int width, height; CStdString image = DecodeImageURL(m_url, width, height, flipped); m_details.updateable = UpdateableURL(image); // generate the hash m_details.hash = GetImageHash(image); if (m_details.hash.empty()) return false; else if (m_details.hash == m_oldHash) return true; CBaseTexture *texture = LoadImage(image, width, height, flipped); if (texture) { if (texture->HasAlpha()) m_details.file = m_cachePath + ".png"; else m_details.file = m_cachePath + ".jpg"; if (width > 0 && height > 0) CLog::Log(LOGDEBUG, "%s image '%s' at %dx%d with orientation %d as '%s'", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(), width, height, texture->GetOrientation(), m_details.file.c_str()); else CLog::Log(LOGDEBUG, "%s image '%s' fullsize with orientation %d as '%s'", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(), texture->GetOrientation(), m_details.file.c_str()); if (CPicture::CacheTexture(texture, width, height, CTextureCache::GetCachedPath(m_details.file))) { m_details.width = width; m_details.height = height; if (out_texture) // caller wants the texture *out_texture = texture; else delete texture; return true; } } delete texture; return false; }
bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture) { // unwrap the URL as required std::string additional_info; unsigned int width, height; CStdString image = DecodeImageURL(m_url, width, height, additional_info); m_details.updateable = additional_info != "music" && UpdateableURL(image); // generate the hash m_details.hash = GetImageHash(image); if (m_details.hash.empty()) return false; else if (m_details.hash == m_oldHash) return true; CBaseTexture *texture = LoadImage(image, width, height, additional_info); if (texture) { if (texture->HasAlpha()) m_details.file = m_cachePath + ".png"; else m_details.file = m_cachePath + ".jpg"; CLog::Log(LOGDEBUG, "%s image '%s' to '%s':", m_oldHash.IsEmpty() ? "Caching" : "Recaching", image.c_str(), m_details.file.c_str()); if (CPicture::CacheTexture(texture, width, height, CTextureCache::GetCachedPath(m_details.file))) { m_details.width = width; m_details.height = height; if (out_texture) // caller wants the texture *out_texture = texture; else delete texture; return true; } } delete texture; return false; }