Kodi Docs 20.0
Kodi is an open source media player and entertainment hub.
CTexture Class Referenceabstract

Base texture class, subclasses of which depend on the render spec (DX, GL etc.) More...

#include <Texture.h>

Inheritance diagram for CTexture:
CDXTexture CGLTexture

Public Member Functions

 CTexture (unsigned int width=0, unsigned int height=0, unsigned int format=XB_FMT_A8R8G8B8)
 
virtual ~CTexture ()
 
bool LoadFromMemory (unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, bool hasAlpha, const unsigned char *pixels)
 
bool LoadPaletted (unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, const COLOR *palette)
 
bool HasAlpha () const
 
void SetMipmapping ()
 
bool IsMipmapped () const
 
void SetScalingMethod (TEXTURE_SCALING scalingMethod)
 
TEXTURE_SCALING GetScalingMethod () const
 
void SetCacheMemory (bool bCacheMemory)
 
bool GetCacheMemory () const
 
virtual void CreateTextureObject ()=0
 
virtual void DestroyTextureObject ()=0
 
virtual void LoadToGPU ()=0
 
virtual void BindToUnit (unsigned int unit)=0
 
unsigned char * GetPixels () const
 
unsigned int GetPitch () const
 
unsigned int GetRows () const
 
unsigned int GetTextureWidth () const
 
unsigned int GetTextureHeight () const
 
unsigned int GetWidth () const
 
unsigned int GetHeight () const
 
unsigned int GetOriginalWidth () const
 return the original width of the image, before scaling/cropping More...
 
unsigned int GetOriginalHeight () const
 return the original height of the image, before scaling/cropping More...
 
int GetOrientation () const
 
void SetOrientation (int orientation)
 
void Update (unsigned int width, unsigned int height, unsigned int pitch, unsigned int format, const unsigned char *pixels, bool loadToGPU)
 
void Allocate (unsigned int width, unsigned int height, unsigned int format)
 
void ClampToEdge ()
 

Static Public Member Functions

static std::unique_ptr< CTextureCreateTexture (unsigned int width=0, unsigned int height=0, unsigned int format=XB_FMT_A8R8G8B8)
 
static std::unique_ptr< CTextureLoadFromFile (const std::string &texturePath, unsigned int idealWidth=0, unsigned int idealHeight=0, bool requirePixels=false, const std::string &strMimeType="")
 Load a texture from a file Loads a texture from a file, restricting in size if needed based on maxHeight and maxWidth. Note that these are the ideal size to load at - the returned texture may be smaller or larger than these. More...
 
static std::unique_ptr< CTextureLoadFromFileInMemory (unsigned char *buffer, size_t bufferSize, const std::string &mimeType, unsigned int idealWidth=0, unsigned int idealHeight=0)
 Load a texture from a file in memory Loads a texture from a file in memory, restricting in size if needed based on maxHeight and maxWidth. Note that these are the ideal size to load at - the returned texture may be smaller or larger than these. More...
 
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)
 

Protected Member Functions

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)
 
unsigned int GetPitch (unsigned int width) const
 
unsigned int GetRows (unsigned int height) const
 
unsigned int GetBlockSize () const
 

Protected Attributes

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 More...
 
unsigned int m_originalHeight
 original image height before scaling or cropping More...
 
unsigned char * m_pixels
 
bool m_loadedToGPU
 
unsigned int m_format
 
int m_orientation
 
bool m_hasAlpha = true
 
bool m_mipmapping = false
 
TEXTURE_SCALING m_scalingMethod = TEXTURE_SCALING::LINEAR
 
bool m_bCacheMemory = false
 

Detailed Description

Base texture class, subclasses of which depend on the render spec (DX, GL etc.)

Constructor & Destructor Documentation

◆ CTexture()

CTexture::CTexture ( unsigned int  width = 0,
unsigned int  height = 0,
unsigned int  format = XB_FMT_A8R8G8B8 
)

◆ ~CTexture()

