]> git.parisson.com Git - pdf.js.git/commitdiff
Remove WorkerPage.
author= <=>
Wed, 19 Oct 2011 19:42:33 +0000 (12:42 -0700)
committer= <=>
Wed, 19 Oct 2011 19:42:33 +0000 (12:42 -0700)
pdf.js
worker.js

diff --git a/pdf.js b/pdf.js
index e7db0ddea88b5e2b8773bf051e498eff5aa7d619..e89d2c76f1525625b5e521ad4b28859a0fc1a5db 100644 (file)
--- a/pdf.js
+++ b/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() {
index c46f722860ac8f778e58a3d492afd77b7534bfd7..5ced1169dac850198d59ec3da70066bb5ab0faa5 100644 (file)
--- a/worker.js
+++ b/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