cache SkSL headers

This reduces the cost of successive shader compilations by caching the
results of compiling SkSL's headers.

Bug: skia:
Change-Id: If7fc21a9877021c4025ad99dd0981523a25855e0
Reviewed-on: https://skia-review.googlesource.com/123422
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index a0de551..c081fd7 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -142,7 +142,8 @@
 #undef CAP
 }
 
-void IRGenerator::start(const Program::Settings* settings) {
+void IRGenerator::start(const Program::Settings* settings,
+                        std::vector<std::unique_ptr<ProgramElement>>* inherited) {
     fSettings = settings;
     fCapsMap.clear();
     if (settings->fCaps) {
@@ -154,6 +155,17 @@
     fSkPerVertex = nullptr;
     fRTAdjust = nullptr;
     fRTAdjustInterfaceBlock = nullptr;
+    if (inherited) {
+        for (const auto& e : *inherited) {
+            if (e->fKind == ProgramElement::kInterfaceBlock_Kind) {
+                InterfaceBlock& intf = (InterfaceBlock&) *e;
+                if (intf.fVariable.fName == Compiler::PERVERTEX_NAME) {
+                    ASSERT(!fSkPerVertex);
+                    fSkPerVertex = &intf.fVariable;
+                }
+            }
+        }
+    }
 }
 
 void IRGenerator::finish() {
@@ -861,10 +873,6 @@
                                                                        (int) i)));
         }
     }
-    if (var->fName == Compiler::PERVERTEX_NAME) {
-        ASSERT(!fSkPerVertex);
-        fSkPerVertex = var;
-    }
     return std::unique_ptr<InterfaceBlock>(new InterfaceBlock(intf.fOffset,
                                                               var,
                                                               intf.fTypeName,