@@ -64,10 +64,6 @@ var CanvasGraphics = (function canvasGraphics() {
64
64
// before it stops and shedules a continue of execution.
65
65
var kExecutionTime = 50 ;
66
66
67
- // Number of IR commands to execute before checking
68
- // if we execute longer then `kExecutionTime`.
69
- var kExecutionTimeCheck = 500 ;
70
-
71
67
function constructor (canvasCtx , objs ) {
72
68
this .ctx = canvasCtx ;
73
69
this .current = new CanvasExtraState ();
@@ -112,31 +108,33 @@ var CanvasGraphics = (function canvasGraphics() {
112
108
var i = executionStartIdx || 0 ;
113
109
var argsArrayLen = argsArray .length ;
114
110
111
+ // Sometimes the IRQueue to execute is empty.
112
+ if (argsArrayLen == i ) {
113
+ return i ;
114
+ }
115
+
115
116
var executionEndIdx ;
116
117
var startTime = Date .now ();
117
118
118
119
var objs = this .objs ;
119
120
120
- do {
121
- executionEndIdx = Math .min (argsArrayLen , i + kExecutionTimeCheck );
122
-
123
- for (i ; i < executionEndIdx ; i ++) {
124
- if (fnArray [i ] !== 'dependency' ) {
125
- this [fnArray [i ]].apply (this , argsArray [i ]);
126
- } else {
127
- var deps = argsArray [i ];
128
- for (var n = 0 , nn = deps .length ; n < nn ; n ++) {
129
- var depObjId = deps [n ];
130
-
131
- // If the promise isn't resolved yet, add the continueCallback
132
- // to the promise and bail out.
133
- if (!objs .isResolved (depObjId )) {
134
- objs .get (depObjId , continueCallback );
135
- return i ;
136
- }
121
+ while (true ) {
122
+ if (fnArray [i ] !== 'dependency' ) {
123
+ this [fnArray [i ]].apply (this , argsArray [i ]);
124
+ } else {
125
+ var deps = argsArray [i ];
126
+ for (var n = 0 , nn = deps .length ; n < nn ; n ++) {
127
+ var depObjId = deps [n ];
128
+
129
+ // If the promise isn't resolved yet, add the continueCallback
130
+ // to the promise and bail out.
131
+ if (!objs .isResolved (depObjId )) {
132
+ objs .get (depObjId , continueCallback );
133
+ return i ;
137
134
}
138
135
}
139
136
}
137
+ i ++;
140
138
141
139
// If the entire IRQueue was executed, stop as were done.
142
140
if (i == argsArrayLen ) {
@@ -153,7 +151,7 @@ var CanvasGraphics = (function canvasGraphics() {
153
151
154
152
// If the IRQueue isn't executed completly yet OR the execution time
155
153
// was short enough, do another execution round.
156
- } while ( true );
154
+ }
157
155
},
158
156
159
157
endDrawing : function canvasGraphicsEndDrawing () {
0 commit comments