Remove a level of indirection with GrProcessorKeyBuilder

Bug: skia:11372
Change-Id: Icb36f665ae9ce39b32d7626b3114c3303923f33e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/379583
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index c691e79..c471f8c 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -20,12 +20,12 @@
 class GrRenderTarget;
 class GrShaderCaps;
 
-class GrKeyBuilder {
+class GrProcessorKeyBuilder {
 public:
-    GrKeyBuilder() = default;
-    GrKeyBuilder(const GrKeyBuilder& other) = default;
+    GrProcessorKeyBuilder() = default;
+    GrProcessorKeyBuilder(const GrProcessorKeyBuilder& other) = default;
 
-    void reset() { *this = GrKeyBuilder{}; }
+    void reset() { *this = GrProcessorKeyBuilder{}; }
 
     void addBits(uint32_t numBits, uint32_t val, const char* label) {
         SkASSERT(numBits > 0 && numBits <= 32);
@@ -55,6 +55,14 @@
         }
     }
 
+    void addBool(bool b, const char* label) {
+        this->addBits(1, b, label);
+    }
+
+    void add32(uint32_t v, const char* label = "unknown") {
+        this->addBits(32, v, label);
+    }
+
     template <typename StringFunc>
     void addString(StringFunc&& sf) {
         #ifdef SK_DEBUG
@@ -63,6 +71,8 @@
         #endif
     }
 
+    // Introduces a word-boundary in the key. Must be called before using the key with any cache,
+    // but can also be called to create a break between generic data and backend-specific data.
     void flush() {
         if (fBitsUsed) {
             fData.push_back(fCurValue);
@@ -86,15 +96,15 @@
         return (fData.count() * sizeof(uint32_t) * CHAR_BIT) + fBitsUsed;
     }
 
-    GrKeyBuilder& operator=(const GrKeyBuilder& other) = default;
+    GrProcessorKeyBuilder& operator=(const GrProcessorKeyBuilder& other) = default;
 
-    bool operator==(const GrKeyBuilder& that) const {
+    bool operator==(const GrProcessorKeyBuilder& that) const {
         return fBitsUsed == that.fBitsUsed &&
                fCurValue == that.fCurValue &&
                fData == that.fData;
     }
 
-    bool operator!= (const GrKeyBuilder& other) const {
+    bool operator!= (const GrProcessorKeyBuilder& other) const {
         return !(*this == other);
     }
 
@@ -194,10 +204,10 @@
         return true;
     }
 
-    GrKeyBuilder& key() { return fKey; }
+    GrProcessorKeyBuilder* key() { return &fKey; }
 
 private:
-    GrKeyBuilder fKey;
+    GrProcessorKeyBuilder fKey;
     uint32_t fInitialKeyLength = 0;
 };