From 620ee4f744cefbf2fef60add803816398522baae Mon Sep 17 00:00:00 2001 From: benjaminwagner Date: Wed, 19 Oct 2016 04:43:03 -0700 Subject: Revert of Generate Signed Distance Field directly from vector path (patchset #18 id:340001 of https://chromiumcodereview.appspot.com/1643143002/ ) Reason for revert: Multiple assertion failures on multiple platforms: ../../../src/gpu/GrDistanceFieldGenFromVector.cpp:806: fatal error: "assert(((col != width - 1) || (windingNumber == 0)) && "Winding number should be zero at the end of a scan line.")" https://luci-milo.appspot.com/swarming/task/31f5353caf8cc410 https://luci-milo.appspot.com/swarming/task/31f567789cbcec10 c:\b\work\skia\src\pathops\skopangle.cpp:165: fatal error: "assert(lrOpposite != trOpposite)" https://luci-milo.appspot.com/swarming/task/31f570d74f750310 Original issue's description: > 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 > Committed: https://skia.googlesource.com/skia/+/e8f0a7b986f1e5583c9bc162efcdd92fd6430549 TBR=bsalomon@google.com,jvanverth@google.com,mtklein@google.com,wasim.abbas@arm.com,caryclark@google.com,joel.liang@arm.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://chromiumcodereview.appspot.com/2435753002 --- src/gpu/text/GrBatchFontCache.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/gpu/text') diff --git a/src/gpu/text/GrBatchFontCache.cpp b/src/gpu/text/GrBatchFontCache.cpp index 2d682a8370..3e212cd171 100644 --- a/src/gpu/text/GrBatchFontCache.cpp +++ b/src/gpu/text/GrBatchFontCache.cpp @@ -14,7 +14,6 @@ #include "SkString.h" #include "SkDistanceFieldGen.h" -#include "GrDistanceFieldGenFromVector.h" bool GrBatchFontCache::initAtlas(GrMaskFormat format) { int index = MaskFormatToAtlasIndex(format); @@ -270,20 +269,30 @@ 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 SkPath* path = cache->findPath(glyph); - if (nullptr == path) { + const void* image = cache->findImage(glyph); + if (nullptr == image) { return false; } - // now generate the distance field SkASSERT(dst); - SkMatrix drawMatrix; - drawMatrix.setTranslate((SkScalar)-glyph.fLeft, (SkScalar)-glyph.fTop); + SkMask::Format maskFormat = static_cast(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; + } - // Generate signed distance field directly from SkPath - return GrGenerateDistanceFieldFromPath((unsigned char*)dst, - *path, drawMatrix, - width, height, width * sizeof(unsigned char)); + return true; } /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3