26static const char*
gSpeech =
"Five score years ago, a great American, in whose symbolic shadow we stand today, signed the Emancipation Proclamation. This momentous decree came as a great beacon light of hope to millions of Negro slaves who had been seared in the flames of withering injustice. It came as a joyous daybreak to end the long night of their captivity.";
28#if defined(SK_UNICODE_ICU_IMPLEMENTATION)
32#if defined(SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION)
36#if defined(SK_UNICODE_ICU4X_IMPLEMENTATION)
43 kUseUnderline = 1 << 1,
44 kShowVisitor = 1 << 2,
48#if defined(SK_UNICODE_ICU_IMPLEMENTATION)
53#if defined(SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION)
58#if defined(SK_UNICODE_ICU4X_IMPLEMENTATION)
69 std::unique_ptr<skia::textlayout::Paragraph> fPara;
70 const unsigned fFlags;
81 if (
fFlags & kUseUnderline) {
96 auto collection = sk_make_sp<skia::textlayout::FontCollection>();
97 collection->setDefaultFontManager(std::move(fontmgr));
105 paraStyle, collection,
unicode);
124 name.printf(
"paragraph%s_%s",
125 fFlags & kTimeLayout ?
"_layout" :
"",
126 fFlags & kUseUnderline ?
"_underline" :
"");
127 if (
fFlags & kShowVisitor) {
128 name.append(
"_visitor");
134 if (
fFlags & kShowVisitor) {
142 p.setColor(0xFF0000FF);
162 std::vector<SkPoint>
pos;
163 for (
int i = 0;
i <
info->count; ++
i) {
165 info->origin.fY +
info->positions[
i].fY});
171 auto sects =
info->font.getIntercepts(
info->glyphs,
info->count,
pos.data(),
175 for (
size_t i = 0;
i < sects.size();
i += 2) {
180 x0 = sects[
i+1] + GAP;
186 if (
info->utf8Starts) {
188 for (int i = 0; i < info->count; ++i) {
189 str.appendUnichar(gSpeech[info->utf8Starts[i]]);
195 for (
int i = 0;
i <
info->count; ++
i) {
204 if (
nullptr == fPara) {
205 *errorMsg =
"Font manager had no fonts or could not build paragraph.";
206 return DrawResult::kSkip;
209 if (
fFlags & kShowVisitor) {
212 fPara->paint(canvas, 10, 10);
214 this->drawFromVisitor(canvas, fPara.get());
215 return DrawResult::kOk;
218 const int loop = (this->getMode() == kGM_Mode) ? 1 : 50;
221 for (
int i = 0;
i < loop; ++
i) {
224 if (
fFlags & kTimeLayout) {
225 fPara->layout(400 + parity);
226 parity = (parity + 1) & 1;
228 fPara->paint(canvas, 10, 10);
234 fPara->paint(canvas, 10, 10);
237 if ((this->getMode() == kGM_Mode) && (
fFlags & kTimeLayout)) {
238 return DrawResult::kSkip;
240 return DrawResult::kOk;
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
for(const auto glyph :glyphs)
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
#define INHERITED(method,...)
sk_sp< SkUnicode > get_unicode()
DrawResult onDraw(SkCanvas *canvas, SkString *errorMsg) override
bool runAsBench() const override
SkISize getISize() override
void onOnceBeforeDraw() override
SkString getName() const override
ParagraphGM(unsigned flags)
void drawFromVisitor(SkCanvas *canvas, skia::textlayout::Paragraph *para) const
bool onAnimate(double) override
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void drawGlyphs(int count, const SkGlyphID glyphs[], const SkPoint positions[], const uint32_t clusters[], int textByteCount, const char utf8text[], SkPoint origin, const SkFont &font, const SkPaint &paint)
void clear(SkColor color)
int countFamilies() const
void setColor(SkColor color)
void setAntiAlias(bool aa)
void setStrokeCap(Cap cap)
void setStrokeWidth(SkScalar width)
static std::unique_ptr< ParagraphBuilder > make(const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
void setFontFamilies(std::vector< SkString > families)
void setFontSize(SkScalar size)
void setForegroundColor(SkPaint paint)
void setDecorationColor(SkColor color)
void setDecoration(TextDecoration decoration)
void setDecorationMode(TextDecorationMode mode)
void setDecorationThicknessMultiplier(SkScalar m)
FlutterSemanticsFlag flags
SKUNICODE_API sk_sp< SkUnicode > Make()
SKUNICODE_API sk_sp< SkUnicode > Make()
SKUNICODE_API sk_sp< SkUnicode > Make()
DEF_SWITCHES_START aot vmservice shared library name
static const char * gSpeech
static constexpr SkISize Make(int32_t w, int32_t h)
void setTextStyle(const TextStyle &textStyle)