Permalink
Browse files

RotateView: improve canvas states

  • Loading branch information...
devemux86 committed Jun 28, 2018
1 parent c8294c7 commit aeedb6467bbeacaf465d26c47d8cb44b8aee5255
@@ -28,6 +28,7 @@
private float heading = 0;
private final Matrix matrix = new Matrix();
private final float[] points = new float[2];
private int saveCount = -1;
private final SmoothCanvas smoothCanvas = new SmoothCanvas();
public RotateView(Context context) {
@@ -45,11 +46,14 @@ protected void dispatchDraw(Canvas canvas) {
return;
}
canvas.save();
saveCount = canvas.save();
canvas.rotate(-heading, getWidth() * 0.5f, getHeight() * 0.5f);
smoothCanvas.delegate = canvas;
super.dispatchDraw(smoothCanvas);
canvas.restore();
if (saveCount != -1) {
canvas.restoreToCount(saveCount);
saveCount = -1;
}
}
@Override

0 comments on commit aeedb64

Please sign in to comment.