mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
RenderTarget.resize
will now check the autoResize
property before applying the change. Textures that have been locked to a fixed size, such as FX POT buffers, will no longer be resized to the full canvas dimensions, causing Out of Memory errors on some mobile devices. Fix #6914
This commit is contained in:
parent
22bd58599c
commit
509de6ae51
1 changed files with 27 additions and 15 deletions
|
@ -160,7 +160,7 @@ var RenderTarget = new Class({
|
|||
*/
|
||||
this.forceClamp = forceClamp;
|
||||
|
||||
this.resize(width, height);
|
||||
this.init(width, height);
|
||||
|
||||
if (autoResize)
|
||||
{
|
||||
|
@ -173,6 +173,28 @@ var RenderTarget = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets up this Render Target to the given width and height, creating a new
|
||||
* frame buffer and texture. This method is called automatically by the constructor
|
||||
* and at no other time.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderTarget#init
|
||||
* @since 3.86.0
|
||||
*
|
||||
* @param {number} width - The new width of this Render Target.
|
||||
* @param {number} height - The new height of this Render Target.
|
||||
*/
|
||||
init: function (width, height)
|
||||
{
|
||||
var renderer = this.renderer;
|
||||
|
||||
this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp);
|
||||
this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer);
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets if this Render Target should automatically resize when the WebGL Renderer
|
||||
* emits a resize event.
|
||||
|
@ -211,9 +233,6 @@ var RenderTarget = new Class({
|
|||
*
|
||||
* This method is called automatically by the pipeline during its resize handler.
|
||||
*
|
||||
* Previous to Phaser v3.85 this method would only run if `autoResize` was `true`,
|
||||
* it will now run regardless.
|
||||
*
|
||||
* @method Phaser.Renderer.WebGL.RenderTarget#resize
|
||||
* @since 3.50.0
|
||||
*
|
||||
|
@ -224,7 +243,7 @@ var RenderTarget = new Class({
|
|||
*/
|
||||
resize: function (width, height)
|
||||
{
|
||||
if (this.willResize(width, height))
|
||||
if (this.autoResize && this.willResize(width, height))
|
||||
{
|
||||
var renderer = this.renderer;
|
||||
|
||||
|
@ -264,15 +283,8 @@ var RenderTarget = new Class({
|
|||
width = Math.round(width * this.scale);
|
||||
height = Math.round(height * this.scale);
|
||||
|
||||
if (width <= 0)
|
||||
{
|
||||
width = 1;
|
||||
}
|
||||
|
||||
if (height <= 0)
|
||||
{
|
||||
height = 1;
|
||||
}
|
||||
width = Math.max(width, 1);
|
||||
height = Math.max(height, 1);
|
||||
|
||||
return (width !== this.width || height !== this.height);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue