Flutter Engine
 
Loading...
Searching...
No Matches
text_types.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_LIB_WEB_UI_SKWASM_TEXT_TEXT_TYPES_H_
6#define FLUTTER_LIB_WEB_UI_SKWASM_TEXT_TEXT_TYPES_H_
7
9#include "third_party/skia/modules/skparagraph/include/Paragraph.h"
10#include "third_party/skia/modules/skparagraph/include/ParagraphBuilder.h"
11
12#include <optional>
13#include <vector>
14
15namespace Skwasm {
16struct TextStyle {
17 skia::textlayout::TextStyle skiaStyle;
18 std::optional<flutter::DlPaint> foreground;
19 std::optional<flutter::DlPaint> background;
20
21 void populatePaintIds(std::vector<flutter::DlPaint>& paints) {
22 if (background) {
23 skiaStyle.setBackgroundPaintID(paints.size());
24 paints.push_back(*background);
25 }
26 if (foreground) {
27 skiaStyle.setForegroundPaintID(paints.size());
28 paints.push_back(*foreground);
29 } else {
30 flutter::DlPaint paint;
31 paint.setColor(flutter::DlColor(skiaStyle.getColor()));
32 skiaStyle.setForegroundPaintID(paints.size());
33 paints.push_back(std::move(paint));
34 }
35 }
36};
37
39 skia::textlayout::ParagraphStyle skiaParagraphStyle;
41};
42
44 std::unique_ptr<skia::textlayout::ParagraphBuilder> skiaParagraphBuilder;
45 std::vector<flutter::DlPaint> paints;
46};
47
48struct Paragraph {
49 std::unique_ptr<skia::textlayout::Paragraph> skiaParagraph;
50 std::vector<flutter::DlPaint> paints;
51};
52} // namespace Skwasm
53
54#endif // FLUTTER_LIB_WEB_UI_SKWASM_TEXT_TEXT_TYPES_H_
DlPaint & setColor(DlColor color)
Definition dl_paint.h:70
std::vector< flutter::DlPaint > paints
Definition text_types.h:45
std::unique_ptr< skia::textlayout::ParagraphBuilder > skiaParagraphBuilder
Definition text_types.h:44
std::unique_ptr< skia::textlayout::Paragraph > skiaParagraph
Definition text_types.h:49
std::vector< flutter::DlPaint > paints
Definition text_types.h:50
skia::textlayout::ParagraphStyle skiaParagraphStyle
Definition text_types.h:39
std::optional< flutter::DlPaint > background
Definition text_types.h:19
std::optional< flutter::DlPaint > foreground
Definition text_types.h:18
void populatePaintIds(std::vector< flutter::DlPaint > &paints)
Definition text_types.h:21
skia::textlayout::TextStyle skiaStyle
Definition text_types.h:17