Skip to content

Commit 8f5ad76

Browse files
committed
Fix line drawing path to use proportional distance from center
boundaryWidth and boundaryLength are now distance from center, instead of distance from edge, in order to avoid unnecessary calculation in the shader. New calculation of these matches drawAARect. Change-Id: I1c7f576a97a6f0ce00d521661fd56fb62e05e6f2
1 parent 176d105 commit 8f5ad76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

libs/hwui/OpenGLRenderer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ status_t OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
19371937
// This value is used in the fragment shader to determine how to fill fragments.
19381938
// We will need to calculate the actual width proportion on each segment for
19391939
// scaled non-hairlines, since the boundary proportion may differ per-axis when scaled.
1940-
float boundaryWidthProportion = 1 / (2 * halfStrokeWidth);
1940+
float boundaryWidthProportion = .5 - 1 / (2 * halfStrokeWidth);
19411941
setupDrawAALine((void*) aaVertices, widthCoords, lengthCoords,
19421942
boundaryWidthProportion, widthSlot, lengthSlot);
19431943
}
@@ -2001,9 +2001,9 @@ status_t OpenGLRenderer::drawLines(float* points, int count, SkPaint* paint) {
20012001
abVector.x *= inverseScaleX;
20022002
abVector.y *= inverseScaleY;
20032003
float abLength = abVector.length();
2004-
boundaryLengthProportion = abLength / (length + abLength);
2004+
boundaryLengthProportion = .5 - abLength / (length + abLength);
20052005
} else {
2006-
boundaryLengthProportion = .5 / (length + 1);
2006+
boundaryLengthProportion = .5 - .5 / (length + 1);
20072007
}
20082008

20092009
abVector /= 2;

0 commit comments

Comments
 (0)