Revert "SkSL now supports null child processors"
This reverts commit 0e8dc4ce36
.
Reason for revert: ASAN complaints
Original change's description:
> SkSL now supports null child processors
>
> Bug: skia:
> Change-Id: Icb3f2d57b393e3d40247aaad98c17344b507f0d7
> Reviewed-on: https://skia-review.googlesource.com/c/193379
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
TBR=bsalomon@google.com,ethannicholas@google.com,fmalita@chromium.org
Change-Id: Ibf739b3c6afd32d44f6b20705922618c29960d16
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/c/194020
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
2356bf1471
commit
bce7d86270
@ -36,19 +36,18 @@ public:
|
||||
args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType,
|
||||
kDefault_GrSLPrecision, "rightBorderColor");
|
||||
SkString _child1("_child1");
|
||||
this->emitChild(_outer.gradLayout_index(), &_child1, args);
|
||||
this->emitChild(1, &_child1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else if (t.x < "
|
||||
"0.0) {\n %s = %s;\n} else if (t.x > 1.0) {\n %s = %s;\n} else {",
|
||||
_child1.c_str(),
|
||||
(_outer.childProcessor(_outer.gradLayout_index()).preservesOpaqueInput() ? "true"
|
||||
: "false"),
|
||||
(_outer.childProcessor(1).preservesOpaqueInput() ? "true" : "false"),
|
||||
args.fOutputColor, args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fLeftBorderColorVar), args.fOutputColor,
|
||||
args.fUniformHandler->getUniformCStr(fRightBorderColorVar));
|
||||
SkString _input0("t");
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.colorizer_index(), _input0.c_str(), &_child0, args);
|
||||
this->emitChild(0, _input0.c_str(), &_child0, args);
|
||||
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
|
||||
args.fOutputColor, _child0.c_str(),
|
||||
(_outer.makePremul() ? "true" : "false"), args.fOutputColor,
|
||||
@ -95,14 +94,12 @@ bool GrClampedGradientEffect::onIsEqual(const GrFragmentProcessor& other) const
|
||||
}
|
||||
GrClampedGradientEffect::GrClampedGradientEffect(const GrClampedGradientEffect& src)
|
||||
: INHERITED(kGrClampedGradientEffect_ClassID, src.optimizationFlags())
|
||||
, fColorizer_index(src.fColorizer_index)
|
||||
, fGradLayout_index(src.fGradLayout_index)
|
||||
, fLeftBorderColor(src.fLeftBorderColor)
|
||||
, fRightBorderColor(src.fRightBorderColor)
|
||||
, fMakePremul(src.fMakePremul)
|
||||
, fColorsAreOpaque(src.fColorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(fColorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(fGradLayout_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(0).clone());
|
||||
this->registerChildProcessor(src.childProcessor(1).clone());
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrClampedGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrClampedGradientEffect(*this));
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrClampedGradientEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
int colorizer_index() const { return fColorizer_index; }
|
||||
int gradLayout_index() const { return fGradLayout_index; }
|
||||
const SkPMColor4f& leftBorderColor() const { return fLeftBorderColor; }
|
||||
const SkPMColor4f& rightBorderColor() const { return fRightBorderColor; }
|
||||
bool makePremul() const { return fMakePremul; }
|
||||
@ -47,19 +45,13 @@ private:
|
||||
, fRightBorderColor(rightBorderColor)
|
||||
, fMakePremul(makePremul)
|
||||
, fColorsAreOpaque(colorsAreOpaque) {
|
||||
SkASSERT(colorizer);
|
||||
fColorizer_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(colorizer));
|
||||
SkASSERT(gradLayout);
|
||||
fGradLayout_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(gradLayout));
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int fColorizer_index = -1;
|
||||
int fGradLayout_index = -1;
|
||||
SkPMColor4f fLeftBorderColor;
|
||||
SkPMColor4f fRightBorderColor;
|
||||
bool fMakePremul;
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
auto colorsAreOpaque = _outer.colorsAreOpaque();
|
||||
(void)colorsAreOpaque;
|
||||
SkString _child1("_child1");
|
||||
this->emitChild(_outer.gradLayout_index(), &_child1, args);
|
||||
this->emitChild(1, &_child1, args);
|
||||
fragBuilder->codeAppendf(
|
||||
"half4 t = %s;\nif (!%s && t.y < 0.0) {\n %s = half4(0.0);\n} else {\n @if "
|
||||
"(%s) {\n half t_1 = t.x - 1.0;\n half tiled_t = (t_1 - 2.0 * "
|
||||
@ -37,12 +37,11 @@ public:
|
||||
" tiled_t = clamp(tiled_t, -1.0, 1.0);\n }\n t.x = "
|
||||
"abs(tiled_t);\n } else {\n t.x = fract(t.x);\n }",
|
||||
_child1.c_str(),
|
||||
(_outer.childProcessor(_outer.gradLayout_index()).preservesOpaqueInput() ? "true"
|
||||
: "false"),
|
||||
(_outer.childProcessor(1).preservesOpaqueInput() ? "true" : "false"),
|
||||
args.fOutputColor, (_outer.mirror() ? "true" : "false"));
|
||||
SkString _input0("t");
|
||||
SkString _child0("_child0");
|
||||
this->emitChild(_outer.colorizer_index(), _input0.c_str(), &_child0, args);
|
||||
this->emitChild(0, _input0.c_str(), &_child0, args);
|
||||
fragBuilder->codeAppendf("\n %s = %s;\n}\n@if (%s) {\n %s.xyz *= %s.w;\n}\n",
|
||||
args.fOutputColor, _child0.c_str(),
|
||||
(_outer.makePremul() ? "true" : "false"), args.fOutputColor,
|
||||
@ -71,13 +70,11 @@ bool GrTiledGradientEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
}
|
||||
GrTiledGradientEffect::GrTiledGradientEffect(const GrTiledGradientEffect& src)
|
||||
: INHERITED(kGrTiledGradientEffect_ClassID, src.optimizationFlags())
|
||||
, fColorizer_index(src.fColorizer_index)
|
||||
, fGradLayout_index(src.fGradLayout_index)
|
||||
, fMirror(src.fMirror)
|
||||
, fMakePremul(src.fMakePremul)
|
||||
, fColorsAreOpaque(src.fColorsAreOpaque) {
|
||||
this->registerChildProcessor(src.childProcessor(fColorizer_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(fGradLayout_index).clone());
|
||||
this->registerChildProcessor(src.childProcessor(0).clone());
|
||||
this->registerChildProcessor(src.childProcessor(1).clone());
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrTiledGradientEffect::clone() const {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrTiledGradientEffect(*this));
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include "GrCoordTransform.h"
|
||||
class GrTiledGradientEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
int colorizer_index() const { return fColorizer_index; }
|
||||
int gradLayout_index() const { return fGradLayout_index; }
|
||||
bool mirror() const { return fMirror; }
|
||||
bool makePremul() const { return fMakePremul; }
|
||||
bool colorsAreOpaque() const { return fColorsAreOpaque; }
|
||||
@ -43,19 +41,13 @@ private:
|
||||
, fMirror(mirror)
|
||||
, fMakePremul(makePremul)
|
||||
, fColorsAreOpaque(colorsAreOpaque) {
|
||||
SkASSERT(colorizer);
|
||||
fColorizer_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(colorizer));
|
||||
SkASSERT(gradLayout);
|
||||
fGradLayout_index = this->numChildProcessors();
|
||||
this->registerChildProcessor(std::move(gradLayout));
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
int fColorizer_index = -1;
|
||||
int fGradLayout_index = -1;
|
||||
bool fMirror;
|
||||
bool fMakePremul;
|
||||
bool fColorsAreOpaque;
|
||||
|
@ -148,10 +148,6 @@ Within an '.fp' fragment processor file:
|
||||
The first variant emits the child with a solid white input color. The second
|
||||
variant emits the child with the result of the 2nd argument's expression,
|
||||
which must evaluate to a half4. The process function returns a half4.
|
||||
* By default, fragment processors must be non-null. The type for a nullable
|
||||
fragment processor is 'fragmentProcessor?', as in
|
||||
'in fragmentProcessor? <name>'. You can check for the presence of such a
|
||||
fragment processor by comparing it to 'null'.
|
||||
|
||||
|
||||
Creating a new .fp file
|
||||
|
@ -391,7 +391,6 @@ void CFGGenerator::addExpression(CFG& cfg, std::unique_ptr<Expression>* e, bool
|
||||
case Expression::kBoolLiteral_Kind: // fall through
|
||||
case Expression::kFloatLiteral_Kind: // fall through
|
||||
case Expression::kIntLiteral_Kind: // fall through
|
||||
case Expression::kNullLiteral_Kind: // fall through
|
||||
case Expression::kSetting_Kind: // fall through
|
||||
case Expression::kVariableReference_Kind:
|
||||
cfg.fBlocks[cfg.fCurrent].fNodes.push_back({ BasicBlock::Node::kExpression_Kind,
|
||||
|
@ -77,32 +77,6 @@ void CPPCodeGenerator::writeBinaryExpression(const BinaryExpression& b,
|
||||
if (precedence >= parentPrecedence) {
|
||||
this->write(")");
|
||||
}
|
||||
} else if (b.fLeft->fKind == Expression::kNullLiteral_Kind ||
|
||||
b.fRight->fKind == Expression::kNullLiteral_Kind) {
|
||||
const Variable* var;
|
||||
if (b.fLeft->fKind != Expression::kNullLiteral_Kind) {
|
||||
SkASSERT(b.fLeft->fKind == Expression::kVariableReference_Kind);
|
||||
var = &((VariableReference&) *b.fLeft).fVariable;
|
||||
} else {
|
||||
SkASSERT(b.fRight->fKind == Expression::kVariableReference_Kind);
|
||||
var = &((VariableReference&) *b.fRight).fVariable;
|
||||
}
|
||||
SkASSERT(var->fType.kind() == Type::kNullable_Kind &&
|
||||
var->fType.componentType() == *fContext.fFragmentProcessor_Type);
|
||||
this->write("%s");
|
||||
const char* op;
|
||||
switch (b.fOperator) {
|
||||
case Token::EQEQ:
|
||||
op = "<";
|
||||
break;
|
||||
case Token::NEQ:
|
||||
op = ">=";
|
||||
break;
|
||||
default:
|
||||
SkASSERT(false);
|
||||
}
|
||||
fFormatArgs.push_back("_outer." + String(var->fName) + "_index() " + op + " 0 ? \"true\" "
|
||||
": \"false\"");
|
||||
} else {
|
||||
INHERITED::writeBinaryExpression(b, parentPrecedence);
|
||||
}
|
||||
@ -359,10 +333,9 @@ void CPPCodeGenerator::writeFieldAccess(const FieldAccess& access) {
|
||||
}
|
||||
|
||||
const Type::Field& field = fContext.fFragmentProcessor_Type->fields()[access.fFieldIndex];
|
||||
const Variable& var = ((const VariableReference&) *access.fBase).fVariable;
|
||||
String cppAccess = String::printf("_outer.childProcessor(_outer.%s_index()).%s()",
|
||||
String(var.fName).c_str(),
|
||||
String(field.fName).c_str());
|
||||
int index = getChildFPIndex((const VariableReference&) *access.fBase);
|
||||
String cppAccess = String::printf("_outer.childProcessor(%s).%s()",
|
||||
to_string(index).c_str(), String(field.fName).c_str());
|
||||
|
||||
if (fCPPMode) {
|
||||
this->write(cppAccess.c_str());
|
||||
@ -374,7 +347,7 @@ void CPPCodeGenerator::writeFieldAccess(const FieldAccess& access) {
|
||||
INHERITED::writeFieldAccess(access);
|
||||
}
|
||||
|
||||
int CPPCodeGenerator::getChildFPIndex(const Variable& var) const {
|
||||
int CPPCodeGenerator::getChildFPIndex(const VariableReference& reference) const {
|
||||
int index = 0;
|
||||
bool found = false;
|
||||
for (const auto& p : fProgram) {
|
||||
@ -382,9 +355,9 @@ int CPPCodeGenerator::getChildFPIndex(const Variable& var) const {
|
||||
const VarDeclarations& decls = (const VarDeclarations&) p;
|
||||
for (const auto& raw : decls.fVars) {
|
||||
const VarDeclaration& decl = (VarDeclaration&) *raw;
|
||||
if (decl.fVar == &var) {
|
||||
if (decl.fVar == &reference.fVariable) {
|
||||
found = true;
|
||||
} else if (decl.fVar->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
} else if (decl.fVar->fType == *fContext.fFragmentProcessor_Type) {
|
||||
++index;
|
||||
}
|
||||
}
|
||||
@ -415,8 +388,7 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
// Second argument must also be a half4 expression
|
||||
SkASSERT("half4" == c.fArguments[1]->fType.name());
|
||||
}
|
||||
const Variable& child = ((const VariableReference&) *c.fArguments[0]).fVariable;
|
||||
int index = getChildFPIndex(child);
|
||||
int index = getChildFPIndex((const VariableReference&) *c.fArguments[0]);
|
||||
|
||||
// Start a new extra emit code section so that the emitted child processor can depend on
|
||||
// sksl variables defined in earlier sksl code.
|
||||
@ -440,14 +412,9 @@ void CPPCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
// Write the output handling after the possible input handling
|
||||
String childName = "_child" + to_string(index);
|
||||
addExtraEmitCodeLine("SkString " + childName + "(\"" + childName + "\");");
|
||||
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
|
||||
addExtraEmitCodeLine("if (_outer." + String(child.fName) + "_index() >= 0) {\n ");
|
||||
}
|
||||
addExtraEmitCodeLine("this->emitChild(_outer." + String(child.fName) + "_index()" +
|
||||
inputArg + ", &" + childName + ", args);");
|
||||
if (c.fArguments[0]->fType.kind() == Type::kNullable_Kind) {
|
||||
addExtraEmitCodeLine("}");
|
||||
}
|
||||
addExtraEmitCodeLine("this->emitChild(" + to_string(index) + inputArg +
|
||||
", &" + childName + ", args);");
|
||||
|
||||
this->write("%s");
|
||||
fFormatArgs.push_back(childName + ".c_str()");
|
||||
return;
|
||||
@ -630,9 +597,8 @@ void CPPCodeGenerator::writePrivateVarValues() {
|
||||
}
|
||||
|
||||
static bool is_accessible(const Variable& var) {
|
||||
const Type& type = var.fType.nonnullable();
|
||||
return Type::kSampler_Kind != type.kind() &&
|
||||
Type::kOther_Kind != type.kind();
|
||||
return Type::kSampler_Kind != var.fType.kind() &&
|
||||
Type::kOther_Kind != var.fType.kind();
|
||||
}
|
||||
|
||||
void CPPCodeGenerator::newExtraEmitCodeBlock() {
|
||||
@ -1025,16 +991,13 @@ void CPPCodeGenerator::writeClone() {
|
||||
": INHERITED(k%s_ClassID, src.optimizationFlags())", fFullName.c_str(),
|
||||
fFullName.c_str(), fFullName.c_str(), fFullName.c_str());
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef("\n, %s_index(src.%s_index)",
|
||||
fieldName.c_str(),
|
||||
fieldName.c_str());
|
||||
} else {
|
||||
this->writef("\n, %s(src.%s)",
|
||||
fieldName.c_str(),
|
||||
fieldName.c_str());
|
||||
if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
continue;
|
||||
}
|
||||
String fieldName = HCodeGenerator::FieldName(String(param->fName).c_str());
|
||||
this->writef("\n, %s(src.%s)",
|
||||
fieldName.c_str(),
|
||||
fieldName.c_str());
|
||||
}
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
@ -1043,20 +1006,14 @@ void CPPCodeGenerator::writeClone() {
|
||||
this->writef("\n, %s(src.%s)", fieldName.c_str(), fieldName.c_str());
|
||||
}
|
||||
this->writef(" {\n");
|
||||
int childCount = 0;
|
||||
int samplerCount = 0;
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind) {
|
||||
++samplerCount;
|
||||
} 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");
|
||||
}
|
||||
} else if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef(" this->registerChildProcessor(src.childProcessor(%d).clone());"
|
||||
"\n", childCount++);
|
||||
}
|
||||
}
|
||||
if (samplerCount) {
|
||||
@ -1225,7 +1182,7 @@ bool CPPCodeGenerator::generateCode() {
|
||||
" (void) that;\n",
|
||||
fullName, fullName, fullName);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
continue;
|
||||
}
|
||||
String nameString(param->fName);
|
||||
|
@ -115,7 +115,7 @@ private:
|
||||
// Append CPP code to the current extra emit code block.
|
||||
void addExtraEmitCodeLine(const String& toAppend);
|
||||
|
||||
int getChildFPIndex(const Variable& var) const;
|
||||
int getChildFPIndex(const VariableReference& reference) const;
|
||||
|
||||
String fName;
|
||||
String fFullName;
|
||||
|
@ -21,7 +21,6 @@ public:
|
||||
Context()
|
||||
: fInvalid_Type(new Type("<INVALID>"))
|
||||
, fVoid_Type(new Type("void"))
|
||||
, fNull_Type(new Type("null"))
|
||||
, fFloatLiteral_Type(new Type("$floatLiteral", Type::kFloat_NumberKind, 3))
|
||||
, fIntLiteral_Type(new Type("$intLiteral", Type::kSigned_NumberKind, 1))
|
||||
, fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6))
|
||||
@ -209,7 +208,6 @@ public:
|
||||
|
||||
const std::unique_ptr<Type> fInvalid_Type;
|
||||
const std::unique_ptr<Type> fVoid_Type;
|
||||
const std::unique_ptr<Type> fNull_Type;
|
||||
const std::unique_ptr<Type> fFloatLiteral_Type;
|
||||
const std::unique_ptr<Type> fIntLiteral_Type;
|
||||
|
||||
|
@ -41,9 +41,7 @@ Layout::CType HCodeGenerator::ParameterCType(const Context& context, const Type&
|
||||
if (layout.fCType != Layout::CType::kDefault) {
|
||||
return layout.fCType;
|
||||
}
|
||||
if (type.kind() == Type::kNullable_Kind) {
|
||||
return ParameterCType(context, type.componentType(), layout);
|
||||
} else if (type == *context.fFloat_Type || type == *context.fHalf_Type) {
|
||||
if (type == *context.fFloat_Type || type == *context.fHalf_Type) {
|
||||
return Layout::CType::kFloat;
|
||||
} else if (type == *context.fInt_Type ||
|
||||
type == *context.fShort_Type ||
|
||||
@ -191,7 +189,7 @@ void HCodeGenerator::writeMake() {
|
||||
fFullName.c_str());
|
||||
separator = "";
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef("%sstd::move(%s)", separator, String(param->fName).c_str());
|
||||
} else {
|
||||
this->writef("%s%s", separator, String(param->fName).c_str());
|
||||
@ -239,8 +237,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
const Type& type = param->fType.nonnullable();
|
||||
if (type.kind() == Type::kSampler_Kind) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind) {
|
||||
this->writef("\n , %s(std::move(%s)", FieldName(name).c_str(), name);
|
||||
for (const Section* s : fSectionAndParameterHelper.getSections(
|
||||
SAMPLER_PARAMS_SECTION)) {
|
||||
@ -249,7 +246,7 @@ void HCodeGenerator::writeConstructor() {
|
||||
}
|
||||
}
|
||||
this->writef(")");
|
||||
} else if (type == *fContext.fFragmentProcessor_Type) {
|
||||
} else if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
// do nothing
|
||||
} else {
|
||||
this->writef("\n , %s(%s)", FieldName(name).c_str(), name);
|
||||
@ -273,19 +270,9 @@ void HCodeGenerator::writeConstructor() {
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind) {
|
||||
++samplerCount;
|
||||
} else if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
if (param->fType.kind() == Type::kNullable_Kind) {
|
||||
this->writef(" if (%s) {\n", String(param->fName).c_str());
|
||||
} else {
|
||||
this->writef(" SkASSERT(%s);", String(param->fName).c_str());
|
||||
}
|
||||
this->writef(" %s_index = this->numChildProcessors();",
|
||||
FieldName(String(param->fName).c_str()).c_str());
|
||||
this->writef(" this->registerChildProcessor(std::move(%s));",
|
||||
} else if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef(" this->registerChildProcessor(std::move(%s));",
|
||||
String(param->fName).c_str());
|
||||
if (param->fType.kind() == Type::kNullable_Kind) {
|
||||
this->writef(" }");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (samplerCount) {
|
||||
@ -302,14 +289,12 @@ void HCodeGenerator::writeConstructor() {
|
||||
void HCodeGenerator::writeFields() {
|
||||
this->writeSection(FIELDS_SECTION);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
String name = FieldName(String(param->fName).c_str());
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef(" int %s_index = -1;\n", name.c_str());
|
||||
} else {
|
||||
this->writef(" %s %s;\n", FieldType(fContext, param->fType,
|
||||
param->fModifiers.fLayout).c_str(),
|
||||
name.c_str());
|
||||
if (param->fType == *fContext.fFragmentProcessor_Type) {
|
||||
continue;
|
||||
}
|
||||
this->writef(" %s %s;\n", FieldType(fContext, param->fType,
|
||||
param->fModifiers.fLayout).c_str(),
|
||||
FieldName(String(param->fName).c_str()).c_str());
|
||||
}
|
||||
const auto transforms = fSectionAndParameterHelper.getSections(COORD_TRANSFORM_SECTION);
|
||||
for (size_t i = 0; i < transforms.size(); ++i) {
|
||||
@ -356,19 +341,15 @@ bool HCodeGenerator::generateCode() {
|
||||
}
|
||||
this->writeSection(CLASS_SECTION);
|
||||
for (const auto& param : fSectionAndParameterHelper.getParameters()) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind) {
|
||||
if (param->fType.kind() == Type::kSampler_Kind ||
|
||||
param->fType.kind() == Type::kOther_Kind) {
|
||||
continue;
|
||||
}
|
||||
String nameString(param->fName);
|
||||
const char* name = nameString.c_str();
|
||||
if (param->fType.nonnullable() == *fContext.fFragmentProcessor_Type) {
|
||||
this->writef(" int %s_index() const { return %s_index; }\n", name,
|
||||
FieldName(name).c_str());
|
||||
} else {
|
||||
this->writef(" %s %s() const { return %s; }\n",
|
||||
AccessType(fContext, param->fType, param->fModifiers.fLayout).c_str(),
|
||||
name, FieldName(name).c_str());
|
||||
}
|
||||
this->writef(" %s %s() const { return %s; }\n",
|
||||
AccessType(fContext, param->fType, param->fModifiers.fLayout).c_str(), name,
|
||||
FieldName(name).c_str());
|
||||
}
|
||||
this->writeMake();
|
||||
this->writef(" %s(const %s& src);\n"
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "ast/SkSLASTFloatLiteral.h"
|
||||
#include "ast/SkSLASTIndexSuffix.h"
|
||||
#include "ast/SkSLASTIntLiteral.h"
|
||||
#include "ast/SkSLASTNullLiteral.h"
|
||||
#include "ir/SkSLAppendStage.h"
|
||||
#include "ir/SkSLBinaryExpression.h"
|
||||
#include "ir/SkSLBoolLiteral.h"
|
||||
@ -41,7 +40,6 @@
|
||||
#include "ir/SkSLInterfaceBlock.h"
|
||||
#include "ir/SkSLIntLiteral.h"
|
||||
#include "ir/SkSLLayout.h"
|
||||
#include "ir/SkSLNullLiteral.h"
|
||||
#include "ir/SkSLPostfixExpression.h"
|
||||
#include "ir/SkSLPrefixExpression.h"
|
||||
#include "ir/SkSLReturnStatement.h"
|
||||
@ -940,7 +938,7 @@ void IRGenerator::convertEnum(const ASTEnum& e) {
|
||||
std::vector<Variable*> variables;
|
||||
int64_t currentValue = 0;
|
||||
Layout layout;
|
||||
ASTType enumType(e.fOffset, e.fTypeName, ASTType::kIdentifier_Kind, {}, false);
|
||||
ASTType enumType(e.fOffset, e.fTypeName, ASTType::kIdentifier_Kind, {});
|
||||
const Type* type = this->convertType(enumType);
|
||||
Modifiers modifiers(layout, Modifiers::kConst_Flag);
|
||||
std::shared_ptr<SymbolTable> symbols(new SymbolTable(fSymbolTable, &fErrors));
|
||||
@ -972,18 +970,6 @@ void IRGenerator::convertEnum(const ASTEnum& e) {
|
||||
const Type* IRGenerator::convertType(const ASTType& type) {
|
||||
const Symbol* result = (*fSymbolTable)[type.fName];
|
||||
if (result && result->fKind == Symbol::kType_Kind) {
|
||||
if (type.fNullable) {
|
||||
if (((Type&) *result) == *fContext.fFragmentProcessor_Type) {
|
||||
if (type.fSizes.size()) {
|
||||
fErrors.error(type.fOffset, "type '" + type.fName + "' may not be used in "
|
||||
"an array");
|
||||
}
|
||||
result = new Type(String(result->fName) + "?", Type::kNullable_Kind,
|
||||
(const Type&) *result);
|
||||
} else {
|
||||
fErrors.error(type.fOffset, "type '" + type.fName + "' may not be nullable");
|
||||
}
|
||||
}
|
||||
for (int size : type.fSizes) {
|
||||
String name(result->fName);
|
||||
name += "[";
|
||||
@ -1015,8 +1001,6 @@ std::unique_ptr<Expression> IRGenerator::convertExpression(const ASTExpression&
|
||||
((ASTFloatLiteral&) expr).fValue));
|
||||
case ASTExpression::kBinary_Kind:
|
||||
return this->convertBinaryExpression((ASTBinaryExpression&) expr);
|
||||
case ASTExpression::kNull_Kind:
|
||||
return std::unique_ptr<Expression>(new NullLiteral(fContext, expr.fOffset));
|
||||
case ASTExpression::kPrefix_Kind:
|
||||
return this->convertPrefixExpression((ASTPrefixExpression&) expr);
|
||||
case ASTExpression::kSuffix_Kind:
|
||||
@ -1134,10 +1118,6 @@ std::unique_ptr<Expression> IRGenerator::coerce(std::unique_ptr<Expression> expr
|
||||
SkASSERT(ctor);
|
||||
return this->call(-1, std::move(ctor), std::move(args));
|
||||
}
|
||||
if (expr->fKind == Expression::kNullLiteral_Kind) {
|
||||
SkASSERT(type.kind() == Type::kNullable_Kind);
|
||||
return std::unique_ptr<Expression>(new NullLiteral(expr->fOffset, type));
|
||||
}
|
||||
std::vector<std::unique_ptr<Expression>> args;
|
||||
args.push_back(std::move(expr));
|
||||
return std::unique_ptr<Expression>(new Constructor(-1, type, std::move(args)));
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
/*****************************************************************************************
|
||||
******************** This file was generated by sksllex. Do not edit. *******************
|
||||
*****************************************************************************************/
|
||||
#include "SkSLLayoutLexer.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
static int8_t mappings[127] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
||||
static int16_t transitions[2][1] = {
|
||||
{
|
||||
0,
|
||||
},
|
||||
{
|
||||
0,
|
||||
},
|
||||
};
|
||||
|
||||
static int8_t accepts[1] = {
|
||||
-1,
|
||||
};
|
||||
|
||||
LayoutToken LayoutLexer::next() {
|
||||
// note that we cheat here: normally a lexer needs to worry about the case
|
||||
// where a token has a prefix which is not itself a valid token - for instance,
|
||||
// maybe we have a valid token 'while', but 'w', 'wh', etc. are not valid
|
||||
// tokens. Our grammar doesn't have this property, so we can simplify the logic
|
||||
// a bit.
|
||||
int32_t startOffset = fOffset;
|
||||
if (startOffset == fLength) {
|
||||
return LayoutToken(LayoutToken::END_OF_FILE, startOffset, 0);
|
||||
}
|
||||
int16_t state = 1;
|
||||
while (fOffset < fLength) {
|
||||
if ((uint8_t)fText[fOffset] >= 127) {
|
||||
++fOffset;
|
||||
break;
|
||||
}
|
||||
int16_t newState = transitions[mappings[(int)fText[fOffset]]][state];
|
||||
if (!newState) {
|
||||
break;
|
||||
}
|
||||
state = newState;
|
||||
++fOffset;
|
||||
}
|
||||
Token::Kind kind = (LayoutToken::Kind)accepts[state];
|
||||
return LayoutToken(kind, startOffset, fOffset - startOffset);
|
||||
}
|
||||
|
||||
} // namespace SkSL
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
/*****************************************************************************************
|
||||
******************** This file was generated by sksllex. Do not edit. *******************
|
||||
*****************************************************************************************/
|
||||
#ifndef SKSL_LayoutLexer
|
||||
#define SKSL_LayoutLexer
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
namespace SkSL {
|
||||
|
||||
struct LayoutToken {
|
||||
enum Kind {
|
||||
#undef END_OF_FILE
|
||||
END_OF_FILE,
|
||||
};
|
||||
|
||||
LayoutToken() : fKind(Kind::INVALID), fOffset(-1), fLength(-1) {}
|
||||
|
||||
LayoutToken(Kind kind, int32_t offset, int32_t length)
|
||||
: fKind(kind), fOffset(offset), fLength(length) {}
|
||||
|
||||
Kind fKind;
|
||||
int fOffset;
|
||||
int fLength;
|
||||
};
|
||||
|
||||
class LayoutLexer {
|
||||
public:
|
||||
void start(const char* text, int32_t length) {
|
||||
fText = text;
|
||||
fLength = length;
|
||||
fOffset = 0;
|
||||
}
|
||||
|
||||
LayoutToken next();
|
||||
|
||||
private:
|
||||
const char* fText;
|
||||
int32_t fLength;
|
||||
int32_t fOffset;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -53,8 +53,6 @@ struct Token {
|
||||
DISCARD,
|
||||
#undef RETURN
|
||||
RETURN,
|
||||
#undef NULL_LITERAL
|
||||
NULL_LITERAL,
|
||||
#undef IN
|
||||
IN,
|
||||
#undef OUT
|
||||
@ -247,5 +245,5 @@ private:
|
||||
int32_t fOffset;
|
||||
};
|
||||
|
||||
} // namespace SkSL
|
||||
} // namespace
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "ast/SkSLASTInterfaceBlock.h"
|
||||
#include "ast/SkSLASTIntLiteral.h"
|
||||
#include "ast/SkSLASTModifiersDeclaration.h"
|
||||
#include "ast/SkSLASTNullLiteral.h"
|
||||
#include "ast/SkSLASTParameter.h"
|
||||
#include "ast/SkSLASTPrefixExpression.h"
|
||||
#include "ast/SkSLASTReturnStatement.h"
|
||||
@ -518,7 +517,7 @@ std::unique_ptr<ASTType> Parser::structDeclaration() {
|
||||
fTypes.add(this->text(name), std::unique_ptr<Type>(new Type(name.fOffset, this->text(name),
|
||||
fields)));
|
||||
return std::unique_ptr<ASTType>(new ASTType(name.fOffset, this->text(name),
|
||||
ASTType::kStruct_Kind, std::vector<int>(), false));
|
||||
ASTType::kStruct_Kind, std::vector<int>()));
|
||||
}
|
||||
|
||||
/* structDeclaration ((IDENTIFIER varDeclarationEnd) | SEMICOLON) */
|
||||
@ -1072,7 +1071,7 @@ std::unique_ptr<ASTStatement> Parser::statement() {
|
||||
}
|
||||
}
|
||||
|
||||
/* IDENTIFIER(type) (LBRACKET intLiteral? RBRACKET)* QUESTION? */
|
||||
/* IDENTIFIER(type) (LBRACKET intLiteral? RBRACKET)* */
|
||||
std::unique_ptr<ASTType> Parser::type() {
|
||||
Token type;
|
||||
if (!this->expect(Token::IDENTIFIER, "a type", &type)) {
|
||||
@ -1096,9 +1095,8 @@ std::unique_ptr<ASTType> Parser::type() {
|
||||
}
|
||||
this->expect(Token::RBRACKET, "']'");
|
||||
}
|
||||
bool nullable = this->checkNext(Token::QUESTION);
|
||||
return std::unique_ptr<ASTType>(new ASTType(type.fOffset, this->text(type),
|
||||
ASTType::kIdentifier_Kind, sizes, nullable));
|
||||
ASTType::kIdentifier_Kind, sizes));
|
||||
}
|
||||
|
||||
/* IDENTIFIER LBRACE varDeclaration* RBRACE (IDENTIFIER (LBRACKET expression? RBRACKET)*)? */
|
||||
@ -1919,7 +1917,7 @@ std::unique_ptr<ASTSuffix> Parser::suffix() {
|
||||
}
|
||||
}
|
||||
|
||||
/* IDENTIFIER | intLiteral | floatLiteral | boolLiteral | NULL_LITERAL | '(' expression ')' */
|
||||
/* IDENTIFIER | intLiteral | floatLiteral | boolLiteral | '(' expression ')' */
|
||||
std::unique_ptr<ASTExpression> Parser::term() {
|
||||
std::unique_ptr<ASTExpression> result;
|
||||
Token t = this->peek();
|
||||
@ -1953,10 +1951,6 @@ std::unique_ptr<ASTExpression> Parser::term() {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Token::NULL_LITERAL:
|
||||
this->nextToken();
|
||||
result.reset(new ASTNullLiteral(t.fOffset));
|
||||
break;
|
||||
case Token::LPAREN: {
|
||||
this->nextToken();
|
||||
result = this->expression();
|
||||
|
@ -17,14 +17,13 @@ namespace SkSL {
|
||||
*/
|
||||
struct ASTExpression : public ASTPositionNode {
|
||||
enum Kind {
|
||||
kBinary_Kind,
|
||||
kBool_Kind,
|
||||
kFloat_Kind,
|
||||
kIdentifier_Kind,
|
||||
kInt_Kind,
|
||||
kNull_Kind,
|
||||
kBool_Kind,
|
||||
kPrefix_Kind,
|
||||
kSuffix_Kind,
|
||||
kBinary_Kind,
|
||||
kTernary_Kind
|
||||
};
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_ASTNULLLITERAL
|
||||
#define SKSL_ASTNULLLITERAL
|
||||
|
||||
#include "SkSLASTExpression.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
/**
|
||||
* Represents "null".
|
||||
*/
|
||||
struct ASTNullLiteral : public ASTExpression {
|
||||
ASTNullLiteral(int offset)
|
||||
: INHERITED(offset, kNull_Kind) {}
|
||||
|
||||
String description() const override {
|
||||
return "null";
|
||||
}
|
||||
|
||||
typedef ASTExpression INHERITED;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@ -21,12 +21,11 @@ struct ASTType : public ASTPositionNode {
|
||||
kStruct_Kind
|
||||
};
|
||||
|
||||
ASTType(int offset, StringFragment name, Kind kind, std::vector<int> sizes, bool nullable)
|
||||
ASTType(int offset, StringFragment name, Kind kind, std::vector<int> sizes)
|
||||
: INHERITED(offset)
|
||||
, fName(name)
|
||||
, fKind(kind)
|
||||
, fSizes(std::move(sizes))
|
||||
, fNullable(nullable) {}
|
||||
, fSizes(std::move(sizes)) {}
|
||||
|
||||
String description() const override {
|
||||
return fName;
|
||||
@ -39,8 +38,6 @@ struct ASTType : public ASTPositionNode {
|
||||
// array sizes, -1 meaning unspecified
|
||||
const std::vector<int> fSizes;
|
||||
|
||||
bool fNullable;
|
||||
|
||||
typedef ASTPositionNode INHERITED;
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,6 @@ struct Expression : public IRNode {
|
||||
kFunctionReference_Kind,
|
||||
kFunctionCall_Kind,
|
||||
kIndex_Kind,
|
||||
kNullLiteral_Kind,
|
||||
kPrefix_Kind,
|
||||
kPostfix_Kind,
|
||||
kSetting_Kind,
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef SKSL_NULLLITERAL
|
||||
#define SKSL_NULLLITERAL
|
||||
|
||||
#include "SkSLContext.h"
|
||||
#include "SkSLExpression.h"
|
||||
|
||||
namespace SkSL {
|
||||
|
||||
/**
|
||||
* Represents 'null'.
|
||||
*/
|
||||
struct NullLiteral : public Expression {
|
||||
NullLiteral(const Context& context, int offset)
|
||||
: INHERITED(offset, kNullLiteral_Kind, *context.fNull_Type) {}
|
||||
|
||||
NullLiteral(int offset, const Type& type)
|
||||
: INHERITED(offset, kNullLiteral_Kind, type) {}
|
||||
|
||||
String description() const override {
|
||||
return "null";
|
||||
}
|
||||
|
||||
bool hasSideEffects() const override {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isConstant() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool compareConstant(const Context& context, const Expression& other) const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<Expression> clone() const override {
|
||||
return std::unique_ptr<Expression>(new NullLiteral(fOffset, fType));
|
||||
}
|
||||
|
||||
typedef Expression INHERITED;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
@ -14,16 +14,6 @@ int Type::coercionCost(const Type& other) const {
|
||||
if (*this == other) {
|
||||
return 0;
|
||||
}
|
||||
if (this->kind() == kNullable_Kind && other.kind() != kNullable_Kind) {
|
||||
int result = this->componentType().coercionCost(other);
|
||||
if (result != INT_MAX) {
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if (this->fName == "null" && other.kind() == kNullable_Kind) {
|
||||
return 0;
|
||||
}
|
||||
if (this->kind() == kVector_Kind && other.kind() == kVector_Kind) {
|
||||
if (this->columns() == other.columns()) {
|
||||
return this->componentType().coercionCost(other.componentType());
|
||||
|
@ -45,7 +45,6 @@ public:
|
||||
kArray_Kind,
|
||||
kEnum_Kind,
|
||||
kGeneric_Kind,
|
||||
kNullable_Kind,
|
||||
kMatrix_Kind,
|
||||
kOther_Kind,
|
||||
kSampler_Kind,
|
||||
@ -145,20 +144,6 @@ public:
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a nullable type.
|
||||
Type(String name, Kind kind, const Type& componentType)
|
||||
: INHERITED(-1, kType_Kind, StringFragment())
|
||||
, fNameString(std::move(name))
|
||||
, fTypeKind(kind)
|
||||
, fNumberKind(kNonnumeric_NumberKind)
|
||||
, fComponentType(&componentType)
|
||||
, fColumns(1)
|
||||
, fRows(1)
|
||||
, fDimensions(SpvDim1D) {
|
||||
fName.fChars = fNameString.c_str();
|
||||
fName.fLength = fNameString.size();
|
||||
}
|
||||
|
||||
// Create a vector type.
|
||||
Type(const char* name, const Type& componentType, int columns)
|
||||
: Type(name, kVector_Kind, componentType, columns) {}
|
||||
@ -303,16 +288,6 @@ public:
|
||||
return *fComponentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* For nullable types, returns the base type, otherwise returns the type itself.
|
||||
*/
|
||||
const Type& nonnullable() const {
|
||||
if (fTypeKind == kNullable_Kind) {
|
||||
return this->componentType();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* For matrices and vectors, returns the number of columns (e.g. both mat3 and float3return 3).
|
||||
* For scalars, returns 1. For arrays, returns either the size of the array (if known) or -1.
|
||||
|
@ -16,7 +16,6 @@ BREAK = "break"
|
||||
CONTINUE = "continue"
|
||||
DISCARD = "discard"
|
||||
RETURN = "return"
|
||||
NULL_LITERAL = "null"
|
||||
IN = "in"
|
||||
OUT = "out"
|
||||
INOUT = "inout"
|
||||
|
@ -25,6 +25,4 @@ layout(builtin=10012) half sk_Height;
|
||||
|
||||
half4 process(fragmentProcessor fp);
|
||||
half4 process(fragmentProcessor fp, half4 input);
|
||||
half4 process(fragmentProcessor? fp);
|
||||
half4 process(fragmentProcessor? fp, half4 input);
|
||||
)
|
||||
|
@ -469,11 +469,11 @@ DEF_TEST(SkSLFPChildProcessors, r) {
|
||||
},
|
||||
{
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), &_child0, args);",
|
||||
"this->emitChild(0, &_child0, args);",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(1, &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(1).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -495,12 +495,12 @@ DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
|
||||
{
|
||||
"SkString _input0(\"childIn\");",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(0, _input0.c_str(), &_child0, args);",
|
||||
"SkString _input1(\"childOut1\");",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(1, _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(1).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -517,8 +517,8 @@ DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
|
||||
{
|
||||
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());",
|
||||
"this->emitChild(0, _input0.c_str(), &_child0, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());",
|
||||
});
|
||||
}
|
||||
|
||||
@ -537,12 +537,12 @@ DEF_TEST(SkSLFPNestedChildProcessors, r) {
|
||||
{
|
||||
"SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child1_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(0, _input0.c_str(), &_child0, args);",
|
||||
"SkString _input1 = SkStringPrintf(\"%s * %s\", args.fInputColor, _child0.c_str());",
|
||||
"SkString _child1(\"_child1\");",
|
||||
"this->emitChild(_outer.child2_index(), _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild1_index).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild2_index).clone());"
|
||||
"this->emitChild(1, _input1.c_str(), &_child1, args);",
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());",
|
||||
"this->registerChildProcessor(src.childProcessor(1).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -567,10 +567,10 @@ DEF_TEST(SkSLFPChildFPAndGlobal, r) {
|
||||
"(hasCap ? \"true\" : \"false\"));",
|
||||
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(0, _input0.c_str(), &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}"
|
||||
"\\n\", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -590,14 +590,13 @@ DEF_TEST(SkSLFPChildProcessorInlineFieldAccess, r) {
|
||||
},
|
||||
{
|
||||
"fragBuilder->codeAppendf(\"if (%s) {\", "
|
||||
"(_outer.childProcessor(_outer.child_index()).preservesOpaqueInput() ? "
|
||||
"\"true\" : \"false\"));",
|
||||
"(_outer.childProcessor(0).preservesOpaqueInput() ? \"true\" : \"false\"));",
|
||||
"SkString _input0 = SkStringPrintf(\"%s\", args.fInputColor);",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), _input0.c_str(), &_child0, args);",
|
||||
"this->emitChild(0, _input0.c_str(), &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(1.0);\\n}\\n\""
|
||||
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());"
|
||||
});
|
||||
}
|
||||
|
||||
@ -617,13 +616,13 @@ DEF_TEST(SkSLFPChildProcessorFieldAccess, r) {
|
||||
"this->registerChildProcessor(std::move(child));"
|
||||
},
|
||||
{
|
||||
"opaque = _outer.childProcessor(_outer.child_index()).preservesOpaqueInput();",
|
||||
"opaque = _outer.childProcessor(0).preservesOpaqueInput();",
|
||||
"fragBuilder->codeAppendf(\"bool opaque = %s;\\nif (opaque) {\", "
|
||||
"(opaque ? \"true\" : \"false\"));",
|
||||
"SkString _child0(\"_child0\");",
|
||||
"this->emitChild(_outer.child_index(), &_child0, args);",
|
||||
"this->emitChild(0, &_child0, args);",
|
||||
"fragBuilder->codeAppendf(\"\\n %s = %s;\\n} else {\\n %s = half4(0.5);\\n}\\n\""
|
||||
", args.fOutputColor, _child0.c_str(), args.fOutputColor);",
|
||||
"this->registerChildProcessor(src.childProcessor(fChild_index).clone());"
|
||||
"this->registerChildProcessor(src.childProcessor(0).clone());"
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user