Android performance optimization Google course 1: Render, androidrender

Source: Internet
Author: User

Android performance optimization Google course 1: Render, androidrender
Context:

I write down Google's translation of the Video Course on Android performance optimization by myself, hoping that the Uploader will not delete my blog address http://blog.csdn.net/zhjali123

Terms:

1. texture and meshes. For example, to create an airplane model, you need to first create a three-dimensional airplane model (mesh), but the model has not been colored. You need to wrap it with sheets of paper, draw camouflage on the top, and the layer of camouflage paper is (texture, Chinese is called texture ).


Lesson1: Render (rendering)

1. Android devices usually update the Activity in 16 ms, depending on the mobile phone hardware. This means that you have to process all your painting logic within 16 Ms. If you miss this 16 ms, the page will not be drawn. This is called dropped frame. However, the animation operation does not stop, so what is presented to the user is a jump in smoothness. This is called the laggy or janky experience.

2. The rendering channel for Android is divided into two key areas: CPU and GPU.

CPU (measure measurement --> layout ---> record records ---> execute execution) ----> GPU (rasterization grating: calculate the value of each pixel)

CPU problems: Unnecessary layout, meaningless computing, splitting (torn down), and rebuilt in View Hierachy)

How XML is converted to screen display:

XML ---- conversion ----> Screen, core step: rasterization grating (). Rasterization is very resource-consuming, so a separate Image Processing Unit GPU was introduced in the 1990s S. GPU uses some specified basic instruction sets (set of primitive: polygons polygon, textures arts, and images), while the CPU is drawing something to the screen, these commands (a set of primitive) are input to the GPU ). The API used in this process is Android OpenGL ES.

This means that if you draw a button, it will first convert it into a polygons polygon, a texture (computer graphics) An image applied to a polygon to create the appearance of a surface in the CPU: the image is added to a polygon to create the appearance of the object.) ------------ the image is delivered to the GPU for rasterization.

There are two time-consuming operations:

1. Convert the button and other things into the corresponding shape (polygons) in the CPU, and draw its surface (texture)

2. the CPU transfers data to the GPU

Corresponding Measures:

You need to reduce the number of items drawn by the CPU and the amount of data uploaded by the CPU to the GPU, while OpenGL ES provides APIs for uploading and storing data to the GPU. So the next time you draw a button, you just need to reference it in the GPU (that is, completing polygons and texture in the GPU) and tell OpenGL how to draw it. An example of experience is: optimizing rendering performance means uploading data to the GPU as quickly as possible and retaining data as long as possible on the GPU.

From the HoneyComb version, the rendering of the entire View is in the GPU and constantly optimized, so you don't need to worry about this. For example, any resources provided by your theme, such as Bitmaps and Drawables, are integrated into a separate texture (the feeling is what theme means, then upload the file to the GPU using meshes, as shown in figure 9. In this way, every time you need to draw these resources, you don't need to perform any conversions. They are already stored in the GPU.

However, as the UI is more advanced, the rendering process is more complex. For example, to draw an image, this means to upload the Image to the CPU and then to the GPU. Using the Path is completely different. You need to create a series of polygons polygon in the CPU, or even create a masking texture (mask texture) in the GPU to define the path. To draw characters, you must first upload image --- to GPU --- in the CPU to draw the square of characters in each string on the screen, which are processed by the Android system. This problem exists in OverDraw, a gpu problem that programmers will encounter)

OverDraw: the number of times that pixels are re-drawn in a single Frame. For example, the UI card has a layer VIew on it, and most of the views are below it. This means that most of the time-consuming plotting is invisible.

View OverDraw: Enter the mobile phone developer mode and enable the show GPU overdraw switch. Purple (probably): one painting; two green painting; three pink painting; four red painting (2)

How to solve OverDraw in the next blog


Continue to translate this evening!


Related Article

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.