How to Use GPU hardware acceleration in android2.3

Source: Internet
Author: User
Tags custom name skia

Http://blog.csdn.net/fengkehuan/article/details/6395730

 

1.Glossary

GPU: Graphic Processing Unit (graphics processor)

OpenGL: Open Graphic Library defines the specification of a cross-programming language and cross-platform programming interface. Different vendors have different implementation methods. It is mainly used for 3D image (two-dimensional) painting.

Surfaceflinger:Dynamic library in Android that is responsible for surface overlay and hybrid operations

Skia:2d graphics library in Android

Libagl:A set of OpenGL dynamic libraries implemented by software in Android

Libhgl:A custom name for distinguishing libagl. OpenGL for hardware implementation provided by GPU Manufacturers

Composition:Surfaceflinger overlay and mix each surface.

Render:3D rendering using OpenGL dynamic library

Copybit: Android uses a 2D engine to accelerate graphic operations (mainly the composition operation between surfaces), corresponding to one or more dynamic libraries.

Pmem:Android-specific drivers: Reserve physical continuous memory from the Linux kernel and allocate physical continuous memory to devices such as 2D, 3D engine, and VPU.

23D,2dEngine inAndroidUsage in

2.1 androidHow to Use2d,3DEngine

After Android is started, it loads the implementation of OpenGL (libagl & libhgl) according to the configuration file at runtime. If libhgl is implemented, the implementation of libhgl is used by default. Otherwise, the implementation of libagl is used.

 

Android OpenGL dynamic library usage:

1. Determine whether the EGL. cfg file is contained. If the libagl file is not loaded

2. If the EGL. cfg file exists, parse The egl. cfg file and load the corresponding libhgl and libagl according To The egl. cfg file.

3. parse libagl and libhgl respectively to obtain the function address (function pointer) of standard OpenGL functions in libagl and libhgl)

4. During execution, the system calls libagl or libhgl through the function pointer to draw the image.

 

OpenGL plays two roles in Android:

1.Used for surface composition operations.

Surfaceflinger calls OpenGL and uses libagl or libhgl to combine and overlay the surface.

2.Used for rendering graphics and Images

The android framework encapsulates the OpenGL implementation in a simple Java hierarchy, and CALLS OpenGL in Java applications will eventually be called to libagl or libhgl.

Many third-party games, 3D image libraries, and some launcher will use OpenGL to implement more dazzling UI effects.

 

The role of copybit in Android

Copybit is mainly used for surface composition operations in Android.

 

 

Role of skia in Android

Skia is a 2D image library for Android. It is used to draw text, geometric images, and images.

Skia device backend: raster, OpenGL, PDF

 

Does skia Support Hardware acceleration?(This is an official explanation. I only translate .)

Reference http://code.google.com/p/skia/wiki/FAQ

1. skia subclass skcanvas

Since all plotting operations are performed using the skcanvas subclass, these plotting can be redirected to different graphic APIs. Skglcanvas can direct plotting operations to OpenGL calls. Refer to the src/GL directory

2. Custom calls with bottlenecks

Some BIA operations in skia have bottlenecks. You can use some CPU features to rewrite these operations. For example, you can use the neon SIMD command on the armv7 device for optimization. See src/opts directory

 

2.2UseGPUWhat hardware acceleration requires

1.LinuxKernel:

1.1 add GPU driver support, compile the GPU driver as a module, and load the kernel module when Android starts.

1.2 added pmem support and reserved memory for GPU

2.AndroidAspect:

2.1 Add copybit hal

We use copybit to call 2D engine for hardware acceleration of surface composition. This may lead to a larger Performance Improvement (compared to using 3D engines ).

2.2 modify gralloc

Gralloc is responsible for the distribution of video memory and other operations on framebuffer. If copybit is used, you must modify gralloc.

2.3 modify libagl

If copybit is used, you must modify libagl and perform some hack on libagl so that it can be called to copybit.

2.4 modify surfaceflinger

Some modifications may be required if copybit is used.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.