mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Respect the disable fx flags and only create the pipelines and render targets as needed
This commit is contained in:
parent
cc931f869c
commit
2c8b70e4f7
1 changed files with 60 additions and 39 deletions
|
@ -96,8 +96,7 @@ var PipelineManager = new Class({
|
|||
[ CONST.ROPE_PIPELINE, RopePipeline ],
|
||||
[ CONST.LIGHT_PIPELINE, LightPipeline ],
|
||||
[ CONST.POINTLIGHT_PIPELINE, PointLightPipeline ],
|
||||
[ CONST.MOBILE_PIPELINE, MobilePipeline ],
|
||||
[ CONST.FX_PIPELINE, FXPipeline ]
|
||||
[ CONST.MOBILE_PIPELINE, MobilePipeline ]
|
||||
]);
|
||||
|
||||
/**
|
||||
|
@ -121,28 +120,17 @@ var PipelineManager = new Class({
|
|||
* * Vignette
|
||||
* * Wipe
|
||||
*
|
||||
* See the FX Controller class for more details.
|
||||
* These are added as part of the boot process.
|
||||
*
|
||||
* If you do not wish to add them, specify `disableFX: true` in your game config.
|
||||
*
|
||||
* See the FX Controller class for more details about each FX.
|
||||
*
|
||||
* @name Phaser.Renderer.WebGL.PipelineManager#postPipelineClasses
|
||||
* @type {Phaser.Structs.Map.<string, Class>}
|
||||
* @since 3.50.0
|
||||
*/
|
||||
this.postPipelineClasses = new CustomMap([
|
||||
[ String(FX_CONST.BARREL), FX.Barrel ],
|
||||
[ String(FX_CONST.BLOOM), FX.Bloom ],
|
||||
[ String(FX_CONST.BLUR), FX.Blur ],
|
||||
[ String(FX_CONST.BOKEH), FX.Bokeh ],
|
||||
[ String(FX_CONST.CIRCLE), FX.Circle ],
|
||||
[ String(FX_CONST.COLOR_MATRIX), FX.ColorMatrix ],
|
||||
[ String(FX_CONST.DISPLACEMENT), FX.Displacement ],
|
||||
[ String(FX_CONST.GLOW), FX.Glow ],
|
||||
[ String(FX_CONST.GRADIENT), FX.Gradient ],
|
||||
[ String(FX_CONST.PIXELATE), FX.Pixelate ],
|
||||
[ String(FX_CONST.SHADOW), FX.Shadow ],
|
||||
[ String(FX_CONST.SHINE), FX.Shine ],
|
||||
[ String(FX_CONST.VIGNETTE), FX.Vignette ],
|
||||
[ String(FX_CONST.WIPE), FX.Wipe ]
|
||||
]);
|
||||
this.postPipelineClasses = new CustomMap();
|
||||
|
||||
/**
|
||||
* This map stores all pipeline instances in this manager.
|
||||
|
@ -379,29 +367,58 @@ var PipelineManager = new Class({
|
|||
var renderWidth = renderer.width;
|
||||
var renderHeight = renderer.height;
|
||||
|
||||
var minDimension = Math.min(renderWidth, renderHeight);
|
||||
var disablePreFX = this.game.config.disablePreFX;
|
||||
var disablePostFX = this.game.config.disablePostFX;
|
||||
|
||||
var qty = Math.ceil(minDimension / this.frameInc);
|
||||
|
||||
for (var i = 1; i < qty; i++)
|
||||
if (!disablePostFX)
|
||||
{
|
||||
var targetWidth = i * this.frameInc;
|
||||
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
// Duplicate RT for swap frame
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
// Duplicate RT for alt swap frame
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
this.maxDimension = targetWidth;
|
||||
this.postPipelineClasses.setAll([
|
||||
[ String(FX_CONST.BARREL), FX.Barrel ],
|
||||
[ String(FX_CONST.BLOOM), FX.Bloom ],
|
||||
[ String(FX_CONST.BLUR), FX.Blur ],
|
||||
[ String(FX_CONST.BOKEH), FX.Bokeh ],
|
||||
[ String(FX_CONST.CIRCLE), FX.Circle ],
|
||||
[ String(FX_CONST.COLOR_MATRIX), FX.ColorMatrix ],
|
||||
[ String(FX_CONST.DISPLACEMENT), FX.Displacement ],
|
||||
[ String(FX_CONST.GLOW), FX.Glow ],
|
||||
[ String(FX_CONST.GRADIENT), FX.Gradient ],
|
||||
[ String(FX_CONST.PIXELATE), FX.Pixelate ],
|
||||
[ String(FX_CONST.SHADOW), FX.Shadow ],
|
||||
[ String(FX_CONST.SHINE), FX.Shine ],
|
||||
[ String(FX_CONST.VIGNETTE), FX.Vignette ],
|
||||
[ String(FX_CONST.WIPE), FX.Wipe ]
|
||||
]);
|
||||
}
|
||||
|
||||
// Full-screen RTs
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
if (!disablePreFX)
|
||||
{
|
||||
this.classes.set(CONST.FX_PIPELINE, FXPipeline);
|
||||
|
||||
var minDimension = Math.min(renderWidth, renderHeight);
|
||||
|
||||
var qty = Math.ceil(minDimension / this.frameInc);
|
||||
|
||||
// These RenderTargets are all shared by the PreFXPipelines
|
||||
for (var i = 1; i < qty; i++)
|
||||
{
|
||||
var targetWidth = i * this.frameInc;
|
||||
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
// Duplicate RT for swap frame
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
// Duplicate RT for alt swap frame
|
||||
targets.push(new RenderTarget(renderer, targetWidth, targetWidth));
|
||||
|
||||
this.maxDimension = targetWidth;
|
||||
}
|
||||
|
||||
// Full-screen RTs
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
targets.push(new RenderTarget(renderer, renderWidth, renderHeight, 1, 0, true, true));
|
||||
}
|
||||
|
||||
// Install each of the default pipelines
|
||||
|
||||
|
@ -431,7 +448,11 @@ var PipelineManager = new Class({
|
|||
this.MULTI_PIPELINE = this.get(CONST.MULTI_PIPELINE);
|
||||
this.BITMAPMASK_PIPELINE = this.get(CONST.BITMAPMASK_PIPELINE);
|
||||
this.MOBILE_PIPELINE = this.get(CONST.MOBILE_PIPELINE);
|
||||
this.FX_PIPELINE = this.get(CONST.FX_PIPELINE);
|
||||
|
||||
if (!disablePreFX)
|
||||
{
|
||||
this.FX_PIPELINE = this.get(CONST.FX_PIPELINE);
|
||||
}
|
||||
|
||||
// And now the ones in the config, if any
|
||||
|
||||
|
|
Loading…
Reference in a new issue