Skip to content

Commit e9efc5e

Browse files
committed
Invokes pre and post batch functions.
1 parent 4287181 commit e9efc5e

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/renderer/webgl/pipelines/MultiPipeline.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ var MultiPipeline = new Class({
192192
*/
193193
batchSprite: function (sprite, camera, parentTransformMatrix)
194194
{
195-
// Will cause a flush if this isn't the current pipeline, vertexbuffer or program
196-
this.renderer.pipelines.set(this, sprite);
195+
this.manager.set(this, sprite);
197196

198197
var camMatrix = this._tempMatrix1;
199198
var spriteMatrix = this._tempMatrix2;
@@ -303,10 +302,13 @@ var MultiPipeline = new Class({
303302
var tx3 = calcMatrix.getX(xw, y);
304303
var ty3 = calcMatrix.getY(xw, y);
305304

306-
var tintTL = Utils.getTintAppendFloatAlpha(sprite.tintTopLeft, camera.alpha * sprite._alphaTL);
307-
var tintTR = Utils.getTintAppendFloatAlpha(sprite.tintTopRight, camera.alpha * sprite._alphaTR);
308-
var tintBL = Utils.getTintAppendFloatAlpha(sprite.tintBottomLeft, camera.alpha * sprite._alphaBL);
309-
var tintBR = Utils.getTintAppendFloatAlpha(sprite.tintBottomRight, camera.alpha * sprite._alphaBR);
305+
var getTint = Utils.getTintAppendFloatAlpha;
306+
var cameraAlpha = camera.alpha;
307+
308+
var tintTL = getTint(sprite.tintTopLeft, cameraAlpha * sprite._alphaTL);
309+
var tintTR = getTint(sprite.tintTopRight, cameraAlpha * sprite._alphaTR);
310+
var tintBL = getTint(sprite.tintBottomLeft, cameraAlpha * sprite._alphaBL);
311+
var tintBR = getTint(sprite.tintBottomRight, cameraAlpha * sprite._alphaBR);
310312

311313
if (camera.roundPixels)
312314
{
@@ -323,17 +325,18 @@ var MultiPipeline = new Class({
323325
ty3 = Math.round(ty3);
324326
}
325327

326-
// So batchQuad never assigns a unit to the glTexture, but to the textureSource instead
327328
if (this.shouldFlush(6))
328329
{
329330
this.flush();
330331
}
331332

332333
var unit = this.setGameObject(sprite, frame);
333334

334-
var tintEffect = sprite.tintFill;
335+
this.manager.preBatch(sprite);
336+
337+
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, sprite.tintEffect, texture, unit);
335338

336-
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, unit);
339+
this.manager.postBatch(sprite);
337340
},
338341

339342
/**
@@ -520,7 +523,11 @@ var MultiPipeline = new Class({
520523
textureUnit = this.renderer.setTexture2D(texture);
521524
}
522525

526+
this.manager.preBatch(gameObject);
527+
523528
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit);
529+
530+
this.manager.postBatch(gameObject);
524531
},
525532

526533
/**
@@ -579,7 +586,7 @@ var MultiPipeline = new Class({
579586
tint = Utils.getTintAppendFloatAlpha(tint, alpha);
580587

581588
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0, frame.glTexture, unit);
582-
},
589+
}
583590

584591
/**
585592
* Pushes a filled rectangle into the vertex batch.
@@ -599,7 +606,6 @@ var MultiPipeline = new Class({
599606
* @param {number} height - Height of the rectangle.
600607
* @param {number} color - Color of the rectangle to draw.
601608
* @param {number} alpha - Alpha value of the rectangle to draw.
602-
*/
603609
drawFillRect: function (x, y, width, height, color, alpha)
604610
{
605611
x = Math.floor(x);
@@ -616,6 +622,7 @@ var MultiPipeline = new Class({
616622
617623
this.batchQuad(x, y, x, yh, xw, yh, xw, y, 0, 0, 1, 1, tint, tint, tint, tint, 2, white, unit);
618624
}
625+
*/
619626

620627
});
621628

0 commit comments

Comments
 (0)