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

Commit 64cecde

Browse files
authored
Merge pull request #124 from UnityTech/xwzhu
shadow improve + performance step 2.1 (focus on Path)
2 parents ba8fb45 + 57234e6 commit 64cecde

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

Runtime/flow/physical_shape_layer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public override void paint(PaintContext context) {
8181
public static void drawShadow(Canvas canvas, Path path, Color color, float elevation, bool transparentOccluder,
8282
float dpr) {
8383
float kAmbientAlpha = 0.039f;
84-
float kSpotAlpha = 0.25f;
84+
float kSpotAlpha = ShadowUtils.kUseFastShadow ? 0.1f : 0.25f;
8585
float kLightHeight = 600f;
8686
float kLightRadius = 800f;
8787

Runtime/ui/painting/path.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ List<float> _getArcCommands(float cx, float cy, float r, float a0, float a1, Pa
458458
}
459459
}
460460
}
461-
462461
// Split arc into max 90 degree segments.
463462
int ndivs = Mathf.Max(1, Mathf.Min((int) (Mathf.Abs(da) / (Mathf.PI * 0.5f) + 0.5f), 5));
464463
float hda = (da / ndivs) / 2.0f;
@@ -1124,9 +1123,9 @@ void _addPoint(PathPoint point) {
11241123
this.addPoint(0, 0, PointFlags.corner);
11251124
}
11261125

1127-
var path = this._paths.Last();
1126+
var path = this._paths[this._paths.Count - 1];
11281127
if (path.count > 0) {
1129-
var pt = this._points.Last();
1128+
var pt = this._points[this._points.Count - 1];
11301129
if (PathUtils.ptEquals(pt.x, pt.y, point.x, point.y, this._distTol)) {
11311130
pt.flags |= point.flags;
11321131
return;
@@ -1147,7 +1146,7 @@ public void tessellateBezier(
11471146
y1 = 0;
11481147
}
11491148
else {
1150-
var pt = this._points.Last();
1149+
var pt = this._points[this._points.Count - 1];
11511150
x1 = pt.x;
11521151
y1 = pt.y;
11531152
}
@@ -1174,7 +1173,7 @@ public void pathWinding(PathWinding winding) {
11741173
return;
11751174
}
11761175

1177-
var path = this._paths.Last();
1176+
var path = this._paths[this._paths.Count - 1];
11781177
path.winding = winding;
11791178
}
11801179

0 commit comments

Comments
 (0)