diff options
author | joel.liang <joel.liang@arm.com> | 2016-10-19 02:50:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-19 02:50:03 -0700 |
commit | e8f0a7b986f1e5583c9bc162efcdd92fd6430549 (patch) | |
tree | 324ec8920bbf3a8f10df517a68396696c2962063 /src/gpu/text | |
parent | 3ac64b427af596e4e8341857ce5f214bf0b49efb (diff) |
Generate Signed Distance Field directly from vector path
Add SkGenerateDistanceFieldFromPath API to generate signed distance field directly from SkPath.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1643143002
Committed: https://skia.googlesource.com/skia/+/4de97a64e8829323a7070b623411d9f9ddb0cd0f
Review-Url: https://chromiumcodereview.appspot.com/1643143002
Diffstat (limited to 'src/gpu/text')
-rw-r--r-- | src/gpu/text/GrBatchFontCache.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/gpu/text/GrBatchFontCache.cpp b/src/gpu/text/GrBatchFontCache.cpp index 3e212cd171..2d682a8370 100644 --- a/src/gpu/text/GrBatchFontCache.cpp +++ b/src/gpu/text/GrBatchFontCache.cpp @@ -14,6 +14,7 @@ #include "SkString.h" #include "SkDistanceFieldGen.h" +#include "GrDistanceFieldGenFromVector.h" bool GrBatchFontCache::initAtlas(GrMaskFormat format) { int index = MaskFormatToAtlasIndex(format); @@ -269,30 +270,20 @@ static bool get_packed_glyph_df_image(SkGlyphCache* cache, const SkGlyph& glyph, int width, int height, void* dst) { SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width); SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height); - const void* image = cache->findImage(glyph); - if (nullptr == image) { + const SkPath* path = cache->findPath(glyph); + if (nullptr == path) { return false; } + // now generate the distance field SkASSERT(dst); - SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat); - if (SkMask::kA8_Format == maskFormat) { - // make the distance field from the image - SkGenerateDistanceFieldFromA8Image((unsigned char*)dst, - (unsigned char*)image, - glyph.fWidth, glyph.fHeight, - glyph.rowBytes()); - } else if (SkMask::kBW_Format == maskFormat) { - // make the distance field from the image - SkGenerateDistanceFieldFromBWImage((unsigned char*)dst, - (unsigned char*)image, - glyph.fWidth, glyph.fHeight, - glyph.rowBytes()); - } else { - return false; - } + SkMatrix drawMatrix; + drawMatrix.setTranslate((SkScalar)-glyph.fLeft, (SkScalar)-glyph.fTop); - return true; + // Generate signed distance field directly from SkPath + return GrGenerateDistanceFieldFromPath((unsigned char*)dst, + *path, drawMatrix, + width, height, width * sizeof(unsigned char)); } /////////////////////////////////////////////////////////////////////////////// |