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 http://skia.googlecode.com/svn/trunk 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, "reed@android.com" 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:

Targets:

: 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 <jserv.tw@gmail.com>

* /

# 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 \

-Lpng-lpthread-g

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.

http://yp.oss.org.cn/software/show_resource.php?resource_id=192

/ / 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"
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Google Skia graphics engine

  • ajax input prompt implementation

    Projects have used at the time entered by the user to give some tips, suggesting that the contents are extracted from the database (in Chinese). So a google search under the amended part of their code to share with you. Attachment is available at the ...

  • Mapping tool for browser-side analysis

    Divided into two main categories: One category is pure Javascript Advantages: does not require any plug-in, no understanding of Flash Recommend Product: 1 Flot http://code.google.com/p/flot/ Function well, the document is too easy 2 EJS commercial pu ...

  • Manual configuration in UBUNTU under ruby on rails environment

    Careless mistake for the day before yesterday, the sources, the results after 810 error after the upgrade, the loss of response button. On google found a lot of trouble really, lucky point modification under the / etc/X11/xorg.conf to restore both, b ...

  • Ruby Rails system calls the use of Ping

    Want to use call system commands under RoR, the general exec and system and the syscall Want to use in Rails, the call ping command The most common are ruby support Ping usage is as follows: Ping contains routines to test for the reachability of remote ho

  • Rails source code analysis (4): Request / Response

    1) Rails defines two abstract class: AbstractRequest and AbstractResponse code is not posted, first take a look at Response. 2) is mainly responsible for the specific ctgi_process.rb main interface is responsible for implementation methods of impleme ...

  • Strength of live practice teaching materials, suitable for each person team look - UFIDA Hua Table CTO talk about "out of the software factory"

    A few months ago, on reading "Going the software factory," one book, not yet published at that time, it can be considered the reference of the watch. Although the language rather uneventful, but the contents of people really can not but carry on

  • ROR resources

    Ruby Web site resources: ruby official website: http://www.ruby-lang.org ruby doc official website: http://www.ruby-doc.org rubyonrails official website: http://www.rubyonrails.org programming ruby online edition (Ruby studying the "Bible") ...

  • What is the JPA

    Same, JDO, also started compatible JPA. At the field of ORM, it seems that JPA is a benevolent government, is the normative specification. At the support of major manufacturers, JPA use became widespread. 2 Spring Spring + Hibernate often referred to as t

  • Use Ext JS to read the JsonReader complex object json

    Today was how to resolve the following complex json object to the difficult living over a long time .. did not find documentation how to read JsonReader Ways json object (possibly also because of their limited level of E the text did not correctly underst

  • NoClassDefFoundError: javax / servlet / Servlet

    In the project in order to achieve a listener in web.xml set up a listener, did start in Tomcat actually occurred after java.lang.NoClassDefFoundError: javax / servlet / ServletContextListener this anomaly google and found the reasons for the lack of serv

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries