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/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 3c7b146..493420d 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -66,7 +66,7 @@
uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
GrDefaultGeoProcFactory::kColor_GPType;
flags |= hasLocalCoords ? GrDefaultGeoProcFactory::kLocalCoord_GPType : 0;
- drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(flags))->unref();
+ drawState->setGeometryProcessor(GrDefaultGeoProcFactory::Create(color, flags))->unref();
if (0xFF == GrColorUnpackA(color)) {
drawState->setHint(GrDrawState::kVertexColorsAreOpaque_Hint, true);
}
@@ -110,12 +110,12 @@
static inline bool cmd_has_trace_marker(uint8_t cmd) { return SkToBool(cmd & kTraceCmdBit); }
void GrInOrderDrawBuffer::onDrawRect(GrDrawState* ds,
+ GrColor color,
const SkRect& rect,
const SkRect* localRect,
const SkMatrix* localMatrix) {
GrDrawState::AutoRestoreEffects are(ds);
- GrColor color = ds->getColor();
set_vertex_attributes(ds, SkToBool(localRect), color);
size_t vstride = ds->getGeometryProcessor()->getVertexStride();
@@ -226,7 +226,9 @@
const GrDeviceCoordTexture* dstCopy) {
SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
- if (!this->recordStateAndShouldDraw(ds, GrGpu::PrimTypeToDrawType(info.primitiveType()),
+ const GrGeometryProcessor* gp = ds.getGeometryProcessor();
+ if (!this->recordStateAndShouldDraw(ds, gp->getColor(), gp->getCoverage(),
+ GrGpu::PrimTypeToDrawType(info.primitiveType()),
scissorState, dstCopy)) {
return;
}
@@ -251,7 +253,8 @@
const GrClipMaskManager::ScissorState& scissorState,
const GrStencilSettings& stencilSettings) {
// Only compare the subset of GrDrawState relevant to path stenciling?
- if (!this->recordStateAndShouldDraw(ds, GrGpu::kStencilPath_DrawType, scissorState, NULL)) {
+ if (!this->recordStateAndShouldDraw(ds, GrColor_WHITE, 0xff, GrGpu::kStencilPath_DrawType,
+ scissorState, NULL)) {
return;
}
StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path));
@@ -260,12 +263,14 @@
}
void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
+ GrColor color,
const GrPath* path,
const GrClipMaskManager::ScissorState& scissorState,
const GrStencilSettings& stencilSettings,
const GrDeviceCoordTexture* dstCopy) {
// TODO: Only compare the subset of GrDrawState relevant to path covering?
- if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorState, dstCopy)) {
+ if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState,
+ dstCopy)) {
return;
}
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
@@ -274,6 +279,7 @@
}
void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
+ GrColor color,
const GrPathRange* pathRange,
const void* indices,
PathIndexType indexType,
@@ -287,7 +293,8 @@
SkASSERT(indices);
SkASSERT(transformValues);
- if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorState, dstCopy)) {
+ if (!this->recordStateAndShouldDraw(ds, color, 0xff, GrGpu::kDrawPath_DrawType, scissorState,
+ dstCopy)) {
return;
}
@@ -317,7 +324,7 @@
transformType == previous->fTransformType &&
stencilSettings == previous->fStencilSettings &&
path_fill_type_is_winding(stencilSettings) &&
- !ds.willBlendWithDst()) {
+ !ds.willBlendWithDst(color, GrColor_WHITE)) {
// Fold this DrawPaths call into the one previous.
previous->fCount += count;
return;
@@ -483,12 +490,14 @@
}
bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
+ GrColor color,
+ uint8_t coverage,
GrGpu::DrawType drawType,
const GrClipMaskManager::ScissorState& scissor,
const GrDeviceCoordTexture* dstCopy) {
SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
- (ds, *this->getGpu()->caps(), scissor, dstCopy,
- drawType));
+ (ds, color, coverage, *this->getGpu()->caps(), scissor,
+ dstCopy, drawType));
if (ss->fState.mustSkip()) {
fCmdBuffer.pop_back();
return false;