NEW 120813
Use of Uint8ClampedArray makes filters twice as slow
https://bugs.webkit.org/show_bug.cgi?id=120813
Summary Use of Uint8ClampedArray makes filters twice as slow
Simon Fraser (smfr)
Reported 2013-09-05 17:07:50 PDT
I was curious about why blur filters on image backgrounds are incredibly slow. Sampling shows lots of time in GenericTypedArrayView::set(unsigned index, double value) const which is doing a safe double -> int cast with clamping. This comes out of a tight look in the blurring code: for (int x = 0; x < effectWidth; ++x) { int pixelByteOffset = line + x * stride + channel; dstPixelArray->set(pixelByteOffset, static_cast<unsigned char>(sum / dx)); It's crazy that we're wasting time doing double -> int conversion when the caller is passing in an unsigned char. We're converting double -> unsigned char -> double -> int32_t -> uint8_t Bypassing this crap by just filling a uint8_t[] and using dstPixelArray->setRange() makes blurring twice as fast.
Attachments
Testcase (872 bytes, text/html)
2013-09-05 17:08 PDT, Simon Fraser (smfr)
no flags
Simon Fraser (smfr)
Comment 1 2013-09-05 17:08:10 PDT
Created attachment 210684 [details] Testcase
Radar WebKit Bug Importer
Comment 2 2013-09-06 11:08:52 PDT
Adenilson Cavalcanti Silva
Comment 3 2014-02-28 11:34:49 PST
Started looking into this.
Ahmad Saleem
Comment 4 2022-12-30 16:39:31 PST
It is still taking several steps to blur completely in Safari 16.2 & STP160 but this does not seem to be working in Chrome Canary 111 and Firefox Nightly 110 for some reasons even after modifying to change pic URL to HTTPS and removing -webkit- prefix in following: URL - https://jsfiddle.net/unz3h758/2/show
Note You need to log in before you can comment on or make changes to this bug.