Add DPI stettings to SkDocument::CreatePDF(). Tests will be added in a future cl, once DPI will be used in SkPDFDevice

R=reed@google.com, bungeman@google.com, vandebo@chromium.org

Author: edisonn@google.com

Review URL: https://codereview.chromium.org/32233003

git-svn-id: http://skia.googlecode.com/svn/trunk/src@11886 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/doc/SkDocument_PDF.cpp b/doc/SkDocument_PDF.cpp
index 695929f..362493d 100644
--- a/doc/SkDocument_PDF.cpp
+++ b/doc/SkDocument_PDF.cpp
@@ -12,9 +12,11 @@
 class SkDocument_PDF : public SkDocument {
 public:
     SkDocument_PDF(SkWStream* stream, void (*doneProc)(SkWStream*),
-                   SkPicture::EncodeBitmap encoder)
+                   SkPicture::EncodeBitmap encoder,
+                   SkScalar rasterDpi)
             : SkDocument(stream, doneProc)
-            , fEncoder(encoder) {
+            , fEncoder(encoder)
+            , fRasterDpi(rasterDpi) {
         fDoc = SkNEW(SkPDFDocument);
         fCanvas = NULL;
         fDevice = NULL;
@@ -38,6 +40,9 @@
         if (fEncoder) {
             fDevice->setDCTEncoder(fEncoder);
         }
+        if (fRasterDpi != 0) {
+            fDevice->setRasterDpi(fRasterDpi);
+        }
         fCanvas = SkNEW_ARGS(SkCanvas, (fDevice));
         return fCanvas;
     }
@@ -76,24 +81,28 @@
     SkPDFDeviceFlattener* fDevice;
     SkCanvas*       fCanvas;
     SkPicture::EncodeBitmap fEncoder;
+    SkScalar        fRasterDpi;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 
 SkDocument* SkDocument::CreatePDF(SkWStream* stream, void (*done)(SkWStream*),
-                                  SkPicture::EncodeBitmap enc) {
-    return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc)) : NULL;
+                                  SkPicture::EncodeBitmap enc,
+                                  SkScalar dpi) {
+    return stream ? SkNEW_ARGS(SkDocument_PDF, (stream, done, enc, dpi)) : NULL;
 }
 
 static void delete_wstream(SkWStream* stream) {
     SkDELETE(stream);
 }
 
-SkDocument* SkDocument::CreatePDF(const char path[], SkPicture::EncodeBitmap enc) {
+SkDocument* SkDocument::CreatePDF(const char path[],
+                                  SkPicture::EncodeBitmap enc,
+                                  SkScalar dpi) {
     SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
     if (!stream->isValid()) {
         SkDELETE(stream);
         return NULL;
     }
-    return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc));
+    return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi));
 }
diff --git a/pdf/SkPDFDevice.cpp b/pdf/SkPDFDevice.cpp
index e90edb1..1aed856 100644
--- a/pdf/SkPDFDevice.cpp
+++ b/pdf/SkPDFDevice.cpp
@@ -704,7 +704,8 @@
       fLastContentEntry(NULL),
       fLastMarginContentEntry(NULL),
       fClipStack(NULL),
-      fEncoder(NULL) {
+      fEncoder(NULL),
+      fRasterDpi(SkFloatToScalar(72.0f)) {
     // just report that PDF does not supports perspective
     // TODO(edisonn): update the shape when possible
     // or dump in an image otherwise
@@ -734,7 +735,9 @@
       fExistingClipRegion(existingClipRegion),
       fLastContentEntry(NULL),
       fLastMarginContentEntry(NULL),
-      fClipStack(NULL) {
+      fClipStack(NULL),
+      fEncoder(NULL),
+      fRasterDpi(SkFloatToScalar(72.0f)) {
     fInitialTransform.reset();
     this->init();
 }