本文整理汇总了C++中GrGLSLVertexBuilder::emitAttributes方法的典型用法代码示例。如果您正苦于以下问题:C++ GrGLSLVertexBuilder::emitAttributes方法的具体用法?C++ GrGLSLVertexBuilder::emitAttributes怎么用?C++ GrGLSLVertexBuilder::emitAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrGLSLVertexBuilder
的用法示例。
在下文中一共展示了GrGLSLVertexBuilder::emitAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEmitCode
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
GrGLSLGPBuilder* pb = args.fPB;
GrGLSLVertexBuilder* vsBuilder = pb->getVertexShaderBuilder();
// emit attributes
vsBuilder->emitAttributes(cte);
// compute numbers to be hardcoded to convert texture coordinates from int to float
SkASSERT(cte.numTextures() == 1);
GrTexture* atlas = cte.textureAccess(0).getTexture();
SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
SkScalar recipWidth = 1.0f / atlas->width();
SkScalar recipHeight = 1.0f / atlas->height();
GrGLSLVertToFrag v(kVec2f_GrSLType);
pb->addVarying("TextureCoords", &v);
vsBuilder->codeAppendf("%s = vec2(%.*f, %.*f) * %s;", v.vsOut(),
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipWidth,
GR_SIGNIFICANT_POW2_DECIMAL_DIG, recipHeight,
cte.inTextureCoords()->fName);
// Setup pass through color
if (!cte.colorIgnored()) {
if (cte.hasVertexColor()) {
pb->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
} else {
this->setupUniformColor(pb, args.fOutputColor, &fColorUniform);
}
}
// Setup position
this->setupPosition(pb, gpArgs, cte.inPosition()->fName);
// emit transforms
this->emitTransforms(args.fPB, gpArgs->fPositionVar, cte.inPosition()->fName,
cte.localMatrix(), args.fTransformsIn, args.fTransformsOut);
GrGLSLFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
if (cte.maskFormat() == kARGB_GrMaskFormat) {
fsBuilder->codeAppendf("%s = ", args.fOutputColor);
fsBuilder->appendTextureLookupAndModulate(args.fOutputColor,
args.fSamplers[0],
v.fsIn(),
kVec2f_GrSLType);
fsBuilder->codeAppend(";");
fsBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
} else {
fsBuilder->codeAppendf("%s = ", args.fOutputCoverage);
fsBuilder->appendTextureLookup(args.fSamplers[0], v.fsIn(), kVec2f_GrSLType);
fsBuilder->codeAppend(";");
if (cte.maskFormat() == kA565_GrMaskFormat) {
// set alpha to be max of rgb coverage
fsBuilder->codeAppendf("%s.a = max(max(%s.r, %s.g), %s.b);",
args.fOutputCoverage, args.fOutputCoverage,
args.fOutputCoverage, args.fOutputCoverage);
}
}
}