mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Tweak the QueueOptimizer
to recognize OPS.paintImageMaskXObject
operators as *repeated* when the "skew" transformation matrix elements are non-zero (issue 8078)
*First of all, I should mention that my understanding of the finer details of the `QueueOptimizer` (and its related `CanvasGraphics` methods) is somewhat limited.* Hence I'm not sure if there's actually a very good reason for *only* considering ImageMasks where the "skew" transformation matrix elements are zero as *repeated*, however simply looking at the code I just don't see why these elements cannot be non-zero as long as they are *all identical* for the ImageMasks. Furthermore, looking at the *group* case (which is what we're currently falling back to), there's no particular limitation placed upon the transformation matrix elements. While this patch obviously isn't enough to *completely* fix the issue, since there should be a visible Pattern rendered as well[1], it seem (at least to me) like enough of an improvement that submitting this is justified. With these changes the referenced PDF document will no longer hang the *entire* browser, and rendering also finishes in a *reasonable* time (< 10 seconds for me) which seem fine given the *huge* number of identical inline images present.[2] --- [1] Temporarily changing the Pattern to a solid color *does* render the correct/expected area, which suggests that the remaining problem is a pre-existing issue related to the Pattern-handling itself rather than the `QueueOptimizer` functionality. [2] The document isn't exactly rendered immediately in e.g. Adobe Reader either.
This commit is contained in:
parent
8cfdfb237a
commit
e18fa3fc45
4 changed files with 30 additions and 10 deletions
|
@ -2157,9 +2157,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
this.paintInlineImageXObject(maskCanvas.canvas);
|
||||
},
|
||||
|
||||
paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(
|
||||
paintImageMaskXObjectRepeat(
|
||||
imgData,
|
||||
scaleX,
|
||||
skewX = 0,
|
||||
skewY = 0,
|
||||
scaleY,
|
||||
positions
|
||||
) {
|
||||
|
@ -2190,7 +2192,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
var ctx = this.ctx;
|
||||
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
||||
ctx.save();
|
||||
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
|
||||
ctx.transform(
|
||||
scaleX,
|
||||
skewX,
|
||||
skewY,
|
||||
scaleY,
|
||||
positions[i],
|
||||
positions[i + 1]
|
||||
);
|
||||
ctx.scale(1, -1);
|
||||
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
||||
ctx.restore();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue