compiled code for tiling patterns
This commit is contained in:
parent
0dcbbf6fc4
commit
157ee74940
39
pdf.js
39
pdf.js
@ -2997,12 +2997,12 @@ var Page = (function() {
|
|||||||
// Firefox error reporting from XHR callbacks.
|
// Firefox error reporting from XHR callbacks.
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
var exc = null;
|
var exc = null;
|
||||||
try {
|
// try {
|
||||||
self.display(gfx);
|
self.display(gfx);
|
||||||
stats.render = Date.now();
|
stats.render = Date.now();
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
exc = e.toString();
|
// exc = e.toString();
|
||||||
}
|
// }
|
||||||
continuation(exc);
|
continuation(exc);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -3571,6 +3571,7 @@ var PartialEvaluator = (function() {
|
|||||||
eval: function(stream, xref, resources, fonts) {
|
eval: function(stream, xref, resources, fonts) {
|
||||||
resources = xref.fetchIfRef(resources) || new Dict();
|
resources = xref.fetchIfRef(resources) || new Dict();
|
||||||
var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict();
|
var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict();
|
||||||
|
var patterns = xref.fetchIfRef(resources.get("Pattern")) || new Dict();
|
||||||
var parser = new Parser(new Lexer(stream), false);
|
var parser = new Parser(new Lexer(stream), false);
|
||||||
var args = [], argsArray = [], fnArray = [], obj;
|
var args = [], argsArray = [], fnArray = [], obj;
|
||||||
|
|
||||||
@ -3581,7 +3582,23 @@ var PartialEvaluator = (function() {
|
|||||||
assertWellFormed(fn, "Unknown command '" + cmd + "'");
|
assertWellFormed(fn, "Unknown command '" + cmd + "'");
|
||||||
// TODO figure out how to type-check vararg functions
|
// TODO figure out how to type-check vararg functions
|
||||||
|
|
||||||
if (cmd == 'Do' && !args[0].code) { // eagerly compile XForm objects
|
if ((cmd == 'SCN' || cmd == 'scn') && !args[args.length - 1].code) {
|
||||||
|
// compile tiling patterns
|
||||||
|
var patternName = args[args.length - 1];
|
||||||
|
// SCN/scn applies patterns along with normal colors
|
||||||
|
if (IsName(patternName)) {
|
||||||
|
var pattern = xref.fetchIfRef(patterns.get(patternName.name));
|
||||||
|
if (pattern) {
|
||||||
|
var dict = IsStream(pattern) ? pattern.dict : pattern;
|
||||||
|
var typeNum = dict.get("PatternType");
|
||||||
|
if (typeNum == 1) {
|
||||||
|
patternName.code = this.eval(pattern, xref,
|
||||||
|
dict.get('Resources'), fonts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (cmd == 'Do' && !args[0].code) {
|
||||||
|
// eagerly compile XForm objects
|
||||||
var name = args[0].name;
|
var name = args[0].name;
|
||||||
var xobj = xobjs.get(name);
|
var xobj = xobjs.get(name);
|
||||||
if (xobj) {
|
if (xobj) {
|
||||||
@ -3595,7 +3612,8 @@ var PartialEvaluator = (function() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ('Form' == type.name) {
|
if ('Form' == type.name) {
|
||||||
args[0].code = this.eval(xobj, xref, xobj.dict.get('Resources'), fonts);
|
args[0].code = this.eval(xobj, xref, xobj.dict.get('Resources'),
|
||||||
|
fonts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == 'Tf') { // eagerly collect all fonts
|
} else if (cmd == 'Tf') { // eagerly collect all fonts
|
||||||
@ -4984,7 +5002,8 @@ var Pattern = (function() {
|
|||||||
|
|
||||||
color = base.getRgb(color);
|
color = base.getRgb(color);
|
||||||
}
|
}
|
||||||
return new TilingPattern(pattern, dict, color, xref, ctx);
|
var code = patternName.code;
|
||||||
|
return new TilingPattern(pattern, code, dict, color, xref, ctx);
|
||||||
case 2:
|
case 2:
|
||||||
var shading = xref.fetchIfRef(dict.get('Shading'));
|
var shading = xref.fetchIfRef(dict.get('Shading'));
|
||||||
var matrix = dict.get('Matrix');
|
var matrix = dict.get('Matrix');
|
||||||
@ -5136,7 +5155,7 @@ var RadialAxialShading = (function() {
|
|||||||
var TilingPattern = (function() {
|
var TilingPattern = (function() {
|
||||||
var PAINT_TYPE_COLORED = 1, PAINT_TYPE_UNCOLORED = 2;
|
var PAINT_TYPE_COLORED = 1, PAINT_TYPE_UNCOLORED = 2;
|
||||||
|
|
||||||
function constructor(pattern, dict, color, xref, ctx) {
|
function constructor(pattern, code, dict, color, xref, ctx) {
|
||||||
function multiply(m, tm) {
|
function multiply(m, tm) {
|
||||||
var a = m[0] * tm[0] + m[1] * tm[2];
|
var a = m[0] * tm[0] + m[1] * tm[2];
|
||||||
var b = m[0] * tm[1] + m[1] * tm[3];
|
var b = m[0] * tm[1] + m[1] * tm[3];
|
||||||
@ -5214,9 +5233,7 @@ var TilingPattern = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var res = xref.fetchIfRef(dict.get('Resources'));
|
var res = xref.fetchIfRef(dict.get('Resources'));
|
||||||
if (!pattern.code)
|
graphics.execute(code, xref, res);
|
||||||
pattern.code = graphics.compile(pattern, xref, res, []);
|
|
||||||
graphics.execute(pattern.code, xref, res);
|
|
||||||
|
|
||||||
this.canvas = tmpCanvas;
|
this.canvas = tmpCanvas;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user