[PDF] Clean up ref counting.

Return ref'd objs where possible enabling removal of many SkRefPtr<> variables.

Review URL: http://codereview.appspot.com/4029051

git-svn-id: http://skia.googlecode.com/svn/trunk@750 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/pdf/SkPDFCatalog.h b/include/pdf/SkPDFCatalog.h
index 60f9791..f004a1d 100644
--- a/include/pdf/SkPDFCatalog.h
+++ b/include/pdf/SkPDFCatalog.h
@@ -35,11 +35,12 @@
     SkPDFCatalog();
     ~SkPDFCatalog();
 
-    /** Add the passed object to the catalog.
+    /** Add the passed object to the catalog.  Refs obj.
      *  @param obj         The object to add.
      *  @param onFirstPage Is the object on the first page.
+     *  @return The obj argument is returned.
      */
-    void addObject(SkPDFObject* obj, bool onFirstPage);
+    SkPDFObject* addObject(SkPDFObject* obj, bool onFirstPage);
 
     /** Inform the catalog of the object's position in the final stream.
      *  The object should already have been added to the catalog.  Returns
diff --git a/include/pdf/SkPDFFormXObject.h b/include/pdf/SkPDFFormXObject.h
index 288a449..6a16709 100644
--- a/include/pdf/SkPDFFormXObject.h
+++ b/include/pdf/SkPDFFormXObject.h
@@ -52,17 +52,19 @@
     virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
     virtual void getResources(SkTDArray<SkPDFObject*>* resourceList);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(SkPDFName* key, SkPDFObject* value);
+    SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The text of the key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(const char key[], SkPDFObject* value);
+    SkPDFObject* insert(const char key[], SkPDFObject* value);
 
 private:
     SkString fContent;
diff --git a/include/pdf/SkPDFImage.h b/include/pdf/SkPDFImage.h
index 9b4e4f9..7966e99 100644
--- a/include/pdf/SkPDFImage.h
+++ b/include/pdf/SkPDFImage.h
@@ -49,10 +49,11 @@
 
     virtual ~SkPDFImage();
 
-    /** Add a Soft Mask (alpha or shape channel) to the image.
+    /** Add a Soft Mask (alpha or shape channel) to the image.  Refs mask.
      *  @param mask A gray scale image representing the mask.
+     *  @return The mask argument is returned.
      */
-    void addSMask(SkPDFImage* mask);
+    SkPDFImage* addSMask(SkPDFImage* mask);
 
     // The SkPDFObject interface.
     virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog,
@@ -76,17 +77,19 @@
     SkPDFImage(SkStream* imageData, const SkBitmap& bitmap,
                const SkIRect& srcRect, bool alpha, const SkPaint& paint);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(SkPDFName* key, SkPDFObject* value);
+    SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The text of the key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(const char key[], SkPDFObject* value);
+    SkPDFObject* insert(const char key[], SkPDFObject* value);
 };
 
 #endif
diff --git a/include/pdf/SkPDFStream.h b/include/pdf/SkPDFStream.h
index 10a40b6..5310b4e 100644
--- a/include/pdf/SkPDFStream.h
+++ b/include/pdf/SkPDFStream.h
@@ -43,17 +43,19 @@
                             bool indirect);
     virtual size_t getOutputSize(SkPDFCatalog* catalog, bool indirect);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(SkPDFName* key, SkPDFObject* value);
+    SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
 
-    /** Add the value to the stream dictionary with the given key.
+    /** Add the value to the stream dictionary with the given key.  Refs value.
      *  @param key   The text of the key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(const char key[], SkPDFObject* value);
+    SkPDFObject* insert(const char key[], SkPDFObject* value);
 
 private:
     SkPDFDict fDict;
diff --git a/include/pdf/SkPDFTypes.h b/include/pdf/SkPDFTypes.h
index fc9b62c..7d59634 100644
--- a/include/pdf/SkPDFTypes.h
+++ b/include/pdf/SkPDFTypes.h
@@ -253,16 +253,18 @@
      */
     SkPDFObject* getAt(int index) { return fValue[index]; }
 
-    /** Set the object at the given offset in the array.
+    /** Set the object at the given offset in the array. Ref's value.
      *  @param index The index into the array to set.
      *  @param value The value to add to the array.
+     *  @return The value argument is returned.
      */
-    void setAt(int index, SkPDFObject* value);
+    SkPDFObject* setAt(int index, SkPDFObject* value);
 
-    /** Append the object to the end of the array.
+    /** Append the object to the end of the array and increments its ref count.
      *  @param value The value to add to the array.
+     *  @return The value argument is returned.
      */
-    void append(SkPDFObject* value);
+    SkPDFObject* append(SkPDFObject* value);
 
 private:
     static const int kMaxLen = 8191;
@@ -295,18 +297,20 @@
      */
     int size() { return fValue.count(); }
 
-    /** Add the value to the dictionary with the given key.
+    /** Add the value to the dictionary with the given key.  Refs value.
      *  @param key   The key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(SkPDFName* key, SkPDFObject* value);
+    SkPDFObject* insert(SkPDFName* key, SkPDFObject* value);
 
-    /** Add the value to the dictionary with the given key.  The method will
-     *  create the SkPDFName object.
+    /** Add the value to the dictionary with the given key.  Refs value.  The
+     *  method will create the SkPDFName object.
      *  @param key   The text of the key for this dictionary entry.
      *  @param value The value for this dictionary entry.
+     *  @return The value argument is returned.
      */
-    void insert(const char key[], SkPDFObject* value);
+    SkPDFObject* insert(const char key[], SkPDFObject* value);
 
     /** Remove all entries from the dictionary.
      */