@@ -64,35 +64,31 @@ Phaser.Renderer.WebGL.BatchManager.prototype = {
6464
6565 setBatch : function ( newBatch )
6666 {
67- if ( this . currentBatch === newBatch )
67+ if ( this . currentBatch . type === newBatch . type )
6868 {
69- return ;
69+ return false ;
7070 }
7171
7272 // Flush whatever was in the current batch (if anything)
7373 this . currentBatch . flush ( ) ;
7474
75- if ( newBatch )
76- {
77- this . currentBatch = newBatch ;
78- }
79- else
80- {
81- this . currentBatch = this . spriteBatch ;
82- }
75+ this . currentBatch = newBatch ;
76+
77+ this . currentBatch . start ( true ) ;
78+
79+ return true ;
8380 } ,
8481
82+ // Add a new entry into the current sprite batch
8583 add : function ( source , blendMode , verts , uvs , textureIndex , alpha , tintColors , bgColors )
8684 {
87- var hasFlushed = false ;
88-
89- // Shader? Then we check the current batch, and swap if needed
90-
85+ // Set the current batch (if different from this one)
86+ var hasFlushed = this . setBatch ( this . spriteBatch ) ;
9187
9288 // Check Batch Size and flush if needed
93- if ( this . currentBatch . size >= this . currentBatch . maxSize )
89+ if ( ! hasFlushed && this . spriteBatch . size >= this . spriteBatch . maxSize )
9490 {
95- this . currentBatch . flush ( ) ;
91+ this . spriteBatch . flush ( ) ;
9692
9793 hasFlushed = true ;
9894 }
@@ -116,23 +112,31 @@ Phaser.Renderer.WebGL.BatchManager.prototype = {
116112 {
117113 if ( ! hasFlushed )
118114 {
119- this . currentBatch . flush ( ) ;
120-
121- hasFlushed = true ;
115+ this . spriteBatch . flush ( ) ;
122116 }
123117
124118 this . renderer . setBlendMode ( blendMode ) ;
125119 }
126120
127- this . currentBatch . add ( verts , uvs , textureIndex , alpha , tintColors , bgColors ) ;
121+ this . spriteBatch . add ( verts , uvs , textureIndex , alpha , tintColors , bgColors ) ;
122+ } ,
123+
124+ addCustomShader : function ( )
125+ {
126+ // TODO
127+ } ,
128+
129+ addFX : function ( )
130+ {
131+ // TODO
128132 } ,
129133
130134 addPixel : function ( x0 , y0 , x1 , y1 , x2 , y2 , x3 , y3 , color )
131135 {
132- // Swapping batch? Flush and change
136+ var hasFlushed = this . setBatch ( this . pixelBatch ) ;
133137
134138 // Check Batch Size and flush if needed
135- if ( this . pixelBatch . size >= this . pixelBatch . maxSize )
139+ if ( ! hasFlushed && this . pixelBatch . size >= this . pixelBatch . maxSize )
136140 {
137141 this . pixelBatch . flush ( ) ;
138142 }
0 commit comments