deallocateTexture method
void
deallocateTexture(
- Texture texture
)
Implementation
void deallocateTexture(Texture texture) {
var textureProperties = properties.get(texture);
if (textureProperties["__webglInit"] == null) return;
// check if it's necessary to remove the WebGLTexture object
var source = texture.source;
var webglTextures = _sources.get(source);
if (webglTextures != null) {
Map webglTexture = webglTextures[textureProperties["__cacheKey"]];
webglTexture["usedTimes"]--;
// the WebGLTexture object is not used anymore, remove it
if (webglTexture["usedTimes"] == 0) {
deleteTexture(texture);
}
// remove the weak map entry if no WebGLTexture uses the source anymore
if (webglTextures.keys.length == 0) {
_sources.delete(source);
}
}
properties.remove(texture);
}