aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLCPPCodeGenerator.cpp
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-07-05 16:19:09 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-05 21:02:39 +0000
commit9fb036fb133d0b2eafb95a86a06b7910c0b0039c (patch)
tree29304b0dd265f2457e44d4a9a8b26d7685de86ec /src/sksl/SkSLCPPCodeGenerator.cpp
parent412cda7379626ee3acfd1dbb1441adde81efddc3 (diff)
rewrote GrAlphaThresholdFragmentProcessor in sksl
Bug: skia: Change-Id: I641b206fc3bc19ac190ad94ee755ab9e1caab9b3 Reviewed-on: https://skia-review.googlesource.com/21341 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLCPPCodeGenerator.cpp')
-rw-r--r--src/sksl/SkSLCPPCodeGenerator.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp
index 04bcf581c6..09622f3e4c 100644
--- a/src/sksl/SkSLCPPCodeGenerator.cpp
+++ b/src/sksl/SkSLCPPCodeGenerator.cpp
@@ -28,13 +28,15 @@ CPPCodeGenerator::CPPCodeGenerator(const Context* context, const Program* progra
void CPPCodeGenerator::writef(const char* s, va_list va) {
static constexpr int BUFFER_SIZE = 1024;
+ va_list copy;
+ va_copy(copy, va);
char buffer[BUFFER_SIZE];
int length = vsnprintf(buffer, BUFFER_SIZE, s, va);
if (length < BUFFER_SIZE) {
fOut->write(buffer, length);
} else {
std::unique_ptr<char[]> heap(new char[length + 1]);
- vsprintf(heap.get(), s, va);
+ vsprintf(heap.get(), s, copy);
fOut->write(heap.get(), length);
}
}
@@ -540,18 +542,18 @@ bool CPPCodeGenerator::generateCode() {
const char* baseName = fName.c_str();
const char* fullName = fFullName.c_str();
this->writef(kFragmentProcessorHeader, fullName);
- this->writef("#include \"%s.h\"\n"
- "#include \"glsl/GrGLSLColorSpaceXformHelper.h\"\n"
+ this->writef("#include \"%s.h\"\n", fullName);
+ this->writeSection(CPP_SECTION);
+ this->writef("#include \"glsl/GrGLSLColorSpaceXformHelper.h\"\n"
"#include \"glsl/GrGLSLFragmentProcessor.h\"\n"
"#include \"glsl/GrGLSLFragmentShaderBuilder.h\"\n"
"#include \"glsl/GrGLSLProgramBuilder.h\"\n"
- "#include \"GrResourceProvider.h\"\n"
"#include \"SkSLCPP.h\"\n"
"#include \"SkSLUtil.h\"\n"
"class GrGLSL%s : public GrGLSLFragmentProcessor {\n"
"public:\n"
" GrGLSL%s() {}\n",
- fullName, baseName, baseName);
+ baseName, baseName);
bool result = this->writeEmitCode(uniforms);
this->write("private:\n");
this->writeSetData(uniforms);
@@ -589,8 +591,8 @@ bool CPPCodeGenerator::generateCode() {
}
this->write(" return true;\n"
"}\n");
- this->writeSection(CPP_SECTION);
this->writeTest();
+ this->writeSection(CPP_END_SECTION);
result &= 0 == fErrors.errorCount();
return result;
}