Commit b84d9222 authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

android: Stop using deprecated Canvas.clipPath

On versions where the API is deprecated. The desired behavior of
essentially inverting the mask can be done with clipOutPath on O or
above, and by Op.DIFFERENCE for below.

Bug: 828195
Change-Id: I08f262018f1596fd79556667961ed80a97221768
Reviewed-on: https://chromium-review.googlesource.com/994257Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547873}
parent 3cf3eea9
......@@ -21,6 +21,7 @@ import android.graphics.RectF;
import android.graphics.Region.Op;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.SystemClock;
import android.view.GestureDetector;
import android.view.MotionEvent;
......@@ -264,7 +265,11 @@ public class PopupZoomer extends View {
RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
float overlayCornerRadius = getOverlayCornerRadius(getContext());
path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
canvas.clipPath(path, Op.XOR);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(path);
} else {
canvas.clipPath(path, Op.DIFFERENCE);
}
Paint clearPaint = new Paint();
clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
clearPaint.setColor(Color.TRANSPARENT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment