mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Check OffscreenCanvas
support once on the worker-thread
Currently we repeat the `FeatureTest.isOffscreenCanvasSupported` checks all over the worker-thread code, and with upcoming changes this will become even "worse". Hence this patch, which changes the *worker-thread* default value for the `isOffscreenCanvasSupported`-parameter to `false` and moves the feature-testing into the `BasePdfManager`-constructor. *Please note:* This patch is written using the GitHub UI, since I'm currently without a dev machine, so hopefully it works correctly.
This commit is contained in:
parent
2da2ac492e
commit
45c332110e
4 changed files with 12 additions and 16 deletions
|
@ -13,14 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
assert,
|
||||
FeatureTest,
|
||||
FormatError,
|
||||
ImageKind,
|
||||
info,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
import { assert, FormatError, ImageKind, info, warn } from "../shared/util.js";
|
||||
import { applyMaskImageData } from "../shared/image_utils.js";
|
||||
import { BaseStream } from "./base_stream.js";
|
||||
import { ColorSpace } from "./colorspace.js";
|
||||
|
@ -356,7 +349,7 @@ class PDFImage {
|
|||
imageIsFromDecodeStream,
|
||||
inverseDecode,
|
||||
interpolate,
|
||||
isOffscreenCanvasSupported = true,
|
||||
isOffscreenCanvasSupported = false,
|
||||
}) {
|
||||
const isSingleOpaquePixel =
|
||||
width === 1 &&
|
||||
|
@ -367,7 +360,7 @@ class PDFImage {
|
|||
return { isSingleOpaquePixel };
|
||||
}
|
||||
|
||||
if (isOffscreenCanvasSupported && FeatureTest.isOffscreenCanvasSupported) {
|
||||
if (isOffscreenCanvasSupported) {
|
||||
const canvas = new OffscreenCanvas(width, height);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const imgData = ctx.createImageData(width, height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue