2 * Copyright (C) 2012-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "pictures/PictureScalingAlgorithm.h"
12 #include "utils/Job.h"
26 \brief Simple class for passing texture detail around
31 bool operator==(const CTextureDetails
&right
) const
33 return (id
== right
.id
&&
35 width
== right
.width
);
41 unsigned int width
{0};
42 unsigned int height
{0};
43 bool updateable
{false};
44 bool hashRevalidated
{false};
49 \brief Job class for caching textures
51 Handles loading and caching of textures.
53 class CTextureCacheJob
: public CJob
56 CTextureCacheJob(const std::string
&url
, const std::string
&oldHash
= "");
57 ~CTextureCacheJob() override
;
59 const char* GetType() const override
{ return kJobTypeCacheImage
; }
60 bool operator==(const CJob
*job
) const override
;
61 bool DoWork() override
;
63 /*! \brief retrieve a hash for the given image
64 Combines the size, ctime and mtime of the image file into a "unique" hash
65 \param url location of the image
66 \return a hash string for this image
68 bool CacheTexture(std::unique_ptr
<CTexture
>* texture
= nullptr);
70 static bool ResizeTexture(const std::string
& url
,
73 CPictureScalingAlgorithm::Algorithm scalingAlgorithm
,
78 std::string m_oldHash
;
79 CTextureDetails m_details
;
81 /*! \brief retrieve a hash for the given image
82 Combines the size, ctime and mtime of the image file into a "unique" hash
83 \param url location of the image
84 \return a hash string for this image
86 static std::string
GetImageHash(const std::string
&url
);
88 /*! \brief Load an image at a given target size and orientation.
90 Doesn't necessarily load the image at the desired size - the loader *may* decide to load it slightly larger
91 or smaller than the desired size for speed reasons.
93 \param image the URL of the image file.
94 \return a pointer to a CTexture object, NULL if failed.
96 static std::unique_ptr
<CTexture
> LoadImage(const IMAGE_FILES::CImageFileURL
& imageURL
);
98 std::string m_cachePath
;
101 /* \brief Job class for storing the use count of textures
103 class CTextureUseCountJob
: public CJob
106 explicit CTextureUseCountJob(const std::vector
<CTextureDetails
> &textures
);
108 const char* GetType() const override
{ return "usecount"; }
109 bool operator==(const CJob
*job
) const override
;
110 bool DoWork() override
;
113 std::vector
<CTextureDetails
> m_textures
;