Flutter Engine
 
Loading...
Searching...
No Matches
paragraph_builder_skia.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_TXT_SRC_SKIA_PARAGRAPH_BUILDER_SKIA_H_
6#define FLUTTER_TXT_SRC_SKIA_PARAGRAPH_BUILDER_SKIA_H_
7
9
11#include "third_party/skia/modules/skparagraph/include/ParagraphBuilder.h"
12
13namespace txt {
14
15//------------------------------------------------------------------------------
16/// @brief ParagraphBuilder implementation using Skia's text layout module.
17///
18/// @note Despite the suffix "Skia", this class is not specific to Skia
19/// and is also used with the Impeller backend.
21 public:
23 const std::shared_ptr<FontCollection>& font_collection,
24 const bool impeller_enabled);
25
27
28 virtual void PushStyle(const TextStyle& style) override;
29 virtual void Pop() override;
30 virtual const TextStyle& PeekStyle() override;
31 virtual void AddText(const std::u16string& text) override;
32 virtual void AddText(const uint8_t* utf8_data, size_t byte_length) override;
33 virtual void AddPlaceholder(PlaceholderRun& span) override;
34 virtual std::unique_ptr<Paragraph> Build() override;
35
36 private:
38
39 skia::textlayout::ParagraphPainter::PaintID CreatePaintID(
40 const flutter::DlPaint& dl_paint);
41 skia::textlayout::ParagraphStyle TxtToSkia(const ParagraphStyle& txt);
42 skia::textlayout::TextStyle TxtToSkia(const TextStyle& txt);
43
44 std::shared_ptr<skia::textlayout::ParagraphBuilder> builder_;
45 TextStyle base_style_;
46
47 /// @brief Whether Impeller is enabled in the runtime.
48 ///
49 /// @note As of the time of this writing, this is used to draw text
50 /// decorations (i.e. dashed and dotted lines) directly using the
51 /// `drawLine` API, because Impeller's path rendering does not
52 /// support dashed and dotted lines (but Skia's does).
53 const bool impeller_enabled_;
54 std::stack<TextStyle> txt_style_stack_;
55 std::vector<flutter::DlPaint> dl_paints_;
56};
57
58} // namespace txt
59
60#endif // FLUTTER_TXT_SRC_SKIA_PARAGRAPH_BUILDER_SKIA_H_
ParagraphBuilder implementation using Skia's text layout module.
virtual const TextStyle & PeekStyle() override
virtual void PushStyle(const TextStyle &style) override
virtual std::unique_ptr< Paragraph > Build() override
virtual void AddText(const std::u16string &text) override
virtual void AddPlaceholder(PlaceholderRun &span) override
friend class SkiaParagraphBuilderTests_ParagraphStrutStyle_Test
std::u16string text