I have a view which does some basic drawing. After this I want to draw a rectangle with a hole punched in so that only a region of the previous drawing is visible. And I\'d
Instead of allocating a new canvas on each repaint, you should be able to allocate it once and then reuse the canvas on each repaint.
on init and on resize:
Bitmap b = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
on repaint:
b.eraseColor(Color.TRANSPARENT);
// needed if backColor is not opaque; thanks @JosephEarl
c.drawColor(backColor);
c.drawCircle(cx, cy, radius, eraser);
canvas.drawBitmap(b, 0, 0, null);