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 |
11 #include "SkMask.h" | 11 #include "SkMask.h" |
12 #include "SkMaskGamma.h" | 12 #include "SkMaskGamma.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 #include "SkPaint.h" | 14 #include "SkPaint.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 | 16 |
17 class SkGlyph; | 17 class SkGlyph; |
18 class SkDescriptor; | 18 class SkDescriptor; |
19 class SkMaskFilter; | 19 class SkMaskFilter; |
20 class SkPathEffect; | 20 class SkPathEffect; |
21 class SkRasterizer; | 21 class SkRasterizer; |
22 | 22 |
| 23 struct SkScalerContextEffects { |
| 24 sk_sp<SkTypeface> fTypeface; |
| 25 sk_sp<SkPathEffect> fPathEffect; |
| 26 sk_sp<SkMaskFilter> fMaskFilter; |
| 27 sk_sp<SkRasterizer> fRasterizer; |
| 28 }; |
| 29 |
23 enum SkAxisAlignment { | 30 enum SkAxisAlignment { |
24 kNone_SkAxisAlignment, | 31 kNone_SkAxisAlignment, |
25 kX_SkAxisAlignment, | 32 kX_SkAxisAlignment, |
26 kY_SkAxisAlignment | 33 kY_SkAxisAlignment |
27 }; | 34 }; |
28 | 35 |
29 /* | 36 /* |
30 * To allow this to be forward-declared, it must be its own typename, rather | 37 * To allow this to be forward-declared, it must be its own typename, rather |
31 * than a nested struct inside SkScalerContext (where it started). | 38 * than a nested struct inside SkScalerContext (where it started). |
32 */ | 39 */ |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Generate A8 from LCD source (for GDI and CoreGraphics). | 192 // Generate A8 from LCD source (for GDI and CoreGraphics). |
186 // only meaningful if fMaskFormat is kA8 | 193 // only meaningful if fMaskFormat is kA8 |
187 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen
dent on fMaskFormat) | 194 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen
dent on fMaskFormat) |
188 }; | 195 }; |
189 | 196 |
190 // computed values | 197 // computed values |
191 enum { | 198 enum { |
192 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, | 199 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, |
193 }; | 200 }; |
194 | 201 |
195 | 202 SkScalerContext(const SkScalerContextEffects&, const SkDescriptor*); |
196 SkScalerContext(SkTypeface*, const SkDescriptor*); | |
197 virtual ~SkScalerContext(); | 203 virtual ~SkScalerContext(); |
198 | 204 |
199 SkTypeface* getTypeface() const { return fTypeface.get(); } | 205 SkTypeface* getTypeface() const { return fTypeface.get(); } |
200 | 206 |
201 SkMask::Format getMaskFormat() const { | 207 SkMask::Format getMaskFormat() const { |
202 return (SkMask::Format)fRec.fMaskFormat; | 208 return (SkMask::Format)fRec.fMaskFormat; |
203 } | 209 } |
204 | 210 |
205 bool isSubpixel() const { | 211 bool isSubpixel() const { |
206 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); | 212 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 */ | 317 */ |
312 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); | 318 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); |
313 | 319 |
314 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } | 320 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } |
315 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } | 321 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } |
316 | 322 |
317 private: | 323 private: |
318 friend class SkRandomScalerContext; // For debug purposes | 324 friend class SkRandomScalerContext; // For debug purposes |
319 | 325 |
320 // never null | 326 // never null |
321 SkAutoTUnref<SkTypeface> fTypeface; | 327 sk_sp<SkTypeface> fTypeface; |
322 | 328 |
323 // optional object, which may be null | 329 // optional objects, which may be null |
324 SkPathEffect* fPathEffect; | 330 sk_sp<SkPathEffect> fPathEffect; |
325 SkMaskFilter* fMaskFilter; | 331 sk_sp<SkMaskFilter> fMaskFilter; |
326 SkRasterizer* fRasterizer; | 332 sk_sp<SkRasterizer> fRasterizer; |
327 | 333 |
328 // if this is set, we draw the image from a path, rather than | 334 // if this is set, we draw the image from a path, rather than |
329 // calling generateImage. | 335 // calling generateImage. |
330 bool fGenerateImageFromPath; | 336 bool fGenerateImageFromPath; |
331 | 337 |
332 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, | 338 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, |
333 SkPath* devPath, SkMatrix* fillToDevMatrix); | 339 SkPath* devPath, SkMatrix* fillToDevMatrix); |
334 | 340 |
335 // returns the right context from our link-list for this char. If no match | 341 // returns the right context from our link-list for this char. If no match |
336 // is found it returns nullptr. If a match is found then the glyphID param i
s | 342 // is found it returns nullptr. If a match is found then the glyphID param i
s |
(...skipping 23 matching lines...) Expand all Loading... |
360 return static_cast<SkPaint::Hinting>(hint); | 366 return static_cast<SkPaint::Hinting>(hint); |
361 } | 367 } |
362 | 368 |
363 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { | 369 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { |
364 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | | 370 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | |
365 (hinting << SkScalerContext::kHinting_Shift); | 371 (hinting << SkScalerContext::kHinting_Shift); |
366 } | 372 } |
367 | 373 |
368 | 374 |
369 #endif | 375 #endif |
OLD | NEW |