|
|
@ -220,8 +220,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
this.stats.enabled = !!globalScope.PDFJS.enableStats; |
|
|
|
this.stats.enabled = !!globalScope.PDFJS.enableStats; |
|
|
|
this.commonObjs = transport.commonObjs; |
|
|
|
this.commonObjs = transport.commonObjs; |
|
|
|
this.objs = new PDFObjects(); |
|
|
|
this.objs = new PDFObjects(); |
|
|
|
this.renderInProgress = false; |
|
|
|
this.receivingOperatorList = false; |
|
|
|
this.cleanupAfterRender = false; |
|
|
|
this.cleanupAfterRender = false; |
|
|
|
|
|
|
|
this.pendingDestroy = false; |
|
|
|
this.renderTasks = []; |
|
|
|
this.renderTasks = []; |
|
|
|
} |
|
|
|
} |
|
|
|
PDFPageProxy.prototype = { |
|
|
|
PDFPageProxy.prototype = { |
|
|
@ -294,15 +295,18 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* finishes rendering (see RenderTask). |
|
|
|
* finishes rendering (see RenderTask). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
render: function PDFPageProxy_render(params) { |
|
|
|
render: function PDFPageProxy_render(params) { |
|
|
|
this.renderInProgress = true; |
|
|
|
|
|
|
|
var stats = this.stats; |
|
|
|
var stats = this.stats; |
|
|
|
stats.time('Overall'); |
|
|
|
stats.time('Overall'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If there was a pending destroy cancel it so no cleanup happens during
|
|
|
|
|
|
|
|
// this call to render.
|
|
|
|
|
|
|
|
this.pendingDestroy = false; |
|
|
|
|
|
|
|
|
|
|
|
// If there is no displayReadyPromise yet, then the operatorList was never
|
|
|
|
// If there is no displayReadyPromise yet, then the operatorList was never
|
|
|
|
// requested before. Make the request and create the promise.
|
|
|
|
// requested before. Make the request and create the promise.
|
|
|
|
if (!this.displayReadyPromise) { |
|
|
|
if (!this.displayReadyPromise) { |
|
|
|
|
|
|
|
this.receivingOperatorList = true; |
|
|
|
this.displayReadyPromise = new Promise(); |
|
|
|
this.displayReadyPromise = new Promise(); |
|
|
|
this.destroyed = false; |
|
|
|
|
|
|
|
this.operatorList = { |
|
|
|
this.operatorList = { |
|
|
|
fnArray: [], |
|
|
|
fnArray: [], |
|
|
|
argsArray: [], |
|
|
|
argsArray: [], |
|
|
@ -324,7 +328,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
this.displayReadyPromise.then( |
|
|
|
this.displayReadyPromise.then( |
|
|
|
function pageDisplayReadyPromise(transparency) { |
|
|
|
function pageDisplayReadyPromise(transparency) { |
|
|
|
if (self.destroyed) { |
|
|
|
if (self.pendingDestroy) { |
|
|
|
complete(); |
|
|
|
complete(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -343,10 +347,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
self.renderTasks.splice(i, 1); |
|
|
|
self.renderTasks.splice(i, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (self.renderTasks.length === 0 && |
|
|
|
if (self.cleanupAfterRender) { |
|
|
|
(self.destroyed || self.cleanupAfterRender)) { |
|
|
|
self.pendingDestroy = true; |
|
|
|
self._destroy(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
self._tryDestroy(); |
|
|
|
|
|
|
|
|
|
|
|
if (error) { |
|
|
|
if (error) { |
|
|
|
renderTask.reject(error); |
|
|
|
renderTask.reject(error); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -389,19 +394,24 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* Destroys resources allocated by the page. |
|
|
|
* Destroys resources allocated by the page. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
destroy: function PDFPageProxy_destroy() { |
|
|
|
destroy: function PDFPageProxy_destroy() { |
|
|
|
this.destroyed = true; |
|
|
|
this.pendingDestroy = true; |
|
|
|
|
|
|
|
this._tryDestroy(); |
|
|
|
if (this.renderTasks.length === 0) { |
|
|
|
|
|
|
|
this._destroy(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* For internal use only. Does the actual cleanup. |
|
|
|
* For internal use only. Attempts to clean up if rendering is in a state |
|
|
|
|
|
|
|
* where that's possible. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
_destroy: function PDFPageProxy__destroy() { |
|
|
|
_tryDestroy: function PDFPageProxy__destroy() { |
|
|
|
|
|
|
|
if (!this.pendingDestroy || |
|
|
|
|
|
|
|
this.renderTasks.length !== 0 || |
|
|
|
|
|
|
|
this.receivingOperatorList) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete this.operatorList; |
|
|
|
delete this.operatorList; |
|
|
|
delete this.displayReadyPromise; |
|
|
|
delete this.displayReadyPromise; |
|
|
|
this.objs.clear(); |
|
|
|
this.objs.clear(); |
|
|
|
|
|
|
|
this.pendingDestroy = false; |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* For internal use only. |
|
|
|
* For internal use only. |
|
|
@ -424,6 +434,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
for (var i = 0; i < this.renderTasks.length; i++) { |
|
|
|
for (var i = 0; i < this.renderTasks.length; i++) { |
|
|
|
this.renderTasks[i].operatorListChanged(); |
|
|
|
this.renderTasks[i].operatorListChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (operatorListChunk.lastChunk) { |
|
|
|
|
|
|
|
this.receivingOperatorList = false; |
|
|
|
|
|
|
|
this._tryDestroy(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
return PDFPageProxy; |
|
|
|
return PDFPageProxy; |
|
|
|