mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Back out "Anti-alias rounded borders on overflow: hidden views"
Summary: Changelog: [Android][Removed] - Anti aliased rounded corners on overflow: hidden views Differential Revision: D39072689 fbshipit-source-id: 41b01fa67280b7b8a7df61fdb809bb97a75c781b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9ac437f25b
commit
e653f2fd15
@@ -144,10 +144,4 @@ public class ReactFeatureFlags {
|
||||
|
||||
/** Temporary flag to allow execution of mount items up to 15ms earlier than normal. */
|
||||
public static boolean enableEarlyScheduledMountItemExecution = false;
|
||||
|
||||
/**
|
||||
* Use a bitmap mask instead of clipPath for rounding corners so that they are antialiased in
|
||||
* Android
|
||||
*/
|
||||
public static boolean antiAliasRoundedOverflowCorners = false;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,7 @@ import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -132,7 +129,6 @@ public class ReactViewGroup extends ViewGroup
|
||||
private boolean mNeedsOffscreenAlphaCompositing;
|
||||
private @Nullable ViewGroupDrawingOrderHelper mDrawingOrderHelper;
|
||||
private @Nullable Path mPath;
|
||||
private @Nullable Paint mPaint;
|
||||
private int mLayoutDirection;
|
||||
private float mBackfaceOpacity;
|
||||
private String mBackfaceVisibility;
|
||||
@@ -163,7 +159,6 @@ public class ReactViewGroup extends ViewGroup
|
||||
mNeedsOffscreenAlphaCompositing = false;
|
||||
mDrawingOrderHelper = null;
|
||||
mPath = null;
|
||||
mPaint = null;
|
||||
mLayoutDirection = 0; // set when background is created
|
||||
mBackfaceOpacity = 1.f;
|
||||
mBackfaceVisibility = "visible";
|
||||
@@ -811,16 +806,8 @@ public class ReactViewGroup extends ViewGroup
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
try {
|
||||
if (ReactFeatureFlags.antiAliasRoundedOverflowCorners && hasRoundedOverflow()) {
|
||||
int saveCount = canvas.saveLayer(0, 0, getWidth(), getHeight(), null);
|
||||
super.dispatchDraw(canvas);
|
||||
dispatchOverflowDraw(canvas);
|
||||
canvas.restoreToCount(saveCount);
|
||||
} else {
|
||||
dispatchOverflowDraw(canvas);
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
|
||||
dispatchOverflowDraw(canvas);
|
||||
super.dispatchDraw(canvas);
|
||||
} catch (NullPointerException | StackOverflowError e) {
|
||||
// Adding special exception management for StackOverflowError for logging purposes.
|
||||
// This will be removed in the future.
|
||||
@@ -873,7 +860,7 @@ public class ReactViewGroup extends ViewGroup
|
||||
|
||||
boolean hasClipPath = false;
|
||||
|
||||
if (mReactBackgroundDrawable != null && mReactBackgroundDrawable.hasRoundedBorders()) {
|
||||
if (mReactBackgroundDrawable != null) {
|
||||
final RectF borderWidth = mReactBackgroundDrawable.getDirectionAwareBorderInsets();
|
||||
|
||||
if (borderWidth.top > 0
|
||||
@@ -993,21 +980,7 @@ public class ReactViewGroup extends ViewGroup
|
||||
Math.max(bottomLeftBorderRadius - borderWidth.bottom, 0),
|
||||
},
|
||||
Path.Direction.CW);
|
||||
|
||||
if (ReactFeatureFlags.antiAliasRoundedOverflowCorners) {
|
||||
mPath.setFillType(Path.FillType.INVERSE_WINDING);
|
||||
|
||||
if (mPaint == null) {
|
||||
mPaint = new Paint();
|
||||
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
|
||||
mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
|
||||
mPaint.setColor(getContext().getColor(android.R.color.white));
|
||||
}
|
||||
|
||||
canvas.drawPath(mPath, mPaint);
|
||||
} else {
|
||||
canvas.clipPath(mPath);
|
||||
}
|
||||
canvas.clipPath(mPath);
|
||||
hasClipPath = true;
|
||||
}
|
||||
}
|
||||
@@ -1022,13 +995,6 @@ public class ReactViewGroup extends ViewGroup
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasRoundedOverflow() {
|
||||
return mOverflow != null
|
||||
&& (mOverflow.equals(ViewProps.HIDDEN.toString())
|
||||
|| mOverflow.equals(ViewProps.SCROLL.toString()))
|
||||
&& (mReactBackgroundDrawable != null && mReactBackgroundDrawable.hasRoundedBorders());
|
||||
}
|
||||
|
||||
public void setOpacityIfPossible(float opacity) {
|
||||
mBackfaceOpacity = opacity;
|
||||
setBackfaceVisibilityDependantOpacity();
|
||||
|
||||
Reference in New Issue
Block a user