python:比较简单,官网下载2.x版的msi,直接安装
为了方便命令行,将安装路径加入到path环境变量
gyp : 从googlecode下载下来,然后
python setup.py install
这样就安装到python里了,以后用就方便了
skia的api文档,打不开就果断翻墙吧~~~
Introduction
Skia is organized around the Canvas object.
It is the host for the "draw" calls: drawRect, drawPath, drawText, etc.
Each of these has two components:
the primitive being drawn (SkRect, SkPath, etc.) and color/style attributes (SkPaint).
canvas.drawRect(rect, paint);
The paint holds much of the state describing how the rectangle (in this case) is drawn:
what color it is, if it is filled or stroked, how it should blend with what was previously drawn.
The canvas holds relatively little state.
It points to the actual pixels being drawn (hosted by a Bitmap), and it maintains a stack of matrices and clips.
Thus in the above call, the canvas' current matrix may transform the coordinates of the rectangle (translation, rotation, skewing, perspective),
and the canvas' current clip may restrict where on the canvas the rectangle will be drawn, but all other stylistic attributes of the drawing are controlled by the paint.
Skia的所有功能都是围绕Canvas对象展开的,主要的功能实现都是drawXXX系列函数,它们的参数都是(画哪里,怎么画)
画哪里,指SkRect, SkPath等等的实例
怎么画,指SkPaint实例
Canvas也负责少量的控制("画哪里"和"怎么画"),譬如实际画多少像素,矩阵(用于变换,旋转,位移,透视等等)和剪辑(限制画哪里)
2. Roadmap
Skia is a key part of several shipping products, and as such will continue to track those projects' needs and priorities.
However, Skia is also a general purpose graphics engine, and as such there are a number of areas that need additional work.
Porting
Skia has a well-defined porting layer, consisting mostly of back-end support for services like threads, fonts, time, and IO.
Fonts - skia has its own portable cache for drawing text, but the actual creation of individual glyph images and metrics are left to the porting layer. There are two classes that must be supplied by the port
SkFontHost - this is a collection of static methods that are responsible for finding font files by name, and for providing read-access to them, most for the scaler context
SkScalerContext - this is a class that is instantiated for each font strike, that is each combination of a typeface+pointsize+matrix+flags.
Image Decoders - skia comes with a collection of wrappers for standard image codecs: jpeg, png, gif, bmp, ico, wbmp. These wrappers bind the existing open source codecs into skia's framework (i.e. they return an SkBitmap). The porting layer supplies the exact set of codecs that are available, by implementing SkImageDecoder::Factory.
Threads - skia can be compiled w/o thread support. However, if support is needed (e.g. to make the font cache useable from multiple threads), then basic operations must be supplied (atomic inc/dec, mutex lock/unlock).
File IO - as a backend for its stream class (see SkStream), the port needs to supply basic file io (open, read, write, close)
Time - a port needs to implement a method to return a millisecond clock (not necessarily time of day).
Fortunately, all of the above has been done for several operating systems [Macintosh, Windows, Linux, Android], so it is usually pretty easy to begin with an existing port, and adapt it to a new environment. In particular, the image codecs are all very portable, as is the scaler context class written around FreeType, so often a new port is just an exercise in picking and choosing from existing modules.
Skia定义了一个接口层,用于跟操作系统打交道,譬如线程,字体,时间和输入输出等.
Fonts - 字体,接口层必须要提供两个类的实现
SkFontHost - 提供一系列的静态方法,用于根据字体名字找到对应的字体文件,并且提供读取它们的功能
SkScalerContext - 字体绘制上下文
Image Decoders - 图像解码,Skia利用各种开源类库对不同的图像编码格式进行解码,譬如jpeg,png,gif,ico等等,通过对这些类库进行封装,统一返回SkBitmap对象
Threads -
File IO - 要求封装各个平台的文件读写,skia只需要处理SkStream
Time - 要求能够提供毫秒级的时间
大部分操作系统都已经提供了上述的功能了,所以只需要很简单的wrap一下就ok
Ports
Android
This work is taken care of by the android team
Windows
Some of this is part of the Chrome product, but more work remains to optimize the Font support
Macintosh
More work is needed for better integration with Fonts, and helper libraries to integrate with the windowing environment
Linux
fontconfig work is underway
need someone to help with integration libraries or various windowing kits
WinMo - TODO
Symbian - TODO
iPhone - TODO
Language Bindings
Skia is a C++ library. To expand its usefulness, bindings to other languages are needed
Perl
Python
JavaScript
C#
Java (other than the android/dalvik bindings)
C - a stable C interface that would explicitly hide the size of most complex types, making its more stable across versions (unlike C++)
Frontends
Skia's flexible API should make it viable to support existing APIs and graphc formats. We need readers/translators to parse the following into Skia API calls...
SVG
Postscript / PDF
Flash
Illustrator
Core Features
These core (missing) features are already planned for, but much of the work remains to be done.
ICU Layout integration for complex-script support when drawing text
ImageFilter (ala SkMaskFilter in full color)
MipMaps (partial implementation exists)
HitTesting (probably via a subclass of SkCanvas)
Formalize API around hinting options
More flexible font chaining
Testing
- Unit tests for bring up on a new port - Rendering regression tests (comparing w/ a master image) - Performance tests