Skip to content

Commit 5b8642f

Browse files
committed
Fix GH-41226
When not drawing a border, the mGapBetweenPaths adjustment can create noticable pixelation when drawing curves through a low number of pixels. This is noticable mostly on buttons and such on low-dpi devices. This fix only applies the fix if clipping for the border radius is done.
1 parent 524a48d commit 5b8642f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ private void updatePath() {
584584
}
585585

586586
// Clip border ONLY if its color is non transparent
587+
float pathAdjustment = 0f;
587588
if (Color.alpha(colorLeft) != 0
588589
&& Color.alpha(colorTop) != 0
589590
&& Color.alpha(colorRight) != 0
@@ -594,6 +595,10 @@ private void updatePath() {
594595
mInnerClipTempRectForBorderRadius.bottom -= borderWidth.bottom;
595596
mInnerClipTempRectForBorderRadius.left += borderWidth.left;
596597
mInnerClipTempRectForBorderRadius.right -= borderWidth.right;
598+
599+
// only close gap between border and main path if we draw the border, otherwise
600+
// we wind up pixelating small pixel-radius curves
601+
pathAdjustment = mGapBetweenPaths;
597602
}
598603

599604
mTempRectForCenterDrawPath.top += borderWidth.top * 0.5f;
@@ -721,10 +726,10 @@ private void updatePath() {
721726
// (mInnerClipTempRectForBorderRadius), ensuring the border can be
722727
// drawn on top without the gap.
723728
mBackgroundColorRenderPath.addRoundRect(
724-
mInnerClipTempRectForBorderRadius.left - mGapBetweenPaths,
725-
mInnerClipTempRectForBorderRadius.top - mGapBetweenPaths,
726-
mInnerClipTempRectForBorderRadius.right + mGapBetweenPaths,
727-
mInnerClipTempRectForBorderRadius.bottom + mGapBetweenPaths,
729+
mInnerClipTempRectForBorderRadius.left - pathAdjustment,
730+
mInnerClipTempRectForBorderRadius.top - pathAdjustment,
731+
mInnerClipTempRectForBorderRadius.right + pathAdjustment,
732+
mInnerClipTempRectForBorderRadius.bottom + pathAdjustment,
728733
new float[] {
729734
innerTopLeftRadiusX,
730735
innerTopLeftRadiusY,

0 commit comments

Comments
 (0)