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 ### Bitmap Subsetting | 7 ### Bitmap Subsetting |
8 | 8 |
9 Taking a subset of a bitmap is effectively free - no pixels are copied or | 9 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 | 10 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 | 11 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 | 12 the following pattern, here being used to magnify a portion of an image with |
13 drawBitmapNine(): | 13 drawBitmapNine(): |
14 | 14 |
15 SkBitmap subset; | 15 SkBitmap subset; |
16 bitmap.extractSubset(&subset, rect); | 16 bitmap.extractSubset(&subset, rect); |
17 canvas->drawBitmapNine(subset, ...); | 17 canvas->drawBitmapNine(subset, ...); |
18 | 18 |
| 19 ### Capturing a `.skp` file on a web page in Chromium. |
| 20 |
| 21 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking` |
| 22 2. Open the JS console (ctrl-shift-J) |
| 23 3. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')` |
| 24 This returns "undefined" on success. |
| 25 |
| 26 Open 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 |
| 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 \ |
| 37 --config 8888 gpu pdf --verbose |
| 38 ls -l /tmp/*/skp/layer_0.skp.* |
| 39 |
19 FAQ | 40 FAQ |
20 --- | 41 --- |
21 | 42 |
22 ### Does Skia support HW acceleration? | 43 ### Does Skia support HW acceleration? |
23 | 44 |
24 | 45 |
25 There are two ways Skia can take advantage of HW. | 46 There are two ways Skia can take advantage of HW. |
26 | 47 |
27 1. Subclass SkCanvas | 48 1. Subclass SkCanvas |
28 | 49 |
(...skipping 10 matching lines...) Expand all Loading... |
39 ### Does Skia support Font hinting? | 60 ### Does Skia support Font hinting? |
40 | 61 |
41 Skia has a built-in font cache, but it does not know how to actual render font | 62 Skia has a built-in font cache, but it does not know how to actual render font |
42 files like TrueType? into its cache. For that it relies on the platform to | 63 files like TrueType? into its cache. For that it relies on the platform to |
43 supply an instance of SkScalerContext?. This is Skia's abstract interface for | 64 supply an instance of SkScalerContext?. This is Skia's abstract interface for |
44 communicating with a font scaler engine. In src/ports you can see support | 65 communicating with a font scaler engine. In src/ports you can see support |
45 files for FreeType?, Mac OS X, and Windows GDI font engines. Other font | 66 files for FreeType?, Mac OS X, and Windows GDI font engines. Other font |
46 engines can easily be supported in a like manner. | 67 engines can easily be supported in a like manner. |
47 | 68 |
48 | 69 |
OLD | NEW |