2015-01-05 19:17:27 +00:00
|
|
|
|
Tips & FAQ
|
|
|
|
|
==========
|
|
|
|
|
|
2015-12-22 15:08:12 +00:00
|
|
|
|
+ [Gyp Options](#gypdefines)
|
|
|
|
|
+ [Bitmap Subsetting](#bitmap-subsetting)
|
|
|
|
|
+ [Capture a `.skp` file on a web page in Chromium](#skp-capture)
|
|
|
|
|
+ [How to add hardware acceleration in Skia](#hw-acceleration)
|
|
|
|
|
+ [Does Skia support Font hinting?](#font-hinting)
|
|
|
|
|
+ [Does Skia shape text (kerning)?](#kerning)
|
|
|
|
|
|
|
|
|
|
* * *
|
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
<span id="gypdefines"></span>
|
|
|
|
|
|
|
|
|
|
Gyp Options
|
|
|
|
|
-----------
|
|
|
|
|
|
|
|
|
|
When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can
|
|
|
|
|
be used to change Skia’s compile-time settings, using a
|
|
|
|
|
space-separated list of key=value pairs. For example, to disable both
|
|
|
|
|
the Skia GPU backend and PDF backends, run it as follows:
|
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
|
|
|
|
|
GYP_DEFINES='skia_gpu=0 skia_pdf=0' python bin/sync-and-gyp
|
|
|
|
|
ninja -C out/Debug
|
|
|
|
|
|
|
|
|
|
Note: Setting enviroment variables in the Windows CMD.EXE shell [uses a
|
|
|
|
|
different syntax](/user/quick/windows#env).
|
|
|
|
|
|
|
|
|
|
You can also set environment variables such as `CC`, `CXX`,
|
2015-12-03 17:20:55 +00:00
|
|
|
|
`CFLAGS`, `CXXFLAGS`, or `CPPFLAGS` to control how Skia is compiled.
|
|
|
|
|
To build with clang, for example:
|
2015-11-16 15:37:23 +00:00
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
|
|
|
|
|
CC='clang' CXX='clang++' python bin/sync-and-gyp
|
|
|
|
|
ninja -C out/Debug
|
|
|
|
|
|
2015-12-03 17:20:55 +00:00
|
|
|
|
To build with clang and enable a compiler warning for unused parameters in C++
|
|
|
|
|
(but not C or assembly) code:
|
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
|
2015-12-22 15:08:12 +00:00
|
|
|
|
CXXFLAGS='-Wunused-parameter' \
|
|
|
|
|
CC='clang' CXX='clang++' python bin/sync-and-gyp
|
2015-12-03 17:20:55 +00:00
|
|
|
|
ninja -C out/Debug
|
|
|
|
|
|
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
The `GYP_GENERATORS` environment variable can be used to set the
|
|
|
|
|
build systems that you want to use (as a comma-separated list).
|
|
|
|
|
The default is `'ninja,msvs-ninja'` on Windows, `'ninja,xcode'` on
|
|
|
|
|
Mac OS X, and just `'ninja'` on Linux. For example, to generate
|
|
|
|
|
only Ninja files on Mac:
|
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
|
|
|
|
|
GYP_GENERATORS='ninja' python bin/sync-and-gyp
|
|
|
|
|
ninja -C out/Debug
|
|
|
|
|
|
|
|
|
|
Finally, the `SKIA_OUT` environment variable can be used to set
|
|
|
|
|
the path for the build directory. The default is `out` inside the
|
|
|
|
|
top-level Skia source directory. For example to test Skia with
|
|
|
|
|
two different compilers:
|
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
|
|
|
|
|
|
|
|
|
CC='clang' CXX='clang++' SKIA_OUT=~/build/skia_clang python bin/sync-and-gyp
|
|
|
|
|
CC='gcc' CXX='g++' SKIA_OUT=~/build/skia_gcc python bin/sync-and-gyp
|
|
|
|
|
ninja -C ~/build/skia_clang/Debug
|
|
|
|
|
ninja -C ~/build/skia_gcc/Debug
|
|
|
|
|
|
|
|
|
|
* * *
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-07-09 13:58:06 +00:00
|
|
|
|
<span id="bitmap-subsetting"></span>
|
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
Bitmap Subsetting
|
|
|
|
|
-----------------
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
|
|
|
|
Taking a subset of a bitmap is effectively free - no pixels are copied or
|
|
|
|
|
memory is allocated. This allows Skia to offer an API that typically operates
|
|
|
|
|
on entire bitmaps; clients who want to operate on a subset of a bitmap can use
|
|
|
|
|
the following pattern, here being used to magnify a portion of an image with
|
|
|
|
|
drawBitmapNine():
|
|
|
|
|
|
|
|
|
|
SkBitmap subset;
|
|
|
|
|
bitmap.extractSubset(&subset, rect);
|
|
|
|
|
canvas->drawBitmapNine(subset, ...);
|
|
|
|
|
|
2016-04-22 18:25:43 +00:00
|
|
|
|
[An example](https://fiddle.skia.org/c/@subset_example)
|
|
|
|
|
|
2015-12-22 15:08:12 +00:00
|
|
|
|
|
2015-07-09 13:58:06 +00:00
|
|
|
|
* * *
|
|
|
|
|
|
|
|
|
|
<span id="skp-capture"></span>
|
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
Capture a `.skp` file on a web page in Chromium
|
|
|
|
|
-----------------------------------------------
|
2015-07-09 13:58:06 +00:00
|
|
|
|
|
2015-07-08 17:56:01 +00:00
|
|
|
|
1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking`
|
|
|
|
|
2. Open the JS console (ctrl-shift-J)
|
|
|
|
|
3. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')`
|
|
|
|
|
This returns "undefined" on success.
|
|
|
|
|
|
2015-07-09 13:58:06 +00:00
|
|
|
|
Open the resulting file in the Skia Debugger, rasterize it with `dm`,
|
|
|
|
|
or use Skia's `SampleApp` to view it:
|
|
|
|
|
|
|
|
|
|
<!--?prettify lang=sh?-->
|
2015-07-08 17:56:01 +00:00
|
|
|
|
|
|
|
|
|
bin/sync-and-gyp
|
2015-07-09 13:58:06 +00:00
|
|
|
|
ninja -C out/Release debugger dm SampleApp
|
2015-07-08 17:56:01 +00:00
|
|
|
|
out/Release/debugger /tmp/layer_0.skp &
|
|
|
|
|
|
|
|
|
|
out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \
|
|
|
|
|
--config 8888 gpu pdf --verbose
|
|
|
|
|
ls -l /tmp/*/skp/layer_0.skp.*
|
|
|
|
|
|
2015-07-09 13:58:06 +00:00
|
|
|
|
out/Release/SampleApp --picture /tmp/layer_0.skp
|
|
|
|
|
|
|
|
|
|
* * *
|
|
|
|
|
|
|
|
|
|
<span id="hw-acceleration"></span>
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
How to add hardware acceleration in Skia
|
|
|
|
|
----------------------------------------
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
There are two ways Skia takes advantage of specific hardware.
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
1. Subclass SkCanvas
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
Since all drawing calls go through SkCanvas, those calls can be
|
|
|
|
|
redirected to a different graphics API. SkGLCanvas has been
|
|
|
|
|
written to direct its drawing calls to OpenGL. See src/gl/
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
2. Custom bottleneck routines
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
There are sets of bottleneck routines inside the blits of Skia
|
|
|
|
|
that can be replace on a platform in order to take advantage of
|
|
|
|
|
specific CPU features. One such example is the NEON SIMD
|
|
|
|
|
instructions on ARM v7 devices. See src/opts/
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
2015-07-09 13:58:06 +00:00
|
|
|
|
* * *
|
|
|
|
|
|
|
|
|
|
<span id="font-hinting"></span>
|
|
|
|
|
|
2015-11-16 15:37:23 +00:00
|
|
|
|
Does Skia support Font hinting?
|
|
|
|
|
-------------------------------
|
2015-01-05 19:17:27 +00:00
|
|
|
|
|
|
|
|
|
Skia has a built-in font cache, but it does not know how to actual render font
|
2015-12-14 17:50:15 +00:00
|
|
|
|
files like TrueType into its cache. For that it relies on the platform to
|
|
|
|
|
supply an instance of SkScalerContext. This is Skia's abstract interface for
|
2015-01-05 19:17:27 +00:00
|
|
|
|
communicating with a font scaler engine. In src/ports you can see support
|
2015-12-14 17:50:15 +00:00
|
|
|
|
files for FreeType, Mac OS X, and Windows GDI font engines. Other font
|
2015-01-05 19:17:27 +00:00
|
|
|
|
engines can easily be supported in a like manner.
|
|
|
|
|
|
|
|
|
|
|
2015-12-14 17:50:15 +00:00
|
|
|
|
* * *
|
|
|
|
|
|
|
|
|
|
<span id="kerning"></span>
|
|
|
|
|
|
|
|
|
|
Does Skia shape text (kerning)?
|
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
|
|
No. Skia provides interfaces to draw glyphs, but does not implement a
|
2015-12-14 18:03:31 +00:00
|
|
|
|
text shaper. Skia's client's often use
|
|
|
|
|
[HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to
|
|
|
|
|
generate the glyphs and their positions, including kerning.
|
2015-12-14 17:50:15 +00:00
|
|
|
|
|
|
|
|
|
<div style="margin-bottom:99%"></div>
|