Skip to content

Commit dbdac4f

Browse files
committed
Better method names
1 parent d7a0bdd commit dbdac4f

1 file changed

Lines changed: 43 additions & 49 deletions

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -780,25 +780,48 @@ var WebGLPipeline = new Class({
780780
/**
781781
* TODO
782782
*
783-
* @method Phaser.Renderer.WebGL.WebGLPipeline#postBind
783+
* @method Phaser.Renderer.WebGL.WebGLPipeline#preBatch
784784
* @since 3.50.0
785785
*
786786
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
787787
*
788788
* @return {this} This WebGLPipeline instance.
789789
*/
790-
postBind: function (gameObject)
790+
preBatch: function (gameObject)
791791
{
792792
if (this.currentRenderTarget)
793793
{
794794
this.currentRenderTarget.bind();
795795
}
796796

797-
this.onPostBind(gameObject);
797+
this.onPreBatch(gameObject);
798798

799799
return this;
800800
},
801801

802+
/**
803+
* TODO
804+
*
805+
* @method Phaser.Renderer.WebGL.WebGLPipeline#postBatch
806+
* @since 3.50.0
807+
*
808+
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
809+
*
810+
* @return {this} This WebGLPipeline instance.
811+
*/
812+
postBatch: function (gameObject)
813+
{
814+
this.onDraw(this.currentRenderTarget);
815+
816+
this.onPostBatch(gameObject);
817+
818+
return this;
819+
},
820+
821+
onDraw: function ()
822+
{
823+
},
824+
802825
/**
803826
* This method is called every time the Pipeline Manager deactivates this pipeline, swapping from
804827
* it to another one. This happens after a call to `flush` and before the new pipeline is bound.
@@ -856,47 +879,6 @@ var WebGLPipeline = new Class({
856879
return this;
857880
},
858881

859-
/**
860-
* TODO
861-
*
862-
* @method Phaser.Renderer.WebGL.WebGLPipeline#postFlush
863-
* @since 3.50.0
864-
*
865-
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
866-
*
867-
* @return {this} This WebGLPipeline instance.
868-
*/
869-
postFlush: function (gameObject)
870-
{
871-
var target = this.currentRenderTarget;
872-
873-
if (target)
874-
{
875-
target.unbind();
876-
}
877-
878-
var wasBound = this.renderer.setVertexBuffer(this.vertexBuffer);
879-
880-
this.currentShader.bind(wasBound);
881-
882-
if (target)
883-
{
884-
this.onDraw(target);
885-
}
886-
887-
this.onPostFlush(gameObject);
888-
889-
return this;
890-
},
891-
892-
onDraw: function (renderTarget)
893-
{
894-
// Post Pipelines can override this as needed
895-
this.manager.copyFrame(renderTarget);
896-
897-
898-
},
899-
900882
/**
901883
* By default this is an empty method hook that you can override and use in your own custom pipelines.
902884
*
@@ -957,12 +939,12 @@ var WebGLPipeline = new Class({
957939
* that requests use of this pipeline, allowing you to perform per-object set-up, such as loading
958940
* shader uniform data.
959941
*
960-
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPostBind
942+
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPreBatch
961943
* @since 3.50.0
962944
*
963945
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
964946
*/
965-
onPostBind: function ()
947+
onPreBatch: function ()
966948
{
967949
},
968950

@@ -971,12 +953,12 @@ var WebGLPipeline = new Class({
971953
*
972954
* TODO
973955
*
974-
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPostFlush
956+
* @method Phaser.Renderer.WebGL.WebGLPipeline#onPostBatch
975957
* @since 3.50.0
976958
*
977959
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
978960
*/
979-
onPostFlush: function ()
961+
onPostBatch: function ()
980962
{
981963
},
982964

@@ -1026,7 +1008,7 @@ var WebGLPipeline = new Class({
10261008
* This method is called every time this pipeline is asked to flush its batch.
10271009
*
10281010
* It is called immediately before the gl.bufferData and gl.drawArray calls are made, so you can
1029-
* perform any final pre-render modifications. To apply changes post-render, see `onPostFlush`.
1011+
* perform any final pre-render modifications. To apply changes post-render, see `onPostBatch`.
10301012
*
10311013
* @method Phaser.Renderer.WebGL.WebGLPipeline#onBeforeFlush
10321014
* @since 3.50.0
@@ -1143,6 +1125,13 @@ var WebGLPipeline = new Class({
11431125
{
11441126
if (unit === undefined) { unit = this.currentUnit; }
11451127

1128+
var postPipeline = (gameObject && gameObject.postPipeline);
1129+
1130+
if (postPipeline)
1131+
{
1132+
this.manager.preBatch(gameObject);
1133+
}
1134+
11461135
var hasFlushed = false;
11471136

11481137
if (this.shouldFlush(6))
@@ -1163,6 +1152,11 @@ var WebGLPipeline = new Class({
11631152

11641153
this.onBatch(gameObject);
11651154

1155+
if (postPipeline)
1156+
{
1157+
this.manager.postBatch(gameObject);
1158+
}
1159+
11661160
return hasFlushed;
11671161
},
11681162

0 commit comments

Comments
 (0)