Minetest  5.4.0
TextureSource Class Reference
+ Inheritance diagram for TextureSource:
+ Collaboration diagram for TextureSource:

Public Member Functions

 TextureSource ()
 
virtual ~TextureSource ()
 
u32 getTextureId (const std::string &name)
 
std::string getTextureName (u32 id)
 
video::ITexture * getTexture (u32 id)
 
video::ITexture * getTexture (const std::string &name, u32 *id=NULL)
 
video::ITexture * getTextureForMesh (const std::string &name, u32 *id)
 
virtual PalettegetPalette (const std::string &name)
 
bool isKnownSourceImage (const std::string &name)
 
void processQueue ()
 
void insertSourceImage (const std::string &name, video::IImage *img)
 
void rebuildImagesAndTextures ()
 
video::ITexture * getNormalTexture (const std::string &name)
 
video::SColor getTextureAverageColor (const std::string &name)
 
video::ITexture * getShaderFlagsTexture (bool normamap_present)
 
- Public Member Functions inherited from IWritableTextureSource
 IWritableTextureSource ()=default
 
virtual ~IWritableTextureSource ()=default
 
- Public Member Functions inherited from ITextureSource
 ITextureSource ()=default
 
virtual ~ITextureSource ()=default
 
- Public Member Functions inherited from ISimpleTextureSource
 ISimpleTextureSource ()=default
 
virtual ~ISimpleTextureSource ()=default
 

Private Member Functions

u32 generateTexture (const std::string &name)
 
bool generateImagePart (std::string part_of_name, video::IImage *&baseimg)
 
video::IImage * generateImage (const std::string &name)
 

Private Attributes

std::thread::id m_main_thread
 
SourceImageCache m_sourcecache
 
MutexedMap< std::string, bool > m_source_image_existence
 
std::vector< TextureInfom_textureinfo_cache
 
std::map< std::string, u32 > m_name_to_id
 
std::mutex m_textureinfo_cache_mutex
 
RequestQueue< std::string, u32, u8, u8 > m_get_texture_queue
 
std::vector< video::ITexture * > m_texture_trash
 
std::unordered_map< std::string, Palettem_palettes
 
bool m_setting_trilinear_filter
 
bool m_setting_bilinear_filter
 

Constructor & Destructor Documentation

◆ TextureSource()

TextureSource::TextureSource ( )

References g_settings, Settings::getBool(), m_main_thread, m_name_to_id, m_setting_bilinear_filter, m_setting_trilinear_filter, and m_textureinfo_cache.

+ Here is the call graph for this function:

◆ ~TextureSource()

TextureSource::~TextureSource ( )
virtual

References RenderingEngine::get_video_driver(), infostream, m_texture_trash, and m_textureinfo_cache.

+ Here is the call graph for this function:

Member Function Documentation

◆ generateImage()

video::IImage * TextureSource::generateImage ( const std::string &  name)
private

Generates an image from a full string like "stone.png^mineral_coal.png^[crack:1:0". Shall be called from the main thread. The returned Image should be dropped.

References blit_with_alpha(), errorstream, and generateImagePart().

Referenced by generateImagePart(), generateTexture(), getPalette(), and rebuildImagesAndTextures().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateImagePart()

bool TextureSource::generateImagePart ( std::string  part_of_name,
video::IImage *&  baseimg 
)
private

◆ generateTexture()

u32 TextureSource::generateTexture ( const std::string &  name)
private

References errorstream, generateImage(), RenderingEngine::get_video_driver(), guiScalingCache(), infostream, m_main_thread, m_name_to_id, m_textureinfo_cache, m_textureinfo_cache_mutex, and sanity_check.

Referenced by getTextureId(), and processQueue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNormalTexture()

video::ITexture * TextureSource::getNormalTexture ( const std::string &  name)
virtual

Implements IWritableTextureSource.

References getTexture(), and isKnownSourceImage().

+ Here is the call graph for this function:

◆ getPalette()

Palette * TextureSource::getPalette ( const std::string &  name)
virtual

Returns a palette from the given texture name. The pointer is valid until the texture source is destructed. Should be called from the main thread.

Implements ITextureSource.

References generateImage(), m_main_thread, m_palettes, sanity_check, and warningstream.

+ Here is the call graph for this function:

◆ getShaderFlagsTexture()

video::ITexture * TextureSource::getShaderFlagsTexture ( bool  normamap_present)
virtual

Implements IWritableTextureSource.

References RenderingEngine::get_video_driver(), getTexture(), insertSourceImage(), isKnownSourceImage(), and sanity_check.

