|Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure|
Caches textures, ensuring no texture is loaded twice. More...
|Pointer to a texture backend with a reference count. |
Public Member Functions
|virtual TextureBackend *||get (const QString &name, const TextureLoadingMode loadingMode)|
|Get a pointer to a cached texture or NULL if not yet in cache. |
|virtual void||add (TextureBackend *backend)|
|Add a texture to the cache (setting its reference count to 1). |
|virtual void||remove (TextureBackend *backend)|
|Remove a texture from the cache. |
Caches textures, ensuring no texture is loaded twice.
StelTextureCache is templated by the textured backend used. This way e.g. StelQGLRenderer can have a texture cache storing StelQGLTextureBackend. The template argument class must have a member function called startAsynchronousLoading() which is called to start loading when a texture created with lazy loading mode is requested again with asynchronous or normal loading mode.
Textures are identified by their name, that is full filesystem path or URL. Generated textures without a name can't be cached. The cache keeps pointers to all textures with reference counts; when a texture with the same name is requested more than once, pointer to the previously created texture is returned and the reference count is incremented.
If a texture was created already with asynchronous/lazy loading mode is requested with normal loading mode, and isn't fully loaded yet, the cache waits until the texture loads and then returns it.
Similarly, if the texture was created with lazy loading mode, is requested with asynchronous mode and didn't start loading yet, loading is started and then the texture is returned.
|virtual void StelTextureCache< TextureBackend >::add||(||TextureBackend *||backend||)||
|virtual TextureBackend* StelTextureCache< TextureBackend >::get||(||const QString &||name,|
Get a pointer to a cached texture or NULL if not yet in cache.
If the texture is already in cache, its reference count is incremented when returing the pointer.
|name||Name of the texture to get.|
|loadingMode||Loading mode used when creating the texture. If the texture is cached but loaded asynchronously, it might not be fully loaded - so if loadingMode is Normal, we wait until it finishes loading. Similarly with lazy/normal or lazy/asynchronous.|
|virtual void StelTextureCache< TextureBackend >::remove||(||TextureBackend *||backend||)||