Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
[imageloader] switch flipped param in CTextureCacheJob to a string to…
Browse files Browse the repository at this point in the history
… allow more values
  • Loading branch information
Jonathan Marshall committed Jul 3, 2012
1 parent 6f4ce3e commit 06e1d96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions xbmc/TextureCacheJob.cpp
Expand Up @@ -74,9 +74,9 @@ bool CTextureCacheJob::DoWork()
bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
{
// unwrap the URL as required
bool flipped;
std::string additional_info;
unsigned int width, height;
CStdString image = DecodeImageURL(m_url, width, height, flipped);
CStdString image = DecodeImageURL(m_url, width, height, additional_info);

m_details.updateable = UpdateableURL(image);

Expand All @@ -87,7 +87,7 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
else if (m_details.hash == m_oldHash)
return true;

CBaseTexture *texture = LoadImage(image, width, height, flipped);
CBaseTexture *texture = LoadImage(image, width, height, additional_info);
if (texture)
{
if (texture->HasAlpha())
Expand Down Expand Up @@ -117,11 +117,11 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
return false;
}

CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, bool &flipped)
CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info)
{
// unwrap the URL as required
CStdString image(url);
flipped = false;
additional_info.clear();
width = g_advancedSettings.m_fanartHeight * 16/9;
height = g_advancedSettings.m_fanartHeight;
if (url.compare(0, 8, "image://") == 0)
Expand Down Expand Up @@ -160,14 +160,14 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
}
else if (option == "flipped")
{
flipped = true;
additional_info = "flipped";
}
}
}
return image;
}

CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int width, unsigned int height, bool flipped)
CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info)
{
// Validate file URL to see if it is an image
CFileItem file(image, false);
Expand All @@ -181,8 +181,8 @@ CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int

// EXIF bits are interpreted as: <flipXY><flipY*flipX><flipX>
// where to undo the operation we apply them in reverse order <flipX>*<flipY*flipX>*<flipXY>
// When flipped = true we have an additional <flipX> on the left, which is equivalent to toggling the last bit
if (flipped)
// When flipped we have an additional <flipX> on the left, which is equivalent to toggling the last bit
if (additional_info == "flipped")
texture->SetOrientation(texture->GetOrientation() ^ 1);

return texture;
Expand Down
8 changes: 4 additions & 4 deletions xbmc/TextureCacheJob.h
Expand Up @@ -100,10 +100,10 @@ class CTextureCacheJob : public CJob
\param url wrapped URL of the image
\param width width derived from URL
\param height height derived from URL
\param flipped whether the image is flipped horizontally
\param additional_info additional information, such as "flipped" to flip horizontally
\return URL of the underlying image file.
*/
static CStdString DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, bool &flipped);
static CStdString DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info);

/*! \brief Load an image at a given target size and orientation.
Expand All @@ -113,10 +113,10 @@ class CTextureCacheJob : public CJob
\param image the URL of the image file.
\param width the desired maximum width.
\param height the desired maximum height.
\param flipped whether the image should be flipped horizontally.
\param additional_info extra info for loading, such as whether to flip horizontally.
\return a pointer to a CBaseTexture object, NULL if failed.
*/
static CBaseTexture *LoadImage(const CStdString &image, unsigned int width, unsigned int height, bool flipped);
static CBaseTexture *LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info);

CStdString m_cachePath;
};
Expand Down

0 comments on commit 06e1d96

Please sign in to comment.