Merge pull request #19758 from Snuffleupagus/OperatorList-setOptions

Initialize the `isOffscreenCanvasSupported` option, in the `OperatorList` class, once per document
This commit is contained in:
Jonas Jenwald 2025-04-05 18:45:55 +02:00 committed by GitHub
commit 7cfb1be650
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 11 deletions

View File

@ -728,8 +728,6 @@ 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],

View File

@ -567,17 +567,12 @@ class QueueOptimizer extends NullOptimizer {
iCurr: 0, iCurr: 0,
fnArray: queue.fnArray, fnArray: queue.fnArray,
argsArray: queue.argsArray, argsArray: queue.argsArray,
isOffscreenCanvasSupported: false, isOffscreenCanvasSupported: OperatorList.isOffscreenCanvasSupported,
}; };
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;
@ -656,6 +651,8 @@ 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 = [];
@ -670,9 +667,8 @@ class OperatorList {
this._resolved = streamSink ? null : Promise.resolve(); this._resolved = streamSink ? null : Promise.resolve();
} }
// eslint-disable-next-line accessor-pairs static setOptions({ isOffscreenCanvasSupported }) {
set isOffscreenCanvasSupported(value) { this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
this.optimizer.isOffscreenCanvasSupported = value;
} }
get length() { get length() {

View File

@ -25,6 +25,7 @@ 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";
@ -74,6 +75,7 @@ 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);