aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-08-05 13:37:49 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-05 13:37:49 -0700
commit59cd36765c10f6451f72ffde446b9ae8ce5599c8 (patch)
treeb70c53cc015aef46a0af2d0d42c31f86de4c4464 /src
parent29e0d3f267a03546f236023347cdb4595ece2fd1 (diff)
Revert of Implement caching of stroked paths in the tessellated path renderer. (patchset #4 id:60001 of https://codereview.chromium.org/1275553002/ )
Reason for revert: Breaking/asserting in Debug on DM. Original issue's description: > Implement caching of stroked paths in the tessellated path renderer. > > This requires adding the stroke info to the cache key, and doing the > stroking and dashing before rendering as triangles. > > BUG=skia:3755 > > Committed: https://skia.googlesource.com/skia/+/29e0d3f267a03546f236023347cdb4595ece2fd1 TBR=bsalomon@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia:3755 Review URL: https://codereview.chromium.org/1276633002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrTessellatingPathRenderer.cpp47
-rw-r--r--src/gpu/GrTestUtils.cpp37
2 files changed, 17 insertions, 67 deletions
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp
index 5bbc4757ff..282efe2516 100644
--- a/src/gpu/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/GrTessellatingPathRenderer.cpp
@@ -1384,10 +1384,9 @@ private:
} // namespace
bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
- // This path renderer can draw all fill styles, all stroke styles except hairlines, but does
- // not do antialiasing. It can do convex and concave paths, but we'll leave the convex ones to
- // simpler algorithms.
- return !args.fStroke->isHairlineStyle() && !args.fAntiAlias && !args.fPath->isConvex();
+ // This path renderer can draw all fill styles, but does not do antialiasing. It can do convex
+ // and concave paths, but we'll leave the convex ones to simpler algorithms.
+ return args.fStroke->isFillStyle() && !args.fAntiAlias && !args.fPath->isConvex();
}
class TessellatingPathBatch : public GrBatch {
@@ -1395,10 +1394,9 @@ public:
static GrBatch* Create(const GrColor& color,
const SkPath& path,
- const GrStrokeInfo& stroke,
const SkMatrix& viewMatrix,
SkRect clipBounds) {
- return SkNEW_ARGS(TessellatingPathBatch, (color, path, stroke, viewMatrix, clipBounds));
+ return SkNEW_ARGS(TessellatingPathBatch, (color, path, viewMatrix, clipBounds));
}
const char* name() const override { return "TessellatingPathBatch"; }
@@ -1423,23 +1421,7 @@ public:
int tessellate(GrUniqueKey* key,
GrResourceProvider* resourceProvider,
SkAutoTUnref<GrVertexBuffer>& vertexBuffer) {
- SkPath path;
- GrStrokeInfo stroke(fStroke);
- if (stroke.isDashed()) {
- if (!stroke.applyDashToPath(&path, &stroke, fPath)) {
- return 0;
- }
- } else {
- path = fPath;
- }
- if (!stroke.isFillStyle()) {
- stroke.setResScale(SkScalarAbs(fViewMatrix.getMaxScale()));
- if (!stroke.applyToPath(&path, path)) {
- return 0;
- }
- stroke.setFillStyle();
- }
- SkRect pathBounds = path.getBounds();
+ SkRect pathBounds = fPath.getBounds();
Comparator c;
if (pathBounds.width() > pathBounds.height()) {
c.sweep_lt = sweep_lt_horiz;
@@ -1451,7 +1433,7 @@ public:
SkScalar screenSpaceTol = GrPathUtils::kDefaultTolerance;
SkScalar tol = GrPathUtils::scaleToleranceToSrc(screenSpaceTol, fViewMatrix, pathBounds);
int contourCnt;
- int maxPts = GrPathUtils::worstCasePointCount(path, &contourCnt, tol);
+ int maxPts = GrPathUtils::worstCasePointCount(fPath, &contourCnt, tol);
if (maxPts <= 0) {
return 0;
}
@@ -1459,7 +1441,7 @@ public:
SkDebugf("Path not rendered, too many verts (%d)\n", maxPts);
return 0;
}
- SkPath::FillType fillType = path.getFillType();
+ SkPath::FillType fillType = fPath.getFillType();
if (SkPath::IsInverseFillType(fillType)) {
contourCnt++;
}
@@ -1473,7 +1455,7 @@ public:
// connectivity of one Edge per Vertex (will grow for intersections).
SkChunkAlloc alloc(maxPts * (3 * sizeof(Vertex) + sizeof(Edge)));
bool isLinear;
- path_to_contours(path, tol, fClipBounds, contours.get(), alloc, &isLinear);
+ path_to_contours(fPath, tol, fClipBounds, contours.get(), alloc, &isLinear);
Poly* polys;
polys = contours_to_polys(contours.get(), contourCnt, c, alloc);
int count = 0;
@@ -1521,15 +1503,13 @@ public:
GrUniqueKey key;
int clipBoundsSize32 =
fPath.isInverseFillType() ? sizeof(fClipBounds) / sizeof(uint32_t) : 0;
- int strokeDataSize32 = fStroke.computeUniqueKeyFragmentData32Cnt();
- GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32 + strokeDataSize32);
+ GrUniqueKey::Builder builder(&key, kDomain, 2 + clipBoundsSize32);
builder[0] = fPath.getGenerationID();
builder[1] = fPath.getFillType();
// For inverse fills, the tessellation is dependent on clip bounds.
if (fPath.isInverseFillType()) {
memcpy(&builder[2], &fClipBounds, sizeof(fClipBounds));
}
- fStroke.asUniqueKeyFragment(&builder[2 + clipBoundsSize32]);
builder.finish();
GrResourceProvider* rp = batchTarget->resourceProvider();
SkAutoTUnref<GrVertexBuffer> vertexBuffer(rp->findAndRefTByUniqueKey<GrVertexBuffer>(key));
@@ -1581,12 +1561,10 @@ public:
private:
TessellatingPathBatch(const GrColor& color,
const SkPath& path,
- const GrStrokeInfo& stroke,
const SkMatrix& viewMatrix,
const SkRect& clipBounds)
: fColor(color)
, fPath(path)
- , fStroke(stroke)
, fViewMatrix(viewMatrix)
, fClipBounds(clipBounds) {
this->initClassID<TessellatingPathBatch>();
@@ -1597,7 +1575,6 @@ private:
GrColor fColor;
SkPath fPath;
- GrStrokeInfo fStroke;
SkMatrix fViewMatrix;
SkRect fClipBounds; // in source space
GrPipelineInfo fPipelineInfo;
@@ -1619,8 +1596,7 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
vmi.mapRect(&clipBounds);
SkAutoTUnref<GrBatch> batch(TessellatingPathBatch::Create(args.fColor, *args.fPath,
- *args.fStroke, *args.fViewMatrix,
- clipBounds));
+ *args.fViewMatrix, clipBounds));
args.fTarget->drawBatch(*args.fPipelineBuilder, batch);
return true;
@@ -1641,8 +1617,7 @@ BATCH_TEST_DEFINE(TesselatingPathBatch) {
SkFAIL("Cannot invert matrix\n");
}
vmi.mapRect(&clipBounds);
- GrStrokeInfo strokeInfo = GrTest::TestStrokeInfo(random);
- return TessellatingPathBatch::Create(color, path, strokeInfo, viewMatrix, clipBounds);
+ return TessellatingPathBatch::Create(color, path, viewMatrix, clipBounds);
}
#endif
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 9e1dbce691..b690d7e3cd 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -5,10 +5,8 @@
* found in the LICENSE file.
*/
-#include "GrStrokeInfo.h"
#include "GrTestUtils.h"
#include "SkMatrix.h"
-#include "SkPathEffect.h"
#include "SkPath.h"
#include "SkRRect.h"
@@ -218,44 +216,21 @@ const SkPath& TestPathConvex(SkRandom* random) {
return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPath)))];
}
-static void randomize_stroke_rec(SkStrokeRec* rec, SkRandom* random) {
+SkStrokeRec TestStrokeRec(SkRandom* random) {
+ SkStrokeRec::InitStyle style =
+ SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_InitStyle + 1));
+ SkStrokeRec rec(style);
bool strokeAndFill = random->nextBool();
SkScalar strokeWidth = random->nextBool() ? 0.f : 1.f;
- rec->setStrokeStyle(strokeWidth, strokeAndFill);
+ rec.setStrokeStyle(strokeWidth, strokeAndFill);
SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount));
SkPaint::Join join = SkPaint::Join(random->nextULessThan(SkPaint::kJoinCount));
SkScalar miterLimit = random->nextRangeScalar(1.f, 5.f);
- rec->setStrokeParams(cap, join, miterLimit);
-}
-
-SkStrokeRec TestStrokeRec(SkRandom* random) {
- SkStrokeRec::InitStyle style =
- SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_InitStyle + 1));
- SkStrokeRec rec(style);
- randomize_stroke_rec(&rec, random);
+ rec.setStrokeParams(cap, join, miterLimit);
return rec;
}
-GrStrokeInfo TestStrokeInfo(SkRandom* random) {
- SkStrokeRec::InitStyle style =
- SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_InitStyle + 1));
- GrStrokeInfo strokeInfo(style);
- randomize_stroke_rec(&strokeInfo, random);
- SkPathEffect::DashInfo dashInfo;
- dashInfo.fCount = random->nextRangeU(1, 100);
- dashInfo.fIntervals = SkNEW_ARRAY(SkScalar, dashInfo.fCount);
- SkScalar sum = 0;
- for (int i = 0; i < dashInfo.fCount; i++) {
- dashInfo.fIntervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01),
- SkDoubleToScalar(10.0));
- sum += dashInfo.fIntervals[i];
- }
- dashInfo.fPhase = random->nextRangeScalar(0, sum);
- strokeInfo.setDashInfo(dashInfo);
- return strokeInfo;
-}
-
};
#endif