-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce or improve calls to clamp0to255 in jpg js #4901
Comments
The clamping is needed, OTOH using Uint8ClampedArrays would work like a charm... except not all browsers support them ( PDF.js aims to work on a very broad range of browsers ) and shiming them using getters and setters would slow the shim'ed code path even more and take more memory. |
would it be possible to polyfill Uint8ClampedArray with CanvasPixelArray ? CanvasPixelArray is supported by IE9. |
Yeah, I thought about that. We will need to do that at some point -- it might take time to review entire code base to fix that for all image processing and colorspace parts. |
wouldn't the data be automatically clamped when painted to canvas? |
Unfortunately the HTML5 spec remained fuzzy about clamping vs clipping for a while which lead to different behaviors across browser. Not sure what is the state of affairs in the browsers targeted by PDF.js |
here a polyfill |
The following picture shows a profiling from IE10.
it shows that clamping is quite frequent. And because it is IE, it is super slow.
http://jsperf.com/clamp-functions/12
confirms that IE is way behind all modern browsers.
The question I am asking myself:
From the perspective of the algorithm, is the clamping actually needed?
and if so, is it needed in both directions?
Would a | 0 truncation be sufficient?
Maybe @p01 or @bthorben can give me a hint or help me out here.
The text was updated successfully, but these errors were encountered: