Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
skia::textlayout::ParagraphBuilderImpl Class Reference

#include <ParagraphBuilderImpl.h>

Inheritance diagram for skia::textlayout::ParagraphBuilderImpl:
skia::textlayout::ParagraphBuilder

Public Member Functions

 ParagraphBuilderImpl (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
 
 ParagraphBuilderImpl (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection)
 
 ~ParagraphBuilderImpl () override
 
void pushStyle (const TextStyle &style) override
 
void pop () override
 
TextStyle peekStyle () override
 
void addText (const std::u16string &text) override
 
void addText (const char *text) override
 
void addText (const char *text, size_t len) override
 
void addPlaceholder (const PlaceholderStyle &placeholderStyle) override
 
std::unique_ptr< ParagraphBuild () override
 
SkSpan< char > getText () override
 
const ParagraphStylegetParagraphStyle () const override
 
void Reset () override
 
- Public Member Functions inherited from skia::textlayout::ParagraphBuilder
virtual ~ParagraphBuilder ()=default
 

Static Public Member Functions

static std::unique_ptr< ParagraphBuildermake (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
 
static std::unique_ptr< ParagraphBuildermake (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection)
 
static bool RequiresClientICU ()
 
- Static Public Member Functions inherited from skia::textlayout::ParagraphBuilder
static std::unique_ptr< ParagraphBuildermake (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
 
static std::unique_ptr< ParagraphBuildermake (const ParagraphStyle &style, sk_sp< FontCollection > fontCollection)
 

Protected Member Functions

void startStyledBlock ()
 
void endRunIfNeeded ()
 
const TextStyleinternalPeekStyle ()
 
void addPlaceholder (const PlaceholderStyle &placeholderStyle, bool lastOne)
 
void finalize ()
 
- Protected Member Functions inherited from skia::textlayout::ParagraphBuilder
 ParagraphBuilder ()
 

Protected Attributes

SkString fUtf8
 
skia_private::STArray< 4, TextStyle, true > fTextStyles
 
skia_private::STArray< 4, Block, true > fStyledBlocks
 
skia_private::STArray< 4, Placeholder, true > fPlaceholders
 
sk_sp< FontCollectionfFontCollection
 
ParagraphStyle fParagraphStyle
 
sk_sp< SkUnicodefUnicode
 

Detailed Description

Definition at line 20 of file ParagraphBuilderImpl.h.

Constructor & Destructor Documentation

◆ ParagraphBuilderImpl() [1/2]

skia::textlayout::ParagraphBuilderImpl::ParagraphBuilderImpl ( const ParagraphStyle style,
sk_sp< FontCollection fontCollection,
sk_sp< SkUnicode unicode 
)

Definition at line 95 of file ParagraphBuilderImpl.cpp.

98 , fUtf8()
99 , fFontCollection(std::move(fontCollection))
100 , fParagraphStyle(style)
101 , fUnicode(std::move(unicode))
102#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
103 , fTextIsFinalized(false)
104 , fUsingClientInfo(false)
105#endif
106{
109}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ ParagraphBuilderImpl() [2/2]

skia::textlayout::ParagraphBuilderImpl::ParagraphBuilderImpl ( const ParagraphStyle style,
sk_sp< FontCollection fontCollection 
)

Definition at line 75 of file ParagraphBuilderImpl.cpp.

77 : ParagraphBuilderImpl(style, std::move(fontCollection), get_unicode())
78{ }
ParagraphBuilderImpl(const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
static sk_sp< SkUnicode > get_unicode()

◆ ~ParagraphBuilderImpl()

skia::textlayout::ParagraphBuilderImpl::~ParagraphBuilderImpl ( )
overridedefault

Member Function Documentation

◆ addPlaceholder() [1/2]

void skia::textlayout::ParagraphBuilderImpl::addPlaceholder ( const PlaceholderStyle placeholderStyle)
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 169 of file ParagraphBuilderImpl.cpp.

169 {
170#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
171 SkASSERT(!fTextIsFinalized);
172#endif
173 addPlaceholder(placeholderStyle, false);
174}
void addPlaceholder(const PlaceholderStyle &placeholderStyle) override

◆ addPlaceholder() [2/2]

void skia::textlayout::ParagraphBuilderImpl::addPlaceholder ( const PlaceholderStyle placeholderStyle,
bool  lastOne 
)
protected

Definition at line 176 of file ParagraphBuilderImpl.cpp.

176 {
177#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
178 // The very last placeholder is added automatically
179 // and only AFTER finalize() is called
180 SkASSERT(!fTextIsFinalized || lastOne);
181#endif
182 if (!fUtf8.isEmpty() && !lastOne) {
183 // We keep the very last text style
184 this->endRunIfNeeded();
185 }
186
187 BlockRange stylesBefore(fPlaceholders.empty() ? 0 : fPlaceholders.back().fBlocksBefore.end + 1,
189 TextRange textBefore(fPlaceholders.empty() ? 0 : fPlaceholders.back().fRange.end,
190 fUtf8.size());
191 auto start = fUtf8.size();
192 auto topStyle = internalPeekStyle();
193 if (!lastOne) {
194 pushStyle(topStyle.cloneForPlaceholder());
195 addText(std::u16string(1ull, 0xFFFC));
196 pop();
197 }
198 auto end = fUtf8.size();
199 fPlaceholders.emplace_back(start, end, placeholderStyle, topStyle, stylesBefore, textBefore);
200}
size_t size() const
Definition SkString.h:131
bool isEmpty() const
Definition SkString.h:130
skia_private::STArray< 4, Block, true > fStyledBlocks
skia_private::STArray< 4, Placeholder, true > fPlaceholders
void addText(const std::u16string &text) override
void pushStyle(const TextStyle &style) override
glong glong end
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
SkRange< size_t > TextRange
Definition TextStyle.h:337
SkRange< size_t > BlockRange
Definition TextStyle.h:356

◆ addText() [1/3]

void skia::textlayout::ParagraphBuilderImpl::addText ( const char *  text)
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 155 of file ParagraphBuilderImpl.cpp.

155 {
156#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
157 SkASSERT(!fTextIsFinalized);
158#endif
160}
void append(const char text[])
Definition SkString.h:203
std::u16string text

◆ addText() [2/3]

void skia::textlayout::ParagraphBuilderImpl::addText ( const char *  text,
size_t  len 
)
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 162 of file ParagraphBuilderImpl.cpp.

162 {
163#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
164 SkASSERT(!fTextIsFinalized);
165#endif
166 fUtf8.append(text, len);
167}

◆ addText() [3/3]

void skia::textlayout::ParagraphBuilderImpl::addText ( const std::u16string &  text)
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 147 of file ParagraphBuilderImpl.cpp.

147 {
148#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
149 SkASSERT(!fTextIsFinalized);
150#endif
152 fUtf8.append(utf8);
153}
static SkString convertUtf16ToUtf8(const char16_t *utf16, int utf16Units)
Definition SkUnicode.cpp:14

◆ Build()

std::unique_ptr< Paragraph > skia::textlayout::ParagraphBuilderImpl::Build ( )
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 235 of file ParagraphBuilderImpl.cpp.

235 {
236 this->finalize();
237 // Add one fake placeholder with the rest of the text
238 this->addPlaceholder(PlaceholderStyle(), true);
239
240 fUTF8IndexForUTF16Index.clear();
241 fUTF16IndexForUTF8Index.clear();
242#if !defined(SK_DISABLE_LEGACY_PARAGRAPH_UNICODE) && defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
243 if (fUsingClientInfo && !fUnicode) {
244 // This is the place where SkUnicode is paired with SkParagraph
246 std::move(fWordsUtf16),
247 std::move(fGraphemeBreaksUtf8),
248 std::move(fLineBreaksUtf8));
249 }
250#endif
251
253 return std::make_unique<ParagraphImpl>(
255}
#define SkASSERT_RELEASE(cond)
Definition SkAssert.h:100
SKUNICODE_API sk_sp< SkUnicode > Make(SkSpan< char > text, std::vector< SkUnicode::Position > words, std::vector< SkUnicode::Position > graphemeBreaks, std::vector< SkUnicode::LineBreakBefore > lineBreaks)

◆ endRunIfNeeded()

void skia::textlayout::ParagraphBuilderImpl::endRunIfNeeded ( )
protected

Definition at line 202 of file ParagraphBuilderImpl.cpp.

202 {
203 if (fStyledBlocks.empty()) {
204 return;
205 }
206
207 auto& last = fStyledBlocks.back();
208 if (last.fRange.start == fUtf8.size()) {
209 fStyledBlocks.pop_back();
210 } else {
211 last.fRange.end = fUtf8.size();
212 }
213}

◆ finalize()

void skia::textlayout::ParagraphBuilderImpl::finalize ( )
protected

Definition at line 220 of file ParagraphBuilderImpl.cpp.

220 {
221#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
222 if (fTextIsFinalized) {
223 return;
224 }
225#endif
226 if (!fUtf8.isEmpty()) {
227 this->endRunIfNeeded();
228 }
229
230#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
231 fTextIsFinalized = true;
232#endif
233}

◆ getParagraphStyle()

const ParagraphStyle & skia::textlayout::ParagraphBuilderImpl::getParagraphStyle ( ) const
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 262 of file ParagraphBuilderImpl.cpp.

262 {
263 return fParagraphStyle;
264}

◆ getText()

SkSpan< char > skia::textlayout::ParagraphBuilderImpl::getText ( )
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 257 of file ParagraphBuilderImpl.cpp.

257 {
258 this->finalize();
259 return SkSpan<char>(fUtf8.isEmpty() ? nullptr : fUtf8.data(), fUtf8.size());
260}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ internalPeekStyle()

const TextStyle & skia::textlayout::ParagraphBuilderImpl::internalPeekStyle ( )
protected

Definition at line 135 of file ParagraphBuilderImpl.cpp.

135 {
136 if (fTextStyles.empty()) {
138 } else {
139 return fTextStyles.back();
140 }
141}
skia_private::STArray< 4, TextStyle, true > fTextStyles
const TextStyle & getTextStyle() const

◆ make() [1/2]

std::unique_ptr< ParagraphBuilder > skia::textlayout::ParagraphBuilderImpl::make ( const ParagraphStyle style,
sk_sp< FontCollection fontCollection 
)
static

Definition at line 70 of file ParagraphBuilderImpl.cpp.

71 {
72 return std::make_unique<ParagraphBuilderImpl>(style, std::move(fontCollection), get_unicode());
73}

◆ make() [2/2]

std::unique_ptr< ParagraphBuilder > skia::textlayout::ParagraphBuilderImpl::make ( const ParagraphStyle style,
sk_sp< FontCollection fontCollection,
sk_sp< SkUnicode unicode 
)
static

Definition at line 88 of file ParagraphBuilderImpl.cpp.

90 {
91 return std::make_unique<ParagraphBuilderImpl>(style, std::move(fontCollection),
92 std::move(unicode));
93}

◆ peekStyle()

TextStyle skia::textlayout::ParagraphBuilderImpl::peekStyle ( )
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 143 of file ParagraphBuilderImpl.cpp.

143 {
144 return this->internalPeekStyle();
145}

◆ pop()

void skia::textlayout::ParagraphBuilderImpl::pop ( )
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 124 of file ParagraphBuilderImpl.cpp.

124 {
125 if (!fTextStyles.empty()) {
126 fTextStyles.pop_back();
127 } else {
128 // In this case we use paragraph style and skip Pop operation
129 SkDEBUGF("SkParagraphBuilder.Pop() called too many times.\n");
130 }
131
132 this->startStyledBlock();
133}
#define SkDEBUGF(...)
Definition SkDebug.h:24

◆ pushStyle()

void skia::textlayout::ParagraphBuilderImpl::pushStyle ( const TextStyle style)
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 113 of file ParagraphBuilderImpl.cpp.

113 {
114 fTextStyles.push_back(style);
115 if (!fStyledBlocks.empty() && fStyledBlocks.back().fRange.end == fUtf8.size() &&
116 fStyledBlocks.back().fStyle == style) {
117 // Just continue with the same style
118 } else {
119 // Go with the new style
121 }
122}

◆ RequiresClientICU()

bool skia::textlayout::ParagraphBuilderImpl::RequiresClientICU ( )
static

Definition at line 337 of file ParagraphBuilderImpl.cpp.

337 {
338#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
339 return true;
340#else
341 return false;
342#endif
343}

◆ Reset()

void skia::textlayout::ParagraphBuilderImpl::Reset ( )
overridevirtual

Implements skia::textlayout::ParagraphBuilder.

Definition at line 320 of file ParagraphBuilderImpl.cpp.

320 {
321
322 fTextStyles.clear();
323 fUtf8.reset();
324 fStyledBlocks.clear();
325 fPlaceholders.clear();
326 fUTF8IndexForUTF16Index.clear();
327 fUTF16IndexForUTF8Index.clear();
328#if defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
329 fWordsUtf16.clear();
330 fGraphemeBreaksUtf8.clear();
331 fLineBreaksUtf8.clear();
332 fTextIsFinalized = false;
333#endif
335}
void reset()
Definition SkString.cpp:358

◆ startStyledBlock()

void skia::textlayout::ParagraphBuilderImpl::startStyledBlock ( )
protected

Definition at line 215 of file ParagraphBuilderImpl.cpp.

215 {
217 fStyledBlocks.emplace_back(fUtf8.size(), fUtf8.size(), internalPeekStyle());
218}

Member Data Documentation

◆ fFontCollection

sk_sp<FontCollection> skia::textlayout::ParagraphBuilderImpl::fFontCollection
protected

Definition at line 116 of file ParagraphBuilderImpl.h.

◆ fParagraphStyle

ParagraphStyle skia::textlayout::ParagraphBuilderImpl::fParagraphStyle
protected

Definition at line 117 of file ParagraphBuilderImpl.h.

◆ fPlaceholders

skia_private::STArray<4, Placeholder, true> skia::textlayout::ParagraphBuilderImpl::fPlaceholders
protected

Definition at line 115 of file ParagraphBuilderImpl.h.

◆ fStyledBlocks

skia_private::STArray<4, Block, true> skia::textlayout::ParagraphBuilderImpl::fStyledBlocks
protected

Definition at line 114 of file ParagraphBuilderImpl.h.

◆ fTextStyles

skia_private::STArray<4, TextStyle, true> skia::textlayout::ParagraphBuilderImpl::fTextStyles
protected

Definition at line 113 of file ParagraphBuilderImpl.h.

◆ fUnicode

sk_sp<SkUnicode> skia::textlayout::ParagraphBuilderImpl::fUnicode
protected

Definition at line 119 of file ParagraphBuilderImpl.h.

◆ fUtf8

SkString skia::textlayout::ParagraphBuilderImpl::fUtf8
protected

Definition at line 112 of file ParagraphBuilderImpl.h.


The documentation for this class was generated from the following files: