Inline PDFImage.createRawMask
in the PDFImage.createMask
method
#19773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After the introduction of
OffscreenCanvas
support we now have two separate mask-methods in thePDFImage
class, and the reason that they were not combined is likely that we need the "raw" bytes when parsing Type3-glyph image masks.However, that case is easy to support simply by disabling
OffscreenCanvas
usage when parsing Type3-glyphs and that way we're able to reduce some code duplication.Another slightly strange property of the
PDFImage.createMask
method is that it needs various image-dictionary parameters manually provided, which is probably because this is very old code.That feels slightly unwieldy, and we instead change the method to pass in the image-stream directly and do the necessary data-lookup internally.
A side-effect of this re-factoring is that we now support using the custom
isSingleOpaquePixel
operator in Type3-glyphs, which shouldn't hurt even though it seems extremely unlikely for that to ever happen in Type3-glyphs.