Skip to content

Commit da043e8

Browse files
committed
use canvas.clipOutPath if Android O or greater
1 parent 1bf68d4 commit da043e8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropOverlayView.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,11 @@ private void drawBackground(Canvas canvas) {
618618
mPath.close();
619619

620620
canvas.save();
621-
canvas.clipPath(mPath, Region.Op.INTERSECT);
621+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
622+
canvas.clipOutPath(mPath);
623+
} else {
624+
canvas.clipPath(mPath, Region.Op.INTERSECT);
625+
}
622626
canvas.clipRect(rect, Region.Op.XOR);
623627
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
624628
canvas.restore();
@@ -632,7 +636,11 @@ private void drawBackground(Canvas canvas) {
632636
}
633637
mPath.addOval(mDrawRect, Path.Direction.CW);
634638
canvas.save();
635-
canvas.clipPath(mPath, Region.Op.XOR);
639+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
640+
canvas.clipOutPath(mPath);
641+
} else {
642+
canvas.clipPath(mPath, Region.Op.INTERSECT);
643+
}
636644
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
637645
canvas.restore();
638646
}

0 commit comments

Comments
 (0)