Skip to content

Commit 90d4b9c

Browse files
authored
Merge pull request #17868 from calixteman/interpolate_flag
Always enable smoothing when rendering downscaled image
2 parents d1f494d + b511878 commit 90d4b9c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/display/canvas.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,14 @@ function composeSMask(ctx, smask, layerCtx, layerBox) {
913913
}
914914

915915
function getImageSmoothingEnabled(transform, interpolate) {
916+
// In section 8.9.5.3 of the PDF spec, it's mentioned that the interpolate
917+
// flag should be used when the image is upscaled.
918+
// In Firefox, smoothing is always used when downscaling images (bug 1360415).
919+
920+
if (interpolate) {
921+
return true;
922+
}
923+
916924
const scale = Util.singularValueDecompose2dScale(transform);
917925
// Round to a 32bit float so that `<=` check below will pass for numbers that
918926
// are very close, but not exactly the same 64bit floats.
@@ -921,15 +929,7 @@ function getImageSmoothingEnabled(transform, interpolate) {
921929
const actualScale = Math.fround(
922930
(globalThis.devicePixelRatio || 1) * PixelsPerInch.PDF_TO_CSS_UNITS
923931
);
924-
if (interpolate !== undefined) {
925-
// If the value is explicitly set use it.
926-
return interpolate;
927-
} else if (scale[0] <= actualScale || scale[1] <= actualScale) {
928-
// Smooth when downscaling.
929-
return true;
930-
}
931-
// Don't smooth when upscaling.
932-
return false;
932+
return scale[0] <= actualScale && scale[1] <= actualScale;
933933
}
934934

935935
const LINE_CAP_STYLES = ["butt", "round", "square"];

0 commit comments

Comments
 (0)