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/ports | |
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/ports')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 8 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac.cpp | 6 | ||||
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 20 | ||||
-rw-r--r-- | src/ports/SkScalerContext_win_dw.cpp | 4 | ||||
-rw-r--r-- | src/ports/SkScalerContext_win_dw.h | 2 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index 2eaf2bf06e..0a4e63688d 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -195,7 +195,7 @@ protected: void generateAdvance(SkGlyph* glyph) override; void generateMetrics(SkGlyph* glyph) override; void generateImage(const SkGlyph& glyph) override; - void generatePath(const SkGlyph& glyph, SkPath* path) override; + void generatePath(SkGlyphID glyphID, SkPath* path) override; void generateFontMetrics(SkPaint::FontMetrics*) override; SkUnichar generateGlyphToChar(uint16_t glyph) override; @@ -1212,7 +1212,7 @@ void SkScalerContext_FreeType::generateImage(const SkGlyph& glyph) { } -void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, SkPath* path) { +void SkScalerContext_FreeType::generatePath(SkGlyphID glyphID, SkPath* path) { SkAutoMutexAcquire ac(gFTMutex); SkASSERT(path); @@ -1226,11 +1226,11 @@ void SkScalerContext_FreeType::generatePath(const SkGlyph& glyph, SkPath* path) flags |= FT_LOAD_NO_BITMAP; // ignore embedded bitmaps so we're sure to get the outline flags &= ~FT_LOAD_RENDER; // don't scan convert (we just want the outline) - FT_Error err = FT_Load_Glyph( fFace, glyph.getGlyphID(), flags); + FT_Error err = FT_Load_Glyph(fFace, glyphID, flags); if (err != 0) { SkDEBUGF(("SkScalerContext_FreeType::generatePath: FT_Load_Glyph(glyph:%d flags:%d) returned 0x%x\n", - glyph.getGlyphID(), flags, err)); + glyphID, flags, err)); path->reset(); return; } diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index a9b9a2a70e..a9f6bb0a6e 100644 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -702,7 +702,7 @@ protected: void generateAdvance(SkGlyph* glyph) override; void generateMetrics(SkGlyph* glyph) override; void generateImage(const SkGlyph& glyph) override; - void generatePath(const SkGlyph& glyph, SkPath* path) override; + void generatePath(SkGlyphID glyph, SkPath* path) override; void generateFontMetrics(SkPaint::FontMetrics*) override; private: @@ -1373,7 +1373,7 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { */ #define kScaleForSubPixelPositionHinting (4.0f) -void SkScalerContext_Mac::generatePath(const SkGlyph& glyph, SkPath* path) { +void SkScalerContext_Mac::generatePath(SkGlyphID glyph, SkPath* path) { AUTO_CG_LOCK(); SkScalar scaleX = SK_Scalar1; @@ -1408,7 +1408,7 @@ void SkScalerContext_Mac::generatePath(const SkGlyph& glyph, SkPath* path) { xform = CGAffineTransformConcat(fTransform, scale); } - CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID(); + CGGlyph cgGlyph = SkTo<CGGlyph>(glyph); AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(fCTFont, cgGlyph, &xform)); path->reset(); diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 77465ceff4..9229be6d30 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -546,11 +546,11 @@ protected: void generateAdvance(SkGlyph* glyph) override; void generateMetrics(SkGlyph* glyph) override; void generateImage(const SkGlyph& glyph) override; - void generatePath(const SkGlyph& glyph, SkPath* path) override; + void generatePath(SkGlyphID glyph, SkPath* path) override; void generateFontMetrics(SkPaint::FontMetrics*) override; private: - DWORD getGDIGlyphPath(const SkGlyph& glyph, UINT flags, + DWORD getGDIGlyphPath(SkGlyphID glyph, UINT flags, SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf); HDCOffscreen fOffscreen; @@ -1589,22 +1589,22 @@ static bool sk_path_from_gdi_paths(SkPath* path, const uint8_t* glyphbuf, DWORD return true; } -DWORD SkScalerContext_GDI::getGDIGlyphPath(const SkGlyph& glyph, UINT flags, - SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf) +DWORD SkScalerContext_GDI::getGDIGlyphPath(SkGlyphID glyph, UINT flags, + SkAutoSTMalloc<BUFFERSIZE, uint8_t>* glyphbuf) { GLYPHMETRICS gm; - DWORD total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, BUFFERSIZE, glyphbuf->get(), &fMat22); + DWORD total_size = GetGlyphOutlineW(fDDC, glyph, flags, &gm, BUFFERSIZE, glyphbuf->get(), &fMat22); // Sometimes GetGlyphOutlineW returns a number larger than BUFFERSIZE even if BUFFERSIZE > 0. // It has been verified that this does not involve a buffer overrun. if (GDI_ERROR == total_size || total_size > BUFFERSIZE) { // GDI_ERROR because the BUFFERSIZE was too small, or because the data was not accessible. // When the data is not accessable GetGlyphOutlineW fails rather quickly, // so just try to get the size. If that fails then ensure the data is accessible. - total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, nullptr, &fMat22); + total_size = GetGlyphOutlineW(fDDC, glyph, flags, &gm, 0, nullptr, &fMat22); if (GDI_ERROR == total_size) { LogFontTypeface::EnsureAccessible(this->getTypeface()); - total_size = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, 0, nullptr, &fMat22); + total_size = GetGlyphOutlineW(fDDC, glyph, flags, &gm, 0, nullptr, &fMat22); if (GDI_ERROR == total_size) { // GetGlyphOutlineW is known to fail for some characters, such as spaces. // In these cases, just return that the glyph does not have a shape. @@ -1614,10 +1614,10 @@ DWORD SkScalerContext_GDI::getGDIGlyphPath(const SkGlyph& glyph, UINT flags, glyphbuf->reset(total_size); - DWORD ret = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, total_size, glyphbuf->get(), &fMat22); + DWORD ret = GetGlyphOutlineW(fDDC, glyph, flags, &gm, total_size, glyphbuf->get(), &fMat22); if (GDI_ERROR == ret) { LogFontTypeface::EnsureAccessible(this->getTypeface()); - ret = GetGlyphOutlineW(fDDC, glyph.getGlyphID(), flags, &gm, total_size, glyphbuf->get(), &fMat22); + ret = GetGlyphOutlineW(fDDC, glyph, flags, &gm, total_size, glyphbuf->get(), &fMat22); if (GDI_ERROR == ret) { SkASSERT(false); return 0; @@ -1627,7 +1627,7 @@ DWORD SkScalerContext_GDI::getGDIGlyphPath(const SkGlyph& glyph, UINT flags, return total_size; } -void SkScalerContext_GDI::generatePath(const SkGlyph& glyph, SkPath* path) { +void SkScalerContext_GDI::generatePath(SkGlyphID glyph, SkPath* path) { SkASSERT(path); SkASSERT(fDDC); diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp index c83542f47a..10afb5a0ca 100644 --- a/src/ports/SkScalerContext_win_dw.cpp +++ b/src/ports/SkScalerContext_win_dw.cpp @@ -887,7 +887,7 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { } } -void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { +void SkScalerContext_DW::generatePath(SkGlyphID glyph, SkPath* path) { SkASSERT(path); path->reset(); @@ -895,7 +895,7 @@ void SkScalerContext_DW::generatePath(const SkGlyph& glyph, SkPath* path) { SkTScopedComPtr<IDWriteGeometrySink> geometryToPath; HRVM(SkDWriteGeometrySink::Create(path, &geometryToPath), "Could not create geometry to path converter."); - uint16_t glyphId = glyph.getGlyphID(); + UINT16 glyphId = SkTo<UINT16>(glyph); { SkAutoExclusive l(DWriteFactoryMutex); //TODO: convert to<->from DIUs? This would make a difference if hinting. diff --git a/src/ports/SkScalerContext_win_dw.h b/src/ports/SkScalerContext_win_dw.h index bcb7ab47db..7b45c320ca 100644 --- a/src/ports/SkScalerContext_win_dw.h +++ b/src/ports/SkScalerContext_win_dw.h @@ -34,7 +34,7 @@ protected: void generateAdvance(SkGlyph* glyph) override; void generateMetrics(SkGlyph* glyph) override; void generateImage(const SkGlyph& glyph) override; - void generatePath(const SkGlyph& glyph, SkPath* path) override; + void generatePath(SkGlyphID glyph, SkPath* path) override; void generateFontMetrics(SkPaint::FontMetrics*) override; private: |