Revert "Reland "Revert "Reland "GPU support for SkMixers""""

This reverts commit 1263889f3a3ea44db959f043254f4ee9e4014ac9.

Bug: skia:
Change-Id: I647cb228e4a8169f12f4afadaf1db06843e4e5fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/206391
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 4baa90e..696b4a1 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -673,6 +673,10 @@
     return std::unique_ptr<Statement>(new ExpressionStatement(std::move(result)));
 }
 
+// returns true if the modifiers are (explicitly or implicitly) nothing but 'in'
+static bool is_in(const Modifiers& modifiers) {
+    return (modifiers.fFlags & ~Modifiers::kIn_Flag) == 0;
+}
 
 void IRGenerator::convertFunction(const ASTFunction& f) {
     const Type* returnType = this->convertType(*f.fReturnType);
@@ -700,33 +704,51 @@
     }
 
     if (f.fName == "main") {
-        if (fKind == Program::kPipelineStage_Kind) {
-            bool valid;
-            switch (parameters.size()) {
-                case 3:
-                    valid = parameters[0]->fType == *fContext.fInt_Type &&
-                            parameters[0]->fModifiers.fFlags == 0 &&
-                            parameters[1]->fType == *fContext.fInt_Type &&
-                            parameters[1]->fModifiers.fFlags == 0 &&
-                            parameters[2]->fType == *fContext.fHalf4_Type &&
-                            parameters[2]->fModifiers.fFlags == (Modifiers::kIn_Flag |
-                                                                 Modifiers::kOut_Flag);
-                    break;
-                case 1:
-                    valid = parameters[0]->fType == *fContext.fHalf4_Type &&
-                            parameters[0]->fModifiers.fFlags == (Modifiers::kIn_Flag |
-                                                                 Modifiers::kOut_Flag);
-                    break;
-                default:
-                    valid = false;
+        switch (fKind) {
+            case Program::kPipelineStage_Kind: {
+                bool valid;
+                switch (parameters.size()) {
+                    case 3:
+                        valid = parameters[0]->fType == *fContext.fInt_Type &&
+                                parameters[0]->fModifiers.fFlags == 0 &&
+                                parameters[1]->fType == *fContext.fInt_Type &&
+                                parameters[1]->fModifiers.fFlags == 0 &&
+                                parameters[2]->fType == *fContext.fHalf4_Type &&
+                                parameters[2]->fModifiers.fFlags == (Modifiers::kIn_Flag |
+                                                                     Modifiers::kOut_Flag);
+                        break;
+                    case 1:
+                        valid = parameters[0]->fType == *fContext.fHalf4_Type &&
+                                parameters[0]->fModifiers.fFlags == (Modifiers::kIn_Flag |
+                                                                     Modifiers::kOut_Flag);
+                        break;
+                    default:
+                        valid = false;
+                }
+                if (!valid) {
+                    fErrors.error(f.fOffset, "pipeline stage 'main' must be declared main(int, "
+                                             "int, inout half4) or main(inout half4)");
+                    return;
+                }
+                break;
             }
-            if (!valid) {
-                fErrors.error(f.fOffset, "pipeline stage 'main' must be declared main(int, "
-                                         "int, inout half4) or main(inout half4)");
-                return;
+            case Program::kMixer_Kind: {
+                if (*returnType != *fContext.fVoid_Type ||
+                    parameters.size() != 2 ||
+                    parameters[0]->fType != *fContext.fHalf4_Type ||
+                    !is_in(parameters[0]->fModifiers) ||
+                    parameters[1]->fType != *fContext.fHalf4_Type ||
+                    !is_in(parameters[1]->fModifiers)) {
+                    fErrors.error(f.fOffset, "mixer stage 'main' must be declared void main("
+                                             "half4, half4)");
+                    return;
+                }
+                break;
             }
-        } else if (parameters.size()) {
-            fErrors.error(f.fOffset, "shader 'main' must have zero parameters");
+            default:
+                if (parameters.size()) {
+                    fErrors.error(f.fOffset, "shader 'main' must have zero parameters");
+                }
         }
     }