Skip to content

Commit 17653fc

Browse files
committed
BitmapMask.destroy will now remove the textures and framebuffers that it created from the WebGL Renderer as part of the destroy process. Fix phaserjs#3771
1 parent cd508ab commit 17653fc

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ There is a new Game Object Component called `TextureCrop`. It replaces the Textu
131131
* The DataManager couldn't redefine previously removed properties. Fix #3803 (thanks @AleBles @oo7ph)
132132
* 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)
133133
* `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)
134-
* 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)
134+
* 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)
135+
* `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)
135136

136137
### Examples, Documentation and TypeScript
137138

src/display/mask/BitmapMask.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ var BitmapMask = new Class({
2626
{
2727
var renderer = scene.sys.game.renderer;
2828

29+
/**
30+
* A reference to either the Canvas or WebGL Renderer that this Mask is using.
31+
*
32+
* @name Phaser.Display.Masks.BitmapMask#renderer
33+
* @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)}
34+
* @since 3.11.0
35+
*/
36+
this.renderer = renderer;
37+
2938
/**
3039
* A renderable Game Object that uses a texture, such as a Sprite.
3140
*
@@ -205,10 +214,22 @@ var BitmapMask = new Class({
205214
destroy: function ()
206215
{
207216
this.bitmapMask = null;
217+
218+
var renderer = this.renderer;
219+
220+
if (renderer && renderer.gl)
221+
{
222+
renderer.deleteTexture(this.mainTexture);
223+
renderer.deleteTexture(this.maskTexture);
224+
renderer.deleteFramebuffer(this.mainFramebuffer);
225+
renderer.deleteFramebuffer(this.maskFramebuffer);
226+
}
227+
208228
this.mainTexture = null;
209229
this.maskTexture = null;
210230
this.mainFramebuffer = null;
211231
this.maskFramebuffer = null;
232+
this.renderer = null;
212233
}
213234

214235
});

0 commit comments

Comments
 (0)