mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 12:57:20 +02:00
Compare commits
4 Commits
a45f961a1c
...
16c876569f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16c876569f | ||
|
|
8c5fb7979f | ||
|
|
ff2d95a9b6 | ||
|
|
41bed561f0 |
@ -516,7 +516,9 @@ class PartialEvaluator {
|
|||||||
// If it's a group, a new canvas will be created that is the size of the
|
// If it's a group, a new canvas will be created that is the size of the
|
||||||
// bounding box and translated to the correct position so we don't need to
|
// bounding box and translated to the correct position so we don't need to
|
||||||
// apply the bounding box to it.
|
// apply the bounding box to it.
|
||||||
const args = group ? [matrix, null] : [matrix, bbox];
|
const f32matrix = matrix && new Float32Array(matrix);
|
||||||
|
const f32bbox = (!group && bbox && new Float32Array(bbox)) || null;
|
||||||
|
const args = [f32matrix, f32bbox];
|
||||||
operatorList.addOp(OPS.paintFormXObjectBegin, args);
|
operatorList.addOp(OPS.paintFormXObjectBegin, args);
|
||||||
|
|
||||||
await this.getOperatorList({
|
await this.getOperatorList({
|
||||||
|
|||||||
@ -768,18 +768,29 @@ class OperatorList {
|
|||||||
switch (fnArray[i]) {
|
switch (fnArray[i]) {
|
||||||
case OPS.paintInlineImageXObject:
|
case OPS.paintInlineImageXObject:
|
||||||
case OPS.paintInlineImageXObjectGroup:
|
case OPS.paintInlineImageXObjectGroup:
|
||||||
case OPS.paintImageMaskXObject:
|
case OPS.paintImageMaskXObject: {
|
||||||
const arg = argsArray[i][0]; // First parameter in imgData.
|
const { bitmap, data } = argsArray[i][0]; // First parameter in imgData.
|
||||||
if (arg.data?.buffer instanceof ArrayBuffer) {
|
if (bitmap || data?.buffer) {
|
||||||
transfers.push(arg.data.buffer);
|
transfers.push(bitmap || data.buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPS.constructPath:
|
}
|
||||||
|
case OPS.constructPath: {
|
||||||
const [, [data], minMax] = argsArray[i];
|
const [, [data], minMax] = argsArray[i];
|
||||||
if (data) {
|
if (data) {
|
||||||
transfers.push(data.buffer, minMax.buffer);
|
transfers.push(data.buffer, minMax.buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case OPS.paintFormXObjectBegin:
|
||||||
|
const [matrix, bbox] = argsArray[i];
|
||||||
|
if (matrix) {
|
||||||
|
transfers.push(matrix.buffer);
|
||||||
|
}
|
||||||
|
if (bbox) {
|
||||||
|
transfers.push(bbox.buffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transfers;
|
return transfers;
|
||||||
|
|||||||
@ -339,20 +339,27 @@ class CanvasExtraState {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRectMinMax(transform, rect) {
|
updateRectMinMax([m0, m1, m2, m3, m4, m5], [r0, r1, r2, r3]) {
|
||||||
const p1 = [rect[0], rect[1]];
|
const m0r0m4 = m0 * r0 + m4;
|
||||||
Util.applyTransform(p1, transform);
|
const m0r2m4 = m0 * r2 + m4;
|
||||||
const p2 = [rect[2], rect[3]];
|
const m1r0m5 = m1 * r0 + m5;
|
||||||
Util.applyTransform(p2, transform);
|
const m1r2m5 = m1 * r2 + m5;
|
||||||
const p3 = [rect[0], rect[3]];
|
const m2r1 = m2 * r1;
|
||||||
Util.applyTransform(p3, transform);
|
const m2r3 = m2 * r3;
|
||||||
const p4 = [rect[2], rect[1]];
|
const m3r1 = m3 * r1;
|
||||||
Util.applyTransform(p4, transform);
|
const m3r3 = m3 * r3;
|
||||||
|
const a0 = m0r0m4 + m2r1;
|
||||||
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
const a1 = m0r2m4 + m2r3;
|
||||||
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
const a2 = m0r0m4 + m2r3;
|
||||||
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
const a3 = m0r2m4 + m2r1;
|
||||||
this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
|
const b0 = m1r0m5 + m3r1;
|
||||||
|
const b1 = m1r2m5 + m3r3;
|
||||||
|
const b2 = m1r0m5 + m3r3;
|
||||||
|
const b3 = m1r2m5 + m3r1;
|
||||||
|
this.minX = Math.min(this.minX, a0, a1, a2, a3);
|
||||||
|
this.maxX = Math.max(this.maxX, a0, a1, a2, a3);
|
||||||
|
this.minY = Math.min(this.minY, b0, b1, b2, b3);
|
||||||
|
this.maxY = Math.max(this.maxY, b0, b1, b2, b3);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
getPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
||||||
@ -2275,7 +2282,7 @@ class CanvasGraphics {
|
|||||||
this.baseTransform = getCurrentTransform(this.ctx);
|
this.baseTransform = getCurrentTransform(this.ctx);
|
||||||
|
|
||||||
if (bbox) {
|
if (bbox) {
|
||||||
this.current.updateRectMinMax(getCurrentTransform(this.ctx), bbox);
|
this.current.updateRectMinMax(this.baseTransform, bbox);
|
||||||
const [x0, y0, x1, y1] = bbox;
|
const [x0, y0, x1, y1] = bbox;
|
||||||
const clip = new Path2D();
|
const clip = new Path2D();
|
||||||
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user