Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skia::textlayout::ParagraphCacheKey Class Reference

Public Member Functions

 ParagraphCacheKey (const ParagraphImpl *paragraph)
 
 ParagraphCacheKey (const ParagraphCacheKey &other)=default
 
 ParagraphCacheKey (ParagraphCacheKey &&other)
 
bool operator== (const ParagraphCacheKey &other) const
 
uint32_t hash () const
 
const SkStringtext () const
 

Detailed Description

Definition at line 31 of file ParagraphCache.cpp.

Constructor & Destructor Documentation

◆ ParagraphCacheKey() [1/3]

skia::textlayout::ParagraphCacheKey::ParagraphCacheKey ( const ParagraphImpl paragraph)
inline

Definition at line 33 of file ParagraphCache.cpp.

34 : fText(paragraph->fText.c_str(), paragraph->fText.size())
35 , fPlaceholders(paragraph->fPlaceholders)
36 , fTextStyles(paragraph->fTextStyles)
37 , fParagraphStyle(paragraph->paragraphStyle()) {
38 fHash = computeHash();
39 }

◆ ParagraphCacheKey() [2/3]

skia::textlayout::ParagraphCacheKey::ParagraphCacheKey ( const ParagraphCacheKey other)
default

◆ ParagraphCacheKey() [3/3]

skia::textlayout::ParagraphCacheKey::ParagraphCacheKey ( ParagraphCacheKey &&  other)
inline

Definition at line 43 of file ParagraphCache.cpp.

44 : fText(std::move(other.fText))
45 , fPlaceholders(std::move(other.fPlaceholders))
46 , fTextStyles(std::move(other.fTextStyles))
47 , fParagraphStyle(std::move(other.fParagraphStyle))
48 , fHash(other.fHash) {
49 other.fHash = 0;
50 }

Member Function Documentation

◆ hash()

uint32_t skia::textlayout::ParagraphCacheKey::hash ( ) const
inline

Definition at line 54 of file ParagraphCache.cpp.

54{ return fHash; }

◆ operator==()

bool skia::textlayout::ParagraphCacheKey::operator== ( const ParagraphCacheKey other) const

Definition at line 169 of file ParagraphCache.cpp.

169 {
170 if (fText.size() != other.fText.size()) {
171 return false;
172 }
173 if (fPlaceholders.size() != other.fPlaceholders.size()) {
174 return false;
175 }
176 if (fText != other.fText) {
177 return false;
178 }
179 if (fTextStyles.size() != other.fTextStyles.size()) {
180 return false;
181 }
182
183 // There is no need to compare default paragraph styles - they are included into fTextStyles
184 if (!exactlyEqual(fParagraphStyle.getHeight(), other.fParagraphStyle.getHeight())) {
185 return false;
186 }
187 if (fParagraphStyle.getTextDirection() != other.fParagraphStyle.getTextDirection()) {
188 return false;
189 }
190
191 if (!(fParagraphStyle.getStrutStyle() == other.fParagraphStyle.getStrutStyle())) {
192 return false;
193 }
194
195 if (!(fParagraphStyle.getReplaceTabCharacters() == other.fParagraphStyle.getReplaceTabCharacters())) {
196 return false;
197 }
198
199 for (int i = 0; i < fTextStyles.size(); ++i) {
200 auto& tsa = fTextStyles[i];
201 auto& tsb = other.fTextStyles[i];
202 if (tsa.fStyle.isPlaceholder()) {
203 continue;
204 }
205 if (!(tsa.fStyle.equalsByFonts(tsb.fStyle))) {
206 return false;
207 }
208 if (tsa.fRange.width() != tsb.fRange.width()) {
209 return false;
210 }
211 if (tsa.fRange.start != tsb.fRange.start) {
212 return false;
213 }
214 }
215 for (int i = 0; i < fPlaceholders.size(); ++i) {
216 auto& tsa = fPlaceholders[i];
217 auto& tsb = other.fPlaceholders[i];
218 if (tsa.fRange.width() == 0 && tsb.fRange.width() == 0) {
219 continue;
220 }
221 if (!(tsa.fStyle.equals(tsb.fStyle))) {
222 return false;
223 }
224 if (tsa.fRange.width() != tsb.fRange.width()) {
225 return false;
226 }
227 if (tsa.fRange.start != tsb.fRange.start) {
228 return false;
229 }
230 }
231
232 return true;
233}
size_t size() const
Definition: SkString.h:131
const StrutStyle & getStrutStyle() const
TextDirection getTextDirection() const

◆ text()

const SkString & skia::textlayout::ParagraphCacheKey::text ( ) const
inline

Definition at line 56 of file ParagraphCache.cpp.

56{ return fText; }

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