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