Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the limit used to decided if a group canvas must be upscaled or not #18035

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js";
const MIN_FONT_SIZE = 16;
// Maximum font size that would be used during canvas fillText operations.
const MAX_FONT_SIZE = 100;
const MAX_GROUP_SIZE = 4096;

// Defines the time the `executeOperatorList`-method is going to be executing
// before it stops and schedules a continue of execution.
Expand Down Expand Up @@ -2553,18 +2552,8 @@ class CanvasGraphics {
// too small and make the canvas at least 1x1 pixels.
const offsetX = Math.floor(bounds[0]);
const offsetY = Math.floor(bounds[1]);
let drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
let 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;
}
const drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
const drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);

this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);

Expand All @@ -2582,7 +2571,6 @@ class CanvasGraphics {

// Since we created a new canvas that is just the size of the bounding box
// we have to translate the group ctx.
groupCtx.scale(1 / scaleX, 1 / scaleY);
groupCtx.translate(-offsetX, -offsetY);
groupCtx.transform(...currentTransform);

Expand All @@ -2593,8 +2581,6 @@ class CanvasGraphics {
context: groupCtx,
offsetX,
offsetY,
scaleX,
scaleY,
subtype: group.smask.subtype,
backdrop: group.smask.backdrop,
transferMap: group.smask.transferMap || null,
Expand All @@ -2605,7 +2591,6 @@ class CanvasGraphics {
// right location.
currentCtx.setTransform(1, 0, 0, 1, 0, 0);
currentCtx.translate(offsetX, offsetY);
currentCtx.scale(scaleX, scaleY);
currentCtx.save();
}
// The transparency group inherits all off the current graphics state
Expand Down
2 changes: 2 additions & 0 deletions test/pdfs/issue14724.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/mozilla/pdf.js/files/8365628/Infographic_EAP_EN_v2.1.pdf

2 changes: 2 additions & 0 deletions test/pdfs/issue14982.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://github.com/mozilla/pdf.js/files/8829368/Tillamook-Market-Menu-04.04.22.pdf

16 changes: 16 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9965,5 +9965,21 @@
"rounds": 1,
"link": true,
"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