CTexture::~CTexture ( )
virtual

Member Function Documentation

◆ Allocate()

void CTexture::Allocate ( unsigned int  width,
unsigned int  height,
unsigned int  format 
)

◆ BindToUnit()

virtual void CTexture::BindToUnit ( unsigned int  unit)
pure virtual

Implemented in CDXTexture, and CGLTexture.

◆ ClampToEdge()

void CTexture::ClampToEdge ( )

◆ CreateTexture()

std::unique_ptr< CTexture > CTexture::CreateTexture ( unsigned int  width = 0,
unsigned int  height = 0,
unsigned int  format = XB_FMT_A8R8G8B8 
)
static

◆ CreateTextureObject()

virtual void CTexture::CreateTextureObject ( )
pure virtual

Implemented in CDXTexture, and CGLTexture.

◆ DestroyTextureObject()

virtual void CTexture::DestroyTextureObject ( )
pure virtual

Implemented in CDXTexture, and CGLTexture.

◆ GetBlockSize()

unsigned int CTexture::GetBlockSize ( ) const
protected

◆ GetCacheMemory()

bool CTexture::GetCacheMemory ( ) const
inline

◆ GetHeight()

unsigned int CTexture::GetHeight ( ) const
inline

◆ GetOrientation()

int CTexture::GetOrientation ( ) const
inline

◆ GetOriginalHeight()

unsigned int CTexture::GetOriginalHeight ( ) const
inline

return the original height of the image, before scaling/cropping

◆ GetOriginalWidth()

unsigned int CTexture::GetOriginalWidth ( ) const
inline

return the original width of the image, before scaling/cropping

◆ GetPitch() [1/2]

unsigned int CTexture::GetPitch ( ) const
inline

◆ GetPitch() [2/2]

unsigned int CTexture::GetPitch ( unsigned int  width) const
protected

◆ GetPixels()

unsigned char * CTexture::GetPixels ( ) const
inline

◆ GetRows() [1/2]

unsigned int CTexture::GetRows ( ) const
inline

◆ GetRows() [2/2]

unsigned int CTexture::GetRows ( unsigned int  height) const
protected

◆ GetScalingMethod()

TEXTURE_SCALING CTexture::GetScalingMethod ( ) const
inline

◆ GetTextureHeight()

unsigned int CTexture::GetTextureHeight ( ) const
inline

◆ GetTextureWidth()

unsigned int CTexture::GetTextureWidth ( ) const
inline

◆ GetWidth()

unsigned int CTexture::GetWidth ( ) const
inline

◆ HasAlpha()

bool CTexture::HasAlpha ( ) const

◆ IsMipmapped()

bool CTexture::IsMipmapped ( ) const

◆ LoadFromFile()

std::unique_ptr< CTexture > CTexture::LoadFromFile ( const std::string &  texturePath,
unsigned int  idealWidth = 0,
unsigned int  idealHeight = 0,
bool  requirePixels = false,
const std::string &  strMimeType = "" 
)
static

Load a texture from a file Loads a texture from a file, restricting in size if needed based on maxHeight and maxWidth. Note that these are the ideal size to load at - the returned texture may be smaller or larger than these.

Parameters
texturePaththe path of the texture to load.
idealWidththe ideal width of the texture (defaults to 0, no ideal width).
idealHeightthe ideal height of the texture (defaults to 0, no ideal height).
strMimeTypemimetype of the given texture if available (defaults to empty)
Returns
a CTexture std::unique_ptr to the created texture - nullptr if the texture failed to load.

◆ LoadFromFileInMem()

bool CTexture::LoadFromFileInMem ( unsigned char *  buffer,
size_t  size,
const std::string &  mimeType,
unsigned int  maxWidth,
unsigned int  maxHeight 
)
protected

◆ LoadFromFileInMemory()

std::unique_ptr< CTexture > CTexture::LoadFromFileInMemory ( unsigned char *  buffer,
size_t  bufferSize,
const std::string &  mimeType,
unsigned int  idealWidth = 0,
unsigned int  idealHeight = 0 
)
static

