OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkScalerContext_DEFINED | 8 #ifndef SkScalerContext_DEFINED |
9 #define SkScalerContext_DEFINED | 9 #define SkScalerContext_DEFINED |
10 | 10 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceP
roperties, | 195 static inline void MakeRec(const SkPaint&, const SkDeviceProperties* deviceP
roperties, |
196 const SkMatrix*, Rec* rec); | 196 const SkMatrix*, Rec* rec); |
197 static inline void PostMakeRec(const SkPaint&, Rec*); | 197 static inline void PostMakeRec(const SkPaint&, Rec*); |
198 | 198 |
199 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); | 199 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); |
200 | 200 |
201 protected: | 201 protected: |
202 Rec fRec; | 202 Rec fRec; |
203 unsigned fBaseGlyphCount; | 203 unsigned fBaseGlyphCount; |
204 | 204 |
205 virtual unsigned generateGlyphCount() = 0; | 205 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. |
206 virtual uint16_t generateCharToGlyph(SkUnichar) = 0; | 206 * May call getMetrics if that would be just as fast. |
207 virtual void generateAdvance(SkGlyph*) = 0; | 207 */ |
208 virtual void generateMetrics(SkGlyph*) = 0; | 208 virtual void generateAdvance(SkGlyph* glyph) = 0; |
209 virtual void generateImage(const SkGlyph&) = 0; | 209 |
210 virtual void generatePath(const SkGlyph&, SkPath*) = 0; | 210 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, |
| 211 * as well as fAdvanceX and fAdvanceY if not already set. |
| 212 * |
| 213 * TODO: fMaskFormat is set by getMetrics later; cannot be set here. |
| 214 */ |
| 215 virtual void generateMetrics(SkGlyph* glyph) = 0; |
| 216 |
| 217 /** Generates the contents of glyph.fImage. |
| 218 * When called, glyph.fImage will be pointing to a pre-allocated, |
| 219 * uninitialized region of memory of size glyph.computeImageSize(). |
| 220 * This method may change glyph.fMaskFormat if the new image size is |
| 221 * less than or equal to the old image size. |
| 222 * |
| 223 * Because glyph.computeImageSize() will determine the size of fImage, |
| 224 * generateMetrics will be called before generateImage. |
| 225 */ |
| 226 virtual void generateImage(const SkGlyph& glyph) = 0; |
| 227 |
| 228 /** Sets the passed path to the glyph outline. |
| 229 * If this cannot be done the path is set to empty; |
| 230 * this is indistinguishable from a glyph with an empty path. |
| 231 * This does not set glyph.fPath. |
| 232 * |
| 233 * TODO: path is always glyph.fPath, no reason to pass separately. |
| 234 */ |
| 235 virtual void generatePath(const SkGlyph& glyph, SkPath* path) = 0; |
| 236 |
| 237 /** Retrieves font metrics. |
| 238 * TODO: there is now a vertical bit, no need for two parameters. |
| 239 */ |
211 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, | 240 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, |
212 SkPaint::FontMetrics* mY) = 0; | 241 SkPaint::FontMetrics* mY) = 0; |
213 // default impl returns 0, indicating failure. | 242 |
214 virtual SkUnichar generateGlyphToChar(uint16_t); | 243 /** Returns the number of glyphs in the font. */ |
| 244 virtual unsigned generateGlyphCount() = 0; |
| 245 |
| 246 /** Returns the glyph id for the given unichar. |
| 247 * If there is no 1:1 mapping from the unichar to a glyph id, returns 0. |
| 248 */ |
| 249 virtual uint16_t generateCharToGlyph(SkUnichar unichar) = 0; |
| 250 |
| 251 /** Returns the unichar for the given glyph id. |
| 252 * If there is no 1:1 mapping from the glyph id to a unichar, returns 0. |
| 253 * The default implementation always returns 0, indicating failure. |
| 254 */ |
| 255 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); |
215 | 256 |
216 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } | 257 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } |
217 | 258 |
218 private: | 259 private: |
219 // never null | 260 // never null |
220 SkAutoTUnref<SkTypeface> fTypeface; | 261 SkAutoTUnref<SkTypeface> fTypeface; |
221 | 262 |
222 #ifdef SK_BUILD_FOR_ANDROID | 263 #ifdef SK_BUILD_FOR_ANDROID |
223 SkPaintOptionsAndroid fPaintOptionsAndroid; | 264 SkPaintOptionsAndroid fPaintOptionsAndroid; |
224 #endif | 265 #endif |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return static_cast<SkPaint::Hinting>(hint); | 337 return static_cast<SkPaint::Hinting>(hint); |
297 } | 338 } |
298 | 339 |
299 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { | 340 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { |
300 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | | 341 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | |
301 (hinting << SkScalerContext::kHinting_Shift); | 342 (hinting << SkScalerContext::kHinting_Shift); |
302 } | 343 } |
303 | 344 |
304 | 345 |
305 #endif | 346 #endif |
OLD | NEW |