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 () | |
virtual | ~TextureCache () |
const char * | description (void) 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, Object *target, SEL_CallFuncO selector) |
local | addImageAsync ( local filepath, local target, local selector) |
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... | |
CC_DEPRECATED_ATTRIBUTE Texture2D * | addUIImage (Image *image, const char *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... | |
CC_DEPRECATED_ATTRIBUTE Texture2D * | textureForKey (const char *key) const |
local | textureForKey ( local key) |
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... | |
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... | |
void | dumpCachedTextureInfo () 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... | |
Public Member Functions inherited from Object | |
Object () | |
Constructor. More... | |
virtual | ~Object () |
void | release () |
Release the ownership immediately. More... | |
void | retain () |
Retains the ownership. More... | |
Object * | autorelease () |
Release the ownership sometime soon automatically. More... | |
bool | isSingleReference () const |
Returns a boolean value that indicates whether there is only one reference to the object. More... | |
unsigned int | retainCount () const |
Returns the object's current reference count. More... | |
virtual bool | isEqual (const Object *object) |
Returns a boolean value that indicates whether this object and a given object are equal. More... | |
virtual void | acceptVisitor (DataVisitor &visitor) |
virtual void | update (float dt) |
Static Public Member Functions | |
static TextureCache * | getInstance () |
Returns the shared instance of the cache. More... | |
var | getInstance () |
Returns the shared instance of the cache. More... | |
local | getInstance () |
Returns the shared instance of the cache. More... | |
static CC_DEPRECATED_ATTRIBUTE TextureCache * | sharedTextureCache () |
local | sharedTextureCache () |
static void | destroyInstance () |
purges the cache. More... | |
var | destroyInstance () |
purges the cache. More... | |
local | destroyInstance () |
purges the cache. More... | |
static CC_DEPRECATED_ATTRIBUTE void | purgeSharedTextureCache () |
local | purgeSharedTextureCache () |
static void | reloadAllTextures () |
Reload all textures It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1. More... | |
Protected Attributes | |
std::thread * | _loadingThread |
var | _loadingThread |
local | _loadingThread |
std::queue< AsyncStruct * > * | _asyncStructQueue |
var | _asyncStructQueue |
local | _asyncStructQueue |
std::queue< ImageInfo * > * | _imageInfoQueue |
var | _imageInfoQueue |
local | _imageInfoQueue |
std::mutex | _asyncStructQueueMutex |
std::mutex | _imageInfoMutex |
std::mutex | _sleepMutex |
var | _sleepMutex |
local | _sleepMutex |
std::condition_variable | _sleepCondition |
var | _sleepCondition |
local | _sleepCondition |
bool | _needQuit |
int | _asyncRefCount |
var | _asyncRefCount |
local | _asyncRefCount |
std::unordered_map < std::string, Texture2D * > | _textures |
Protected Attributes inherited from Object | |
unsigned int | _reference |
count of references More... | |
var | _reference |
count of references More... | |
local | _reference |
count of references More... | |
unsigned int | _autoReleaseCount |
count of autorelease More... | |
var | _autoReleaseCount |
count of autorelease More... | |
local | _autoReleaseCount |
count of autorelease More... | |
Static Protected Attributes | |
static TextureCache * | _sharedTextureCache |
var | _sharedTextureCache |
local | _sharedTextureCache |
Additional Inherited Members | |
Public Attributes inherited from Object | |
unsigned int | _ID |
object id, ScriptSupport need public _ID More... | |
int | _luaID |
Lua reference id. 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, .gif
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, .gif
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, .gif
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 |
|
inline |
const char* description | ( | void | ) | const |
|
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.
void dumpCachedTextureInfo | ( | ) | 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 dumpCachedTextureInfo | ( | ) |
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 dumpCachedTextureInfo | ( | ) |
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.
|
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.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
Reload all textures It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1.
|
static |
Reload all textures It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1.
|
static |
Reload all textures It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1.
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.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |