diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/AbstractClippingDrawCommand.java b/ReactAndroid/src/main/java/com/facebook/react/flat/AbstractClippingDrawCommand.java index 2919b52e9..e3a4298d8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/AbstractClippingDrawCommand.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/AbstractClippingDrawCommand.java @@ -13,6 +13,7 @@ import android.graphics.Canvas; /* package */ abstract class AbstractClippingDrawCommand implements DrawCommand { + protected boolean mNeedsClipping; private float mClipLeft; private float mClipTop; private float mClipRight; @@ -36,6 +37,7 @@ import android.graphics.Canvas; mClipTop = clipTop; mClipRight = clipRight; mClipBottom = clipBottom; + mNeedsClipping = mClipLeft != Float.NEGATIVE_INFINITY; } public final float getClipLeft() { @@ -60,7 +62,7 @@ import android.graphics.Canvas; // shows up during screenshot testing. Note that checking one side is enough, since if one side // is infinite, all sides will be infinite, since we only set infinite for all sides at the // same time - conversely, if one side is finite, all sides will be finite. - if (mClipLeft != Float.NEGATIVE_INFINITY) { + if (mNeedsClipping) { canvas.clipRect(mClipLeft, mClipTop, mClipRight, mClipBottom); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/DrawView.java b/ReactAndroid/src/main/java/com/facebook/react/flat/DrawView.java index dc811a2a8..350506cd3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/DrawView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/DrawView.java @@ -21,9 +21,13 @@ import android.graphics.Canvas; @Override public void draw(FlatViewGroup parent, Canvas canvas) { - canvas.save(); - applyClipping(canvas); - parent.drawNextChild(canvas); - canvas.restore(); + if (mNeedsClipping) { + canvas.save(); + applyClipping(canvas); + parent.drawNextChild(canvas); + canvas.restore(); + } else { + parent.drawNextChild(canvas); + } } }