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>
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.
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 void addImageAsync |
( |
const std::string & |
filepath, |
|
|
const std::function< void(Texture2D *)> & |
callback |
|
) |
| |
|
virtual |
var addImageAsync |
( |
var |
filepath, |
|
|
var |
callback |
|
) |
| |
|
virtual |
local addImageAsync |
( |
local |
filepath, |
|
|
local |
callback |
|
) |
| |
|
virtual |
var addUIImage |
( |
var |
image, |
|
|
var |
key |
|
) |
| |
|
inline |
local addUIImage |
( |
local |
image, |
|
|
local |
key |
|
) |
| |
|
inline |
static void destroyInstance |
( |
| ) |
|
|
static |
purges the cache.
It releases the retained instance.
- Since
- v0.99.0
purges the cache.
It releases the retained instance.
- Since
- v0.99.0
local destroyInstance |
( |
| ) |
|
|
static |
purges the cache.
It releases the retained instance.
- Since
- v0.99.0
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.
- Since
- v1.0
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.
- Since
- v1.0
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.
- Since
- v1.0
virtual std::string getDescription |
( |
| ) |
const |
|
virtual |
Returns the shared instance of the cache.
Returns the shared instance of the cache.
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.
- Since
- v0.99.5
var getTextureForKey |
( |
var |
key | ) |
|
Returns an already created texture.
Returns nil if the texture doesn't exist.
- Since
- v0.99.5
local getTextureForKey |
( |
local |
key | ) |
|
Returns an already created texture.
Returns nil if the texture doesn't exist.
- Since
- v0.99.5
static void purgeSharedTextureCache |
( |
| ) |
|
|
static |
var purgeSharedTextureCache |
( |
| ) |
|
|
static |
local purgeSharedTextureCache |
( |
| ) |
|
|
static |
static void reloadAllTextures |
( |
| ) |
|
|
static |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures.
var reloadAllTextures |
( |
| ) |
|
|
static |
Reload all textures should not call it, called by frame work now the function do nothing, use VolatileTextureMgr::reloadAllTextures.
local 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
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.
- Since
- v0.99.4
var removeTextureForKey |
( |
var |
key | ) |
|
Deletes a texture from the cache given a its key name.
- Since
- v0.99.4
local removeTextureForKey |
( |
local |
key | ) |
|
Deletes a texture from the cache given a its key name.
- Since
- v0.99.4
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.
- Since
- v0.8
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.
- Since
- v0.8
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.
- Since
- v0.8
var sharedTextureCache |
( |
| ) |
|
|
static |
local sharedTextureCache |
( |
| ) |
|
|
static |
Texture2D* textureForKey |
( |
const std::string & |
key | ) |
const |
|
inline |
var textureForKey |
( |
var |
key | ) |
|
|
inline |
local textureForKey |
( |
local |
key | ) |
|
|
inline |
virtual void unbindAllImageAsync |
( |
| ) |
|
|
virtual |
var unbindAllImageAsync |
( |
| ) |
|
|
virtual |
local unbindAllImageAsync |
( |
| ) |
|
|
virtual |
virtual void unbindImageAsync |
( |
const std::string & |
filename | ) |
|
|
virtual |
var unbindImageAsync |
( |
var |
filename | ) |
|
|
virtual |
local unbindImageAsync |
( |
local |
filename | ) |
|
|
virtual |
std::mutex _asyncStructQueueMutex |
|
protected |
var _asyncStructQueueMutex |
|
protected |
local _asyncStructQueueMutex |
|
protected |
std::mutex _imageInfoMutex |
|
protected |
std::thread* _loadingThread |
|
protected |
std::condition_variable
_sleepCondition |
|
protected |
std::unordered_map<std::string,
Texture2D*> _textures |
|
protected |
The documentation for this class was generated from the following file: