Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SurfaceView vs Custom View (extended from View). SurfaceView is slower, Why?

I wrote the same program two ways.

One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower animations, less intense graphics.

However, in my simple app, I can clearly see that using a custom view with calls to invalidate seems to render faster.

What do you guys know/think about this?

My touchEvent code is exactly the same, and my drawing code is exactly the same. The only difference is that one is all in the UI thread, and the other is using a tread to handle the drawing.

like image 582
Andi Jay Avatar asked Nov 06 '22 09:11

Andi Jay


1 Answers

SurfaceView enables to work on 2 buffer for drawing, how about your custom view?

Another thing: You mentioned that the doc says invalidate works fast on slower animations/less intense graphics. How intense is your "simple app"? You should try to do a stress test and also take in account, how the single thread handles your touch-input.

I have 3 threads in my game. One for game logic, one for drawing and then the "normal" UI thread...

like image 183
WarrenFaith Avatar answered Nov 15 '22 10:11

WarrenFaith