Skip to content

Commit

Permalink
Fix anti-aliasing on older Android devices
Browse files Browse the repository at this point in the history
Summary:
On older Android versions clipping doesn't have anti-aliasing by default which means that clipping with no border will always make the background not have anti-aliasing.

This is fixed by default on new Background and Border drawables since rendering logic is separated

Moving the clipping logic so it only runs when we have a border.

facebook#41226

Changelog: [Android] [Fixed] - Fixed anti-aliasing not showing on older Android versions

Reviewed By: javache

Differential Revision: D68279400

fbshipit-source-id: e2383c71bd1ca89f66f42630b3712bb4cc5cd7ac
  • Loading branch information
jorge-cab authored and facebook-github-bot committed Jan 24, 2025
1 parent 1b710a0 commit 6c6e0a9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,6 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
updatePath();
canvas.save();

// Clip outer border
canvas.clipPath(Preconditions.checkNotNull(mOuterClipPathForBorderRadius), Region.Op.INTERSECT);

// Draws the View without its border first (with background color fill)
int useColor = ColorUtils.setAlphaComponent(mColor, (Color.alpha(mColor) * mAlpha) >> 8);
if (Color.alpha(useColor) != 0) {
Expand Down Expand Up @@ -434,6 +431,10 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
|| borderWidth.left > 0
|| borderWidth.right > 0) {

// Clip outer border
canvas.clipPath(
Preconditions.checkNotNull(mOuterClipPathForBorderRadius), Region.Op.INTERSECT);

// If it's a full and even border draw inner rect path with stroke
final float fullBorderWidth = getFullBorderWidth();
int borderColor = getBorderColor(Spacing.ALL);
Expand Down

0 comments on commit 6c6e0a9

Please sign in to comment.