Android internals 07 - Android graphics (rev_1.1)

Post on 10-May-2015

10.174 views 14 download

Tags:

description

Course: Android Internals Lecture 7: Android Graphics

Transcript of Android internals 07 - Android graphics (rev_1.1)

Android internalsEgor ElizarovSPbSU 2012

Egor Elizarov SPbSU 20122

Legal info

Android internals by Egor Elizarov is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License

You are free to – copy, distribute, display, and perform the work

– make derivative works Under the following conditions

– Attribution. You must give the original author credit

– Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one

All pictures and trademarks are the property of their respective owners. Use of these trademarks and pictures is subject to owners permissions.

Corrections, suggestions, contributions and translations are welcome!

Egor Elizarov SPbSU 20123

Lecture 7

Graphic Subsystem

OpenGL HW acceleration

yegor.yelizarov(at)gmail.com

http://vk.com/android_internalsRev: 1.1Last update: 06/01/2012

Egor Elizarov SPbSU 20124

Previous time

Linux IPC primitives

Binder

Application layer

Service manager

Middleware level

Kernel level

Typical Android sybsystem

Egor Elizarov SPbSU 20125

Graphic subsystem

Provides buffer to application for drawing

Provides interfaces for draw primitives

Controls and composes surfaces (windows)

Provides 2D & 3D primitives

Uses HW acceleration where acceptable

Egor Elizarov SPbSU 20126

Main players

Surface Flinger

Window Manager

Activity Manager

Egor Elizarov SPbSU 20127

Surface

Virtual buffer we can draw on

Can be marshalled/unmarlled in Parcel

One Activity can have more then one Surface

Egor Elizarov SPbSU 20128

Surface Flinger

Allocates surfaces

Composes surfaces

Can combines 2D/3D surfaces

Can use HW acceleration for surface composition

Egor Elizarov SPbSU 20129

Window Manager

Dispatches input events to clients

Provides transition animation capabilities

Window Manager Policy handles common key events in PhoneWindowManager (Home/Back/Volume)

Egor Elizarov SPbSU 201210

Activity manager

Manages activity life cycle

Manages activity stacking

Dispatches intents

Spawn processes

Egor Elizarov SPbSU 201211

Composition example

Egor Elizarov SPbSU 201212

Simple view

Egor Elizarov SPbSU 201213

Khronos OpenGL API

Khronos Group - not for profit industry consortium creating open standards.

OpenGL – 2D/3D graphics API

OpenGLES – 2D/3D graphics API for embedded systems

EGL – interface between OpenGLES and native platform window system

Egor Elizarov SPbSU 201214

Graphic libraries

SKIA - 2D graphic library

PixelFlinger – android software renderer

Codeflinger – simple graphic JIT

Gralloc – android graphics memory allocator

Mesa – open source OpenGL implementation

Egor Elizarov SPbSU 201215

Renderscript

Renderscript is new API targeted at high-performance 3D rendering and compute operations.

Renderscript provides:

• 3D rendering API on top of HW acceleration

• compute API (similar to CUDA)

• familiar language in C99

Egor Elizarov SPbSU 201216

Java/middleware interaction

Egor Elizarov SPbSU 201217

Double buffering

Egor Elizarov SPbSU 201218

Composition approach

Dirty regions – regions that should be redrawn

Use Z ordering to compose layers

Use HW composer to compose layers if possible

frameworks/base/services/surfaceflinger/SurfaceFlinger.cpp

Egor Elizarov SPbSU 201219

SW vs HW OpenGL

Egor Elizarov SPbSU 201220

Middleware level

Egor Elizarov SPbSU 201221

3D acceleration

Egor Elizarov SPbSU 201222

2D acceleration

Egor Elizarov SPbSU 201223

HAL/kernel interaction

Egor Elizarov SPbSU 201224

Overlay vs Framebuffer surface

Two different type of surfaces in Android < 3.0

Overlay – Picture in YUV format (Video, Camera)– Video4Linux devices (/dev/video*)

Framebuffer surfaces –Picture in RGB format–Framebuffer device (/dev/fb*)

Composition is performed by HW

Egor Elizarov SPbSU 201225

HWComposer (Omap4)

Egor Elizarov SPbSU 201226

Emulator GL acceleration

In ICS Android team added GL acceleration for Emulator

Emulator uses x86 host GL acceleration relying on host hardware accelerated libraries

Egor Elizarov SPbSU 201227

Android-emulator approach

Egor Elizarov SPbSU 201228

Android-x86 approach

Egor Elizarov SPbSU 201229

Next Time

System start up

Media subsystem

Egor Elizarov SPbSU 201230

Useful links

http://vk.com/android_internals

http://www.slideshare.net/jserv/design-and-concepts-of-android-graphics

http://people.debian.org.tw/~olv/surfaceflinger/surfaceflinger.pdf

http://www.cnblogs.com/xl19862005/archive/2011/11/17/2215363.html

Http://www.khronos.org

https://plus.google.com/105051985738280261832/posts/2FXDCz8x93s

Egor Elizarov SPbSU 201231

Useful links (2)

http://www.ti.com/lit/wp/swpy027/swpy027.pdf

http://www.freescale.com/files/ftf_2010/Americas/FTF10_FTF-ENT-F0824.pdf

http://elinux.org/images/0/02/Android_Platform_Optimizations_SNPS_20111027.pdf

http://android-developers.blogspot.com/2011/02/introducing-renderscript.html

http://android-developers.blogspot.com/2011/03/renderscript.html

Egor Elizarov SPbSU 201232

Thanks to

Sergey Matyukevich for review and advices (www.linkedin.com/pub/sergey-matyukevich/31/889/769)

Nikolay F. Fominykh for review and advices

Nikita Shulga for advices and notes (http://www.linkedin.com/pub/nikita-shulga/8/582/287)

Grigory Tolstolytkin for advices and notes (http://www.linkedin.com/pub/grigory-tolstolytkin/2a/b41/74)