1 // Copyright 2020 Google LLC. 2 #ifndef Decorations_DEFINED 3 #define Decorations_DEFINED 4 5 #include "include/core/SkPath.h" 6 #include "modules/skparagraph/include/ParagraphPainter.h" 7 #include "modules/skparagraph/include/TextStyle.h" 8 #include "modules/skparagraph/src/TextLine.h" 9 10 namespace skia { 11 namespace textlayout { 12 13 class Decorations { 14 public: 15 void paint(ParagraphPainter* painter, const TextStyle& textStyle, const TextLine::ClipContext& context, SkScalar baseline); 16 17 private: 18 19 #ifndef USE_SKIA_TXT 20 void calculateThickness(TextStyle textStyle, sk_sp<SkTypeface> typeface); 21 #else 22 void calculateThickness(TextStyle textStyle, std::shared_ptr<RSTypeface> typeface); 23 #endif 24 void calculatePosition(TextDecoration decoration, SkScalar ascent, const TextDecorationStyle textDecorationStyle); 25 void calculatePaint(const TextStyle& textStyle); 26 void calculateWaves(const TextStyle& textStyle, SkRect clip); 27 void calculateGaps(const TextLine::ClipContext& context, const SkRect& rect, SkScalar baseline, SkScalar halo); 28 29 SkScalar fThickness; 30 SkScalar fPosition; 31 32 #ifndef USE_SKIA_TXT 33 SkFontMetrics fFontMetrics; 34 ParagraphPainter::DecorationStyle fDecorStyle; 35 SkPath fPath; 36 #else 37 RSFontMetrics fFontMetrics; 38 ParagraphPainter::DecorationStyle fDecorStyle; 39 RSPath fPath; 40 #endif 41 }; 42 } // namespace textlayout 43 } // namespace skia 44 #endif 45