#include <ParagraphCache.h>
Definition at line 18 of file ParagraphCache.h.
◆ ParagraphCache()
skia::textlayout::ParagraphCache::ParagraphCache |
( |
| ) |
|
Definition at line 241 of file ParagraphCache.cpp.
242 : fChecker([](ParagraphImpl* impl, const char*, bool){ })
243 , fLRUCacheMap(kMaxEntries)
244 , fCacheIsOn(true)
245 , fLastCachedValue(nullptr)
246#ifdef PARAGRAPH_CACHE_STATS
247 , fTotalRequests(0)
248 , fCacheMisses(0)
249 , fHashMisses(0)
250#endif
251{ }
◆ ~ParagraphCache()
skia::textlayout::ParagraphCache::~ParagraphCache |
( |
| ) |
|
◆ abandon()
void skia::textlayout::ParagraphCache::abandon |
( |
| ) |
|
◆ count()
int skia::textlayout::ParagraphCache::count |
( |
| ) |
|
|
inline |
◆ findParagraph()
bool skia::textlayout::ParagraphCache::findParagraph |
( |
ParagraphImpl * |
paragraph | ) |
|
Definition at line 300 of file ParagraphCache.cpp.
300 {
301 if (!fCacheIsOn) {
302 return false;
303 }
304#ifdef PARAGRAPH_CACHE_STATS
305 ++fTotalRequests;
306#endif
308 ParagraphCacheKey
key(paragraph);
309 std::unique_ptr<Entry>* entry = fLRUCacheMap.find(
key);
310
311 if (!entry) {
312
313#ifdef PARAGRAPH_CACHE_STATS
314 ++fCacheMisses;
315#endif
316 fChecker(paragraph, "missingParagraph", true);
317 return false;
318 }
319 updateTo(paragraph, entry->get());
320 fChecker(paragraph, "foundParagraph", true);
321 return true;
322}
◆ isPossiblyTextEditing()
bool skia::textlayout::ParagraphCache::isPossiblyTextEditing |
( |
ParagraphImpl * |
paragraph | ) |
|
Definition at line 354 of file ParagraphCache.cpp.
354 {
355 if (fLastCachedValue == nullptr) {
356 return false;
357 }
358
359 auto& lastText = fLastCachedValue->
fKey.
text();
360 auto&
text = paragraph->fText;
361
363
364 return false;
365 }
366
368
369 return true;
370 }
371
373
374 return true;
375 }
376
377
378 return false;
379}
#define NOCACHE_PREFIX_LENGTH
const SkString & text() const
◆ printStatistics()
void skia::textlayout::ParagraphCache::printStatistics |
( |
| ) |
|
Definition at line 275 of file ParagraphCache.cpp.
275 {
276 SkDebugf(
"--- Paragraph Cache ---\n");
277 SkDebugf(
"Total requests: %d\n", fTotalRequests);
278 SkDebugf(
"Cache misses: %d\n", fCacheMisses);
279 SkDebugf(
"Cache miss %%: %f\n", (fTotalRequests > 0) ? 100.f * fCacheMisses / fTotalRequests : 0.f);
280 int cacheHits = fTotalRequests - fCacheMisses;
281 SkDebugf(
"Hash miss %%: %f\n", (cacheHits > 0) ? 100.f * fHashMisses / cacheHits : 0.f);
282 SkDebugf(
"---------------------\n");
283}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
◆ reset()
void skia::textlayout::ParagraphCache::reset |
( |
| ) |
|
Definition at line 289 of file ParagraphCache.cpp.
289 {
291#ifdef PARAGRAPH_CACHE_STATS
292 fTotalRequests = 0;
293 fCacheMisses = 0;
294 fHashMisses = 0;
295#endif
296 fLRUCacheMap.reset();
297 fLastCachedValue = nullptr;
298}
◆ setChecker()
Definition at line 29 of file ParagraphCache.h.
29 {
30 fChecker = std::move(checker);
31 }
◆ turnOn()
void skia::textlayout::ParagraphCache::turnOn |
( |
bool |
value | ) |
|
|
inline |
◆ updateParagraph()
bool skia::textlayout::ParagraphCache::updateParagraph |
( |
ParagraphImpl * |
paragraph | ) |
|
Definition at line 324 of file ParagraphCache.cpp.
324 {
325 if (!fCacheIsOn) {
326 return false;
327 }
328#ifdef PARAGRAPH_CACHE_STATS
329 ++fTotalRequests;
330#endif
332
333 ParagraphCacheKey
key(paragraph);
334 std::unique_ptr<Entry>* entry = fLRUCacheMap.find(
key);
335 if (!entry) {
336
338
339 return false;
340 }
341 ParagraphCacheValue*
value =
new ParagraphCacheValue(std::move(
key), paragraph);
342 fLRUCacheMap.insert(
value->fKey, std::make_unique<Entry>(
value));
343 fChecker(paragraph, "addedParagraph", true);
344 fLastCachedValue =
value;
345 return true;
346 } else {
347
348 return false;
349 }
350}
bool isPossiblyTextEditing(ParagraphImpl *paragraph)
The documentation for this class was generated from the following files: