Skip to content

Commit e4f88c6

Browse files
ayc1facebook-github-bot
authored andcommitted
Revert D7569885: Fix anti aliasing rounded background
Differential Revision: D7569885 Original commit changeset: 4bfb00485211 fbshipit-source-id: 2fc76ca8615d5562ebe8c7527e9a54058b8d82dc
1 parent 1433d15 commit e4f88c6

File tree

1 file changed

+89
-108
lines changed

1 file changed

+89
-108
lines changed

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

+89-108
Original file line numberDiff line numberDiff line change
@@ -343,132 +343,113 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
343343
|| borderWidth.bottom > 0
344344
|| borderWidth.left > 0
345345
|| borderWidth.right > 0) {
346+
mPaint.setStyle(Paint.Style.FILL);
346347

347-
//If it's a full and even border draw inner rect path with stroke
348-
final float fullBorderWidth = getFullBorderWidth();
349-
if (borderWidth.top == fullBorderWidth &&
350-
borderWidth.bottom == fullBorderWidth &&
351-
borderWidth.left == fullBorderWidth &&
352-
borderWidth.right == fullBorderWidth) {
353-
if (fullBorderWidth > 0) {
354-
int borderColor = getBorderColor(Spacing.ALL);
355-
mPaint.setColor(ColorUtil.multiplyColorAlpha(borderColor, mAlpha));
356-
mPaint.setStyle(Paint.Style.STROKE);
357-
mPaint.setStrokeWidth(fullBorderWidth);
358-
canvas.drawPath(mInnerClipPathForBorderRadius, mPaint);
359-
}
360-
}
361-
//In the case of uneven border widths/colors draw quadrilateral in each direction
362-
else {
363-
mPaint.setStyle(Paint.Style.FILL);
364-
365-
// Draw border
366-
canvas.clipPath(mOuterClipPathForBorderRadius, Region.Op.INTERSECT);
367-
canvas.clipPath(mInnerClipPathForBorderRadius, Region.Op.DIFFERENCE);
368-
369-
int colorLeft = getBorderColor(Spacing.LEFT);
370-
int colorTop = getBorderColor(Spacing.TOP);
371-
int colorRight = getBorderColor(Spacing.RIGHT);
372-
int colorBottom = getBorderColor(Spacing.BOTTOM);
373-
374-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
375-
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
376-
int colorStart = getBorderColor(Spacing.START);
377-
int colorEnd = getBorderColor(Spacing.END);
348+
// Draw border
349+
canvas.clipPath(mOuterClipPathForBorderRadius, Region.Op.INTERSECT);
350+
canvas.clipPath(mInnerClipPathForBorderRadius, Region.Op.DIFFERENCE);
378351

379-
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
380-
if (!isBorderColorDefined(Spacing.START)) {
381-
colorStart = colorLeft;
382-
}
352+
int colorLeft = getBorderColor(Spacing.LEFT);
353+
int colorTop = getBorderColor(Spacing.TOP);
354+
int colorRight = getBorderColor(Spacing.RIGHT);
355+
int colorBottom = getBorderColor(Spacing.BOTTOM);
383356

384-
if (!isBorderColorDefined(Spacing.END)) {
385-
colorEnd = colorRight;
386-
}
357+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
358+
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
359+
int colorStart = getBorderColor(Spacing.START);
360+
int colorEnd = getBorderColor(Spacing.END);
387361

388-
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
389-
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
362+
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
363+
if (!isBorderColorDefined(Spacing.START)) {
364+
colorStart = colorLeft;
365+
}
390366

391-
colorLeft = directionAwareColorLeft;
392-
colorRight = directionAwareColorRight;
393-
} else {
394-
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
395-
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
396-
397-
final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
398-
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
399-
final boolean isDirectionAwareColorLeftDefined =
400-
isRTL ? isColorEndDefined : isColorStartDefined;
401-
final boolean isDirectionAwareColorRightDefined =
402-
isRTL ? isColorStartDefined : isColorEndDefined;
403-
404-
if (isDirectionAwareColorLeftDefined) {
405-
colorLeft = directionAwareColorLeft;
406-
}
407-
408-
if (isDirectionAwareColorRightDefined) {
409-
colorRight = directionAwareColorRight;
410-
}
367+
if (!isBorderColorDefined(Spacing.END)) {
368+
colorEnd = colorRight;
411369
}
412-
}
413370

414-
final float left = mOuterClipTempRectForBorderRadius.left;
415-
final float right = mOuterClipTempRectForBorderRadius.right;
416-
final float top = mOuterClipTempRectForBorderRadius.top;
417-
final float bottom = mOuterClipTempRectForBorderRadius.bottom;
371+
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
372+
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
418373

419-
if (borderWidth.left > 0) {
420-
final float x1 = left;
421-
final float y1 = top;
422-
final float x2 = mInnerTopLeftCorner.x;
423-
final float y2 = mInnerTopLeftCorner.y;
424-
final float x3 = mInnerBottomLeftCorner.x;
425-
final float y3 = mInnerBottomLeftCorner.y;
426-
final float x4 = left;
427-
final float y4 = bottom;
374+
colorLeft = directionAwareColorLeft;
375+
colorRight = directionAwareColorRight;
376+
} else {
377+
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
378+
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
428379

429-
drawQuadrilateral(canvas, colorLeft, x1, y1, x2, y2, x3, y3, x4, y4);
430-
}
380+
final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
381+
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
382+
final boolean isDirectionAwareColorLeftDefined = isRTL ? isColorEndDefined : isColorStartDefined;
383+
final boolean isDirectionAwareColorRightDefined = isRTL ? isColorStartDefined : isColorEndDefined;
431384

432-
if (borderWidth.top > 0) {
433-
final float x1 = left;
434-
final float y1 = top;
435-
final float x2 = mInnerTopLeftCorner.x;
436-
final float y2 = mInnerTopLeftCorner.y;
437-
final float x3 = mInnerTopRightCorner.x;
438-
final float y3 = mInnerTopRightCorner.y;
439-
final float x4 = right;
440-
final float y4 = top;
385+
if (isDirectionAwareColorLeftDefined) {
386+
colorLeft = directionAwareColorLeft;
387+
}
441388

442-
drawQuadrilateral(canvas, colorTop, x1, y1, x2, y2, x3, y3, x4, y4);
389+
if (isDirectionAwareColorRightDefined) {
390+
colorRight = directionAwareColorRight;
391+
}
443392
}
393+
}
444394

