Changeset 62782 in webkit


Ignore:
Timestamp:
Jul 8, 2010 5:38:12 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-08 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Simon Hausmann.

[Qt] Canvas putImageData() resets painter state
https://bugs.webkit.org/show_bug.cgi?id=41827

Added a test to verify that the painting state remains intact after calling putImageData().

  • fast/canvas/canvas-state-intact-after-putImageData-expected.txt: Added.
  • fast/canvas/canvas-state-intact-after-putImageData.html: Added.
  • fast/canvas/script-tests/canvas-state-intact-after-putImageData.js: Added.

2010-07-08 Andreas Kling <andreas.kling@nokia.com>

Reviewed by Simon Hausmann.

[Qt] Canvas putImageData() resets painter state
https://bugs.webkit.org/show_bug.cgi?id=41827

Use drawImage() to copy pixels in putImageData() instead of QPixmap::operator=

Test: fast/canvas/canvas-state-intact-after-putImageData.html

  • platform/graphics/qt/ImageBufferQt.cpp: (WebCore::putImageData):
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62779 r62782  
     12010-07-08  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Canvas putImageData() resets painter state
     6        https://bugs.webkit.org/show_bug.cgi?id=41827
     7
     8        Added a test to verify that the painting state remains intact after calling putImageData().
     9
     10        * fast/canvas/canvas-state-intact-after-putImageData-expected.txt: Added.
     11        * fast/canvas/canvas-state-intact-after-putImageData.html: Added.
     12        * fast/canvas/script-tests/canvas-state-intact-after-putImageData.js: Added.
     13
    1142010-07-08  Justin Schuh  <jschuh@chromium.org>
    215
  • trunk/WebCore/ChangeLog

    r62781 r62782  
     12010-07-08  Andreas Kling  <andreas.kling@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Canvas putImageData() resets painter state
     6        https://bugs.webkit.org/show_bug.cgi?id=41827
     7
     8        Use drawImage() to copy pixels in putImageData() instead of QPixmap::operator=
     9
     10        Test: fast/canvas/canvas-state-intact-after-putImageData.html
     11
     12        * platform/graphics/qt/ImageBufferQt.cpp:
     13        (WebCore::putImageData):
     14
    1152010-07-08  Andrey Kosyakov  <caseq@chromium.org>
    216
  • trunk/WebCore/platform/graphics/qt/ImageBufferQt.cpp

    r60675 r62782  
    235235    unsigned srcBytesPerRow = 4 * source->width();
    236236
    237     bool isPainting = data.m_painter->isActive();
    238     if (isPainting)
    239         data.m_painter->end();
    240 
    241     QImage image = data.m_pixmap.toImage();
    242     if (multiplied == Unmultiplied)
    243         image = image.convertToFormat(QImage::Format_ARGB32);
    244     else
    245         image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
     237    QRect destRect(destx, desty, endx - destx, endy - desty);
     238
     239    QImage::Format format = multiplied == Unmultiplied ? QImage::Format_ARGB32 : QImage::Format_ARGB32_Premultiplied;
     240    QImage image(destRect.size(), format);
    246241
    247242    unsigned char* srcRows = source->data()->data()->data() + originy * srcBytesPerRow + originx * 4;
    248243    for (int y = 0; y < numRows; ++y) {
    249         quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y + desty));
     244        quint32* scanLine = reinterpret_cast<quint32*>(image.scanLine(y));
    250245        for (int x = 0; x < numColumns; x++) {
    251246            // ImageData stores the pixels in RGBA while QImage is ARGB
    252247            quint32 pixel = reinterpret_cast<quint32*>(srcRows + 4 * x)[0];
    253248            pixel = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00);
    254             scanLine[x + destx] = pixel;
     249            scanLine[x] = pixel;
    255250        }
    256251
     
    258253    }
    259254
    260     data.m_pixmap = QPixmap::fromImage(image);
    261 
    262     if (isPainting)
     255    bool isPainting = data.m_painter->isActive();
     256    if (!isPainting)
    263257        data.m_painter->begin(&data.m_pixmap);
     258    else {
     259        data.m_painter->save();
     260
     261        // putImageData() should be unaffected by painter state
     262        data.m_painter->resetTransform();
     263        data.m_painter->setOpacity(1.0);
     264        data.m_painter->setClipping(false);
     265    }
     266
     267    data.m_painter->setCompositionMode(QPainter::CompositionMode_Source);
     268    data.m_painter->drawImage(destRect, image);
     269
     270    if (!isPainting)
     271        data.m_painter->end();
     272    else
     273        data.m_painter->restore();
    264274}
    265275
Note: See TracChangeset for help on using the changeset viewer.