]> git.parisson.com Git - pdf.js.git/commitdiff
Add some comments + fix getColorN_IR_Pattern
authorJulian Viereck <julian.viereck@gmail.com>
Wed, 7 Sep 2011 20:42:38 +0000 (13:42 -0700)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 15 Sep 2011 15:21:23 +0000 (08:21 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 1407cd9b41d90c68c9639bccfc9f043c8679715a..7af3e6493197fd5f7f5fd6e9897d299efcff02aa 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -4234,21 +4234,22 @@ var PartialEvaluator = (function() {
                 var dict = IsStream(pattern) ? pattern.dict : pattern;
                 var typeNum = dict.get('PatternType');
 
-                // Type1 is TilingPattern, Type2 is ShadingPattern.
+                // Type1 is TilingPattern
                 if (typeNum == 1) {
                   // Create an IR of the pattern code.
                   var codeIR = this.evalRaw(pattern, xref,
                                     dict.get('Resources'), fonts);
                   
                   args = TilingPattern.getIR(codeIR, dict);
-
-                  //patternName.code = this.evalRaw(pattern, xref,
-                  //    dict.get('Resources'), fonts);
-                } else {
+                } 
+                // Type2 is ShadingPattern.
+                else if (typeNum == 2) {
                   var shading = xref.fetchIfRef(dict.get('Shading'));
                   var matrix = dict.get('Matrix');
                   var pattern = Pattern.parseShading(shading, matrix, xref, res, null /*ctx*/);
                   args = pattern.getPatternRaw();
+                } else {
+                  error("Unkown PatternType " + typeNum);
                 }
               }
             }
@@ -5277,7 +5278,7 @@ var CanvasGraphics = (function() {
         this.setStrokeColor.apply(this, arguments);
       }
     },
-    getColorN_IR_Pattern: function(IR) {
+    getColorN_IR_Pattern: function(IR, cs) {
       if (IR[0] == "TilingPatternIR") {
         // First, build the `color` var like it's done in the
         // Pattern.prototype.parse function.
@@ -5306,7 +5307,7 @@ var CanvasGraphics = (function() {
       var cs = this.current.strokeColorSpace;
 
       if (cs.name == 'Pattern') {
-        this.current.strokeColor = this.getColorN_IR_Pattern(arguments);
+        this.current.strokeColor = this.getColorN_IR_Pattern(arguments, cs);
       } else {
         this.setStrokeColor.apply(this, arguments);
       }
@@ -5333,7 +5334,7 @@ var CanvasGraphics = (function() {
       var cs = this.current.fillColorSpace;
 
       if (cs.name == 'Pattern') {
-        this.current.fillColor = this.getColorN_IR_Pattern(arguments);
+        this.current.fillColor = this.getColorN_IR_Pattern(arguments, cs);
       } else {
         this.setFillColor.apply(this, arguments);
       }