[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/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 77a9fdb..79ce9f3 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -62,20 +62,14 @@
         SkPDFDict* pageTreeRoot;
         SkPDFPage::generatePageTree(fPages, &fCatalog, &fPageTree,
                                     &pageTreeRoot);
-        SkRefPtr<SkPDFObjRef> pageTreeRootRef = new SkPDFObjRef(pageTreeRoot);
-        pageTreeRootRef->unref();  // SkRefPtr and new both took a reference.
-        fDocCatalog->insert("Pages", pageTreeRootRef.get());
+        fDocCatalog->insert("Pages", new SkPDFObjRef(pageTreeRoot))->unref();
 
         /* TODO(vandebo) output intent
         SkRefPtr<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent");
         outputIntent->unref();  // SkRefPtr and new both took a reference.
-        SkRefPtr<SkPDFName> intentSubtype = new SkPDFName("GTS_PDFA1");
-        intentSubtype->unref();  // SkRefPtr and new both took a reference.
-        outputIntent->insert("S", intentSubtype.get());
-        SkRefPtr<SkPDFString> intentIdentifier = new SkPDFString("sRGB");
-        intentIdentifier->unref();  // SkRefPtr and new both took a reference.
+        outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref();
         outputIntent->insert("OutputConditionIdentifier",
-                             intentIdentifier.get());
+                             new SkPDFString("sRGB"))->unref();
         SkRefPtr<SkPDFArray> intentArray = new SkPDFArray;
         intentArray->unref();  // SkRefPtr and new both took a reference.
         intentArray->append(outputIntent.get());
@@ -179,17 +173,11 @@
         fTrailerDict = new SkPDFDict();
         fTrailerDict->unref();  // SkRefPtr and new both took a reference.
 
-        SkPDFInt* objCountInt = new SkPDFInt(objCount);
-        fTrailerDict->insert("Size", objCountInt);
-        objCountInt->unref();  // insert took a ref and we're done with it.
-
         // TODO(vandebo) Linearized format will take a Prev entry too.
-
-        SkPDFObjRef* docCatalogRef = new SkPDFObjRef(fDocCatalog.get());
-        fTrailerDict->insert("Root", docCatalogRef);
-        docCatalogRef->unref();  // insert took a ref and we're done with it.
-
         // TODO(vandebo) PDF/A requires an ID entry.
+        fTrailerDict->insert("Size", new SkPDFInt(objCount))->unref();
+        fTrailerDict->insert("Root",
+                             new SkPDFObjRef(fDocCatalog.get()))->unref();
     }
 
     stream->writeText("trailer\n");