Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkTypeface_remote.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2018 Google LLC
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
9
15#include "src/core/SkGlyph.h"
19
20#include <optional>
21#include <utility>
22
23class SkArenaAlloc;
24class SkDescriptor;
25class SkPath;
26
28 const SkScalerContextEffects& effects,
29 const SkDescriptor* desc,
31 : SkScalerContext{std::move(tf), effects, desc}
32 , fDiscardableManager{std::move(manager)} {}
33
35 SkArenaAlloc*) {
36 TRACE_EVENT1("skia", "generateMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
37 if (this->getProxyTypeface()->isLogging()) {
38 SkDebugf("GlyphCacheMiss generateMetrics looking for glyph: %x\n generateMetrics: %s\n",
39 glyph.getPackedID().value(), this->getRec().dump().c_str());
40 }
41
42 fDiscardableManager->notifyCacheMiss(
44
45 return {glyph.maskFormat()};
46}
47
49 TRACE_EVENT1("skia", "generateImage", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
50 if (this->getProxyTypeface()->isLogging()) {
51 SkDebugf("GlyphCacheMiss generateImage: %s\n", this->getRec().dump().c_str());
52 }
53
54 // There is no desperation search here, because if there was an image to be found it was
55 // copied over with the metrics search.
56 fDiscardableManager->notifyCacheMiss(
58}
59
61 TRACE_EVENT1("skia", "generatePath", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
62 if (this->getProxyTypeface()->isLogging()) {
63 SkDebugf("GlyphCacheMiss generatePath: %s\n", this->getRec().dump().c_str());
64 }
65
66 fDiscardableManager->notifyCacheMiss(
68 return false;
69}
70
72 TRACE_EVENT1("skia", "generateDrawable", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
73 if (this->getProxyTypeface()->isLogging()) {
74 SkDebugf("GlyphCacheMiss generateDrawable: %s\n", this->getRec().dump().c_str());
75 }
76
77 fDiscardableManager->notifyCacheMiss(
79 return nullptr;
80}
81
84 "skia", "generateFontMetrics", "rec", TRACE_STR_COPY(this->getRec().dump().c_str()));
85 if (this->getProxyTypeface()->isLogging()) {
86 SkDebugf("GlyphCacheMiss generateFontMetrics: %s\n", this->getRec().dump().c_str());
87 }
88
89 // Font metrics aren't really used for render, so just zero out the data and return.
90 fDiscardableManager->notifyCacheMiss(
92 sk_bzero(metrics, sizeof(*metrics));
93}
94
95std::optional<SkTypefaceProxyPrototype>
97 SkASSERT(buffer.isValid());
98 const SkTypefaceID typefaceID = buffer.readUInt();
99 const int glyphCount = buffer.readInt();
100 const int32_t styleValue = buffer.read32();
101 const bool isFixedPitch = buffer.readBool();
102 const bool glyphMaskNeedsCurrentColor = buffer.readBool();
103
104 if (buffer.isValid()) {
106 typefaceID, glyphCount, styleValue, isFixedPitch, glyphMaskNeedsCurrentColor};
107 }
108
109 return std::nullopt;
110}
111
113 : fServerTypefaceID{typeface.uniqueID()}
114 , fGlyphCount{typeface.countGlyphs()}
115 , fStyleValue{typeface.fontStyle().fValue}
116 , fIsFixedPitch{typeface.isFixedPitch()}
117 , fGlyphMaskNeedsCurrentColor{typeface.glyphMaskNeedsCurrentColor()} {}
118
120 int32_t styleValue, bool isFixedPitch,
121 bool glyphMaskNeedsCurrentColor)
122 : fServerTypefaceID {typefaceID}
123 , fGlyphCount{glyphCount}
124 , fStyleValue{styleValue}
125 , fIsFixedPitch{isFixedPitch}
126 , fGlyphMaskNeedsCurrentColor{glyphMaskNeedsCurrentColor} {}
127
129 buffer.writeUInt(fServerTypefaceID);
130 buffer.writeInt(fGlyphCount);
131 buffer.write32(fStyleValue);
132 buffer.writeBool(fIsFixedPitch);
133 buffer.writeBool(fGlyphMaskNeedsCurrentColor);
134}
135
136
139 bool isLogging)
140 : SkTypeface{prototype.style(), prototype.fIsFixedPitch}
141 , fTypefaceID{prototype.fServerTypefaceID}
142 , fGlyphCount{prototype.fGlyphCount}
143 , fIsLogging{isLogging}
144 , fGlyphMaskNeedsCurrentColor{prototype.fGlyphMaskNeedsCurrentColor}
145 , fDiscardableManager{std::move(manager)} {}
146
148 int glyphCount,
149 const SkFontStyle& style,
150 bool isFixedPitch,
151 bool glyphMaskNeedsCurrentColor,
153 bool isLogging)
154 : SkTypeface{style, isFixedPitch}
155 , fTypefaceID{typefaceID}
156 , fGlyphCount{glyphCount}
157 , fIsLogging{isLogging}
158 , fGlyphMaskNeedsCurrentColor(glyphMaskNeedsCurrentColor)
159 , fDiscardableManager{std::move(manager)} {}
160
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void sk_bzero(void *buffer, size_t size)
Definition SkMalloc.h:105
#define TRACE_STR_COPY(str)
uint32_t SkTypefaceID
Definition SkTypeface.h:38
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
SkMask::Format maskFormat() const
Definition SkGlyph.h:500
SkPackedGlyphID getPackedID() const
Definition SkGlyph.h:430
SkScalerContextProxy(sk_sp< SkTypeface > tf, const SkScalerContextEffects &effects, const SkDescriptor *desc, sk_sp< SkStrikeClient::DiscardableHandleManager > manager)
void generateFontMetrics(SkFontMetrics *metrics) override
sk_sp< SkDrawable > generateDrawable(const SkGlyph &) override
bool generatePath(const SkGlyph &glyph, SkPath *path) override
SkTypefaceProxy * getProxyTypeface() const
void generateImage(const SkGlyph &, void *) override
GlyphMetrics generateMetrics(const SkGlyph &, SkArenaAlloc *) override
SkScalerContextRec fRec
SkTypeface * getTypeface() const
const SkScalerContextRec & getRec() const
virtual void notifyCacheMiss(CacheMissType type, int fontSize)=0
void flatten(SkWriteBuffer &buffer) const
static std::optional< SkTypefaceProxyPrototype > MakeFromBuffer(SkReadBuffer &buffer)
SkTypefaceProxyPrototype(const SkTypeface &typeface)
SkTypefaceProxy(const SkTypefaceProxyPrototype &prototype, sk_sp< SkStrikeClient::DiscardableHandleManager > manager, bool isLogging=true)
static const uint8_t buffer[]
Definition ref_ptr.h:256
uint32_t value() const
Definition SkGlyph.h:110
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)