`
haking
  • 浏览: 262686 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Android SurfaceView

 
阅读更多

最近自己做了个指南针应用,用到了SurfaceView。总结下Surfaceview与View的区别:

(因为写程序时是用英语写的注释和笔记,这里就贴英语的,但是本人英语不是很好。)

 

SurfaceView VS View


SurfaceView has an instance of Surface which can use OS background thread to
handle onto a raw buffer that is being managed by the screen compositor.


Because of Surface, SurfaceView has two main difference from View:
1. SurfaceView can draw canvas in background thread, not UI thread.
2. SurfaceView can use OpenGL(via Surface) which can draw 3D object
  and use Hardware Acceleration to have a faster drawing.


Therefore, if we have to use 3D or high FPS(Frame per Second) performance,
use SurfaceView; otherwise use View.

 

Something about Surfaceview native code


Android graphic engine -- Skia -- main class type SkCanvas


View.invalidate() --- Android framework --- View.onDraw() --- Nativecode draw on SkCanvas


SurfaceHolder.lockCanvas() to get SkCanvas --- Nativecode draw on SkCanvas --- SurfaceHolder.unlockCanvasAndPost()

 

refer to:

http://branda.to/~thinker/GinGin_CGI.py/show_id_doc/404

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics