本文整理汇总了C++中GrDrawState::positionAttributeIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ GrDrawState::positionAttributeIndex方法的具体用法?C++ GrDrawState::positionAttributeIndex怎么用?C++ GrDrawState::positionAttributeIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrDrawState
的用法示例。
在下文中一共展示了GrDrawState::positionAttributeIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Build
//.........这里部分代码省略.........
if (readsDst) {
GrAssert(NULL != dstCopy);
desc->fDstRead = GrGLShaderBuilder::KeyForDstRead(dstCopy->texture(), gpu->glCaps());
GrAssert(0 != desc->fDstRead);
} else {
desc->fDstRead = 0;
}
desc->fCoverageOutput = kModulate_CoverageOutput;
// Currently the experimental GS will only work with triangle prims (and it doesn't do anything
// other than pass through values from the VS to the FS anyway).
#if GR_GL_EXPERIMENTAL_GS
#if 0
desc->fExperimentalGS = gpu->caps().geometryShaderSupport();
#else
desc->fExperimentalGS = false;
#endif
#endif
// We leave this set to kNumStages until we discover that the coverage/color distinction is
// material to the generated program. We do this to avoid distinct keys that generate equivalent
// programs.
desc->fFirstCoverageStage = GrDrawState::kNumStages;
// This tracks the actual first coverage stage.
int firstCoverageStage = GrDrawState::kNumStages;
desc->fDiscardIfZeroCoverage = false; // Enabled below if stenciling and there is coverage.
bool hasCoverage = false;
// If we're rendering coverage-as-color then it's as though there are no coverage stages.
if (!drawState.isCoverageDrawing()) {
// We can have coverage either through a stage or coverage vertex attributes.
if (drawState.getFirstCoverageStage() <= lastEnabledStage) {
firstCoverageStage = drawState.getFirstCoverageStage();
hasCoverage = true;
} else {
hasCoverage = requiresCoverageAttrib;
}
}
if (hasCoverage) {
// color filter is applied between color/coverage computation
if (SkXfermode::kDst_Mode != desc->fColorFilterXfermode) {
desc->fFirstCoverageStage = firstCoverageStage;
}
// If we're stenciling then we want to discard samples that have zero coverage
if (drawState.getStencil().doesWrite()) {
desc->fDiscardIfZeroCoverage = true;
desc->fFirstCoverageStage = firstCoverageStage;
}
if (gpu->caps()->dualSourceBlendingSupport() &&
!(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
GrDrawState::kCoverageAsAlpha_BlendOptFlag))) {
if (kZero_GrBlendCoeff == dstCoeff) {
// write the coverage value to second color
desc->fCoverageOutput = kSecondaryCoverage_CoverageOutput;
desc->fFirstCoverageStage = firstCoverageStage;
} else if (kSA_GrBlendCoeff == dstCoeff) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
desc->fCoverageOutput = kSecondaryCoverageISA_CoverageOutput;
desc->fFirstCoverageStage = firstCoverageStage;
} else if (kSC_GrBlendCoeff == dstCoeff) {
// SA dst coeff becomes 1-(1-SA)*coverage when dst is partially covered.
desc->fCoverageOutput = kSecondaryCoverageISC_CoverageOutput;
desc->fFirstCoverageStage = firstCoverageStage;
}
} else if (readsDst &&
kOne_GrBlendCoeff == drawState.getSrcBlendCoeff() &&
kZero_GrBlendCoeff == drawState.getDstBlendCoeff()) {
desc->fCoverageOutput = kCombineWithDst_CoverageOutput;
desc->fFirstCoverageStage = firstCoverageStage;
}
}
desc->fPositionAttributeIndex = drawState.positionAttributeIndex();
desc->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex();
// For constant color and coverage we need an attribute with an index beyond those already set
int availableAttributeIndex = drawState.getVertexAttribCount();
if (requiresColorAttrib) {
desc->fColorAttributeIndex = drawState.colorVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fColorInput) {
GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
desc->fColorAttributeIndex = availableAttributeIndex;
availableAttributeIndex++;
} else {
desc->fColorAttributeIndex = -1;
}
if (requiresCoverageAttrib) {
desc->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == desc->fCoverageInput) {
GrAssert(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
desc->fCoverageAttributeIndex = availableAttributeIndex;
} else {
desc->fCoverageAttributeIndex = -1;
}
}
示例2: Build
//.........这里部分代码省略.........
bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == drawState.getCoverageColor();
if (skipCoverage) {
header->fCoverageInput = kTransBlack_ColorInput;
} else if (covIsSolidWhite || !inputCoverageIsUsed) {
header->fCoverageInput = kSolidWhite_ColorInput;
} else if (defaultToUniformInputs && !requiresCoverageAttrib) {
header->fCoverageInput = kUniform_ColorInput;
} else {
header->fCoverageInput = kAttribute_ColorInput;
header->fHasVertexCode = true;
}
if (readsDst) {
SkASSERT(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport());
const GrTexture* dstCopyTexture = NULL;
if (NULL != dstCopy) {
dstCopyTexture = dstCopy->texture();
}
header->fDstReadKey = GrGLShaderBuilder::KeyForDstRead(dstCopyTexture, gpu->glCaps());
SkASSERT(0 != header->fDstReadKey);
} else {
header->fDstReadKey = 0;
}
if (readFragPosition) {
header->fFragPosKey = GrGLShaderBuilder::KeyForFragmentPosition(drawState.getRenderTarget(),
gpu->glCaps());
} else {
header->fFragPosKey = 0;
}
// Record attribute indices
header->fPositionAttributeIndex = drawState.positionAttributeIndex();
header->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex();
// For constant color and coverage we need an attribute with an index beyond those already set
int availableAttributeIndex = drawState.getVertexAttribCount();
if (requiresColorAttrib) {
header->fColorAttributeIndex = drawState.colorVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fColorAttributeIndex = availableAttributeIndex;
availableAttributeIndex++;
} else {
header->fColorAttributeIndex = -1;
}
if (requiresCoverageAttrib) {
header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fCoverageAttributeIndex = availableAttributeIndex;
} else {
header->fCoverageAttributeIndex = -1;
}
// Here we deal with whether/how we handle color and coverage separately.
// Set this default and then possibly change our mind if there is coverage.
header->fCoverageOutput = kModulate_CoverageOutput;
// If we do have coverage determine whether it matters.
bool separateCoverageFromColor = false;
if (!drawState.isCoverageDrawing() && !skipCoverage &&
(drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) {
示例3: Build
//.........这里部分代码省略.........
bool covIsSolidWhite = !requiresCoverageAttrib && 0xffffffff == drawState.getCoverageColor();
if ((covIsSolidWhite || !inputCoverageIsUsed) && !skipCoverage) {
header->fCoverageInput = kAllOnes_ColorInput;
} else if (defaultToUniformInputs && !requiresCoverageAttrib && inputCoverageIsUsed) {
header->fCoverageInput = kUniform_ColorInput;
} else {
header->fCoverageInput = kAttribute_ColorInput;
header->fRequiresVertexShader = true;
}
if (readsDst) {
SkASSERT(NULL != dstCopy || gpu->caps()->dstReadInShaderSupport());
const GrTexture* dstCopyTexture = NULL;
if (NULL != dstCopy) {
dstCopyTexture = dstCopy->texture();
}
header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTexture,
gpu->glCaps());
SkASSERT(0 != header->fDstReadKey);
} else {
header->fDstReadKey = 0;
}
if (readFragPosition) {
header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition(
drawState.getRenderTarget(), gpu->glCaps());
} else {
header->fFragPosKey = 0;
}
// Record attribute indices
header->fPositionAttributeIndex = drawState.positionAttributeIndex();
header->fLocalCoordAttributeIndex = drawState.localCoordAttributeIndex();
// For constant color and coverage we need an attribute with an index beyond those already set
int availableAttributeIndex = drawState.getVertexAttribCount();
if (requiresColorAttrib) {
header->fColorAttributeIndex = drawState.colorVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == header->fColorInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fColorAttributeIndex = availableAttributeIndex;
availableAttributeIndex++;
} else {
header->fColorAttributeIndex = -1;
}
if (requiresCoverageAttrib) {
header->fCoverageAttributeIndex = drawState.coverageVertexAttributeIndex();
} else if (GrGLProgramDesc::kAttribute_ColorInput == header->fCoverageInput) {
SkASSERT(availableAttributeIndex < GrDrawState::kMaxVertexAttribCnt);
header->fCoverageAttributeIndex = availableAttributeIndex;
} else {
header->fCoverageAttributeIndex = -1;
}
// Here we deal with whether/how we handle color and coverage separately.
// Set this default and then possibly change our mind if there is coverage.
header->fCoverageOutput = kModulate_CoverageOutput;
// If we do have coverage determine whether it matters.
bool separateCoverageFromColor = drawState.hasGeometryProcessor();
if (!drawState.isCoverageDrawing() && !skipCoverage &&
(drawState.numCoverageStages() > 0 ||