Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android View vs SurfaceView vs GLSurfaceView for 2D drawing app with Zoomable User Interface

I plan to write a 2D drawing app with a zoomable user interface. With the app the user should be able to transform (translate and scale) drawn paths (and of course the UI). I assume that there will be up to 500 paths at the same time. Now, I am wondering which view to start off with (View, SurfaceView or GLSurfaceView ) in order to provide acceptable performance. I read a couple of posts [1-6] including the once on android developer guide and am still not 100% sure which view to use.

According to the presentation at Google I/O 2009 (http://youtu.be/U4Bk5rmIpic?t=45m10s) and own experiences canvas (View and SurfaceView) doesn't seem to be performing fast enough when handling more than 100 paths.

Does anyone see a possibility in implementing the app using canvas or is OpenGL the way to go?

[1] Android: Deciding between SurfaceView and OpenGL (GLSurfaceView)

[2] SurfaceView or GLSurfaceview?

[3] Difference between SurfaceView and View?

[4] http://pierrchen.blogspot.jp/2014/03/anroid-graphics-surfaceview-all-you.html

[5] Difference between SurfaceView and ImageView

[6] Difference between SurfaceView and GLSurfaceView in Android

like image 524
Hannes Leitner Avatar asked Nov 04 '14 15:11

Hannes Leitner


1 Answers

Because of your performance concerns, you will need to use hardware rendering. Displays keep getting denser, so touching every pixel in software is getting slower.

If you want to draw with a Canvas, you must render to a custom View, with hardware acceleration enabled. Canvas rendering on a Surface is always done with software.

SurfaceView and GLSurfaceView are nearly the same thing; GLSurfaceView just has some helper functions that take care of some of the housekeeping for you. You can use GLES to render on SurfaceView and TextureView. There are multiple examples of this in Grafika.

If you want to know what's going on under the hood, see the System-Level Graphics Architecture doc.

You may want to consider the use of an open-source 2D game engine. That'll handle the EGL setup, should provide code for GLES font rendering, and so on.

like image 138
fadden Avatar answered Oct 02 '22 23:10

fadden