浏览代码

fix gc problem

/main
xingwei.zhu 5 年前
当前提交
70d96acd
共有 2 个文件被更改,包括 36 次插入45 次删除
  1. 51
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
  2. 30
      Runtime/ui/renderer/common/geometry/matrix/ui_matrix_utils.cs

51
Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs


layer.clipStack.save();
}
static uiOffset[] _cachedPoints = new uiOffset[4];
void _saveLayer(uiRect bounds, uiPaint paint) {
D.assert(bounds.width > 0);
D.assert(bounds.height > 0);

this._currentLayer = layer;
if (paint.backdrop != null) {
var points = new uiOffset[4];
points[0] = bounds.topLeft;
points[1] = bounds.bottomLeft;
points[2] = bounds.bottomRight;
points[3] = bounds.topRight;
_cachedPoints[0] = bounds.topLeft;
_cachedPoints[1] = bounds.bottomLeft;
_cachedPoints[2] = bounds.bottomRight;
_cachedPoints[3] = bounds.topRight;
points = state.matrix.Value.mapPoints(points);
state.matrix.Value.mapPoints(ref _cachedPoints);
points[i] = new uiOffset(
(points[i].dx - parentBounds.left) / parentBounds.width,
(points[i].dy - parentBounds.top) / parentBounds.height
_cachedPoints[i] = new uiOffset(
(_cachedPoints[i].dx - parentBounds.left) / parentBounds.width,
(_cachedPoints[i].dy - parentBounds.top) / parentBounds.height
points[0],
points[1],
points[2],
points[3],
_cachedPoints[0],
_cachedPoints[1],
_cachedPoints[2],
_cachedPoints[3],
bounds);
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
layer.draws.Add(renderDraw);

if (!filter.transform.isIdentity()) {
layer.filterMode = filter.filterMode;
points[0] = bounds.topLeft;
points[1] = bounds.bottomLeft;
points[2] = bounds.bottomRight;
points[3] = bounds.topRight;
_cachedPoints[0] = bounds.topLeft;
_cachedPoints[1] = bounds.bottomLeft;
_cachedPoints[2] = bounds.bottomRight;
_cachedPoints[3] = bounds.topRight;
points = state.matrix.Value.mapPoints(points);
state.matrix.Value.mapPoints(ref _cachedPoints);
points[i] = new uiOffset(
(points[i].dx - parentBounds.left) / parentBounds.width,
(points[i].dy - parentBounds.top) / parentBounds.height
_cachedPoints[i] = new uiOffset(
(_cachedPoints[i].dx - parentBounds.left) / parentBounds.width,
(_cachedPoints[i].dy - parentBounds.top) / parentBounds.height
);
}

var mesh = ImageMeshGenerator.imageMesh(
matrix,
points[0],
points[1],
points[2],
points[3],
_cachedPoints[0],
_cachedPoints[1],
_cachedPoints[2],
_cachedPoints[3],
bounds);
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
layer.draws.Add(renderDraw);

30
Runtime/ui/renderer/common/geometry/matrix/ui_matrix_utils.cs


namespace Unity.UIWidgets.ui {
public partial struct uiMatrix3 {
public uiOffset[] mapPoints(uiOffset[] dst, uiOffset[] src) {
public void mapPoints(ref uiOffset[] dst, ref uiOffset[] src) {
return this._getMapPtsProc()(this, dst, src, src.Length);
this._getMapPtsProc()(this, ref dst, ref src, src.Length);
public uiOffset[] mapPoints(uiOffset[] pts) {
return this.mapPoints(pts, pts);
public void mapPoints(ref uiOffset[] pts) {
this.mapPoints(ref pts, ref pts);
delegate uiOffset[] MapPtsProc(uiMatrix3 mat, uiOffset[] dst, uiOffset[] src, int count);
delegate void MapPtsProc(uiMatrix3 mat, ref uiOffset[] dst, ref uiOffset[] src, int count);
static readonly MapPtsProc[] gMapPtsProcs = {
Identity_pts, Trans_pts,

return GetMapPtsProc(this._getType());
}
static uiOffset[] Identity_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Identity_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
return dst;
static uiOffset[] Trans_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Trans_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
D.assert(m._getType() <= TypeMask.kTranslate_Mask);
if (count > 0) {
var tx = m.getTranslateX();

}
}
return dst;
static uiOffset[] Scale_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Scale_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
D.assert(m._getType() <= (TypeMask.kScale_Mask | TypeMask.kTranslate_Mask));
if (count > 0) {
var tx = m.getTranslateX();

dst[i] = new uiOffset(src[i].dx * sx + tx, src[i].dy * sy + ty);
}
}
return dst;
static uiOffset[] Persp_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Persp_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
D.assert(m._hasPerspective());
if (count > 0) {

dst[i] = new uiOffset(x * z, y * z);
}
}
return dst;
static uiOffset[] Affine_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Affine_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
D.assert(m._getType() != TypeMask.kPerspective_Mask);
if (count > 0) {
var tx = m.getTranslateX();

src[i].dx * ky + src[i].dy * sy + ty);
}
}
return dst;
}
}

正在加载...
取消
保存