}
bool GrDrawState::setIdentityViewMatrix() {
- if (this->numTotalStages()) {
+ if (this->numFragmentStages()) {
SkMatrix invVM;
if (!fViewMatrix.invert(&invVM)) {
// sad trombone sound
return true;
}
+ if (this->numCoverageStages() > 0) {
+ return false;
+ }
+
GrProcessor::InvariantOutput inout;
inout.fIsSingleComponent = true;
// Initialize to an unknown starting coverage if per-vertex coverage is specified.
inout.fValidFlags = kRGBA_GrColorComponentFlags;
}
- // Run through the coverage stages and see if the coverage will be all ones at the end.
+ // check the coverage output from the GP
if (this->hasGeometryProcessor()) {
fGeometryProcessor->computeInvariantOutput(&inout);
}
- for (int s = 0; s < this->numCoverageStages(); ++s) {
- const GrProcessor* processor = this->getCoverageStage(s).getProcessor();
- processor->computeInvariantOutput(&inout);
- }
return inout.isSolidWhite();
}
}
fViewMatrix = drawState->getViewMatrix();
- if (0 == drawState->numTotalStages()) {
+ if (0 == drawState->numFragmentStages()) {
drawState->fViewMatrix.reset();
fDrawState = drawState;
fNumColorStages = 0;
}
void GrDrawState::AutoViewMatrixRestore::doEffectCoordChanges(const SkMatrix& coordChangeMatrix) {
- fSavedCoordChanges.reset(fDrawState->numTotalStages());
+ fSavedCoordChanges.reset(fDrawState->numFragmentStages());
int i = 0;
fNumColorStages = fDrawState->numColorStages();
int firstColorStageIdx = 0;
int firstCoverageStageIdx = 0;
- bool separateCoverageFromColor;
uint8_t fixedFunctionVAToRemove = 0;
this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInfo);
}
this->getStageStats(drawState, firstColorStageIdx, firstCoverageStageIdx, &descInfo);
- this->setOutputStateInfo(drawState, *gpu->caps(), firstCoverageStageIdx, &descInfo,
- &separateCoverageFromColor);
// Copy GeometryProcesssor from DS or ODS
if (drawState.hasGeometryProcessor()) {
if (firstCoverageStageIdx < drawState.numCoverageStages()) {
fFragmentStages.push_back_n(drawState.numCoverageStages() - firstCoverageStageIdx,
&drawState.getCoverageStage(firstCoverageStageIdx));
- if (!separateCoverageFromColor) {
- fNumColorStages = fFragmentStages.count();
- }
}
+ this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo);
+
// now create a key
gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
};
void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
const GrDrawTargetCaps& caps,
- int firstCoverageStageIdx,
- GrProgramDesc::DescInfo* descInfo,
- bool* separateCoverageFromColor) {
+ GrProgramDesc::DescInfo* descInfo) {
// Set this default and then possibly change our mind if there is coverage.
descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
- // If we do have coverage determine whether it matters.
- *separateCoverageFromColor = this->hasGeometryProcessor();
- if (!this->isCoverageDrawing() &&
- (ds.numCoverageStages() - firstCoverageStageIdx > 0 ||
- ds.hasGeometryProcessor() ||
- descInfo->hasCoverageVertexAttribute())) {
-
+ // If we do have coverage determine whether it matters. Dual source blending is expensive so
+ // we don't do it if we are doing coverage drawing. If we aren't then We always do dual source
+ // blending if we have any effective coverage stages OR the geometry processor doesn't emits
+ // solid coverage.
+ // TODO move the gp logic into the GP base class
+ if (!this->isCoverageDrawing() && !ds.hasSolidCoverage()) {
if (caps.dualSourceBlendingSupport()) {
if (kZero_GrBlendCoeff == fDstBlend) {
// write the coverage value to second color
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverage_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
} else if (kSA_GrBlendCoeff == fDstBlend) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISA_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
} else if (kSC_GrBlendCoeff == fDstBlend) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
descInfo->fSecondaryOutputType = GrProgramDesc::kCoverageISC_SecondaryOutputType;
- *separateCoverageFromColor = true;
fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff;
}
} else if (descInfo->fReadsDst &&
kOne_GrBlendCoeff == fSrcBlend &&
kZero_GrBlendCoeff == fDstBlend) {
descInfo->fPrimaryOutputType = GrProgramDesc::kCombineWithDst_PrimaryOutputType;
- *separateCoverageFromColor = true;
}
}
}
template <class ProcessorKeyBuilder>
-bool
-GrGLProgramDescBuilder::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::StagedProcessor& stage,
- const GrGLCaps& caps,
- bool requiresLocalCoordAttrib,
- GrProgramDesc* desc,
- int* offsetAndSizeIndex) {
+bool GrGLProgramDescBuilder::BuildStagedProcessorKey(
+ const typename ProcessorKeyBuilder::StagedProcessor& stage,
+ const GrGLCaps& caps,
+ bool requiresLocalCoordAttrib,
+ GrProgramDesc* desc,
+ int* offsetAndSizeIndex) {
GrProcessorKeyBuilder b(&desc->fKey);
uint16_t processorKeySize;
uint32_t processorOffset = desc->fKey.count();
}
bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState,
- const GrProgramDesc::DescInfo& descInfo,
- GrGpu::DrawType drawType,
- GrGpuGL* gpu,
- const GrDeviceCoordTexture* dstCopy,
- GrProgramDesc* desc) {
+ const GrProgramDesc::DescInfo& descInfo,
+ GrGpu::DrawType drawType,
+ GrGpuGL* gpu,
+ const GrDeviceCoordTexture* dstCopy,
+ GrProgramDesc* desc) {
bool inputColorIsUsed = descInfo.fInputColorIsUsed;
bool inputCoverageIsUsed = descInfo.fInputCoverageIsUsed;