mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
[api-minor] Extend general transfer function support to browsers without OffscreenCanvas
This patch extends PR 16115 to work in all browsers, regardless of their `OffscreenCanvas` support, such that transfer functions will be applied to general rendering (and not just image data). In order to do this we introduce the `BaseFilterFactory` that is then extended in browsers/Node.js environments, similar to all the other factories used in the API, such that we always have the necessary factory available in `src/display/canvas.js`. These changes help simplify the existing `putBinaryImageData` function, and the new method can easily be stubbed-out in the Firefox PDF Viewer. *Please note:* This patch removes the old *partial* transfer function support, which only applied to image data, from Node.js environments since the `node-canvas` package currently doesn't support filters. However, this should hopefully be fine given that: - Transfer functions are not very commonly used in PDF documents. - Browsers in general, and Firefox in particular, are the *primary* development target for the PDF.js library. - The FAQ only lists Node.js as *mostly* supported, see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
This commit is contained in:
parent
945855a2b8
commit
fc055dbd80
8 changed files with 92 additions and 102 deletions
|
@ -16,6 +16,7 @@
|
|||
import {
|
||||
BaseCanvasFactory,
|
||||
BaseCMapReaderFactory,
|
||||
BaseFilterFactory,
|
||||
BaseStandardFontDataFactory,
|
||||
BaseSVGFactory,
|
||||
} from "./base_factory.js";
|
||||
|
@ -48,7 +49,7 @@ class PixelsPerInch {
|
|||
* an image without the need to apply them on the pixel arrays: the renderer
|
||||
* does the magic for us.
|
||||
*/
|
||||
class FilterFactory {
|
||||
class DOMFilterFactory extends BaseFilterFactory {
|
||||
#_cache;
|
||||
|
||||
#_defs;
|
||||
|
@ -60,6 +61,7 @@ class FilterFactory {
|
|||
#id = 0;
|
||||
|
||||
constructor({ docId, ownerDocument = globalThis.document } = {}) {
|
||||
super();
|
||||
this.#docId = docId;
|
||||
this.#document = ownerDocument;
|
||||
}
|
||||
|
@ -823,9 +825,9 @@ export {
|
|||
deprecated,
|
||||
DOMCanvasFactory,
|
||||
DOMCMapReaderFactory,
|
||||
DOMFilterFactory,
|
||||
DOMStandardFontDataFactory,
|
||||
DOMSVGFactory,
|
||||
FilterFactory,
|
||||
getColorValues,
|
||||
getCurrentTransform,
|
||||
getCurrentTransformInverse,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue