8

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.

user291701
  • 38,411
  • 72
  • 187
  • 285
  • Have you read over [Hardware Acceleration - View Layers](http://developer.android.com/guide/topics/graphics/hardware-accel.html#layers) yet? – Geobits Nov 08 '13 at 18:20

0 Answers0