Skip to content

Commit 691b680

Browse files
committed
Added JSDocs and fixed boot sequence
1 parent cf275b4 commit 691b680

1 file changed

Lines changed: 202 additions & 1 deletion

File tree

src/renderer/webgl/PipelineManager.js

Lines changed: 202 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,70 @@ var PipelineManager = new Class({
170170
* @since 3.50.0
171171
*/
172172
this.UTILITY_PIPELINE = null;
173+
174+
/**
175+
* A reference to the Full Frame 1 Render Target that belongs to the
176+
* Utility Pipeline. This property is set during the `boot` method.
177+
*
178+
* This Render Target is the full size of the renderer.
179+
*
180+
* You can use this directly in Post FX Pipelines for multi-target effects.
181+
* However, be aware that these targets are shared between all post fx pipelines.
182+
*
183+
* @name Phaser.Renderer.WebGL.PipelineManager#fullFrame1
184+
* @type {Phaser.Renderer.WebGL.RenderTarget}
185+
* @default null
186+
* @since 3.50.0
187+
*/
188+
this.fullFrame1;
189+
190+
/**
191+
* A reference to the Full Frame 2 Render Target that belongs to the
192+
* Utility Pipeline. This property is set during the `boot` method.
193+
*
194+
* This Render Target is the full size of the renderer.
195+
*
196+
* You can use this directly in Post FX Pipelines for multi-target effects.
197+
* However, be aware that these targets are shared between all post fx pipelines.
198+
*
199+
* @name Phaser.Renderer.WebGL.PipelineManager#fullFrame2
200+
* @type {Phaser.Renderer.WebGL.RenderTarget}
201+
* @default null
202+
* @since 3.50.0
203+
*/
204+
this.fullFrame2;
205+
206+
/**
207+
* A reference to the Half Frame 1 Render Target that belongs to the
208+
* Utility Pipeline. This property is set during the `boot` method.
209+
*
210+
* This Render Target is half the size of the renderer.
211+
*
212+
* You can use this directly in Post FX Pipelines for multi-target effects.
213+
* However, be aware that these targets are shared between all post fx pipelines.
214+
*
215+
* @name Phaser.Renderer.WebGL.PipelineManager#halfFrame1
216+
* @type {Phaser.Renderer.WebGL.RenderTarget}
217+
* @default null
218+
* @since 3.50.0
219+
*/
220+
this.halfFrame1;
221+
222+
/**
223+
* A reference to the Half Frame 2 Render Target that belongs to the
224+
* Utility Pipeline. This property is set during the `boot` method.
225+
*
226+
* This Render Target is half the size of the renderer.
227+
*
228+
* You can use this directly in Post FX Pipelines for multi-target effects.
229+
* However, be aware that these targets are shared between all post fx pipelines.
230+
*
231+
* @name Phaser.Renderer.WebGL.PipelineManager#halfFrame2
232+
* @type {Phaser.Renderer.WebGL.RenderTarget}
233+
* @default null
234+
* @since 3.50.0
235+
*/
236+
this.halfFrame2;
173237
},
174238

175239
/**
@@ -187,15 +251,24 @@ var PipelineManager = new Class({
187251
{
188252
var game = this.game;
189253

254+
// Must always be set first, before any other pipeline
255+
this.UTILITY_PIPELINE = this.add(CONST.UTILITY_PIPELINE, new UtilityPipeline({ game: game }));
256+
190257
this.MULTI_PIPELINE = this.add(CONST.MULTI_PIPELINE, new MultiPipeline({ game: game }));
191258
this.BITMAPMASK_PIPELINE = this.add(CONST.BITMAPMASK_PIPELINE, new BitmapMaskPipeline({ game: game }));
192259
this.POSTFX_PIPELINE = this.add(CONST.POSTFX_PIPELINE, new PostFXPipeline({ game: game }));
193-
this.UTILITY_PIPELINE = this.add(CONST.UTILITY_PIPELINE, new UtilityPipeline({ game: game }));
194260

195261
this.add(CONST.SINGLE_PIPELINE, new SinglePipeline({ game: game }));
196262
this.add(CONST.ROPE_PIPELINE, new RopePipeline({ game: game }));
197263
this.add(CONST.LIGHT_PIPELINE, new LightPipeline({ game: game }));
198264
this.add(CONST.GRAPHICS_PIPELINE, new GraphicsPipeline({ game: game }));
265+
266+
var utility = this.UTILITY_PIPELINE;
267+
268+
this.fullFrame1 = utility.fullFrame1;
269+
this.fullFrame2 = utility.fullFrame2;
270+
this.halfFrame1 = utility.halfFrame1;
271+
this.halfFrame2 = utility.halfFrame2;
199272
},
200273

201274
/**
@@ -456,20 +529,53 @@ var PipelineManager = new Class({
456529
return pipeline;
457530
},
458531

532+
/**
533+
* This method is called by the `WebGLPipeline.batchQuad` method, right before a quad
534+
* belonging to a Game Object is about to be added to the batch. It causes a batch
535+
* flush, then calls the `preBatch` method on the post-fx pipeline belonging to the
536+
* Game Object.
537+
*
538+
* @method Phaser.Renderer.WebGL.PipelineManager#preBatch
539+
* @since 3.50.0
540+
*
541+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object about to be batched.
542+
*/
459543
preBatch: function (gameObject)
460544
{
461545
this.flush();
462546

463547
gameObject.postPipeline.preBatch(gameObject);
464548
},
465549

550+
/**
551+
* This method is called by the `WebGLPipeline.batchQuad` method, right after a quad
552+
* belonging to a Game Object has been added to the batch. It causes a batch
553+
* flush, then calls the `postBatch` method on the post-fx pipeline belonging to the
554+
* Game Object.
555+
*
556+
* @method Phaser.Renderer.WebGL.PipelineManager#postBatch
557+
* @since 3.50.0
558+
*
559+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to the batch.
560+
*/
466561
postBatch: function (gameObject)
467562
{
468563
this.flush();
469564

470565
gameObject.postPipeline.postBatch(gameObject);
471566
},
472567

568+
/**
569+
* Called at the start of the `WebGLRenderer.preRenderCamera` method.
570+
*
571+
* If the Camera has a postPipeline set, it will flush the batch and then call the
572+
* `preBatch` method on the post-fx pipeline belonging to the Camera.
573+
*
574+
* @method Phaser.Renderer.WebGL.PipelineManager#preBatchCamera
575+
* @since 3.50.0
576+
*
577+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera being pre-rendered.
578+
*/
473579
preBatchCamera: function (camera)
474580
{
475581
if (camera.postPipeline)
@@ -480,6 +586,17 @@ var PipelineManager = new Class({
480586
}
481587
},
482588

589+
/**
590+
* Called at the end of the `WebGLRenderer.postRenderCamera` method.
591+
*
592+
* If the Camera has a postPipeline set, it will flush the batch and then call the
593+
* `postBatch` method on the post-fx pipeline belonging to the Camera.
594+
*
595+
* @method Phaser.Renderer.WebGL.PipelineManager#postBatchCamera
596+
* @since 3.50.0
597+
*
598+
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that was just rendered.
599+
*/
483600
postBatchCamera: function (camera)
484601
{
485602
if (camera.postPipeline)
@@ -519,6 +636,27 @@ var PipelineManager = new Class({
519636
);
520637
},
521638

639+
/**
640+
* Copy the `source` Render Target to the `target` Render Target.
641+
*
642+
* You can optionally set the brightness factor of the copy.
643+
*
644+
* The difference between this method and `drawFrame` is that this method
645+
* uses a faster copy shader, where only the brightness can be modified.
646+
* If you need color level manipulation, see `drawFrame` instead.
647+
*
648+
* The copy itself is handled by the Utility Pipeline.
649+
*
650+
* @method Phaser.Renderer.WebGL.PipelineManager#copyFrame
651+
* @since 3.50.0
652+
*
653+
* @param {Phaser.Renderer.WebGL.RenderTarget} source - The source Render Target.
654+
* @param {Phaser.Renderer.WebGL.RenderTarget} [target] - The target Render Target.
655+
* @param {number} [brightness=1] - The brightness value applied to the frame copy.
656+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
657+
*
658+
* @return {this} This Pipeline Manager instance.
659+
*/
522660
copyFrame: function (source, target, brightness, clearAlpha)
523661
{
524662
var pipeline = this.setUtility(this.UTILITY_PIPELINE.copyShader);
@@ -528,6 +666,27 @@ var PipelineManager = new Class({
528666
return this;
529667
},
530668

669+
/**
670+
* Copy the `source` Render Target to the `target` Render Target, using the
671+
* given Color Matrix.
672+
*
673+
* The difference between this method and `copyFrame` is that this method
674+
* uses a color matrix shader, where you have full control over the luminance
675+
* values used during the copy. If you don't need this, you can use the faster
676+
* `copyFrame` method instead.
677+
*
678+
* The copy itself is handled by the Utility Pipeline.
679+
*
680+
* @method Phaser.Renderer.WebGL.PipelineManager#drawFrame
681+
* @since 3.50.0
682+
*
683+
* @param {Phaser.Renderer.WebGL.RenderTarget} source - The source Render Target.
684+
* @param {Phaser.Renderer.WebGL.RenderTarget} [target] - The target Render Target.
685+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
686+
* @param {Phaser.Display.ColorMatrix} [colorMatrix] - The Color Matrix to use when performing the draw.
687+
*
688+
* @return {this} This Pipeline Manager instance.
689+
*/
531690
drawFrame: function (source, target, clearAlpha, colorMatrix)
532691
{
533692
var pipeline = this.setUtility(this.UTILITY_PIPELINE.colorMatrixShader);
@@ -537,6 +696,23 @@ var PipelineManager = new Class({
537696
return this;
538697
},
539698

699+
/**
700+
* Draws the `source1` and `source2` Render Targets to the `target` Render Target
701+
* using a linear blend effect, which is controlled by the `strength` parameter.
702+
*
703+
* The draw itself is handled by the Utility Pipeline.
704+
*
705+
* @method Phaser.Renderer.WebGL.PipelineManager#blendFrames
706+
* @since 3.50.0
707+
*
708+
* @param {Phaser.Renderer.WebGL.RenderTarget} source1 - The first source Render Target.
709+
* @param {Phaser.Renderer.WebGL.RenderTarget} source2 - The second source Render Target.
710+
* @param {Phaser.Renderer.WebGL.RenderTarget} [target] - The target Render Target.
711+
* @param {number} [strength=1] - The strength of the blend.
712+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
713+
*
714+
* @return {this} This Pipeline Manager instance.
715+
*/
540716
blendFrames: function (source1, source2, target, strength, clearAlpha)
541717
{
542718
var pipeline = this.setUtility(this.UTILITY_PIPELINE.linearShader);
@@ -546,6 +722,23 @@ var PipelineManager = new Class({
546722
return this;
547723
},
548724

725+
/**
726+
* Draws the `source1` and `source2` Render Targets to the `target` Render Target
727+
* using an additive blend effect, which is controlled by the `strength` parameter.
728+
*
729+
* The draw itself is handled by the Utility Pipeline.
730+
*
731+
* @method Phaser.Renderer.WebGL.PipelineManager#blendFramesAdditive
732+
* @since 3.50.0
733+
*
734+
* @param {Phaser.Renderer.WebGL.RenderTarget} source1 - The first source Render Target.
735+
* @param {Phaser.Renderer.WebGL.RenderTarget} source2 - The second source Render Target.
736+
* @param {Phaser.Renderer.WebGL.RenderTarget} [target] - The target Render Target.
737+
* @param {number} [strength=1] - The strength of the blend.
738+
* @param {boolean} [clearAlpha=true] - Clear the alpha channel when running `gl.clear` on the target?
739+
*
740+
* @return {this} This Pipeline Manager instance.
741+
*/
549742
blendFramesAdditive: function (source1, source2, target, strength, clearAlpha)
550743
{
551744
var pipeline = this.setUtility(this.UTILITY_PIPELINE.addShader);
@@ -555,6 +748,14 @@ var PipelineManager = new Class({
555748
return this;
556749
},
557750

751+
/**
752+
* Returns `true` if the current pipeline is forced to use texture unit zero.
753+
*
754+
* @method Phaser.Renderer.WebGL.PipelineManager#forceZero
755+
* @since 3.50.0
756+
*
757+
* @return {boolean} `true` if the current pipeline is forced to use texture unit zero.
758+
*/
558759
forceZero: function ()
559760
{
560761
return (this.current && this.current.forceZero);

0 commit comments

Comments
 (0)