Fix border rendering incorrectly when it has translucent alpha (#50829)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50829

It is not appropriate to go through the fast path for border drawing when we have translucent border colors since it will cause overlapping borders to look weird.

Adding an if statement to prevent fastpath when the alpha value of any border is less than 255 (opaque)

Changelog: [Android][Fixed] - Fix translucent borders on Android overlapping bug

Reviewed By: NickGerleman

Differential Revision: D73145119

fbshipit-source-id: f22d0d55adca571d6b75725f6bc4753f98698763
This commit is contained in:
Jorge Cabiedes Acosta
2025-04-21 17:35:12 -07:00
committed by Facebook GitHub Bot
parent 132a871b46
commit 57779cebf0
@@ -490,6 +490,14 @@ internal class BorderDrawable(
colorRight: Int,
colorBottom: Int
): Int {
// If any of the border colors are translucent then we can't use the fast path.
if (Color.alpha(colorLeft) < 255 ||
Color.alpha(colorTop) < 255 ||
Color.alpha(colorRight) < 255 ||
Color.alpha(colorBottom) < 255) {
return 0
}
val andSmear =
((if (borderLeft > 0) colorLeft else ALL_BITS_SET) and
(if (borderTop > 0) colorTop else ALL_BITS_SET) and