Skip to content

Commit

Permalink
use canvas.clipOutPath if Android O or greater
Browse files Browse the repository at this point in the history
  • Loading branch information
juliooa committed Oct 14, 2018
1 parent 1bf68d4 commit da043e8
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,11 @@ private void drawBackground(Canvas canvas) {
mPath.close();

canvas.save();
canvas.clipPath(mPath, Region.Op.INTERSECT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(mPath);
} else {
canvas.clipPath(mPath, Region.Op.INTERSECT);
}
canvas.clipRect(rect, Region.Op.XOR);
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
canvas.restore();
Expand All @@ -632,7 +636,11 @@ private void drawBackground(Canvas canvas) {
}
mPath.addOval(mDrawRect, Path.Direction.CW);
canvas.save();
canvas.clipPath(mPath, Region.Op.XOR);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(mPath);
} else {
canvas.clipPath(mPath, Region.Op.INTERSECT);
}
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
canvas.restore();
}
Expand Down

1 comment on commit da043e8

@rostopira
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, looks like Region.Op.XOR was expected at line 642

Please sign in to comment.