Flutter Engine
The Flutter Engine
third_party
skia
modules
skparagraph
include
ParagraphCache.h
Go to the documentation of this file.
1
// Copyright 2019 Google LLC.
2
#ifndef ParagraphCache_DEFINED
3
#define ParagraphCache_DEFINED
4
5
#include "
include/private/base/SkMutex.h
"
6
#include "
src/core/SkLRUCache.h
"
7
#include <functional>
// std::function
8
9
#define PARAGRAPH_CACHE_STATS
10
11
namespace
skia
{
12
namespace
textlayout {
13
14
class
ParagraphImpl;
15
class
ParagraphCacheKey;
16
class
ParagraphCacheValue;
17
18
class
ParagraphCache
{
19
public
:
20
ParagraphCache
();
21
~ParagraphCache
();
22
23
void
abandon
();
24
void
reset
();
25
bool
updateParagraph
(
ParagraphImpl
* paragraph);
26
bool
findParagraph
(
ParagraphImpl
* paragraph);
27
28
// For testing
29
void
setChecker
(
std::function
<
void
(
ParagraphImpl
* impl,
const
char
*,
bool
)> checker) {
30
fChecker = std::move(checker);
31
}
32
void
printStatistics
();
33
void
turnOn
(
bool
value
) { fCacheIsOn =
value
; }
34
int
count
() {
return
fLRUCacheMap.count(); }
35
36
bool
isPossiblyTextEditing
(
ParagraphImpl
* paragraph);
37
38
private
:
39
40
struct
Entry
;
41
void
updateFrom(
const
ParagraphImpl
* paragraph,
Entry
* entry);
42
void
updateTo(
ParagraphImpl
* paragraph,
const
Entry
* entry);
43
44
mutable
SkMutex fParagraphMutex;
45
std::function
<void(
ParagraphImpl
* impl,
const
char
*,
bool
)> fChecker;
46
47
static
const
int
kMaxEntries = 128;
48
49
struct
KeyHash {
50
uint32_t operator()(
const
ParagraphCacheKey
&
key
)
const
;
51
};
52
53
SkLRUCache<ParagraphCacheKey, std::unique_ptr<Entry>
, KeyHash> fLRUCacheMap;
54
bool
fCacheIsOn;
55
ParagraphCacheValue* fLastCachedValue;
56
57
#ifdef PARAGRAPH_CACHE_STATS
58
int
fTotalRequests;
59
int
fCacheMisses;
60
int
fHashMisses;
// cache hit but hash table missed
61
#endif
62
};
63
64
}
// namespace textlayout
65
}
// namespace skia
66
67
#endif
// ParagraphCache_DEFINED
SkLRUCache.h
SkMutex.h
SkLRUCache
Definition:
SkLRUCache.h:19
skia::textlayout::ParagraphCacheKey
Definition:
ParagraphCache.cpp:31
skia::textlayout::ParagraphCache
Definition:
ParagraphCache.h:18
skia::textlayout::ParagraphCache::turnOn
void turnOn(bool value)
Definition:
ParagraphCache.h:33
skia::textlayout::ParagraphCache::setChecker
void setChecker(std::function< void(ParagraphImpl *impl, const char *, bool)> checker)
Definition:
ParagraphCache.h:29
skia::textlayout::ParagraphCache::printStatistics
void printStatistics()
Definition:
ParagraphCache.cpp:275
skia::textlayout::ParagraphCache::ParagraphCache
ParagraphCache()
Definition:
ParagraphCache.cpp:241
skia::textlayout::ParagraphCache::abandon
void abandon()
Definition:
ParagraphCache.cpp:285
skia::textlayout::ParagraphCache::updateParagraph
bool updateParagraph(ParagraphImpl *paragraph)
Definition:
ParagraphCache.cpp:324
skia::textlayout::ParagraphCache::findParagraph
bool findParagraph(ParagraphImpl *paragraph)
Definition:
ParagraphCache.cpp:300
skia::textlayout::ParagraphCache::count
int count()
Definition:
ParagraphCache.h:34
skia::textlayout::ParagraphCache::isPossiblyTextEditing
bool isPossiblyTextEditing(ParagraphImpl *paragraph)
Definition:
ParagraphCache.cpp:354
skia::textlayout::ParagraphCache::reset
void reset()
Definition:
ParagraphCache.cpp:289
skia::textlayout::ParagraphCache::~ParagraphCache
~ParagraphCache()
Definition:
ParagraphCache.cpp:253
skia::textlayout::ParagraphImpl
Definition:
ParagraphImpl.h:88
value
uint8_t value
Definition:
fl_standard_message_codec.cc:36
function
Dart_NativeFunction function
Definition:
fuchsia.cc:51
key
int key
Definition:
keyboard_key_handler_unittests.cc:114
convert_manifest_to_json.Entry
Entry
Definition:
convert_manifest_to_json.py:16
skia
Definition:
DartTypes.h:13
Generated on Sun Jun 23 2024 21:56:06 for Flutter Engine by
1.9.4