Skip to content

Commit cbc9f45

Browse files
committed
changes required in code-review
1 parent 40e940a commit cbc9f45

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private enum BorderStyle {
8989
private @Nullable Path mOuterClipPathForBorderRadius;
9090
private @Nullable Path mPathForBorderRadiusOutline;
9191
private @Nullable Path mPathForBorder;
92+
private Path mPathForSingleBorder = new Path();
9293
private @Nullable Path mCenterDrawPath;
9394
private @Nullable RectF mInnerClipTempRectForBorderRadius;
9495
private @Nullable RectF mOuterClipTempRectForBorderRadius;
@@ -1100,6 +1101,7 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) {
11001101
colorTop,
11011102
colorRight,
11021103
colorBottom);
1104+
11031105
if (fastBorderColor != 0) {
11041106
if (Color.alpha(fastBorderColor) != 0) {
11051107
// Border color is not transparent.
@@ -1109,41 +1111,40 @@ private void drawRectangularBackgroundWithBorders(Canvas canvas) {
11091111
mPaint.setColor(fastBorderColor);
11101112
mPaint.setStyle(Paint.Style.STROKE);
11111113
if (borderLeft > 0) {
1112-
int leftInset = left + borderLeft;
1113-
Path path = new Path();
1114+
mPathForSingleBorder.reset();
11141115
int width = Math.round(borderWidth.left);
11151116
updatePathEffect(width);
11161117
mPaint.setStrokeWidth(width);
1117-
path.moveTo(left, top - borderWidth.top/2);
1118-
path.lineTo(left, bottom + borderWidth.bottom/2);
1119-
canvas.drawPath(path, mPaint);
1118+
mPathForSingleBorder.moveTo(left, top - borderWidth.top/2);
1119+
mPathForSingleBorder.lineTo(left, bottom + borderWidth.bottom/2);
1120+
canvas.drawPath(mPathForSingleBorder, mPaint);
11201121
}
11211122
if (borderTop > 0) {
1122-
Path path = new Path();
1123+
mPathForSingleBorder.reset();
11231124
int width = Math.round(borderWidth.top);
11241125
updatePathEffect(width);
11251126
mPaint.setStrokeWidth(width);
1126-
path.moveTo(left, top);
1127-
path.lineTo(right, top);
1128-
canvas.drawPath(path, mPaint);
1127+
mPathForSingleBorder.moveTo(left, top);
1128+
mPathForSingleBorder.lineTo(right, top);
1129+
canvas.drawPath(mPathForSingleBorder, mPaint);
11291130
}
11301131
if (borderRight > 0) {
1131-
Path path = new Path();
1132+
mPathForSingleBorder.reset();
11321133
int width = Math.round(borderWidth.right);
11331134
updatePathEffect(width);
11341135
mPaint.setStrokeWidth(width);
1135-
path.moveTo(right, top - borderWidth.top/2);
1136-
path.lineTo(right, bottom + borderWidth.bottom/2);
1137-
canvas.drawPath(path, mPaint);
1136+
mPathForSingleBorder.moveTo(right, top - borderWidth.top/2);
1137+
mPathForSingleBorder.lineTo(right, bottom + borderWidth.bottom/2);
1138+
canvas.drawPath(mPathForSingleBorder, mPaint);
11381139
}
11391140
if (borderBottom > 0) {
1140-
Path path = new Path();
1141+
mPathForSingleBorder.reset();
11411142
int width = Math.round(borderWidth.bottom);
11421143
updatePathEffect(width);
11431144
mPaint.setStrokeWidth(width);
1144-
path.moveTo(left, bottom);
1145-
path.lineTo(right, bottom);
1146-
canvas.drawPath(path, mPaint);
1145+
mPathForSingleBorder.moveTo(left, bottom);
1146+
mPathForSingleBorder.lineTo(right, bottom);
1147+
canvas.drawPath(mPathForSingleBorder, mPaint);
11471148
}
11481149
}
11491150
} else {

0 commit comments

Comments
 (0)