|
|
|
|
|
|
|
|
|
|
var matrix = new Matrix3(state.matrix); |
|
|
|
matrix.preTranslate(offset.dx, offset.dy); |
|
|
|
var mesh = MeshGenerator.generateMesh(textBlob, scale)?.transform(matrix); |
|
|
|
if (mesh == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
var mesh = new TextBlobMesh(textBlob, scale, matrix); |
|
|
|
// request font texture so text mesh could be generated correctly
|
|
|
|
var style = textBlob.style; |
|
|
|
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * scale); |
|
|
|
var subText = textBlob.text.Substring(textBlob.textOffset, textBlob.textSize); |
|
|
|
font.RequestCharactersInTexture(subText, fontSizeToLoad, style.UnityFontStyle); |
|
|
|
|
|
|
|
if (!this._applyClip(mesh.bounds)) { |
|
|
|
if (!this._applyClip(textBlob.bounds)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (paint.maskFilter != null && paint.maskFilter.sigma != 0) { |
|
|
|
this._drawWithMaskFilter(mesh.bounds, drawMesh, paint, paint.maskFilter); |
|
|
|
this._drawWithMaskFilter(textBlob.bounds, drawMesh, paint, paint.maskFilter); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
public void flush(Picture picture) { |
|
|
|
this._reset(); |
|
|
|
|
|
|
|
this._drawPicture(picture, false); |
|
|
|
|
|
|
|
D.assert(this._layers.Count == 1); |
|
|
|
|
|
|
// clear triangles first in order to bypass validation in SetVertices.
|
|
|
|
cmd.meshObj.SetTriangles((int[]) null, 0, false); |
|
|
|
|
|
|
|
cmd.meshObj.SetVertices(cmd.mesh.vertices); |
|
|
|
cmd.meshObj.SetTriangles(cmd.mesh.triangles, 0, false); |
|
|
|
cmd.meshObj.SetUVs(0, cmd.mesh.uv); |
|
|
|
MeshMesh mesh = cmd.mesh; |
|
|
|
if (cmd.textMesh != null) { |
|
|
|
mesh = cmd.textMesh.resovleMesh(); |
|
|
|
} |
|
|
|
|
|
|
|
cmd.meshObj.SetVertices(mesh.vertices); |
|
|
|
cmd.meshObj.SetTriangles(mesh.triangles, 0, false); |
|
|
|
cmd.meshObj.SetUVs(0, mesh.uv); |
|
|
|
if (cmd.mesh.matrix == null) { |
|
|
|
if (mesh.matrix == null) { |
|
|
|
cmd.properties.SetFloatArray(RenderDraw.matId, cmd.mesh.matrix.fMat); |
|
|
|
cmd.properties.SetFloatArray(RenderDraw.matId, mesh.matrix.fMat); |
|
|
|
} |
|
|
|
|
|
|
|
cmdBuf.DrawMesh(cmd.meshObj, RenderDraw.idMat, cmd.material, 0, cmd.pass, cmd.properties); |
|
|
|
|
|
|
|
|
|
|
internal class RenderDraw { |
|
|
|
public MeshMesh mesh; |
|
|
|
public TextBlobMesh textMesh; |
|
|
|
public int pass; |
|
|
|
public MaterialPropertyBlock properties; |
|
|
|
public RenderLayer layer; |
|
|
|