android - Why is canvas not clipped in onDraw? -
in example, try invalidate rectangle of custom view, canvas passed ondraw not clipped. output shows clip bounds contain whole canvas. what's reason this?
public class clippingactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new clippingview(this)); } } class clippingview extends view { rect r = new rect(); public clippingview(context context) { super(context); } @override protected void ondraw(canvas canvas) { canvas.getclipbounds(r); log.d("clippingview","ondraw: " + r); } @override public boolean ontouchevent(motionevent event) { invalidate(0,0,400,400); return true; } }
i found closely related question: partial invalidation in custom android view hardware acceleration
romain guy answered it:
partial redraw works fine, specified region of screen redrawn. won't change clip bounds on canvas. drawing operations recorded ones intersecting dirty region executed.
Comments
Post a Comment