1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

[api-minor] Generate images in the worker instead of the main thread.

We introduced the use of OffscreenCanvas in #14754 and this patch aims
to use them for all kind of images.
It'll slightly improve performances (and maybe slightly decrease memory use).
Since an image can be rendered in using some transfer maps but because of
OffscreenCanvas we don't have the underlying pixels array the transfer maps
stuff is re-implemented in using the SVG filter feComponentTransfer.
This commit is contained in:
Calixte Denizet 2023-02-15 17:14:04 +01:00
parent 9640add1f7
commit fd03cd5493
13 changed files with 700 additions and 89 deletions

View file

@ -63,7 +63,7 @@ class JpegStream extends DecodeStream {
// Checking if values need to be transformed before conversion.
const decodeArr = this.dict.getArray("D", "Decode");
if (this.forceRGB && Array.isArray(decodeArr)) {
if ((this.forceRGBA || this.forceRGB) && Array.isArray(decodeArr)) {
const bitsPerComponent = this.dict.get("BPC", "BitsPerComponent") || 8;
const decodeArrLength = decodeArr.length;
const transform = new Int32Array(decodeArrLength);
@ -93,6 +93,7 @@ class JpegStream extends DecodeStream {
const data = jpegImage.getData({
width: this.drawWidth,
height: this.drawHeight,
forceRGBA: this.forceRGBA,
forceRGB: this.forceRGB,
isSourcePDF: true,
});