Google Skia graphics engine

2010-08-11  来源:本站原创  分类:Mobile  人气:354 

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, "[email protected]" 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 <[email protected]>

* /

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

相关文章
  • Google Skia graphics engine 2010-08-11

    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-s

  • Ogre graphics engine introduced 2010-03-25

    1 - What is the Ogre Ogre is an open source graphics rendering engine, it's full name (Object-oriented Graphics Rendering Engine), which consists of a core group to develop and maintain, as it is an open source engine, so it is also the same as the L

  • Google发布App Engine 欲打造网络应用统一平台 2015-02-15

    Google Apps为团体及企业用户提供了一体化的在线协作应用套件,但那只是一个开始.尽管用户可以直接利用Google Apps里的在线应用,无需添加额外的主机或管理,但同时,用户的选择也不多,因为所有的应用都是直接由Google指定的.想像一下,如果Google直接提供一种在线应用平台,允许用户直接在平台上创建及运行各种应用,那该有多震撼. 根据TechCrunch得到的情报,在今天晚些时候,Google将在Google Campfire One大会上宣布推出App Engine(应用引擎)

  • google appengine application engine is really good strong, just love legoogle 2010-06-19

    google application engine is really good power, he was the space we provide full free, but it Yijing enough that we used in the study of the novice, Although , google on each user's configuration has certain limitations, but there will be Chaoguozheg

  • google custom search engine 2010-06-22

    <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/cse/api/007429510447144258136/cse/a6v1wwaio6q/gadget&synd=open&w=320&h=75&title=%E6%90%9C%E7%B4%A2%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2+-+%E4%BD%BF%E7%94%A8google

  • [Transfer] Android graphics system analysis 2011-03-30

    Original Address: http://www.linuxgraphics.cn/android/graphics_system.html Android graphics system analysis Author: Based on the reference date of 1 additional order is made: 2009-06-04 This article attempts to describe Android underlying graphics sy

  • Android 2.1 Source Structure Analysis 2010-05-10

    Android 2.1 Source Structure Analysis Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development package configuration

  • Adroid core analysis 2010-06-27

    On the blog: http://blog.csdn.net/maxleng 2010 In June. 14 Day Android core analysis (28 )----- Android GDI of Surface & Canvas Surface & Canvas Canvas is the meaning of the canvas. Android's mapping upper Canvas instance by almost complete, in fa

  • Android 2.1 source directory structure of (turn) 2010-08-03

    Android 2.1 source directory structure of (turn) Author Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development pac

  • The most comprehensive source directory structure Xiangjie Android 2010-08-25

    Android 2.1 | - Makefile | - bionic (bionic C Library) | - bootable (boot-related code) | - build (compile rules and generic storage systems and other infrastructure development package configuration) | - cts (Android compatibility test suite standar

  • Source directory structure Xiangjie 2010-09-11

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development package configuration) | - Cts (Android compatibility test kit standard)

  • Android2.1 source structure analysis 2010-09-29

    The following is reproduced: Android 2.1 Source Structure Analysis Rockie Cheng Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure deve

  • Android - Android2.1 Source Structure Analysis 2010-12-07

    Android 2.1 Source Structure Analysis Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Androi

  • Detailed source directory structure 2011-01-10

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Android compatibility test suite standard) |

  • Android 2.1 Source Structure 2011-01-14

    Android 2.1 | - Makefile | - Bionic (bionic C Library) | - Bootable (boot-related code) | - Build (compile rules and generic storage systems and other infrastructure development kit configuration) | - Cts (Android compatibility test suite standard) |

  • [To] Android directory structure 2011-05-23

    Android directory structure Android 2.1 | - Makefile | - bionic (bionic C Library) | - bootable (boot-related code) | - build (compile rules and generic storage systems and other infrastructure development kit configuration) | - cts (Android compatib

  • A serious shortage of qualified personnel Android-IASN · Love Moon Technology 2011-05-23

    A serious shortage of qualified personnel Android-IASN · Love Moon Technology IOS are users like Android and the operating system, Android is a software stack for mobile devices, including operating system, middleware and key applications. Android SD

  • google app engine Google Application Engine 2010-06-20

    Use google appengine application engine for some time, began to use python, then google even begun to support java, which really made me was very excited, but also the traditional application server that a lot of difference, most notably in the data

  • Google search engine optimization - website design for search engines 2010-07-31

    Abstract: Site in the search marketing major shortcomings: Knowledge of the industry: do not know search engines to attract new users of the importance of search engine ranking services in the pursuit of "fool-related", buy some in fact do not h

  • Google's start - analyzes large-scale hypertext web search engine 2010-12-01

    Reprinted from: http://www.yeeyan.com/articles/view/thunder/364 Author: Sergey Brin and Lawrence Page Translator: thunder and heavy rain large (Blog) Translators: This is the Google founders Sergey and Larry at Stanford University when the Department