BitmapMask.destroy will now remove the textures and framebuffers that it created from the WebGL Renderer as part of the destroy process. Fix #3771

This commit is contained in:
Richard Davey 2018-07-09 14:26:45 +01:00
parent cd508ab3f1
commit 17653fcf7d
2 changed files with 23 additions and 1 deletions

View file

@ -131,7 +131,8 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
* The DataManager couldn't redefine previously removed properties. Fix #3803 (thanks @AleBles @oo7ph)
* The Canvas DrawImage function has been recoded entirely so it now correctly supports parent matrix and camera matrix calculations. This fixes an issue where children inside Containers would lose their rotation, and other issues, when in the Canvas Renderer. Fix #3728 (thanks @samid737)
* `clearMask(true)` would throw an exception if the Game Object didn't have a mask. Now it checks first before destroying the mask. Fix #3809 (thanks @NokFrt)
* In the WebGL `GeometryMask` the stencil has been changed from `INVERT` to `KEEP` in order to fix issues when masking Graphics objects and other complex objects. Fix #3807 (thanks @zilbuz)
* In the WebGL `GeometryMask` the stencil has been changed from `INVERT` to `KEEP` in order to fix issues when masking Graphics objects and other complex objects. Fix #3807. This also fixes the issue where children in Containers would display incorrectly outside of a Geometry mask. Fix #3746 (thanks @zilbuz @oklar)
* `BitmapMask.destroy` will now remove the textures and framebuffers that it created from the WebGL Renderer as part of the destroy process. Fix #3771 (thanks @nunof07)
### Examples, Documentation and TypeScript

View file

@ -26,6 +26,15 @@ var BitmapMask = new Class({
{
var renderer = scene.sys.game.renderer;
/**
* A reference to either the Canvas or WebGL Renderer that this Mask is using.
*
* @name Phaser.Display.Masks.BitmapMask#renderer
* @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)}
* @since 3.11.0
*/
this.renderer = renderer;
/**
* A renderable Game Object that uses a texture, such as a Sprite.
*
@ -205,10 +214,22 @@ var BitmapMask = new Class({
destroy: function ()
{
this.bitmapMask = null;
var renderer = this.renderer;
if (renderer && renderer.gl)
{
renderer.deleteTexture(this.mainTexture);
renderer.deleteTexture(this.maskTexture);
renderer.deleteFramebuffer(this.mainFramebuffer);
renderer.deleteFramebuffer(this.maskFramebuffer);
}
this.mainTexture = null;
this.maskTexture = null;
this.mainFramebuffer = null;
this.maskFramebuffer = null;
this.renderer = null;
}
});