Load a texture from a file in memory Loads a texture from a file in memory, restricting in size if needed based on maxHeight and maxWidth. Note that these are the ideal size to load at - the returned texture may be smaller or larger than these.

Parameters
bufferthe memory buffer holding the file.
bufferSizethe size of buffer.
mimeTypethe mime type of the file in buffer.
idealWidththe ideal width of the texture (defaults to 0, no ideal width).
idealHeightthe ideal height of the texture (defaults to 0, no ideal height).
Returns
a CTexture std::unique_ptr to the created texture - nullptr if the texture failed to load.

◆ LoadFromFileInternal()

bool CTexture::LoadFromFileInternal ( const std::string &  texturePath,
unsigned int  maxWidth,
unsigned int  maxHeight,
bool  requirePixels,
const std::string &  strMimeType = "" 
)
protected

◆ LoadFromMemory()

bool CTexture::LoadFromMemory ( unsigned int  width,
unsigned int  height,
unsigned int  pitch,
unsigned int  format,
bool  hasAlpha,
const unsigned char *  pixels 
)

◆ LoadIImage()

bool CTexture::LoadIImage ( IImage pImage,
unsigned char *  buffer,
unsigned int  bufSize,
unsigned int  width,
unsigned int  height 
)
protected

◆ LoadPaletted()

bool CTexture::LoadPaletted ( unsigned int  width,
unsigned int  height,
unsigned int  pitch,
unsigned int  format,
const unsigned char *  pixels,
const COLOR palette 
)

◆ LoadToGPU()

virtual void CTexture::LoadToGPU ( )
pure virtual

Implemented in CDXTexture, and CGLTexture.

◆ PadPow2()

unsigned int CTexture::PadPow2 ( unsigned int  x)
static

◆ SetCacheMemory()

void CTexture::SetCacheMemory ( bool  bCacheMemory)
inline

◆ SetMipmapping()

void CTexture::SetMipmapping ( )

◆ SetOrientation()

void CTexture::SetOrientation ( int  orientation)
inline

◆ SetScalingMethod()

void CTexture::SetScalingMethod ( TEXTURE_SCALING  scalingMethod)
inline

◆ SwapBlueRed()

bool CTexture::SwapBlueRed ( unsigned char *  pixels,
unsigned int  height,
unsigned int  pitch,
unsigned int  elements = 4,
unsigned int  offset = 0 
)
static

◆ Update()

void CTexture::Update ( unsigned int  width,
unsigned int  height,
unsigned int  pitch,
unsigned int  format,
const unsigned char *  pixels,
bool  loadToGPU 
)

Member Data Documentation

◆ m_bCacheMemory

bool CTexture::m_bCacheMemory = false
protected

◆ m_format

unsigned int CTexture::m_format
protected

◆ m_hasAlpha

bool CTexture::m_hasAlpha = true
protected

◆ m_imageHeight

unsigned int CTexture::m_imageHeight
protected

◆ m_imageWidth

unsigned int CTexture::m_imageWidth
protected

◆ m_loadedToGPU

bool CTexture::m_loadedToGPU
protected

◆ m_mipmapping

bool CTexture::m_mipmapping = false
protected

◆ m_orientation

int CTexture::m_orientation
protected

◆ m_originalHeight

unsigned int CTexture::m_originalHeight
protected

original image height before scaling or cropping

◆ m_originalWidth

unsigned int CTexture::m_originalWidth
protected

original image width before scaling or cropping

◆ m_pixels

unsigned char* CTexture::m_pixels
protected

◆ m_scalingMethod

TEXTURE_SCALING CTexture::m_scalingMethod = TEXTURE_SCALING::LINEAR
protected

◆ m_textureHeight

unsigned int CTexture::m_textureHeight
protected

◆ m_textureWidth

unsigned int CTexture::m_textureWidth
protected

The documentation for this class was generated from the following files: