[Webkit-unassigned] [Bug 60897] [Qt] Implement toImageData() in QtWebKit Bridge

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed May 18 11:38:36 PDT 2011


https://bugs.webkit.org/show_bug.cgi?id=60897





--- Comment #6 from Andrew Wason <rectalogic at rectalogic.com>  2011-05-18 11:38:36 PST ---
Created an attachment (id=93954)
 --> (https://bugs.webkit.org/attachment.cgi?id=93954&action=review)
QImage conversion performance testing

(In reply to comment #4)
> 
> What about using QImage::convertToFormat() to always convert to QImage::Format_ARGB32,
> and then do the byte shifting? Qt already has optimized color conversions fonctions
> for plenty of formats.

I had considered that (and also looked at QGLWidget::convertToGLFormat() which converts to RGBA), but was trying to avoid a full intermediate copy of the image bits by converting them directly into the ImageData ByteArray. My use case is thousands of relatively large images (1920x1080).

I tried to find a way to use the internal optimized image conversion routines, but they're all private.

You are right QImage::pixel() is a performance killer though. I'm attaching a simple app to compare the performance for each format of using convertToFormat() vs. directly copying/converting. For the formats I'm handling directly, convertToFormat() is about 1.5X slower. For the formats where I fall back to QImage::pixel(), convertToFormat() is about 2-3X faster. Here are the results when I run it:

$ ./imageconvert 
format 1 convertDirect=13432740 convertWithCopy=4496240 direct/copy=2.987550
format 2 convertDirect=13330259 convertWithCopy=4649569 direct/copy=2.866988
format 3 convertDirect=12529513 convertWithCopy=4600696 direct/copy=2.723395
format 4 convertDirect=2837000 convertWithCopy=4375153 direct/copy=0.648434
format 5 convertDirect=2891826 convertWithCopy=4293214 direct/copy=0.673581
format 6 convertDirect=12443809 convertWithCopy=12101966 direct/copy=1.028247
format 7 convertDirect=15110204 convertWithCopy=5870940 direct/copy=2.573728
format 8 convertDirect=19884922 convertWithCopy=9334570 direct/copy=2.130245
format 9 convertDirect=17433956 convertWithCopy=7134872 direct/copy=2.443485
format 10 convertDirect=18181269 convertWithCopy=8235076 direct/copy=2.207784
format 11 convertDirect=15399767 convertWithCopy=6015450 direct/copy=2.560036
format 12 convertDirect=16741198 convertWithCopy=7187635 direct/copy=2.329166
format 13 convertDirect=1690568 convertWithCopy=4665468 direct/copy=0.362358
format 14 convertDirect=14963419 convertWithCopy=5687373 direct/copy=2.630990
format 15 convertDirect=16249964 convertWithCopy=6523285 direct/copy=2.491071

So perhaps copyPixels() could continue to handle Format_RGB32, Format_ARGB32, Format_RGB888 directly, and for the fallback case use convertToFormat() instead of QImage::pixel(). i.e. avoid the intermediate copy for these 3 formats which are pretty simple to convert to RGBA instead of always converting to Format_ARGB32 first.

-- 
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