mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02:00
Compare commits
No commits in common. "6cc37c8415e937b63d21cb13e491b05bbed3fc1a" and "7eef7dfc7820648b36bd083c11d4fae867306e80" have entirely different histories.
6cc37c8415
...
7eef7dfc78
@ -728,6 +728,8 @@ class PartialEvaluator {
|
|||||||
/* forceRGBA = */ true,
|
/* forceRGBA = */ true,
|
||||||
/* isOffscreenCanvasSupported = */ false
|
/* isOffscreenCanvasSupported = */ false
|
||||||
);
|
);
|
||||||
|
operatorList.isOffscreenCanvasSupported =
|
||||||
|
this.options.isOffscreenCanvasSupported;
|
||||||
operatorList.addImageOps(
|
operatorList.addImageOps(
|
||||||
OPS.paintInlineImageXObject,
|
OPS.paintInlineImageXObject,
|
||||||
[imgData],
|
[imgData],
|
||||||
@ -2237,9 +2239,6 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OPS.setTextMatrix:
|
|
||||||
operatorList.addOp(fn, [new Float32Array(args)]);
|
|
||||||
continue;
|
|
||||||
case OPS.markPoint:
|
case OPS.markPoint:
|
||||||
case OPS.markPointProps:
|
case OPS.markPointProps:
|
||||||
case OPS.beginCompat:
|
case OPS.beginCompat:
|
||||||
|
|||||||
@ -567,12 +567,17 @@ class QueueOptimizer extends NullOptimizer {
|
|||||||
iCurr: 0,
|
iCurr: 0,
|
||||||
fnArray: queue.fnArray,
|
fnArray: queue.fnArray,
|
||||||
argsArray: queue.argsArray,
|
argsArray: queue.argsArray,
|
||||||
isOffscreenCanvasSupported: OperatorList.isOffscreenCanvasSupported,
|
isOffscreenCanvasSupported: false,
|
||||||
};
|
};
|
||||||
this.match = null;
|
this.match = null;
|
||||||
this.lastProcessed = 0;
|
this.lastProcessed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line accessor-pairs
|
||||||
|
set isOffscreenCanvasSupported(value) {
|
||||||
|
this.context.isOffscreenCanvasSupported = value;
|
||||||
|
}
|
||||||
|
|
||||||
_optimize() {
|
_optimize() {
|
||||||
// Process new fnArray item(s) chunk.
|
// Process new fnArray item(s) chunk.
|
||||||
const fnArray = this.queue.fnArray;
|
const fnArray = this.queue.fnArray;
|
||||||
@ -651,8 +656,6 @@ class OperatorList {
|
|||||||
// Close to chunk size.
|
// Close to chunk size.
|
||||||
static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
|
static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
|
||||||
|
|
||||||
static isOffscreenCanvasSupported = false;
|
|
||||||
|
|
||||||
constructor(intent = 0, streamSink) {
|
constructor(intent = 0, streamSink) {
|
||||||
this._streamSink = streamSink;
|
this._streamSink = streamSink;
|
||||||
this.fnArray = [];
|
this.fnArray = [];
|
||||||
@ -667,8 +670,9 @@ class OperatorList {
|
|||||||
this._resolved = streamSink ? null : Promise.resolve();
|
this._resolved = streamSink ? null : Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
static setOptions({ isOffscreenCanvasSupported }) {
|
// eslint-disable-next-line accessor-pairs
|
||||||
this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
|
set isOffscreenCanvasSupported(value) {
|
||||||
|
this.optimizer.isOffscreenCanvasSupported = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get length() {
|
get length() {
|
||||||
@ -787,9 +791,6 @@ class OperatorList {
|
|||||||
transfers.push(bbox.buffer);
|
transfers.push(bbox.buffer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OPS.setTextMatrix:
|
|
||||||
transfers.push(argsArray[i][0].buffer);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transfers;
|
return transfers;
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import { ImageResizer } from "./image_resizer.js";
|
|||||||
import { JpegStream } from "./jpeg_stream.js";
|
import { JpegStream } from "./jpeg_stream.js";
|
||||||
import { JpxImage } from "./jpx.js";
|
import { JpxImage } from "./jpx.js";
|
||||||
import { MissingDataException } from "./core_utils.js";
|
import { MissingDataException } from "./core_utils.js";
|
||||||
import { OperatorList } from "./operator_list.js";
|
|
||||||
import { PDFDocument } from "./document.js";
|
import { PDFDocument } from "./document.js";
|
||||||
import { Stream } from "./stream.js";
|
import { Stream } from "./stream.js";
|
||||||
|
|
||||||
@ -75,7 +74,6 @@ class BasePdfManager {
|
|||||||
// Initialize image-options once per document.
|
// Initialize image-options once per document.
|
||||||
ImageResizer.setOptions(evaluatorOptions);
|
ImageResizer.setOptions(evaluatorOptions);
|
||||||
JpegStream.setOptions(evaluatorOptions);
|
JpegStream.setOptions(evaluatorOptions);
|
||||||
OperatorList.setOptions(evaluatorOptions);
|
|
||||||
|
|
||||||
const options = { ...evaluatorOptions, handler };
|
const options = { ...evaluatorOptions, handler };
|
||||||
JpxImage.setOptions(options);
|
JpxImage.setOptions(options);
|
||||||
|
|||||||
@ -17,8 +17,10 @@ import {
|
|||||||
DrawOPS,
|
DrawOPS,
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
FONT_IDENTITY_MATRIX,
|
FONT_IDENTITY_MATRIX,
|
||||||
|
IDENTITY_MATRIX,
|
||||||
ImageKind,
|
ImageKind,
|
||||||
info,
|
info,
|
||||||
|
isNodeJS,
|
||||||
OPS,
|
OPS,
|
||||||
shadow,
|
shadow,
|
||||||
TextRenderingMode,
|
TextRenderingMode,
|
||||||
@ -123,47 +125,47 @@ function mirrorContextOperations(ctx, destCtx) {
|
|||||||
delete ctx._removeMirroring;
|
delete ctx._removeMirroring;
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.save = function () {
|
ctx.save = function ctxSave() {
|
||||||
destCtx.save();
|
destCtx.save();
|
||||||
this.__originalSave();
|
this.__originalSave();
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.restore = function () {
|
ctx.restore = function ctxRestore() {
|
||||||
destCtx.restore();
|
destCtx.restore();
|
||||||
this.__originalRestore();
|
this.__originalRestore();
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.translate = function (x, y) {
|
ctx.translate = function ctxTranslate(x, y) {
|
||||||
destCtx.translate(x, y);
|
destCtx.translate(x, y);
|
||||||
this.__originalTranslate(x, y);
|
this.__originalTranslate(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.scale = function (x, y) {
|
ctx.scale = function ctxScale(x, y) {
|
||||||
destCtx.scale(x, y);
|
destCtx.scale(x, y);
|
||||||
this.__originalScale(x, y);
|
this.__originalScale(x, y);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.transform = function (a, b, c, d, e, f) {
|
ctx.transform = function ctxTransform(a, b, c, d, e, f) {
|
||||||
destCtx.transform(a, b, c, d, e, f);
|
destCtx.transform(a, b, c, d, e, f);
|
||||||
this.__originalTransform(a, b, c, d, e, f);
|
this.__originalTransform(a, b, c, d, e, f);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.setTransform = function (a, b, c, d, e, f) {
|
ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
|
||||||
destCtx.setTransform(a, b, c, d, e, f);
|
destCtx.setTransform(a, b, c, d, e, f);
|
||||||
this.__originalSetTransform(a, b, c, d, e, f);
|
this.__originalSetTransform(a, b, c, d, e, f);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.resetTransform = function () {
|
ctx.resetTransform = function ctxResetTransform() {
|
||||||
destCtx.resetTransform();
|
destCtx.resetTransform();
|
||||||
this.__originalResetTransform();
|
this.__originalResetTransform();
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.rotate = function (angle) {
|
ctx.rotate = function ctxRotate(angle) {
|
||||||
destCtx.rotate(angle);
|
destCtx.rotate(angle);
|
||||||
this.__originalRotate(angle);
|
this.__originalRotate(angle);
|
||||||
};
|
};
|
||||||
|
|
||||||
ctx.clip = function (rule) {
|
ctx.clip = function ctxRotate(rule) {
|
||||||
destCtx.clip(rule);
|
destCtx.clip(rule);
|
||||||
this.__originalClip(rule);
|
this.__originalClip(rule);
|
||||||
};
|
};
|
||||||
@ -303,63 +305,39 @@ function drawImageAtIntegerCoords(
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CanvasExtraState {
|
class CanvasExtraState {
|
||||||
// Are soft masks and alpha values shapes or opacities?
|
|
||||||
alphaIsShape = false;
|
|
||||||
|
|
||||||
fontSize = 0;
|
|
||||||
|
|
||||||
fontSizeScale = 1;
|
|
||||||
|
|
||||||
textMatrix = null;
|
|
||||||
|
|
||||||
textMatrixScale = 1;
|
|
||||||
|
|
||||||
fontMatrix = FONT_IDENTITY_MATRIX;
|
|
||||||
|
|
||||||
leading = 0;
|
|
||||||
|
|
||||||
// Current point (in user coordinates)
|
|
||||||
x = 0;
|
|
||||||
|
|
||||||
y = 0;
|
|
||||||
|
|
||||||
// Start of text line (in text coordinates)
|
|
||||||
lineX = 0;
|
|
||||||
|
|
||||||
lineY = 0;
|
|
||||||
|
|
||||||
// Character and word spacing
|
|
||||||
charSpacing = 0;
|
|
||||||
|
|
||||||
wordSpacing = 0;
|
|
||||||
|
|
||||||
textHScale = 1;
|
|
||||||
|
|
||||||
textRenderingMode = TextRenderingMode.FILL;
|
|
||||||
|
|
||||||
textRise = 0;
|
|
||||||
|
|
||||||
// Default fore and background colors
|
|
||||||
fillColor = "#000000";
|
|
||||||
|
|
||||||
strokeColor = "#000000";
|
|
||||||
|
|
||||||
patternFill = false;
|
|
||||||
|
|
||||||
patternStroke = false;
|
|
||||||
|
|
||||||
// Note: fill alpha applies to all non-stroking operations
|
|
||||||
fillAlpha = 1;
|
|
||||||
|
|
||||||
strokeAlpha = 1;
|
|
||||||
|
|
||||||
lineWidth = 1;
|
|
||||||
|
|
||||||
activeSMask = null;
|
|
||||||
|
|
||||||
transferMaps = "none";
|
|
||||||
|
|
||||||
constructor(width, height) {
|
constructor(width, height) {
|
||||||
|
// Are soft masks and alpha values shapes or opacities?
|
||||||
|
this.alphaIsShape = false;
|
||||||
|
this.fontSize = 0;
|
||||||
|
this.fontSizeScale = 1;
|
||||||
|
this.textMatrix = IDENTITY_MATRIX;
|
||||||
|
this.textMatrixScale = 1;
|
||||||
|
this.fontMatrix = FONT_IDENTITY_MATRIX;
|
||||||
|
this.leading = 0;
|
||||||
|
// Current point (in user coordinates)
|
||||||
|
this.x = 0;
|
||||||
|
this.y = 0;
|
||||||
|
// Start of text line (in text coordinates)
|
||||||
|
this.lineX = 0;
|
||||||
|
this.lineY = 0;
|
||||||
|
// Character and word spacing
|
||||||
|
this.charSpacing = 0;
|
||||||
|
this.wordSpacing = 0;
|
||||||
|
this.textHScale = 1;
|
||||||
|
this.textRenderingMode = TextRenderingMode.FILL;
|
||||||
|
this.textRise = 0;
|
||||||
|
// Default fore and background colors
|
||||||
|
this.fillColor = "#000000";
|
||||||
|
this.strokeColor = "#000000";
|
||||||
|
this.patternFill = false;
|
||||||
|
this.patternStroke = false;
|
||||||
|
// Note: fill alpha applies to all non-stroking operations
|
||||||
|
this.fillAlpha = 1;
|
||||||
|
this.strokeAlpha = 1;
|
||||||
|
this.lineWidth = 1;
|
||||||
|
this.activeSMask = null;
|
||||||
|
this.transferMaps = "none";
|
||||||
|
|
||||||
this.clipBox = new Float32Array([0, 0, width, height]);
|
this.clipBox = new Float32Array([0, 0, width, height]);
|
||||||
this.minMax = MIN_MAX_INIT.slice();
|
this.minMax = MIN_MAX_INIT.slice();
|
||||||
}
|
}
|
||||||
@ -611,9 +589,14 @@ function resetCtxToDefault(ctx) {
|
|||||||
ctx.setLineDash([]);
|
ctx.setLineDash([]);
|
||||||
ctx.lineDashOffset = 0;
|
ctx.lineDashOffset = 0;
|
||||||
}
|
}
|
||||||
const { filter } = ctx;
|
if (
|
||||||
if (filter !== "none" && filter !== "") {
|
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||||
ctx.filter = "none";
|
!isNodeJS
|
||||||
|
) {
|
||||||
|
const { filter } = ctx;
|
||||||
|
if (filter !== "none" && filter !== "") {
|
||||||
|
ctx.filter = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1610,7 +1593,7 @@ class CanvasGraphics {
|
|||||||
|
|
||||||
// Text
|
// Text
|
||||||
beginText() {
|
beginText() {
|
||||||
this.current.textMatrix = null;
|
this.current.textMatrix = IDENTITY_MATRIX;
|
||||||
this.current.textMatrixScale = 1;
|
this.current.textMatrixScale = 1;
|
||||||
this.current.x = this.current.lineX = 0;
|
this.current.x = this.current.lineX = 0;
|
||||||
this.current.y = this.current.lineY = 0;
|
this.current.y = this.current.lineY = 0;
|
||||||
@ -1731,13 +1714,12 @@ class CanvasGraphics {
|
|||||||
this.moveText(x, y);
|
this.moveText(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
setTextMatrix(matrix) {
|
setTextMatrix(a, b, c, d, e, f) {
|
||||||
const { current } = this;
|
this.current.textMatrix = [a, b, c, d, e, f];
|
||||||
current.textMatrix = matrix;
|
this.current.textMatrixScale = Math.hypot(a, b);
|
||||||
current.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
|
|
||||||
|
|
||||||
current.x = current.lineX = 0;
|
this.current.x = this.current.lineX = 0;
|
||||||
current.y = current.lineY = 0;
|
this.current.y = this.current.lineY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextLine() {
|
nextLine() {
|
||||||
@ -1904,9 +1886,7 @@ class CanvasGraphics {
|
|||||||
!current.patternFill;
|
!current.patternFill;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
if (current.textMatrix) {
|
ctx.transform(...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) {
|
||||||
@ -2101,9 +2081,7 @@ class CanvasGraphics {
|
|||||||
this._cachedGetSinglePixelWidth = null;
|
this._cachedGetSinglePixelWidth = null;
|
||||||
|
|
||||||
ctx.save();
|
ctx.save();
|
||||||
if (current.textMatrix) {
|
ctx.transform(...current.textMatrix);
|
||||||
ctx.transform(...current.textMatrix);
|
|
||||||
}
|
|
||||||
ctx.translate(current.x, current.y + current.textRise);
|
ctx.translate(current.x, current.y + current.textRise);
|
||||||
|
|
||||||
ctx.scale(textHScale, fontDirection);
|
ctx.scale(textHScale, fontDirection);
|
||||||
@ -2756,13 +2734,18 @@ class CanvasGraphics {
|
|||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
// The filter, if any, will be applied in applyTransferMapsToBitmap.
|
if (
|
||||||
// It must be applied to the image before rescaling else some artifacts
|
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
|
||||||
// could appear.
|
!isNodeJS
|
||||||
// The final restore will reset it to its value.
|
) {
|
||||||
const { filter } = ctx;
|
// The filter, if any, will be applied in applyTransferMapsToBitmap.
|
||||||
if (filter !== "none" && filter !== "") {
|
// It must be applied to the image before rescaling else some artifacts
|
||||||
ctx.filter = "none";
|
// could appear.
|
||||||
|
// The final restore will reset it to its value.
|
||||||
|
const { filter } = ctx;
|
||||||
|
if (filter !== "none" && filter !== "") {
|
||||||
|
ctx.filter = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale the image to the unit square
|
// scale the image to the unit square
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user