浏览代码

Merge pull request #299 from UnityTech/backdropbugfix

backdrop mask bug fix
/main
GitHub 5 年前
当前提交
2c57e822
共有 2 个文件被更改,包括 42 次插入40 次删除
  1. 62
      Runtime/ui/renderer/cmdbufferCanvas/rendering/canvas_impl.cs
  2. 20
      Runtime/ui/renderer/common/geometry/matrix/ui_matrix_utils.cs

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


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

this._currentLayer = layer;
if (paint.backdrop != null) {
if (paint.backdrop is _BlurImageFilter) {
var filter = (_BlurImageFilter) paint.backdrop;
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;
_cachedPoints[0] = bounds.topLeft;
_cachedPoints[1] = bounds.bottomLeft;
_cachedPoints[2] = bounds.bottomRight;
_cachedPoints[3] = bounds.topRight;
state.matrix.Value.mapPoints(this._saveLayer_Points);
state.matrix.Value.mapPoints(ref _cachedPoints);
this._saveLayer_Points[i] = new uiOffset(
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
(this._saveLayer_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
this._saveLayer_Points[0],
this._saveLayer_Points[1],
this._saveLayer_Points[2],
this._saveLayer_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);

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);
_cachedPoints[0] = bounds.topLeft;
_cachedPoints[1] = bounds.bottomLeft;
_cachedPoints[2] = bounds.bottomRight;
_cachedPoints[3] = bounds.topRight;
state.matrix.Value.mapPoints(ref _cachedPoints);
this._saveLayer_Points[i] = new uiOffset(
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
(this._saveLayer_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
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],
_cachedPoints[0],
_cachedPoints[1],
_cachedPoints[2],
_cachedPoints[3],
bounds);
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
layer.draws.Add(renderDraw);

20
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 void mapPoints(ref uiOffset[] dst, ref uiOffset[] src) {
this._getMapPtsProc()(this, dst, src, src.Length);
this._getMapPtsProc()(this, ref dst, ref src, src.Length);
public void mapPoints(uiOffset[] pts) {
this.mapPoints(pts, pts);
public void mapPoints(ref uiOffset[] pts) {
this.mapPoints(ref pts, ref pts);
delegate void 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 void Identity_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
static void Identity_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
D.assert(m._getType() == 0);
if (dst != src && count > 0) {

static void 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();

}
}
static void 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();

}
}
static void 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) {

}
}
static void 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();

正在加载...
取消
保存