+ Here is the call graph for this function:

◆ getTexture() [1/2]

video::ITexture * TextureSource::getTexture ( const std::string &  name,
u32 *  id = NULL 
)
virtual

Implements IWritableTextureSource.

References getTexture(), and getTextureId().

+ Here is the call graph for this function:

◆ getTexture() [2/2]

video::ITexture * TextureSource::getTexture ( u32  id)
virtual

Implements IWritableTextureSource.

References m_textureinfo_cache, and m_textureinfo_cache_mutex.

Referenced by getNormalTexture(), getShaderFlagsTexture(), getTexture(), getTextureAverageColor(), and getTextureForMesh().

+ Here is the caller graph for this function:

◆ getTextureAverageColor()

video::SColor TextureSource::getTextureAverageColor ( const std::string &  name)
virtual

Implements IWritableTextureSource.

References RenderingEngine::get_video_driver(), and getTexture().

+ Here is the call graph for this function:

◆ getTextureForMesh()

video::ITexture * TextureSource::getTextureForMesh ( const std::string &  name,
u32 *  id 
)
virtual

Implements ITextureSource.

References g_settings, Settings::getBool(), Settings::getS32(), getTexture(), m_setting_bilinear_filter, and m_setting_trilinear_filter.

+ Here is the call graph for this function:

◆ getTextureId()

u32 TextureSource::getTextureId ( const std::string &  name)
virtual

Implements IWritableTextureSource.

References RequestQueue< Key, T, Caller, CallerData >::add(), errorstream, generateTexture(), infostream, GetResult< Key, T, Caller, CallerData >::item, GetResult< Key, T, Caller, CallerData >::key, m_get_texture_queue, m_main_thread, m_name_to_id, m_textureinfo_cache_mutex, and MutexedQueue< T >::pop_front().

Referenced by getTexture().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextureName()

std::string TextureSource::getTextureName ( u32  id)
virtual

◆ insertSourceImage()

void TextureSource::insertSourceImage ( const std::string &  name,
video::IImage *  img 
)
virtual

Implements IWritableTextureSource.

References SourceImageCache::insert(), m_main_thread, m_source_image_existence, m_sourcecache, sanity_check, and MutexedMap< Key, Value >::set().

Referenced by getShaderFlagsTexture().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isKnownSourceImage()

bool TextureSource::isKnownSourceImage ( const std::string &  name)
inlinevirtual

Implements IWritableTextureSource.

References MutexedMap< Key, Value >::get(), getTexturePath(), m_source_image_existence, and MutexedMap< Key, Value >::set().

Referenced by getNormalTexture(), and getShaderFlagsTexture().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processQueue()

void TextureSource::processQueue ( )
virtual

Implements IWritableTextureSource.

References RequestQueue< Key, T, Caller, CallerData >::empty(), generateTexture(), GetRequest< Key, T, Caller, CallerData >::key, m_get_texture_queue, RequestQueue< Key, T, Caller, CallerData >::pop(), and RequestQueue< Key, T, Caller, CallerData >::pushResult().

+ Here is the call graph for this function:

◆ rebuildImagesAndTextures()

void TextureSource::rebuildImagesAndTextures ( )
virtual

Implements IWritableTextureSource.

References generateImage(), RenderingEngine::get_video_driver(), guiScalingCache(), infostream, m_texture_trash, m_textureinfo_cache, m_textureinfo_cache_mutex, and sanity_check.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_get_texture_queue

RequestQueue<std::string, u32, u8, u8> TextureSource::m_get_texture_queue
private

Referenced by getTextureId(), and processQueue().

◆ m_main_thread

std::thread::id TextureSource::m_main_thread
private

◆ m_name_to_id

std::map<std::string, u32> TextureSource::m_name_to_id
private

◆ m_palettes

std::unordered_map<std::string, Palette> TextureSource::m_palettes
private

Referenced by getPalette().

◆ m_setting_bilinear_filter

bool TextureSource::m_setting_bilinear_filter
private

◆ m_setting_trilinear_filter

bool TextureSource::m_setting_trilinear_filter
private

◆ m_source_image_existence

MutexedMap<std::string, bool> TextureSource::m_source_image_existence
private

◆ m_sourcecache

SourceImageCache TextureSource::m_sourcecache
private

◆ m_texture_trash

std::vector<video::ITexture*> TextureSource::m_texture_trash
private

◆ m_textureinfo_cache

std::vector<TextureInfo> TextureSource::m_textureinfo_cache
private

◆ m_textureinfo_cache_mutex

std::mutex TextureSource::m_textureinfo_cache_mutex
private

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