Skip to content

Commit c0109c1

Browse files
committed
BatchChar is a new internal private function for batching a single character of a Bitmap Text to the pipeline.
1 parent 883670f commit c0109c1

2 files changed

Lines changed: 54 additions & 23 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2020 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* Renders one character of the Bitmap Text to the WebGL Pipeline.
9+
*
10+
* @function BatchChar
11+
* @since 3.50.0
12+
* @private
13+
*
14+
* @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The BitmapText Game Object.
15+
* @param {Phaser.GameObjects.BitmapText} src - The BitmapText Game Object.
16+
* @param {Phaser.Types.GameObjects.BitmapText.BitmapTextCharacter} char - The character to render.
17+
* @param {Phaser.Types.GameObjects.BitmapText.BitmapFontCharacterData} glyph - The character glyph.
18+
* @param {number} offsetX - The x offset.
19+
* @param {number} offsetY - The y offset.
20+
* @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix.
21+
* @param {boolean} roundPixels - Round the transform values or not?
22+
* @param {number} tintTL - Top-left tint value.
23+
* @param {number} tintTR - Top-right tint value.
24+
* @param {number} tintBL - Bottom-left tint value.
25+
* @param {number} tintBR - Bottom-right tint value.
26+
* @param {number} tintEffect - The tint effect mode.
27+
* @param {WebGLTexture} texture - The WebGL texture.
28+
* @param {number} textureUnit - The texture unit.
29+
*/
30+
var BatchChar = function (pipeline, src, char, glyph, offsetX, offsetY, calcMatrix, roundPixels, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit)
31+
{
32+
var x = (char.x - src.displayOriginX) + offsetX;
33+
var y = (char.y - src.displayOriginY) + offsetY;
34+
35+
var xw = x + char.w;
36+
var yh = y + char.h;
37+
38+
var tx0 = calcMatrix.getXRound(x, y, roundPixels);
39+
var ty0 = calcMatrix.getYRound(x, y, roundPixels);
40+
41+
var tx1 = calcMatrix.getXRound(x, yh, roundPixels);
42+
var ty1 = calcMatrix.getYRound(x, yh, roundPixels);
43+
44+
var tx2 = calcMatrix.getXRound(xw, yh, roundPixels);
45+
var ty2 = calcMatrix.getYRound(xw, yh, roundPixels);
46+
47+
var tx3 = calcMatrix.getXRound(xw, y, roundPixels);
48+
var ty3 = calcMatrix.getYRound(xw, y, roundPixels);
49+
50+
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, glyph.u0, glyph.v0, glyph.u1, glyph.v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit);
51+
};
52+
53+
module.exports = BatchChar;

src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,9 @@
44
* @license {@link https://opensource.org/licenses/MIT|MIT License}
55
*/
66

7+
var BatchChar = require('../BatchChar');
78
var Utils = require('../../../renderer/webgl/Utils');
89

9-
function BatchChar (pipeline, src, char, glyph, offsetX, offsetY, calcMatrix, roundPixels, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit)
10-
{
11-
var x = (char.x - src.displayOriginX) + offsetX;
12-
var y = (char.y - src.displayOriginY) + offsetY;
13-
14-
var xw = x + char.w;
15-
var yh = y + char.h;
16-
17-
var tx0 = calcMatrix.getXRound(x, y, roundPixels);
18-
var ty0 = calcMatrix.getYRound(x, y, roundPixels);
19-
20-
var tx1 = calcMatrix.getXRound(x, yh, roundPixels);
21-
var ty1 = calcMatrix.getYRound(x, yh, roundPixels);
22-
23-
var tx2 = calcMatrix.getXRound(xw, yh, roundPixels);
24-
var ty2 = calcMatrix.getYRound(xw, yh, roundPixels);
25-
26-
var tx3 = calcMatrix.getXRound(xw, y, roundPixels);
27-
var ty3 = calcMatrix.getYRound(xw, y, roundPixels);
28-
29-
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, glyph.u0, glyph.v0, glyph.u1, glyph.v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, textureUnit);
30-
}
31-
3210
/**
3311
* Renders this Game Object with the WebGL Renderer to the given Camera.
3412
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.

0 commit comments

Comments
 (0)