| Index: src/gpu/GrAAHairLinePathRenderer.cpp
|
| ===================================================================
|
| --- src/gpu/GrAAHairLinePathRenderer.cpp (revision 8328)
|
| +++ src/gpu/GrAAHairLinePathRenderer.cpp (working copy)
|
| @@ -17,6 +17,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
|
| @@ -507,7 +509,6 @@
|
| {kVec2f_GrVertexAttribType, 0},
|
| {kVec4f_GrVertexAttribType, sizeof(GrPoint)}
|
| };
|
| - static const GrAttribBindings kBindings = GrDrawState::kEdge_AttribBindingsBit;
|
| SkMatrix viewM = drawState->getViewMatrix();
|
|
|
| PREALLOC_PTARRAY(128) lines;
|
| @@ -521,8 +522,7 @@
|
|
|
| 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)) {
|
| @@ -588,8 +588,10 @@
|
| return false;
|
| }
|
|
|
| + GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kPreserve_ASRInit);
|
| + GrDrawState* drawState = target->drawState();
|
| +
|
| GrDrawState::AutoDeviceCoordDraw adcd;
|
| - GrDrawState* drawState = target->drawState();
|
| // createGeom transforms the geometry to device space when the matrix does not have
|
| // perspective.
|
| if (!drawState->getViewMatrix().hasPerspective()) {
|
| @@ -602,12 +604,21 @@
|
| // 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,
|
| @@ -620,7 +631,7 @@
|
|
|
| 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,
|
| @@ -630,6 +641,6 @@
|
| kIdxsPerQuad*n); // iCount
|
| quads += n;
|
| }
|
| - drawState->setVertexEdgeType(oldEdgeType);
|
| +
|
| return true;
|
| }
|
|
|