Flutter Engine
The Flutter Engine
ParagraphPainterImpl.cpp
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2
8
9#include <array>
10
11namespace skia {
12namespace textlayout {
13
15 : fOnLength(onLength), fOffLength(offLength) {}
16
19
22 std::optional<DashPathEffect> dashPathEffect)
23 : fColor(color), fStrokeWidth(strokeWidth), fDashPathEffect(dashPathEffect) {
25 fPaint.setAntiAlias(true);
26 fPaint.setColor(fColor);
27 fPaint.setStrokeWidth(fStrokeWidth);
28
29 if (fDashPathEffect) {
30 const std::array<SkScalar, 4> intervals =
31 {fDashPathEffect->fOnLength, fDashPathEffect->fOffLength,
32 fDashPathEffect->fOnLength, fDashPathEffect->fOffLength};
34 SkDashPathEffect::Make(intervals.data(), intervals.size(), 0.0f),
36 }
37}
38
40 : fCanvas(canvas) {}
41
43 SkASSERT(std::holds_alternative<SkPaint>(paint));
44 fCanvas->drawTextBlob(blob, x, y, std::get<SkPaint>(paint));
45}
46
49 paint.setColor(color);
50 if (blurSigma != 0.0) {
52 kNormal_SkBlurStyle, blurSigma, false);
53 paint.setMaskFilter(filter);
54 }
55 fCanvas->drawTextBlob(blob, x, y, paint);
56}
57
59 SkASSERT(std::holds_alternative<SkPaint>(paint));
60 fCanvas->drawRect(rect, std::get<SkPaint>(paint));
61}
62
64 SkPaint p(decorStyle.skPaint());
65 p.setStroke(false);
66 fCanvas->drawRect(rect, p);
67}
68
70 fCanvas->drawPath(path, decorStyle.skPaint());
71}
72
74 fCanvas->drawLine(x0, y0, x1, y1, decorStyle.skPaint());
75}
76
78 fCanvas->clipRect(rect);
79}
80
82 fCanvas->translate(dx, dy);
83}
84
86 fCanvas->save();
87}
88
90 fCanvas->restore();
91}
92
93} // namespace textlayout
94} // namespace skia
static const int strokeWidth
Definition: BlurTest.cpp:60
#define SkASSERT(cond)
Definition: SkAssert.h:116
@ kNormal_SkBlurStyle
fuzzy inside and outside
Definition: SkBlurTypes.h:12
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
int save()
Definition: SkCanvas.cpp:447
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void drawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2484
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static sk_sp< SkPathEffect > Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist=0)
static sk_sp< SkMaskFilter > MakeBlur(SkBlurStyle style, SkScalar sigma, bool respectCTM=true)
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
static sk_sp< SkPathEffect > MakeCompose(sk_sp< SkPathEffect > outer, sk_sp< SkPathEffect > inner)
Definition: SkPath.h:59
void drawPath(const SkPath &path, const DecorationStyle &decorStyle) override
void translate(SkScalar dx, SkScalar dy) override
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const DecorationStyle &decorStyle) override
void drawTextShadow(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, SkColor color, SkScalar blurSigma) override
void clipRect(const SkRect &rect) override
void drawFilledRect(const SkRect &rect, const DecorationStyle &decorStyle) override
void drawTextBlob(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y, const SkPaintOrID &paint) override
void drawRect(const SkRect &rect, const SkPaintOrID &paint) override
std::variant< SkPaint, PaintID > SkPaintOrID
const Paint & paint
Definition: color_source.cc:38
DlColor color
float SkScalar
Definition: extension.cpp:12
double y
double x
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
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
Definition: switches.h:57
Definition: DartTypes.h:13
Definition: ref_ptr.h:256
DashPathEffect(SkScalar onLength, SkScalar offLength)