浏览代码

backdrop mask bug fix

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

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


layer.clipStack.save();
}
readonly uiOffset[] _saveLayer_Points = 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) {
if (paint.backdrop is _BlurImageFilter) {
var filter = (_BlurImageFilter) paint.backdrop;
var points = new uiOffset[4];
if (paint.backdrop is _uiBlurImageFilter) {
var filter = (_uiBlurImageFilter) paint.backdrop;
this._saveLayer_Points[0] = bounds.topLeft;
this._saveLayer_Points[1] = bounds.bottomLeft;
this._saveLayer_Points[2] = bounds.bottomRight;
this._saveLayer_Points[3] = bounds.topRight;
points[0] = bounds.topLeft;
points[1] = bounds.bottomLeft;
points[2] = bounds.bottomRight;
points[3] = bounds.topRight;
state.matrix.Value.mapPoints(this._saveLayer_Points);
points = state.matrix.Value.mapPoints(points);
this._saveLayer_Points[i] = new uiOffset(
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
(this._saveLayer_Points[i].dy - parentBounds.top) / parentBounds.height
points[i] = new uiOffset(
(points[i].dx - parentBounds.left) / parentBounds.width,
(points[i].dy - parentBounds.top) / parentBounds.height
this._saveLayer_Points[0],
this._saveLayer_Points[1],
this._saveLayer_Points[2],
this._saveLayer_Points[3],
points[0],
points[1],
points[2],
points[3],
bounds);
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
layer.draws.Add(renderDraw);

layer.draws.Add(CanvasShader.texRT(layer, paint, blurMesh, blurLayer));
}
}
else if (paint.backdrop is _MatrixImageFilter) {
var filter = (_MatrixImageFilter) paint.backdrop;
else if (paint.backdrop is _uiMatrixImageFilter) {
var filter = (_uiMatrixImageFilter) paint.backdrop;
this._saveLayer_Points[0] = bounds.topLeft;
this._saveLayer_Points[1] = bounds.bottomLeft;
this._saveLayer_Points[2] = bounds.bottomRight;
this._saveLayer_Points[3] = bounds.topRight;
state.matrix.Value.mapPoints(this._saveLayer_Points);
points[0] = bounds.topLeft;
points[1] = bounds.bottomLeft;
points[2] = bounds.bottomRight;
points[3] = bounds.topRight;
points = state.matrix.Value.mapPoints(points);
this._saveLayer_Points[i] = new uiOffset(
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
(this._saveLayer_Points[i].dy - parentBounds.top) / parentBounds.height
points[i] = new uiOffset(
(points[i].dx - parentBounds.left) / parentBounds.width,
(points[i].dy - parentBounds.top) / parentBounds.height
matrix.postConcat(uiMatrix3.fromMatrix3(filter.transform));
matrix.postConcat(filter.transform);
this._saveLayer_Points[0],
this._saveLayer_Points[1],
this._saveLayer_Points[2],
this._saveLayer_Points[3],
points[0],
points[1],
points[2],
points[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 void mapPoints(uiOffset[] dst, uiOffset[] src) {
public uiOffset[] mapPoints(uiOffset[] dst, uiOffset[] src) {
this._getMapPtsProc()(this, dst, src, src.Length);
return this._getMapPtsProc()(this, dst, src, src.Length);
public void mapPoints(uiOffset[] pts) {
this.mapPoints(pts, pts);
public uiOffset[] mapPoints(uiOffset[] pts) {
return this.mapPoints(pts, pts);
delegate void MapPtsProc(uiMatrix3 mat, uiOffset[] dst, uiOffset[] src, int count);
delegate uiOffset[] MapPtsProc(uiMatrix3 mat, uiOffset[] dst, uiOffset[] src, int count);
static readonly MapPtsProc[] gMapPtsProcs = {
Identity_pts, Trans_pts,

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

}
}
return dst;
static void Scale_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static uiOffset[] Scale_pts(uiMatrix3 m, uiOffset[] dst, 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 void Persp_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static uiOffset[] Persp_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
D.assert(m._hasPerspective());
if (count > 0) {

dst[i] = new uiOffset(x * z, y * z);
}
}
return dst;
static void Affine_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static uiOffset[] Affine_pts(uiMatrix3 m, uiOffset[] dst, 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;
}
}

正在加载...
取消
保存