本文整理汇总了C++中GrGLSLFPFragmentBuilder::getProgramBuilder方法的典型用法代码示例。如果您正苦于以下问题:C++ GrGLSLFPFragmentBuilder::getProgramBuilder方法的具体用法?C++ GrGLSLFPFragmentBuilder::getProgramBuilder怎么用?C++ GrGLSLFPFragmentBuilder::getProgramBuilder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrGLSLFPFragmentBuilder
的用法示例。
在下文中一共展示了GrGLSLFPFragmentBuilder::getProgramBuilder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitCode
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrCircleBlurFragmentProcessor& _outer =
args.fFp.cast<GrCircleBlurFragmentProcessor>();
(void)_outer;
auto circleRect = _outer.circleRect();
(void)circleRect;
auto textureRadius = _outer.textureRadius();
(void)textureRadius;
auto solidRadius = _outer.solidRadius();
(void)solidRadius;
fCircleDataVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
kDefault_GrSLPrecision, "circleData");
fragBuilder->codeAppendf(
"half2 vec = half2(half((sk_FragCoord.x - float(%s.x)) * float(%s.w)), "
"half((sk_FragCoord.y - float(%s.y)) * float(%s.w)));\nhalf dist = "
"float(length(vec)) + (0.5 - float(%s.z)) * float(%s.w);\n%s = %s * texture(%s, "
"float2(half2(dist, 0.5))).%s.w;\n",
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar),
args.fUniformHandler->getUniformCStr(fCircleDataVar), args.fOutputColor,
args.fInputColor ? args.fInputColor : "half4(1)",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
}
示例2: emitCode
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrMagnifierEffect& _outer = args.fFp.cast<GrMagnifierEffect>();
(void)_outer;
auto bounds = _outer.bounds();
(void)bounds;
auto srcRect = _outer.srcRect();
(void)srcRect;
auto xInvZoom = _outer.xInvZoom();
(void)xInvZoom;
auto yInvZoom = _outer.yInvZoom();
(void)yInvZoom;
auto xInvInset = _outer.xInvInset();
(void)xInvInset;
auto yInvInset = _outer.yInvInset();
(void)yInvInset;
fBoundsUniformVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kFloat4_GrSLType, kDefault_GrSLPrecision, "boundsUniform");
fXInvZoomVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvZoom");
fYInvZoomVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvZoom");
fXInvInsetVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "xInvInset");
fYInvInsetVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kFloat_GrSLType, kDefault_GrSLPrecision, "yInvInset");
fOffsetVar = args.fUniformHandler->addUniform(
kFragment_GrShaderFlag, kHalf2_GrSLType, kDefault_GrSLPrecision, "offset");
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"float2 coord = %s;\nfloat2 zoom_coord = float2(%s + half2(coord * "
"float2(half2(half(%s), half(%s)))));\nfloat2 delta = (coord - %s.xy) * "
"%s.zw;\ndelta = min(delta, float2(half2(1.0, 1.0) - half2(delta)));\ndelta *= "
"float2(half2(half(%s), half(%s)));\nhalf weight = 0.0;\nif (delta.x < 2.0 && "
"delta.y < 2.0) {\n delta = float2(half2(2.0, 2.0) - half2(delta));\n half "
"dist = half(length(delta));\n dist = half(max(2.0 - float(dist), 0.0));\n "
"weight = half(min(float(dist * dist), 1.0));\n} else {\n ",
sk_TransformedCoords2D_0.c_str(),
args.fUniformHandler->getUniformCStr(fOffsetVar),
args.fUniformHandler->getUniformCStr(fXInvZoomVar),
args.fUniformHandler->getUniformCStr(fYInvZoomVar),
args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
args.fUniformHandler->getUniformCStr(fBoundsUniformVar),
args.fUniformHandler->getUniformCStr(fXInvInsetVar),
args.fUniformHandler->getUniformCStr(fYInvInsetVar));
fragBuilder->codeAppendf(
"float2 delta_squared = delta * delta;\n weight = half(min(min(delta_squared.x, "
"delta_squared.y), 1.0));\n}\n%s = texture(%s, mix(coord, zoom_coord, "
"float(weight))).%s;\n",
args.fOutputColor,
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
}
示例3: emitCode
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrSimpleTextureEffect& _outer = args.fFp.cast<GrSimpleTextureEffect>();
(void)_outer;
auto matrix = _outer.matrix();
(void)matrix;
SkString sk_TransformedCoords2D_0 = fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);
fragBuilder->codeAppendf(
"%s = %s * texture(%s, %s).%s;\n", args.fOutputColor,
args.fInputColor ? args.fInputColor : "half4(1)",
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
sk_TransformedCoords2D_0.c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
}
示例4: emitCode
void emitCode(EmitArgs& args) override {
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
const GrRectBlurEffect& _outer = args.fFp.cast<GrRectBlurEffect>();
(void)_outer;
auto rect = _outer.rect();
(void)rect;
auto sigma = _outer.sigma();
(void)sigma;
highPrecision = ((((abs(rect.left()) > 16000.0 || abs(rect.top()) > 16000.0) ||
abs(rect.right()) > 16000.0) ||
abs(rect.bottom()) > 16000.0) ||
abs(rect.right() - rect.left()) > 16000.0) ||
abs(rect.bottom() - rect.top()) > 16000.0;
fRectVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
kDefault_GrSLPrecision, "rect");
if (!highPrecision) {
fProxyRectHalfVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
kDefault_GrSLPrecision, "proxyRectHalf");
}
if (highPrecision) {
fProxyRectFloatVar =
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kFloat4_GrSLType,
kDefault_GrSLPrecision, "proxyRectFloat");
}
fProfileSizeVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf_GrSLType,
kDefault_GrSLPrecision, "profileSize");
fragBuilder->codeAppendf(
"bool highPrecision = %s;\[email protected] (highPrecision) {\n float2 translatedPos = "
"sk_FragCoord.xy - %s.xy;\n float width = %s.z - %s.x;\n float height = %s.w "
"- %s.y;\n float2 smallDims = float2(width - float(%s), height - float(%s));\n "
" float center = 2.0 * floor(float(float(%s / 2.0) + 0.25)) - 1.0;\n float2 wh "
"= smallDims - float2(center, center);\n half hcoord = "
"half((abs(translatedPos.x - 0.5 * width) - 0.5 * wh.x) / float(%s));\n half "
"hlookup = texture(%s, float2(float(hcoord), 0.5)).%s.w",
(highPrecision ? "true" : "false"), args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str());
fragBuilder->codeAppendf(
";\n half vcoord = half((abs(translatedPos.y - 0.5 * height) - 0.5 * wh.y) / "
"float(%s));\n half vlookup = texture(%s, float2(float(vcoord), 0.5)).%s.w;\n "
" %s = (%s * hlookup) * vlookup;\n} else {\n half2 translatedPos = "
"half2(sk_FragCoord.xy - %s.xy);\n half width = half(%s.z - %s.x);\n half "
"height = half(%s.w - %s.y);\n half2 smallDims = half2(width - %s, height - "
"%s);\n half center = half(2.0 * floor(float(float(%s / 2.0) + 0.25)) - 1.0);\n "
" half2 wh = smallDims - half2(float2(floa",
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
args.fOutputColor, args.fInputColor ? args.fInputColor : "half4(1)",
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fRectVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
args.fUniformHandler->getUniformCStr(fProfileSizeVar));
fragBuilder->codeAppendf(
"t(center), float(center)));\n half hcoord = "
"half((abs(float(float(translatedPos.x) - 0.5 * float(width))) - 0.5 * "
"float(wh.x)) / float(%s));\n half hlookup = texture(%s, float2(float(hcoord), "
"0.5)).%s.w;\n half vcoord = half((abs(float(float(translatedPos.y) - 0.5 * "
"float(height))) - 0.5 * float(wh.y)) / float(%s));\n half vlookup = "
"texture(%s, float2(float(vcoord), 0.5)).%s.w;\n %s = (%s * hlookup) * "
"vlookup;\n}\n",
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
args.fUniformHandler->getUniformCStr(fProfileSizeVar),
fragBuilder->getProgramBuilder()->samplerVariable(args.fTexSamplers[0]).c_str(),
fragBuilder->getProgramBuilder()->samplerSwizzle(args.fTexSamplers[0]).c_str(),
args.fOutputColor, args.fInputColor ? args.fInputColor : "half4(1)");
}