Skip to content

Commit a271a52

Browse files
committed
Added glLastUsed property to TextureSource.
1 parent 120b6eb commit a271a52

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/renderer/webgl/BatchManager.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ Phaser.Renderer.WebGL.BatchManager.prototype = {
378378

379379
var source = gameObject.frame.source;
380380

381+
source.glLastUsed = this.renderer.startTime;
382+
381383
// Does this Game Objects texture need updating?
382384
if (source.glDirty)
383385
{

src/renderer/webgl/WebGLRenderer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,12 @@ Phaser.Renderer.WebGL = function (game)
168168

169169
this.blendModes = [];
170170

171-
this.drawCount = 0;
172171
this.flipY = 1;
173172

173+
this.startTime = 0;
174+
this.endTime = 0;
175+
this.drawCount = 0;
176+
174177
this.contextLost = false;
175178

176179
this._fbErrors = {
@@ -397,6 +400,8 @@ Phaser.Renderer.WebGL.prototype = {
397400

398401
// Add Pre-render hook
399402

403+
this.startTime = Date.now();
404+
400405
var gl = this.gl;
401406

402407
gl.viewport(0, 0, this.width, this.height);
@@ -460,6 +465,8 @@ Phaser.Renderer.WebGL.prototype = {
460465

461466
// debugger;
462467

468+
this.endTime = Date.now();
469+
463470
// Add Post-render hook
464471
},
465472

src/textures/TextureSource.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ Phaser.TextureSource = function (texture, source)
101101
*/
102102
this.glTextureIndex = 0;
103103

104+
/**
105+
* The timestamp when this texture was last used by the WebGL renderer.
106+
* Can be used to purge out 'dead' textures from GPU memory.
107+
* @property glLastUsed
108+
* @type Number
109+
*/
110+
this.glLastUsed = 0;
111+
104112
/**
105113
* @property glDirty
106114
*/

0 commit comments

Comments
 (0)