11 #include "TextureManager.h" 13 #include "utils/ColorUtils.h" 14 #include "utils/Geometry.h" 19 #define ASPECT_ALIGN_CENTER 0 20 #define ASPECT_ALIGN_LEFT 1 21 #define ASPECT_ALIGN_RIGHT 2 22 #define ASPECT_ALIGNY_CENTER 0 23 #define ASPECT_ALIGNY_TOP 4 24 #define ASPECT_ALIGNY_BOTTOM 8 25 #define ASPECT_ALIGN_MASK 3 26 #define ASPECT_ALIGNY_MASK ~3 31 enum ASPECT_RATIO { AR_STRETCH = 0, AR_SCALE, AR_KEEP, AR_CENTER };
35 align = ASPECT_ALIGN_CENTER | ASPECT_ALIGNY_CENTER;
40 if (ratio != right.ratio)
return true;
41 if (align != right.align)
return true;
42 if (scaleDiffuse != right.scaleDiffuse)
return true;
68 using CreateGUITextureFunc = std::function<
CGUITexture*(
69 float posX,
float posY,
float width,
float height,
const CTextureInfo& texture)>;
70 using DrawQuadFunc = std::function<void(
71 const CRect& coords, UTILS::COLOR::Color color,
CTexture* texture,
const CRect* texCoords)>;
78 static void Register(
const CreateGUITextureFunc& createFunction,
79 const DrawQuadFunc& drawQuadFunction);
82 float posX,
float posY,
float width,
float height,
const CTextureInfo& texture);
85 static void DrawQuad(
const CRect& coords,
86 UTILS::COLOR::Color color,
88 const CRect* texCoords =
nullptr);
90 bool Process(
unsigned int currentTime);
93 void DynamicResourceAlloc(
bool bOnOff);
94 bool AllocResources();
95 void FreeResources(
bool immediately =
false);
98 bool SetVisible(
bool visible);
99 bool SetAlpha(
unsigned char alpha);
100 bool SetDiffuseColor(UTILS::COLOR::Color color,
const CGUIListItem* item =
nullptr);
101 bool SetPosition(
float x,
float y);
102 bool SetWidth(
float width);
103 bool SetHeight(
float height);
104 bool SetFileName(
const std::string &filename);
105 void SetUseCache(
const bool useCache =
true);
108 const std::string& GetFileName()
const {
return m_info.filename; }
109 float GetTextureWidth()
const {
return m_frameWidth; }
110 float GetTextureHeight()
const {
return m_frameHeight; }
111 float GetWidth()
const {
return m_width; }
112 float GetHeight()
const {
return m_height; }
113 float GetXPosition()
const {
return m_posX; }
114 float GetYPosition()
const {
return m_posY; }
115 int GetOrientation()
const;
116 const CRect& GetRenderRect()
const {
return m_vertex; }
117 bool IsLazyLoaded()
const {
return m_info.useLarge; }
125 bool HitTest(
const CPoint& point)
const 127 return CRect(m_posX, m_posY, m_posX + m_width, m_posY + m_height).PtInRect(point);
129 bool IsAllocated()
const {
return m_isAllocated != NO; }
130 bool FailedToAlloc()
const 132 return m_isAllocated == NORMAL_FAILED || m_isAllocated == LARGE_FAILED;
134 bool ReadyToRender()
const;
140 bool CalculateSize();
141 bool AllocateOnDemand();
142 bool UpdateAnimFrame(
unsigned int currentTime);
143 void Render(
float left,
153 static void OrientateTexture(
CRect &rect,
float width,
float height,
int orientation);
154 void ResetAnimState();
157 virtual void Allocate() {};
159 virtual void Begin(UTILS::COLOR::Color color) = 0;
160 virtual void Draw(
float* x,
163 const CRect& texture,
164 const CRect& diffuse,
165 int orientation) = 0;
166 virtual void End() = 0;
169 UTILS::COLOR::Color m_diffuseColor;
179 unsigned char m_alpha;
181 float m_frameWidth, m_frameHeight;
182 float m_texCoordsScaleU, m_texCoordsScaleV;
186 unsigned int m_currentFrame;
189 float m_diffuseU, m_diffuseV;
190 float m_diffuseScaleU, m_diffuseScaleV;
193 bool m_allocateDynamically;
194 enum ALLOCATE_TYPE { NO = 0, NORMAL, LARGE, NORMAL_FAILED, LARGE_FAILED };
195 ALLOCATE_TYPE m_isAllocated;
204 static CreateGUITextureFunc m_createGUITextureFunc;
205 static DrawQuadFunc m_drawQuadFunc;
Definition: GUIListItem.h:30
Definition: TextureManager.h:29
Definition: GUITexture.h:28
Base texture class, subclasses of which depend on the render spec (DX, GL etc.)
Definition: Texture.h:34
Definition: GUITexture.h:51
Definition: GUITexture.h:73
virtual void Free()
called after our textures have been allocated
Definition: GUITexture.h:158
KODI::GUILIB::GUIINFO::CGUIInfoColor GetDiffuseColor() const
Get the diffuse color (info color) associated to this texture.
Definition: GUITexture.h:123
Definition: GUIInfoColor.h:30