浏览代码

noallocate -- uiPathCache -> PoolItem step 2

/main
xingwei.zhu 5 年前
当前提交
caedf790
共有 3 个文件被更改,包括 21 次插入7 次删除
  1. 3
      Runtime/ui/painting/canvas_clip.cs
  2. 3
      Runtime/ui/painting/canvas_impl.cs
  3. 22
      Runtime/ui/utils/basic_types/path.cs

3
Runtime/ui/painting/canvas_clip.cs


var pathCache = uiPath.flatten(scale);
this.mesh = pathCache.getFillMesh(out this.convex).transform(matrix);
pathCache.dispose();
var vertices = this.mesh.vertices;
if (this.convex && vertices.Count == 4 && matrix.rectStaysRect() &&
(Mathf.Abs(vertices[0].x - vertices[1].x) < 1e-6 && Mathf.Abs(vertices[1].y - vertices[2].y) < 1e-6 &&

3
Runtime/ui/painting/canvas_impl.cs


bool convex;
var mesh = cache.getFillMesh(out convex).transform(state.matrix);
cache.dispose();
Action<Paint> drawMesh = p => {
if (!this._applyClip(mesh.bounds)) {

paint.strokeCap,
paint.strokeJoin,
paint.strokeMiterLimit).transform(state.matrix);
cache.dispose();
Action<Paint> drawMesh = p => {
if (!this._applyClip(mesh.bounds)) {

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


internal uiPathCache flatten(float scale) {
scale = Mathf.Round(scale * 2.0f) / 2.0f; // round to 0.5f
var _cache = new uiPathCache(scale);
var _cache = uiPathCache.create(scale);
var i = 0;
while (i < this._commands.Count) {

public bool convex;
}
class uiPathCache {
class uiPathCache : PoolItem {
float _scale;
float _distTol;
float _tessTol;

public uiPathCache(float scale) {
this._scale = scale;
this._distTol = 0.01f / scale;
this._tessTol = 0.25f / scale;
public static uiPathCache create(float scale) {
uiPathCache newPathCache = ItemPoolManager.alloc<uiPathCache>();
newPathCache._scale = scale;
newPathCache._distTol = 0.01f / scale;
newPathCache._tessTol = 0.25f / scale;
return newPathCache;
}
public override void clear() {
this._paths.Clear();
this._points.Clear();
}
public uiPathCache() {
}
public bool canReuse(float scale) {

正在加载...
取消
保存