This cl moves color and coverage off of drawstate. In an effort to keep this CL manageable, I have left the compute invariant input / output in a bit of a strange state(fixing this will be complicated).
In addition, NVPR makes this very complicated, and I haven't quite figured out a good way to handle it, so for now color and coverage DO live on optstate, but I will figure out some way to refactor that in future CLs.
BUG=skia:
Review URL: https://codereview.chromium.org/783763002
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index 4d9026f..24d3c45 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -233,12 +233,10 @@
}
}
- // TODO this is really wierd, I just need default vertex stride, can I think of a better way?
- SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Create());
- if (!arg->set(target, maxPts, gp->getVertexStride(), maxIdxs)) {
+ if (!arg->set(target, maxPts, GrDefaultGeoProcFactory::DefaultVertexStride(), maxIdxs)) {
return false;
}
- SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
+ SkASSERT(GrDefaultGeoProcFactory::DefaultVertexStride() == sizeof(SkPoint));
uint16_t* idxBase = reinterpret_cast<uint16_t*>(arg->indices());
uint16_t* idx = idxBase;
@@ -330,6 +328,7 @@
bool GrDefaultPathRenderer::internalDrawPath(GrDrawTarget* target,
GrDrawState* drawState,
+ GrColor color,
const SkPath& path,
const SkStrokeRec& origStroke,
bool stencilOnly) {
@@ -337,10 +336,10 @@
SkTCopyOnFirstWrite<SkStrokeRec> stroke(origStroke);
SkScalar hairlineCoverage;
+ uint8_t newCoverage = 0xff;
if (IsStrokeHairlineOrEquivalent(*stroke, drawState->getViewMatrix(),
&hairlineCoverage)) {
- uint8_t newCoverage = SkScalarRoundToInt(hairlineCoverage * drawState->getCoverage());
- drawState->setCoverage(newCoverage);
+ newCoverage = SkScalarRoundToInt(hairlineCoverage * 0xff);
if (!stroke->isHairlineStyle()) {
stroke.writable()->setHairlineStyle();
@@ -493,13 +492,16 @@
bounds = path.getBounds();
}
GrDrawTarget::AutoGeometryPush agp(target);
- target->drawSimpleRect(drawState, bounds);
+ target->drawSimpleRect(drawState, color, bounds);
} else {
if (passCount > 1) {
drawState->enableState(GrDrawState::kNoColorWrites_StateBit);
}
GrDrawState::AutoRestoreEffects are(drawState);
- drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create())->unref();
+ drawState->setGeometryProcessor(
+ GrDefaultGeoProcFactory::Create(color,
+ GrDefaultGeoProcFactory::kPosition_GPType,
+ newCoverage))->unref();
if (indexCnt) {
target->drawIndexed(drawState,
primType,
@@ -530,11 +532,13 @@
bool GrDefaultPathRenderer::onDrawPath(GrDrawTarget* target,
GrDrawState* drawState,
+ GrColor color,
const SkPath& path,
const SkStrokeRec& stroke,
bool antiAlias) {
return this->internalDrawPath(target,
drawState,
+ color,
path,
stroke,
false);
@@ -546,5 +550,5 @@
const SkStrokeRec& stroke) {
SkASSERT(SkPath::kInverseEvenOdd_FillType != path.getFillType());
SkASSERT(SkPath::kInverseWinding_FillType != path.getFillType());
- this->internalDrawPath(target, drawState, path, stroke, true);
+ this->internalDrawPath(target, drawState, GrColor_WHITE, path, stroke, true);
}