Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: src/gpu/GrAAHairLinePathRenderer.cpp

Issue 13069003: Replace edge types with GrEdgeEffect. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrAAHairLinePathRenderer.cpp
===================================================================
--- src/gpu/GrAAHairLinePathRenderer.cpp (revision 8387)
+++ src/gpu/GrAAHairLinePathRenderer.cpp (working copy)
@@ -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 @@
{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 @@
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 @@
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()) {
@@ -603,12 +605,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,
@@ -621,7 +632,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,
@@ -631,6 +642,6 @@
kIdxsPerQuad*n); // iCount
quads += n;
}
- drawState->setVertexEdgeType(oldEdgeType);
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698