Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,6 @@ class PartialEvaluator {
/* forceRGBA = */ true,
/* isOffscreenCanvasSupported = */ false
);
operatorList.isOffscreenCanvasSupported =
this.options.isOffscreenCanvasSupported;
operatorList.addImageOps(
OPS.paintInlineImageXObject,
[imgData],
Expand Down
14 changes: 5 additions & 9 deletions src/core/operator_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [];
Expand All @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions src/core/pdf_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
Expand Down