Runtime effects: Fix error when mutating main's coords

These often became direct references to a varying, which can't be
mutated in GLSL. Fix this by copying them to a local variable in the
FP, and pointing all references at that.

Bug: skia:10918
Change-Id: I705e3c966b1d44fc4dfc3d4b40eb8e46110febdd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334043
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
diff --git a/tests/SkRuntimeEffectTest.cpp b/tests/SkRuntimeEffectTest.cpp
index 49213df..e234f30 100644
--- a/tests/SkRuntimeEffectTest.cpp
+++ b/tests/SkRuntimeEffectTest.cpp
@@ -238,6 +238,13 @@
     effect.build("vec4 main(float2 p) { return float4(p - 0.5, 0, 1); }");
     effect.test(0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF);
 
+    // Mutating coords should work. (skbug.com/10918)
+    effect.build("vec4 main(vec2 p) { p -= 0.5; return vec4(p, 0, 1); }");
+    effect.test(0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF);
+    effect.build("void moveCoords(inout vec2 p) { p -= 0.5; }"
+                 "vec4 main(vec2 p) { moveCoords(p); return vec4(p, 0, 1); }");
+    effect.test(0xFF000000, 0xFF0000FF, 0xFF00FF00, 0xFF00FFFF);
+
     //
     // Sampling children
     //