diff options
author | 2016-10-19 04:43:03 -0700 | |
---|---|---|
committer | 2016-10-19 04:43:03 -0700 | |
commit | 620ee4f744cefbf2fef60add803816398522baae (patch) | |
tree | 09c15234a67f7e85fa42de8d0e029281ed3250ad /src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | |
parent | e8f0a7b986f1e5583c9bc162efcdd92fd6430549 (diff) |
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
Diffstat (limited to 'src/gpu/batches/GrAADistanceFieldPathRenderer.cpp')
-rw-r--r-- | src/gpu/batches/GrAADistanceFieldPathRenderer.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp index ad5fa77493..36a9ff01e7 100644 --- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp @@ -1,6 +1,5 @@ /* * Copyright 2014 Google Inc. - * Copyright 2016 ARM Ltd. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. @@ -20,9 +19,7 @@ #include "batches/GrVertexBatch.h" #include "effects/GrDistanceFieldGeoProc.h" -#include "SkPathOps.h" #include "SkDistanceFieldGen.h" -#include "GrDistanceFieldGenFromVector.h" #define ATLAS_TEXTURE_WIDTH 2048 #define ATLAS_TEXTURE_HEIGHT 2048 @@ -114,24 +111,7 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c SkRect bounds = args.fShape->styledBounds(); SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); - if (!(maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP)) { - return false; - } - - // Only support even-odd fill type. (Checked by the IsDistanceFieldSupportedFillType function) - // The Simplify operation can convert some paths into even-odd fill type. - // Check whether we can generate distance field from this path after Simplify. - // TODO: Cache the simplifiedPath/workingPath somewhere for later use. - SkPath path; - args.fShape->asPath(&path); - SkPath simplifiedPath; - const SkPath* workingPath; - if (Simplify(path, &simplifiedPath)) { - workingPath = &simplifiedPath; - } else { - workingPath = &path; - } - return IsDistanceFieldSupportedFillType(workingPath->getFillType()); + return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP; } //////////////////////////////////////////////////////////////////////////////// @@ -346,23 +326,45 @@ private: drawMatrix.postScale(scale, scale); drawMatrix.postTranslate(kAntiAliasPad, kAntiAliasPad); + // setup bitmap backing SkASSERT(devPathBounds.fLeft == 0); SkASSERT(devPathBounds.fTop == 0); + SkAutoPixmapStorage dst; + if (!dst.tryAlloc(SkImageInfo::MakeA8(devPathBounds.width(), + devPathBounds.height()))) { + return false; + } + sk_bzero(dst.writable_addr(), dst.getSafeSize()); + + // rasterize path + SkPaint paint; + paint.setStyle(SkPaint::kFill_Style); + paint.setAntiAlias(antiAlias); + + SkDraw draw; + sk_bzero(&draw, sizeof(draw)); + + SkRasterClip rasterClip; + rasterClip.setRect(devPathBounds); + draw.fRC = &rasterClip; + draw.fMatrix = &drawMatrix; + draw.fDst = dst; SkPath path; shape.asPath(&path); + draw.drawPathCoverage(path, paint); - // setup signed distance field storage + // generate signed distance field devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad); width = devPathBounds.width(); height = devPathBounds.height(); // TODO We should really generate this directly into the plot somehow SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char)); - // Generate signed distance field directly from SkPath - GrGenerateDistanceFieldFromPath((unsigned char*)dfStorage.get(), - path, drawMatrix, - width, height, width * sizeof(unsigned char)); + // Generate signed distance field + SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(), + (const unsigned char*)dst.addr(), + dst.width(), dst.height(), dst.rowBytes()); // add to atlas SkIPoint16 atlasLocation; |