SkPDF: Refactor PDFShader to use ShTHashMap<>

my tests run ~14% faster.

  - Split out gradient shaders from image shaders.  new compilation
    unit: SkPDFGradientShader
  - Common functions InverseTransformBBox and PopulateTilingPatternDict
    moved to SkPDFUtils
  - Split SkPDFShader::State into image and gradient structures.
  - SkPDFCanon is now a simpler structure, with no logic of its own.
    I am considering just moving all of its fields into SkPDFDocument
  - SkPDFShader::State (the image/fallback shader) now is POD, making
    the use of a hashmap for canonicalization straightforward.
    Formerly, we used a linear search.
  - Do not bother trying to canonicalize the falback image shader.
  - SkPDFGradientShader::Key is not POD; comparison of two objects
    requires looking at the contents of two variable-sized arrays.
    We now pre-calculate the hash of the arrays using SkOpts::hash and
    store a hash for the object in the fHash field.
    Using that hash, we can now canonicalize using a hashmap instead
    of a linar search!
  - several static functions renamed to follow style guidelines
  - stop using codeFunction function pointer; I find that less
    clear than it could be.
  - operator==() for SkPDFShader::State and SkPDFGradientShader::Key is
    now much simpler and can now be inlined.
  - SkArrayEqual template in SkPDFUtils.h

No change to PDF output.

BUG=skia:3585
Change-Id: I354ad1b600be6d6749abccb58d13db257370bc0b
Reviewed-on: https://skia-review.googlesource.com/21376
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
index 3ecd474..53a0044 100644
--- a/src/pdf/SkPDFCanon.cpp
+++ b/src/pdf/SkPDFCanon.cpp
@@ -10,47 +10,7 @@
 #include "SkPDFCanon.h"
 #include "SkPDFFont.h"
 
-////////////////////////////////////////////////////////////////////////////////
-
 SkPDFCanon::~SkPDFCanon() {}
+SkPDFCanon::SkPDFCanon() {}
 
-////////////////////////////////////////////////////////////////////////////////
 
-template <typename T>
-sk_sp<SkPDFObject> find_shader(const SkTArray<T>& records,
-                               const SkPDFShader::State& state) {
-    for (const T& record : records) {
-        if (record.fShaderState == state) {
-            return record.fShaderObject;
-        }
-    }
-    return nullptr;
-}
-
-sk_sp<SkPDFObject> SkPDFCanon::findFunctionShader(
-        const SkPDFShader::State& state) const {
-    return find_shader(fFunctionShaderRecords, state);
-}
-void SkPDFCanon::addFunctionShader(sk_sp<SkPDFObject> pdfShader,
-                                   SkPDFShader::State state) {
-    fFunctionShaderRecords.emplace_back(ShaderRec{std::move(state), std::move(pdfShader)});
-}
-
-sk_sp<SkPDFObject> SkPDFCanon::findAlphaShader(
-        const SkPDFShader::State& state) const {
-    return find_shader(fAlphaShaderRecords, state);
-}
-void SkPDFCanon::addAlphaShader(sk_sp<SkPDFObject> pdfShader,
-                                SkPDFShader::State state) {
-    fAlphaShaderRecords.emplace_back(ShaderRec{std::move(state), std::move(pdfShader)});
-}
-
-sk_sp<SkPDFObject> SkPDFCanon::findImageShader(
-        const SkPDFShader::State& state) const {
-    return find_shader(fImageShaderRecords, state);
-}
-
-void SkPDFCanon::addImageShader(sk_sp<SkPDFObject> pdfShader,
-                                SkPDFShader::State state) {
-    fImageShaderRecords.emplace_back(ShaderRec{std::move(state), std::move(pdfShader)});
-}