aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkGlyphCache.cpp11
-rw-r--r--src/core/SkRemoteGlyphCache.cpp17
-rw-r--r--src/core/SkRemoteGlyphCache.h2
-rw-r--r--src/core/SkScalerContext.cpp22
-rw-r--r--src/core/SkScalerContext.h6
-rw-r--r--src/core/SkTypeface_remote.cpp4
-rw-r--r--src/core/SkTypeface_remote.h2
7 files changed, 39 insertions, 25 deletions
diff --git a/src/core/SkGlyphCache.cpp b/src/core/SkGlyphCache.cpp
index e030c4b9a3..057f4d731e 100644
--- a/src/core/SkGlyphCache.cpp
+++ b/src/core/SkGlyphCache.cpp
@@ -214,9 +214,14 @@ const SkPath* SkGlyphCache::findPath(const SkGlyph& glyph) {
SkGlyph::PathData* pathData = fAlloc.make<SkGlyph::PathData>();
const_cast<SkGlyph&>(glyph).fPathData = pathData;
pathData->fIntercept = nullptr;
- SkPath* path = pathData->fPath = new SkPath;
- fScalerContext->getPath(glyph.getPackedID(), path);
- fMemoryUsed += sizeof(SkPath) + path->countPoints() * sizeof(SkPoint);
+ SkPath* path = new SkPath;
+ if (fScalerContext->getPath(glyph.getPackedID(), path)) {
+ pathData->fPath = path;
+ fMemoryUsed += sizeof(SkPath) + path->countPoints() * sizeof(SkPoint);
+ } else {
+ pathData->fPath = nullptr;
+ delete path;
+ }
}
}
return glyph.fPathData ? glyph.fPathData->fPath : nullptr;
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 4c2548c384..200f86a118 100644
--- a/src/core/SkRemoteGlyphCache.cpp
+++ b/src/core/SkRemoteGlyphCache.cpp
@@ -616,11 +616,12 @@ int SkStrikeServer::serve() {
auto sc = this->generateScalerContext(op->descriptor, op->typefaceId);
// TODO: check for buffer overflow.
SkPath path;
- sc->getPath(op->glyphID, &path);
- size_t pathSize = path.writeToMemory(nullptr);
- serializer.push_back<size_t>(pathSize);
- auto pathData = serializer.allocateArray<uint8_t>(pathSize);
- path.writeToMemory(pathData);
+ if (sc->getPath(op->glyphID, &path)) {
+ size_t pathSize = path.writeToMemory(nullptr);
+ serializer.push_back<size_t>(pathSize);
+ auto pathData = serializer.allocateArray<uint8_t>(pathSize);
+ path.writeToMemory(pathData);
+ }
break;
}
case OpCode::kGlyphMetricsAndImage : {
@@ -760,7 +761,7 @@ void SkStrikeClient::generateMetricsAndImage(
}
}
-void SkStrikeClient::generatePath(
+bool SkStrikeClient::generatePath(
const SkTypefaceProxy& typefaceProxy,
const SkScalerContextRec& rec,
SkGlyphID glyphID,
@@ -779,9 +780,13 @@ void SkStrikeClient::generatePath(
fTransport->readVector(&fBuffer);
Deserializer deserializer{fBuffer};
size_t pathSize = *deserializer.read<size_t>();
+ if (pathSize == 0) {
+ return false;
+ }
auto rawPath = deserializer.readArray<uint8_t>(pathSize);
path->readFromMemory(rawPath.data(), rawPath.size());
}
+ return true;
}
void SkStrikeClient::primeStrikeCache(const SkStrikeCacheDifferenceSpec& strikeDifferences) {
diff --git a/src/core/SkRemoteGlyphCache.h b/src/core/SkRemoteGlyphCache.h
index 2271e75138..3dfa8c28e5 100644
--- a/src/core/SkRemoteGlyphCache.h
+++ b/src/core/SkRemoteGlyphCache.h
@@ -203,7 +203,7 @@ public:
const SkTypefaceProxy&, const SkScalerContextRec&, SkPaint::FontMetrics*);
void generateMetricsAndImage(
const SkTypefaceProxy&, const SkScalerContextRec&, SkArenaAlloc*, SkGlyph*);
- void generatePath(
+ bool generatePath(
const SkTypefaceProxy&, const SkScalerContextRec&, SkGlyphID glyph, SkPath* path);
SkTypeface* lookupTypeface(SkFontID id);
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index d529db9eb0..600163910a 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -158,10 +158,12 @@ void SkScalerContext::getMetrics(SkGlyph* glyph) {
SK_ERROR:
// draw nothing 'cause we failed
- glyph->fLeft = 0;
- glyph->fTop = 0;
- glyph->fWidth = 0;
- glyph->fHeight = 0;
+ glyph->fLeft = 0;
+ glyph->fTop = 0;
+ glyph->fWidth = 0;
+ glyph->fHeight = 0;
+ glyph->fLsbDelta = 0;
+ glyph->fRsbDelta = 0;
// put a valid value here, in case it was earlier set to
// MASK_FORMAT_JUST_ADVANCE
glyph->fMaskFormat = fRec.fMaskFormat;
@@ -500,8 +502,8 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) {
}
}
-void SkScalerContext::getPath(SkPackedGlyphID glyphID, SkPath* path) {
- this->internalGetPath(glyphID, nullptr, path, nullptr);
+bool SkScalerContext::getPath(SkPackedGlyphID glyphID, SkPath* path) {
+ return this->internalGetPath(glyphID, nullptr, path, nullptr);
}
void SkScalerContext::getFontMetrics(SkPaint::FontMetrics* fm) {
@@ -518,8 +520,7 @@ SkUnichar SkScalerContext::generateGlyphToChar(uint16_t glyph) {
bool SkScalerContext::internalGetPath(SkPackedGlyphID glyphID, SkPath* fillPath,
SkPath* devPath, SkMatrix* fillToDevMatrix) {
SkPath path;
- generatePath(glyphID.code(), &path);
- if (path.isEmpty()) {
+ if (!generatePath(glyphID.code(), &path)) {
return false;
}
@@ -790,7 +791,10 @@ protected:
glyph->zeroMetrics();
}
void generateImage(const SkGlyph& glyph) override {}
- void generatePath(SkGlyphID glyph, SkPath* path) override {}
+ bool generatePath(SkGlyphID glyph, SkPath* path) override {
+ path->reset();
+ return false;
+ }
void generateFontMetrics(SkPaint::FontMetrics* metrics) override {
if (metrics) {
sk_bzero(metrics, sizeof(*metrics));
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 33072f8a57..96cff4d44a 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -289,7 +289,7 @@ public:
void getAdvance(SkGlyph*);
void getMetrics(SkGlyph*);
void getImage(const SkGlyph&);
- void getPath(SkPackedGlyphID, SkPath*);
+ bool SK_WARN_UNUSED_RESULT getPath(SkPackedGlyphID, SkPath*);
void getFontMetrics(SkPaint::FontMetrics*);
/** Return the size in bytes of the associated gamma lookup table
@@ -377,9 +377,9 @@ protected:
/** Sets the passed path to the glyph outline.
* If this cannot be done the path is set to empty;
- * this is indistinguishable from a glyph with an empty path.
+ * @return false if this glyph does not have any path.
*/
- virtual void generatePath(SkGlyphID glyphId, SkPath* path) = 0;
+ virtual bool SK_WARN_UNUSED_RESULT generatePath(SkGlyphID glyphId, SkPath* path) = 0;
/** Retrieves font metrics. */
virtual void generateFontMetrics(SkPaint::FontMetrics*) = 0;
diff --git a/src/core/SkTypeface_remote.cpp b/src/core/SkTypeface_remote.cpp
index 6fc6aa46d7..bc0d04bc2a 100644
--- a/src/core/SkTypeface_remote.cpp
+++ b/src/core/SkTypeface_remote.cpp
@@ -39,8 +39,8 @@ void SkScalerContextProxy::generateMetrics(SkGlyph* glyph) {
void SkScalerContextProxy::generateImage(const SkGlyph& glyph) {
}
-void SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) {
- fClient->generatePath(*this->typefaceProxy(), this->getRec(), glyphID, path);
+bool SkScalerContextProxy::generatePath(SkGlyphID glyphID, SkPath* path) {
+ return fClient->generatePath(*this->typefaceProxy(), this->getRec(), glyphID, path);
}
void SkScalerContextProxy::generateFontMetrics(SkPaint::FontMetrics* metrics) {
diff --git a/src/core/SkTypeface_remote.h b/src/core/SkTypeface_remote.h
index 485982aa2d..85a8fc5617 100644
--- a/src/core/SkTypeface_remote.h
+++ b/src/core/SkTypeface_remote.h
@@ -33,7 +33,7 @@ protected:
void generateAdvance(SkGlyph* glyph) override;
void generateMetrics(SkGlyph* glyph) override;
void generateImage(const SkGlyph& glyph) override;
- void generatePath(SkGlyphID glyphID, SkPath* path) override;
+ bool generatePath(SkGlyphID glyphID, SkPath* path) override;
void generateFontMetrics(SkPaint::FontMetrics* metrics) override;
private: