[Change] Android technology - graphics system Xiangjie

This paper describes the underlying implementation of graphics system Android. Android underlying graphics system to achieve a very complex document less, to use popular graphic form, such as X window, Cairo, etc..

Android's graphics system, Client / Server architecture. Server (ie SurfaceFlinger) mainly written in c + + code. Client-side code is divided into two parts, the supply is provided by the use of Java to use the api, the other one is written in c + + by the underlying implementation. The following diagram outlines the android graphics system architecture and key components used to.

Android graphics system is an important concept and clues that surface. View and sub-categories (eg TextView, Button) to draw on the surface. Each surface to create a Canvas object (but often attribute change), used to manage view on the surface of the drawing operation, the picturesque dotted line. Each canvas object corresponds to a bitmap, store content on the painted surface.

Surface usually corresponds to each of the two buffer, a front buffer, a back buffer. Which, back buffer is the canvas drawing corresponding bitmap (of android_view_Surface.cpp:: lockCanvas). Therefore, the painting is always in the back buffer, the need to update, will be back buffer and front buffer exchange.

The window is tied to a Surface and the ViewRoot asks the Surface for a
Canvas that is then used by the Views to draw onto. After View draw its data to canvas, ViewRoot
will call surface.unlockCanvasAndPost (canvas) to schedule surfaceFlinger:: composeSurfaces () which do the actually display to display panel. SurfaceFlinger handles to transfers drawn data in canvas to surface front buffer or backbuffer

Except for SurfaceViews, different views within the same ViewRoot share the same surface.

Layer concept:

 Each surface and corresponds to a  layer, SurfaceFlinger Responsible for the various layer  front buffer Synthesis  (composite) Drawn to the screen  .
A Layer is something that can be composited by SurfaceFlinger (should have been called LayerFlinger). There are several types of Layers if you look in the code, in particular the regular ones (Layer.cpp) , they are backed by a Surface, and the LayerBuffer (very badly chosen name) which don't have a backing store, but receive one from their client. . Note that the GGLSurface type, should have been called GGLBuffer

Multiple layers are just composited to the final buffer in  their Z order.

