Merge pull request #19392 from Snuffleupagus/image-options-init-once
Initialize the image-options, on the worker-thread, once per document
This commit is contained in:
commit
d1a0f3e495
@ -75,9 +75,6 @@ import { getFontSubstitution } from "./font_substitutions.js";
|
|||||||
import { getGlyphsUnicode } from "./glyphlist.js";
|
import { getGlyphsUnicode } from "./glyphlist.js";
|
||||||
import { getMetrics } from "./metrics.js";
|
import { getMetrics } from "./metrics.js";
|
||||||
import { getUnicodeForGlyph } from "./unicode.js";
|
import { getUnicodeForGlyph } from "./unicode.js";
|
||||||
import { ImageResizer } from "./image_resizer.js";
|
|
||||||
import { JpegStream } from "./jpeg_stream.js";
|
|
||||||
import { JpxImage } from "./jpx.js";
|
|
||||||
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
||||||
import { OperatorList } from "./operator_list.js";
|
import { OperatorList } from "./operator_list.js";
|
||||||
import { PDFImage } from "./image.js";
|
import { PDFImage } from "./image.js";
|
||||||
@ -240,13 +237,6 @@ class PartialEvaluator {
|
|||||||
|
|
||||||
this._regionalImageCache = new RegionalImageCache();
|
this._regionalImageCache = new RegionalImageCache();
|
||||||
this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
|
this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
|
||||||
|
|
||||||
ImageResizer.setOptions(this.options);
|
|
||||||
JpegStream.setOptions(this.options);
|
|
||||||
JpxImage.setOptions({
|
|
||||||
wasmUrl: this.options.wasmUrl,
|
|
||||||
handler,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -20,6 +20,9 @@ import {
|
|||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import { ChunkedStreamManager } from "./chunked_stream.js";
|
import { ChunkedStreamManager } from "./chunked_stream.js";
|
||||||
|
import { ImageResizer } from "./image_resizer.js";
|
||||||
|
import { JpegStream } from "./jpeg_stream.js";
|
||||||
|
import { JpxImage } from "./jpx.js";
|
||||||
import { MissingDataException } from "./core_utils.js";
|
import { MissingDataException } from "./core_utils.js";
|
||||||
import { PDFDocument } from "./document.js";
|
import { PDFDocument } from "./document.js";
|
||||||
import { Stream } from "./stream.js";
|
import { Stream } from "./stream.js";
|
||||||
@ -36,25 +39,41 @@ function parseDocBaseUrl(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class BasePdfManager {
|
class BasePdfManager {
|
||||||
constructor(args) {
|
constructor({
|
||||||
|
// source,
|
||||||
|
// disableAutoFetch,
|
||||||
|
docBaseUrl,
|
||||||
|
docId,
|
||||||
|
enableXfa,
|
||||||
|
evaluatorOptions,
|
||||||
|
handler,
|
||||||
|
// length,
|
||||||
|
password,
|
||||||
|
// rangeChunkSize,
|
||||||
|
}) {
|
||||||
if (
|
if (
|
||||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
|
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
|
||||||
this.constructor === BasePdfManager
|
this.constructor === BasePdfManager
|
||||||
) {
|
) {
|
||||||
unreachable("Cannot initialize BasePdfManager.");
|
unreachable("Cannot initialize BasePdfManager.");
|
||||||
}
|
}
|
||||||
this._docBaseUrl = parseDocBaseUrl(args.docBaseUrl);
|
this._docBaseUrl = parseDocBaseUrl(docBaseUrl);
|
||||||
this._docId = args.docId;
|
this._docId = docId;
|
||||||
this._password = args.password;
|
this._password = password;
|
||||||
this.enableXfa = args.enableXfa;
|
this.enableXfa = enableXfa;
|
||||||
|
|
||||||
// Check `OffscreenCanvas` and `ImageDecoder` support once,
|
// Check `OffscreenCanvas` and `ImageDecoder` support once,
|
||||||
// rather than repeatedly throughout the worker-thread code.
|
// rather than repeatedly throughout the worker-thread code.
|
||||||
args.evaluatorOptions.isOffscreenCanvasSupported &&=
|
evaluatorOptions.isOffscreenCanvasSupported &&=
|
||||||
FeatureTest.isOffscreenCanvasSupported;
|
FeatureTest.isOffscreenCanvasSupported;
|
||||||
args.evaluatorOptions.isImageDecoderSupported &&=
|
evaluatorOptions.isImageDecoderSupported &&=
|
||||||
FeatureTest.isImageDecoderSupported;
|
FeatureTest.isImageDecoderSupported;
|
||||||
this.evaluatorOptions = Object.freeze(args.evaluatorOptions);
|
this.evaluatorOptions = Object.freeze(evaluatorOptions);
|
||||||
|
|
||||||
|
// Initially image-options once per document.
|
||||||
|
ImageResizer.setOptions(evaluatorOptions);
|
||||||
|
JpegStream.setOptions(evaluatorOptions);
|
||||||
|
JpxImage.setOptions({ ...evaluatorOptions, handler });
|
||||||
}
|
}
|
||||||
|
|
||||||
get docId() {
|
get docId() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user