12 const ParagraphPainter::DecorationStyle& decorStyle) {
13 SkASSERT(decorStyle.skPaint().getPathEffect() ==
nullptr);
15 SkASSERT(decorStyle.skPaint().getStrokeWidth() > 0);
17 float radius = decorStyle.getStrokeWidth() * 0.5f;
18 painter->drawFilledRect({
x,
y - radius,
x +
width,
y + radius}, decorStyle);
21const float kDoubleDecorationSpacing = 3.0f;
37 calculatePosition(decoration,
42 calculatePaint(textStyle);
53 calculateWaves(textStyle, context.
clip);
55 painter->
drawPath(fPath, fDecorStyle);
59 SkScalar bottom =
y + kDoubleDecorationSpacing;
64 painter->
drawPath(fPath, fDecorStyle);
66 painter->
drawPath(fPath, fDecorStyle);
68 draw_line_as_rect(painter,
x,
y,
width, fDecorStyle);
69 draw_line_as_rect(painter,
x, bottom,
width, fDecorStyle);
79 painter->
drawPath(fPath, fDecorStyle);
89 painter->
drawPath(fPath, fDecorStyle);
91 draw_line_as_rect(painter,
x,
y,
width, fDecorStyle);
119 intersections.resize(
count);
125 for (
int i = 0;
i < intersections.size();
i += 2) {
126 auto end = intersections[
i] - halo;
127 if (end - start >= halo) {
128 start = intersections[
i + 1] + halo;
132 if (!intersections.empty() && (
rect.fRight - start > halo)) {
135 fPath =
path.detach();
141 textStyle.setTypeface(std::move(typeface));
142 textStyle.getFontMetrics(&fFontMetrics);
144 fThickness = textStyle.getFontSize() / 14.0f;
146 if ((fFontMetrics.
fFlags & SkFontMetrics::FontMetricsFlags::kUnderlineThicknessIsValid_Flag) &&
152 if ((fFontMetrics.
fFlags & SkFontMetrics::FontMetricsFlags::kStrikeoutThicknessIsValid_Flag) &&
157 fThickness *= textStyle.getDecorationThicknessMultiplier();
162 switch (decoration) {
164 if ((fFontMetrics.
fFlags & SkFontMetrics::FontMetricsFlags::kUnderlinePositionIsValid_Flag) &&
168 fPosition = fThickness;
176 fPosition = (fFontMetrics.
fFlags & SkFontMetrics::FontMetricsFlags::kStrikeoutPositionIsValid_Flag)
187void Decorations::calculatePaint(
const TextStyle& textStyle) {
188 std::optional<ParagraphPainter::DashPathEffect> dashPathEffect;
189 SkScalar scaleFactor = textStyle.getFontSize() / 14.f;
190 switch (textStyle.getDecorationStyle()) {
195 dashPathEffect.emplace(1.0f * scaleFactor, 1.5f * scaleFactor);
202 dashPathEffect.emplace(4.0f * scaleFactor, 2.0f * scaleFactor);
209 ? textStyle.getColor()
210 : textStyle.getDecorationColor();
212 fDecorStyle = ParagraphPainter::DecorationStyle(
color, fThickness, dashPathEffect);
222 while (x_start + quarterWave * 2 <
clip.width()) {
224 wave_count % 2 != 0 ? quarterWave : -quarterWave,
227 x_start += quarterWave * 2;
232 auto remaining =
clip.width() - x_start;
234 double x1 = remaining / 2;
235 double y1 = remaining / 2 * (wave_count % 2 == 0 ? -1 : 1);
236 double x2 = remaining;
237 double y2 = (remaining - remaining * remaining / (quarterWave * 2)) *
238 (wave_count % 2 == 0 ? -1 : 1);
constexpr SkColor SK_ColorTRANSPARENT
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
constexpr uint32_t SkToU32(S x)
sk_sp< SkTypeface > refTypeface() const
@ kButt_Cap
no stroke extension
void offset(SkScalar dx, SkScalar dy, SkPath *dst) const
SkPath & moveTo(SkScalar x, SkScalar y)
SkPath & rQuadTo(SkScalar dx1, SkScalar dy1, SkScalar dx2, SkScalar dy2)
int getIntercepts(const SkScalar bounds[2], SkScalar intervals[], const SkPaint *paint=nullptr) const
void paint(ParagraphPainter *painter, const TextStyle &textStyle, const TextLine::ClipContext &context, SkScalar baseline)
const SkPaint & skPaint() const
virtual void translate(SkScalar dx, SkScalar dy)=0
virtual void drawPath(const SkPath &path, const DecorationStyle &decorStyle)=0
virtual void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const DecorationStyle &decorStyle)=0
void copyTo(SkTextBlobBuilder &builder, size_t pos, size_t size) const
const SkFont & font() const
SkScalar correctAscent() const
TextDecorationMode getDecorationMode() const
TextDecorationStyle getDecorationStyle() const
TextDecoration getDecorationType() const
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
constexpr TextDecoration AllTextDecorations[]
SkScalar fStrikeoutPosition
distance from baseline to bottom of stroke, typically negative
SkScalar fStrikeoutThickness
strikeout thickness
uint32_t fFlags
FontMetricsFlags indicating which metrics are valid.
SkScalar fXHeight
height of lower-case 'x', zero if unknown, typically negative
SkScalar fUnderlineThickness
underline thickness
SkScalar fUnderlinePosition
distance from baseline to top of stroke, typically positive
constexpr float left() const
constexpr float top() const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
constexpr float width() const