I'm creating an off-screen bitmap+canvas, drawing a bunch of smaller bitmaps into it, then drawing it into a view. The isHardwareAccelerated() method returns false for my canvas:
mBitmap = new Bitmap(500, 500, Bitmap.Config.RGB_565);
mCanvas = new Canvas(mBitmap);
mCanvas.isHardwareAccelerated(); // false
I can see that the canvas given to me in my View's onDraw() method is hardware accelerated though:
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.isHardwareAccelerated(); // true
// My current approach, but maybe better to draw directly
// to the view's canvas if it's hardware accelerated?
canvas.drawBitmap(mBitmap, ...);
}
I'm wondering if we can turn this on for the off-screen canvas?
I'm also wondering if I should just draw directly to the view's hardware-accelerated canvas instead of bothering with the off-screen one, if it's not going to be accelerated. I thought it would be faster drawing everything to the offscreen one first.
I have to reorganize my code to test this out, just wondering if I'm missing something obvious for the off-screen one.
Thanks
------- Update -----------------------------------
I refactored my draw code to just draw directly to the view's canvas in onDraw(), instead of using the off-screen canvas. Performance is way better.
It would still be nice to enable hardware acceleration for the off-screen canvas though, there are definitely tons of use-cases for that.