First of all, as a programmer ape who has been lazy for several years and has not written blog articles, I have the face to come back and write blogs. Well, if you don't say much, I will update it regularly in the future. I hope you will support me a lot.
1. What is SKIA?
Skia is a cross-platform 2D vector graphics engine, which was originally a commercial project. After being acquired by Google in 2005, Skia was used in many famous Google projects such as Android, Chrome and so on. After a year of silence, Google made this mysterious code public in early 2007. If you are interested in learning more about Skia, you can find out more about Skia's official website: https://skia.org./
2. What can SKIA do?
Skia, like the famous airo, is a well-known graphics engine, but the difference is that Skia is a vector graphics engine, Cairo is a vector graphics engine, the former is the main graphics engine of Android, and the latter is the main graphics engine of Linux. Skia is deeply opened by its refreshing code style, concise API design, efficient drawing mechanism and relatively simple structure design. Hairdresser's favorite. Skia's main functions include: Drawing: points, lines, paths, triangles, rectangles, polygons, irregular polygons, etc. Image decoding: including PNG, JPG, JPEG, BMP, GIF, SVG and other formats support. PDF operation: PDF generation, text to PDF. Hardware Acceleration: Skia integrates OpenGL, Vulkan and other three-dimensional graphics APIs, so it can use hardware acceleration and three-dimensional graphics drawing on related devices supporting these APIs. Because Skia's interface design is very friendly, it will make it easier for you to use the relevant API interface. Well, of course, there are many other things I don't know. There aren't many BB s here. Let's get right to the point.
3.SKIA Source Download
Because of the domestic situation, I think you can only afford to give up a lot of time, but don't worry, as programmers, we have some ways. If you can't find a ladder, or you can't do it (as of February 12, 2018):
git clone https://github.com/1934016928/skia_full.git
The above synchronized source code is picked up by me from the Far West (funny) and can be compiled directly (PS: If you use the source code provided by me, please ignore the following download steps. The source code includes depot_tools, Skia source code, coding dependencies, etc.).
First, you need a Linux computer with access to googlesource.com (here Ubuntu is an example). You can also complete the following steps from the Ubuntu server and then down load to the local computer for follow-up work.
1. Download the depot_tools Toolkit
git clone 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'
2. Setting environment variables for the depot_tools Toolkit
## ${depot_tools} is the path to the toolkit downloaded in the first step
## For example, mine:
## export PATH=$PATH:/home/var_rain/files/depot_tools
export PATH=$PATH:${depot_tools}
3. Synchronized SKIA source code
git clone 'https://skia.googlesource.com/skia.git'
4. Synchronized compilation dependencies
cd skia
## Note that this step may depend partly on the failure of the first download and wait until the other downloads are completed to try again.
python tools/git-sync-deps
Okay, here's the source code for SKIA, and then... the exciting compilation time...
4. Compiling under Ubuntu
1. First, go to Ska's source directory
var_rain@root:~$cd skia
var_rain@root:~/skia$
2. Execute different build configuration commands as needed
## If the bin/gn command is not found at the prompt:
## 1. Check that there is a folder pointer named depot_tools in the environment variable
## 2. Check whether depot_tools are empty
## 3. Nothing? Start reading this blog from the beginning.
## Configure static library
bin/gn gen out/Static --args='is_official_build=true'
## Configure dynamic library
bin/gn gen out/Shared --args='is_official_build=true is_component_build=true'
## Configure Debug Debug Debug Debug
bin/gn gen out/Debug
## Configure Release version
bin/gn gen out/Release --args='is_debug=false'
Generally speaking, Skia has a lot of libraries. If it is not mandatory to use it, it will be found in the system at compilation time. If it is not found, it will report an error. So, I changed the configuration of the build.
## Configure static library
bin/gn gen out/Static --args='is_official_build=true skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_icu=false skia_use_system_jsoncpp=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_lua=false skia_use_system_zlib=false'
## Configure dynamic library
bin/gn gen out/Shared --args='is_official_build=true is_component_build=true skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_icu=false skia_use_system_jsoncpp=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_lua=false skia_use_system_zlib=false'
## Configure Debug Debug Debug Debug
bin/gn gen out/Debug --args='skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_icu=false skia_use_system_jsoncpp=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_lua=false skia_use_system_zlib=false'
## Configure Release version
## Compilation fails because Release compiles with a return value.
## So here in extra_cflags_cc Add compile ignore parameters-Wno-unused-result
bin/gn gen out/Release --args='is_debug=false skia_use_system_expat=false skia_use_system_freetype2=false skia_use_system_icu=false skia_use_system_jsoncpp=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_lua=false skia_use_system_zlib=false extra_cflags_cc=["-Wno-unused-result"]'
3. Start compiling
## Compile according to your build configuration
## Compile static library
ninja -C out/Static
## Compile dynamic library
ninja -C out/Shared
## Compile Debug version
ninja -C out/Debug
## Compile Release version
ninja -C out/Release
Once compiled, an out directory will be generated in the current directory. The folder inside corresponds to your build configuration.
5. appendix
1. How to use the source code I provided
(1) Synchronize the source code I provided (about 900M after all synchronization)
## Because all the packages are compressed, the speed will be slower. Please wait patiently.
git clone https://github.com/1934016928/skia_full.git
(2) Merge files (subcontracted upload due to Github but maximum file support of 100M)
## Go to the directory you just synchronized, and then execute the following commands
cat skia_source.tar.gz* > skia.tar.gz
## Of course, after the merge is completed, you can also choose to delete the subpackage, leaving only one merged package to save space.
# rm -rf skia_source.tar.gz*
(3) Unzip files
## Unzip to the current directory
tar -zxvf skia.tar.gz
(4) Follow-up steps
After decompression, there will be a file folder, which contains depot_tools and skia folders. Please add depot_tools to the environment variable first and then proceed to the next step. PS: When this step is completed, please follow the second section of paragraph 4 as follows.