Remove the unused /Decode handling from the JpegStream/JpegImage classes - #21809
Conversation
…classes According to the coverage data this code is now unused, see: - https://app.codecov.io/gh/mozilla/pdf.js/commit/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/blob/src/core/jpeg_stream.js?dropdown=coverage#L74 - https://app.codecov.io/gh/mozilla/pdf.js/commit/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/blob/src/core/jpeg_stream.js?dropdown=coverage#L149 - https://app.codecov.io/gh/mozilla/pdf.js/commit/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/blob/src/core/jpg.js?dropdown=coverage#L1281 I've not attempted to find out exactly when it was made obsolete, however it most likely happened with the introduction of `ImageDecoder`. Note that any /Decode entry is already parsed in the `PDFImage` constructor, see [this code](https://github.com/mozilla/pdf.js/blob/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/src/core/image.js#L267-L290), and that the `PDFImage.prototype.getImageBytes` method is only ever invoked with the `forceRGBA`/`forceRGB` parameters set from [this code](https://github.com/mozilla/pdf.js/blob/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/src/core/image.js#L868-L873) respectively [this code](https://github.com/mozilla/pdf.js/blob/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/src/core/image.js#L885-L890). Note that both of those occurrences are placed within the following block: https://github.com/mozilla/pdf.js/blob/9aea8e2dfb142ad7c4e3a2595e8052e5dc8ce160/src/core/image.js#L834-L839 Hence, outside of the IMAGE_DECODERS build, there's no longer any reason for the `JpegStream` and `JpegImage` classes to implement their own /Decode handling. Besides removing what's now dead code, it also improves consistency in the code-base given that none of the other image-decoders do this. Finally, while slightly unrelated, move SMask/Mask checks in the `PDFImage.prototype.createImageData` method to occur earlier instead of unnecessarily repeating them later.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21809 +/- ##
==========================================
- Coverage 90.19% 90.19% -0.01%
==========================================
Files 264 264
Lines 67350 67339 -11
==========================================
- Hits 60749 60734 -15
- Misses 6601 6605 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/botio browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/d2f75828016aa6c/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/37edbe470854a82/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/d2f75828016aa6c/output.txt Total script time: 18.10 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/37edbe470854a82/output.txt Total script time: 23.13 mins
|
According to the coverage data this code is now unused, see:
I've not attempted to find out exactly when it was made obsolete, however it most likely happened with the introduction of
ImageDecoder.Note that any /Decode entry is already parsed in the
PDFImageconstructor, see this code, and that thePDFImage.prototype.getImageBytesmethod is only ever invoked with theforceRGBA/forceRGBparameters set from this code respectively this code.Note that both of those occurrences are placed within the following block:
pdf.js/src/core/image.js
Lines 834 to 839 in 9aea8e2
Hence, outside of the IMAGE_DECODERS build, there's no longer any reason for the
JpegStreamandJpegImageclasses to implement their own /Decode handling.Besides removing what's now dead code, it also improves consistency in the code-base given that none of the other image-decoders do this.
Finally, while slightly unrelated, move SMask/Mask checks in the
PDFImage.prototype.createImageDatamethod to occur earlier instead of unnecessarily repeating them later.Slightly smaller diff with https://github.com/mozilla/pdf.js/pull/21809/changes?w=1