2 * Copyright (C) 2012-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
23 #include "utils/StdString.h"
24 #include "utils/Job.h"
30 \brief Simple class for passing texture detail around
41 bool operator==(const CTextureDetails &right) const
43 return (id == right.id &&
45 width == right.width );
57 \brief Job class for caching textures
59 Handles loading and caching of textures.
61 class CTextureCacheJob : public CJob
64 CTextureCacheJob(const CStdString &url, const CStdString &oldHash = "");
65 virtual ~CTextureCacheJob();
67 virtual const char* GetType() const { return kJobTypeCacheImage; };
68 virtual bool operator==(const CJob *job) const;
69 virtual bool DoWork();
71 /*! \brief retrieve a hash for the given image
72 Combines the size, ctime and mtime of the image file into a "unique" hash
73 \param url location of the image
74 \return a hash string for this image
76 bool CacheTexture(CBaseTexture **texture = NULL);
80 CTextureDetails m_details;
82 friend class CEdenVideoArtUpdater;
84 /*! \brief retrieve a hash for the given image
85 Combines the size, ctime and mtime of the image file into a "unique" hash
86 \param url location of the image
87 \return a hash string for this image
89 static CStdString GetImageHash(const CStdString &url);
91 /*! \brief Check whether a given URL represents an image that can be updated
92 We currently don't check http:// and https:// URLs for updates, under the assumption that
93 a image URL is much more likely to be static and the actual image at the URL is unlikely
94 to change, so no point checking all the time.
95 \param url the url to check
96 \return true if the image given by the URL should be checked for updates, false otehrwise
98 bool UpdateableURL(const CStdString &url) const;
100 /*! \brief Decode an image URL to the underlying image, width, height and orientation
101 \param url wrapped URL of the image
102 \param width width derived from URL
103 \param height height derived from URL
104 \param additional_info additional information, such as "flipped" to flip horizontally
105 \return URL of the underlying image file.
107 static CStdString DecodeImageURL(const CStdString &url, unsigned int &width, unsigned int &height, std::string &additional_info);
109 /*! \brief Load an image at a given target size and orientation.
111 Doesn't necessarily load the image at the desired size - the loader *may* decide to load it slightly larger
112 or smaller than the desired size for speed reasons.
114 \param image the URL of the image file.
115 \param width the desired maximum width.
116 \param height the desired maximum height.
117 \param additional_info extra info for loading, such as whether to flip horizontally.
118 \return a pointer to a CBaseTexture object, NULL if failed.
120 static CBaseTexture *LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info, bool requirePixels = false);
122 CStdString m_cachePath;
125 /* \brief Job class for creating .dds versions of textures
127 class CTextureDDSJob : public CJob
130 CTextureDDSJob(const CStdString &original);
132 virtual const char* GetType() const { return kJobTypeDDSCompress; };
133 virtual bool operator==(const CJob *job) const;
134 virtual bool DoWork();
136 CStdString m_original;
139 /* \brief Job class for storing the use count of textures
141 class CTextureUseCountJob : public CJob
144 CTextureUseCountJob(const std::vector<CTextureDetails> &textures);
146 virtual const char* GetType() const { return "usecount"; };
147 virtual bool operator==(const CJob *job) const;
148 virtual bool DoWork();
151 std::vector<CTextureDetails> m_textures;