Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 0cdac01

Browse files
committed
Merge branch 'master' of github.com:UnityTech/UIWidgets into dev
2 parents f33e744 + 9a3788f commit 0cdac01

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void _save() {
9999
layer.clipStack.save();
100100
}
101101

102-
readonly uiOffset[] _saveLayer_Points = new uiOffset[4];
102+
static uiOffset[] _cachedPoints = new uiOffset[4];
103103

104104
void _saveLayer(uiRect bounds, uiPaint paint) {
105105
D.assert(bounds.width > 0);
@@ -132,30 +132,31 @@ void _saveLayer(uiRect bounds, uiPaint paint) {
132132
this._currentLayer = layer;
133133

134134
if (paint.backdrop != null) {
135-
if (paint.backdrop is _BlurImageFilter) {
136-
var filter = (_BlurImageFilter) paint.backdrop;
135+
136+
if (paint.backdrop is _uiBlurImageFilter) {
137+
var filter = (_uiBlurImageFilter) paint.backdrop;
137138
if (!(filter.sigmaX == 0 && filter.sigmaY == 0)) {
138-
this._saveLayer_Points[0] = bounds.topLeft;
139-
this._saveLayer_Points[1] = bounds.bottomLeft;
140-
this._saveLayer_Points[2] = bounds.bottomRight;
141-
this._saveLayer_Points[3] = bounds.topRight;
139+
_cachedPoints[0] = bounds.topLeft;
140+
_cachedPoints[1] = bounds.bottomLeft;
141+
_cachedPoints[2] = bounds.bottomRight;
142+
_cachedPoints[3] = bounds.topRight;
142143

143-
state.matrix.Value.mapPoints(this._saveLayer_Points);
144+
state.matrix.Value.mapPoints(ref _cachedPoints);
144145

145146
var parentBounds = parentLayer.layerBounds;
146147
for (int i = 0; i < 4; i++) {
147-
this._saveLayer_Points[i] = new uiOffset(
148-
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
149-
(this._saveLayer_Points[i].dy - parentBounds.top) / parentBounds.height
148+
_cachedPoints[i] = new uiOffset(
149+
(_cachedPoints[i].dx - parentBounds.left) / parentBounds.width,
150+
(_cachedPoints[i].dy - parentBounds.top) / parentBounds.height
150151
);
151152
}
152153

153154
var mesh = ImageMeshGenerator.imageMesh(
154155
null,
155-
this._saveLayer_Points[0],
156-
this._saveLayer_Points[1],
157-
this._saveLayer_Points[2],
158-
this._saveLayer_Points[3],
156+
_cachedPoints[0],
157+
_cachedPoints[1],
158+
_cachedPoints[2],
159+
_cachedPoints[3],
159160
bounds);
160161
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
161162
layer.draws.Add(renderDraw);
@@ -165,35 +166,36 @@ void _saveLayer(uiRect bounds, uiPaint paint) {
165166
layer.draws.Add(CanvasShader.texRT(layer, paint, blurMesh, blurLayer));
166167
}
167168
}
168-
else if (paint.backdrop is _MatrixImageFilter) {
169-
var filter = (_MatrixImageFilter) paint.backdrop;
169+
else if (paint.backdrop is _uiMatrixImageFilter) {
170+
var filter = (_uiMatrixImageFilter) paint.backdrop;
170171
if (!filter.transform.isIdentity()) {
171172
layer.filterMode = filter.filterMode;
172173

173-
this._saveLayer_Points[0] = bounds.topLeft;
174-
this._saveLayer_Points[1] = bounds.bottomLeft;
175-
this._saveLayer_Points[2] = bounds.bottomRight;
176-
this._saveLayer_Points[3] = bounds.topRight;
177-
state.matrix.Value.mapPoints(this._saveLayer_Points);
174+
_cachedPoints[0] = bounds.topLeft;
175+
_cachedPoints[1] = bounds.bottomLeft;
176+
_cachedPoints[2] = bounds.bottomRight;
177+
_cachedPoints[3] = bounds.topRight;
178+
179+
state.matrix.Value.mapPoints(ref _cachedPoints);
178180

179181
var parentBounds = parentLayer.layerBounds;
180182
for (int i = 0; i < 4; i++) {
181-
this._saveLayer_Points[i] = new uiOffset(
182-
(this._saveLayer_Points[i].dx - parentBounds.left) / parentBounds.width,
183-
(this._saveLayer_Points[i].dy - parentBounds.top) / parentBounds.height
183+
_cachedPoints[i] = new uiOffset(
184+
(_cachedPoints[i].dx - parentBounds.left) / parentBounds.width,
185+
(_cachedPoints[i].dy - parentBounds.top) / parentBounds.height
184186
);
185187
}
186188

187189
var matrix = uiMatrix3.makeTrans(-bounds.left, -bounds.top);
188-
matrix.postConcat(uiMatrix3.fromMatrix3(filter.transform));
190+
matrix.postConcat(filter.transform);
189191
matrix.postTranslate(bounds.left, bounds.top);
190192

191193
var mesh = ImageMeshGenerator.imageMesh(
192194
matrix,
193-
this._saveLayer_Points[0],
194-
this._saveLayer_Points[1],
195-
this._saveLayer_Points[2],
196-
this._saveLayer_Points[3],
195+
_cachedPoints[0],
196+
_cachedPoints[1],
197+
_cachedPoints[2],
198+
_cachedPoints[3],
197199
bounds);
198200
var renderDraw = CanvasShader.texRT(layer, layer.layerPaint.Value, mesh, parentLayer);
199201
layer.draws.Add(renderDraw);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
namespace Unity.UIWidgets.ui {
66
public partial struct uiMatrix3 {
7-
public void mapPoints(uiOffset[] dst, uiOffset[] src) {
7+
public void mapPoints(ref uiOffset[] dst, ref uiOffset[] src) {
88
D.assert(dst != null && src != null && dst.Length == src.Length);
9-
this._getMapPtsProc()(this, dst, src, src.Length);
9+
this._getMapPtsProc()(this, ref dst, ref src, src.Length);
1010
}
1111

12-
public void mapPoints(uiOffset[] pts) {
13-
this.mapPoints(pts, pts);
12+
public void mapPoints(ref uiOffset[] pts) {
13+
this.mapPoints(ref pts, ref pts);
1414
}
1515

16-
delegate void MapPtsProc(uiMatrix3 mat, uiOffset[] dst, uiOffset[] src, int count);
16+
delegate void MapPtsProc(uiMatrix3 mat, ref uiOffset[] dst, ref uiOffset[] src, int count);
1717

1818
static readonly MapPtsProc[] gMapPtsProcs = {
1919
Identity_pts, Trans_pts,
@@ -36,15 +36,15 @@ MapPtsProc _getMapPtsProc() {
3636
return GetMapPtsProc(this._getType());
3737
}
3838

39-
static void Identity_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
39+
static void Identity_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
4040
D.assert(m._getType() == 0);
4141

4242
if (dst != src && count > 0) {
4343
Array.Copy(src, dst, count);
4444
}
4545
}
4646

47-
static void Trans_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
47+
static void Trans_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
4848
D.assert(m._getType() <= TypeMask.kTranslate_Mask);
4949
if (count > 0) {
5050
var tx = m.getTranslateX();
@@ -55,7 +55,7 @@ static void Trans_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
5555
}
5656
}
5757

58-
static void Scale_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
58+
static void Scale_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
5959
D.assert(m._getType() <= (TypeMask.kScale_Mask | TypeMask.kTranslate_Mask));
6060
if (count > 0) {
6161
var tx = m.getTranslateX();
@@ -69,7 +69,7 @@ static void Scale_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
6969
}
7070
}
7171

72-
static void Persp_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
72+
static void Persp_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
7373
D.assert(m._hasPerspective());
7474

7575
if (count > 0) {
@@ -91,7 +91,7 @@ static void Persp_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
9191
}
9292
}
9393

94-
static void Affine_pts(uiMatrix3 m, uiOffset[] dst, uiOffset[] src, int count) {
94+
static void Affine_pts(uiMatrix3 m, ref uiOffset[] dst, ref uiOffset[] src, int count) {
9595
D.assert(m._getType() != TypeMask.kPerspective_Mask);
9696
if (count > 0) {
9797
var tx = m.getTranslateX();

0 commit comments

Comments
 (0)