aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrAAConvexPathRenderer.cpp13
-rw-r--r--src/gpu/GrDefaultPathRenderer.cpp55
-rw-r--r--src/gpu/GrPathUtils.cpp8
3 files changed, 56 insertions, 20 deletions
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index ed6bc6365b..fcf38ef7e7 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -15,6 +15,7 @@
#include "GrInvariantOutput.h"
#include "GrProcessor.h"
#include "GrPathUtils.h"
+#include "SkGeometry.h"
#include "SkString.h"
#include "SkStrokeRec.h"
#include "SkTraceEvent.h"
@@ -307,6 +308,18 @@ static bool get_segments(const SkPath& path,
update_degenerate_test(&degenerateData, pts[2]);
add_quad_segment(pts, segments, devBounds);
break;
+ case SkPath::kConic_Verb: {
+ m.mapPoints(pts, 3);
+ SkScalar weight = iter.conicWeight();
+ SkAutoConicToQuads converter;
+ const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.5f);
+ for (int i = 0; i < converter.countQuads(); ++i) {
+ update_degenerate_test(&degenerateData, quadPts[2*i + 1]);
+ update_degenerate_test(&degenerateData, quadPts[2*i + 2]);
+ add_quad_segment(quadPts + 2*i, segments, devBounds);
+ }
+ break;
+ }
case SkPath::kCubic_Verb: {
m.mapPoints(pts, 4);
update_degenerate_test(&degenerateData, pts[1]);
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 79e9f154ae..af0404ae0e 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -11,12 +11,12 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawState.h"
#include "GrPathUtils.h"
+#include "SkGeometry.h"
#include "SkString.h"
#include "SkStrokeRec.h"
#include "SkTLazy.h"
#include "SkTraceEvent.h"
-
GrDefaultPathRenderer::GrDefaultPathRenderer(bool separateStencilSupport,
bool stencilWrapOpsSupport)
: fSeparateStencil(separateStencilSupport)
@@ -189,6 +189,24 @@ static inline void append_countour_edge_indices(bool hairLine,
*((*indices)++) = edgeV0Idx + 1;
}
+static inline void add_quad(SkPoint** vert, const SkPoint* base, const SkPoint pts[],
+ SkScalar srcSpaceTolSqd, SkScalar srcSpaceTol, bool indexed,
+ bool isHairline, uint16_t subpathIdxStart, uint16_t** idx) {
+ // first pt of quad is the pt we ended on in previous step
+ uint16_t firstQPtIdx = (uint16_t)(*vert - base) - 1;
+ uint16_t numPts = (uint16_t)
+ GrPathUtils::generateQuadraticPoints(
+ pts[0], pts[1], pts[2],
+ srcSpaceTolSqd, vert,
+ GrPathUtils::quadraticPointCount(pts, srcSpaceTol));
+ if (indexed) {
+ for (uint16_t i = 0; i < numPts; ++i) {
+ append_countour_edge_indices(isHairline, subpathIdxStart,
+ firstQPtIdx + i, idx);
+ }
+ }
+}
+
bool GrDefaultPathRenderer::createGeom(GrDrawTarget* target,
GrDrawState* drawState,
GrPrimitiveType* primType,
@@ -256,9 +274,6 @@ bool GrDefaultPathRenderer::createGeom(GrDrawTarget* target,
for (;;) {
SkPath::Verb verb = iter.next(pts);
switch (verb) {
- case SkPath::kConic_Verb:
- SkASSERT(0);
- break;
case SkPath::kMove_Verb:
if (!first) {
uint16_t currIdx = (uint16_t) (vert - base);
@@ -276,22 +291,22 @@ bool GrDefaultPathRenderer::createGeom(GrDrawTarget* target,
}
*(vert++) = pts[1];
break;
- case SkPath::kQuad_Verb: {
- // first pt of quad is the pt we ended on in previous step
- uint16_t firstQPtIdx = (uint16_t)(vert - base) - 1;
- uint16_t numPts = (uint16_t)
- GrPathUtils::generateQuadraticPoints(
- pts[0], pts[1], pts[2],
- srcSpaceTolSqd, &vert,
- GrPathUtils::quadraticPointCount(pts, srcSpaceTol));
- if (indexed) {
- for (uint16_t i = 0; i < numPts; ++i) {
- append_countour_edge_indices(isHairline, subpathIdxStart,
- firstQPtIdx + i, &idx);
- }
+ case SkPath::kConic_Verb: {
+ SkScalar weight = iter.conicWeight();
+ SkAutoConicToQuads converter;
+ // Converting in src-space, hance the finer tolerance (0.25)
+ // TODO: find a way to do this in dev-space so the tolerance means something
+ const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.25f);
+ for (int i = 0; i < converter.countQuads(); ++i) {
+ add_quad(&vert, base, quadPts + i*2, srcSpaceTolSqd, srcSpaceTol, indexed,
+ isHairline, subpathIdxStart, &idx);
}
break;
}
+ case SkPath::kQuad_Verb:
+ add_quad(&vert, base, pts, srcSpaceTolSqd, srcSpaceTol, indexed,
+ isHairline, subpathIdxStart, &idx);
+ break;
case SkPath::kCubic_Verb: {
// first pt of cubic is the pt we ended on in previous step
uint16_t firstCPtIdx = (uint16_t)(vert - base) - 1;
@@ -530,9 +545,9 @@ bool GrDefaultPathRenderer::canDrawPath(const GrDrawTarget* target,
const SkStrokeRec& stroke,
bool antiAlias) const {
// this class can draw any path with any fill but doesn't do any anti-aliasing.
-
- return !antiAlias && !(SkPath::kConic_SegmentMask & path.getSegmentMasks()) &&
- (stroke.isFillStyle() || IsStrokeHairlineOrEquivalent(stroke, viewMatrix, NULL));
+ return !antiAlias && (stroke.isFillStyle() || IsStrokeHairlineOrEquivalent(stroke,
+ viewMatrix,
+ NULL));
}
bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 81dc103e02..8e7a01d091 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -166,6 +166,14 @@ int GrPathUtils::worstCasePointCount(const SkPath& path, int* subpaths,
case SkPath::kLine_Verb:
pointCount += 1;
break;
+ case SkPath::kConic_Verb: {
+ SkScalar weight = iter.conicWeight();
+ SkAutoConicToQuads converter;
+ const SkPoint* quadPts = converter.computeQuads(pts, weight, 0.25f);
+ for (int i = 0; i < converter.countQuads(); ++i) {
+ pointCount += quadraticPointCount(quadPts + 2*i, tol);
+ }
+ }
case SkPath::kQuad_Verb:
pointCount += quadraticPointCount(pts, tol);
break;