aboutsummaryrefslogtreecommitdiff
path: root/pointless
diff options
context:
space:
mode:
Diffstat (limited to 'pointless')
-rw-r--r--pointless/viewer/screen.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/pointless/viewer/screen.js b/pointless/viewer/screen.js
index 8a6891c..0c1c3ad 100644
--- a/pointless/viewer/screen.js
+++ b/pointless/viewer/screen.js
@@ -38,11 +38,28 @@ class Screen {
38 this.context.transform(1, 0, 0, 1, xOffset, 0); 38 this.context.transform(1, 0, 0, 1, xOffset, 0);
39 } 39 }
40 40
41 _makeWorkCanvas(width, height) {
42 var canvas = document.createElement("canvas");
43 canvas.width = width;
44 canvas.height = height;
45 return canvas;
46 }
47
48 _transferCanvas(source) {
49 this.context.drawImage(source, 0, 0);
50 }
51
41 _paintPage() { 52 _paintPage() {
42 var renderRatio = this.canvas.height / this.page.getViewport(1).height; 53 var renderRatio = this.canvas.height / this.page.getViewport(1).height;
43 var renderViewport = this.page.getViewport(renderRatio); 54 var renderViewport = this.page.getViewport(renderRatio);
44 var renderContext = { canvasContext: this.context, viewport: renderViewport }; 55 var workCanvas = this._makeWorkCanvas(renderViewport.width, renderViewport.height);
45 this.page.render(renderContext); 56 var workContext = workCanvas.getContext("2d");
57 var renderContext = { canvasContext: workContext, viewport: renderViewport };
58
59 var self = this;
60 this.page.render(renderContext).then(function() {
61 self._transferCanvas(workCanvas);
62 });
46 } 63 }
47 64
48 _refreshPage() { 65 _refreshPage() {