[PDF] Restrict scalars to the range that PDF understands.

* Add a config flag to ignore the restrictions
* Apply restriction to both SkPDFScalar and scalars used in content streams.
* +/- 32,767 for the integer part.
* +/1 1/65536 for the fraction part.

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

git-svn-id: http://skia.googlecode.com/svn/trunk@882 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 6d33a01..6feab51 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -122,6 +122,24 @@
     realHalf->unref();  // SkRefPtr and new both took a reference.
     CheckObjectOutput(reporter, realHalf.get(), "0.5", true);
 
+    SkRefPtr<SkPDFScalar> bigScalar = new SkPDFScalar(110999.75);
+    bigScalar->unref();  // SkRefPtr and new both took a reference.
+#if defined(SK_SCALAR_IS_FIXED) || !defined(SK_ALLOW_LARGE_PDF_SCALARS)
+    CheckObjectOutput(reporter, bigScalar.get(), "111000", true);
+#else
+    CheckObjectOutput(reporter, bigScalar.get(), "110999.75", true);
+#endif
+
+#if defined(SK_SCALAR_IS_FLOAT) && defined(SK_ALLOW_LARGE_PDF_SCALARS)
+    SkRefPtr<SkPDFScalar> biggerScalar = new SkPDFScalar(50000000.1);
+    biggerScalar->unref();  // SkRefPtr and new both took a reference.
+    CheckObjectOutput(reporter, biggerScalar.get(), "50000000", true);
+
+    SkRefPtr<SkPDFScalar> smallestScalar = new SkPDFScalar(1.0/65536);
+    smallestScalar->unref();  // SkRefPtr and new both took a reference.
+    CheckObjectOutput(reporter, smallestScalar.get(), "0.00001526", true);
+#endif
+
     SkRefPtr<SkPDFString> stringSimple = new SkPDFString("test ) string ( foo");
     stringSimple->unref();  // SkRefPtr and new both took a reference.
     CheckObjectOutput(reporter, stringSimple.get(), "(test \\) string \\( foo)",