Design Experience of the copybit Android module-reprinted

Source: Internet
Author: User

First, let's review the copybit interface functions. Although simple, there are many functions.


The copybit module mainly uses the following hardware acceleration functions:
Bitbits
Stretch
Rotate
Alpha blending
Color transform

1. Implementation of bit bits and stretch
Strctch is not implemented in particular, because all coordinate data is transmitted from the android surface and OpenGL ES layers. It mainly implements bit bits, that is, block copy.
The upper layer of Android is surfaceflinger, which maintains several important graphic buffers.
These graphic buffers are the pmem space applied through the gralloc module. Therefore, you can obtain the physical address and provide it to the 2D Acceleration Engine.
Why is there only a few buffers? I estimate that the X screen only needs 10 MB of pmem space. If the data is continuously transmitted to the LCD, it is definitely not enough.
Therefore, Android adopts a partial update policy, which only updates the screen and needs to be changed. This is suitable for 2D engines, because the engine can only fl changed data to the screen.
The upper layer of copybit will pass two parameters, one is the total size of the current buffer (screen), such as 800x480, and the other is the size of the window to be updated (X, Y, W, h ).
Note that before providing the data to the bits engine of cloud6410, You need to distinguish the data of SRC and DST (FB or pmem). If the data is FB, pass the FB base address, otherwise, the pmem physical address is passed.

2. Implement rotate
Rotate is simple. The upper layer of the coordinate data is basically ready. You can use set_rects of the MSM module to refresh the rectangle and configure the rotation mode of the 2D engine.

3. alpha blending implementation
There are two alpha modes: full screen Alpha and Android rgba data for Alpha rendering.

The first method is relatively simple. If the full screen Alpha value is found, configure the AMB register to refresh the full screen Alpha and fill in the Alpha data. However, because the Samsung 0 value is 0x0, however, the upper layer is 0xff, so the down-to-Down conversion is required. However, there are few full-screen Alpha opportunities, which cannot be seen.

The second is that the rgba8888 data contains an Alpha value, which is usually reflected on the interface.
The android interface is basically pasted with two layers of images, one layer is the background image (rgb565), and the other layer is the icon (rgba8888 ).
At first, no matter how I configure it, the screen background is black. After a long time, I found that the AMB Register needs to be configured in Alpha with bitmap mode, but this register is not written in the driver.

4. color format transform
Color format conversion, because the screen is rgb565, If you brush rgba8888 data, you must convert the color format, this 2D engine is certainly supported.
However, when I started to configure rgba8888 to rgb565, I found that the screen was red?
After debugging for a long time, it was found that the rgba8888 of Google Android was in the ascending order of the dashboard, that is, the abgr8888 of the corresponding arm. Samsung does not seem to support this color.
Manually configure the color conversion to argb8888, and find that white is normal, green and blue are reversed, so I wrote a soft color format function:
Daddr [I] = (saddr [I]) & 0xff00ff00) | (saddr [I]) & 0xff) <16) | (saddr [I]) & 0xff0000)> 16 );
As a result, this function reduces the interface effect and I used another pmem for this conversion.
Yesterday I checked the kernel driver of Samsung android1.5.CodeIt was found that the address (0x350) not found in a data manual was OMG.
I searched the internet and some header files were excited to mark the Indian sequence conversion register. In this way, the abgr color format is supported and no software conversion is required!
After I tried it, it turned out to be helpful and smooth. Samsung, you did leave a hand. Maybe the data manual I read is too old.

5. cache consistency
Because the upper layer of the memory allocated by pmem should also be used. If the memory cannot be cached, the performance will be compromised.
However, 6410 of the cache is write back, that is, it is not updated in the memory synchronously.
This will cause some small color errors on the screen if the image cache data is cached.
The current solution is to flush the cache before starting the 2D engine. I don't know if I can configure the cache as wirte through. Which performance loss is small?

Rockie Cheng

The last is the latest test video screen of the copybit module, which is really smooth.

 

This article from http://hi.baidu.com/aokikyon/blog/item/75cd002a680efb345343c199.html

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.