26 return std::unique_ptr<SkStreamAsset>(fFCI->
openStream(this->getIdentity()));
31 return std::make_unique<SkFontData>(std::unique_ptr<SkStreamAsset>(fFCI->
openStream(
id)),
32 id.fTTCIndex, 0,
nullptr, 0,
nullptr, 0);
38 desc->setFamilyName(
name.c_str());
50 int count()
override {
return 0; }
64 char*
content =
const_cast<char*
>(SkTAfter<const char>(&this->fStyle));
70 SkASSERT((
content -
reinterpret_cast<char*
>(
this)) %
sizeof(uint32_t) == 0);
72 size_t contentLen =
SkAlign4(nameLen);
75 this->
init(
nullptr, 0, keySize + contentLen);
79 static const size_t keySize =
sizeof(
fStyle);
83 size_t nameLen =
name ? strlen(
name) : 0;
84 size_t contentLen =
SkAlign4(nameLen);
85 char* storage =
new char[
sizeof(
Request) + contentLen];
88 void operator delete(
void* storage) {
89 delete[]
reinterpret_cast<char*
>(storage);
97 : fRequest(request), fFace(
std::move(typeface)) {}
98 Result(Result&&) =
default;
99 Result& operator=(Result&&) =
default;
101 const Key& getKey()
const override {
return *fRequest; }
102 size_t bytesUsed()
const override {
return fRequest->
size() +
sizeof(fFace); }
103 const char* getCategory()
const override {
return "request_cache"; }
106 std::unique_ptr<Request> fRequest;
117 fCachedResults.
add(
new Result(request, std::move(face)));
123 const Result&
result =
static_cast<const Result&
>(rec);
138 FontIdentity* identity =
static_cast<FontIdentity*
>(ctx);
140 return cachedFCTypeface->
getIdentity() == *identity;
148 mutable SkMutex fMutex;
153 static const size_t kMaxSize = 1 << 15;
158 : fFCI(
std::move(fci))
188 std::unique_ptr<Request> request(Request::Create(requestedFamilyName, requestedStyle));
197 if (!fFCI->matchFamilyName(requestedFamilyName, requestedStyle,
198 &identity, &outFamilyName, &outStyle))
217 const char* bcp47[],
int bcp47Count,
227 int ttcIndex)
const override {
234 const size_t length = stream->getLength();
238 if (
length >= 1024 * 1024 * 1024) {
247 return stream ? this->
makeFromStream(std::move(stream), ttcIndex) :
nullptr;
258 return sk_make_sp<SkFontMgr_FCI>(std::move(fci));
SkStrokeRec::Style fStyle
static constexpr T SkAlign4(T x)
#define SK_ABORT(message,...)
#define SkASSERT_RELEASE(cond)
SK_API sk_sp< SkFontMgr > SkFontMgr_New_FCI(sk_sp< SkFontConfigInterface > fci)
static bool find_by_FontIdentity(SkTypeface *cachedTypeface, void *ctx)
static void sk_bzero(void *buffer, size_t size)
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
virtual SkStreamAsset * openStream(const FontIdentity &)=0
void setFactoryId(SkTypeface::FactoryId factoryId)
sk_sp< SkTypeface > onMakeFromData(sk_sp< SkData > data, int ttcIndex) const override
sk_sp< SkTypeface > onMakeFromStreamIndex(std::unique_ptr< SkStreamAsset > stream, int ttcIndex) const override
sk_sp< SkTypeface > onMatchFamilyStyle(const char requestedFamilyName[], const SkFontStyle &requestedStyle) const override
sk_sp< SkTypeface > onMakeFromFile(const char path[], int ttcIndex) const override
sk_sp< SkFontStyleSet > onMatchFamily(const char familyName[]) const override
SkFontMgr_FCI(sk_sp< SkFontConfigInterface > fci)
int onCountFamilies() const override
sk_sp< SkTypeface > onMakeFromStreamArgs(std::unique_ptr< SkStreamAsset > stream, const SkFontArguments &args) const override
sk_sp< SkFontStyleSet > onCreateStyleSet(int index) const override
void onGetFamilyName(int index, SkString *familyName) const override
sk_sp< SkTypeface > onLegacyMakeTypeface(const char requestedFamilyName[], SkFontStyle requestedStyle) const override
sk_sp< SkTypeface > onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &, const char *bcp47[], int bcp47Count, SkUnichar character) const override
sk_sp< SkTypeface > makeFromStream(std::unique_ptr< SkStreamAsset >, int ttcIndex=0) const
SkFontRequestCache(size_t maxSize)
void add(sk_sp< SkTypeface > face, Request *request)
sk_sp< SkTypeface > findAndRef(Request *request)
sk_sp< SkTypeface > createTypeface(int index) override
void getStyle(int index, SkFontStyle *, SkString *style) override
sk_sp< SkTypeface > matchStyle(const SkFontStyle &pattern) override
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
bool find(const Key &, FindVisitor, void *context)
void add(Rec *, void *payload=nullptr)
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
sk_sp< SkTypeface > findByProcAndRef(FindProc proc, void *ctx) const
void add(sk_sp< SkTypeface >)
const SkFontConfigInterface::FontIdentity & getIdentity() const
void onGetFontDescriptor(SkFontDescriptor *, bool *) const override
std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const override
std::unique_ptr< SkFontData > onMakeFontData() const override
static SkTypeface_FCI * Create(sk_sp< SkFontConfigInterface > fci, const SkFontConfigInterface::FontIdentity &fi, SkString familyName, const SkFontStyle &style)
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
void getFamilyName(SkString *name) const
SkFontStyle fontStyle() const
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
void reset(T *ptr=nullptr)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
union flutter::testing::@2838::KeyboardChange::@76 content
static Request * Create(const char *name, const SkFontStyle &style)
void init(void *nameSpace, uint64_t sharedID, size_t dataSize)