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--');
links.push(link);
}
return links;
+ },
+ startRendering: function(ctx, callback, errback) {
+ this.ctx = ctx;
+ this.callback = callback;
+
+ this.startRenderingTime = Date.now();
+ this.pdf.startRendering(this);
}
};
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));
},
// 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() {
'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