445-
if (borderWidth.right > 0) {
446-
final float x1 = right;
447-
final float y1 = top;
448-
final float x2 = mInnerTopRightCorner.x;
449-
final float y2 = mInnerTopRightCorner.y;
450-
final float x3 = mInnerBottomRightCorner.x;
451-
final float y3 = mInnerBottomRightCorner.y;
452-
final float x4 = right;
453-
final float y4 = bottom;
395+
final float left = mOuterClipTempRectForBorderRadius.left;
396+
final float right = mOuterClipTempRectForBorderRadius.right;
397+
final float top = mOuterClipTempRectForBorderRadius.top;
398+
final float bottom = mOuterClipTempRectForBorderRadius.bottom;
399+
400+
if (borderWidth.left > 0) {
401+
final float x1 = left;
402+
final float y1 = top;
403+
final float x2 = mInnerTopLeftCorner.x;
404+
final float y2 = mInnerTopLeftCorner.y;
405+
final float x3 = mInnerBottomLeftCorner.x;
406+
final float y3 = mInnerBottomLeftCorner.y;
407+
final float x4 = left;
408+
final float y4 = bottom;
409+
410+
drawQuadrilateral(canvas, colorLeft, x1, y1, x2, y2, x3, y3, x4, y4);
411+
}
454412

455-
drawQuadrilateral(canvas, colorRight, x1, y1, x2, y2, x3, y3, x4, y4);
456-
}
413+
if (borderWidth.top > 0) {
414+
final float x1 = left;
415+
final float y1 = top;
416+
final float x2 = mInnerTopLeftCorner.x;
417+
final float y2 = mInnerTopLeftCorner.y;
418+
final float x3 = mInnerTopRightCorner.x;
419+
final float y3 = mInnerTopRightCorner.y;
420+
final float x4 = right;
421+
final float y4 = top;
422+
423+
drawQuadrilateral(canvas, colorTop, x1, y1, x2, y2, x3, y3, x4, y4);
424+
}
457425

458-
if (borderWidth.bottom > 0) {
459-
final float x1 = left;
460-
final float y1 = bottom;
461-
final float x2 = mInnerBottomLeftCorner.x;
462-
final float y2 = mInnerBottomLeftCorner.y;
463-
final float x3 = mInnerBottomRightCorner.x;
464-
final float y3 = mInnerBottomRightCorner.y;
465-
final float x4 = right;
466-
final float y4 = bottom;
426+
if (borderWidth.right > 0) {
427+
final float x1 = right;
428+
final float y1 = top;
429+
final float x2 = mInnerTopRightCorner.x;
430+
final float y2 = mInnerTopRightCorner.y;
431+
final float x3 = mInnerBottomRightCorner.x;
432+
final float y3 = mInnerBottomRightCorner.y;
433+
final float x4 = right;
434+
final float y4 = bottom;
435+
436+
drawQuadrilateral(canvas, colorRight, x1, y1, x2, y2, x3, y3, x4, y4);
437+
}
467438

468-
drawQuadrilateral(canvas, colorBottom, x1, y1, x2, y2, x3, y3, x4, y4);
469-
}
439+
if (borderWidth.bottom > 0) {
440+
final float x1 = left;
441+
final float y1 = bottom;
442+
final float x2 = mInnerBottomLeftCorner.x;
443+
final float y2 = mInnerBottomLeftCorner.y;
444+
final float x3 = mInnerBottomRightCorner.x;
445+
final float y3 = mInnerBottomRightCorner.y;
446+
final float x4 = right;
447+
final float y4 = bottom;
448+
449+
drawQuadrilateral(canvas, colorBottom, x1, y1, x2, y2, x3, y3, x4, y4);
470450
}
471451
}
452+
472453
canvas.restore();
473454
}
474455

0 commit comments

Comments
 (0)