Is there way to prevent drawing of parts of objects, like bitmaps or paths, which go beyond the borders of Canvas
in SurfaceView
?
When I gradually scale an object beyond the Canvas
' size, especially with blurred paint, it all slows down to a stand still and I have to wait few seconds to get the control back -- it is not responsive. I scale an object by moving my finger over the screen; if I do it too fast and scale it up, then it really slows down drawing.
I did not have the same problem when using just ordinary View
canvas, so don't know what is slowing it down. It's as though SurfaceView
responds too fast and then gets congested.
So one idea to improve this, is to prevent drawing outside canvas, but not sure if SurfaceView
has such clipping options.
One solution perhaps is by using one of the Canvas
.drawBitmap
methods that accepts a source Rect
/ RectF
argument, so that only the visible portion of the Bitmap
is rendered. I've just done this on my own project to speed up SurfaceView
performance where I have several Bitmaps
that are sometimes only partially in view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With