77/**
88*
99*
10- * @class Phaser.Renderer.WebGL.Batch.Base
10+ * @class Phaser.Renderer.WebGL.Batch
1111* @constructor
1212* @param {Phaser.Renderer.WebGL } renderer - The WebGL Renderer.
1313*/
14- Phaser . Renderer . WebGL . Batch . Base = function ( manager , batchSize , vertSize )
14+ Phaser . Renderer . WebGL . Batch = function ( manager , batchSize , vertSize )
1515{
1616 this . batchManager = manager ;
1717
@@ -21,16 +21,16 @@ Phaser.Renderer.WebGL.Batch.Base = function (manager, batchSize, vertSize)
2121
2222 // Total number of objects we'll batch before flushing and rendering
2323 // Integer
24- this . maxBatchSize = batchSize ;
24+ this . maxSize = batchSize ;
2525
2626 // Integer
27- this . halfBatchSize = Math . floor ( this . maxBatchSize / 2 ) ;
27+ this . halfSize = Math . floor ( this . maxSize / 2 ) ;
2828
2929 // Integer
3030 this . vertSize = vertSize ;
3131
3232 // * 4 because there are 4 verts per batch entry (each corner of the quad)
33- var numVerts = this . vertSize * this . maxBatchSize * 4 ;
33+ var numVerts = this . vertSize * this . maxSize * 4 ;
3434
3535 // ArrayBuffer
3636 // This data is what changes every frame, populated by the game objects
@@ -41,10 +41,13 @@ Phaser.Renderer.WebGL.Batch.Base = function (manager, batchSize, vertSize)
4141 // 6 because there are 2 triangles per quad, and each triangle has 3 indices
4242 // This Typed Array is set in the build method of the extended class, and then
4343 // doesn't change again (it's populated just once)
44- this . indices = new Uint16Array ( this . maxBatchSize * 6 ) ;
44+ this . indices = new Uint16Array ( this . maxSize * 6 ) ;
45+
46+ // Populated by the flush operation when the batch is < 50% of the max size
47+ this . view = null ;
4548
4649 // Integer
47- this . currentBatchSize = 0 ;
50+ this . size = 0 ;
4851
4952 // Boolean
5053 this . dirty = true ;
@@ -82,17 +85,23 @@ Phaser.Renderer.WebGL.Batch.Base = function (manager, batchSize, vertSize)
8285 this . _i = 0 ;
8386} ;
8487
85- Phaser . Renderer . WebGL . Batch . Base . prototype . constructor = Phaser . Renderer . WebGL . Batch . Base ;
88+ Phaser . Renderer . WebGL . Batch . prototype . constructor = Phaser . Renderer . WebGL . Batch ;
8689
87- Phaser . Renderer . WebGL . Batch . Base . prototype = {
90+ Phaser . Renderer . WebGL . Batch . prototype = {
8891
8992 start : function ( )
9093 {
9194 this . _i = 0 ;
9295
93- this . currentBatchSize = 0 ;
96+ this . size = 0 ;
97+
98+ // We only need to do this if this batch isn't the current one
9499
95- this . bindShader ( ) ;
100+ if ( this . dirty )
101+ {
102+ this . bindShader ( ) ;
103+ this . dirty = false ;
104+ }
96105 } ,
97106
98107 stop : function ( )
0 commit comments