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