@@ -254,32 +254,6 @@ export class CoreTextureManager {
254
254
}
255
255
}
256
256
257
- /**
258
- * Remove a `Texture` from the texture cache
259
- *
260
- * @param texture
261
- */
262
- removeTexture ( texture : Texture ) : void {
263
- const { textureRefCountMap } = this ;
264
-
265
- if ( textureRefCountMap . has ( texture ) ) {
266
- const refCountObj = textureRefCountMap . get ( texture ) ;
267
- assertTruthy ( refCountObj ) ;
268
- refCountObj . count -- ;
269
- if ( refCountObj . count === 0 ) {
270
- textureRefCountMap . delete ( texture ) ;
271
- // If the texture is not referenced anywhere else, remove it from the key cache
272
- // as well.
273
- // This should allow the `Texture` instance to be garbage collected.
274
- if ( refCountObj . cacheKey ) {
275
- this . textureKeyCache . delete ( refCountObj . cacheKey ) ;
276
- }
277
- }
278
- }
279
- // Free the ctx texture if it exists.
280
- this . ctxTextureCache . get ( texture ) ?. free ( ) ;
281
- }
282
-
283
257
/**
284
258
* Remove a `Texture` from the texture cache by its texture desc ID
285
259
*
@@ -292,40 +266,31 @@ export class CoreTextureManager {
292
266
* @param textureDescId
293
267
*/
294
268
removeTextureIdFromCache ( textureDescId : number ) : void {
295
- const { textureIdCache } = this ;
269
+ const { textureIdCache, textureRefCountMap } = this ;
296
270
const texture = textureIdCache . get ( textureDescId ) ;
297
271
if ( ! texture ) {
298
272
// Sometimes a texture is removed from the cache before it ever gets
299
273
// added to the cache. This is fine and not an error.
300
274
return ;
301
275
}
302
276
textureIdCache . delete ( textureDescId ) ;
303
-
304
- // remove the texture
305
- this . removeTexture ( texture ) ;
306
- }
307
-
308
- /**
309
- * Remove a `Texture` from the texture cache by its cache key
310
- *
311
- * @remarks
312
- * Same as removeTextureIdFromCache, but then by cache key.
313
- *
314
- * @param cacheKey
315
- */
316
- removeTextureCacheKeyFromCache ( cacheKey : string ) : void {
317
- const { textureKeyCache } = this ;
318
- const texture = this . textureKeyCache . get ( cacheKey ) ;
319
- if ( ! texture ) {
320
- // Sometimes a texture is removed from the cache before it ever gets
321
- // added to the cache. This is fine and not an error.
322
- return ;
277
+ if ( textureRefCountMap . has ( texture ) ) {
278
+ const refCountObj = textureRefCountMap . get ( texture ) ;
279
+ assertTruthy ( refCountObj ) ;
280
+ refCountObj . count -- ;
281
+ if ( refCountObj . count === 0 ) {
282
+ textureRefCountMap . delete ( texture ) ;
283
+ // If the texture is not referenced anywhere else, remove it from the key cache
284
+ // as well.
285
+ // This should allow the `Texture` instance to be garbage collected.
286
+ if ( refCountObj . cacheKey ) {
287
+ this . textureKeyCache . delete ( refCountObj . cacheKey ) ;
288
+ }
289
+ }
323
290
}
324
291
325
- textureKeyCache . delete ( cacheKey ) ;
326
-
327
- // remove the texture
328
- this . removeTexture ( texture ) ;
292
+ // Free the ctx texture if it exists.
293
+ this . ctxTextureCache . get ( texture ) ?. free ( ) ;
329
294
}
330
295
331
296
/**
0 commit comments