Interesting Live Wallpaper Behavior

194 views Asked by At

I just started making some of my first live wallpapers in Android, and I noticed an interesting behavior regarding the PixelFormat. If I use the SurfaceHolder's default PixelFormat, my live wallpaper is a bit laggy. If I set the PixelFormat to RGB_565 it seems to fix this problem. This really should not be too surprising. What was odd was profiling reveal that it was taking just as long to do the rendering in both formats. Could anyone explain this behavior.

Thanks, Xor

---Edit--- If it of any help, I am rendering on a Canvas. All I do is call drawColor and draw 3 fairly simple, anti-aliased paths. Not really much to it.

1

There are 1 answers

5
Chiral Code On

PixelFormat shouldn't be a problem. You should be even able to set PixelFormat.RGBA_8888 with no performance hiccups. In some cases this format is useful to reduce color banding on gradients.

Using Handler for animation may be good for simple cases, but you should consider using separate thread for this task. Some time ago I've prepared simple live wallpaper template. You can download whole project for GitHub and experiment a bit with it. I'm sure that you'll get much better performance.