Optimize CPP code generation.

Previously, we were limiting our calls to appendVAList to 512-byte
chunks to avoid a potential buffer overflow. This had two problems:
1 - it did not avoid the buffer overflow :(
    see chromium:1092743
2 - every call to appendVAList is expensive; it incurs a resize of the
    code buffer (alloc new, memcpy, free old)

This CL removes the 512-byte cap as the buffer overflow issue was
resolved at http://review.skia.org/297276

This CL also includes a few more minor improvements.
- `codeAppendf` now uses a raw string so the gencode is easier to read.
- Optimized `SkStringPrintf("%s", foo)` to `SkString(foo)`.
- Optimized `strA = strB` to `strA.swap(strB)` where safe to do so.

Change-Id: Ia0909a68719848dd2ca655066a9bc6929c8fd09f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297358
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
index 761c4e6..3d9dc96 100644
--- a/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
+++ b/src/gpu/gradients/generated/GrTiledGradientEffect.cpp
@@ -32,11 +32,20 @@
         SkString _sample453;
         _sample453 = this->invokeChild(_outer.gradLayout_index, 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 * "
-                "floor(t_1 * 0.5)) - 1.0;\n        if (sk_Caps.mustDoOpBetweenFloorAndAbs) {\n     "
-                "       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    }",
+                R"SkSL(half4 t = %s;
+if (!%s && t.y < 0.0) {
+    %s = half4(0.0);
+} else {
+    @if (%s) {
+        half t_1 = t.x - 1.0;
+        half tiled_t = (t_1 - 2.0 * floor(t_1 * 0.5)) - 1.0;
+        if (sk_Caps.mustDoOpBetweenFloorAndAbs) {
+            tiled_t = clamp(tiled_t, -1.0, 1.0);
+        }
+        t.x = abs(tiled_t);
+    } else {
+        t.x = fract(t.x);
+    })SkSL",
                 _sample453.c_str(),
                 (_outer.childProcessor(_outer.gradLayout_index).preservesOpaqueInput() ? "true"
                                                                                        : "false"),
@@ -44,10 +53,16 @@
         SkString _input1464("t");
         SkString _sample1464;
         _sample1464 = this->invokeChild(_outer.colorizer_index, _input1464.c_str(), args);
-        fragBuilder->codeAppendf("\n    %s = %s;\n}\n@if (%s) {\n    %s.xyz *= %s.w;\n}\n",
-                                 args.fOutputColor, _sample1464.c_str(),
-                                 (_outer.makePremul ? "true" : "false"), args.fOutputColor,
-                                 args.fOutputColor);
+        fragBuilder->codeAppendf(
+                R"SkSL(
+    %s = %s;
+}
+@if (%s) {
+    %s.xyz *= %s.w;
+}
+)SkSL",
+                args.fOutputColor, _sample1464.c_str(), (_outer.makePremul ? "true" : "false"),
+                args.fOutputColor, args.fOutputColor);
     }
 
 private: