Skip to content
Permalink
Browse files
2010-10-24 Andreas Kling <kling@webkit.org>
        Reviewed by Kenneth Rohde Christiansen.

        [Qt] ImageBuffer::platformTransformColorSpace is unnecessarily slow
        https://bugs.webkit.org/show_bug.cgi?id=48211

        Grab the QImage::bits() and do direct access instead of going through
        QImage::pixel() and QImage::setPixel().

        This is a performance optimization, so no new tests.

        * platform/graphics/qt/ImageBufferQt.cpp:
        (WebCore::ImageBuffer::platformTransformColorSpace):


Canonical link: https://commits.webkit.org/60961@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70424 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Oct 24, 2010
1 parent 2af06d3 commit 23a12864255cc6bebc8b0a45a331c630022af78a
Showing 2 changed files with 25 additions and 7 deletions.
@@ -1,3 +1,18 @@
2010-10-24 Andreas Kling <kling@webkit.org>

Reviewed by Kenneth Rohde Christiansen.

[Qt] ImageBuffer::platformTransformColorSpace is unnecessarily slow
https://bugs.webkit.org/show_bug.cgi?id=48211

Grab the QImage::bits() and do direct access instead of going through
QImage::pixel() and QImage::setPixel().

This is a performance optimization, so no new tests.

* platform/graphics/qt/ImageBufferQt.cpp:
(WebCore::ImageBuffer::platformTransformColorSpace):

2010-10-24 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.
@@ -157,14 +157,17 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
QImage image = m_data.m_pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
ASSERT(!image.isNull());

uchar* bits = image.bits();
const int bytesPerLine = image.bytesPerLine();

for (int y = 0; y < m_size.height(); ++y) {
for (int x = 0; x < m_size.width(); x++) {
QRgb value = image.pixel(x, y);
value = qRgba(lookUpTable[qRed(value)],
lookUpTable[qGreen(value)],
lookUpTable[qBlue(value)],
qAlpha(value));
image.setPixel(x, y, value);
quint32* scanLine = reinterpret_cast_ptr<quint32*>(bits + y * bytesPerLine);
for (int x = 0; x < m_size.width(); ++x) {
QRgb& pixel = scanLine[x];
pixel = qRgba(lookUpTable[qRed(pixel)],
lookUpTable[qGreen(pixel)],
lookUpTable[qBlue(pixel)],
qAlpha(pixel));
}
}

0 comments on commit 23a1286

Please sign in to comment.