Merge remote-tracking branch 'upstream/master' into smaskscale
This commit is contained in:
		
						commit
						3175e5498c
					
				| @ -257,9 +257,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||||||
|       this.ctx.scale(cw / mediaBox.width, ch / mediaBox.height); |       this.ctx.scale(cw / mediaBox.width, ch / mediaBox.height); | ||||||
|       this.textDivs = []; |       this.textDivs = []; | ||||||
|       this.textLayerQueue = []; |       this.textLayerQueue = []; | ||||||
|       // Prevent textLayerQueue from being rendered while rendering a new page
 |  | ||||||
|       if (this.textLayerTimer) |  | ||||||
|         clearTimeout(this.textLayerTimer); |  | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     executeIRQueue: function canvasGraphicsExecuteIRQueue(codeIR, |     executeIRQueue: function canvasGraphicsExecuteIRQueue(codeIR, | ||||||
| @ -328,31 +325,22 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { | |||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|       var self = this; |       var self = this; | ||||||
|       var renderTextLayer = function canvasRenderTextLayer() { |       var textDivs = this.textDivs; | ||||||
|         var textDivs = self.textDivs; |       this.textLayerTimer = setInterval(function renderTextLayer() { | ||||||
|         for (var i = 0, length = textDivs.length; i < length; ++i) { |         if (textDivs.length === 0) { | ||||||
|           if (textDivs[i].dataset.textLength > 1) { // avoid div by zero
 |           clearInterval(self.textLayerTimer); | ||||||
|             textLayer.appendChild(textDivs[i]); |           return; | ||||||
|             // Adjust div width (via letterSpacing) to match canvas text
 |  | ||||||
|             // Due to the .offsetWidth calls, this is slow
 |  | ||||||
|             textDivs[i].style.letterSpacing = |  | ||||||
|               ((textDivs[i].dataset.canvasWidth - textDivs[i].offsetWidth) / |  | ||||||
|                (textDivs[i].dataset.textLength - 1)) + 'px'; |  | ||||||
|           } |  | ||||||
|         } |         } | ||||||
|       } |         var textDiv = textDivs.shift(); | ||||||
|       var textLayerQueue = this.textLayerQueue; |         if (textDiv.dataset.textLength > 1) { // avoid div by zero
 | ||||||
|       textLayerQueue.push(renderTextLayer); |           textLayer.appendChild(textDiv); | ||||||
| 
 |           // Adjust div width (via letterSpacing) to match canvas text
 | ||||||
|       // Lazy textLayer rendering (to prevent UI hangs)
 |           // Due to the .offsetWidth calls, this is slow
 | ||||||
|       // Only render queue if activity has stopped, where "no activity" ==
 |           textDiv.style.letterSpacing = | ||||||
|       // "no beginDrawing() calls in the last N ms"
 |             ((textDiv.dataset.canvasWidth - textDiv.offsetWidth) / | ||||||
|       this.textLayerTimer = setTimeout(function renderTextLayerQueue() { |               (textDiv.dataset.textLength - 1)) + 'px'; | ||||||
|         // Render most recent (==most relevant) layers first
 |  | ||||||
|         for (var i = textLayerQueue.length - 1; i >= 0; i--) { |  | ||||||
|           textLayerQueue.pop().call(); |  | ||||||
|         } |         } | ||||||
|       }, 500); |       }, 0); | ||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     // Graphics state
 |     // Graphics state
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user