Skip to content

Commit 9331c15

Browse files
committed
Updated to use tint object.
1 parent 6027b65 commit 9331c15

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

src/renderer/webgl/pipelines/TextureTintPipeline.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,21 @@ var TextureTintPipeline = new Class({
195195
* Cached stroke tint.
196196
*
197197
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint
198-
* @type {number}
198+
* @type {object}
199199
* @private
200200
* @since 3.12.0
201201
*/
202-
this.strokeTint = 0;
202+
this.strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 };
203203

204204
/**
205205
* Cached fill tint.
206206
*
207207
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint
208-
* @type {number}
208+
* @type {object}
209209
* @private
210210
* @since 3.12.0
211211
*/
212-
this.fillTint = 0;
212+
this.fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 };
213213

214214
/**
215215
* Internal texture frame reference.
@@ -600,7 +600,7 @@ var TextureTintPipeline = new Class({
600600
* | \
601601
* | \
602602
* | \
603-
* 1----2
603+
* 1-----2
604604
* ```
605605
*
606606
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri
@@ -616,14 +616,14 @@ var TextureTintPipeline = new Class({
616616
* @param {number} v0 - UV v0 value.
617617
* @param {number} u1 - UV u1 value.
618618
* @param {number} v1 - UV v1 value.
619-
* @param {number} tint1 - The top-left tint color value.
620-
* @param {number} tint2 - The top-right tint color value.
621-
* @param {number} tint3 - The bottom-left tint color value.
619+
* @param {number} tintTL - The top-left tint color value.
620+
* @param {number} tintTR - The top-right tint color value.
621+
* @param {number} tintBL - The bottom-left tint color value.
622622
* @param {(number|boolean)} tintEffect - The tint effect for the shader to use.
623623
*
624624
* @return {boolean} `true` if this method caused the batch to flush, otherwise `false`.
625625
*/
626-
batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tint1, tint2, tint3, tintEffect)
626+
batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect)
627627
{
628628
var hasFlushed = false;
629629

@@ -644,21 +644,21 @@ var TextureTintPipeline = new Class({
644644
vertexViewF32[++vertexOffset] = u0;
645645
vertexViewF32[++vertexOffset] = v0;
646646
vertexViewF32[++vertexOffset] = tintEffect;
647-
vertexViewU32[++vertexOffset] = tint1;
647+
vertexViewU32[++vertexOffset] = tintTL;
648648

649649
vertexViewF32[++vertexOffset] = x2;
650650
vertexViewF32[++vertexOffset] = y2;
651651
vertexViewF32[++vertexOffset] = u0;
652652
vertexViewF32[++vertexOffset] = v1;
653653
vertexViewF32[++vertexOffset] = tintEffect;
654-
vertexViewU32[++vertexOffset] = tint2;
654+
vertexViewU32[++vertexOffset] = tintTR;
655655

656656
vertexViewF32[++vertexOffset] = x3;
657657
vertexViewF32[++vertexOffset] = y3;
658658
vertexViewF32[++vertexOffset] = u1;
659659
vertexViewF32[++vertexOffset] = v1;
660660
vertexViewF32[++vertexOffset] = tintEffect;
661-
vertexViewU32[++vertexOffset] = tint3;
661+
vertexViewU32[++vertexOffset] = tintBL;
662662

663663
this.vertexCount += 3;
664664

@@ -968,9 +968,7 @@ var TextureTintPipeline = new Class({
968968
var u1 = frame.u1;
969969
var v1 = frame.v1;
970970

971-
var tint = this.fillTint;
972-
973-
this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tint, tint, tint, tint, this.tintEffect);
971+
this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.fillTint.BR, this.tintEffect);
974972
},
975973

976974
/**
@@ -1014,9 +1012,7 @@ var TextureTintPipeline = new Class({
10141012
var u1 = frame.u1;
10151013
var v1 = frame.v1;
10161014

1017-
var tint = this.fillTint;
1018-
1019-
this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tint, tint, tint, this.tintEffect);
1015+
this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.tintEffect);
10201016
},
10211017

10221018
/**
@@ -1089,7 +1085,9 @@ var TextureTintPipeline = new Class({
10891085
var polygonIndexArray;
10901086
var point;
10911087

1092-
var tint = this.fillTint;
1088+
var tintTL = this.fillTint.TL;
1089+
var tintTR = this.fillTint.TR;
1090+
var tintBL = this.fillTint.BL;
10931091
var tintEffect = this.tintEffect;
10941092

10951093
for (var pathIndex = 0; pathIndex < length; ++pathIndex)
@@ -1130,7 +1128,7 @@ var TextureTintPipeline = new Class({
11301128
var u1 = frame.u1;
11311129
var v1 = frame.v1;
11321130

1133-
this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tint, tint, tint, tintEffect);
1131+
this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect);
11341132
}
11351133

11361134
polygonCache.length = 0;
@@ -1252,8 +1250,13 @@ var TextureTintPipeline = new Class({
12521250
var u1 = frame.u1;
12531251
var v1 = frame.v1;
12541252

1253+
var tintTL = this.strokeTint.TL;
1254+
var tintTR = this.strokeTint.TR;
1255+
var tintBL = this.strokeTint.BL;
1256+
var tintBR = this.strokeTint.BR;
1257+
12551258
// TL, BL, BR, TR
1256-
this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tint, tint, tint, tint, tintEffect);
1259+
this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
12571260

12581261
if (lineWidth <= 1)
12591262
{
@@ -1266,7 +1269,7 @@ var TextureTintPipeline = new Class({
12661269

12671270
if (index > 0)
12681271
{
1269-
this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tint, tint, tint, tint, tintEffect);
1272+
this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
12701273
}
12711274
else
12721275
{
@@ -1279,7 +1282,7 @@ var TextureTintPipeline = new Class({
12791282
if (closePath)
12801283
{
12811284
// Add a join for the final path segment
1282-
this.batchQuad(first[0], first[1], first[2], first[3], brX, brY, trX, trY, u0, v0, u1, v1, tint, tint, tint, tint, tintEffect);
1285+
this.batchQuad(first[0], first[1], first[2], first[3], brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
12831286
}
12841287
else
12851288
{

0 commit comments

Comments
 (0)