Merge pull request #857 from jviereck/hotcmds
Only check execution time on some commands
This commit is contained in:
commit
3b112edd91
@ -195,6 +195,35 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var EO_CLIP = {};
|
var EO_CLIP = {};
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
|
slowCommands: {
|
||||||
|
'stroke': true,
|
||||||
|
'closeStroke': true,
|
||||||
|
'fill': true,
|
||||||
|
'eoFill': true,
|
||||||
|
'fillStroke': true,
|
||||||
|
'eoFillStroke': true,
|
||||||
|
'closeFillStroke': true,
|
||||||
|
'closeEOFillStroke': true,
|
||||||
|
'showText': true,
|
||||||
|
'showSpacedText': true,
|
||||||
|
'setStrokeColorSpace': true,
|
||||||
|
'setFillColorSpace': true,
|
||||||
|
'setStrokeColor': true,
|
||||||
|
'setStrokeColorN': true,
|
||||||
|
'setFillColor': true,
|
||||||
|
'setFillColorN_IR': true,
|
||||||
|
'setStrokeGray': true,
|
||||||
|
'setFillGray': true,
|
||||||
|
'setStrokeRGBColor': true,
|
||||||
|
'setFillRGBColor': true,
|
||||||
|
'setStrokeCMYKColor': true,
|
||||||
|
'setFillCMYKColor': true,
|
||||||
|
'paintJpegXObject': true,
|
||||||
|
'paintImageXObject': true,
|
||||||
|
'paintImageMaskXObject': true,
|
||||||
|
'shadingFill': true
|
||||||
|
},
|
||||||
|
|
||||||
beginDrawing: function canvasGraphicsBeginDrawing(mediaBox) {
|
beginDrawing: function canvasGraphicsBeginDrawing(mediaBox) {
|
||||||
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
|
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
|
||||||
this.ctx.save();
|
this.ctx.save();
|
||||||
@ -234,13 +263,17 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var executionEndIdx;
|
var executionEndIdx;
|
||||||
var startTime = Date.now();
|
var endTime = Date.now() + kExecutionTime;
|
||||||
|
|
||||||
var objs = this.objs;
|
var objs = this.objs;
|
||||||
|
var fnName;
|
||||||
|
var slowCommands = this.slowCommands;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (fnArray[i] !== 'dependency') {
|
fnName = fnArray[i];
|
||||||
this[fnArray[i]].apply(this, argsArray[i]);
|
|
||||||
|
if (fnName !== 'dependency') {
|
||||||
|
this[fnName].apply(this, argsArray[i]);
|
||||||
} else {
|
} else {
|
||||||
var deps = argsArray[i];
|
var deps = argsArray[i];
|
||||||
for (var n = 0, nn = deps.length; n < nn; n++) {
|
for (var n = 0, nn = deps.length; n < nn; n++) {
|
||||||
@ -254,6 +287,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// If the entire IRQueue was executed, stop as were done.
|
// If the entire IRQueue was executed, stop as were done.
|
||||||
@ -264,7 +298,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
// If the execution took longer then a certain amount of time, shedule
|
// If the execution took longer then a certain amount of time, shedule
|
||||||
// to continue exeution after a short delay.
|
// to continue exeution after a short delay.
|
||||||
// However, this is only possible if a 'continueCallback' is passed in.
|
// However, this is only possible if a 'continueCallback' is passed in.
|
||||||
if (continueCallback && (Date.now() - startTime) > kExecutionTime) {
|
if (continueCallback && slowCommands[fnName] && Date.now() > endTime) {
|
||||||
setTimeout(continueCallback, 0);
|
setTimeout(continueCallback, 0);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user