Experience of porting the Android graphics engine Skia to the MIPS platform (2)

Source: Internet
Author: User
Tags skia

In the previous article, I have already introduced the various conditions for porting Skia and the basic configuration of the environment. This article will introduce the specific steps for porting Skia. My
There is no IDE development environment on the MIPS platform, and the porting work is done under the command line. Makefile files must be provided. Because Skia is well modularized, my code organization divides Skia into sub-modules and then provides separate makefile files for each sub-module, finally, the Makefile of these sub-modules is summarized into
In Makefile, It is the makefile of the Skia library.
To port the Core module, you must first confirm the files to be compiled. For more information, see
The. mk file of the Core module of the Skia library in Android code and the makefile file of the core module in the latest Skia code. The cpp text searched under the Basic src/core directory must be compiled. If the first three configuration files are correct, this module is easier to compile. There may be some minor differences between different platforms. We need to cut down the source files in the core. For example, our MIPS platform does not have a file system, so we need to remove the Code related to the file system, for example
SkFileStream and SkMMapStream. Generally, after this module is transplanted, the basic functions of Skia can be achieved, such as drawing in the memory. Here you can verify your porting result (it is an encouragement to us to see the result), because the drawing is in the memory, you can use the memory data, and output it to any device, for example, to the Bitmap file (provided that you are familiar with the bitmap file structure ), the test code is not provided here (my test code is in the unit, and the code control is strict. I cannot get it out, so I am depressed ).


Port the opt module to accelerate performance. No accelerated code for MIPS is found in the code. You can only select SkBitmapProcState_opts_none.cpp, SkBlitRow_opts_none.cpp, and SkUtils_opts_none.cpp.
Three files, that is, no acceleration, you can select acceleration files based on your platform or implement acceleration files by yourself (if you implement acceleration files, please contact me, I learned from you ). This module is relatively simple and there is no problem with compilation.


Below we can transplant the ports module, which provides Code related to the operating system, because the fonts, threads, events, and time on each OS are different. You need to select the code suitable for your platform and compile it. If your platform has some special features, you may need to make some reductions on your own. For example, the font. Our platform does not provide a file system. All platform implementations in the Skia Source Code require a file system (font file). What should we do? You can only implement it by yourself. First, burn the font file into the ROM, and then load it into the RAM memory during system initialization (it may take about 10 MB for a Chinese font file, embedded devices need to measure the RAM memory size), and then modify the Linux-based
The font implements SkFontHost_linux.cpp, Port all the Code related to the file system, and then implement it in the memory mode. If you find that there is no proper implementation, you can also choose
Implementation files at the end of none. These files all implement empty functions, so that you can compile them. If necessary, try again.

The utils module implements some tool classes. This module is relatively small. Refer to the. mk file in Android and the makefile in the official code. This module is easier to transplant.

The effects module is transplanted below. This module implements some effects. There is no special way to add all the source code files to Makefile for compilation. This is a good solution.

The images module mainly implements image-related functions, such as inputting data from image files to the Skia library or outputting data from Skia to image files. This module requires some external libraries for support. For example, if you need to support png, you need to add SkImageDecoder_libpng.cpp to the makefiel file, which depends on the libpng library, you need to first port it to your platform. This library is in the Android source code, and libpng depends on libz. You should be able to compile these files and your Skia supports png files. Similarly, to support gif and jpg files, you need to transplant the corresponding libraries. It can be said that there has been a staged result after porting it here. You can use online testing programs to verify it, such as the Code in Mr Jserv's blog.

If you need the opengl library for 3D (2D is implemented by Skia) acceleration, You need to transplant the gl module, the premise is that your platform provides opengl implementation (soft implementation or hard implementation ). Because my platform does not have
Opengl, so this module is not transplanted.

Other modules are optional. You can port them if needed. Although Skia provides the animator module, Skia does not use this sub-module and may not be complete yet. If you use it, you need to maintain it yourself. The views module provides some window classes independent of OS, which are not required currently due to our limited platform performance.


So far, the Skia library has been successfully transplanted. It can be seen from the above description that as long as you are familiar with your platform features and master the correct methods, it is easier to transplant Skia one step at a time.

 

From http://my.unix-center.net /~ Simon_fu /? P = 305

 

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.