Remove WorkerPage.
This commit is contained in:
parent
65ea07a3a2
commit
452f33b328
18
pdf.js
18
pdf.js
@ -3509,10 +3509,12 @@ var Page = (function pagePage() {
|
||||
return shadow(this, 'rotate', rotate);
|
||||
},
|
||||
|
||||
startRenderingFromIRQueue: function startRenderingFromIRQueue(gfx,
|
||||
IRQueue, fonts, continuation) {
|
||||
startRenderingFromIRQueue: function startRenderingFromIRQueue(
|
||||
IRQueue, fonts) {
|
||||
var self = this;
|
||||
this.IRQueue = IRQueue;
|
||||
var gfx = new CanvasGraphics(this.ctx, this.objs);
|
||||
var continuation = this.callback;
|
||||
|
||||
var displayContinuation = function pageDisplayContinuation() {
|
||||
console.log('--display--');
|
||||
@ -3665,6 +3667,13 @@ var Page = (function pagePage() {
|
||||
links.push(link);
|
||||
}
|
||||
return links;
|
||||
},
|
||||
startRendering: function(ctx, callback, errback) {
|
||||
this.ctx = ctx;
|
||||
this.callback = callback;
|
||||
|
||||
this.startRenderingTime = Date.now();
|
||||
this.pdf.startRendering(this);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4098,7 +4107,7 @@ var PDFDoc = (function() {
|
||||
startRendering: function(page) {
|
||||
// The worker might not be ready to receive the page request yet.
|
||||
this.workerReadyPromise.then(function() {
|
||||
this.processorHandler.send('page_request', page.page.pageNumber + 1);
|
||||
this.processorHandler.send('page_request', page.pageNumber + 1);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
@ -4111,7 +4120,8 @@ var PDFDoc = (function() {
|
||||
// Add a reference to the objects such that Page can forward the reference
|
||||
// to the CanvasGraphics and so on.
|
||||
page.objs = this.objs;
|
||||
return this.pageCache[n] = new WorkerPage(this, page, this.objs);
|
||||
page.pdf = this;
|
||||
return this.pageCache[n] = page;
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
|
64
worker.js
64
worker.js
@ -4,69 +4,7 @@
|
||||
'use strict';
|
||||
|
||||
// Set this to true if you want to use workers.
|
||||
var useWorker = false;
|
||||
|
||||
var WorkerPage = (function() {
|
||||
function constructor(pdf, page, objs) {
|
||||
this.pdf = pdf;
|
||||
this.page = page;
|
||||
this.objs = objs;
|
||||
|
||||
this.ref = page.ref;
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
get width() {
|
||||
return this.page.width;
|
||||
},
|
||||
|
||||
get height() {
|
||||
return this.page.height;
|
||||
},
|
||||
|
||||
get stats() {
|
||||
return this.page.stats;
|
||||
},
|
||||
|
||||
get view() {
|
||||
return this.page.view;
|
||||
},
|
||||
|
||||
startRendering: function(ctx, callback, errback) {
|
||||
this.ctx = ctx;
|
||||
this.callback = callback;
|
||||
// TODO: Place the worker magic HERE.
|
||||
// this.page.startRendering(ctx, callback, errback);
|
||||
|
||||
this.startRenderingTime = Date.now();
|
||||
this.pdf.startRendering(this);
|
||||
},
|
||||
|
||||
startRenderingFromIRQueue: function(IRQueue, fonts) {
|
||||
var gfx = new CanvasGraphics(this.ctx, this.objs);
|
||||
|
||||
var startTime = Date.now();
|
||||
var callback = function(err) {
|
||||
var pageNum = this.page.pageNumber + 1;
|
||||
console.log('page=%d - rendering time: time=%dms',
|
||||
pageNum, Date.now() - startTime);
|
||||
console.log('page=%d - total time: time=%dms',
|
||||
pageNum, Date.now() - this.startRenderingTime);
|
||||
|
||||
if (this.callback) {
|
||||
this.callback(err);
|
||||
}
|
||||
}.bind(this);
|
||||
this.page.startRenderingFromIRQueue(gfx, IRQueue, fonts, callback);
|
||||
},
|
||||
|
||||
getLinks: function() {
|
||||
return this.page.getLinks();
|
||||
}
|
||||
};
|
||||
|
||||
return constructor;
|
||||
})();
|
||||
var useWorker = true;
|
||||
|
||||
/**
|
||||
* A PDF document and page is build up of many objects. E.g. there are objects
|
||||
|
Loading…
Reference in New Issue
Block a user