@lightningjs/renderer
Advanced tools
Comparing version 2.11.0 to 2.11.1
@@ -20,2 +20,3 @@ /* | ||
import { isProductionEnvironment } from '../utils.js'; | ||
import { getTimeStamp } from './platform.js'; | ||
import { bytesToMb } from './utils.js'; | ||
@@ -88,2 +89,6 @@ /** | ||
addToOrphanedTextures(texture) { | ||
// if the texture is already in the orphaned textures list add it at the end | ||
if (this.orphanedTextures.includes(texture)) { | ||
this.removeFromOrphanedTextures(texture); | ||
} | ||
// If the texture can be cleaned up, add it to the orphaned textures list | ||
@@ -149,4 +154,12 @@ if (texture.preventCleanup === false) { | ||
const txManager = this.stage.txManager; | ||
while (this.memUsed >= memTarget && this.orphanedTextures.length > 0) { | ||
const timestamp = getTimeStamp(); | ||
while (this.memUsed >= memTarget && | ||
this.orphanedTextures.length > 0 && | ||
// if it a non-critical cleanup, we will only cleanup for 10ms | ||
(critical || getTimeStamp() - timestamp < 10)) { | ||
const texture = this.orphanedTextures.shift(); | ||
if (texture.renderable === true) { | ||
// If the texture is renderable, we can't free it up | ||
continue; | ||
} | ||
texture.free(); | ||
@@ -153,0 +166,0 @@ txManager.removeTextureFromCache(texture); |
{ | ||
"name": "@lightningjs/renderer", | ||
"version": "2.11.0", | ||
"version": "2.11.1", | ||
"description": "Lightning 3 Renderer", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -20,2 +20,3 @@ /* | ||
import { isProductionEnvironment } from '../utils.js'; | ||
import { getTimeStamp } from './platform.js'; | ||
import type { Stage } from './Stage.js'; | ||
@@ -172,2 +173,7 @@ import type { Texture } from './textures/Texture.js'; | ||
addToOrphanedTextures(texture: Texture) { | ||
// if the texture is already in the orphaned textures list add it at the end | ||
if (this.orphanedTextures.includes(texture)) { | ||
this.removeFromOrphanedTextures(texture); | ||
} | ||
// If the texture can be cleaned up, add it to the orphaned textures list | ||
@@ -245,5 +251,17 @@ if (texture.preventCleanup === false) { | ||
const txManager = this.stage.txManager; | ||
const timestamp = getTimeStamp(); | ||
while (this.memUsed >= memTarget && this.orphanedTextures.length > 0) { | ||
while ( | ||
this.memUsed >= memTarget && | ||
this.orphanedTextures.length > 0 && | ||
// if it a non-critical cleanup, we will only cleanup for 10ms | ||
(critical || getTimeStamp() - timestamp < 10) | ||
) { | ||
const texture = this.orphanedTextures.shift()!; | ||
if (texture.renderable === true) { | ||
// If the texture is renderable, we can't free it up | ||
continue; | ||
} | ||
texture.free(); | ||
@@ -250,0 +268,0 @@ txManager.removeTextureFromCache(texture); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2879028
61128