1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-18 14:18:23 +02:00

Initialize the isOffscreenCanvasSupported option, in the OperatorList class, once per document

Currently we're setting this option for each small inline image, which seems unnecessary since it should suffice to do that once per document.
This commit is contained in:
Jonas Jenwald 2025-04-03 14:00:07 +02:00
parent a45f961a1c
commit 4a6c47489e
3 changed files with 7 additions and 11 deletions

View file

@ -726,8 +726,6 @@ class PartialEvaluator {
/* forceRGBA = */ true,
/* isOffscreenCanvasSupported = */ false
);
operatorList.isOffscreenCanvasSupported =
this.options.isOffscreenCanvasSupported;
operatorList.addImageOps(
OPS.paintInlineImageXObject,
[imgData],

View file

@ -567,17 +567,12 @@ class QueueOptimizer extends NullOptimizer {
iCurr: 0,
fnArray: queue.fnArray,
argsArray: queue.argsArray,
isOffscreenCanvasSupported: false,
isOffscreenCanvasSupported: OperatorList.isOffscreenCanvasSupported,
};
this.match = null;
this.lastProcessed = 0;
}
// eslint-disable-next-line accessor-pairs
set isOffscreenCanvasSupported(value) {
this.context.isOffscreenCanvasSupported = value;
}
_optimize() {
// Process new fnArray item(s) chunk.
const fnArray = this.queue.fnArray;
@ -656,6 +651,8 @@ class OperatorList {
// Close to chunk size.
static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
static isOffscreenCanvasSupported = false;
constructor(intent = 0, streamSink) {
this._streamSink = streamSink;
this.fnArray = [];
@ -670,9 +667,8 @@ class OperatorList {
this._resolved = streamSink ? null : Promise.resolve();
}
// eslint-disable-next-line accessor-pairs
set isOffscreenCanvasSupported(value) {
this.optimizer.isOffscreenCanvasSupported = value;
static setOptions({ isOffscreenCanvasSupported }) {
this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
}
get length() {

View file

@ -25,6 +25,7 @@ import { ImageResizer } from "./image_resizer.js";
import { JpegStream } from "./jpeg_stream.js";
import { JpxImage } from "./jpx.js";
import { MissingDataException } from "./core_utils.js";
import { OperatorList } from "./operator_list.js";
import { PDFDocument } from "./document.js";
import { Stream } from "./stream.js";
@ -74,6 +75,7 @@ class BasePdfManager {
// Initialize image-options once per document.
ImageResizer.setOptions(evaluatorOptions);
JpegStream.setOptions(evaluatorOptions);
OperatorList.setOptions(evaluatorOptions);
const options = { ...evaluatorOptions, handler };
JpxImage.setOptions(options);