|
@@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
});
|
|
});
|
|
exports.CanvasGraphics = void 0;
|
|
exports.CanvasGraphics = void 0;
|
|
|
|
|
|
-var _util = require("../shared/util.js");
|
|
|
|
-
|
|
|
|
var _display_utils = require("./display_utils.js");
|
|
var _display_utils = require("./display_utils.js");
|
|
|
|
|
|
|
|
+var _util = require("../shared/util.js");
|
|
|
|
+
|
|
var _pattern_helper = require("./pattern_helper.js");
|
|
var _pattern_helper = require("./pattern_helper.js");
|
|
|
|
|
|
var _image_utils = require("../shared/image_utils.js");
|
|
var _image_utils = require("../shared/image_utils.js");
|
|
@@ -41,10 +41,8 @@ const MAX_FONT_SIZE = 100;
|
|
const MAX_GROUP_SIZE = 4096;
|
|
const MAX_GROUP_SIZE = 4096;
|
|
const EXECUTION_TIME = 15;
|
|
const EXECUTION_TIME = 15;
|
|
const EXECUTION_STEPS = 10;
|
|
const EXECUTION_STEPS = 10;
|
|
-const COMPILE_TYPE3_GLYPHS = true;
|
|
|
|
-const MAX_SIZE_TO_COMPILE = 1000;
|
|
|
|
|
|
+const MAX_SIZE_TO_COMPILE = _is_node.isNodeJS && typeof Path2D === "undefined" ? -1 : 1000;
|
|
const FULL_CHUNK_HEIGHT = 16;
|
|
const FULL_CHUNK_HEIGHT = 16;
|
|
-const LINEWIDTH_SCALE_FACTOR = 1.000001;
|
|
|
|
|
|
|
|
function mirrorContextOperations(ctx, destCtx) {
|
|
function mirrorContextOperations(ctx, destCtx) {
|
|
if (ctx._removeMirroring) {
|
|
if (ctx._removeMirroring) {
|
|
@@ -177,147 +175,23 @@ function mirrorContextOperations(ctx, destCtx) {
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
-function addContextCurrentTransform(ctx) {
|
|
|
|
- if (ctx._transformStack) {
|
|
|
|
- ctx._transformStack = [];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (ctx.mozCurrentTransform) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ctx._originalSave = ctx.save;
|
|
|
|
- ctx._originalRestore = ctx.restore;
|
|
|
|
- ctx._originalRotate = ctx.rotate;
|
|
|
|
- ctx._originalScale = ctx.scale;
|
|
|
|
- ctx._originalTranslate = ctx.translate;
|
|
|
|
- ctx._originalTransform = ctx.transform;
|
|
|
|
- ctx._originalSetTransform = ctx.setTransform;
|
|
|
|
- ctx._originalResetTransform = ctx.resetTransform;
|
|
|
|
- ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
|
|
|
|
- ctx._transformStack = [];
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- const desc = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(ctx), "lineWidth");
|
|
|
|
- ctx._setLineWidth = desc.set;
|
|
|
|
- ctx._getLineWidth = desc.get;
|
|
|
|
- Object.defineProperty(ctx, "lineWidth", {
|
|
|
|
- set: function setLineWidth(width) {
|
|
|
|
- this._setLineWidth(width * LINEWIDTH_SCALE_FACTOR);
|
|
|
|
- },
|
|
|
|
- get: function getLineWidth() {
|
|
|
|
- return this._getLineWidth();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } catch (_) {}
|
|
|
|
-
|
|
|
|
- Object.defineProperty(ctx, "mozCurrentTransform", {
|
|
|
|
- get: function getCurrentTransform() {
|
|
|
|
- return this._transformMatrix;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- Object.defineProperty(ctx, "mozCurrentTransformInverse", {
|
|
|
|
- get: function getCurrentTransformInverse() {
|
|
|
|
- const [a, b, c, d, e, f] = this._transformMatrix;
|
|
|
|
- const ad_bc = a * d - b * c;
|
|
|
|
- const bc_ad = b * c - a * d;
|
|
|
|
- return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc];
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- ctx.save = function ctxSave() {
|
|
|
|
- const old = this._transformMatrix;
|
|
|
|
-
|
|
|
|
- this._transformStack.push(old);
|
|
|
|
-
|
|
|
|
- this._transformMatrix = old.slice(0, 6);
|
|
|
|
-
|
|
|
|
- this._originalSave();
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.restore = function ctxRestore() {
|
|
|
|
- if (this._transformStack.length === 0) {
|
|
|
|
- (0, _util.warn)("Tried to restore a ctx when the stack was already empty.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const prev = this._transformStack.pop();
|
|
|
|
-
|
|
|
|
- if (prev) {
|
|
|
|
- this._transformMatrix = prev;
|
|
|
|
-
|
|
|
|
- this._originalRestore();
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.translate = function ctxTranslate(x, y) {
|
|
|
|
- const m = this._transformMatrix;
|
|
|
|
- m[4] = m[0] * x + m[2] * y + m[4];
|
|
|
|
- m[5] = m[1] * x + m[3] * y + m[5];
|
|
|
|
-
|
|
|
|
- this._originalTranslate(x, y);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.scale = function ctxScale(x, y) {
|
|
|
|
- const m = this._transformMatrix;
|
|
|
|
- m[0] *= x;
|
|
|
|
- m[1] *= x;
|
|
|
|
- m[2] *= y;
|
|
|
|
- m[3] *= y;
|
|
|
|
-
|
|
|
|
- this._originalScale(x, y);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.transform = function ctxTransform(a, b, c, d, e, f) {
|
|
|
|
- const m = this._transformMatrix;
|
|
|
|
- this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]];
|
|
|
|
-
|
|
|
|
- ctx._originalTransform(a, b, c, d, e, f);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
|
|
|
|
- this._transformMatrix = [a, b, c, d, e, f];
|
|
|
|
-
|
|
|
|
- ctx._originalSetTransform(a, b, c, d, e, f);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.resetTransform = function ctxResetTransform() {
|
|
|
|
- this._transformMatrix = [1, 0, 0, 1, 0, 0];
|
|
|
|
-
|
|
|
|
- ctx._originalResetTransform();
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- ctx.rotate = function ctxRotate(angle) {
|
|
|
|
- const cosValue = Math.cos(angle);
|
|
|
|
- const sinValue = Math.sin(angle);
|
|
|
|
- const m = this._transformMatrix;
|
|
|
|
- this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]];
|
|
|
|
-
|
|
|
|
- this._originalRotate(angle);
|
|
|
|
- };
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
class CachedCanvases {
|
|
class CachedCanvases {
|
|
constructor(canvasFactory) {
|
|
constructor(canvasFactory) {
|
|
this.canvasFactory = canvasFactory;
|
|
this.canvasFactory = canvasFactory;
|
|
this.cache = Object.create(null);
|
|
this.cache = Object.create(null);
|
|
}
|
|
}
|
|
|
|
|
|
- getCanvas(id, width, height, trackTransform) {
|
|
|
|
|
|
+ getCanvas(id, width, height) {
|
|
let canvasEntry;
|
|
let canvasEntry;
|
|
|
|
|
|
if (this.cache[id] !== undefined) {
|
|
if (this.cache[id] !== undefined) {
|
|
canvasEntry = this.cache[id];
|
|
canvasEntry = this.cache[id];
|
|
this.canvasFactory.reset(canvasEntry, width, height);
|
|
this.canvasFactory.reset(canvasEntry, width, height);
|
|
- canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
|
|
|
|
} else {
|
|
} else {
|
|
canvasEntry = this.canvasFactory.create(width, height);
|
|
canvasEntry = this.canvasFactory.create(width, height);
|
|
this.cache[id] = canvasEntry;
|
|
this.cache[id] = canvasEntry;
|
|
}
|
|
}
|
|
|
|
|
|
- if (trackTransform) {
|
|
|
|
- addContextCurrentTransform(canvasEntry.context);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
return canvasEntry;
|
|
return canvasEntry;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -336,7 +210,7 @@ class CachedCanvases {
|
|
}
|
|
}
|
|
|
|
|
|
function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
|
|
function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
|
|
- const [a, b, c, d, tx, ty] = ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const [a, b, c, d, tx, ty] = (0, _display_utils.getCurrentTransform)(ctx);
|
|
|
|
|
|
if (b === 0 && c === 0) {
|
|
if (b === 0 && c === 0) {
|
|
const tlX = destX * a + tx;
|
|
const tlX = destX * a + tx;
|
|
@@ -380,7 +254,7 @@ function compileType3Glyph(imgData) {
|
|
height
|
|
height
|
|
} = imgData;
|
|
} = imgData;
|
|
|
|
|
|
- if (!COMPILE_TYPE3_GLYPHS || width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
|
|
|
|
+ if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -483,13 +357,7 @@ function compileType3Glyph(imgData) {
|
|
}
|
|
}
|
|
|
|
|
|
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
- let path, outlines, coords;
|
|
|
|
-
|
|
|
|
- if (!_is_node.isNodeJS) {
|
|
|
|
- path = new Path2D();
|
|
|
|
- } else {
|
|
|
|
- outlines = [];
|
|
|
|
- }
|
|
|
|
|
|
+ const path = new Path2D();
|
|
|
|
|
|
for (i = 0; count && i <= height; i++) {
|
|
for (i = 0; count && i <= height; i++) {
|
|
let p = i * width1;
|
|
let p = i * width1;
|
|
@@ -503,12 +371,7 @@ function compileType3Glyph(imgData) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if (path) {
|
|
|
|
- path.moveTo(p % width1, i);
|
|
|
|
- } else {
|
|
|
|
- coords = [p % width1, i];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ path.moveTo(p % width1, i);
|
|
const p0 = p;
|
|
const p0 = p;
|
|
let type = points[p];
|
|
let type = points[p];
|
|
|
|
|
|
@@ -529,21 +392,13 @@ function compileType3Glyph(imgData) {
|
|
points[p] &= type >> 2 | type << 2;
|
|
points[p] &= type >> 2 | type << 2;
|
|
}
|
|
}
|
|
|
|
|
|
- if (path) {
|
|
|
|
- path.lineTo(p % width1, p / width1 | 0);
|
|
|
|
- } else {
|
|
|
|
- coords.push(p % width1, p / width1 | 0);
|
|
|
|
- }
|
|
|
|
|
|
+ path.lineTo(p % width1, p / width1 | 0);
|
|
|
|
|
|
if (!points[p]) {
|
|
if (!points[p]) {
|
|
--count;
|
|
--count;
|
|
}
|
|
}
|
|
} while (p0 !== p);
|
|
} while (p0 !== p);
|
|
|
|
|
|
- if (!path) {
|
|
|
|
- outlines.push(coords);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
--i;
|
|
--i;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -554,23 +409,7 @@ function compileType3Glyph(imgData) {
|
|
c.save();
|
|
c.save();
|
|
c.scale(1 / width, -1 / height);
|
|
c.scale(1 / width, -1 / height);
|
|
c.translate(0, -height);
|
|
c.translate(0, -height);
|
|
-
|
|
|
|
- if (path) {
|
|
|
|
- c.fill(path);
|
|
|
|
- } else {
|
|
|
|
- c.beginPath();
|
|
|
|
-
|
|
|
|
- for (const o of outlines) {
|
|
|
|
- c.moveTo(o[0], o[1]);
|
|
|
|
-
|
|
|
|
- for (let l = 2, ll = o.length; l < ll; l += 2) {
|
|
|
|
- c.lineTo(o[l], o[l + 1]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- c.fill();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ c.fill(path);
|
|
c.beginPath();
|
|
c.beginPath();
|
|
c.restore();
|
|
c.restore();
|
|
};
|
|
};
|
|
@@ -1097,11 +936,6 @@ class CanvasGraphics {
|
|
this.outputScaleY = 1;
|
|
this.outputScaleY = 1;
|
|
this.backgroundColor = pageColors?.background || null;
|
|
this.backgroundColor = pageColors?.background || null;
|
|
this.foregroundColor = pageColors?.foreground || null;
|
|
this.foregroundColor = pageColors?.foreground || null;
|
|
-
|
|
|
|
- if (canvasCtx) {
|
|
|
|
- addContextCurrentTransform(canvasCtx);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
this._cachedScaleForStroking = null;
|
|
this._cachedScaleForStroking = null;
|
|
this._cachedGetSinglePixelWidth = null;
|
|
this._cachedGetSinglePixelWidth = null;
|
|
this._cachedBitmapsMap = new Map();
|
|
this._cachedBitmapsMap = new Map();
|
|
@@ -1161,28 +995,29 @@ class CanvasGraphics {
|
|
this.ctx.restore();
|
|
this.ctx.restore();
|
|
|
|
|
|
if (transparency) {
|
|
if (transparency) {
|
|
- const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
|
|
|
|
|
|
+ const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height);
|
|
this.compositeCtx = this.ctx;
|
|
this.compositeCtx = this.ctx;
|
|
this.transparentCanvas = transparentCanvas.canvas;
|
|
this.transparentCanvas = transparentCanvas.canvas;
|
|
this.ctx = transparentCanvas.context;
|
|
this.ctx = transparentCanvas.context;
|
|
this.ctx.save();
|
|
this.ctx.save();
|
|
- this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
|
|
|
|
|
|
+ this.ctx.transform(...(0, _display_utils.getCurrentTransform)(this.compositeCtx));
|
|
}
|
|
}
|
|
|
|
|
|
this.ctx.save();
|
|
this.ctx.save();
|
|
resetCtxToDefault(this.ctx, this.foregroundColor);
|
|
resetCtxToDefault(this.ctx, this.foregroundColor);
|
|
|
|
|
|
if (transform) {
|
|
if (transform) {
|
|
- this.ctx.transform.apply(this.ctx, transform);
|
|
|
|
|
|
+ this.ctx.transform(...transform);
|
|
this.outputScaleX = transform[0];
|
|
this.outputScaleX = transform[0];
|
|
this.outputScaleY = transform[0];
|
|
this.outputScaleY = transform[0];
|
|
}
|
|
}
|
|
|
|
|
|
- this.ctx.transform.apply(this.ctx, viewport.transform);
|
|
|
|
|
|
+ this.ctx.transform(...viewport.transform);
|
|
this.viewportScale = viewport.scale;
|
|
this.viewportScale = viewport.scale;
|
|
- this.baseTransform = this.ctx.mozCurrentTransform.slice();
|
|
|
|
|
|
+ this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
|
|
|
|
if (this.imageLayer) {
|
|
if (this.imageLayer) {
|
|
|
|
+ (0, _display_utils.deprecated)("The `imageLayer` functionality will be removed in the future.");
|
|
this.imageLayer.beginLayout();
|
|
this.imageLayer.beginLayout();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1305,7 +1140,7 @@ class CanvasGraphics {
|
|
heightScale /= paintHeight / newHeight;
|
|
heightScale /= paintHeight / newHeight;
|
|
}
|
|
}
|
|
|
|
|
|
- tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight, false);
|
|
|
|
|
|
+ tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
|
|
tmpCtx = tmpCanvas.context;
|
|
tmpCtx = tmpCanvas.context;
|
|
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
|
tmpCtx.clearRect(0, 0, newWidth, newHeight);
|
|
tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
|
|
tmpCtx.drawImage(img, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
|
|
@@ -1330,7 +1165,7 @@ class CanvasGraphics {
|
|
} = img;
|
|
} = img;
|
|
const fillColor = this.current.fillColor;
|
|
const fillColor = this.current.fillColor;
|
|
const isPatternFill = this.current.patternFill;
|
|
const isPatternFill = this.current.patternFill;
|
|
- const currentTransform = ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
|
|
let cache, cacheKey, scaled, maskCanvas;
|
|
let cache, cacheKey, scaled, maskCanvas;
|
|
|
|
|
|
if ((img.bitmap || img.data) && img.count > 1) {
|
|
if ((img.bitmap || img.data) && img.count > 1) {
|
|
@@ -1361,7 +1196,7 @@ class CanvasGraphics {
|
|
}
|
|
}
|
|
|
|
|
|
if (!scaled) {
|
|
if (!scaled) {
|
|
- maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height, false);
|
|
|
|
|
|
+ maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
|
putBinaryImageMask(maskCanvas.context, img);
|
|
putBinaryImageMask(maskCanvas.context, img);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1377,15 +1212,15 @@ class CanvasGraphics {
|
|
|
|
|
|
const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
|
|
const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
|
|
const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
|
|
const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
|
|
- const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight, true);
|
|
|
|
|
|
+ const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight);
|
|
const fillCtx = fillCanvas.context;
|
|
const fillCtx = fillCanvas.context;
|
|
const offsetX = Math.min(cord1[0], cord2[0]);
|
|
const offsetX = Math.min(cord1[0], cord2[0]);
|
|
const offsetY = Math.min(cord1[1], cord2[1]);
|
|
const offsetY = Math.min(cord1[1], cord2[1]);
|
|
fillCtx.translate(-offsetX, -offsetY);
|
|
fillCtx.translate(-offsetX, -offsetY);
|
|
- fillCtx.transform.apply(fillCtx, maskToCanvas);
|
|
|
|
|
|
+ fillCtx.transform(...maskToCanvas);
|
|
|
|
|
|
if (!scaled) {
|
|
if (!scaled) {
|
|
- scaled = this._scaleImage(maskCanvas.canvas, fillCtx.mozCurrentTransformInverse);
|
|
|
|
|
|
+ scaled = this._scaleImage(maskCanvas.canvas, (0, _display_utils.getCurrentTransformInverse)(fillCtx));
|
|
scaled = scaled.img;
|
|
scaled = scaled.img;
|
|
|
|
|
|
if (cache && isPatternFill) {
|
|
if (cache && isPatternFill) {
|
|
@@ -1393,11 +1228,11 @@ class CanvasGraphics {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled(fillCtx.mozCurrentTransform, img.interpolate);
|
|
|
|
|
|
+ fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(fillCtx), img.interpolate);
|
|
drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
|
|
drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
|
|
fillCtx.globalCompositeOperation = "source-in";
|
|
fillCtx.globalCompositeOperation = "source-in";
|
|
|
|
|
|
- const inverse = _util.Util.transform(fillCtx.mozCurrentTransformInverse, [1, 0, 0, 1, -offsetX, -offsetY]);
|
|
|
|
|
|
+ const inverse = _util.Util.transform((0, _display_utils.getCurrentTransformInverse)(fillCtx), [1, 0, 0, 1, -offsetX, -offsetY]);
|
|
|
|
|
|
fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, _pattern_helper.PathType.FILL) : fillColor;
|
|
fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, _pattern_helper.PathType.FILL) : fillColor;
|
|
fillCtx.fillRect(0, 0, width, height);
|
|
fillCtx.fillRect(0, 0, width, height);
|
|
@@ -1534,11 +1369,11 @@ class CanvasGraphics {
|
|
const drawnWidth = this.ctx.canvas.width;
|
|
const drawnWidth = this.ctx.canvas.width;
|
|
const drawnHeight = this.ctx.canvas.height;
|
|
const drawnHeight = this.ctx.canvas.height;
|
|
const cacheId = "smaskGroupAt" + this.groupLevel;
|
|
const cacheId = "smaskGroupAt" + this.groupLevel;
|
|
- const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
|
|
|
|
|
+ const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
|
|
this.suspendedCtx = this.ctx;
|
|
this.suspendedCtx = this.ctx;
|
|
this.ctx = scratchCanvas.context;
|
|
this.ctx = scratchCanvas.context;
|
|
const ctx = this.ctx;
|
|
const ctx = this.ctx;
|
|
- ctx.setTransform.apply(ctx, this.suspendedCtx.mozCurrentTransform);
|
|
|
|
|
|
+ ctx.setTransform(...(0, _display_utils.getCurrentTransform)(this.suspendedCtx));
|
|
copyCtxState(this.suspendedCtx, ctx);
|
|
copyCtxState(this.suspendedCtx, ctx);
|
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
|
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
|
@@ -1626,7 +1461,7 @@ class CanvasGraphics {
|
|
let x = current.x,
|
|
let x = current.x,
|
|
y = current.y;
|
|
y = current.y;
|
|
let startX, startY;
|
|
let startX, startY;
|
|
- const currentTransform = ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
|
|
const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
|
|
const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
|
|
const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
|
|
const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
|
|
|
|
|
|
@@ -1734,7 +1569,7 @@ class CanvasGraphics {
|
|
if (this.contentVisible) {
|
|
if (this.contentVisible) {
|
|
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
|
|
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.strokeStyle = strokeColor.getPattern(ctx, this, ctx.mozCurrentTransformInverse, _pattern_helper.PathType.STROKE);
|
|
|
|
|
|
+ ctx.strokeStyle = strokeColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.STROKE);
|
|
this.rescaleAndStroke(false);
|
|
this.rescaleAndStroke(false);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
} else {
|
|
} else {
|
|
@@ -1763,7 +1598,7 @@ class CanvasGraphics {
|
|
|
|
|
|
if (isPatternFill) {
|
|
if (isPatternFill) {
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.fillStyle = fillColor.getPattern(ctx, this, ctx.mozCurrentTransformInverse, _pattern_helper.PathType.FILL);
|
|
|
|
|
|
+ ctx.fillStyle = fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
|
|
needRestore = true;
|
|
needRestore = true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1846,7 +1681,7 @@ class CanvasGraphics {
|
|
ctx.beginPath();
|
|
ctx.beginPath();
|
|
|
|
|
|
for (const path of paths) {
|
|
for (const path of paths) {
|
|
- ctx.setTransform.apply(ctx, path.transform);
|
|
|
|
|
|
+ ctx.setTransform(...path.transform);
|
|
ctx.translate(path.x, path.y);
|
|
ctx.translate(path.x, path.y);
|
|
path.addToPath(ctx, path.fontSize);
|
|
path.addToPath(ctx, path.fontSize);
|
|
}
|
|
}
|
|
@@ -1975,7 +1810,7 @@ class CanvasGraphics {
|
|
addToPath(ctx, fontSize);
|
|
addToPath(ctx, fontSize);
|
|
|
|
|
|
if (patternTransform) {
|
|
if (patternTransform) {
|
|
- ctx.setTransform.apply(ctx, patternTransform);
|
|
|
|
|
|
+ ctx.setTransform(...patternTransform);
|
|
}
|
|
}
|
|
|
|
|
|
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
|
|
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
|
|
@@ -2000,7 +1835,7 @@ class CanvasGraphics {
|
|
if (isAddToPathSet) {
|
|
if (isAddToPathSet) {
|
|
const paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
|
const paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
|
paths.push({
|
|
paths.push({
|
|
- transform: ctx.mozCurrentTransform,
|
|
|
|
|
|
+ transform: (0, _display_utils.getCurrentTransform)(ctx),
|
|
x,
|
|
x,
|
|
y,
|
|
y,
|
|
fontSize,
|
|
fontSize,
|
|
@@ -2012,7 +1847,7 @@ class CanvasGraphics {
|
|
get isFontSubpixelAAEnabled() {
|
|
get isFontSubpixelAAEnabled() {
|
|
const {
|
|
const {
|
|
context: ctx
|
|
context: ctx
|
|
- } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10, false);
|
|
|
|
|
|
+ } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
|
|
ctx.scale(1.5, 1);
|
|
ctx.scale(1.5, 1);
|
|
ctx.fillText("I", 0, 10);
|
|
ctx.fillText("I", 0, 10);
|
|
const data = ctx.getImageData(0, 0, 10, 10).data;
|
|
const data = ctx.getImageData(0, 0, 10, 10).data;
|
|
@@ -2055,7 +1890,7 @@ class CanvasGraphics {
|
|
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
|
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
|
const simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
|
const simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.transform.apply(ctx, current.textMatrix);
|
|
|
|
|
|
+ ctx.transform(...current.textMatrix);
|
|
ctx.translate(current.x, current.y + current.textRise);
|
|
ctx.translate(current.x, current.y + current.textRise);
|
|
|
|
|
|
if (fontDirection > 0) {
|
|
if (fontDirection > 0) {
|
|
@@ -2068,8 +1903,8 @@ class CanvasGraphics {
|
|
|
|
|
|
if (current.patternFill) {
|
|
if (current.patternFill) {
|
|
ctx.save();
|
|
ctx.save();
|
|
- const pattern = current.fillColor.getPattern(ctx, this, ctx.mozCurrentTransformInverse, _pattern_helper.PathType.FILL);
|
|
|
|
- patternTransform = ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const pattern = current.fillColor.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL);
|
|
|
|
+ patternTransform = (0, _display_utils.getCurrentTransform)(ctx);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
ctx.fillStyle = pattern;
|
|
ctx.fillStyle = pattern;
|
|
}
|
|
}
|
|
@@ -2199,7 +2034,7 @@ class CanvasGraphics {
|
|
this._cachedScaleForStroking = null;
|
|
this._cachedScaleForStroking = null;
|
|
this._cachedGetSinglePixelWidth = null;
|
|
this._cachedGetSinglePixelWidth = null;
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.transform.apply(ctx, current.textMatrix);
|
|
|
|
|
|
+ ctx.transform(...current.textMatrix);
|
|
ctx.translate(current.x, current.y);
|
|
ctx.translate(current.x, current.y);
|
|
ctx.scale(textHScale, fontDirection);
|
|
ctx.scale(textHScale, fontDirection);
|
|
|
|
|
|
@@ -2225,7 +2060,7 @@ class CanvasGraphics {
|
|
this.processingType3 = glyph;
|
|
this.processingType3 = glyph;
|
|
this.save();
|
|
this.save();
|
|
ctx.scale(fontSize, fontSize);
|
|
ctx.scale(fontSize, fontSize);
|
|
- ctx.transform.apply(ctx, fontMatrix);
|
|
|
|
|
|
+ ctx.transform(...fontMatrix);
|
|
this.executeOperatorList(operatorList);
|
|
this.executeOperatorList(operatorList);
|
|
this.restore();
|
|
this.restore();
|
|
}
|
|
}
|
|
@@ -2254,7 +2089,7 @@ class CanvasGraphics {
|
|
|
|
|
|
if (IR[0] === "TilingPattern") {
|
|
if (IR[0] === "TilingPattern") {
|
|
const color = IR[1];
|
|
const color = IR[1];
|
|
- const baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
|
|
|
|
|
|
+ const baseTransform = this.baseTransform || (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
const canvasGraphicsFactory = {
|
|
const canvasGraphicsFactory = {
|
|
createCanvasGraphics: ctx => {
|
|
createCanvasGraphics: ctx => {
|
|
return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory);
|
|
return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory);
|
|
@@ -2319,8 +2154,8 @@ class CanvasGraphics {
|
|
|
|
|
|
const pattern = this._getPattern(objId);
|
|
const pattern = this._getPattern(objId);
|
|
|
|
|
|
- ctx.fillStyle = pattern.getPattern(ctx, this, ctx.mozCurrentTransformInverse, _pattern_helper.PathType.SHADING);
|
|
|
|
- const inv = ctx.mozCurrentTransformInverse;
|
|
|
|
|
|
+ ctx.fillStyle = pattern.getPattern(ctx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.SHADING);
|
|
|
|
+ const inv = (0, _display_utils.getCurrentTransformInverse)(ctx);
|
|
|
|
|
|
if (inv) {
|
|
if (inv) {
|
|
const canvas = ctx.canvas;
|
|
const canvas = ctx.canvas;
|
|
@@ -2365,16 +2200,16 @@ class CanvasGraphics {
|
|
this.baseTransformStack.push(this.baseTransform);
|
|
this.baseTransformStack.push(this.baseTransform);
|
|
|
|
|
|
if (Array.isArray(matrix) && matrix.length === 6) {
|
|
if (Array.isArray(matrix) && matrix.length === 6) {
|
|
- this.transform.apply(this, matrix);
|
|
|
|
|
|
+ this.transform(...matrix);
|
|
}
|
|
}
|
|
|
|
|
|
- this.baseTransform = this.ctx.mozCurrentTransform;
|
|
|
|
|
|
+ this.baseTransform = (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
|
|
|
|
if (bbox) {
|
|
if (bbox) {
|
|
const width = bbox[2] - bbox[0];
|
|
const width = bbox[2] - bbox[0];
|
|
const height = bbox[3] - bbox[1];
|
|
const height = bbox[3] - bbox[1];
|
|
this.ctx.rect(bbox[0], bbox[1], width, height);
|
|
this.ctx.rect(bbox[0], bbox[1], width, height);
|
|
- this.current.updateRectMinMax(this.ctx.mozCurrentTransform, bbox);
|
|
|
|
|
|
+ this.current.updateRectMinMax((0, _display_utils.getCurrentTransform)(this.ctx), bbox);
|
|
this.clip();
|
|
this.clip();
|
|
this.endPath();
|
|
this.endPath();
|
|
}
|
|
}
|
|
@@ -2411,17 +2246,17 @@ class CanvasGraphics {
|
|
(0, _util.warn)("Knockout groups not supported.");
|
|
(0, _util.warn)("Knockout groups not supported.");
|
|
}
|
|
}
|
|
|
|
|
|
- const currentTransform = currentCtx.mozCurrentTransform;
|
|
|
|
|
|
+ const currentTransform = (0, _display_utils.getCurrentTransform)(currentCtx);
|
|
|
|
|
|
if (group.matrix) {
|
|
if (group.matrix) {
|
|
- currentCtx.transform.apply(currentCtx, group.matrix);
|
|
|
|
|
|
+ currentCtx.transform(...group.matrix);
|
|
}
|
|
}
|
|
|
|
|
|
if (!group.bbox) {
|
|
if (!group.bbox) {
|
|
throw new Error("Bounding box is required.");
|
|
throw new Error("Bounding box is required.");
|
|
}
|
|
}
|
|
|
|
|
|
- let bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
|
|
|
|
|
|
+ let bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, (0, _display_utils.getCurrentTransform)(currentCtx));
|
|
|
|
|
|
const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
|
|
const canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height];
|
|
bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
|
|
bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
|
|
@@ -2449,11 +2284,11 @@ class CanvasGraphics {
|
|
cacheId += "_smask_" + this.smaskCounter++ % 2;
|
|
cacheId += "_smask_" + this.smaskCounter++ % 2;
|
|
}
|
|
}
|
|
|
|
|
|
- const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
|
|
|
|
|
+ const scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight);
|
|
const groupCtx = scratchCanvas.context;
|
|
const groupCtx = scratchCanvas.context;
|
|
groupCtx.scale(1 / scaleX, 1 / scaleY);
|
|
groupCtx.scale(1 / scaleX, 1 / scaleY);
|
|
groupCtx.translate(-offsetX, -offsetY);
|
|
groupCtx.translate(-offsetX, -offsetY);
|
|
- groupCtx.transform.apply(groupCtx, currentTransform);
|
|
|
|
|
|
+ groupCtx.transform(...currentTransform);
|
|
|
|
|
|
if (group.smask) {
|
|
if (group.smask) {
|
|
this.smaskStack.push({
|
|
this.smaskStack.push({
|
|
@@ -2498,10 +2333,10 @@ class CanvasGraphics {
|
|
this.restore();
|
|
this.restore();
|
|
} else {
|
|
} else {
|
|
this.ctx.restore();
|
|
this.ctx.restore();
|
|
- const currentMtx = this.ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const currentMtx = (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
this.restore();
|
|
this.restore();
|
|
this.ctx.save();
|
|
this.ctx.save();
|
|
- this.ctx.setTransform.apply(this.ctx, currentMtx);
|
|
|
|
|
|
+ this.ctx.setTransform(...currentMtx);
|
|
|
|
|
|
const dirtyBox = _util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
|
|
const dirtyBox = _util.Util.getAxialAlignedBoundingBox([0, 0, groupCtx.canvas.width, groupCtx.canvas.height], currentMtx);
|
|
|
|
|
|
@@ -2518,7 +2353,7 @@ class CanvasGraphics {
|
|
this.save();
|
|
this.save();
|
|
|
|
|
|
if (this.baseTransform) {
|
|
if (this.baseTransform) {
|
|
- this.ctx.setTransform.apply(this.ctx, this.baseTransform);
|
|
|
|
|
|
+ this.ctx.setTransform(...this.baseTransform);
|
|
}
|
|
}
|
|
|
|
|
|
if (Array.isArray(rect) && rect.length === 4) {
|
|
if (Array.isArray(rect) && rect.length === 4) {
|
|
@@ -2534,7 +2369,7 @@ class CanvasGraphics {
|
|
rect[2] = width;
|
|
rect[2] = width;
|
|
rect[3] = height;
|
|
rect[3] = height;
|
|
|
|
|
|
- const [scaleX, scaleY] = _util.Util.singularValueDecompose2dScale(this.ctx.mozCurrentTransform);
|
|
|
|
|
|
+ const [scaleX, scaleY] = _util.Util.singularValueDecompose2dScale((0, _display_utils.getCurrentTransform)(this.ctx));
|
|
|
|
|
|
const {
|
|
const {
|
|
viewportScale
|
|
viewportScale
|
|
@@ -2549,7 +2384,6 @@ class CanvasGraphics {
|
|
this.annotationCanvasMap.set(id, canvas);
|
|
this.annotationCanvasMap.set(id, canvas);
|
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
this.ctx = context;
|
|
this.ctx = context;
|
|
- addContextCurrentTransform(this.ctx);
|
|
|
|
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
|
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
|
|
resetCtxToDefault(this.ctx, this.foregroundColor);
|
|
resetCtxToDefault(this.ctx, this.foregroundColor);
|
|
} else {
|
|
} else {
|
|
@@ -2561,8 +2395,8 @@ class CanvasGraphics {
|
|
}
|
|
}
|
|
|
|
|
|
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
|
|
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
|
|
- this.transform.apply(this, transform);
|
|
|
|
- this.transform.apply(this, matrix);
|
|
|
|
|
|
+ this.transform(...transform);
|
|
|
|
+ this.transform(...matrix);
|
|
}
|
|
}
|
|
|
|
|
|
endAnnotation() {
|
|
endAnnotation() {
|
|
@@ -2613,7 +2447,7 @@ class CanvasGraphics {
|
|
img = this.getObject(img.data, img);
|
|
img = this.getObject(img.data, img);
|
|
const ctx = this.ctx;
|
|
const ctx = this.ctx;
|
|
ctx.save();
|
|
ctx.save();
|
|
- const currentTransform = ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const currentTransform = (0, _display_utils.getCurrentTransform)(ctx);
|
|
ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
|
|
ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);
|
|
|
|
|
|
const mask = this._createMaskCanvas(img);
|
|
const mask = this._createMaskCanvas(img);
|
|
@@ -2648,17 +2482,17 @@ class CanvasGraphics {
|
|
height,
|
|
height,
|
|
transform
|
|
transform
|
|
} = image;
|
|
} = image;
|
|
- const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height, false);
|
|
|
|
|
|
+ const maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
|
const maskCtx = maskCanvas.context;
|
|
const maskCtx = maskCanvas.context;
|
|
maskCtx.save();
|
|
maskCtx.save();
|
|
const img = this.getObject(data, image);
|
|
const img = this.getObject(data, image);
|
|
putBinaryImageMask(maskCtx, img);
|
|
putBinaryImageMask(maskCtx, img);
|
|
maskCtx.globalCompositeOperation = "source-in";
|
|
maskCtx.globalCompositeOperation = "source-in";
|
|
- maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, ctx.mozCurrentTransformInverse, _pattern_helper.PathType.FILL) : fillColor;
|
|
|
|
|
|
+ maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this, (0, _display_utils.getCurrentTransformInverse)(ctx), _pattern_helper.PathType.FILL) : fillColor;
|
|
maskCtx.fillRect(0, 0, width, height);
|
|
maskCtx.fillRect(0, 0, width, height);
|
|
maskCtx.restore();
|
|
maskCtx.restore();
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.transform.apply(ctx, transform);
|
|
|
|
|
|
+ ctx.transform(...transform);
|
|
ctx.scale(1, -1);
|
|
ctx.scale(1, -1);
|
|
drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
|
drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
|
ctx.restore();
|
|
ctx.restore();
|
|
@@ -2726,23 +2560,24 @@ class CanvasGraphics {
|
|
if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
|
|
if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
|
|
imgToPaint = imgData;
|
|
imgToPaint = imgData;
|
|
} else {
|
|
} else {
|
|
- const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height, false);
|
|
|
|
|
|
+ const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
|
|
const tmpCtx = tmpCanvas.context;
|
|
const tmpCtx = tmpCanvas.context;
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
|
imgToPaint = tmpCanvas.canvas;
|
|
imgToPaint = tmpCanvas.canvas;
|
|
}
|
|
}
|
|
|
|
|
|
- const scaled = this._scaleImage(imgToPaint, ctx.mozCurrentTransformInverse);
|
|
|
|
|
|
+ const scaled = this._scaleImage(imgToPaint, (0, _display_utils.getCurrentTransformInverse)(ctx));
|
|
|
|
|
|
- ctx.imageSmoothingEnabled = getImageSmoothingEnabled(ctx.mozCurrentTransform, imgData.interpolate);
|
|
|
|
|
|
+ ctx.imageSmoothingEnabled = getImageSmoothingEnabled((0, _display_utils.getCurrentTransform)(ctx), imgData.interpolate);
|
|
const [rWidth, rHeight] = drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
|
|
const [rWidth, rHeight] = drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
|
|
|
|
|
|
if (this.imageLayer) {
|
|
if (this.imageLayer) {
|
|
- const position = this.getCanvasPosition(0, -height);
|
|
|
|
|
|
+ const [left, top] = _util.Util.applyTransform([0, -height], (0, _display_utils.getCurrentTransform)(this.ctx));
|
|
|
|
+
|
|
this.imageLayer.appendImage({
|
|
this.imageLayer.appendImage({
|
|
imgData,
|
|
imgData,
|
|
- left: position[0],
|
|
|
|
- top: position[1],
|
|
|
|
|
|
+ left,
|
|
|
|
+ top,
|
|
width: rWidth,
|
|
width: rWidth,
|
|
height: rHeight
|
|
height: rHeight
|
|
});
|
|
});
|
|
@@ -2760,23 +2595,23 @@ class CanvasGraphics {
|
|
const ctx = this.ctx;
|
|
const ctx = this.ctx;
|
|
const w = imgData.width;
|
|
const w = imgData.width;
|
|
const h = imgData.height;
|
|
const h = imgData.height;
|
|
- const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h, false);
|
|
|
|
|
|
+ const tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
|
|
const tmpCtx = tmpCanvas.context;
|
|
const tmpCtx = tmpCanvas.context;
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
|
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
|
|
|
|
|
- for (let i = 0, ii = map.length; i < ii; i++) {
|
|
|
|
- const entry = map[i];
|
|
|
|
|
|
+ for (const entry of map) {
|
|
ctx.save();
|
|
ctx.save();
|
|
- ctx.transform.apply(ctx, entry.transform);
|
|
|
|
|
|
+ ctx.transform(...entry.transform);
|
|
ctx.scale(1, -1);
|
|
ctx.scale(1, -1);
|
|
drawImageAtIntegerCoords(ctx, tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
|
|
drawImageAtIntegerCoords(ctx, tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
|
|
|
|
|
|
if (this.imageLayer) {
|
|
if (this.imageLayer) {
|
|
- const position = this.getCanvasPosition(entry.x, entry.y);
|
|
|
|
|
|
+ const [left, top] = _util.Util.applyTransform([entry.x, entry.y], (0, _display_utils.getCurrentTransform)(this.ctx));
|
|
|
|
+
|
|
this.imageLayer.appendImage({
|
|
this.imageLayer.appendImage({
|
|
imgData,
|
|
imgData,
|
|
- left: position[0],
|
|
|
|
- top: position[1],
|
|
|
|
|
|
+ left,
|
|
|
|
+ top,
|
|
width: w,
|
|
width: w,
|
|
height: h
|
|
height: h
|
|
});
|
|
});
|
|
@@ -2861,7 +2696,7 @@ class CanvasGraphics {
|
|
|
|
|
|
getSinglePixelWidth() {
|
|
getSinglePixelWidth() {
|
|
if (!this._cachedGetSinglePixelWidth) {
|
|
if (!this._cachedGetSinglePixelWidth) {
|
|
- const m = this.ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const m = (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
|
|
|
|
if (m[1] === 0 && m[2] === 0) {
|
|
if (m[1] === 0 && m[2] === 0) {
|
|
this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
|
|
this._cachedGetSinglePixelWidth = 1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));
|
|
@@ -2881,7 +2716,7 @@ class CanvasGraphics {
|
|
const {
|
|
const {
|
|
lineWidth
|
|
lineWidth
|
|
} = this.current;
|
|
} = this.current;
|
|
- const m = this.ctx.mozCurrentTransform;
|
|
|
|
|
|
+ const m = (0, _display_utils.getCurrentTransform)(this.ctx);
|
|
let scaleX, scaleY;
|
|
let scaleX, scaleY;
|
|
|
|
|
|
if (m[1] === 0 && m[2] === 0) {
|
|
if (m[1] === 0 && m[2] === 0) {
|
|
@@ -2936,7 +2771,7 @@ class CanvasGraphics {
|
|
let savedMatrix, savedDashes, savedDashOffset;
|
|
let savedMatrix, savedDashes, savedDashOffset;
|
|
|
|
|
|
if (saveRestore) {
|
|
if (saveRestore) {
|
|
- savedMatrix = ctx.mozCurrentTransform.slice();
|
|
|
|
|
|
+ savedMatrix = (0, _display_utils.getCurrentTransform)(ctx);
|
|
savedDashes = ctx.getLineDash().slice();
|
|
savedDashes = ctx.getLineDash().slice();
|
|
savedDashOffset = ctx.lineDashOffset;
|
|
savedDashOffset = ctx.lineDashOffset;
|
|
}
|
|
}
|
|
@@ -2954,11 +2789,6 @@ class CanvasGraphics {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- getCanvasPosition(x, y) {
|
|
|
|
- const transform = this.ctx.mozCurrentTransform;
|
|
|
|
- return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
isContentVisible() {
|
|
isContentVisible() {
|
|
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
|
|
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
|
|
if (!this.markedContentStack[i].visible) {
|
|
if (!this.markedContentStack[i].visible) {
|