Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: site/user/tips.md

Issue 2366403002: Documentation: fix links (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Tips & FAQ 1 Tips & FAQ
2 ========== 2 ==========
3 3
4 + [Gyp Options](#gypdefines) 4 + [Gyp Options](#gypdefines)
5 + [Bitmap Subsetting](#bitmap-subsetting) 5 + [Bitmap Subsetting](#bitmap-subsetting)
6 + [Capture a `.skp` file on a web page in Chromium](#skp-capture) 6 + [Capture a `.skp` file on a web page in Chromium](#skp-capture)
7 + [Capture a `.mskp` file on a web page in Chromium](#mskp-capture) 7 + [Capture a `.mskp` file on a web page in Chromium](#mskp-capture)
8 + [How to add hardware acceleration in Skia](#hw-acceleration) 8 + [How to add hardware acceleration in Skia](#hw-acceleration)
9 + [Does Skia support Font hinting?](#font-hinting) 9 + [Does Skia support Font hinting?](#font-hinting)
10 + [Does Skia shape text (kerning)?](#kerning) 10 + [Does Skia shape text (kerning)?](#kerning)
11 + [How do I add drop shadow on text?](#text-shadow) 11 + [How do I add drop shadow on text?](#text-shadow)
12 12
13 * * * 13 * * *
14 14
15 <span id="gypdefines"></span> 15 <span id="gypdefines">Gyp Options</span>
16 16 ----------------------------------------
17 Gyp Options
18 -----------
19 17
20 When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can 18 When running `sync-and-gyp`, the `GYP_DEFINES` environment variable can
21 be used to change Skia’s compile-time settings, using a 19 be used to change Skia’s compile-time settings, using a
22 space-separated list of key=value pairs. For example, to disable both 20 space-separated list of key=value pairs. For example, to disable both
23 the Skia GPU backend and PDF backends, run it as follows: 21 the Skia GPU backend and PDF backends, run it as follows:
24 22
25 <!--?prettify lang=sh?--> 23 <!--?prettify lang=sh?-->
26 24
27 GYP_DEFINES='skia_gpu=0 skia_pdf=0' python bin/sync-and-gyp 25 GYP_DEFINES='skia_gpu=0 skia_pdf=0' python bin/sync-and-gyp
28 ninja -C out/Debug 26 ninja -C out/Debug
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 65
68 <!--?prettify lang=sh?--> 66 <!--?prettify lang=sh?-->
69 67
70 CC='clang' CXX='clang++' SKIA_OUT=~/build/skia_clang python bin/sync-and-gyp 68 CC='clang' CXX='clang++' SKIA_OUT=~/build/skia_clang python bin/sync-and-gyp
71 CC='gcc' CXX='g++' SKIA_OUT=~/build/skia_gcc python bin/sync-and-gyp 69 CC='gcc' CXX='g++' SKIA_OUT=~/build/skia_gcc python bin/sync-and-gyp
72 ninja -C ~/build/skia_clang/Debug 70 ninja -C ~/build/skia_clang/Debug
73 ninja -C ~/build/skia_gcc/Debug 71 ninja -C ~/build/skia_gcc/Debug
74 72
75 * * * 73 * * *
76 74
77 <span id="bitmap-subsetting"></span>
78 75
79 Bitmap Subsetting 76
80 ----------------- 77 <span id="bitmap-subsetting">Bitmap Subsetting</span>
78 -----------------------------------------------------
81 79
82 Taking a subset of a bitmap is effectively free - no pixels are copied or 80 Taking a subset of a bitmap is effectively free - no pixels are copied or
83 memory is allocated. This allows Skia to offer an API that typically operates 81 memory is allocated. This allows Skia to offer an API that typically operates
84 on entire bitmaps; clients who want to operate on a subset of a bitmap can use 82 on entire bitmaps; clients who want to operate on a subset of a bitmap can use
85 the following pattern, here being used to magnify a portion of an image with 83 the following pattern, here being used to magnify a portion of an image with
86 drawBitmapNine(): 84 drawBitmapNine():
87 85
88 SkBitmap subset; 86 SkBitmap subset;
89 bitmap.extractSubset(&subset, rect); 87 bitmap.extractSubset(&subset, rect);
90 canvas->drawBitmapNine(subset, ...); 88 canvas->drawBitmapNine(subset, ...);
91 89
92 [An example](https://fiddle.skia.org/c/@subset_example) 90 [An example](https://fiddle.skia.org/c/@subset_example)
93 91
94 92
95 * * * 93 * * *
96 94
97 <span id="skp-capture"></span> 95 <span id="skp-capture">Capture a `.skp` file on a web page in Chromium</span>
98 96 -----------------------------------------------------------------------------
99 Capture a `.skp` file on a web page in Chromium
100 -----------------------------------------------
101 97
102 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking` 98 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking`
103 2. Open the JS console (ctrl-shift-J) 99 2. Open the JS console (ctrl-shift-J)
104 3. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')` 100 3. Execute: `chrome.gpuBenchmarking.printToSkPicture('/tmp')`
105 This returns "undefined" on success. 101 This returns "undefined" on success.
106 102
107 Open the resulting file in the [Skia Debugger](/dev/tools/debugger), rasterize i t with `dm`, 103 Open the resulting file in the [Skia Debugger](/dev/tools/debugger), rasterize i t with `dm`,
108 or use Skia's `SampleApp` to view it: 104 or use Skia's `SampleApp` to view it:
109 105
110 <!--?prettify lang=sh?--> 106 <!--?prettify lang=sh?-->
111 107
112 out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \ 108 out/Release/dm --src skp --skps /tmp/layer_0.skp -w /tmp \
113 --config 8888 gpu pdf --verbose 109 --config 8888 gpu pdf --verbose
114 ls -l /tmp/*/skp/layer_0.skp.* 110 ls -l /tmp/*/skp/layer_0.skp.*
115 111
116 out/Release/SampleApp --picture /tmp/layer_0.skp 112 out/Release/SampleApp --picture /tmp/layer_0.skp
117 113
118 * * * 114 * * *
119 115
120 <span id="mskp-capture"></span> 116 <span id="mskp-capture">Capture a `.mskp` file on a web page in Chromium</span>
121 117 -------------------------------------------------------------------------------
122 Capture a `.mskp` file on a web page in Chromium
123 -----------------------------------------------
124 118
125 Multipage Skia Picture files capture the commands sent to produce PDFs 119 Multipage Skia Picture files capture the commands sent to produce PDFs
126 and printed documents. 120 and printed documents.
127 121
128 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking` 122 1. Launch Chrome or Chromium with `--no-sandbox --enable-gpu-benchmarking`
129 2. Open the JS console (ctrl-shift-J) 123 2. Open the JS console (ctrl-shift-J)
130 3. Execute: `chrome.gpuBenchmarking.printPagesToSkPictures('/tmp/filename.mskp' )` 124 3. Execute: `chrome.gpuBenchmarking.printPagesToSkPictures('/tmp/filename.mskp' )`
131 This returns "undefined" on success. 125 This returns "undefined" on success.
132 126
133 Open the resulting file in the [Skia Debugger](/dev/tools/debugger) or 127 Open the resulting file in the [Skia Debugger](/dev/tools/debugger) or
134 process it with `dm`. 128 process it with `dm`.
135 129
136 <!--?prettify lang=sh?--> 130 <!--?prettify lang=sh?-->
137 131
138 experimental/tools/mskp_parser.py /tmp/filename.mskp /tmp/filename.mskp.skp 132 experimental/tools/mskp_parser.py /tmp/filename.mskp /tmp/filename.mskp.skp
139 ls -l /tmp/filename.mskp.skp 133 ls -l /tmp/filename.mskp.skp
140 # open filename.mskp.skp in the debugger. 134 # open filename.mskp.skp in the debugger.
141 135
142 out/Release/dm --src mskp --mskps /tmp/filename.mskp -w /tmp \ 136 out/Release/dm --src mskp --mskps /tmp/filename.mskp -w /tmp \
143 --config pdf --verbose 137 --config pdf --verbose
144 ls -l /tmp/pdf/mskp/filename.mskp 138 ls -l /tmp/pdf/mskp/filename.mskp.pdf
145 139
146 * * * 140 * * *
147 141
148 <span id="hw-acceleration"></span> 142 <span id="hw-acceleration">How to add hardware acceleration in Skia</span>
149 143 --------------------------------------------------------------------------
150 How to add hardware acceleration in Skia
151 ----------------------------------------
152 144
153 There are two ways Skia takes advantage of specific hardware. 145 There are two ways Skia takes advantage of specific hardware.
154 146
155 1. Subclass SkCanvas 147 1. Subclass SkCanvas
156 148
157 Since all drawing calls go through SkCanvas, those calls can be 149 Since all drawing calls go through SkCanvas, those calls can be
158 redirected to a different graphics API. SkGLCanvas has been 150 redirected to a different graphics API. SkGLCanvas has been
159 written to direct its drawing calls to OpenGL. See src/gl/ 151 written to direct its drawing calls to OpenGL. See src/gl/
160 152
161 2. Custom bottleneck routines 153 2. Custom bottleneck routines
162 154
163 There are sets of bottleneck routines inside the blits of Skia 155 There are sets of bottleneck routines inside the blits of Skia
164 that can be replace on a platform in order to take advantage of 156 that can be replace on a platform in order to take advantage of
165 specific CPU features. One such example is the NEON SIMD 157 specific CPU features. One such example is the NEON SIMD
166 instructions on ARM v7 devices. See src/opts/ 158 instructions on ARM v7 devices. See src/opts/
167 159
168 * * * 160 * * *
169 161
170 <span id="font-hinting"></span> 162 <span id="font-hinting">Does Skia support Font hinting?</span>
171 163 --------------------------------------------------------------
172 Does Skia support Font hinting?
173 -------------------------------
174 164
175 Skia has a built-in font cache, but it does not know how to actual render font 165 Skia has a built-in font cache, but it does not know how to actual render font
176 files like TrueType into its cache. For that it relies on the platform to 166 files like TrueType into its cache. For that it relies on the platform to
177 supply an instance of SkScalerContext. This is Skia's abstract interface for 167 supply an instance of SkScalerContext. This is Skia's abstract interface for
178 communicating with a font scaler engine. In src/ports you can see support 168 communicating with a font scaler engine. In src/ports you can see support
179 files for FreeType, Mac OS X, and Windows GDI font engines. Other font 169 files for FreeType, Mac OS X, and Windows GDI font engines. Other font
180 engines can easily be supported in a like manner. 170 engines can easily be supported in a like manner.
181 171
182 172
183 * * * 173 * * *
184 174
185 <span id="kerning"></span> 175 <span id="kerning">Does Skia shape text (kerning)?</span>
186 176 ---------------------------------------------------------
187 Does Skia shape text (kerning)?
188 -------------------------------
189 177
190 No. Skia provides interfaces to draw glyphs, but does not implement a 178 No. Skia provides interfaces to draw glyphs, but does not implement a
191 text shaper. Skia's client's often use 179 text shaper. Skia's client's often use
192 [HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to 180 [HarfBuzz](http://www.freedesktop.org/wiki/Software/HarfBuzz/) to
193 generate the glyphs and their positions, including kerning. 181 generate the glyphs and their positions, including kerning.
194 182
195 [Here is an example of how to use Skia and HarfBuzz 183 [Here is an example of how to use Skia and HarfBuzz
196 together](https://github.com/aam/skiaex). In the example, a 184 together](https://github.com/aam/skiaex). In the example, a
197 `SkTypeface` and a `hb_face_t` are created using the same `mmap()`ed 185 `SkTypeface` and a `hb_face_t` are created using the same `mmap()`ed
198 `.ttf` font file. The HarfBuzz face is used to shape unicode text into 186 `.ttf` font file. The HarfBuzz face is used to shape unicode text into
199 a sequence of glyphs and positions, and the SkTypeface can then be 187 a sequence of glyphs and positions, and the SkTypeface can then be
200 used to draw those glyphs. 188 used to draw those glyphs.
201 189
202 * * * 190 * * *
203 191
204 <span id="text-shadow"></span> 192 <span id="text-shadow">How do I add drop shadow on text?</span>
205 193 ---------------------------------------------------------------
206 How do I add drop shadow on text?
207 ---------------------------------
208 194
209 <!--?prettify lang=cc?--> 195 <!--?prettify lang=cc?-->
210 196
211 void draw(SkCanvas* canvas) { 197 void draw(SkCanvas* canvas) {
212 const char text[] = "Skia"; 198 const char text[] = "Skia";
213 const SkScalar radius = 2.0f; 199 const SkScalar radius = 2.0f;
214 const SkScalar xDrop = 2.0f; 200 const SkScalar xDrop = 2.0f;
215 const SkScalar yDrop = 2.0f; 201 const SkScalar yDrop = 2.0f;
216 const SkScalar x = 8.0f; 202 const SkScalar x = 8.0f;
217 const SkScalar y = 52.0f; 203 const SkScalar y = 52.0f;
(...skipping 10 matching lines...) Expand all
228 SkBlurMaskFilter::ConvertRadiusToSigma(radius), 0)); 214 SkBlurMaskFilter::ConvertRadiusToSigma(radius), 0));
229 canvas->drawText(text, strlen(text), x + xDrop, y + yDrop, blur); 215 canvas->drawText(text, strlen(text), x + xDrop, y + yDrop, blur);
230 canvas->drawText(text, strlen(text), x, y, paint); 216 canvas->drawText(text, strlen(text), x, y, paint);
231 } 217 }
232 218
233 <a href='https://fiddle.skia.org/c/@text_shadow'><img src='https://fiddle.skia.o rg/i/@text_shadow_raster.png'></a> 219 <a href='https://fiddle.skia.org/c/@text_shadow'><img src='https://fiddle.skia.o rg/i/@text_shadow_raster.png'></a>
234 220
235 * * * 221 * * *
236 222
237 <div style="margin-bottom:99%"></div> 223 <div style="margin-bottom:99%"></div>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698