[Webkit-unassigned] [Bug 120813] New: Use of Uint8ClampedArray makes filters twice as slow

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 5 17:08:34 PDT 2013


           Summary: Use of Uint8ClampedArray makes filters twice as slow
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Layout and Rendering
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: simon.fraser at apple.com
                CC: oliver at apple.com, krit at webkit.org

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.

Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

More information about the webkit-unassigned mailing list