| 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 SkScalerContextEffects() : fPathEffect(nullptr), fMaskFilter(nullptr), fRast
erizer(nullptr) {} | |
| 25 SkScalerContextEffects(SkPathEffect* pe, SkMaskFilter* mf, SkRasterizer* ra) | |
| 26 : fPathEffect(pe), fMaskFilter(mf), fRasterizer(ra) {} | |
| 27 | |
| 28 SkPathEffect* fPathEffect; | |
| 29 SkMaskFilter* fMaskFilter; | |
| 30 SkRasterizer* fRasterizer; | |
| 31 }; | |
| 32 | |
| 33 enum SkAxisAlignment { | 23 enum SkAxisAlignment { |
| 34 kNone_SkAxisAlignment, | 24 kNone_SkAxisAlignment, |
| 35 kX_SkAxisAlignment, | 25 kX_SkAxisAlignment, |
| 36 kY_SkAxisAlignment | 26 kY_SkAxisAlignment |
| 37 }; | 27 }; |
| 38 | 28 |
| 39 /* | 29 /* |
| 40 * To allow this to be forward-declared, it must be its own typename, rather | 30 * To allow this to be forward-declared, it must be its own typename, rather |
| 41 * than a nested struct inside SkScalerContext (where it started). | 31 * than a nested struct inside SkScalerContext (where it started). |
| 42 */ | 32 */ |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Generate A8 from LCD source (for GDI and CoreGraphics). | 193 // Generate A8 from LCD source (for GDI and CoreGraphics). |
| 204 // only meaningful if fMaskFormat is kA8 | 194 // only meaningful if fMaskFormat is kA8 |
| 205 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen
dent on fMaskFormat) | 195 kGenA8FromLCD_Flag = 0x0800, // could be 0x200 (bit meaning depen
dent on fMaskFormat) |
| 206 }; | 196 }; |
| 207 | 197 |
| 208 // computed values | 198 // computed values |
| 209 enum { | 199 enum { |
| 210 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, | 200 kHinting_Mask = kHintingBit1_Flag | kHintingBit2_Flag, |
| 211 }; | 201 }; |
| 212 | 202 |
| 213 SkScalerContext(SkTypeface*, const SkScalerContextEffects&, const SkDescript
or*); | 203 |
| 204 SkScalerContext(SkTypeface*, const SkDescriptor*); |
| 214 virtual ~SkScalerContext(); | 205 virtual ~SkScalerContext(); |
| 215 | 206 |
| 216 SkTypeface* getTypeface() const { return fTypeface.get(); } | 207 SkTypeface* getTypeface() const { return fTypeface.get(); } |
| 217 | 208 |
| 218 SkMask::Format getMaskFormat() const { | 209 SkMask::Format getMaskFormat() const { |
| 219 return (SkMask::Format)fRec.fMaskFormat; | 210 return (SkMask::Format)fRec.fMaskFormat; |
| 220 } | 211 } |
| 221 | 212 |
| 222 bool isSubpixel() const { | 213 bool isSubpixel() const { |
| 223 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); | 214 return SkToBool(fRec.fFlags & kSubpixelPositioning_Flag); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 void* data); | 253 void* data); |
| 263 | 254 |
| 264 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps, | 255 static void MakeRec(const SkPaint&, const SkSurfaceProps* surfaceProps, |
| 265 const SkMatrix*, Rec* rec); | 256 const SkMatrix*, Rec* rec); |
| 266 static inline void PostMakeRec(const SkPaint&, Rec*); | 257 static inline void PostMakeRec(const SkPaint&, Rec*); |
| 267 | 258 |
| 268 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); | 259 static SkMaskGamma::PreBlend GetMaskPreBlend(const Rec& rec); |
| 269 | 260 |
| 270 const Rec& getRec() const { return fRec; } | 261 const Rec& getRec() const { return fRec; } |
| 271 | 262 |
| 272 SkScalerContextEffects getEffects() const { | |
| 273 return { fPathEffect.get(), fMaskFilter.get(), fRasterizer.get() }; | |
| 274 } | |
| 275 | |
| 276 /** | 263 /** |
| 277 * Return the axis (if any) that the baseline for horizontal text should lan
d on. | 264 * Return the axis (if any) that the baseline for horizontal text should lan
d on. |
| 278 * As an example, the identity matrix will return kX_SkAxisAlignment | 265 * As an example, the identity matrix will return kX_SkAxisAlignment |
| 279 */ | 266 */ |
| 280 SkAxisAlignment computeAxisAlignmentForHText(); | 267 SkAxisAlignment computeAxisAlignmentForHText(); |
| 281 | 268 |
| 269 |
| 282 protected: | 270 protected: |
| 283 Rec fRec; | 271 Rec fRec; |
| 284 | 272 |
| 285 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. | 273 /** Generates the contents of glyph.fAdvanceX and glyph.fAdvanceY. |
| 286 * May call getMetrics if that would be just as fast. | 274 * May call getMetrics if that would be just as fast. |
| 287 */ | 275 */ |
| 288 virtual void generateAdvance(SkGlyph* glyph) = 0; | 276 virtual void generateAdvance(SkGlyph* glyph) = 0; |
| 289 | 277 |
| 290 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, | 278 /** Generates the contents of glyph.fWidth, fHeight, fTop, fLeft, |
| 291 * as well as fAdvanceX and fAdvanceY if not already set. | 279 * as well as fAdvanceX and fAdvanceY if not already set. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 */ | 319 */ |
| 332 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); | 320 virtual SkUnichar generateGlyphToChar(uint16_t glyphId); |
| 333 | 321 |
| 334 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } | 322 void forceGenerateImageFromPath() { fGenerateImageFromPath = true; } |
| 335 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } | 323 void forceOffGenerateImageFromPath() { fGenerateImageFromPath = false; } |
| 336 | 324 |
| 337 private: | 325 private: |
| 338 friend class SkRandomScalerContext; // For debug purposes | 326 friend class SkRandomScalerContext; // For debug purposes |
| 339 | 327 |
| 340 // never null | 328 // never null |
| 341 sk_sp<SkTypeface> fTypeface; | 329 SkAutoTUnref<SkTypeface> fTypeface; |
| 342 | 330 |
| 343 // optional objects, which may be null | 331 // optional object, which may be null |
| 344 sk_sp<SkPathEffect> fPathEffect; | 332 SkPathEffect* fPathEffect; |
| 345 sk_sp<SkMaskFilter> fMaskFilter; | 333 SkMaskFilter* fMaskFilter; |
| 346 sk_sp<SkRasterizer> fRasterizer; | 334 SkRasterizer* fRasterizer; |
| 347 | 335 |
| 348 // if this is set, we draw the image from a path, rather than | 336 // if this is set, we draw the image from a path, rather than |
| 349 // calling generateImage. | 337 // calling generateImage. |
| 350 bool fGenerateImageFromPath; | 338 bool fGenerateImageFromPath; |
| 351 | 339 |
| 352 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, | 340 void internalGetPath(const SkGlyph& glyph, SkPath* fillPath, |
| 353 SkPath* devPath, SkMatrix* fillToDevMatrix); | 341 SkPath* devPath, SkMatrix* fillToDevMatrix); |
| 354 | 342 |
| 355 // returns the right context from our link-list for this char. If no match | 343 // returns the right context from our link-list for this char. If no match |
| 356 // is found it returns nullptr. If a match is found then the glyphID param i
s | 344 // is found it returns nullptr. If a match is found then the glyphID param i
s |
| (...skipping 23 matching lines...) Expand all Loading... |
| 380 return static_cast<SkPaint::Hinting>(hint); | 368 return static_cast<SkPaint::Hinting>(hint); |
| 381 } | 369 } |
| 382 | 370 |
| 383 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { | 371 void SkScalerContextRec::setHinting(SkPaint::Hinting hinting) { |
| 384 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | | 372 fFlags = (fFlags & ~SkScalerContext::kHinting_Mask) | |
| 385 (hinting << SkScalerContext::kHinting_Shift); | 373 (hinting << SkScalerContext::kHinting_Shift); |
| 386 } | 374 } |
| 387 | 375 |
| 388 | 376 |
| 389 #endif | 377 #endif |
| OLD | NEW |