Based on shallow, the Google Skia graphics processor engine and the Skia Demo Build. Skia is a cross-platform graphics library that is currently used in Android , there are also PC version, test it here to understand its meaning.
1.PC version test:
# 1. Download Skia
git clone [email protected]: Google/skia.git
# 2. Switch to the old version reference Ubuntu transplant Skia date for fallback
git reset--hard 0e2810be95d3f1aa95c341521d3f514eb9e9ebde
# 3. View compilation Help
$ make Help
Targets:
<default>: out/libskia.a
Bench:out/bench/bench
Gm:out/gm/gm
Skimage:out/tools/skimage
Skhello:out/tools/skhello
Tests:out/tests/tests
Clean:removes entire Out/directory
Help:this text
Options: (After make, or in bash shell)
Skia_debug=true for DEBUG Build
Skia_scalar=fixed for fixed-point Build
Skia_build_for=mac for Mac BUILD (e.g. CG for image decoding)
Skia_pdf_support=false to disable the PDF generation backend
# 3. Compiling
$ make Skia_build_for=linux
# 4. Save the example of the Skia Demo Build to TEST-SKIA.C.
# 5. Compiling the test program
$ g++ \
-i./include \
-i./include/core \
-i./include/images \
-i./include/config \
-wall-o Test-skia test-skia.c \
OUT/SRC/IMAGES/SKIMAGEDECODER_LIBPNG.O out/libskia.a \
-lpng-lpthread-lfreetype-g
# Run
$./test-skia
# View Test Results
$ EOG Snapshot.png
A picture is displayed as follows:
Test procedure:
/* Simple vector Graphics demo utilizing Skia toolkit.
* Authored by Jim Huang <[email protected]>
*/
#include "SkBitmap.h"
#include "SkDevice.h"
#include "SkPaint.h"
#include "SkRect.h"
#include "SkImageEncoder.h"
int main ()
{
Declare a raster bitmap, which have an integer width and height,
and a format (config), and a pointer to the actual pixels.
Bitmaps can drawn into a skcanvas, but they is also used to
Specify the target of a Skcanvas ' drawing operations.
Skbitmap bitmap;
Bitmap.setconfig (Skbitmap::kargb_8888_config, 200, 200);
Bitmap.allocpixels ();
A Canvas encapsulates all of the State about drawing into a
Device (bitmap). This includes a reference to the device itself,
and a stack of matrix/clip values. For any given draw call (e.g.
DrawRect), the geometry of the object being drawn is transformed
By the concatenation of the matrices in the stack. The
Transformed geometry is clipped by the intersection of the
Clips in the stack.
Skcanvas canvas (bitmap);
Skpaint class holds the style and color information about
Draw geometries, text and bitmaps.
Skpaint paint;
Skirect holds four the bit integer coordinates for a rectangle.
Skrect R;
Paint.setargb (255, 255, 0, 0);
R.set (25, 25, 145, 145);
Canvas.drawrect (R, Paint); /** Draw the specified rectangle using
The specified paint. The rectangle
would be filled or stroked based on
The Style in the paint. */
Paint.setargb (255, 0, 255, 0);
R.offset (20, 20);
Canvas.drawrect (R, Paint);
Paint.setargb (255, 0, 0, 255);
R.offset (20, 20);
Canvas.drawrect (R, Paint);
Skimageencoder is the base class for encoding compressed images
From a specific skbitmap.
Skimageencoder::encodefile ("Snapshot.png", Bitmap,
Skimageencoder::kpng_type,
/* Quality ranges from 0..100 */100);
return 0;
}
2. testing in Android
Wrote a android.mk content as follows:
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module_tags: = Optional
Local_module: = Skia_test2
#Can ' t use ' local_src_files: = $ (call all-subdir-cpp-files) '
Local_src_files: = Skia_test2.cpp
Local_c_includes: = \
External/skia/include/core/\
external/skia/include/images/
Local_shared_libraries: = \
Libskia
Include $ (build_executable)
The test source on your PC can be compiled intact to test programs for Android . Place it in the /system/bin directory. Execute as follows:
$ CD SDcard
$ skia_test2
Will also generate snapshot.pngin the /sdcard directory, and upload it to the PC to see the same results as before. freetype and framebufferwill be added later. The result is an Android -based system that allows simple graphical font display.