mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Initialize the image-options, on the worker-thread, once per document
Currently we're initializing the image-options for every page, which seems unnecessary since it should suffice to do that once per document. Also, changes the `BasePdfManager` constructor to improve readability/documentation a little bit.
This commit is contained in:
parent
42c2b7b657
commit
db53320da8
2 changed files with 27 additions and 18 deletions
|
@ -75,9 +75,6 @@ import { getFontSubstitution } from "./font_substitutions.js";
|
|||
import { getGlyphsUnicode } from "./glyphlist.js";
|
||||
import { getMetrics } from "./metrics.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 { OperatorList } from "./operator_list.js";
|
||||
import { PDFImage } from "./image.js";
|
||||
|
@ -240,13 +237,6 @@ class PartialEvaluator {
|
|||
|
||||
this._regionalImageCache = new RegionalImageCache();
|
||||
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,
|
||||
} from "../shared/util.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 { PDFDocument } from "./document.js";
|
||||
import { Stream } from "./stream.js";
|
||||
|
@ -36,25 +39,41 @@ function parseDocBaseUrl(url) {
|
|||
}
|
||||
|
||||
class BasePdfManager {
|
||||
constructor(args) {
|
||||
constructor({
|
||||
// source,
|
||||
// disableAutoFetch,
|
||||
docBaseUrl,
|
||||
docId,
|
||||
enableXfa,
|
||||
evaluatorOptions,
|
||||
handler,
|
||||
// length,
|
||||
password,
|
||||
// rangeChunkSize,
|
||||
}) {
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
|
||||
this.constructor === BasePdfManager
|
||||
) {
|
||||
unreachable("Cannot initialize BasePdfManager.");
|
||||
}
|
||||
this._docBaseUrl = parseDocBaseUrl(args.docBaseUrl);
|
||||
this._docId = args.docId;
|
||||
this._password = args.password;
|
||||
this.enableXfa = args.enableXfa;
|
||||
this._docBaseUrl = parseDocBaseUrl(docBaseUrl);
|
||||
this._docId = docId;
|
||||
this._password = password;
|
||||
this.enableXfa = enableXfa;
|
||||
|
||||
// Check `OffscreenCanvas` and `ImageDecoder` support once,
|
||||
// rather than repeatedly throughout the worker-thread code.
|
||||
args.evaluatorOptions.isOffscreenCanvasSupported &&=
|
||||
evaluatorOptions.isOffscreenCanvasSupported &&=
|
||||
FeatureTest.isOffscreenCanvasSupported;
|
||||
args.evaluatorOptions.isImageDecoderSupported &&=
|
||||
evaluatorOptions.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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue