diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index f7e7dad3d..1bb4f1bc8 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -806,8 +806,7 @@ class PDFPageView { } const ctx = canvas.getContext("2d", { alpha: false }); - const outputScale = getOutputScale(ctx); - this.outputScale = outputScale; + const outputScale = (this.outputScale = getOutputScale()); if (this.useOnlyCssZoom) { const actualSizeViewport = viewport.clone({ @@ -844,9 +843,9 @@ class PDFPageView { this.paintedViewportMap.set(canvas, viewport); // Rendering area - const transform = !outputScale.scaled - ? null - : [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; + const transform = outputScale.scaled + ? [outputScale.sx, 0, 0, outputScale.sy, 0, 0] + : null; const renderContext = { canvasContext: ctx, transform, diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js index b2d5541fa..91895eff5 100644 --- a/web/pdf_thumbnail_view.js +++ b/web/pdf_thumbnail_view.js @@ -233,7 +233,7 @@ class PDFThumbnailView { canvas.mozOpaque = true; } const ctx = canvas.getContext("2d", { alpha: false }); - const outputScale = getOutputScale(ctx); + const outputScale = getOutputScale(); canvas.width = (upscaleFactor * this.canvasWidth * outputScale.sx) | 0; canvas.height = (upscaleFactor * this.canvasHeight * outputScale.sy) | 0; diff --git a/web/ui_utils.js b/web/ui_utils.js index 86b4bd907..64450b372 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -79,18 +79,11 @@ const AutoPrintRegExp = /\bprint\s*\(/; /** * Returns scale factor for the canvas. It makes sense for the HiDPI displays. - * @returns {Object} The object with horizontal (sx) and vertical (sy) - * scales. The scaled property is set to false if scaling is - * not required, true otherwise. + * @returns {Object} The object with horizontal (sx) and vertical (sy) scales. + * The scaled property is false if scaling is not required, true otherwise. */ -function getOutputScale(ctx) { - const devicePixelRatio = window.devicePixelRatio || 1; - const backingStoreRatio = - ctx.webkitBackingStorePixelRatio || - ctx.mozBackingStorePixelRatio || - ctx.backingStorePixelRatio || - 1; - const pixelRatio = devicePixelRatio / backingStoreRatio; +function getOutputScale() { + const pixelRatio = window.devicePixelRatio || 1; return { sx: pixelRatio, sy: pixelRatio,