浏览代码

some fixes.

/main
kg 5 年前
当前提交
9379b106
共有 4 个文件被更改,包括 113 次插入88 次删除
  1. 10
      Runtime/Unity.UIWidgets.asmdef
  2. 74
      Runtime/ui/painting/path.cs
  3. 51
      Runtime/ui/painting/tessellation_generator.cs
  4. 66
      Runtime/ui/painting/txt/font_manager.cs

10
Runtime/Unity.UIWidgets.asmdef


{
"name": "Unity.UIWidgets",
"references": [],
"optionalUnityReferences": [],
"excludePlatforms": []
}
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

74
Runtime/ui/painting/path.cs


PathCache _cache;
public Path(int capacity = 0) {
public Path(int capacity = 128) {
this._commands = new List<float>(capacity);
this._reset();
}

clockwise = 2, // which just means the reversed order.
}
[Flags]
enum PointFlags {
corner = 0x01,
left = 0x02,
bevel = 0x04,
innerBevel = 0x08,
}
class PathPoint {
public float x, y;
public float dx, dy;
public float len;
public float dmx, dmy;
public PointFlags flags;
}
enum PathCommand {
moveTo,
lineTo,
bezierTo,
close,
winding,
}
class _Conic {
public float x0;
public float y0;

}
}
enum PathCommand {
moveTo,
lineTo,
bezierTo,
close,
winding,
}
[Flags]
enum PointFlags {
corner = 0x01,
left = 0x02,
bevel = 0x04,
innerBevel = 0x08,
}
class PathPoint {
public float x, y;
public float dx, dy;
public float len;
public float dmx, dmy;
public PointFlags flags;
}
class PathPath {
public int first;
public int count;

y1 = pt.y;
}
if (x1 == x2 && x1 == x3 && x1 == x4 &&
y1 == y2 && y1 == y3 && y1 == y4) {
return;
}
D.assert(points.Count > 0);
points[points.Count - 1].flags = flags;
foreach (var point in points) {
this._addPoint(point);
D.assert(points.Count > 0);
for (int i = 0; i < points.Count; i++) {
var point = points[i];
if (i == points.Count - 1) {
this._addPoint(new PathPoint {
x = point.x + x1,
y = point.y + y1,
flags = flags,
});
} else {
this._addPoint(new PathPoint {
x = point.x + x1,
y = point.y + y1,
});
}
}
}

51
Runtime/ui/painting/tessellation_generator.cs


return true;
}
return this.x2.Equals(other.x2) && this.y2.Equals(other.y2) && this.x3.Equals(other.x3) &&
this.y3.Equals(other.y3) && this.x4.Equals(other.x4) && this.y4.Equals(other.y4) &&
this.tessTol.Equals(other.tessTol);
return this.x2 == other.x2 && this.y2 == other.y2 && this.x3 == other.x3 &&
this.y3 == other.y3 && this.x4 == other.x4 && this.y4 == other.y4 &&
this.tessTol == other.tessTol;
}
public override bool Equals(object obj) {

return this.Equals((TessellationKey) obj);
}
public override int GetHashCode() {
public override unsafe int GetHashCode() {
var hashCode = this.x2.GetHashCode();
hashCode = (hashCode * 397) ^ this.y2.GetHashCode();
hashCode = (hashCode * 397) ^ this.x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.y3.GetHashCode();
hashCode = (hashCode * 397) ^ this.x4.GetHashCode();
hashCode = (hashCode * 397) ^ this.y4.GetHashCode();
hashCode = (hashCode * 397) ^ this.tessTol.GetHashCode();
var hashCode = 0;
float x = this.x2;
hashCode ^= *(int*) &x;
x = this.y2;
hashCode = (hashCode * 13) ^ *(int*) &x;
x = this.x3;
hashCode = (hashCode * 13) ^ *(int*) &x;
x = this.y3;
hashCode = (hashCode * 13) ^ *(int*) &x;
x = this.x4;
hashCode = (hashCode * 13) ^ *(int*) &x;
x = this.y4;
hashCode = (hashCode * 13) ^ *(int*) &x;
x = this.tessTol;
hashCode = (hashCode * 13) ^ *(int*) &x;
return hashCode;
}
}

}
}
public static List<PathPoint> tessellateBezier(float x1, float y1, float x2, float y2,
public static List<Vector2> tessellateBezier(float x1, float y1, float x2, float y2,
float x3, float y3, float x4, float y4, float tessTol) {
var key = new TessellationKey(x1, y1, x2, y2, x3, y3, x4, y4, tessTol);

return _toPathPoints(tessellationInfo.points, x1, y1);
return tessellationInfo.points;
return _toPathPoints(points, x1, y1);
}
static List<PathPoint> _toPathPoints(List<Vector2> points, float x1, float y1) {
var pathPoints = new List<PathPoint>(points.Count);
foreach (var point in points) {
pathPoints.Add(new PathPoint {
x = point.x + x1,
y = point.y + y1,
});
}
return pathPoints;
return points;
}
struct _StackData {

66
Runtime/ui/painting/txt/font_manager.cs


}
class GlyphInfo {
struct GlyphInfo {
public static readonly GlyphInfo empty = new GlyphInfo();
public static GlyphInfo empty = new GlyphInfo(Rect.zero,0, 0, new Vector2(0, 0),
new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0));
public readonly Rect rect;
public readonly float advance;
public readonly float glyphHeight;
public readonly Vector2 uvTopLeft;
public readonly Vector2 uvTopRight;
public readonly Vector2 uvBottomLeft;
public readonly Vector2 uvBottomRight;
Rect _rect;
readonly CharacterInfo _info;
this.rect = Rect.fromLTRB(info.minX, -info.maxY, info.maxX, -info.minY);
this.advance = info.advance;
this.glyphHeight = info.glyphHeight;
this.uvTopLeft = info.uvTopLeft;
this.uvTopRight = info.uvTopRight;
this.uvBottomLeft = info.uvBottomLeft;
this.uvBottomRight = info.uvBottomRight;
this._rect = null;
this._info = info;
public GlyphInfo(Rect rect, float advance, float glyphHeight,
Vector2 uvTopLeft, Vector2 uvTopRight, Vector2 uvBottomLeft, Vector2 uvBottomRight) {
this.rect = rect;
this.advance = advance;
this.glyphHeight = glyphHeight;
this.uvTopLeft = uvTopLeft;
this.uvTopRight = uvTopRight;
this.uvBottomLeft = uvBottomLeft;
this.uvBottomRight = uvBottomRight;
public Rect rect {
get {
if (this._rect == null) {
this._rect = Rect.fromLTRB(this._info.minX, -this._info.maxY, this._info.maxX, -this._info.minY);
}
return this._rect;
}
}
public float advance {
get { return this._info.advance; }
}
public float glyphHeight {
get { return this._info.advance; }
}
public Vector2 uvTopLeft {
get { return this._info.uvTopLeft; }
public Vector2 uvTopRight {
get { return this._info.uvTopRight; }
}
public Vector2 uvBottomLeft {
get { return this._info.uvBottomLeft; }
}
public Vector2 uvBottomRight {
get { return this._info.uvBottomRight; }
}
}
public static class FontExtension

正在加载...
取消
保存