Move the initial GrProgramDesc keyLength into the header

This sets up for moving GrProgramDesc creation to GrCaps. I.e., we will have a virtual "GrProgramDesc GrCaps::makeDesc(const GrRenderTarget*, const GrProgramInfo&)" call.

Bug: skia:9455
Change-Id: I82053297383af9d405e6b485bf8287f10fa15967
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/256696
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index 9d9ea00..775db62 100644
--- a/src/gpu/GrProgramDesc.h
+++ b/src/gpu/GrProgramDesc.h
@@ -86,6 +86,8 @@
         return !(*this == other);
     }
 
+    uint32_t initialKeyLength() const { return this->header().fInitialKeyLength; }
+
 protected:
     // TODO: this should be removed and converted to just data added to the key
     struct KeyHeader {
@@ -94,18 +96,26 @@
         uint8_t fColorFragmentProcessorCnt; // Can be packed into 4 bits if required.
         uint8_t fCoverageFragmentProcessorCnt;
         // Set to uniquely identify the rt's origin, or 0 if the shader does not require this info.
-        uint8_t fSurfaceOriginKey : 2;
-        uint8_t fProcessorFeatures : 1;
-        bool fSnapVerticesToPixelCenters : 1;
-        bool fHasPointSize : 1;
-        uint8_t fPad : 3;
+        uint32_t fSurfaceOriginKey : 2;
+        uint32_t fProcessorFeatures : 1;
+        uint32_t fSnapVerticesToPixelCenters : 1;
+        uint32_t fHasPointSize : 1;
+        // This is the key size (in bytes) after core key construction. It doesn't include any
+        // portions added by the platform-specific backends.
+        uint32_t fInitialKeyLength : 27;
     };
-    GR_STATIC_ASSERT(sizeof(KeyHeader) == 6);
+    GR_STATIC_ASSERT(sizeof(KeyHeader) == 8);
+
+    const KeyHeader& header() const { return *this->atOffset<KeyHeader, kHeaderOffset>(); }
 
     template<typename T, size_t OFFSET> T* atOffset() {
         return reinterpret_cast<T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET);
     }
 
+    template<typename T, size_t OFFSET> const T* atOffset() const {
+        return reinterpret_cast<const T*>(reinterpret_cast<intptr_t>(fKey.begin()) + OFFSET);
+    }
+
     // The key, stored in fKey, is composed of two parts:
     // 1. Header struct defined above.
     // 2. A Backend specific payload which includes the per-processor keys.