[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andreas.kling at nokia.com andreas.kling at nokia.com
Wed Dec 22 11:27:48 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit bc5312a3034c645e5e3586d3ba8bb149c7e9e97b
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jul 26 11:51:45 2010 +0000

    2010-07-26  Andreas Kling  <andreas.kling at nokia.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] getImageData(): Single-pass RGB->BGR and un-premultiplication
            https://bugs.webkit.org/show_bug.cgi?id=42945
    
            Combine the two operations into a single loop over the pixel data.
            Yields a considerable FPS gain on http://www.semantix.gr/statue.html
    
            * platform/graphics/qt/ImageBufferQt.cpp:
            (WebCore::getImageData):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64041 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4196839..7331ee0 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,16 @@
+2010-07-26  Andreas Kling  <andreas.kling at nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] getImageData(): Single-pass RGB->BGR and un-premultiplication
+        https://bugs.webkit.org/show_bug.cgi?id=42945
+
+        Combine the two operations into a single loop over the pixel data.
+        Yields a considerable FPS gain on http://www.semantix.gr/statue.html
+
+        * platform/graphics/qt/ImageBufferQt.cpp:
+        (WebCore::getImageData):
+
 2010-07-26  Pavel Feldman  <pfeldman at chromium.org>
 
         Reviewed by Shinichiro Hamaji.
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index b4ca617..dcbc817 100644
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -175,32 +175,53 @@ PassRefPtr<ImageData> getImageData(const IntRect& rect, const ImageBufferData& i
         endy = size.height();
     int numRows = endy - originy;
 
-    QImage image = imageData.m_pixmap.toImage();
-    if (multiplied == Unmultiplied)
-        image = image.convertToFormat(QImage::Format_ARGB32);
-    else
-        image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+    // NOTE: For unmultiplied data, we undo the premultiplication below.
+    QImage image = imageData.m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
 
     ASSERT(!image.isNull());
 
-    unsigned destBytesPerRow = 4 * rect.width();
-    unsigned char* destRows = data + desty * destBytesPerRow + destx * 4;
-    for (int y = 0; y < numRows; ++y) {
+    const int bytesPerLine = image.bytesPerLine();
 #if QT_VERSION >= 0x040700
-        const quint32* scanLine = reinterpret_cast<const quint32*>(image.constScanLine(y + originy));
+    const uchar* bits = image.constBits();
 #else
-        quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y + originy));
+    const uchar* bits = image.bits();
 #endif
-        for (int x = 0; x < numColumns; x++) {
-            QRgb value = scanLine[x + originx];
-            int basex = x * 4;
 
-            destRows[basex] = qRed(value);
-            destRows[basex + 1] = qGreen(value);
-            destRows[basex + 2] = qBlue(value);
-            destRows[basex + 3] = qAlpha(value);
+    quint32* destRows = reinterpret_cast<quint32*>(&data[desty * rect.width() + destx]);
+
+    if (multiplied == Unmultiplied) {
+        for (int y = 0; y < numRows; ++y) {
+            const quint32* scanLine = reinterpret_cast<const quint32*>(bits + (y + originy) * bytesPerLine);
+            for (int x = 0; x < numColumns; x++) {
+                QRgb pixel = scanLine[x + originx];
+                int alpha = qAlpha(pixel);
+                // Un-premultiply and convert RGB to BGR.
+                if (alpha == 255)
+                    destRows[x] = (0xFF000000
+                                | (qBlue(pixel) << 16)
+                                | (qGreen(pixel) << 8)
+                                | (qRed(pixel)));
+                else if (alpha > 0)
+                    destRows[x] = ((alpha << 24)
+                                | (((255 * qBlue(pixel)) / alpha)) << 16)
+                                | (((255 * qGreen(pixel)) / alpha) << 8)
+                                | ((255 * qRed(pixel)) / alpha);
+                else
+                    destRows[x] = 0;
+            }
+            destRows += rect.width();
+        }
+    } else {
+        for (int y = 0; y < numRows; ++y) {
+            const quint32* scanLine = reinterpret_cast<const quint32*>(bits + (y + originy) * bytesPerLine);
+            for (int x = 0; x < numColumns; x++) {
+                QRgb pixel = scanLine[x + originx];
+                // Convert RGB to BGR.
+                destRows[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
+
+            }
+            destRows += rect.width();
         }
-        destRows += destBytesPerRow;
     }
 
     return result;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list