Google Skia graphics engine

September 2008, Google announced improvements to the core through the WebKit web browser Chrome, exposed the many new features, for example, new [ V8 ] JavaScript (ECMAscript) execution engine, perhaps too rosy, the use of masking the other an open-source project [ Skia ], which is a 2D vector graphics library, including fonts, coordinate transformation, and bitmap are efficient and compact performance. Not only for Google Chrome browser, opening up new Android mobile phone platform also used skia as graphics, with OpenGL / ES with specific hardware features, enhanced display effects, this profile Google Skia historical background, application, and to investigate its programming model.

Google to build Open Handset Alliance (OHA) of the Android platform, layout very long time, R & D team behind the 100 people mostly from before the merger, two of them with indicators of significance:

  • August 17, 2005, acquisition of the U.S. Android, the mobile phone software business, which of course is now open source Android project predecessor
  • November 2005 acquisition of U.S. Skia company, business is a vector drawing software

Prior to the acquisition of Android by Google in the IT industry, the company has a man to tell about the results, this article does not talk about, and Skia company is not fuel-efficient natural light. Skia Inc. Was set up in North Carolina, Chapel HIll, by the Michael Reed (also known as Mike Reed) was the founder, his graphics technology is a very top people, and Benoit Schillings (BeOS major developer, Be Inc . The second engineer, now Nokia CTO) in the mobile software development company OpenWave professional when working, that is, in the company's products OpenWave Phone Suite Version 7.0 (hereinafter referred to as V7) the introduction of sophisticated vector graphics technology, the space in 50-300 kb do in fact provide a layer between the alpha blended overlay preview, full-function advanced features such as vector matrix transformation. Prior to joining OpenWave, Mike Reed to serve Apple, on behalf of the project for the QuickDraw GX, a leading advanced graphics and font handling techniques. Benoit Schillings transferred from OpenWave during Trolltech CTO, Mike Reed created a Skia Inc., The company's first product for the SGL (Skia Graphics Library), a very strict vector graphics engine, capable of low-end devices such as mobile phones, television and other on handheld devices, presenting high-quality 2D graphics. According LocalTechWire description:

"Skia's first product, SGL, is a portable graphics engine capable of rendering state-of-the-art 2D graphics on low-end devices such as mobile phones, TVs, and handhelds," the Web site said. "SGL is feature- set compatible with existing 2D standards, making it ideal to serve as a back-end for public formats such as SVG, PDF, and OpenVG. SGL is licensed as source or binary, and can be customized to match specific HW / framebuffer requirements. "

Skia 2005 after the acquisition by Google has been fairly low-key mystery, until early 2007, Skia GL-related code is revealed, as the Google Android platform graphics engine, wait for Google Chrome browser, also used Skia engine. With Android and Chrome (open version is called "Chromium") announced two major projects program code, skia also be open source code to Apache License v2 release (note that this means that is not compatible with the GPLv2 license), The Android and Chrome's code library has a [ Skia ] replication, due to different requirements, made some changes, for example, Chrome project under the [ chrome / trunk / src / Skia ], to note that Skia itself is not involved in the underlying environment, such as the Linux Framebuffer or Gtk + interface for handling, this is why the Android ( Through Linux Framebuffer) and Chrome (developed in the Linux version uses Gtk +) the need for a revised, so that the system integration, on this of information, can refer to Google Chromium Development log [ Graphics in Google Chrome ]

