سؤال

I'm in my first tries with the android 2D API (I learned a lot here), and while playing with alpha blending I noticed some worrying performance issue on my Honeycomb tablet (TF101) :

canvas.drawBitmap(bmBackground, 0,0, null);                     
canvas.drawBitmap(bmForeground, 0, 0, p);

The code above is rendered using the well known SurfaceView/Thread couple. bmBackground is RGB_565, bmForeground is a mutable ARGB_8888, the paint p is for playing with alpha only. Both bitmaps are full screen.

On both my Nexus S and Galaxy S (Gingerbread), the rendering is running at 55 fps whatever the alpha value I set for p, and whatever the pixel format for bmForeground (RGB_565 or ARGB_8888).

But on my Honeycomb tablet, I've some strange behaviour :

  • 60 fps with alpha disabled (= 0)
  • 10 fps with 0 < alpha < 255
  • 20 fps with p = null
  • 60 fps with bmForeground = RGB_565

It seems that the driver have some performance issue when using alpha blending and/or converting from ARGB (Bitmap) to RGB (framebuffer) ?

I already know about the OpenGL solution, but I'd like to understand what's happening here, and to find a way to solve it.

That would be awesome that a dual core device running at 1GHz can't do better than my Galaxy S drawing 2 bitmaps ! Am I missing something ?

هل كانت مفيدة؟

المحلول

There is no drivers issue, rendering with a Canvas onto a SurfaceView is done entirely in software. Having 2 cores or even 1 Ghz don't necessarily help, what matters most of the time with bitmaps is the memory bandwidth and the Galaxy S is really good at that.

You are also making the assumption that your framebuffer is RGB but you don't specify which RGB (RGBX 8888 or RGB565?) How do you create your SurfaceView? It is very important that you minimize conversions (if your SurfaceView is RGBX 8888, don't use RGB 565 bitmaps, if your surface is RGB 565, avoid using RGBA 8888 bitmaps, etc.)

You also fail to mention how big your bitmaps are? If both your bitmaps are fullscreen bitmaps, the performance you are getting is not unexpected if your tablet has the same architecture as a Motorola Xoom (Tegra2 based.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top