Flutter Engine
The Flutter Engine
paragraph_builder_skia.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LIB_TXT_SRC_PARAGRAPH_BUILDER_SKIA_H_
18#define LIB_TXT_SRC_PARAGRAPH_BUILDER_SKIA_H_
19
21
22#include "flutter/display_list/dl_paint.h"
24
25namespace txt {
26
27//------------------------------------------------------------------------------
28/// @brief ParagraphBuilder implementation using Skia's text layout module.
29///
30/// @note Despite the suffix "Skia", this class is not specific to Skia
31/// and is also used with the Impeller backend.
33 public:
35 std::shared_ptr<FontCollection> font_collection,
36 const bool impeller_enabled);
37
39
40 virtual void PushStyle(const TextStyle& style) override;
41 virtual void Pop() override;
42 virtual const TextStyle& PeekStyle() override;
43 virtual void AddText(const std::u16string& text) override;
44 virtual void AddPlaceholder(PlaceholderRun& span) override;
45 virtual std::unique_ptr<Paragraph> Build() override;
46
47 private:
49
51 const flutter::DlPaint& dl_paint);
54
55 std::shared_ptr<skia::textlayout::ParagraphBuilder> builder_;
56 TextStyle base_style_;
57
58 /// @brief Whether Impeller is enabled in the runtime.
59 ///
60 /// @note As of the time of this writing, this is used to draw text
61 /// decorations (i.e. dashed and dotted lines) directly using the
62 /// `drawLine` API, because Impeller's path rendering does not
63 /// support dashed and dotted lines (but Skia's does).
64 const bool impeller_enabled_;
65 std::stack<TextStyle> txt_style_stack_;
66 std::vector<flutter::DlPaint> dl_paints_;
67};
68
69} // namespace txt
70
71#endif // LIB_TXT_SRC_PARAGRAPH_BUILDER_SKIA_H_
ParagraphBuilder implementation using Skia's text layout module.
virtual const TextStyle & PeekStyle() override
ParagraphBuilderSkia(const ParagraphStyle &style, std::shared_ptr< FontCollection > font_collection, const bool impeller_enabled)
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
virtual void Pop() override
friend class SkiaParagraphBuilderTests_ParagraphStrutStyle_Test
std::u16string text