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

optimize aa draw (won't draw hairline for Rects) #364

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Runtime/ui/renderer/common/geometry/path/path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal uiPathCache flatten(float scale) {
return this._cache;
}

var _cache = uiPathCache.create(scale);
var _cache = uiPathCache.create(scale, this._shapeHint);

var i = 0;
while (i < this._commands.Count) {
Expand Down
13 changes: 11 additions & 2 deletions Runtime/ui/renderer/common/geometry/path/path_cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ public uiMeshMesh strokeMesh {
float _miterLimit;
float _fringe;

public static uiPathCache create(float scale) {
uiPath.uiPathShapeHint _shapeHint;

public static uiPathCache create(float scale, uiPath.uiPathShapeHint shapeHint) {
uiPathCache newPathCache = ObjectPool<uiPathCache>.alloc();
newPathCache._distTol = 0.01f / scale;
newPathCache._tessTol = 0.25f / scale;
newPathCache._scale = scale;
newPathCache._shapeHint = shapeHint;
return newPathCache;
}

Expand All @@ -49,6 +52,10 @@ public bool canReuse(float scale) {
return true;
}

public bool canSkipAAHairline {
get { return this._shapeHint == uiPath.uiPathShapeHint.Rect; }
}

public override void clear() {
this._paths.Clear();
this._points.Clear();
Expand All @@ -57,6 +64,8 @@ public override void clear() {

ObjectPool<uiMeshMesh>.release(this._strokeMesh);
this._strokeMesh = null;

this._shapeHint = uiPath.uiPathShapeHint.Other;
}

public uiPathCache() {
Expand Down Expand Up @@ -460,7 +469,7 @@ uiVertexUV _expandFill(float fringe) {

uiList<Vector3> _strokeVertices = null;
uiList<Vector2> _strokeUV = null;
if (aa > 0.0f) {
if (aa > 0.0f && !this.canSkipAAHairline) {
_strokeVertices = ObjectPool<uiList<Vector3>>.alloc();
_strokeUV = ObjectPool<uiList<Vector2>>.alloc();
cvertices = 0;
Expand Down