浏览代码

noallocate -- use rendering-specified classes 1

/main
xingwei.zhu 5 年前
当前提交
a42ee864
共有 8 个文件被更改,包括 242 次插入96 次删除
  1. 14
      Runtime/ui/painting/canvas_clip.cs
  2. 140
      Runtime/ui/painting/canvas_impl.cs
  3. 34
      Runtime/ui/painting/canvas_shader.cs
  4. 2
      Runtime/ui/painting/path.cs
  5. 46
      Runtime/ui/painting/shader.cs
  6. 14
      Runtime/ui/painting/txt/mesh_generator.cs
  7. 28
      Runtime/ui/utils/basic_types/matrix.cs
  8. 60
      Runtime/ui/utils/basic_types/path.cs

14
Runtime/ui/painting/canvas_clip.cs


namespace Unity.UIWidgets.ui {
class ClipElement {
public readonly int saveCount;
public readonly MeshMesh mesh;
public readonly uiMeshMesh mesh;
public readonly bool convex;
public readonly bool isRect;
public Rect rect { get; private set; }

Rect _bound;
Matrix3 _invMat;
uiMatrix3 _invMat;
public ClipElement(int saveCount, Path path, Matrix3 matrix, float scale) {
public ClipElement(int saveCount, uiPath uiPath, uiMatrix3 matrix, float scale) {
var pathCache = path.flatten(scale);
var pathCache = uiPath.flatten(scale);
this.mesh = pathCache.getFillMesh(out this.convex).transform(matrix);
var vertices = this.mesh.vertices;

if (this.convex) {
if (this.mesh.matrix != null && !this.mesh.matrix.isIdentity()) {
if (this._invMat == null) {
this._invMat = Matrix3.I();
this._invMat = uiMatrix3.I();
this.mesh.matrix.invert(this._invMat); // ignore if not invertible for now.
}

}
}
public void clipPath(Path path, Matrix3 matrix, float scale) {
var element = new ClipElement(this._saveCount, path, matrix, scale);
public void clipPath(uiPath uiPath, uiMatrix3 matrix, float scale) {
var element = new ClipElement(this._saveCount, uiPath, matrix, scale);
this._pushElement(element);
}

140
Runtime/ui/painting/canvas_impl.cs


);
}
var matrix = Matrix3.makeTrans(-bounds.left, -bounds.top);
matrix.postConcat(filter.transform);
var matrix = uiMatrix3.makeTrans(-bounds.left, -bounds.top);
matrix.postConcat(uiMatrix3.fromMatrix3(filter.transform));
matrix.postTranslate(bounds.left, bounds.top);
var mesh = ImageMeshGenerator.imageMesh(

void _translate(float dx, float dy) {
var state = this._currentLayer.currentState;
var matrix = Matrix3.makeTrans(dx, dy);
var matrix = uiMatrix3.makeTrans(dx, dy);
matrix.postConcat(state.matrix);
state.matrix = matrix;
}

var matrix = Matrix3.makeScale(sx, (sy ?? sx));
var matrix = uiMatrix3.makeScale(sx, (sy ?? sx));
matrix.postConcat(state.matrix);
state.matrix = matrix;
}

if (offset == null) {
var matrix = Matrix3.makeRotate(radians);
var matrix = uiMatrix3.makeRotate(radians);
var matrix = Matrix3.makeRotate(radians, offset.dx, offset.dy);
var matrix = uiMatrix3.makeRotate(radians, offset.dx, offset.dy);
matrix.postConcat(state.matrix);
state.matrix = matrix;
}

var state = this._currentLayer.currentState;
var matrix = Matrix3.makeSkew( sx, sy);
var matrix = uiMatrix3.makeSkew( sx, sy);
void _concat(Matrix3 matrix) {
void _concat(uiMatrix3 matrix) {
matrix = new Matrix3(matrix);
matrix = new uiMatrix3(matrix);
matrix.postConcat(state.matrix);
state.matrix = matrix;
}

state.matrix = Matrix3.I();
state.matrix = uiMatrix3.I();
void _setMatrix(Matrix3 matrix) {
void _setMatrix(uiMatrix3 matrix) {
state.matrix = new Matrix3(matrix);
state.matrix = new uiMatrix3(matrix);
var path = new Path();
var path = new uiPath();
var path = new Path();
var path = new uiPath();
void _clipPath(Path path) {
void _clipPath(uiPath path) {
var layer = this._currentLayer;
var state = layer.currentState;
layer.clipStack.clipPath(path, state.matrix, state.scale * this._devicePixelRatio);

// need to inflate a bit to make sure all area is cleared.
var inflatedScissor = reducedClip.scissor.inflate(this._fringeWidth);
var boundsMesh = new MeshMesh(inflatedScissor);
var boundsMesh = new uiMeshMesh(inflatedScissor);
layer.draws.Add(CanvasShader.stencilClear(layer, boundsMesh));
foreach (var maskElement in reducedClip.maskElements) {

layer.draws.Add(CanvasShader.texRT(layer, paint, blurMesh, blurLayer));
}
void _drawPath(Path path, Paint paint) {
void _drawPath(uiPath path, Paint paint) {
D.assert(path != null);
D.assert(paint != null);

break;
}
case DrawConcat cmd: {
this._concat(cmd.matrix);
this._concat(uiMatrix3.fromMatrix3(cmd.matrix));
break;
}
case DrawResetMatrix _:

this._setMatrix(cmd.matrix);
this._setMatrix(uiMatrix3.fromMatrix3(cmd.matrix));
break;
}
case DrawClipRect cmd: {

break;
}
case DrawClipPath cmd: {
this._clipPath(cmd.path);
this._clipPath(uiPath.fromPath(cmd.path));
this._drawPath(cmd.path, cmd.paint);
this._drawPath(uiPath.fromPath(cmd.path), cmd.paint);
break;
}
case DrawImage cmd: {

var state = this._currentLayer.currentState;
var scale = state.scale * this._devicePixelRatio;
var matrix = new Matrix3(state.matrix);
var matrix = new uiMatrix3(state.matrix);
matrix.preTranslate(offset.dx, offset.dy);
var mesh = new TextBlobMesh(textBlob, scale, matrix);

// clear triangles first in order to bypass validation in SetVertices.
cmd.meshObj.SetTriangles((int[]) null, 0, false);
MeshMesh mesh = cmd.mesh;
uiMeshMesh mesh = cmd.mesh;
if (cmd.textMesh != null) {
mesh = cmd.textMesh.resovleMesh();
}

}
internal class State {
static readonly Matrix3 _id = Matrix3.I();
static readonly uiMatrix3 _id = uiMatrix3.I();
Matrix3 _matrix;
uiMatrix3 _matrix;
Matrix3 _invMatrix;
uiMatrix3 _invMatrix;
public State(Matrix3 matrix = null, float? scale = null, Matrix3 invMatrix = null) {
public State(uiMatrix3 matrix = null, float? scale = null, uiMatrix3 invMatrix = null) {
public Matrix3 matrix {
public uiMatrix3 matrix {
get { return this._matrix; }
set {
this._matrix = value ?? _id;

public float scale {
get {
if (this._scale == null) {
this._scale = XformUtils.getScale(this._matrix);
this._scale = uiXformUtils.getScale(this._matrix);
public Matrix3 invMatrix {
public uiMatrix3 invMatrix {
this._invMatrix = Matrix3.I();
this._invMatrix = uiMatrix3.I();
this._matrix.invert(this._invMatrix);
}
return this._invMatrix;

}
internal class CmdDraw {
public MeshMesh mesh;
public uiMeshMesh mesh;
public TextBlobMesh textMesh;
public int pass;
public MaterialPropertyBlock properties;

this._recorder.reset();
this._flusher.flush(picture);
}
}
}
static class uiXformUtils {
public static float getAverageScale(uiMatrix3 matrix) {
return (getScaleX(matrix) + getScaleY(matrix)) * 0.5f;
}
public static float getMaxScale(uiMatrix3 matrix) {
return Mathf.Max(getScaleX(matrix), getScaleY(matrix));
}
public static float getScaleX(uiMatrix3 matrix) {
// ignore perspective parameters for now.
if (matrix.isIdentity()) {
return 1.0f;
}
if (matrix.getSkewY() == 0) {
return matrix.getScaleX();
}
var x = matrix.getScaleX();
var y = matrix.getSkewY();
return Mathf.Sqrt(x * x + y * y);
}
public static float getScaleY(uiMatrix3 matrix) {
// ignore perspective parameters for now.
if (matrix.isIdentity()) {
return 1.0f;
}
if (matrix.getSkewX() == 0) {
return matrix.getScaleY();
}
var x = matrix.getSkewX();
var y = matrix.getScaleY();
return Mathf.Sqrt(x * x + y * y);
}
public static float getScale(uiMatrix3 matrix) {
var scaleX = getScaleX(matrix);
var scaleY = getScaleY(matrix);
if (scaleX == 1.0) {
return scaleY;
}
if (scaleY == 1.0) {
return scaleX;
}
// geometric mean of len0 and len1.
return Mathf.Sqrt(scaleX * scaleY);
}
public static float mapRadius(uiMatrix3 matrix, float radius) {
return getScale(matrix) * radius;
}
}
static class XformUtils {
public static float getAverageScale(Matrix3 matrix) {

10, 11, 14, 11, 15, 14,
};
public static MeshMesh imageMesh(Matrix3 matrix,
public static uiMeshMesh imageMesh(uiMatrix3 matrix,
Offset srcTL, Offset srcBL, Offset srcBR, Offset srcTR,
Rect dst) {
var vertices = new List<Vector3>(4);

vertices.Add(new Vector2(dst.right, dst.top));
uv.Add(new Vector2(srcTR.dx, 1.0f - srcTR.dy));
return new MeshMesh(matrix, vertices, _imageTriangles, uv);
return new uiMeshMesh(matrix, vertices, _imageTriangles, uv);
public static MeshMesh imageMesh(Matrix3 matrix, Rect src, Rect dst) {
public static uiMeshMesh imageMesh(uiMatrix3 matrix, Rect src, Rect dst) {
var vertices = new List<Vector3>(4);
var uv = new List<Vector2>(4);

vertices.Add(new Vector2(dst.right, dst.top));
uv.Add(new Vector2(uvx1, uvy0));
return new MeshMesh(matrix, vertices, _imageTriangles, uv);
return new uiMeshMesh(matrix, vertices, _imageTriangles, uv);
public static MeshMesh imageNineMesh(Matrix3 matrix, Rect src, Rect center, int srcWidth, int srcHeight, Rect dst) {
public static uiMeshMesh imageNineMesh(uiMatrix3 matrix, Rect src, Rect center, int srcWidth, int srcHeight, Rect dst) {
float x0 = dst.left;
float x3 = dst.right;
float x1 = x0 + ((center.left - src.left) * srcWidth);

vertices.Add(new Vector2(x3, y3));
uv.Add(new Vector2(tx3, ty3));
return new MeshMesh(matrix, vertices, _imageNineTriangles, uv);
return new uiMeshMesh(matrix, vertices, _imageNineTriangles, uv);
}
}
}

34
Runtime/ui/painting/canvas_shader.cs


);
}
static Matrix3 _getShaderMatBase(PictureFlusher.State state, Matrix3 meshMatrix) {
static uiMatrix3 _getShaderMatBase(PictureFlusher.State state, uiMatrix3 meshMatrix) {
return Matrix3.I();
return uiMatrix3.I();
}
if (meshMatrix == null) {

return Matrix3.concat(state.invMatrix, meshMatrix);
return uiMatrix3.concat(state.invMatrix, meshMatrix);
PictureFlusher.RenderLayer layer, Paint paint, Matrix3 meshMatrix, float alpha,
PictureFlusher.RenderLayer layer, Paint paint, uiMatrix3 meshMatrix, float alpha,
out int pass, out MaterialPropertyBlock props) {
Vector4 viewport = layer.viewport;

}
public static PictureFlusher.CmdDraw convexFill(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh) {
uiMeshMesh mesh) {
var mat = _convexFillMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props);

};
}
public static PictureFlusher.CmdDraw fill0(PictureFlusher.RenderLayer layer, MeshMesh mesh) {
public static PictureFlusher.CmdDraw fill0(PictureFlusher.RenderLayer layer, uiMeshMesh mesh) {
Vector4 viewport = layer.viewport;
var mat = _fill0Mat.getMaterial(layer.ignoreClip);

}
public static PictureFlusher.CmdDraw fill1(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh) {
uiMeshMesh mesh) {
var mat = _fill1Mat.getMaterial(paint.blendMode);
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props);

}
public static PictureFlusher.CmdDraw stroke0(PictureFlusher.RenderLayer layer, Paint paint,
float alpha, MeshMesh mesh) {
float alpha, uiMeshMesh mesh) {
var mat = _stroke0Mat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh.matrix, alpha, out var pass, out var props);

};
}
public static PictureFlusher.CmdDraw stroke1(PictureFlusher.RenderLayer layer, MeshMesh mesh) {
public static PictureFlusher.CmdDraw stroke1(PictureFlusher.RenderLayer layer, uiMeshMesh mesh) {
Vector4 viewport = layer.viewport;
var mat = _stroke1Mat;

}
public static PictureFlusher.CmdDraw stencilClear(
PictureFlusher.RenderLayer layer, MeshMesh mesh) {
PictureFlusher.RenderLayer layer, uiMeshMesh mesh) {
Vector4 viewport = layer.viewport;
var mat = _stencilMat;

};
}
public static PictureFlusher.CmdDraw stencil0(PictureFlusher.RenderLayer layer, MeshMesh mesh) {
public static PictureFlusher.CmdDraw stencil0(PictureFlusher.RenderLayer layer, uiMeshMesh mesh) {
Vector4 viewport = layer.viewport;
var mat = _stencilMat;

};
}
public static PictureFlusher.CmdDraw stencil1(PictureFlusher.RenderLayer layer, MeshMesh mesh) {
public static PictureFlusher.CmdDraw stencil1(PictureFlusher.RenderLayer layer, uiMeshMesh mesh) {
Vector4 viewport = layer.viewport;
var mat = _stencilMat;

}
public static PictureFlusher.CmdDraw tex(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, Image image) {
uiMeshMesh mesh, Image image) {
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props);

}
public static PictureFlusher.CmdDraw texRT(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, PictureFlusher.RenderLayer renderLayer) {
uiMeshMesh mesh, PictureFlusher.RenderLayer renderLayer) {
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
_getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, out var pass, out var props);
props.SetInt(_texModeId, 1); // pre alpha

}
public static PictureFlusher.CmdDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, Texture tex) {
uiMeshMesh mesh, Texture tex) {
return texAlpha(layer, paint, mesh, null, tex);
}

}
public static PictureFlusher.CmdDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
MeshMesh mesh, TextBlobMesh textMesh, Texture tex) {
uiMeshMesh mesh, TextBlobMesh textMesh, Texture tex) {
var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
var meshMatrix = mesh != null ? mesh.matrix : textMesh.matrix;

};
}
public static PictureFlusher.CmdDraw maskFilter(PictureFlusher.RenderLayer layer, MeshMesh mesh,
public static PictureFlusher.CmdDraw maskFilter(PictureFlusher.RenderLayer layer, uiMeshMesh mesh,
PictureFlusher.RenderLayer renderLayer, float radius, Vector2 imgInc, float[] kernel) {
Vector4 viewport = layer.viewport;
var mat = _filterMat;

2
Runtime/ui/painting/path.cs


this._reset();
}
public List<float> commands => this._commands;
public override string ToString() {
var sb = new StringBuilder("Path: count = " + this._commands.Count);

46
Runtime/ui/painting/shader.cs


public static Gradient linear(
Offset start, Offset end, List<Color> colors,
List<float> colorStops = null, TileMode tileMode = TileMode.clamp,
Matrix3 matrix = null) {
uiMatrix3 matrix = null) {
D.assert(PaintingUtils._offsetIsValid(start));
D.assert(PaintingUtils._offsetIsValid(end));
D.assert(colors != null && colors.Count >= 2);

public static Gradient radial(
Offset center, float radius, List<Color> colors,
List<float> colorStops = null, TileMode tileMode = TileMode.clamp,
Matrix3 matrix = null) {
uiMatrix3 matrix = null) {
D.assert(PaintingUtils._offsetIsValid(center));
D.assert(colors != null && colors.Count >= 2);

Offset center, List<Color> colors,
List<float> colorStops = null, TileMode tileMode = TileMode.clamp,
float startAngle = 0.0f, float endAngle = Mathf.PI * 2,
Matrix3 matrix = null) {
uiMatrix3 matrix = null) {
D.assert(PaintingUtils._offsetIsValid(center));
D.assert(colors != null && colors.Count >= 2);
D.assert(startAngle < endAngle);

public _LinearGradient(
Offset start, Offset end, List<Color> colors,
List<float> colorStops, TileMode tileMode,
Matrix3 matrix = null) {
uiMatrix3 matrix = null) {
this.start = start;
this.end = end;
this.colors = colors;

public readonly List<Color> colors;
public readonly List<float> colorStops;
public readonly TileMode tileMode;
public readonly Matrix3 matrix;
public readonly Matrix3 ptsToUnit;
public readonly uiMatrix3 matrix;
public readonly uiMatrix3 ptsToUnit;
public readonly Image gradientTex;
public Color leftColor {

get { return this.colors[this.colors.Count - 1]; }
}
public Matrix3 getGradientMat(Matrix3 mat) {
public uiMatrix3 getGradientMat(uiMatrix3 mat) {
if (this.matrix != null) {
mat.postConcat(this.matrix);
}

}
static Matrix3 ptsToUnitMatrix(Offset start, Offset end) {
static uiMatrix3 ptsToUnitMatrix(Offset start, Offset end) {
var matrix = Matrix3.I();
var matrix = uiMatrix3.I();
matrix.setSinCos(-vec.dy, vec.dx, start.dx, start.dy);
matrix.postTranslate(-start.dx, -start.dy);
matrix.postScale(inv, inv);

public _RadialGradient(
Offset center, float radius, List<Color> colors,
List<float> colorStops = null, TileMode tileMode = TileMode.clamp,
Matrix3 matrix = null
uiMatrix3 matrix = null
) {
this.center = center;
this.radius = radius;

public readonly List<Color> colors;
public readonly List<float> colorStops;
public readonly TileMode tileMode;
public readonly Matrix3 matrix;
public readonly Matrix3 ptsToUnit;
public readonly uiMatrix3 matrix;
public readonly uiMatrix3 ptsToUnit;
public readonly Image gradientTex;
public Color leftColor {

get { return this.colors[this.colors.Count - 1]; }
}
public Matrix3 getGradientMat(Matrix3 mat) {
public uiMatrix3 getGradientMat(uiMatrix3 mat) {
if (this.matrix != null) {
mat.postConcat(this.matrix);
}

}
static Matrix3 radToUnitMatrix(Offset center, float radius) {
static uiMatrix3 radToUnitMatrix(Offset center, float radius) {
var matrix = Matrix3.I();
var matrix = uiMatrix3.I();
matrix.setTranslate(-center.dx, -center.dy);
matrix.postScale(inv, inv);
return matrix;

Offset center, List<Color> colors,
List<float> colorStops = null, TileMode tileMode = TileMode.clamp,
float startAngle = 0.0f, float endAngle = Mathf.PI * 2,
Matrix3 matrix = null
uiMatrix3 matrix = null
) {
this.center = center;
this.colors = colors;

this.bias = -t0;
this.scale = 1f / (t1 - t0);
var ptsToUnit = Matrix3.I();
var ptsToUnit = uiMatrix3.I();
ptsToUnit.setTranslate(-center.dx, -center.dy);
this.ptsToUnit = ptsToUnit;

public readonly TileMode tileMode;
public readonly float startAngle;
public readonly float endAngle;
public readonly Matrix3 matrix;
public readonly Matrix3 ptsToUnit;
public readonly uiMatrix3 matrix;
public readonly uiMatrix3 ptsToUnit;
public readonly Image gradientTex;
public readonly float bias;
public readonly float scale;

get { return this.colors[this.colors.Count - 1]; }
}
public Matrix3 getGradientMat(Matrix3 mat) {
public uiMatrix3 getGradientMat(uiMatrix3 mat) {
if (this.matrix != null) {
mat.postConcat(this.matrix);
}

public class ImageShader : PaintShader {
public ImageShader(Image image,
TileMode tileMode = TileMode.clamp, Matrix3 matrix = null) {
TileMode tileMode = TileMode.clamp, uiMatrix3 matrix = null) {
this.image = image;
this.tileMode = tileMode;
this.matrix = matrix;

public readonly TileMode tileMode;
public readonly Matrix3 matrix;
public readonly uiMatrix3 matrix;
public Matrix3 getShaderMat(Matrix3 mat) {
public uiMatrix3 getShaderMat(uiMatrix3 mat) {
if (this.matrix != null) {
mat.postConcat(this.matrix);
}

14
Runtime/ui/painting/txt/mesh_generator.cs


class MeshInfo {
public readonly MeshKey key;
public readonly long textureVersion;
public readonly MeshMesh mesh;
public readonly uiMeshMesh mesh;
public MeshInfo(MeshKey key, MeshMesh mesh, long textureVersion, int timeToLive = 5) {
public MeshInfo(MeshKey key, uiMeshMesh mesh, long textureVersion, int timeToLive = 5) {
this.mesh = mesh;
this.key = key;
this.textureVersion = textureVersion;

public readonly TextBlob textBlob;
public readonly float scale;
public readonly Matrix3 matrix;
public readonly uiMatrix3 matrix;
MeshMesh _mesh;
uiMeshMesh _mesh;
public TextBlobMesh(TextBlob textBlob, float scale, Matrix3 matrix) {
public TextBlobMesh(TextBlob textBlob, float scale, uiMatrix3 matrix) {
this.textBlob = textBlob;
this.scale = scale;
this.matrix = matrix;

}
}
public MeshMesh resovleMesh() {
public uiMeshMesh resovleMesh() {
if (this._resolved) {
return this._mesh;
}

return null;
}
MeshMesh mesh = vertices.Count > 0 ? new MeshMesh(null, vertices, triangles, uv) : null;
uiMeshMesh mesh = vertices.Count > 0 ? new uiMeshMesh(null, vertices, triangles, uv) : null;
_meshes[key] = new MeshInfo(key, mesh, fontInfo.textureVersion);
this._mesh = mesh.transform(this.matrix);

28
Runtime/ui/utils/basic_types/matrix.cs


public Offset mapPoint(Offset point) {
return this.mapXY(point.dx, point.dy);
}
public Matrix4x4 toMatrix4x4() {
var matrix = Matrix4x4.identity;
matrix[0, 0] = this[0]; // row 0
matrix[0, 1] = this[1];
matrix[0, 3] = this[2];
matrix[1, 0] = this[3]; // row 1
matrix[1, 1] = this[4];
matrix[1, 3] = this[5];
matrix[3, 0] = this[6]; // row 2
matrix[3, 1] = this[7];
matrix[3, 3] = this[8];
return matrix;
}
public static uiMatrix3 fromMatrix3(Matrix3 mat3) {
var uiMat3 = I();
for (int i = 0; i < 9; i++) {
uiMat3[i] = mat3[i];
}
uiMat3.setTypeMask(kUnknown_Mask);
return uiMat3;
}
}
class uiScalarUtils {

60
Runtime/ui/utils/basic_types/path.cs


this.addPath(path, transform);
}
public static uiPath fromPath(Path path) {
D.assert(path != null);
uiPath uipath = new uiPath();
var i = 0;
var _commands = path.commands;
while (i < _commands.Count) {
var cmd = (uiPathCommand) _commands[i];
switch (cmd) {
case uiPathCommand.moveTo: {
float x = _commands[i + 1];
float y = _commands[i + 2];
uipath._appendMoveTo(x, y);
}
i += 3;
break;
case uiPathCommand.lineTo: {
float x = _commands[i + 1];
float y = _commands[i + 2];
uipath._appendLineTo(x, y);
}
i += 3;
break;
case uiPathCommand.bezierTo: {
float c1x = _commands[i + 1];
float c1y = _commands[i + 2];
float c2x = _commands[i + 3];
float c2y = _commands[i + 4];
float x1 = _commands[i + 5];
float y1 = _commands[i + 6];
uipath._appendBezierTo(c1x, c1y, c2x, c2y, x1, y1);
}
i += 7;
break;
case uiPathCommand.close:
uipath._appendClose();
i++;
break;
case uiPathCommand.winding:
uipath._appendWinding(_commands[i + 1]);
i += 2;
break;
default:
D.assert(false, () => "unknown cmd: " + cmd);
break;
}
}
return uipath;
}
public void addPath(uiPath path, Matrix3 transform = null) {
D.assert(path != null);

public readonly List<Vector3> vertices;
public readonly List<int> triangles;
public readonly List<Vector2> uv;
public readonly Matrix3 matrix;
public readonly uiMatrix3 matrix;
public readonly Rect rawBounds;
Rect _bounds;

this._boundsMesh = this;
}
public uiMeshMesh(Matrix3 matrix, List<Vector3> vertices, List<int> triangles, List<Vector2> uv = null,
public uiMeshMesh(uiMatrix3 matrix, List<Vector3> vertices, List<int> triangles, List<Vector2> uv = null,
Rect rawBounds = null) {
D.assert(vertices != null);
D.assert(vertices.Count >= 0);

this.rawBounds = rawBounds;
}
public uiMeshMesh transform(Matrix3 matrix) {
public uiMeshMesh transform(uiMatrix3 matrix) {
return new uiMeshMesh(matrix, this.vertices, this.triangles, this.uv, this.rawBounds);
}
}

正在加载...
取消
保存