Make SkSL CPP code gen copy explicit coord status for cloned FPs
Change-Id: I1479136de8fcab32e2be661fd5fae020b319aab8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272458 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
ca85b9b8e3
commit
b243b4389f
@ -71,10 +71,16 @@ GrComposeLerpEffect::GrComposeLerpEffect(const GrComposeLerpEffect& src)
|
||||
, child2_index(src.child2_index)
|
||||
, weight(src.weight) {
|
||||
if (child1_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(child1_index).clone());
|
||||
auto clone = src.childProcessor(child1_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(child1_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
if (child2_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(child2_index).clone());
|
||||
auto clone = src.childProcessor(child2_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(child2_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrComposeLerpEffect::clone() const {
|
||||
|
@ -63,12 +63,23 @@ GrComposeLerpRedEffect::GrComposeLerpRedEffect(const GrComposeLerpRedEffect& src
|
||||
, child2_index(src.child2_index)
|
||||
, lerp_index(src.lerp_index) {
|
||||
if (child1_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(child1_index).clone());
|
||||
auto clone = src.childProcessor(child1_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(child1_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
if (child2_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(child2_index).clone());
|
||||
auto clone = src.childProcessor(child2_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(child2_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
{
|
||||
auto clone = src.childProcessor(lerp_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(lerp_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
this->registerChildProcessor(src.childProcessor(lerp_index).clone());
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrComposeLerpRedEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrComposeLerpRedEffect(*this));
|
||||
|
@ -68,9 +68,17 @@ GrMixerEffect::GrMixerEffect(const GrMixerEffect& src)
|
||||
, fp0_index(src.fp0_index)
|
||||
, fp1_index(src.fp1_index)
|
||||
, weight(src.weight) {
|
||||
this->registerChildProcessor(src.childProcessor(fp0_index).clone());
|
||||
{
|
||||
auto clone = src.childProcessor(fp0_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(fp0_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
if (fp1_index >= 0) {
|
||||
this->registerChildProcessor(src.childProcessor(fp1_index).clone());
|
||||
auto clone = src.childProcessor(fp1_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(fp1_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrMixerEffect::clone() const {
|
||||
|
@ -91,7 +91,12 @@ GrOverrideInputFragmentProcessor::GrOverrideInputFragmentProcessor(
|
||||
, useUniform(src.useUniform)
|
||||
, uniformColor(src.uniformColor)
|
||||
, literalColor(src.literalColor) {
|
||||
this->registerChildProcessor(src.childProcessor(fp_index).clone());
|
||||
{
|
||||
auto clone = src.childProcessor(fp_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(fp_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrOverrideInputFragmentProcessor::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrOverrideInputFragmentProcessor(*this));
|
||||
|
@ -101,8 +101,18 @@ GrClampedGradientEffect::GrClampedGradientEffect(const GrClampedGradientEffect&
|
||||
, rightBorderColor(src.rightBorderColor)
|
||||
, makePremul(src.makePremul)
|
||||
, colorsAreOpaque(src.colorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(colorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(gradLayout_index).clone());
|
||||
{
|
||||
auto clone = src.childProcessor(colorizer_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(colorizer_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
{
|
||||
auto clone = src.childProcessor(gradLayout_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(gradLayout_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrClampedGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrClampedGradientEffect(*this));
|
||||
|
@ -77,8 +77,18 @@ GrTiledGradientEffect::GrTiledGradientEffect(const GrTiledGradientEffect& src)
|
||||
, mirror(src.mirror)
|
||||
, makePremul(src.makePremul)
|
||||
, colorsAreOpaque(src.colorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(colorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(gradLayout_index).clone());
|
||||
{
|
||||
auto clone = src.childProcessor(colorizer_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(colorizer_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
{
|
||||
auto clone = src.childProcessor(gradLayout_index).clone();
|
||||
clone->setSampledWithExplicitCoords(
|
||||
src.childProcessor(gradLayout_index).isSampledWithExplicitCoords());
|
||||
this->registerChildProcessor(std::move(clone));
|
||||
}
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
|
||||
|
@ -1111,13 +1111,18 @@ void CPPCodeGenerator::writeClone() {
|
||||
} else if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
if (param->fType.kind() == Type::kNullable_Kind) {
|
||||
this->writef(" if (%s_index >= 0) {\n ", fieldName.c_str());
|
||||
}
|
||||
this->writef(" this->registerChildProcessor(src.childProcessor(%s_index)."
|
||||
"clone());\n", fieldName.c_str());
|
||||
if (param->fType.kind() == Type::kNullable_Kind) {
|
||||
this->writef(" }\n");
|
||||
this->writef(" if (%s_index >= 0) {\n", fieldName.c_str());
|
||||
} else {
|
||||
this->write(" {\n");
|
||||
}
|
||||
this->writef(
|
||||
" auto clone = src.childProcessor(%s_index).clone();\n"
|
||||
" clone->setSampledWithExplicitCoords(\n"
|
||||
" "
|
||||
"src.childProcessor(%s_index).isSampledWithExplicitCoords());\n"
|
||||
" this->registerChildProcessor(std::move(clone));\n"
|
||||
" }\n",
|
||||
fieldName.c_str(), fieldName.c_str());
|
||||
}
|
||||
}
|
||||
if (samplerCount) {
|
||||
|
@ -493,8 +493,18 @@ DEF_TEST(SkSLFPChildProcessors, r) {
|
||||
"_sample110 = this->invokeChild(_outer.child2_index, args);\n",
|
||||
"fragBuilder->codeAppendf(\"%s = %s * %s;\\n\", args.fOutputColor, _sample93.c_str(), "
|
||||
"_sample110.c_str());\n",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child1_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child1_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child2_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child2_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
@ -521,8 +531,18 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
|
||||
"SkString _input174(\"childOut1\");",
|
||||
"SkString _sample174;",
|
||||
"_sample174 = this->invokeChild(_outer.child2_index, _input174.c_str(), args);",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child1_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child1_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child2_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child2_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}"
|
||||
});
|
||||
}
|
||||
|
||||
@ -541,7 +561,12 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
|
||||
"SkString _sample64;",
|
||||
"_sample64 = this->invokeChild(_outer.child_index, _input64.c_str(), args);",
|
||||
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample64.c_str());",
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());",
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
@ -565,9 +590,19 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
|
||||
"SkString _sample93;",
|
||||
"_sample93 = this->invokeChild(_outer.child2_index, _input93.c_str(), args);",
|
||||
"fragBuilder->codeAppendf(\"%s = %s;\\n\", args.fOutputColor, _sample93.c_str());",
|
||||
"this->registerChildProcessor(src.childProcessor(child1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(child2_index).clone());"
|
||||
});
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child1_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child1_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child2_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child2_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLFPChildFPAndGlobal, r) {
|
||||
@ -594,8 +629,13 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
|
||||
"_sample130 = this->invokeChild(_outer.child_index, _input130.c_str(), args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
|
||||
" args.fOutputColor, _sample130.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
});
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
|
||||
@ -620,7 +660,12 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
|
||||
"_sample105 = this->invokeChild(_outer.child_index, _input105.c_str(), args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\","
|
||||
" args.fOutputColor, _sample105.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
@ -647,7 +692,12 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
|
||||
"_sample126 = this->invokeChild(_outer.child_index, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\","
|
||||
" args.fOutputColor, _sample126.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(child_index).clone());"
|
||||
"{",
|
||||
" auto clone = src.childProcessor(child_index).clone();",
|
||||
" clone->setSampledWithExplicitCoords(",
|
||||
" src.childProcessor(child_index).isSampledWithExplicitCoords());",
|
||||
" this->registerChildProcessor(std::move(clone));",
|
||||
"}",
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user