blob: 9b86bf1b4c885595e3ccd284fc18e43472e5eb5a [file] [log] [blame] [view]
jcgregorio942262f2015-01-05 11:17:27 -08001Tips & FAQ
2==========
3
4Tips and Tricks
5---------------
6
7### Bitmap Subsetting
8
9Taking a subset of a bitmap is effectively free - no pixels are copied or
10memory is allocated. This allows Skia to offer an API that typically operates
11on entire bitmaps; clients who want to operate on a subset of a bitmap can use
12the following pattern, here being used to magnify a portion of an image with
13drawBitmapNine():
14
15 SkBitmap subset;
16 bitmap.extractSubset(&subset, rect);
17 canvas->drawBitmapNine(subset, ...);
18
halcanary5f0b0ad2015-07-08 10:56:01 -070019### Capturing a `.skp` file on a web page in Chromium.
20
211. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking`
222. Open the JS console (ctrl-shift-J)
233. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')`
24 This returns "undefined" on success.
25
26Open the resulting file in the Skia Debugger:
27
28 bin/sync-and-gyp
29 ninja -C out/Release debugger
30 out/Release/debugger /tmp/layer_0.skp &
31
32Or use `dm` to rasterize it.
33
34 bin/sync-and-gyp
35 ninja -C out/Release dm
36 out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \
37 --config 8888 gpu pdf --verbose
38 ls -l /tmp/*/skp/layer_0.skp.*
39
jcgregorio942262f2015-01-05 11:17:27 -080040FAQ
41---
42
43### Does Skia support HW acceleration?
44
45
46There are two ways Skia can take advantage of HW.
47
481. Subclass SkCanvas
49
50Since all drawing calls go through SkCanvas, those calls can be redirected to
51a different graphics API. SkGLCanvas has been written to direct its drawing
52calls to OpenGL. See src/gl/
53
542. Custom bottleneck routines
55
56There are sets of bottleneck routines inside the blits of Skia that can be
57replace on a platform in order to take advantage of specific CPU features. One
58such example is the NEON SIMD instructions on ARM v7 devices. See src/opts/
59
60### Does Skia support Font hinting?
61
62Skia has a built-in font cache, but it does not know how to actual render font
63files like TrueType? into its cache. For that it relies on the platform to
64supply an instance of SkScalerContext?. This is Skia's abstract interface for
65communicating with a font scaler engine. In src/ports you can see support
66files for FreeType?, Mac OS X, and Windows GDI font engines. Other font
67engines can easily be supported in a like manner.
68
69