Compared with Firefox 1.x, Firefox 2.x/3.x subsequent terms in the graphical display considerable progress, significant level due to the introduction of Cario vector graphics link library to handle HTML rendering, but the equivalent of playing Skia Cairo's role, but some lighter volume. WebKit as if the rapid development of desktop applications, crossed over from the mobile devices of choice for web engine solution, Apple and Google have invested a significant number of full-time engineers, thanks to the power of the Internet, there are other companies and individuals active in community development, current WebKit graphics library supported include Cairo, Gtk +, Qt4, WxWidgets, Cg (Mac's non-open source library), Skia, etc. and to deal with the aforementioned WebKit in class GraphicsContext do real graphics library can be for different platforms, features, specifications required for different platforms and members of the macro, please refer to program code WebCore / platform / graphics / GraphicsContext. (h, cpp).
Skia to C + + to implement, and program code of about 80 000 lines, the basic some unknown factors, may refer to the documents is limited, but the SVN log and Chromium code is now the most complete file, the following are its features:

  • Highly optimized software rasteriser (module sgl /)
  • Selectivity through the OpenGL / ES, accelerate specific operations, such as shader and textures (module gl /)
  • Animation capabilities (module animator /)
  • Built-in SVG support (module (svg /)
  • Built a number of image codec, such as PNG, JPEG, GIF, BMP (modules images /)
  • Built-in word processing, but the lack of Thai, Tibetan for a class of complex word processing capabilities
  • Performance Characteristics:
    • Specific data on the image and the types of Copy-on-write
    • Internal memory management, be careful to avoid fragmentation
    • Thread-safety

Skia really make the required dependencies:

  • Font: FreeType (It is worth noting, FreeType defender David Turner who now works at Google), Windows GDI
  • Multi-threading model: pthread, Windows threads
  • XML: expat, tinyxml

Understand the historical background, we can finally point to make things interesting. First of all, made from the Google Code Skia original code:

# Svn co skia-trunk

At first glance this "refreshing" the directory structure, it is difficult to imagine the past, this is a commercial software, perhaps Google some "can not be said of the secret", in addition to samplecode / catalog number of the program code, the full documentation on a few. Using svn log records available Skia development, "" I am Mike Reed is still very active in the real improvement Skia do. Compilation method is very simple, look at the description: (This corresponds to svn r130)

# Cd skia-trunk

# Make help

Obtain the following description:


: Out / libskia.a

bench: out / bench / bench

tests: out / tests / tests

clean: removes entire out / directory

help: this text

Options: (after make, or in bash shell)

SKIA_DEBUG = true for debug build

SKIA_SCALAR = fixed for fixed-point build

SKIA_BUILD_FOR = mac for mac build (eg CG for image decoding)

The desired output is compiled static libraries out / libskia.a, and Skia internal floating point and fixed-point computation can choose (fixed-point), but I find that there is not through yet have to choose, but this does not affect our understanding Skia use and experience of its power. I used to GNU / Linux, it may be given the following instructions to compile:

# Make SKIA_BUILD_FOR = linux

Not unexpected, the system will be nice compilation:

compiling out/src/core/Sk64.o

compiling out / src / core / SkAlphaRuns.o

compiling out / src / core / SkBitmap.o


As for compiling benchmark programs, you can through the following instructions:

# Make SKIA_BUILD_FOR = linux bench

benchmark programs considered in addition to Chromium, the best "document", but still simple and powerful SKia API already, this is not prejudice. Implementation of the benchmark programs:

. / Out / bench / bench-o `pwd`

Gradually there will be similar to the following output:

running bench polygon

running bench lines

running bench points

running bench rrects3

running bench rrects1

running bench ovals3

running bench ovals1

running bench rects3

running bench rects1

running bench bitmap_index8

running bench bitmap_4444

running bench bitmap_565

running bench bitmap_8888

Skia can probably lift the veil on the scope of coverage, then I would write a small program that uses C + + API Skia: [ test-skia.c ]

/ * Simple vector graphics demo utilizing Skia toolkit.

* Authored by Jim Huang <>

* /

# Include "SkBitmap.h"

# Include "SkDevice.h"

# Include "SkPaint.h"

# Include "SkImageEncoder.h"


/ / Declare a raster bitmap, which has an integer width and height,

/ / And a format (config), and a pointer to the actual pixels.

/ / Bitmaps can be drawn into a SkCanvas, but they are also used to

SkBitmap bitmap;

bitmap.setConfig (SkBitmap:: kARGB_8888_Config, 200, 200);

bitmap.allocPixels ();

/ / Device (bitmap). This includes a reference to the device itself,

/ / And a stack of matrix / clip values. For any given draw call (eg

/ / DrawRect), the geometry of the object being drawn is transformed

/ / By the concatenation of all the matrices in the stack. The

/ / Transformed geometry is clipped by the intersection of all of the

SkCanvas canvas (new SkDevice (bitmap));

/ / Draw geometries, text and bitmaps.

SkPaint paint;

r.set (25, 25, 145, 145);

canvas.drawRect (r, paint); / ** Draw the specified rectangle using

the specified paint. The rectangle

will be filled or stroked based on

the Style in the paint. * /

r.offset (20, 20);

canvas.drawRect (r, paint);

r.offset (20, 20);

canvas.drawRect (r, paint);

/ / From a specific SkBitmap.

SkImageEncoder:: EncodeFile ("snapshot.png", bitmap,

SkImageEncoder:: kPNG_Type,

/ * Quality ranges from 0 .. 100 * / 100);

return 0;


Compiled by:

g + + \

-I./include \

-I./include/core \

-I./include/images \

-Wall-o test-skia test-skia.c \

out / src / images / SkImageDecoder_libpng.o out / libskia.a \


I made a brief comment, probably be aware of Sk at the beginning of the API function, but the beginning of the example program requires Skia configuration canvas (SkCanvas), followed by a SkRect object r, the description given ARGB, so that it has a different color, again is to adjust the displacement vector objects and Draw. As previously mentioned, Skia graphics engine just did not like Cairo generally corresponds to the wide range of PDF, X11, GDI and so the underlying graphics device, so in order to facilitate observation of the drawing results, we have built through Skia to output PNG map image codec file, so the implementation of the above compiled executable file "test-skia", should get the following image file: (no frame and the background, but in order to clear in the article show, the additional use of mapping software Supplementary)

<!--[ If! Vml] ->
<!--[ Endif] ->

Overlays of three different colored rectangular object is reached through the following API calls:

paint.setARGB (255, 0, 255, 0);

r.offset (20, 20);

canvas.drawRect (r, paint);

Skia Cairo as the same configuration with a high, it can refer to [ Cairo:: documentation ] to establish the necessary background knowledge.

/ / SkImageEncoder is the base class for encoding compressed images

paint.setARGB (255, 0, 0, 255);

paint.setARGB (255, 0, 255, 0);

paint.setARGB (255, 255, 0, 0);

SkRect r;

/ / SkIRect holds four 32 bit integer coordinates for a rectangle.

/ / SkPaint class holds the style and color information about how to

/ / Clips in the stack.

/ / A Canvas encapsulates all of the state about drawing into a

/ / Specify the target of a SkCanvas' drawing operations.

int main ()

# Include "SkRect.h"

分类:Mobile 时间:2010-08-11 人气:325
blog comments powered by Disqus


  • Common Chinese word open source project 2010-07-07

    As the project technology needs, need to use the Chinese word, then go research a bit simple, easy to gather some information Common Chinese word open source project SCWS Hightman developed a machine based on word frequency dictionary of Chinese word

  • Google's new open source project ANGLE 2010-03-25

    Google announces new open source project ANGLE: Let WebGL content rendering OpenGL driver is no longer dependent on 2010-03-19 11:16 Google today announced a new open source project ANGLE (full name Almost Native Graphics Layer Engine), this project

  • How to create an open source project Google Code 2010-10-22

    How to create an open source project Google Code 1. To apply Google's account, and log 2. Open the Google project hosting Homepage 3. Click contribution to open source projects into the GettingStarted 4. Click Create Project , enter the Create Projec

  • How to create open source project on Google Code 2011-07-21

    1 for a Google account, and log 2 Open the Google project hosting Homepage 3 Click the contribution of open source projects into the GettingStarted 4 Click Create Project , the Create Project page 5 Fill in the information, and Create Project Project

  • Source Project will introduce eclipse, and compile source code under linux 2010-09-27

    Start with an eclipse of the Android project the following 3 grid file copy, you can even HelloWorld program. 1,. Classpath 2,. Project 3, Note: The first two files are hidden files, show hidden files first to see. Copied later, ch

  • [Reserved] crazy big collection of Web application open source project 2011-08-17

    <p mce_style="text-align: left; "> switched <br> <br> <br> The following is a list of open-source Web applications . Nothing to say, crazy. In particular, it is a bunch of Web 2.0. I

  • DotProject open source project management 2010-06-21

    In fact, many work need to be conducted in terms of project management. From a team point of view, but also the need for members in accordance with project management control. The most widely used project management software is MS Project, with the s

  • Android take full advantage of the open source project 2010-12-22

    Linux is open source operating system, due to the involvement of Google Android open-source community to become very lively. Most components of the operating system Android is open source. Android mobile phone network to see what with everyone using

  • C # open source project description (rpm) 2011-05-22

    C # open source project (still a lot of foreign countries) A, Ajax framework Ajax.NET Professional (AjaxPro) was the first to AJAX technology in Microsoft. NET environment, the implementation of the AJAX frameworks. It creates client-side script on t

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.418 (s). 12 q(s)