Singleton that handles the loading of textures Once the texture is loaded, the next time it will return a reference of the previously loaded texture reducing GPU & CPU memory. More...
#include <CCTextureCache.h>
Classes | |
struct | AsyncStruct |
Public Member Functions | |
TextureCache () | |
TextureCache () | |
virtual | ~TextureCache () |
virtual std::string | getDescription () const |
Texture2D * | addImage (const std::string &filepath) |
Returns a Texture2D object given an filename. More... | |
local | addImage ( local filepath) |
Returns a Texture2D object given an filename. More... | |
virtual void | addImageAsync (const std::string &filepath, const std::function< void(Texture2D *)> &callback) |
virtual void | unbindImageAsync (const std::string &filename) |
virtual void | unbindAllImageAsync () |
local | unbindAllImageAsync () |
Texture2D * | addImage (Image *image, const std::string &key) |
Returns a Texture2D object given an Image. More... | |
local | addImage ( local image, local key) |
Returns a Texture2D object given an Image. More... | |
Texture2D * | addUIImage (Image *image, const std::string &key) |
local | addUIImage ( local image, local key) |
Texture2D * | getTextureForKey (const std::string &key) const |
Returns an already created texture. More... | |
var | getTextureForKey ( var key) |
Returns an already created texture. More... | |
local | getTextureForKey ( local key) |
Returns an already created texture. More... | |
Texture2D * | textureForKey (const std::string &key) const |
var | textureForKey ( var key) |
local | textureForKey ( local key) |
bool | reloadTexture (const std::string &fileName) |
Reload texture from the image file If the file image hasn't loaded before, load it. More... | |
void | removeAllTextures () |
Purges the dictionary of loaded textures. More... | |
void | removeUnusedTextures () |
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene. More... | |
local | removeUnusedTextures () |
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene. More... | |
void | removeTexture (Texture2D *texture) |
Deletes a texture from the cache given a texture. More... | |
void | removeTextureForKey (const std::string &key) |
Deletes a texture from the cache given a its key name. More... | |
local | removeTextureForKey ( local key) |
Deletes a texture from the cache given a its key name. More... | |
std::string | getCachedTextureInfo () const |
Output to CCLOG the current contents of this TextureCache This will attempt to calculate the size of each texture, and the total texture memory in use. More... | |
local | getCachedTextureInfo () |
Output to CCLOG the current contents of this TextureCache This will attempt to calculate the size of each texture, and the total texture memory in use. More... | |
void | waitForQuit () |
var | waitForQuit () |
local | waitForQuit () |
Public Member Functions inherited from Ref | |
void | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
Static Public Member Functions | |
static TextureCache * | getInstance () |
Returns the shared instance of the cache. More... | |
static TextureCache * | sharedTextureCache () |
var | sharedTextureCache () |
local | sharedTextureCache () |
static void | destroyInstance () |
purges the cache. More... | |
static void | purgeSharedTextureCache () |
local | purgeSharedTextureCache () |
static void | reloadAllTextures () |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures. More... | |
var | reloadAllTextures () |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures. More... | |
local | reloadAllTextures () |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures. More... | |
Protected Attributes | |
std::thread * | _loadingThread |
var | _loadingThread |
local | _loadingThread |
std::queue< AsyncStruct * > * | _asyncStructQueue |
var | _asyncStructQueue |
local | _asyncStructQueue |
std::deque< ImageInfo * > * | _imageInfoQueue |
var | _imageInfoQueue |
local | _imageInfoQueue |
std::mutex | _asyncStructQueueMutex |
var | _asyncStructQueueMutex |
local | _asyncStructQueueMutex |
std::mutex | _imageInfoMutex |
var | _imageInfoMutex |
local | _imageInfoMutex |
std::mutex | _sleepMutex |
var | _sleepMutex |
local | _sleepMutex |
std::condition_variable | _sleepCondition |
var | _sleepCondition |
local | _sleepCondition |
bool | _needQuit |
var | _needQuit |
local | _needQuit |
int | _asyncRefCount |
var | _asyncRefCount |
local | _asyncRefCount |
std::unordered_map < std::string, Texture2D * > | _textures |
Protected Attributes inherited from Ref | |
unsigned int | _referenceCount |
count of references More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Ref | |
Ref () | |
Constructor. More... | |
Singleton that handles the loading of textures Once the texture is loaded, the next time it will return a reference of the previously loaded texture reducing GPU & CPU memory.
TextureCache | ( | ) |
var ctor | ( | ) |
local TextureCache | ( | ) |
|
virtual |
Texture2D* addImage | ( | const std::string & | filepath | ) |
Returns a Texture2D object given an filename.
If the filename was not previously loaded, it will create a new Texture2D object and it will return it. It will use the filename as a key. Otherwise it will return a reference of a previously loaded image. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr
var addImage | ( | var | filepath | ) |
Returns a Texture2D object given an filename.
If the filename was not previously loaded, it will create a new Texture2D object and it will return it. It will use the filename as a key. Otherwise it will return a reference of a previously loaded image. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr
local addImage | ( | local | filepath | ) |
Returns a Texture2D object given an filename.
If the filename was not previously loaded, it will create a new Texture2D object and it will return it. It will use the filename as a key. Otherwise it will return a reference of a previously loaded image. Supported image extensions: .png, .bmp, .tiff, .jpeg, .pvr
Returns a Texture2D object given an Image.
If the image was not previously loaded, it will create a new Texture2D object and it will return it. Otherwise it will return a reference of a previously loaded image. The "key" parameter will be used as the "key" for the cache. If "key" is nil, then a new texture will be created each time.
var addImage | ( | var | image, |
var | key | ||
) |
Returns a Texture2D object given an Image.
If the image was not previously loaded, it will create a new Texture2D object and it will return it. Otherwise it will return a reference of a previously loaded image. The "key" parameter will be used as the "key" for the cache. If "key" is nil, then a new texture will be created each time.
local addImage | ( | local | image, |
local | key | ||
) |
Returns a Texture2D object given an Image.
If the image was not previously loaded, it will create a new Texture2D object and it will return it. Otherwise it will return a reference of a previously loaded image. The "key" parameter will be used as the "key" for the cache. If "key" is nil, then a new texture will be created each time.
|
virtual |
|
virtual |
|
virtual |
|
inline |
|
inline |
|
static |
purges the cache.
It releases the retained instance.
|
static |
purges the cache.
It releases the retained instance.
|
static |
purges the cache.
It releases the retained instance.
std::string getCachedTextureInfo | ( | ) | const |
Output to CCLOG the current contents of this TextureCache This will attempt to calculate the size of each texture, and the total texture memory in use.
var getCachedTextureInfo | ( | ) |
Output to CCLOG the current contents of this TextureCache This will attempt to calculate the size of each texture, and the total texture memory in use.
local getCachedTextureInfo | ( | ) |
Output to CCLOG the current contents of this TextureCache This will attempt to calculate the size of each texture, and the total texture memory in use.
|
virtual |
|
static |
Returns the shared instance of the cache.
|
static |
Returns the shared instance of the cache.
|
static |
Returns the shared instance of the cache.
Texture2D* getTextureForKey | ( | const std::string & | key | ) | const |
Returns an already created texture.
Returns nil if the texture doesn't exist.
var getTextureForKey | ( | var | key | ) |
Returns an already created texture.
Returns nil if the texture doesn't exist.
local getTextureForKey | ( | local | key | ) |
Returns an already created texture.
Returns nil if the texture doesn't exist.
|
static |
|
static |
|
static |
|
static |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures.
|
static |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures.
|
static |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures.
bool reloadTexture | ( | const std::string & | fileName | ) |
Reload texture from the image file If the file image hasn't loaded before, load it.
Otherwise the texture will be reloaded from the file image. The "filenName" parameter is the related/absolute path of the file image. Return true if the reloading is succeed, otherwise return false.
var reloadTexture | ( | var | fileName | ) |
Reload texture from the image file If the file image hasn't loaded before, load it.
Otherwise the texture will be reloaded from the file image. The "filenName" parameter is the related/absolute path of the file image. Return true if the reloading is succeed, otherwise return false.
local reloadTexture | ( | local | fileName | ) |
Reload texture from the image file If the file image hasn't loaded before, load it.
Otherwise the texture will be reloaded from the file image. The "filenName" parameter is the related/absolute path of the file image. Return true if the reloading is succeed, otherwise return false.
void removeAllTextures | ( | ) |
Purges the dictionary of loaded textures.
Call this method if you receive the "Memory Warning" In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same
var removeAllTextures | ( | ) |
Purges the dictionary of loaded textures.
Call this method if you receive the "Memory Warning" In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same
local removeAllTextures | ( | ) |
Purges the dictionary of loaded textures.
Call this method if you receive the "Memory Warning" In the short term: it will free some resources preventing your app from being killed In the medium term: it will allocate more resources In the long term: it will be the same
void removeTexture | ( | Texture2D * | texture | ) |
Deletes a texture from the cache given a texture.
var removeTexture | ( | var | texture | ) |
Deletes a texture from the cache given a texture.
local removeTexture | ( | local | texture | ) |
Deletes a texture from the cache given a texture.
void removeTextureForKey | ( | const std::string & | key | ) |
Deletes a texture from the cache given a its key name.
var removeTextureForKey | ( | var | key | ) |
Deletes a texture from the cache given a its key name.
local removeTextureForKey | ( | local | key | ) |
Deletes a texture from the cache given a its key name.
void removeUnusedTextures | ( | ) |
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene.
var removeUnusedTextures | ( | ) |
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene.
local removeUnusedTextures | ( | ) |
Removes unused textures Textures that have a retain count of 1 will be deleted It is convenient to call this method after when starting a new Scene.
|
static |
|
static |
|
static |
|
inline |
|
inline |
|
inline |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
void waitForQuit | ( | ) |
var waitForQuit | ( | ) |
local waitForQuit | ( | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |