diff options
Diffstat (limited to 'xbmc/guilib/Texture.h')
-rw-r--r-- | xbmc/guilib/Texture.h | 75 |
1 files changed, 12 insertions, 63 deletions
diff --git a/xbmc/guilib/Texture.h b/xbmc/guilib/Texture.h index 5e32e60f8f..605d56b380 100644 --- a/xbmc/guilib/Texture.h +++ b/xbmc/guilib/Texture.h @@ -8,6 +8,7 @@ #pragma once +#include "guilib/TextureBase.h" #include "guilib/TextureFormats.h" #include <cstddef> @@ -21,17 +22,11 @@ class IImage; struct COLOR {unsigned char b,g,r,x;}; // Windows GDI expects 4bytes per color #pragma pack() -enum class TEXTURE_SCALING -{ - LINEAR, - NEAREST, -}; - /*! \ingroup textures -\brief Base texture class, subclasses of which depend on the render spec (DX, GL etc.) +\brief Texture loader class, subclasses of which depend on the render spec (DX, GL etc.) */ -class CTexture +class CTexture : public CTextureBase { public: @@ -86,47 +81,17 @@ public: const unsigned char* pixels, const COLOR* palette); - bool HasAlpha() const; - void SetAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; } - - void SetMipmapping(); - bool IsMipmapped() const; - void SetScalingMethod(TEXTURE_SCALING scalingMethod) { m_scalingMethod = scalingMethod; } - TEXTURE_SCALING GetScalingMethod() const { return m_scalingMethod; } - void SetCacheMemory(bool bCacheMemory) { m_bCacheMemory = bCacheMemory; } - bool GetCacheMemory() const { return m_bCacheMemory; } - - virtual void CreateTextureObject() = 0; - virtual void DestroyTextureObject() = 0; - virtual void LoadToGPU() = 0; - virtual void BindToUnit(unsigned int unit) = 0; - - unsigned char* GetPixels() const { return m_pixels; } - unsigned int GetPitch() const { return GetPitch(m_textureWidth); } - unsigned int GetRows() const { return GetRows(m_textureHeight); } - unsigned int GetTextureWidth() const { return m_textureWidth; } - unsigned int GetTextureHeight() const { return m_textureHeight; } - unsigned int GetWidth() const { return m_imageWidth; } - unsigned int GetHeight() const { return m_imageHeight; } - /*! \brief return the original width of the image, before scaling/cropping */ - unsigned int GetOriginalWidth() const { return m_originalWidth; } - /*! \brief return the original height of the image, before scaling/cropping */ - unsigned int GetOriginalHeight() const { return m_originalHeight; } - - int GetOrientation() const { return m_orientation; } - void SetOrientation(int orientation) { m_orientation = orientation; } - void Update(unsigned int width, unsigned int height, unsigned int pitch, XB_FMT format, const unsigned char* pixels, bool loadToGPU); - void Allocate(unsigned int width, unsigned int height, XB_FMT format); - void ClampToEdge(); - static unsigned int PadPow2(unsigned int x); - static bool SwapBlueRed(unsigned char *pixels, unsigned int height, unsigned int pitch, unsigned int elements = 4, unsigned int offset=0); + virtual void CreateTextureObject() = 0; + virtual void DestroyTextureObject() = 0; + virtual void LoadToGPU() = 0; + virtual void BindToUnit(unsigned int unit) = 0; private: // no copy constructor @@ -136,25 +101,9 @@ protected: bool LoadFromFileInMem(unsigned char* buffer, size_t size, const std::string& mimeType, unsigned int maxWidth, unsigned int maxHeight); bool LoadFromFileInternal(const std::string& texturePath, unsigned int maxWidth, unsigned int maxHeight, bool requirePixels, const std::string& strMimeType = ""); - bool LoadIImage(IImage* pImage, unsigned char* buffer, unsigned int bufSize, unsigned int width, unsigned int height); - // helpers for computation of texture parameters for compressed textures - unsigned int GetPitch(unsigned int width) const; - unsigned int GetRows(unsigned int height) const; - unsigned int GetBlockSize() const; - - unsigned int m_imageWidth; - unsigned int m_imageHeight; - unsigned int m_textureWidth; - unsigned int m_textureHeight; - unsigned int m_originalWidth; ///< original image width before scaling or cropping - unsigned int m_originalHeight; ///< original image height before scaling or cropping - - unsigned char* m_pixels; - bool m_loadedToGPU; - XB_FMT m_format; - int m_orientation; - bool m_hasAlpha = true ; - bool m_mipmapping = false ; - TEXTURE_SCALING m_scalingMethod = TEXTURE_SCALING::LINEAR; - bool m_bCacheMemory = false; + bool LoadIImage(IImage* pImage, + unsigned char* buffer, + unsigned int bufSize, + unsigned int width, + unsigned int height); }; |