pdf: ifgnore shader colors applied for 0 range.

R=vandebo@chromium.org

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11322 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index fa0587f..80ea2f2 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -55,6 +55,7 @@
  */
 static void interpolateColorCode(SkScalar range, SkScalar* curColor,
                                  SkScalar* prevColor, SkString* result) {
+    SkASSERT(range != SkIntToScalar(0));
     static const int kColorComponents = 3;
 
     // Figure out how to scale each color component.
@@ -152,7 +153,13 @@
     result->append(" }\n");
 
     // The gradient colors.
+    int gradients = 0;
     for (int i = 1 ; i < info.fColorCount; i++) {
+        if (info.fColorOffsets[i] == info.fColorOffsets[i - 1]) {
+            continue;
+        }
+        gradients++;
+
         result->append("{dup ");
         result->appendScalar(info.fColorOffsets[i]);
         result->append(" le {");
@@ -174,7 +181,7 @@
     result->append(" ");
     result->appendScalar(colorData[info.fColorCount - 1][2]);
 
-    for (int i = 0 ; i < info.fColorCount; i++) {
+    for (int i = 0 ; i < gradients + 1; i++) {
         result->append("} ifelse\n");
     }
 }