deallocateTexture method

void deallocateTexture(
  1. Texture texture
)

Implementation

void deallocateTexture(Texture texture) {
  final textureProperties = properties.get(texture);

  if (textureProperties["__webglInit"] == null) return;

  final source = texture.source;
  final webglTextures = _sources.get(source);

  if (webglTextures != null) {
    Map webglTexture = webglTextures[textureProperties["__cacheKey"]];
    webglTexture["usedTimes"]--;

    if (webglTexture["usedTimes"] == 0) {
      deleteTexture(texture);
    }

    if (webglTextures.keys.length == 0) {
      _sources.delete(source);
    }
  }

  properties.remove(texture);
}