转自:http://www.cnblogs.com/Caiqinghua/archive/2010/08/04/1791752.html
一、简介:
skia 有大概 80,000 行代码,基于 C++ 开发,主要特点包括:
- 高度优化的软体 ->Optimised software-based rasteriser (module sgl/);
- 选择性透过OpenGL/ES ,加速特定操作,如shader 和 textures -> Optional GL-based acceleration of certain graphics operations including shader support and textures (module gl/);
- 动画处理能力->Animation capabilities (module animator/);
- 内建SVG支援->Some built-in SVG support (module (svg/)
- 內建若干 image codec,如 PNG, JPEG, GIF, BMP (modules images/) ->Built-in image decoders: PNG, JPEG, GIF, BMP, WBMP, ICO (modules images/);
- 内建文字处理,但缺乏泰文、藏文一类复杂文字处理能力->Text capabilities (no built-in support for complex scripts);
- Some awareness of higher-level UI toolkit constructs (platform windows, platform events): Mac, Unix (sic. X11, incomplete), Windows, wxwidgets
- 功能特性 Performace features
- Copy-on-write for images and certain other data types;
- Extensive use of the stack, both internally and for API consumers to avoid needless allocations and memory fragmentation;
- Thread-safety to enable parallelisation.
The library is portable and has (optional) platform-specific backends:
- Fonts: Android / Ascender, FreeType, Windows (GDI);
- Threading: pthread, Windows;
- XML: expat, tinyxml;
- Android shared memory (ashmem) for inter-process image data references;
二、从应用层到底层对skia的调用关系
Android对skia的调用是一个比较经典的调用过程,应用程序的几个包是在SDK中提供的;JNI放在框架的JNI目录下面的Graphic目录;skia是作为一个第三方组件放在external目录下面。skia结构如图:
其实主要涉及到的3个库:
libcorecg.so 包含/skia/src/core的部分内容,比如其中的Region,Rect是在SurfaceFlinger里面计算可是区域的操作基本单位;
libsgl.so 包含/skia/src/core|effects|images|ports|utils的部分和全部内容,这个实现了skia大部分的图形效果,以及图形格式的编解码;
libskiagl.so 包含/skia/src/gl里面的内容,主要用来调用opengl实现部分效果。