mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Merge pull request #4683 from yurydelendik/grouppath
Groups path commands into single operation
This commit is contained in:
commit
a26d28a393
4 changed files with 68 additions and 24 deletions
|
@ -502,6 +502,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
return font;
|
||||
},
|
||||
|
||||
buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
|
||||
var lastIndex = operatorList.length - 1;
|
||||
if (lastIndex < 0 ||
|
||||
operatorList.fnArray[lastIndex] !== OPS.constructPath) {
|
||||
operatorList.addOp(OPS.constructPath, [[fn], args]);
|
||||
} else {
|
||||
var opArgs = operatorList.argsArray[lastIndex];
|
||||
opArgs[0].push(fn);
|
||||
Array.prototype.push.apply(opArgs[1], args);
|
||||
}
|
||||
},
|
||||
|
||||
getOperatorList: function PartialEvaluator_getOperatorList(stream,
|
||||
resources,
|
||||
operatorList,
|
||||
|
@ -525,7 +537,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
var fn = operation.fn;
|
||||
var shading;
|
||||
|
||||
switch (fn) {
|
||||
switch (fn | 0) {
|
||||
case OPS.setStrokeColorN:
|
||||
case OPS.setFillColorN:
|
||||
if (args[args.length - 1].code) {
|
||||
|
@ -668,6 +680,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
stateManager);
|
||||
args = [];
|
||||
continue;
|
||||
case OPS.moveTo:
|
||||
case OPS.lineTo:
|
||||
case OPS.curveTo:
|
||||
case OPS.curveTo2:
|
||||
case OPS.curveTo3:
|
||||
case OPS.closePath:
|
||||
self.buildPath(operatorList, fn, args);
|
||||
continue;
|
||||
}
|
||||
operatorList.addOp(fn, args);
|
||||
}
|
||||
|
@ -838,7 +858,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
textState = stateManager.state;
|
||||
var fn = operation.fn;
|
||||
var args = operation.args;
|
||||
switch (fn) {
|
||||
switch (fn | 0) {
|
||||
case OPS.setFont:
|
||||
handleSetFont(args[0].name);
|
||||
textState.fontSize = args[1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue