mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Remove the limit used to decided if a group canvas must be upscaled or not
It fixes issues #14982 and #14724. The main problem of upscaling a canvas is that it can induces some pixelation (see issue #14724). So this patch is just removing the limit and as a side effect it fixes issue #14982. As far as I can tell, in looking different profiles (especially some memory profile) in using the Firefox profiler, I don't see any noticeable difference in term of memory use.
This commit is contained in:
parent
96ce111e0c
commit
5c771628de
4 changed files with 22 additions and 17 deletions
|
@ -45,7 +45,6 @@ import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js";
|
||||||
const MIN_FONT_SIZE = 16;
|
const MIN_FONT_SIZE = 16;
|
||||||
// Maximum font size that would be used during canvas fillText operations.
|
// Maximum font size that would be used during canvas fillText operations.
|
||||||
const MAX_FONT_SIZE = 100;
|
const MAX_FONT_SIZE = 100;
|
||||||
const MAX_GROUP_SIZE = 4096;
|
|
||||||
|
|
||||||
// Defines the time the `executeOperatorList`-method is going to be executing
|
// Defines the time the `executeOperatorList`-method is going to be executing
|
||||||
// before it stops and schedules a continue of execution.
|
// before it stops and schedules a continue of execution.
|
||||||
|
@ -2553,18 +2552,8 @@ class CanvasGraphics {
|
||||||
// too small and make the canvas at least 1x1 pixels.
|
// too small and make the canvas at least 1x1 pixels.
|
||||||
const offsetX = Math.floor(bounds[0]);
|
const offsetX = Math.floor(bounds[0]);
|
||||||
const offsetY = Math.floor(bounds[1]);
|
const offsetY = Math.floor(bounds[1]);
|
||||||
let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
|
const drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
|
||||||
let drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
|
const drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
|
||||||
let scaleX = 1,
|
|
||||||
scaleY = 1;
|
|
||||||
if (drawnWidth > MAX_GROUP_SIZE) {
|
|
||||||
scaleX = drawnWidth / MAX_GROUP_SIZE;
|
|
||||||
drawnWidth = MAX_GROUP_SIZE;
|
|
||||||
}
|
|
||||||
if (drawnHeight > MAX_GROUP_SIZE) {
|
|
||||||
scaleY = drawnHeight / MAX_GROUP_SIZE;
|
|
||||||
drawnHeight = MAX_GROUP_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
|
this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);
|
||||||
|
|
||||||
|
@ -2582,7 +2571,6 @@ class CanvasGraphics {
|
||||||
|
|
||||||
// Since we created a new canvas that is just the size of the bounding box
|
// Since we created a new canvas that is just the size of the bounding box
|
||||||
// we have to translate the group ctx.
|
// we have to translate the group ctx.
|
||||||
groupCtx.scale(1 / scaleX, 1 / scaleY);
|
|
||||||
groupCtx.translate(-offsetX, -offsetY);
|
groupCtx.translate(-offsetX, -offsetY);
|
||||||
groupCtx.transform(...currentTransform);
|
groupCtx.transform(...currentTransform);
|
||||||
|
|
||||||
|
@ -2593,8 +2581,6 @@ class CanvasGraphics {
|
||||||
context: groupCtx,
|
context: groupCtx,
|
||||||
offsetX,
|
offsetX,
|
||||||
offsetY,
|
offsetY,
|
||||||
scaleX,
|
|
||||||
scaleY,
|
|
||||||
subtype: group.smask.subtype,
|
subtype: group.smask.subtype,
|
||||||
backdrop: group.smask.backdrop,
|
backdrop: group.smask.backdrop,
|
||||||
transferMap: group.smask.transferMap || null,
|
transferMap: group.smask.transferMap || null,
|
||||||
|
@ -2605,7 +2591,6 @@ class CanvasGraphics {
|
||||||
// right location.
|
// right location.
|
||||||
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
|
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
currentCtx.translate(offsetX, offsetY);
|
currentCtx.translate(offsetX, offsetY);
|
||||||
currentCtx.scale(scaleX, scaleY);
|
|
||||||
currentCtx.save();
|
currentCtx.save();
|
||||||
}
|
}
|
||||||
// The transparency group inherits all off the current graphics state
|
// The transparency group inherits all off the current graphics state
|
||||||
|
|
2
test/pdfs/issue14724.pdf.link
Normal file
2
test/pdfs/issue14724.pdf.link
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
https://github.com/mozilla/pdf.js/files/8365628/Infographic_EAP_EN_v2.1.pdf
|
||||||
|
|
2
test/pdfs/issue14982.pdf.link
Normal file
2
test/pdfs/issue14982.pdf.link
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
https://github.com/mozilla/pdf.js/files/8829368/Tillamook-Market-Menu-04.04.22.pdf
|
||||||
|
|
|
@ -9965,5 +9965,21 @@
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue14724",
|
||||||
|
"file": "pdfs/issue14724.pdf",
|
||||||
|
"md5": "34ecf91792eb54d58e0e86f877017f71",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "issue14982",
|
||||||
|
"file": "pdfs/issue14982.pdf",
|
||||||
|
"md5": "bbd7d7f75f51a477b56b6e3f69174d06",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue