MCPcopy Create free account
hub / github.com/melonjs/melonJS / freeTextureUnit

Method freeTextureUnit

packages/melonjs/src/video/texture/cache.js:104–117  ·  view source on GitHub ↗

* @ignore * * Hot-path note: `getUnit` / `peekUnit` / `freeTextureUnit` are * called per-texture per-draw, so the `(source, repeat)` lookup is * inlined here rather than going through a helper that allocates a * `{source, repeat}` object on every call.

(texture)

Source from the content-addressed store, hash-verified

102 * `{source, repeat}` object on every call.
103 */
104 freeTextureUnit(texture) {
105 const source = texture.sources.get(texture.activeAtlas);
106 const repeat = normalizeRepeat(texture.repeat);
107 const perRepeat = this.units.get(source);
108 const unit = perRepeat?.get(repeat);
109 // was a texture unit allocated ?
110 if (typeof unit !== "undefined") {
111 this.usedUnits.delete(unit);
112 perRepeat.delete(repeat);
113 if (perRepeat.size === 0) {
114 this.units.delete(source);
115 }
116 }
117 }
118
119 /**
120 * @ignore

Callers 4

deleteMethod · 0.95
dropMethod · 0.80
texture.spec.jsFile · 0.80

Calls 3

normalizeRepeatFunction · 0.85
getMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected