Check after each executed command if execution took too long already
This commit is contained in:
		
							parent
							
								
									5bae370a90
								
							
						
					
					
						commit
						8991cfad83
					
				| @ -64,10 +64,6 @@ var CanvasGraphics = (function canvasGraphics() { | |||||||
|   // before it stops and shedules a continue of execution.
 |   // before it stops and shedules a continue of execution.
 | ||||||
|   var kExecutionTime = 50; |   var kExecutionTime = 50; | ||||||
| 
 | 
 | ||||||
|   // Number of IR commands to execute before checking
 |  | ||||||
|   // if we execute longer then `kExecutionTime`.
 |  | ||||||
|   var kExecutionTimeCheck = 500; |  | ||||||
| 
 |  | ||||||
|   function constructor(canvasCtx, objs) { |   function constructor(canvasCtx, objs) { | ||||||
|     this.ctx = canvasCtx; |     this.ctx = canvasCtx; | ||||||
|     this.current = new CanvasExtraState(); |     this.current = new CanvasExtraState(); | ||||||
| @ -112,15 +108,17 @@ var CanvasGraphics = (function canvasGraphics() { | |||||||
|       var i = executionStartIdx || 0; |       var i = executionStartIdx || 0; | ||||||
|       var argsArrayLen = argsArray.length; |       var argsArrayLen = argsArray.length; | ||||||
| 
 | 
 | ||||||
|  |       // Sometimes the IRQueue to execute is empty.
 | ||||||
|  |       if (argsArrayLen == i) { | ||||||
|  |         return i; | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|       var executionEndIdx; |       var executionEndIdx; | ||||||
|       var startTime = Date.now(); |       var startTime = Date.now(); | ||||||
| 
 | 
 | ||||||
|       var objs = this.objs; |       var objs = this.objs; | ||||||
| 
 | 
 | ||||||
|       do { |       while (true) { | ||||||
|         executionEndIdx = Math.min(argsArrayLen, i + kExecutionTimeCheck); |  | ||||||
| 
 |  | ||||||
|         for (i; i < executionEndIdx; i++) { |  | ||||||
|         if (fnArray[i] !== 'dependency') { |         if (fnArray[i] !== 'dependency') { | ||||||
|           this[fnArray[i]].apply(this, argsArray[i]); |           this[fnArray[i]].apply(this, argsArray[i]); | ||||||
|         } else { |         } else { | ||||||
| @ -136,7 +134,7 @@ var CanvasGraphics = (function canvasGraphics() { | |||||||
|             } |             } | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|         } |         i++; | ||||||
| 
 | 
 | ||||||
|         // If the entire IRQueue was executed, stop as were done.
 |         // If the entire IRQueue was executed, stop as were done.
 | ||||||
|         if (i == argsArrayLen) { |         if (i == argsArrayLen) { | ||||||
| @ -153,7 +151,7 @@ var CanvasGraphics = (function canvasGraphics() { | |||||||
| 
 | 
 | ||||||
|         // If the IRQueue isn't executed completly yet OR the execution time
 |         // If the IRQueue isn't executed completly yet OR the execution time
 | ||||||
|         // was short enough, do another execution round.
 |         // was short enough, do another execution round.
 | ||||||
|       } while (true); |       } | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     endDrawing: function canvasGraphicsEndDrawing() { |     endDrawing: function canvasGraphicsEndDrawing() { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user