blob: ed701792dd6ded8ad794422ffad86ec095a3271a [file] [log] [blame] [view]
jcgregorio942262f2015-01-05 11:17:27 -08001Tips & FAQ
2==========
3
halcanaryb5002392015-11-16 07:37:23 -08004<span id="gypdefines"></span>
5
6Gyp Options
7-----------
8
9When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can
10be used to change Skias compile-time settings, using a
11space-separated list of key=value pairs. For example, to disable both
12the Skia GPU backend and PDF backends, run it as follows:
13
14<!--?prettify lang=sh?-->
15
16 GYP_DEFINES='skia_gpu=0 skia_pdf=0' python bin/sync-and-gyp
17 ninja -C out/Debug
18
19Note: Setting enviroment variables in the Windows CMD.EXE shell [uses a
20different syntax](/user/quick/windows#env).
21
22You can also set environment variables such as `CC`, `CXX`,
23`CFLAGS`, or `CPPFLAGS` to control how Skia is compiled. For
24example:
25
26<!--?prettify lang=sh?-->
27
28 CC='clang' CXX='clang++' python bin/sync-and-gyp
29 ninja -C out/Debug
30
31The `GYP_GENERATORS` environment variable can be used to set the
32build systems that you want to use (as a comma-separated list).
33The default is `'ninja,msvs-ninja'` on Windows, `'ninja,xcode'` on
34Mac OS X, and just `'ninja'` on Linux. For example, to generate
35only Ninja files on Mac:
36
37<!--?prettify lang=sh?-->
38
39 GYP_GENERATORS='ninja' python bin/sync-and-gyp
40 ninja -C out/Debug
41
42Finally, the `SKIA_OUT` environment variable can be used to set
43the path for the build directory. The default is `out` inside the
44top-level Skia source directory. For example to test Skia with
45two different compilers:
46
47<!--?prettify lang=sh?-->
48
49 CC='clang' CXX='clang++' SKIA_OUT=~/build/skia_clang python bin/sync-and-gyp
50 CC='gcc' CXX='g++' SKIA_OUT=~/build/skia_gcc python bin/sync-and-gyp
51 ninja -C ~/build/skia_clang/Debug
52 ninja -C ~/build/skia_gcc/Debug
53
54* * *
jcgregorio942262f2015-01-05 11:17:27 -080055
halcanary8d3f7bd2015-07-09 06:58:06 -070056<span id="bitmap-subsetting"></span>
57
halcanaryb5002392015-11-16 07:37:23 -080058Bitmap Subsetting
59-----------------
jcgregorio942262f2015-01-05 11:17:27 -080060
61Taking a subset of a bitmap is effectively free - no pixels are copied or
62memory is allocated. This allows Skia to offer an API that typically operates
63on entire bitmaps; clients who want to operate on a subset of a bitmap can use
64the following pattern, here being used to magnify a portion of an image with
65drawBitmapNine():
66
67 SkBitmap subset;
68 bitmap.extractSubset(&subset, rect);
69 canvas->drawBitmapNine(subset, ...);
70
halcanary8d3f7bd2015-07-09 06:58:06 -070071* * *
72
73<span id="skp-capture"></span>
74
halcanaryb5002392015-11-16 07:37:23 -080075Capture a `.skp` file on a web page in Chromium
76-----------------------------------------------
halcanary8d3f7bd2015-07-09 06:58:06 -070077
halcanary5f0b0ad2015-07-08 10:56:01 -0700781. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking`
792. Open the JS console (ctrl-shift-J)
803. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')`
81 This returns "undefined" on success.
82
halcanary8d3f7bd2015-07-09 06:58:06 -070083Open the resulting file in the Skia Debugger, rasterize it with `dm`,
84or use Skia's `SampleApp` to view it:
85
86<!--?prettify lang=sh?-->
halcanary5f0b0ad2015-07-08 10:56:01 -070087
88 bin/sync-and-gyp
halcanary8d3f7bd2015-07-09 06:58:06 -070089 ninja -C out/Release debugger dm SampleApp
halcanary5f0b0ad2015-07-08 10:56:01 -070090 out/Release/debugger /tmp/layer_0.skp &
91
halcanary5f0b0ad2015-07-08 10:56:01 -070092 out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \
93 --config 8888 gpu pdf --verbose
94 ls -l /tmp/*/skp/layer_0.skp.*
95
halcanary8d3f7bd2015-07-09 06:58:06 -070096 out/Release/SampleApp --picture /tmp/layer_0.skp
halcanary8d3f7bd2015-07-09 06:58:06 -070097
98* * *
99
halcanary8d3f7bd2015-07-09 06:58:06 -0700100<span id="hw-acceleration"></span>
jcgregorio942262f2015-01-05 11:17:27 -0800101
halcanaryb5002392015-11-16 07:37:23 -0800102How to add hardware acceleration in Skia
103----------------------------------------
jcgregorio942262f2015-01-05 11:17:27 -0800104
halcanaryb5002392015-11-16 07:37:23 -0800105There are two ways Skia takes advantage of specific hardware.
jcgregorio942262f2015-01-05 11:17:27 -0800106
halcanaryb5002392015-11-16 07:37:23 -08001071. Subclass SkCanvas
jcgregorio942262f2015-01-05 11:17:27 -0800108
halcanaryb5002392015-11-16 07:37:23 -0800109 Since all drawing calls go through SkCanvas, those calls can be
110 redirected to a different graphics API. SkGLCanvas has been
111 written to direct its drawing calls to OpenGL. See src/gl/
jcgregorio942262f2015-01-05 11:17:27 -0800112
halcanaryb5002392015-11-16 07:37:23 -08001132. Custom bottleneck routines
jcgregorio942262f2015-01-05 11:17:27 -0800114
halcanaryb5002392015-11-16 07:37:23 -0800115 There are sets of bottleneck routines inside the blits of Skia
116 that can be replace on a platform in order to take advantage of
117 specific CPU features. One such example is the NEON SIMD
118 instructions on ARM v7 devices. See src/opts/
jcgregorio942262f2015-01-05 11:17:27 -0800119
halcanary8d3f7bd2015-07-09 06:58:06 -0700120* * *
121
122<span id="font-hinting"></span>
123
halcanaryb5002392015-11-16 07:37:23 -0800124Does Skia support Font hinting?
125-------------------------------
jcgregorio942262f2015-01-05 11:17:27 -0800126
127Skia has a built-in font cache, but it does not know how to actual render font
128files like TrueType? into its cache. For that it relies on the platform to
129supply an instance of SkScalerContext?. This is Skia's abstract interface for
130communicating with a font scaler engine. In src/ports you can see support
131files for FreeType?, Mac OS X, and Windows GDI font engines. Other font
132engines can easily be supported in a like manner.
133
134