Merge pull request #12618 from Snuffleupagus/thumbnails-render-transform
Ensure that rendering of thumbnails work correctly on HiDPI displays (issue 9820)
This commit is contained in:
commit
1bf640bb86
@ -229,7 +229,7 @@ class PDFThumbnailView {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_getPageDrawContext(noCtxScale = false) {
|
||||
_getPageDrawContext() {
|
||||
const canvas = document.createElement("canvas");
|
||||
// Keep the no-thumbnail outline visible, i.e. `data-loaded === false`,
|
||||
// until rendering/image conversion is complete, to avoid display issues.
|
||||
@ -249,10 +249,11 @@ class PDFThumbnailView {
|
||||
canvas.style.width = this.canvasWidth + "px";
|
||||
canvas.style.height = this.canvasHeight + "px";
|
||||
|
||||
if (!noCtxScale && outputScale.scaled) {
|
||||
ctx.scale(outputScale.sx, outputScale.sy);
|
||||
}
|
||||
return ctx;
|
||||
const transform = outputScale.scaled
|
||||
? [outputScale.sx, 0, 0, outputScale.sy, 0, 0]
|
||||
: null;
|
||||
|
||||
return [ctx, transform];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -333,7 +334,7 @@ class PDFThumbnailView {
|
||||
}
|
||||
};
|
||||
|
||||
const ctx = this._getPageDrawContext();
|
||||
const [ctx, transform] = this._getPageDrawContext();
|
||||
const drawViewport = this.viewport.clone({ scale: this.scale });
|
||||
const renderContinueCallback = cont => {
|
||||
if (!this.renderingQueue.isHighestPriority(this)) {
|
||||
@ -349,6 +350,7 @@ class PDFThumbnailView {
|
||||
|
||||
const renderContext = {
|
||||
canvasContext: ctx,
|
||||
transform,
|
||||
viewport: drawViewport,
|
||||
optionalContentConfigPromise: this._optionalContentConfigPromise,
|
||||
};
|
||||
@ -393,7 +395,7 @@ class PDFThumbnailView {
|
||||
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
const ctx = this._getPageDrawContext(true);
|
||||
const [ctx] = this._getPageDrawContext();
|
||||
const canvas = ctx.canvas;
|
||||
if (img.width <= 2 * canvas.width) {
|
||||
ctx.drawImage(
|
||||
|
Loading…
Reference in New Issue
Block a user