Remove WorkerPage.

This commit is contained in:
= 2011-10-19 12:42:33 -07:00
parent 65ea07a3a2
commit 452f33b328
2 changed files with 15 additions and 67 deletions

18
pdf.js
View File

@ -3509,10 +3509,12 @@ var Page = (function pagePage() {
return shadow(this, 'rotate', rotate); return shadow(this, 'rotate', rotate);
}, },
startRenderingFromIRQueue: function startRenderingFromIRQueue(gfx, startRenderingFromIRQueue: function startRenderingFromIRQueue(
IRQueue, fonts, continuation) { IRQueue, fonts) {
var self = this; var self = this;
this.IRQueue = IRQueue; this.IRQueue = IRQueue;
var gfx = new CanvasGraphics(this.ctx, this.objs);
var continuation = this.callback;
var displayContinuation = function pageDisplayContinuation() { var displayContinuation = function pageDisplayContinuation() {
console.log('--display--'); console.log('--display--');
@ -3665,6 +3667,13 @@ var Page = (function pagePage() {
links.push(link); links.push(link);
} }
return links; 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) { startRendering: function(page) {
// The worker might not be ready to receive the page request yet. // The worker might not be ready to receive the page request yet.
this.workerReadyPromise.then(function() { this.workerReadyPromise.then(function() {
this.processorHandler.send('page_request', page.page.pageNumber + 1); this.processorHandler.send('page_request', page.pageNumber + 1);
}.bind(this)); }.bind(this));
}, },
@ -4111,7 +4120,8 @@ var PDFDoc = (function() {
// Add a reference to the objects such that Page can forward the reference // Add a reference to the objects such that Page can forward the reference
// to the CanvasGraphics and so on. // to the CanvasGraphics and so on.
page.objs = this.objs; page.objs = this.objs;
return this.pageCache[n] = new WorkerPage(this, page, this.objs); page.pdf = this;
return this.pageCache[n] = page;
}, },
destroy: function() { destroy: function() {

View File

@ -4,69 +4,7 @@
'use strict'; 'use strict';
// Set this to true if you want to use workers. // Set this to true if you want to use workers.
var useWorker = false; var useWorker = true;
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;
})();
/** /**
* A PDF document and page is build up of many objects. E.g. there are objects * A PDF document and page is build up of many objects. E.g. there are objects