Flutter Engine
The Flutter Engine
third_party
skia
src
text
gpu
StrikeCache.h
Go to the documentation of this file.
1
/*
2
* Copyright 2015 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#ifndef sktext_gpu_StrikeCache_DEFINED
9
#define sktext_gpu_StrikeCache_DEFINED
10
11
#include "
include/core/SkRefCnt.h
"
12
#include "
src/base/SkArenaAlloc.h
"
13
#include "
src/core/SkDescriptor.h
"
14
#include "
src/core/SkStrikeSpec.h
"
15
#include "
src/core/SkTHash.h
"
16
17
#include <cstdint>
18
19
struct
SkPackedGlyphID
;
20
21
namespace
sktext::gpu
{
22
23
class
Glyph
;
24
25
// The TextStrike manages an SkArenaAlloc for Glyphs. The SkStrike is what actually creates
26
// the mask. The TextStrike may outlive the generating SkStrike. However, it retains a copy
27
// of it's SkDescriptor as a key to access (or regenerate) the SkStrike. TextStrikes are
28
// created by and owned by a StrikeCache.
29
class
TextStrike
:
public
SkNVRefCnt
<TextStrike> {
30
public
:
31
TextStrike
(
const
SkStrikeSpec
&
strikeSpec
);
32
33
Glyph
*
getGlyph
(
SkPackedGlyphID
);
34
const
SkStrikeSpec
&
strikeSpec
()
const
{
return
fStrikeSpec; }
35
36
private
:
37
// Key for retrieving the SkStrike for creating new atlas data.
38
const
SkStrikeSpec
fStrikeSpec;
39
40
struct
HashTraits {
41
static
const
SkPackedGlyphID
& GetKey(
const
Glyph
* glyph);
42
static
uint32_t
Hash
(
SkPackedGlyphID
key
);
43
};
44
// Map SkPackedGlyphID -> Glyph*.
45
skia_private::THashTable<Glyph*, SkPackedGlyphID, HashTraits>
fCache;
46
47
// Store for the glyph information.
48
SkArenaAlloc
fAlloc{512};
49
50
friend
class
StrikeCache
;
51
};
52
53
// StrikeCache manages strikes which are indexed by a SkStrike. These strikes can then be
54
// used to generate individual Glyph Masks.
55
class
StrikeCache
{
56
public
:
57
~StrikeCache
();
58
59
// The user of the cache may hold a long-lived ref to the returned strike.
60
sk_sp<TextStrike>
findOrCreateStrike
(
const
SkStrikeSpec
& strikeSpec);
61
62
void
freeAll
();
63
64
private
:
65
sk_sp<TextStrike>
generateStrike(
const
SkStrikeSpec
& strikeSpec);
66
67
struct
HashTraits {
68
static
const
SkDescriptor
& GetKey(
const
sk_sp<TextStrike>
& strike);
69
static
uint32_t
Hash
(
const
SkDescriptor
& strikeSpec);
70
};
71
72
using
StrikeHash
=
skia_private::THashTable<sk_sp<TextStrike>
,
const
SkDescriptor
&, HashTraits>;
73
74
StrikeHash
fCache;
75
};
76
77
}
// namespace sktext::gpu
78
79
#endif
// sktext_gpu_StrikeCache_DEFINED
SkArenaAlloc.h
SkDescriptor.h
SkRefCnt.h
SkStrikeSpec.h
SkTHash.h
SkArenaAlloc
Definition:
SkArenaAlloc.h:105
SkDescriptor
Definition:
SkDescriptor.h:25
SkNVRefCnt
Definition:
SkRefCnt.h:160
SkStrikeSpec
Definition:
SkStrikeSpec.h:39
sk_sp
Definition:
SkRefCnt.h:220
skia_private::THashTable
Definition:
SkTHash.h:32
sktext::gpu::Glyph
Definition:
Glyph.h:17
sktext::gpu::StrikeCache
Definition:
StrikeCache.h:55
sktext::gpu::StrikeCache::~StrikeCache
~StrikeCache()
Definition:
StrikeCache.cpp:26
sktext::gpu::StrikeCache::findOrCreateStrike
sk_sp< TextStrike > findOrCreateStrike(const SkStrikeSpec &strikeSpec)
Definition:
StrikeCache.cpp:34
sktext::gpu::StrikeCache::freeAll
void freeAll()
Definition:
StrikeCache.cpp:30
sktext::gpu::TextStrike
Definition:
StrikeCache.h:29
sktext::gpu::TextStrike::TextStrike
TextStrike(const SkStrikeSpec &strikeSpec)
Definition:
StrikeCache.cpp:55
sktext::gpu::TextStrike::getGlyph
Glyph * getGlyph(SkPackedGlyphID)
Definition:
StrikeCache.cpp:57
sktext::gpu::TextStrike::strikeSpec
const SkStrikeSpec & strikeSpec() const
Definition:
StrikeCache.h:34
key
int key
Definition:
keyboard_key_handler_unittests.cc:114
dart::Hash
static uint32_t Hash(uint32_t key)
Definition:
hashmap_test.cc:65
sktext::gpu
Definition:
SkCanvas.h:81
SkPackedGlyphID
Definition:
SkGlyph.h:46
Generated on Sun Jun 23 2024 21:56:36 for Flutter Engine by
1.9.4