浏览代码

uiPath will hold the PathCache, as in original implementation of Path

/main
xingwei.zhu 5 年前
当前提交
36962a7b
共有 5 个文件被更改,包括 39 次插入6 次删除
  1. 1
      Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_clip.cs
  2. 2
      Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
  3. 3
      Runtime/ui/utils/renderer/common/picture.cs
  4. 27
      Runtime/ui/utils/renderer/geometry/path/path.cs
  5. 12
      Runtime/ui/utils/renderer/geometry/path/path_cache.cs

1
Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_clip.cs


var pathCache = uiPath.flatten(scale);
var fillMesh = pathCache.getFillMesh(out newElement.convex);
newElement.mesh = fillMesh.transform(matrix);
pathCache.dispose();
var vertices = newElement.mesh.vertices;
if (newElement.convex && vertices.Count == 4 && matrix.rectStaysRect() &&

2
Runtime/ui/utils/renderer/cmdbufferCanvas/rendering/canvas_impl.cs


bool convex;
var fillMesh = cache.getFillMesh(out convex);
var mesh = fillMesh.transform(state.matrix);
cache.dispose();
if (paint.maskFilter != null && paint.maskFilter.sigma != 0) {
this._drawWithMaskFilter(mesh.bounds, paint, paint.maskFilter, mesh, convex, 0, null, uiRectHelper.zero, null, this._drawPathDrawMeshCallback);

paint.strokeMiterLimit);
var mesh = strokenMesh.transform(state.matrix);
cache.dispose();
if (paint.maskFilter != null && paint.maskFilter.sigma != 0) {
this._drawWithMaskFilter(mesh.bounds, paint, paint.maskFilter, mesh, false, alpha, null, uiRectHelper.zero, null, this._drawPathDrawMeshCallback2);

3
Runtime/ui/utils/renderer/common/picture.cs


var transformedMesh = rectMesh.transform(state.xform);
var rect = transformedMesh.bounds;
state.scissor = state.scissor == null ? rect : state.scissor.Value.intersect(rect);
rectPathCache.dispose();
transformedMesh.dispose();
break;
}

var cache = path.flatten(scale * devicePixelRatio);
var fillMesh = cache.getFillMesh(out _);
mesh = fillMesh.transform(state.xform);
cache.dispose();
} else {
float strokeWidth = (paint.strokeWidth * scale).clamp(0, 200.0f);
float fringeWidth = 1 / devicePixelRatio;

paint.strokeMiterLimit);
mesh = strokenMesh.transform(state.xform);
cache.dispose();
}
if (paint.maskFilter != null && paint.maskFilter.sigma != 0) {

27
Runtime/ui/utils/renderer/geometry/path/path.cs


float _commandy;
float _minX, _minY;
float _maxX, _maxY;
uiPathCache _cache;
public static uiPath create(int capacity = 128) {
uiPath newPath = ItemPoolManager.alloc<uiPath>();

public override void clear() {
this._commands.dispose();
this._cache?.dispose();
this._cache = null;
}
void _reset() {

this._minY = float.MaxValue;
this._maxX = float.MinValue;
this._maxY = float.MinValue;
this._cache?.dispose();
this._cache = null;
if (this._cache != null && this._cache.canReuse(scale)) {
return this._cache;
}
var _cache = uiPathCache.create(scale);
var i = 0;

}
_cache.normalize();
this._cache?.dispose();
this._cache = _cache;
return _cache;
}

this._commandx = x;
this._commandy = y;
this._cache?.dispose();
this._cache = null;
}
void _appendLineTo(float x, float y) {

this._commandx = x;
this._commandy = y;
this._cache?.dispose();
this._cache = null;
}
void _appendBezierTo(float x1, float y1, float x2, float y2, float x3, float y3) {

this._commandx = x3;
this._commandy = y3;
this._cache?.dispose();
this._cache = null;
this._cache?.dispose();
this._cache = null;
this._cache?.dispose();
this._cache = null;
}
public void addRect(uiRect rect) {

12
Runtime/ui/utils/renderer/geometry/path/path_cache.cs


using UnityEngine;
namespace Unity.UIWidgets.ui {
class uiPathCache : PoolItem {
float _distTol;
float _tessTol;

float _scale;
//mesh cache
uiMeshMesh _fillMesh;

uiPathCache newPathCache = ItemPoolManager.alloc<uiPathCache>();
newPathCache._distTol = 0.01f / scale;
newPathCache._tessTol = 0.25f / scale;
newPathCache._scale = scale;
}
public bool canReuse(float scale) {
if (this._scale != scale) {
return false;
}
return true;
}
public override void clear() {

正在加载...
取消
保存