[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:30:48 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit fd93a01308412f9b6e33815528edcf3a9fcd11c6
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 21:17:44 2010 +0000
2010-07-27 Andreas Kling <andreas.kling at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] putImageData() optimizations
https://bugs.webkit.org/show_bug.cgi?id=43059
- Single-pass premultiplication and BGR->RGB conversion
- Use ARGB32PM for the temporary image so Qt calls the
fast Source composition function
* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::premultiply): Added (static inline)
(WebCore::putImageData):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64157 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 778048a..d1eeeae 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2010-07-27 Andreas Kling <andreas.kling at nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] putImageData() optimizations
+ https://bugs.webkit.org/show_bug.cgi?id=43059
+
+ - Single-pass premultiplication and BGR->RGB conversion
+ - Use ARGB32PM for the temporary image so Qt calls the
+ fast Source composition function
+
+ * platform/graphics/qt/ImageBufferQt.cpp:
+ (WebCore::premultiply): Added (static inline)
+ (WebCore::putImageData):
+
2010-07-27 Anders Carlsson <andersca at apple.com>
Reviewed by Sam Weinig.
diff --git a/WebCore/platform/graphics/qt/ImageBufferQt.cpp b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
index dcbc817..bd272db 100644
--- a/WebCore/platform/graphics/qt/ImageBufferQt.cpp
+++ b/WebCore/platform/graphics/qt/ImageBufferQt.cpp
@@ -237,6 +237,20 @@ PassRefPtr<ImageData> ImageBuffer::getPremultipliedImageData(const IntRect& rect
return getImageData<Premultiplied>(rect, m_data, m_size);
}
+static inline unsigned int premultiply(unsigned int x)
+{
+ unsigned int a = x >> 24;
+ unsigned int t = (x & 0xff00ff) * a;
+ t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
+ t &= 0xff00ff;
+
+ x = ((x >> 8) & 0xff) * a;
+ x = (x + ((x >> 8) & 0xff) + 0x80);
+ x &= 0xff00;
+ x |= t | (a << 24);
+ return x;
+}
+
template <Multiply multiplied>
void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint& destPoint, ImageBufferData& data, const IntSize& size)
{
@@ -268,22 +282,33 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
unsigned srcBytesPerRow = 4 * source->width();
- QRect destRect(destx, desty, endx - destx, endy - desty);
+ // NOTE: For unmultiplied input data, we do the premultiplication below.
+ QImage image(numColumns, numRows, QImage::Format_ARGB32_Premultiplied);
+ uchar* bits = image.bits();
+ const int bytesPerLine = image.bytesPerLine();
- QImage::Format format = multiplied == Unmultiplied ? QImage::Format_ARGB32 : QImage::Format_ARGB32_Premultiplied;
- QImage image(destRect.size(), format);
+ const quint32* srcScanLine = reinterpret_cast<const quint32*>(source->data()->data()->data() + originy * srcBytesPerRow + originx * 4);
- unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4;
- for (int y = 0; y < numRows; ++y) {
- quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y));
- for (int x = 0; x < numColumns; x++) {
- // ImageData stores the pixels in RGBA while QImage is ARGB
- quint32 pixel = reinterpret_cast<quint32*>(srcRows + 4 * x)[0];
- pixel = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
- scanLine[x] = pixel;
+ if (multiplied == Unmultiplied) {
+ for (int y = 0; y < numRows; ++y) {
+ quint32* destScanLine = reinterpret_cast<quint32*>(bits + y * bytesPerLine);
+ for (int x = 0; x < numColumns; x++) {
+ // Premultiply and convert BGR to RGB.
+ quint32 pixel = srcScanLine[x];
+ destScanLine[x] = premultiply(((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00));
+ }
+ srcScanLine += source->width();
+ }
+ } else {
+ for (int y = 0; y < numRows; ++y) {
+ quint32* destScanLine = reinterpret_cast<quint32*>(bits + y * bytesPerLine);
+ for (int x = 0; x < numColumns; x++) {
+ // Convert BGR to RGB.
+ quint32 pixel = srcScanLine[x];
+ destScanLine[x] = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
+ }
+ srcScanLine += source->width();
}
-
- srcRows += srcBytesPerRow;
}
bool isPainting = data.m_painter->isActive();
@@ -299,7 +324,7 @@ void putImageData(ImageData*& source, const IntRect& sourceRect, const IntPoint&
}
data.m_painter->setCompositionMode(QPainter::CompositionMode_Source);
- data.m_painter->drawImage(destRect, image);
+ data.m_painter->drawImage(destx, desty, image);
if (!isPainting)
data.m_painter->end();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list