Skip to content

Commit 19d9241

Browse files
committed
Removed un-needed shaders.
Added batch processor switching and tested it.
1 parent 7477599 commit 19d9241

4 files changed

Lines changed: 28 additions & 766 deletions

File tree

src/renderer/webgl/BatchManager.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/renderer/webgl/batches/BaseBatch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ Phaser.Renderer.WebGL.Batch.prototype.constructor = Phaser.Renderer.WebGL.Batch;
9191

9292
Phaser.Renderer.WebGL.Batch.prototype = {
9393

94-
start: function ()
94+
start: function (force)
9595
{
9696
this._i = 0;
9797

9898
this.size = 0;
9999

100100
// We only need to do this if this batch isn't the current one
101101

102-
if (this.dirty)
102+
if (this.dirty || force)
103103
{
104104
this.bindShader();
105105
this.dirty = false;

src/renderer/webgl/shaders/Image.js

Lines changed: 0 additions & 214 deletions
This file was deleted.

0 commit comments

Comments
 (0)