diff options
Diffstat (limited to 'src/gpu/GrAAHairLinePathRenderer.cpp')
-rw-r--r-- | src/gpu/GrAAHairLinePathRenderer.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp index 80304f822e..079c826e4e 100644 --- a/src/gpu/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/GrAAHairLinePathRenderer.cpp @@ -18,6 +18,8 @@ #include "SkStroke.h" #include "SkTemplates.h" +#include "effects/GrEdgeEffect.h" + namespace { // quadratics are rendered as 5-sided polys in order to bound the // AA stroke around the center-curve. See comments in push_quad_index_buffer and @@ -508,7 +510,6 @@ bool GrAAHairLinePathRenderer::createGeom( {kVec2f_GrVertexAttribType, 0}, {kVec4f_GrVertexAttribType, sizeof(GrPoint)} }; - static const GrAttribBindings kBindings = GrDrawState::kEdge_AttribBindingsBit; SkMatrix viewM = drawState->getViewMatrix(); PREALLOC_PTARRAY(128) lines; @@ -522,8 +523,7 @@ bool GrAAHairLinePathRenderer::createGeom( target->drawState()->setVertexAttribs(kAttribs, SK_ARRAY_COUNT(kAttribs)); target->drawState()->setAttribIndex(GrDrawState::kPosition_AttribIndex, 0); - target->drawState()->setAttribIndex(GrDrawState::kEdge_AttribIndex, 1); - target->drawState()->setAttribBindings(kBindings); + target->drawState()->setAttribBindings(GrDrawState::kDefault_AttribBindings); GrAssert(sizeof(Vertex) == target->getDrawState().getVertexSize()); if (!arg->set(target, vertCnt, 0)) { @@ -589,8 +589,10 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, return false; } - GrDrawState::AutoDeviceCoordDraw adcd; + GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit); GrDrawState* drawState = target->drawState(); + + GrDrawState::AutoDeviceCoordDraw adcd; // createGeom transforms the geometry to device space when the matrix does not have // perspective. if (!drawState->getViewMatrix().hasPerspective()) { @@ -603,12 +605,21 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, // TODO: See whether rendering lines as degenerate quads improves perf // when we have a mix - GrDrawState::VertexEdgeType oldEdgeType = drawState->getVertexEdgeType(); + enum { + // the edge effects share this stage with glyph rendering + // (kGlyphMaskStage in GrTextContext) && SW path rendering + // (kPathMaskStage in GrSWMaskHelper) + kEdgeEffectStage = GrPaint::kTotalStages, + }; + static const int kEdgeAttrIndex = 1; + GrEffectRef* hairLineEffect = GrEdgeEffect::Create(GrEdgeEffect::kHairLine_EdgeType); + GrEffectRef* hairQuadEffect = GrEdgeEffect::Create(GrEdgeEffect::kHairQuad_EdgeType); + target->setIndexSourceToBuffer(fLinesIndexBuffer); int lines = 0; int nBufLines = fLinesIndexBuffer->maxQuads(); - drawState->setVertexEdgeType(GrDrawState::kHairLine_EdgeType); + drawState->setEffect(kEdgeEffectStage, hairLineEffect, kEdgeAttrIndex)->unref(); while (lines < lineCnt) { int n = GrMin(lineCnt - lines, nBufLines); target->drawIndexed(kTriangles_GrPrimitiveType, @@ -621,7 +632,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, target->setIndexSourceToBuffer(fQuadsIndexBuffer); int quads = 0; - drawState->setVertexEdgeType(GrDrawState::kHairQuad_EdgeType); + drawState->setEffect(kEdgeEffectStage, hairQuadEffect, kEdgeAttrIndex)->unref(); while (quads < quadCnt) { int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer); target->drawIndexed(kTriangles_GrPrimitiveType, @@ -631,6 +642,6 @@ bool GrAAHairLinePathRenderer::onDrawPath(const SkPath& path, kIdxsPerQuad*n); // iCount quads += n; } - drawState->setVertexEdgeType(oldEdgeType); + return true; } |