Skip to content

Commit

Permalink
[RN][Android] Fix GH-41226: suppress path adjustment when not actuall…
Browse files Browse the repository at this point in the history
…y drawing a border
  • Loading branch information
tjzel authored and cipolleschi committed Nov 12, 2024
1 parent e992405 commit c9cf6d4
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ private void updatePath() {
}

// Clip border ONLY if its color is non transparent
float pathAdjustment = 0f;
if (Color.alpha(colorLeft) != 0
&& Color.alpha(colorTop) != 0
&& Color.alpha(colorRight) != 0
Expand All @@ -591,6 +592,10 @@ private void updatePath() {
mInnerClipTempRectForBorderRadius.bottom -= borderWidth.bottom;
mInnerClipTempRectForBorderRadius.left += borderWidth.left;
mInnerClipTempRectForBorderRadius.right -= borderWidth.right;

// only close gap between border and main path if we draw the border, otherwise
// we wind up pixelating small pixel-radius curves
pathAdjustment = mGapBetweenPaths;
}

mTempRectForCenterDrawPath.top += borderWidth.top * 0.5f;
Expand Down Expand Up @@ -714,14 +719,14 @@ private void updatePath() {
Path.Direction.CW);

// There is a small gap between mBackgroundColorRenderPath and its
// border. mGapBetweenPaths is used to slightly enlarge the rectangle
// border. pathAdjustment is used to slightly enlarge the rectangle
// (mInnerClipTempRectForBorderRadius), ensuring the border can be
// drawn on top without the gap.
mBackgroundColorRenderPath.addRoundRect(
mInnerClipTempRectForBorderRadius.left - mGapBetweenPaths,
mInnerClipTempRectForBorderRadius.top - mGapBetweenPaths,
mInnerClipTempRectForBorderRadius.right + mGapBetweenPaths,
mInnerClipTempRectForBorderRadius.bottom + mGapBetweenPaths,
mInnerClipTempRectForBorderRadius.left - pathAdjustment,
mInnerClipTempRectForBorderRadius.top - pathAdjustment,
mInnerClipTempRectForBorderRadius.right + pathAdjustment,
mInnerClipTempRectForBorderRadius.bottom + pathAdjustment,
new float[] {
innerTopLeftRadiusX,
innerTopLeftRadiusY,
Expand Down

0 comments on commit c9cf6d4

Please sign in to comment.