diff options
author | Ben Wagner <bungeman@google.com> | 2016-11-11 14:31:06 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-11 21:59:54 +0000 |
commit | 6e9ac12495f3b64b6ea8860bb9f99c43cd33aa08 (patch) | |
tree | 757e4c3fe61339400866c54d51d56eb38452ccfa /src/fonts | |
parent | bf7b620b1e44985b164a8bd68031a7613fe0bb9b (diff) |
Clean up glyph id handling.
Extract SkPackedID and its strongly typed subclasses SkPackedGlyphID and
SkPackedUnicharID out of SkGlyph. This simplifies the code handling
these types, as well as making it clearer that we wouuld eventually like
to get away from this scheme.
Changes SkScalerContext::getPath to take SkPackedGlyphID.
Changes SkScalerContext::generatePath to take SkGlyphID.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4722
Change-Id: I365c0c618b7ae0d348272155fac7761a69faa920
Reviewed-on: https://skia-review.googlesource.com/4722
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src/fonts')
-rw-r--r-- | src/fonts/SkGScalerContext.cpp | 10 | ||||
-rw-r--r-- | src/fonts/SkRandomScalerContext.cpp | 12 | ||||
-rw-r--r-- | src/fonts/SkTestScalerContext.cpp | 10 | ||||
-rw-r--r-- | src/fonts/SkTestScalerContext.h | 2 |
4 files changed, 17 insertions, 17 deletions
diff --git a/src/fonts/SkGScalerContext.cpp b/src/fonts/SkGScalerContext.cpp index 53d385437e..9da05492e6 100644 --- a/src/fonts/SkGScalerContext.cpp +++ b/src/fonts/SkGScalerContext.cpp @@ -53,7 +53,7 @@ protected: void generateAdvance(SkGlyph*) override; void generateMetrics(SkGlyph*) override; void generateImage(const SkGlyph&) override; - void generatePath(const SkGlyph&, SkPath*) override; + void generatePath(SkGlyphID, SkPath*) override; void generateFontMetrics(SkPaint::FontMetrics*) override; private: @@ -89,7 +89,7 @@ void SkGScalerContext::generateMetrics(SkGlyph* glyph) { glyph->fAdvanceY = SkScalarToFloat(advance.fY); SkPath path; - fProxy->getPath(*glyph, &path); + fProxy->getPath(glyph->getPackedID(), &path); path.transform(fMatrix); SkRect storage; @@ -109,7 +109,7 @@ void SkGScalerContext::generateMetrics(SkGlyph* glyph) { void SkGScalerContext::generateImage(const SkGlyph& glyph) { if (SkMask::kARGB32_Format == glyph.fMaskFormat) { SkPath path; - fProxy->getPath(glyph, &path); + fProxy->getPath(glyph.getPackedID(), &path); SkBitmap bm; bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight), @@ -126,8 +126,8 @@ void SkGScalerContext::generateImage(const SkGlyph& glyph) { } } -void SkGScalerContext::generatePath(const SkGlyph& glyph, SkPath* path) { - fProxy->getPath(glyph, path); +void SkGScalerContext::generatePath(SkGlyphID glyph, SkPath* path) { + fProxy->getPath(SkPackedGlyphID(glyph), path); path->transform(fMatrix); } diff --git a/src/fonts/SkRandomScalerContext.cpp b/src/fonts/SkRandomScalerContext.cpp index 96a2619876..55c7fb30d4 100644 --- a/src/fonts/SkRandomScalerContext.cpp +++ b/src/fonts/SkRandomScalerContext.cpp @@ -25,7 +25,7 @@ protected: void generateAdvance(SkGlyph*) override; void generateMetrics(SkGlyph*) override; void generateImage(const SkGlyph&) override; - void generatePath(const SkGlyph&, SkPath*) override; + void generatePath(SkGlyphID, SkPath*) override; void generateFontMetrics(SkPaint::FontMetrics*) override; private: @@ -84,7 +84,7 @@ void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { } if (SkMask::kARGB32_Format == format) { SkPath path; - fProxy->getPath(*glyph, &path); + fProxy->getPath(glyph->getPackedID(), &path); SkRect storage; const SkPaint& paint = this->getRandomTypeface()->paint(); @@ -101,7 +101,7 @@ void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { SkPath devPath, fillPath; SkMatrix fillToDevMatrix; - this->internalGetPath(*glyph, &fillPath, &devPath, &fillToDevMatrix); + this->internalGetPath(glyph->getPackedID(), &fillPath, &devPath, &fillToDevMatrix); // just use devPath const SkIRect ir = devPath.getBounds().roundOut(); @@ -154,7 +154,7 @@ void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { if (!fFakeIt) { if (SkMask::kARGB32_Format == glyph.fMaskFormat) { SkPath path; - fProxy->getPath(glyph, &path); + fProxy->getPath(glyph.getPackedID(), &path); SkBitmap bm; bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight), @@ -175,8 +175,8 @@ void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { } } -void SkRandomScalerContext::generatePath(const SkGlyph& glyph, SkPath* path) { - fProxy->getPath(glyph, path); +void SkRandomScalerContext::generatePath(SkGlyphID glyph, SkPath* path) { + fProxy->generatePath(glyph, path); } void SkRandomScalerContext::generateFontMetrics(SkPaint::FontMetrics* metrics) { diff --git a/src/fonts/SkTestScalerContext.cpp b/src/fonts/SkTestScalerContext.cpp index 7a97ca8bba..d84571d310 100644 --- a/src/fonts/SkTestScalerContext.cpp +++ b/src/fonts/SkTestScalerContext.cpp @@ -137,8 +137,8 @@ void SkTestTypeface::getMetrics(SkGlyph* glyph) { glyph->fAdvanceY = 0; } -void SkTestTypeface::getPath(const SkGlyph& glyph, SkPath* path) { - *path = *fTestFont->fPaths[glyph.getGlyphID()]; +void SkTestTypeface::getPath(SkGlyphID glyph, SkPath* path) { + *path = *fTestFont->fPaths[glyph]; } void SkTestTypeface::onFilterRec(SkScalerContextRec* rec) const { @@ -236,7 +236,7 @@ protected: glyph->fAdvanceY = SkScalarToFloat(advance.fY); SkPath path; - this->getTestTypeface()->getPath(*glyph, &path); + this->getTestTypeface()->getPath(glyph->getGlyphID(), &path); path.transform(fMatrix); SkRect storage; @@ -254,7 +254,7 @@ protected: void generateImage(const SkGlyph& glyph) override { SkPath path; - this->getTestTypeface()->getPath(glyph, &path); + this->getTestTypeface()->getPath(glyph.getGlyphID(), &path); SkBitmap bm; bm.installPixels(SkImageInfo::MakeN32Premul(glyph.fWidth, glyph.fHeight), @@ -270,7 +270,7 @@ protected: canvas.drawPath(path, paint); } - void generatePath(const SkGlyph& glyph, SkPath* path) override { + void generatePath(SkGlyphID glyph, SkPath* path) override { this->getTestTypeface()->getPath(glyph, path); path->transform(fMatrix); } diff --git a/src/fonts/SkTestScalerContext.h b/src/fonts/SkTestScalerContext.h index 90945970fa..217e57c2a4 100644 --- a/src/fonts/SkTestScalerContext.h +++ b/src/fonts/SkTestScalerContext.h @@ -60,7 +60,7 @@ public: void getAdvance(SkGlyph* glyph); void getFontMetrics(SkPaint::FontMetrics* metrics); void getMetrics(SkGlyph* glyph); - void getPath(const SkGlyph& glyph, SkPath* path); + void getPath(SkGlyphID glyph, SkPath* path); protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor* desc) const override; |