Make additional code paths go through GrDrawState helper classes for their matrix manipulations.
R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6615064
git-svn-id: http://skia.googlecode.com/svn/trunk@5856 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 5d30b24..06d8e71 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -587,29 +587,28 @@
return false;
}
- GrDrawTarget::AutoStateRestore asr;
+ 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()) {
- // we are going to whack the view matrix to identity to remove
- // perspective.
- asr.set(target,
- GrDrawTarget::kPreserve_ASRInit);
- drawState = target->drawState();
- if (!drawState->preConcatSamplerMatricesWithInverse(drawState->getViewMatrix())) {
+ adcd.set(drawState);
+ if (!adcd.succeeded()) {
return false;
}
- drawState->viewMatrix()->reset();
}
-
// TODO: See whether rendering lines as degenerate quads improves perf
// when we have a mix
+
+ GrDrawState::VertexEdgeType oldEdgeType = drawState->getVertexEdgeType();
+
target->setIndexSourceToBuffer(fLinesIndexBuffer);
int lines = 0;
int nBufLines = fLinesIndexBuffer->maxQuads();
+ drawState->setVertexEdgeType(GrDrawState::kHairLine_EdgeType);
while (lines < lineCnt) {
int n = GrMin(lineCnt - lines, nBufLines);
- drawState->setVertexEdgeType(GrDrawState::kHairLine_EdgeType);
target->drawIndexed(kTriangles_GrPrimitiveType,
kVertsPerLineSeg*lines, // startV
0, // startI
@@ -620,9 +619,9 @@
target->setIndexSourceToBuffer(fQuadsIndexBuffer);
int quads = 0;
+ drawState->setVertexEdgeType(GrDrawState::kHairQuad_EdgeType);
while (quads < quadCnt) {
int n = GrMin(quadCnt - quads, kNumQuadsInIdxBuffer);
- drawState->setVertexEdgeType(GrDrawState::kHairQuad_EdgeType);
target->drawIndexed(kTriangles_GrPrimitiveType,
4 * lineCnt + kVertsPerQuad*quads, // startV
0, // startI
@@ -630,6 +629,7 @@
kIdxsPerQuad*n); // iCount
quads += n;
}
+ drawState->setVertexEdgeType(oldEdgeType);
return true;
}