Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
skia::textlayout::Decorations Class Reference

#include <Decorations.h>

Public Member Functions

void paint (ParagraphPainter *painter, const TextStyle &textStyle, const TextLine::ClipContext &context, SkScalar baseline)
 

Detailed Description

Definition at line 13 of file Decorations.h.

Member Function Documentation

◆ paint()

void skia::textlayout::Decorations::paint ( ParagraphPainter painter,
const TextStyle textStyle,
const TextLine::ClipContext context,
SkScalar  baseline 
)

Definition at line 24 of file Decorations.cpp.

24 {
25 if (textStyle.getDecorationType() == TextDecoration::kNoDecoration) {
26 return;
27 }
28
29 // Get thickness and position
30 calculateThickness(textStyle, context.run->font().refTypeface());
31
32 for (auto decoration : AllTextDecorations) {
33 if ((textStyle.getDecorationType() & decoration) == 0) {
34 continue;
35 }
36
37 calculatePosition(decoration,
38 decoration == TextDecoration::kOverline
39 ? context.run->correctAscent() - context.run->ascent()
40 : context.run->correctAscent());
41
42 calculatePaint(textStyle);
43
44 auto width = context.clip.width();
45 SkScalar x = context.clip.left();
46 SkScalar y = context.clip.top() + fPosition;
47
48 bool drawGaps = textStyle.getDecorationMode() == TextDecorationMode::kGaps &&
49 textStyle.getDecorationType() == TextDecoration::kUnderline;
50
51 switch (textStyle.getDecorationStyle()) {
53 calculateWaves(textStyle, context.clip);
54 fPath.offset(x, y);
55 painter->drawPath(fPath, fDecorStyle);
56 break;
57 }
59 SkScalar bottom = y + kDoubleDecorationSpacing;
60 if (drawGaps) {
61 SkScalar left = x - context.fTextShift;
62 painter->translate(context.fTextShift, 0);
63 calculateGaps(context, SkRect::MakeXYWH(left, y, width, fThickness), baseline, fThickness);
64 painter->drawPath(fPath, fDecorStyle);
65 calculateGaps(context, SkRect::MakeXYWH(left, bottom, width, fThickness), baseline, fThickness);
66 painter->drawPath(fPath, fDecorStyle);
67 } else {
68 draw_line_as_rect(painter, x, y, width, fDecorStyle);
69 draw_line_as_rect(painter, x, bottom, width, fDecorStyle);
70 }
71 break;
72 }
75 if (drawGaps) {
76 SkScalar left = x - context.fTextShift;
77 painter->translate(context.fTextShift, 0);
78 calculateGaps(context, SkRect::MakeXYWH(left, y, width, fThickness), baseline, 0);
79 painter->drawPath(fPath, fDecorStyle);
80 } else {
81 painter->drawLine(x, y, x + width, y, fDecorStyle);
82 }
83 break;
85 if (drawGaps) {
86 SkScalar left = x - context.fTextShift;
87 painter->translate(context.fTextShift, 0);
88 calculateGaps(context, SkRect::MakeXYWH(left, y, width, fThickness), baseline, fThickness);
89 painter->drawPath(fPath, fDecorStyle);
90 } else {
91 draw_line_as_rect(painter, x, y, width, fDecorStyle);
92 }
93 break;
94 default:break;
95 }
96 }
97}
static bool left(const SkPoint &p0, const SkPoint &p1)
void offset(SkScalar dx, SkScalar dy, SkPath *dst) const
Definition SkPath.cpp:1627
float SkScalar
Definition extension.cpp:12
double y
double x
Definition run.py:1
constexpr TextDecoration AllTextDecorations[]
Definition TextStyle.h:47
int32_t width
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659

The documentation for this class was generated from the following files: