aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLCPPCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-07-12 13:51:34 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-12 13:51:46 +0000
commitbaf981f71614e7a2fbe6af2726e65126d431ed8e (patch)
tree1efed95d65f841bbbe8006165f37d9f03a0c0972 /src/sksl/SkSLCPPCodeGenerator.cpp
parent46b654df9e70bbfacf6dc45d3a2a7ceb13a61edb (diff)
Revert "converted GrSimpleTextureEffect to sksl"
This reverts commit 46b654df9e70bbfacf6dc45d3a2a7ceb13a61edb. Reason for revert: making Vulkan mad Original change's description: > converted GrSimpleTextureEffect to sksl > > Bug: skia: > Change-Id: If556c6baad75f22135f429759feabaaec095b900 > Reviewed-on: https://skia-review.googlesource.com/21720 > Commit-Queue: Ethan Nicholas <ethannicholas@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,ethannicholas@google.com Change-Id: I06fac3d106435e1d58e19cc54a919c5d84784d92 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/22266 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLCPPCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index d636d5a63c..72dcd013a3 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -163,7 +163,7 @@ void CPPCodeGenerator::writeVarInitializer(const Variable& var, const Expression
String CPPCodeGenerator::getSamplerHandle(const Variable& var) {
int samplerCount = 0;
- for (const auto param : fSectionAndParameterHelper.getParameters()) {
+ for (const auto param : fSectionAndParameterHelper.fParameters) {
if (&var == param) {
return "args.fTexSamplers[" + to_string(samplerCount) + "]";
}
@@ -267,9 +267,9 @@ void CPPCodeGenerator::writeSetting(const Setting& s) {
}
void CPPCodeGenerator::writeSection(const char* name, const char* prefix) {
- const Section* s = fSectionAndParameterHelper.getSection(name);
- if (s) {
- this->writef("%s%s", prefix, s->fText.c_str());
+ const auto found = fSectionAndParameterHelper.fSections.find(String(name));
+ if (found != fSectionAndParameterHelper.fSections.end()) {
+ this->writef("%s%s", prefix, found->second->fText.c_str());
}
}
@@ -398,8 +398,10 @@ bool CPPCodeGenerator::writeEmitCode(std::vector<const Variable*>& uniforms) {
void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
const char* fullName = fFullName.c_str();
- const Section* section = fSectionAndParameterHelper.getSection(SET_DATA_SECTION);
- const char* pdman = section ? section->fArgument.c_str() : "pdman";
+ auto section = fSectionAndParameterHelper.fSections.find(String(SET_DATA_SECTION));
+ const char* pdman = section != fSectionAndParameterHelper.fSections.end() ?
+ section->second->fArgument.c_str() :
+ "pdman";
this->writef(" void onSetData(const GrGLSLProgramDataManager& %s, "
"const GrFragmentProcessor& _proc) override {\n",
pdman);
@@ -437,7 +439,7 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
if (wroteProcessor) {
this->writef(" }\n");
}
- if (section) {
+ if (section != fSectionAndParameterHelper.fSections.end()) {
for (const auto& p : fProgram.fElements) {
if (ProgramElement::kVar_Kind == p->fKind) {
const VarDeclarations* decls = (const VarDeclarations*) p.get();
@@ -468,25 +470,27 @@ void CPPCodeGenerator::writeSetData(std::vector<const Variable*>& uniforms) {
}
void CPPCodeGenerator::writeTest() {
- const Section* test = fSectionAndParameterHelper.getSection(TEST_CODE_SECTION);
- if (test) {
- this->writef("GR_DEFINE_FRAGMENT_PROCESSOR_TEST(%s);\n"
- "#if GR_TEST_UTILS\n"
- "sk_sp<GrFragmentProcessor> %s::TestCreate(GrProcessorTestData* %s) {\n",
- fFullName.c_str(),
- fFullName.c_str(),
- test->fArgument.c_str());
- this->writeSection(TEST_CODE_SECTION);
- this->write("}\n"
- "#endif\n");
+ const auto found = fSectionAndParameterHelper.fSections.find(TEST_CODE_SECTION);
+ if (found == fSectionAndParameterHelper.fSections.end()) {
+ return;
}
+ const Section* test = found->second;
+ this->writef("GR_DEFINE_FRAGMENT_PROCESSOR_TEST(%s);\n"
+ "#if GR_TEST_UTILS\n"
+ "sk_sp<GrFragmentProcessor> %s::TestCreate(GrProcessorTestData* %s) {\n",
+ fFullName.c_str(),
+ fFullName.c_str(),
+ test->fArgument.c_str());
+ this->writeSection(TEST_CODE_SECTION);
+ this->write("}\n"
+ "#endif\n");
}
void CPPCodeGenerator::writeGetKey() {
this->writef("void %s::onGetGLSLProcessorKey(const GrShaderCaps& caps, "
"GrProcessorKeyBuilder* b) const {\n",
fFullName.c_str());
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
+ for (const auto& param : fSectionAndParameterHelper.fParameters) {
const char* name = param->fName.c_str();
if (param->fType == *fContext.fColorSpaceXform_Type) {
this->writef(" b->add32(GrColorSpaceXform::XformKey(%s.get()));\n",
@@ -576,7 +580,7 @@ bool CPPCodeGenerator::generateCode() {
this->writef(" UniformHandle %sVar;\n", HCodeGenerator::FieldName(name).c_str());
}
}
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
+ for (const auto& param : fSectionAndParameterHelper.fParameters) {
const char* name = param->fName.c_str();
if (needs_uniform_var(*param)) {
this->writef(" UniformHandle %sVar;\n", HCodeGenerator::FieldName(name).c_str());
@@ -595,7 +599,7 @@ bool CPPCodeGenerator::generateCode() {
" const %s& that = other.cast<%s>();\n"
" (void) that;\n",
fullName, fullName, fullName);
- for (const auto& param : fSectionAndParameterHelper.getParameters()) {
+ for (const auto& param : fSectionAndParameterHelper.fParameters) {
const char* name = param->fName.c_str();
this->writef(" if (%s != that.%s) return false;\n",
HCodeGenerator::FieldName(name).c_str(),