Skip to content

Commit 8c996b4

Browse files
committed
Added setPost, isCurrentPost, removed setCameraPipeline
1 parent c12b4cf commit 8c996b4

1 file changed

Lines changed: 67 additions & 18 deletions

File tree

src/renderer/webgl/PipelineManager.js

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,43 @@ var PipelineManager = new Class({
529529
return pipeline;
530530
},
531531

532+
/**
533+
* Sets the current post pipeline to be used by the `WebGLRenderer`.
534+
*
535+
* This method accepts a pipeline instance as its parameter, not the name.
536+
*
537+
* If the pipeline isn't already the current one it will call `WebGLPipeline.bind` and then `onBind`.
538+
*
539+
* @method Phaser.Renderer.WebGL.PipelineManager#setPost
540+
* @since 3.50.0
541+
*
542+
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The post pipeline instance to be set as current.
543+
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
544+
* @param {Phaser.Renderer.WebGL.WebGLShader} [currentShader] - The shader to set as being current.
545+
*
546+
* @return {Phaser.Renderer.WebGL.WebGLPipeline} The post pipeline that was set.
547+
*/
548+
setPost: function (pipeline, gameObject, currentShader)
549+
{
550+
if (!this.isCurrentPost(pipeline, currentShader))
551+
{
552+
this.flush();
553+
554+
if (this.currentPost)
555+
{
556+
this.currentPost.unbind();
557+
}
558+
559+
this.currentPost = pipeline;
560+
561+
pipeline.bind(currentShader);
562+
}
563+
564+
pipeline.onBind(gameObject);
565+
566+
return pipeline;
567+
},
568+
532569
/**
533570
* This method is called by the `WebGLPipeline.batchQuad` method, right before a quad
534571
* belonging to a Game Object is about to be added to the batch. It causes a batch
@@ -636,6 +673,35 @@ var PipelineManager = new Class({
636673
);
637674
},
638675

676+
/**
677+
* Checks to see if the given post pipeline is already the active pipeline, both within this
678+
* Pipeline Manager, and also has the same vertex buffer and shader set within the Renderer.
679+
*
680+
* @method Phaser.Renderer.WebGL.PipelineManager#isCurrentPost
681+
* @since 3.50.0
682+
*
683+
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The pipeline instance to be checked.
684+
* @param {Phaser.Renderer.WebGL.WebGLShader} [currentShader] - The shader to set as being current.
685+
*
686+
* @return {boolean} `true` if the given pipeline is already the current pipeline, otherwise `false`.
687+
*/
688+
isCurrentPost: function (pipeline, currentShader)
689+
{
690+
var renderer = this.renderer;
691+
var current = this.currentPost;
692+
693+
if (current && !currentShader)
694+
{
695+
currentShader = current.currentShader;
696+
}
697+
698+
return !(
699+
current !== pipeline ||
700+
current.vertexBuffer !== renderer.currentVertexBuffer ||
701+
currentShader.program !== renderer.currentProgram
702+
);
703+
},
704+
639705
/**
640706
* Copy the `source` Render Target to the `target` Render Target.
641707
*
@@ -817,26 +883,9 @@ var PipelineManager = new Class({
817883
return this.set(this.MULTI_PIPELINE);
818884
},
819885

820-
/**
821-
* Sets the Camera Pipeline to be the currently bound pipeline.
822-
*
823-
* This is the default Phaser 3 pipeline for cameras.
824-
*
825-
* @method Phaser.Renderer.WebGL.PipelineManager#setCameraPipeline
826-
* @since 3.50.0
827-
*
828-
* @return {Phaser.Renderer.WebGL.Pipelines.CameraPipeline} The Camera Pipeline instance.
829-
*/
830-
setCameraPipeline: function ()
831-
{
832-
return this.set(this.CAMERA_PIPELINE);
833-
},
834-
835886
/**
836887
* Sets the Utility Pipeline to be the currently bound pipeline.
837888
*
838-
* This is the default Phaser 3 rendering pipeline.
839-
*
840889
* @method Phaser.Renderer.WebGL.PipelineManager#setUtility
841890
* @since 3.50.0
842891
*
@@ -846,7 +895,7 @@ var PipelineManager = new Class({
846895
*/
847896
setUtility: function (currentShader)
848897
{
849-
return this.set(this.UTILITY_PIPELINE, null, currentShader);
898+
return this.setPost(this.UTILITY_PIPELINE, null, currentShader);
850899
},
851900

852901
/**

0 commit comments

Comments
 (0)