2 * Copyright (C) 2005-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 "GUIComponent.h"
12 #include "TextureBundle.h"
13 #include "threads/CriticalSection.h"
26 /************************************************************************/
28 /************************************************************************/
32 CTextureArray(int width
, int height
, int loops
, bool texCoordsArePixels
= false);
35 virtual ~CTextureArray();
39 void Add(std::shared_ptr
<CTexture
> texture
, int delay
);
40 void Set(std::shared_ptr
<CTexture
> texture
, int width
, int height
);
42 unsigned int size() const;
44 std::vector
<std::shared_ptr
<CTexture
>> m_textures
;
45 std::vector
<int> m_delays
;
52 bool m_texCoordsArePixels
;
59 /************************************************************************/
61 /************************************************************************/
66 CTextureMap(const std::string
& textureName
, int width
, int height
, int loops
);
67 virtual ~CTextureMap();
69 void Add(std::unique_ptr
<CTexture
> texture
, int delay
);
72 const std::string
& GetName() const;
73 const CTextureArray
& GetTexture();
75 uint32_t GetMemoryUsage() const;
78 void SetHeight(int height
);
79 void SetWidth(int height
);
83 CTextureArray m_texture
;
84 std::string m_textureName
;
85 unsigned int m_referenceCount
;
93 /************************************************************************/
95 /************************************************************************/
96 class CGUITextureManager
99 CGUITextureManager(void);
100 virtual ~CGUITextureManager(void);
102 bool HasTexture(const std::string
&textureName
, std::string
*path
= NULL
, int *bundle
= NULL
, int *size
= NULL
);
103 static bool CanLoad(const std::string
&texturePath
); ///< Returns true if the texture manager can load this texture
104 const CTextureArray
& Load(const std::string
& strTextureName
, bool checkBundleOnly
= false);
105 void ReleaseTexture(const std::string
& strTextureName
, bool immediately
= false);
108 uint32_t GetMemoryUsage() const;
110 std::string
GetTexturePath(const std::string
& textureName
, bool directory
= false);
111 std::vector
<std::string
> GetBundledTexturesFromPath(const std::string
& texturePath
);
113 void AddTexturePath(const std::string
&texturePath
); ///< Add a new path to the paths to check when loading media
114 void SetTexturePath(const std::string
&texturePath
); ///< Set a single path as the path to check when loading media (clear then add)
115 void RemoveTexturePath(const std::string
&texturePath
); ///< Remove a path from the paths to check when loading media
117 void FreeUnusedTextures(unsigned int timeDelay
= 0); ///< Free textures (called from app thread only)
118 void ReleaseHwTexture(unsigned int texture
);
120 std::vector
<CTextureMap
*> m_vecTextures
;
121 std::list
<std::pair
<CTextureMap
*, std::chrono::time_point
<std::chrono::steady_clock
>>>
123 std::vector
<unsigned int> m_unusedHwTextures
;
124 typedef std::vector
<CTextureMap
*>::iterator ivecTextures
;
125 // we have 2 texture bundles (one for the base textures, one for the theme)
126 CTextureBundle m_TexBundle
[2];
128 std::vector
<std::string
> m_texturePaths
;
129 CCriticalSection m_section
;