RenderTexture.preDestroy will now release the canvas back to the CanvasPool if running in canvas mode

Also removed un-used `drawFrame` references.
This commit is contained in:
Richard Davey 2018-07-29 12:20:09 +01:00
parent 34b27fd57a
commit a1ae1744ac

View file

@ -146,7 +146,6 @@ var RenderTexture = new Class({
this.fill = RenderTextureWebGL.fill; this.fill = RenderTextureWebGL.fill;
this.clear = RenderTextureWebGL.clear; this.clear = RenderTextureWebGL.clear;
this.draw = RenderTextureWebGL.draw; this.draw = RenderTextureWebGL.draw;
this.drawFrame = RenderTextureWebGL.drawFrame;
this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false);
this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false);
} }
@ -155,7 +154,6 @@ var RenderTexture = new Class({
this.fill = RenderTextureCanvas.fill; this.fill = RenderTextureCanvas.fill;
this.clear = RenderTextureCanvas.clear; this.clear = RenderTextureCanvas.clear;
this.draw = RenderTextureCanvas.draw; this.draw = RenderTextureCanvas.draw;
this.drawFrame = RenderTextureCanvas.drawFrame;
this.canvas = CanvasPool.create2D(this, width, height); this.canvas = CanvasPool.create2D(this, width, height);
this.context = this.canvas.getContext('2d'); this.context = this.canvas.getContext('2d');
} }
@ -253,6 +251,11 @@ var RenderTexture = new Class({
*/ */
preDestroy: function () preDestroy: function ()
{ {
if (this.canvas)
{
CanvasPool.remove(this.canvas);
}
if (this.renderer && this.renderer.gl) if (this.renderer && this.renderer.gl)
{ {
this.renderer.deleteTexture(this.texture); this.renderer.deleteTexture(this.texture);