blob: 20a17bbd4f13b474b78a9586cc94426e8d5ff310 [file] [log] [blame]
Ethan Nicholas762466e2017-06-29 10:03:38 -04001/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "SkSLCompiler.h"
9
10#include "Test.h"
11
Ethan Nicholas762466e2017-06-29 10:03:38 -040012static void test(skiatest::Reporter* r, const char* src, const GrShaderCaps& caps,
13 std::vector<const char*> expectedH, std::vector<const char*> expectedCPP) {
14 SkSL::Program::Settings settings;
15 settings.fCaps = &caps;
16 SkSL::Compiler compiler;
17 SkSL::StringStream output;
18 std::unique_ptr<SkSL::Program> program = compiler.convertProgram(
19 SkSL::Program::kFragmentProcessor_Kind,
Brian Osman93ba0a42017-08-14 14:48:10 -040020 SkSL::String(src),
Ethan Nicholas762466e2017-06-29 10:03:38 -040021 settings);
22 if (!program) {
23 SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
24 return;
25 }
26 REPORTER_ASSERT(r, program);
27 bool success = compiler.toH(*program, "Test", output);
28 if (!success) {
29 SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
30 }
31 REPORTER_ASSERT(r, success);
32 if (success) {
33 for (const char* expected : expectedH) {
34 bool found = strstr(output.str().c_str(), expected);
35 if (!found) {
36 SkDebugf("HEADER MISMATCH:\nsource:\n%s\n\nexpected:\n'%s'\n\nreceived:\n'%s'", src,
37 expected, output.str().c_str());
38 }
39 REPORTER_ASSERT(r, found);
40 }
41 }
42 output.reset();
43 success = compiler.toCPP(*program, "Test", output);
44 if (!success) {
45 SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
46 }
47 REPORTER_ASSERT(r, success);
48 if (success) {
49 for (const char* expected : expectedCPP) {
50 bool found = strstr(output.str().c_str(), expected);
51 if (!found) {
52 SkDebugf("CPP MISMATCH:\nsource:\n%s\n\nexpected:\n'%s'\n\nreceived:\n'%s'", src,
53 expected, output.str().c_str());
54 }
55 REPORTER_ASSERT(r, found);
56 }
57 }
58}
59
60DEF_TEST(SkSLFPHelloWorld, r) {
61 test(r,
Ethan Nicholas130fb3f2018-02-01 12:14:34 -050062 "/* HEADER */"
Ethan Nicholas762466e2017-06-29 10:03:38 -040063 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -040064 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -040065 "}",
66 *SkSL::ShaderCapsFactory::Default(),
67 {
Ethan Nicholas130fb3f2018-02-01 12:14:34 -050068 "/* HEADER */\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040069 "\n"
Ethan Nicholas130fb3f2018-02-01 12:14:34 -050070 "/**************************************************************************************************\n"
71 " *** This file was autogenerated from GrTest.fp; do not modify.\n"
72 " **************************************************************************************************/\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040073 "#ifndef GrTest_DEFINED\n"
74 "#define GrTest_DEFINED\n"
Ethan Nicholasceb4d482017-07-10 15:40:20 -040075 "#include \"SkTypes.h\"\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040076 "#include \"GrFragmentProcessor.h\"\n"
77 "#include \"GrCoordTransform.h\"\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040078 "class GrTest : public GrFragmentProcessor {\n"
79 "public:\n"
Brian Salomonaff329b2017-08-11 09:40:37 -040080 " static std::unique_ptr<GrFragmentProcessor> Make() {\n"
81 " return std::unique_ptr<GrFragmentProcessor>(new GrTest());\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040082 " }\n"
Ethan Nicholasf57c0d62017-07-31 11:18:22 -040083 " GrTest(const GrTest& src);\n"
Brian Salomonaff329b2017-08-11 09:40:37 -040084 " std::unique_ptr<GrFragmentProcessor> clone() const override;\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040085 " const char* name() const override { return \"Test\"; }\n"
86 "private:\n"
87 " GrTest()\n"
Ethan Nicholasabff9562017-10-09 10:54:08 -040088 " : INHERITED(kGrTest_ClassID, kNone_OptimizationFlags) {\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040089 " }\n"
90 " GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;\n"
91 " void onGetGLSLProcessorKey(const GrShaderCaps&,GrProcessorKeyBuilder*) "
92 "const override;\n"
93 " bool onIsEqual(const GrFragmentProcessor&) const override;\n"
Brian Salomon0c26a9d2017-07-06 10:09:38 -040094 " GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -040095 " typedef GrFragmentProcessor INHERITED;\n"
96 "};\n"
97 "#endif\n"
98 },
99 {
Ethan Nicholas130fb3f2018-02-01 12:14:34 -0500100 "/* HEADER */\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400101 "\n"
Ethan Nicholas130fb3f2018-02-01 12:14:34 -0500102 "/**************************************************************************************************\n"
103 " *** This file was autogenerated from GrTest.fp; do not modify.\n"
104 " **************************************************************************************************/\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400105 "#include \"GrTest.h\"\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400106 "#include \"glsl/GrGLSLFragmentProcessor.h\"\n"
107 "#include \"glsl/GrGLSLFragmentShaderBuilder.h\"\n"
108 "#include \"glsl/GrGLSLProgramBuilder.h\"\n"
Ethan Nicholas2d5f9b32017-12-13 14:36:14 -0500109 "#include \"GrTexture.h\"\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400110 "#include \"SkSLCPP.h\"\n"
111 "#include \"SkSLUtil.h\"\n"
112 "class GrGLSLTest : public GrGLSLFragmentProcessor {\n"
113 "public:\n"
114 " GrGLSLTest() {}\n"
115 " void emitCode(EmitArgs& args) override {\n"
116 " GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;\n"
117 " const GrTest& _outer = args.fFp.cast<GrTest>();\n"
118 " (void) _outer;\n"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400119 " fragBuilder->codeAppendf(\"%s = half4(1.0);\\n\", args.fOutputColor);\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400120 " }\n"
121 "private:\n"
122 " void onSetData(const GrGLSLProgramDataManager& pdman, "
123 "const GrFragmentProcessor& _proc) override {\n"
124 " }\n"
125 "};\n"
126 "GrGLSLFragmentProcessor* GrTest::onCreateGLSLInstance() const {\n"
127 " return new GrGLSLTest();\n"
128 "}\n"
129 "void GrTest::onGetGLSLProcessorKey(const GrShaderCaps& caps, "
130 "GrProcessorKeyBuilder* b) const {\n"
131 "}\n"
132 "bool GrTest::onIsEqual(const GrFragmentProcessor& other) const {\n"
133 " const GrTest& that = other.cast<GrTest>();\n"
134 " (void) that;\n"
135 " return true;\n"
136 "}\n"
Ethan Nicholasf57c0d62017-07-31 11:18:22 -0400137 "GrTest::GrTest(const GrTest& src)\n"
Ethan Nicholasabff9562017-10-09 10:54:08 -0400138 ": INHERITED(kGrTest_ClassID, src.optimizationFlags()) {\n"
Ethan Nicholasf57c0d62017-07-31 11:18:22 -0400139 "}\n"
Brian Salomonaff329b2017-08-11 09:40:37 -0400140 "std::unique_ptr<GrFragmentProcessor> GrTest::clone() const {\n"
141 " return std::unique_ptr<GrFragmentProcessor>(new GrTest(*this));\n"
Ethan Nicholasf57c0d62017-07-31 11:18:22 -0400142 "}\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400143 });
144}
145
146DEF_TEST(SkSLFPInput, r) {
147 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400148 "in half2 point;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400149 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400150 "sk_OutColor = half4(point, point);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400151 "}",
152 *SkSL::ShaderCapsFactory::Default(),
153 {
154 "SkPoint point() const { return fPoint; }",
Brian Salomonaff329b2017-08-11 09:40:37 -0400155 "static std::unique_ptr<GrFragmentProcessor> Make(SkPoint point) {",
156 "return std::unique_ptr<GrFragmentProcessor>(new GrTest(point));",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400157 "GrTest(SkPoint point)",
158 ", fPoint(point)"
159 },
160 {
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400161 "fragBuilder->codeAppendf(\"%s = half4(half2(%f, %f), half2(%f, %f));\\n\", "
Ethan Nicholas762466e2017-06-29 10:03:38 -0400162 "args.fOutputColor, _outer.point().fX, _outer.point().fY, "
163 "_outer.point().fX, _outer.point().fY);",
164 "if (fPoint != that.fPoint) return false;"
165 });
166}
167
168DEF_TEST(SkSLFPUniform, r) {
169 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400170 "uniform half4 color;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400171 "void main() {"
172 "sk_OutColor = color;"
173 "}",
174 *SkSL::ShaderCapsFactory::Default(),
175 {
Brian Salomonaff329b2017-08-11 09:40:37 -0400176 "static std::unique_ptr<GrFragmentProcessor> Make()"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400177 },
178 {
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400179 "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
Ethan Nicholas762466e2017-06-29 10:03:38 -0400180 "kDefault_GrSLPrecision, \"color\");",
181 });
182}
183
184DEF_TEST(SkSLFPInUniform, r) {
185 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400186 "in uniform half4 color;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400187 "void main() {"
188 "sk_OutColor = color;"
189 "}",
190 *SkSL::ShaderCapsFactory::Default(),
191 {
Brian Salomonaff329b2017-08-11 09:40:37 -0400192 "static std::unique_ptr<GrFragmentProcessor> Make(SkRect color) {",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400193 },
194 {
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400195 "fColorVar = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, kHalf4_GrSLType, "
Ethan Nicholas762466e2017-06-29 10:03:38 -0400196 "kDefault_GrSLPrecision, \"color\");",
197 "const SkRect colorValue = _outer.color();",
Ethan Nicholasee338732017-07-17 15:13:45 -0400198 "pdman.set4fv(fColorVar, 1, (float*) &colorValue);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400199 });
200}
201
202DEF_TEST(SkSLFPSections, r) {
203 test(r,
204 "@header { header section }"
205 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400206 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400207 "}",
208 *SkSL::ShaderCapsFactory::Default(),
209 {
Greg Daniel3e8c3452018-04-06 10:37:55 -0400210 "header section"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400211 },
212 {});
213 test(r,
214 "@class { class section }"
215 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400216 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400217 "}",
218 *SkSL::ShaderCapsFactory::Default(),
219 {
220 "class GrTest : public GrFragmentProcessor {\n"
221 "public:\n"
222 " class section"
223 },
224 {});
225 test(r,
226 "@cpp { cpp section }"
227 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400228 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400229 "}",
230 *SkSL::ShaderCapsFactory::Default(),
231 {},
232 {"cpp section"});
233 test(r,
234 "@constructorParams { int x, float y, std::vector<float> z }"
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400235 "in float w;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400236 "void main() {"
Ethan Nicholas8aa45692017-09-20 11:24:15 -0400237 "sk_OutColor = float4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400238 "}",
239 *SkSL::ShaderCapsFactory::Default(),
240 {
241 "Make(float w, int x, float y, std::vector<float> z )",
Brian Salomonaff329b2017-08-11 09:40:37 -0400242 "return std::unique_ptr<GrFragmentProcessor>(new GrTest(w, x, y, z));",
Ethan Nicholas762466e2017-06-29 10:03:38 -0400243 "GrTest(float w, int x, float y, std::vector<float> z )",
244 ", fW(w) {"
245 },
246 {});
247 test(r,
248 "@constructor { constructor section }"
249 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400250 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400251 "}",
252 *SkSL::ShaderCapsFactory::Default(),
253 {
254 "private:\n constructor section"
255 },
256 {});
257 test(r,
258 "@initializers { initializers section }"
259 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400260 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400261 "}",
262 *SkSL::ShaderCapsFactory::Default(),
263 {
Ethan Nicholasabff9562017-10-09 10:54:08 -0400264 ": INHERITED(kGrTest_ClassID, kNone_OptimizationFlags)\n , initializers section"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400265 },
266 {});
267 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400268 "half x = 10;"
269 "@emitCode { fragBuilder->codeAppendf(\"half y = %d\\n\", x * 2); }"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400270 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400271 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400272 "}",
273 *SkSL::ShaderCapsFactory::Default(),
274 {},
275 {
276 "x = 10.0;\n"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400277 " fragBuilder->codeAppendf(\"half y = %d\\n\", x * 2);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400278 });
279 test(r,
280 "@fields { fields section }"
Ethan Nicholasf57c0d62017-07-31 11:18:22 -0400281 "@clone { }"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400282 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400283 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400284 "}",
285 *SkSL::ShaderCapsFactory::Default(),
286 {
Brian Salomon0c26a9d2017-07-06 10:09:38 -0400287 "GR_DECLARE_FRAGMENT_PROCESSOR_TEST\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400288 " fields section typedef GrFragmentProcessor INHERITED;"
289 },
290 {});
291 test(r,
292 "@make { make section }"
293 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400294 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400295 "}",
296 *SkSL::ShaderCapsFactory::Default(),
297 {
298 "public:\n"
299 " make section"
300 },
301 {});
302 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400303 "uniform half calculated;"
304 "in half provided;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400305 "@setData(varName) { varName.set1f(calculated, provided * 2); }"
306 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400307 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400308 "}",
309 *SkSL::ShaderCapsFactory::Default(),
310 {},
311 {
312 "void onSetData(const GrGLSLProgramDataManager& varName, "
313 "const GrFragmentProcessor& _proc) override {\n",
314 "UniformHandle& calculated = fCalculatedVar;",
315 "auto provided = _outer.provided();",
316 "varName.set1f(calculated, provided * 2);"
317 });
318 test(r,
319 "@test(testDataName) { testDataName section }"
320 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400321 "sk_OutColor = half4(1);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400322 "}",
323 *SkSL::ShaderCapsFactory::Default(),
324 {},
325 {
326 "#if GR_TEST_UTILS\n"
Brian Salomonaff329b2017-08-11 09:40:37 -0400327 "std::unique_ptr<GrFragmentProcessor> GrTest::TestCreate(GrProcessorTestData* testDataName) {\n"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400328 " testDataName section }\n"
329 "#endif"
330 });
331}
332
Ethan Nicholas762466e2017-06-29 10:03:38 -0400333DEF_TEST(SkSLFPTransformedCoords, r) {
334 test(r,
335 "void main() {"
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400336 "sk_OutColor = half4(sk_TransformedCoords2D[0], sk_TransformedCoords2D[0]);"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400337 "}",
338 *SkSL::ShaderCapsFactory::Default(),
339 {},
340 {
Brian Osman72a37be2017-08-15 09:19:53 -0400341 "SkString sk_TransformedCoords2D_0 = "
Ethan Nicholas762466e2017-06-29 10:03:38 -0400342 "fragBuilder->ensureCoords2D(args.fTransformedCoords[0]);",
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400343 "fragBuilder->codeAppendf(\"%s = half4(%s, %s);\\n\", args.fOutputColor, "
Ethan Nicholas762466e2017-06-29 10:03:38 -0400344 "sk_TransformedCoords2D_0.c_str(), sk_TransformedCoords2D_0.c_str());"
345 });
346
347}
348
349DEF_TEST(SkSLFPLayoutWhen, r) {
350 test(r,
Ethan Nicholasf7b88202017-09-18 14:10:39 -0400351 "layout(when=someExpression(someOtherExpression())) uniform half sometimes;"
Ethan Nicholas762466e2017-06-29 10:03:38 -0400352 "void main() {"
353 "}",
354 *SkSL::ShaderCapsFactory::Default(),
355 {},
356 {
357 "if (someExpression(someOtherExpression())) {\n"
358 " fSometimesVar = args.fUniformHandler->addUniform"
359 });
360
361}
362
Ethan Nicholasc9472af2017-10-10 16:30:21 -0400363DEF_TEST(SkSLFPChildProcessors, r) {
364 test(r,
365 "in fragmentProcessor child1;"
366 "in fragmentProcessor child2;"
367 "void main() {"
368 " sk_OutColor = process(child1) * process(child2);"
369 "}",
370 *SkSL::ShaderCapsFactory::Default(),
371 {
372 "this->registerChildProcessor(std::move(child1));",
373 "this->registerChildProcessor(std::move(child2));"
374 },
375 {
376 "SkString _child0(\"_child0\");",
377 "this->emitChild(0, &_child0, args);",
378 "SkString _child1(\"_child1\");",
379 "this->emitChild(1, &_child1, args);",
380 "this->registerChildProcessor(src.childProcessor(0).clone());",
381 "this->registerChildProcessor(src.childProcessor(1).clone());"
382 });
383}
Michael Ludwig92e4c7f2018-08-30 16:08:18 -0400384
385DEF_TEST(SkSLFPChildProcessorsWithInput, r) {
386 test(r,
387 "in fragmentProcessor child1;"
388 "in fragmentProcessor child2;"
389 "void main() {"
390 " half4 childIn = sk_InColor;"
391 " half4 childOut1 = process(child1, childIn);"
392 " half4 childOut2 = process(child2, childOut1);"
393 " sk_OutColor = childOut2;"
394 "}",
395 *SkSL::ShaderCapsFactory::Default(),
396 {
397 "this->registerChildProcessor(std::move(child1));",
398 "this->registerChildProcessor(std::move(child2));"
399 },
400 {
401 "SkString _input0(\"childIn\");",
402 "SkString _child0(\"_child0\");",
403 "this->emitChild(0, _input0.c_str(), &_child0, args);",
404 "SkString _input1(\"childOut1\");",
405 "SkString _child1(\"_child1\");",
406 "this->emitChild(1, _input1.c_str(), &_child1, args);",
407 "this->registerChildProcessor(src.childProcessor(0).clone());",
408 "this->registerChildProcessor(src.childProcessor(1).clone());"
409 });
410}
411
412DEF_TEST(SkSLFPChildProcessorWithInputExpression, r) {
413 test(r,
414 "in fragmentProcessor child;"
415 "void main() {"
416 " sk_OutColor = process(child, sk_InColor * half4(0.5));"
417 "}",
418 *SkSL::ShaderCapsFactory::Default(),
419 {
420 "this->registerChildProcessor(std::move(child));",
421 },
422 {
423 "SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
424 "SkString _child0(\"_child0\");",
425 "this->emitChild(0, _input0.c_str(), &_child0, args);",
426 "this->registerChildProcessor(src.childProcessor(0).clone());",
427 });
428}
429
430DEF_TEST(SkSLFPNestedChildProcessors, r) {
431 test(r,
432 "in fragmentProcessor child1;"
433 "in fragmentProcessor child2;"
434 "void main() {"
435 " sk_OutColor = process(child2, sk_InColor * process(child1, sk_InColor * half4(0.5)));"
436 "}",
437 *SkSL::ShaderCapsFactory::Default(),
438 {
439 "this->registerChildProcessor(std::move(child1));",
440 "this->registerChildProcessor(std::move(child2));"
441 },
442 {
443 "SkString _input0 = SkStringPrintf(\"%s * half4(0.5)\", args.fInputColor);",
444 "SkString _child0(\"_child0\");",
445 "this->emitChild(0, _input0.c_str(), &_child0, args);",
446 "SkString _input1 = SkStringPrintf(\"%s * %s\", args.fInputColor, _child0.c_str());",
447 "SkString _child1(\"_child1\");",
448 "this->emitChild(1, _input1.c_str(), &_child1, args);",
449 "this->registerChildProcessor(src.childProcessor(0).clone());",
450 "this->registerChildProcessor(src.childProcessor(1).clone());"
451 });
452}