SkPDF: SkPDFMakeArray; clean up pdfutils, pdfresourcedict

New templated function SkPDFMakeArray that for example replaced this
code:

    auto array = sk_make_sp<SkPDFArray>();
    array->reserve(4);
    array->appendInt(0);
    array->appendInt(0);
    array->appendInt(width);
    array->appendInt(height);

with this code:

    auto array = SkPDFMakeArray(0, 0, width, height);

Move some functions from SkPDFUtils to the only place they
are used and make them static: SkPDFUtils::AppendTransform,
SkPDFUtils::DrawFormXObject, SkPDFUtils::WriteString, and
SkPDFUtils::AppendCubic.

Also replaced SkPDFResourceDict::getResourceName with
SkPDFResourceDict::WriteResourceName and eliminated
SkPDFResourceDict::GetResourceTypePrefix.

Change-Id: I891339fa2d1e5819f22fb8d10d8d8ef75c9507e3
Reviewed-on: https://skia-review.googlesource.com/153884
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
diff --git a/src/pdf/SkPDFResourceDict.h b/src/pdf/SkPDFResourceDict.h
index 680855f..63b7eb1 100644
--- a/src/pdf/SkPDFResourceDict.h
+++ b/src/pdf/SkPDFResourceDict.h
@@ -9,30 +9,22 @@
 #define SkPDFResourceDict_DEFINED
 
 #include "SkPDFFont.h"
-#include "SkString.h"
 
 #include <vector>
 
 class SkPDFDict;
 class SkPDFObject;
+class SkWStream;
 
-/** A resource dictionary, which maintains the relevant sub-dicts and
-    allows generation of a list of referenced SkPDFObjects inserted with
-    insertResourceAsRef.
-*/
-namespace SkPDFResourceDict {
-
-enum SkPDFResourceType {
-    kExtGState_ResourceType,
-    kPattern_ResourceType,
-    kXObject_ResourceType,
-    kFont_ResourceType,
+enum class SkPDFResourceType {
+    kExtGState = 0,
+    kPattern = 1,
+    kXObject = 2,
+    kFont = 3,
     // These additional types are defined by the spec, but not
     // currently used by Skia: ColorSpace, Shading, Properties
-    kResourceTypeCount
 };
 
-char GetResourceTypePrefix(SkPDFResourceDict::SkPDFResourceType type);
 
 /** Create a PDF resource dictionary.
  *  The full set of ProcSet entries is automatically created for backwards
@@ -40,21 +32,18 @@
  *
  *  Any arguments can be nullptr.
  */
-sk_sp<SkPDFDict> Make(std::vector<sk_sp<SkPDFObject>> graphicStateResources,
-                      std::vector<sk_sp<SkPDFObject>> shaderResources,
-                      std::vector<sk_sp<SkPDFObject>> xObjectResources,
-                      std::vector<sk_sp<SkPDFFont>> fontResources);
+sk_sp<SkPDFDict> SkPDFMakeResourceDict(std::vector<sk_sp<SkPDFObject>> graphicStateResources,
+                                       std::vector<sk_sp<SkPDFObject>> shaderResources,
+                                       std::vector<sk_sp<SkPDFObject>> xObjectResources,
+                                       std::vector<sk_sp<SkPDFFont>> fontResources);
 
 /**
- * Returns the name for the resource that will be generated by the resource
+ * Writes the name for the resource that will be generated by the resource
  * dict.
  *
- *  @param type  The type of resource being entered, like
- *    kPattern_ResourceType or kExtGState_ResourceType.
+ *  @param type  The type of resource being entered
  *  @param key   The resource key, should be unique within its type.
  */
-SkString getResourceName(SkPDFResourceType type, int key);
-
-}
+void SkPDFWriteResourceName(SkWStream*, SkPDFResourceType type, int key);
 
 #endif