There are several closely related concepts of objects and Surface:
1. Java Surface (frameworks / base / core / java / android / view / Surface.java). Application of the indirect object is called (by SurfaceView, ViewRoot, etc.), applications need to create a surface, (and also create a canvas), drawing graphics to the object and finally delivered to the screen.
2. C + + Surface (frameworks / base / libs / ui / Surface.cpp. The object is Java Surface by Jni call the function to achieve Java Surface
3. ISurface (and its derived classes BnSurface). This object is the interface between application and server. C + + Surface to create this ISurface (BnSurface) and send commands, such as updating the content to the screen surface. Server-side to accept the command and the implementation of the action.

How to create a surface of the critical path is as follows:
1. Frameworks / base / core / java / android / view / Surface.java - Surface:: Surface ()
2. Frameworks / base / core / jni / android_view_Surface.cpp - Surface_init (). In this function SurfaceComposerClient object is created.
3. Frameworks / base / libs / ui / SurfaceComposerClient.cpp - SurfaceComposerClient:: SurfaceComposerClient (). This function is very important here to establish a bridge between the client and the server. By function _get_surface_manager () was a point of IBinder server object (with ISurfaceComposer interface), followed by the IBinder can access Server functions across the process. Then call ISurfaceComposer:: createConnection () Creates and returns a ISurfaceFlingerClient of IBinder.
4. Frameworks / base / libs / ui / SurfaceComposerClient.cpp - SurfaceComposerClient:: createSurface (). This function, use the previous obtained ISurfaceFlingerClient the IBinder, call its createSurface interfaces.
5.frameworks/base/libs/surfaceflinger/SurfaceFlinger.cpp - BClient:: createSurface (). BClient derived from the ISurfaceFlingerClient.
6. Frameworks / base / libs / surfaceflinger / SurfaceFlinger.cpp - SurfaceFlinger:: createSurface (). This function creates a corresponding Surface Layer.

The critical path, 1,2,3,4 process running on the client, while the 5,6-operation with the server process. server as a service to provide access to the client.

And graphics related code are mainly located in the following directory:
1, frameworks / base / graphics / java / android / graphics
2, frameworks / base / core / java / android / view
3, frameworks / base / core / java / android / widget
4, frameworks / base / opengl /
5, frameworks / base / libs / ui
6, frameworks / base / libs / surfaceflinger
7, frameworks / base / core / jni / android / graphics
8, frameworks / base / core / jni / android / opengl
9, frameworks / base / core / jni / android / android_view_ *. cpp
10, external / skia

1, the following directory part of the code:
1, frameworks / base / graphics / java / android / graphics
2, frameworks / base / core / java / android / view
3, frameworks / base / core / java / android / widget

android.graphics, android.view and android.widget features and other similar graphics library such as Qt / Gtk + similar to the provision of basic graphics were primitive (picturesque dotted line, set the graphics context, etc.), events, mechanisms, and the development of graphical user interface controls and so on. canvas for the development of 2D graphics, Surface behalf of a graphics system for rendering the surface. Can live in their draw 2D 3D graphics.

2. Frameworks / base / opengl /
This directory contains opengel of interfaces and software. In http://developer.android.com/guide/topics/graphics/opengl.html have details on how to use android.opengl develop 3d graphics.

3 .external / skia, Mr. Jserv Taiwan has a good introduction, interested readers can refer to his Bowen (http://blog.linux.org.tw/ ~ jserv/archives/002095.html). In short, skia and cairo functionally equivalent, the underlying graphics hardware package for the above graphics library to provide the most basic operation of graphics hardware primitives.

4. Frameworks / base / libs / ui and frameworks / base / libs / surfaceflinger
ISurface defined based Surface interface for graphics system client (application) and server-side (ie surfaceflinger) interactions.
BpSurface is ISurface derived classes, provide interfaces for the server call the client function;
BnSurface is ISurface another derived class, providing an interface for the client calls the server function. When the server received from the client (through BnSurace) call request, such as registerBuffers, postBuffer so, BnSurface:: onTransact be triggered.
Surface (LayerBaseClient private class) is BnSurface derived class.
SurfaceBuffer (SurfaceBuffer private class) is the Surface of the derived class.

ISurfaceComposer defined based interface for client and server side interaction.
BpSurfaceComposer is a derived class, providing an interface for the server call the client function;
BnSurfaceComposer is another derived class, providing an interface for the client calls the server function. Class SurfaceFlinger derived from the BnSurfaceComposer.

SurfaceComposerClient used directly for the client, call ISurface (BnSurface) and ISurfaceComposer (BnSurfaceComposer) and ISurfaceFlingerClient interface, and server interaction.

BClient derived from ISurfaceFlingerClient (BnSurfaceFlingerClient), call the server's createSurface, really create a surface. Each surface corresponds to a layer.

egl_native_window_t defines a local window class. This class provides all the description of the local window for egl (opengl graphics system with local interface) method of operation of all local windwo.
EGLNativeSurface is egl_native_window_t a derived class.
EGLDisplaySurface is EGLNativeSurface derived class. EGLDisplaySurface is a very important category in this class, the truly open framebuffer device (/ dev/graphics/fb0 or / dev/fb0), and the device in the form of packaged EGLDisplaySurface for server use. Function mapFrameBuffer open framebuffer, create two buffers (one is on screen front buffer and one back buffer, may be located offscreen framebuffer, may also be located in system memory). Function swapBuffers the back buffer copied to the front buffer of the content.

DisplayHardware class initialization of the egl system and for the local window object to create the corresponding EGLSurface EGLDisplaySurface object. surfaceflinger use DisplayHardware to deal with local window.

5, part of the code in the following directory
7, frameworks / base / core / jni / android / graphics
8, frameworks / base / core / jni / android / opengl
9, frameworks / base / core / jni / android / android_view_ *. cpp

The directory of the Java code level graphics components and native (c + +) interface between components, the java level function calls to switch to the corresponding local calls.

hardware / libhardware achieved HAL (Hardware Abstraction Layer) layer, copybit device is one of the module.

分类:Mobile 时间:2010-09-06 人气:261
blog comments powered by Disqus


  • Flex painting dotted line 2010-06-07

    Personal blog: Wolf Dreams --- love Ukraine and housing Today's project needs, need to draw dotted lines, see later about API, AS API is not related to its implementation so, check back a bit in the online information, the whole dotted line using the

  • IText painting dotted line problem 2010-07-26

    Recently in the output PDF file with IText, their first time to do, so do not know many things, especially the layout is very complex. Dotted line in the picture with IText a lot of time to go online to find information not found. Finally in java Tut

  • 2.4.2 Configuring the client / server architecture 2010-05-28

    Using ORACLE's SQL * Net V.2 to connect clients and servers, need to configure each client and server. The server configuration file required to have: listener.ora, / etc / services, the client must be configured tnsnames.ora file. 1. Configure liste

  • [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

  • Notes of the JAVA api using to send mail (code fragment) 2010-06-27

    Notes of the JAVA api using to send mail (code fragment) Recently the use Notes to write a program to send mail automatically to study the `` day finally OK to share with you the code here import lotus.domino.AgentBase; import lotus.domino.NotesExcep

  • Use Google Chart API to quickly create QR Code (two-dimensional code) 2011-03-25

    With the rapid development of intelligent hand, QR code (two-dimensional code) applications on mobile phones more and more, the use of camera phones, smart phones with two-dimensional code recognition software (recommended QR Droid), can be easily tw

  • High-performance server architecture of Key Points 2010-11-11

    High-Performance Server Architecture High-performance server architecture Source: http://pl.atyp.us/content/tech/servers.html Mr Source: http://www.lupaworld.com/home/space-341888-do-blog-id-136718.html Introduction This article will share with you m

  • Game server architecture 2010-12-22

    There was a time not of technology, this time just to see a new version of mangos, compared to earlier versions of me have a relatively large improvement, then again the next visit of his code, I also take this opportunity to organize the next server

  • Based on the electronic map system shows GeoServer GeoServer based description of the electronic map system 2011-07-05

    Based on the electronic map system shows GeoServer GeoServer based description of the electronic map system April 20, 2010 Comments 1,818 people visit the comments outlined in an AJAX application, the front page based on OpenLayers2.2 version to deve

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.466 (s). 10 q(s)