Changeset 146206 in webkit


Ignore:
Timestamp:
Mar 19, 2013, 8:39:46 AM (12 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt] Make ImageDiff similar to Chromium's ImageDiff
https://bugs.webkit.org/show_bug.cgi?id=94782

Based on patch by Csaba Osztrogonác.
Reviewed by Jocelyn Turcotte.

The diff image is generated with bright red indicating errors, but letting the base image
shine through so the context of the error-pixel can be identified.

  • DumpRenderTree/qt/ImageDiff.cpp:

(main):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r146197 r146206  
     12013-03-19  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] Make ImageDiff similar to Chromium's ImageDiff
     4        https://bugs.webkit.org/show_bug.cgi?id=94782
     5
     6        Based on patch by Csaba Osztrogonác.
     7        Reviewed by Jocelyn Turcotte.
     8
     9        The diff image is generated with bright red indicating errors, but letting the base image
     10        shine through so the context of the error-pixel can be identified.
     11
     12        * DumpRenderTree/qt/ImageDiff.cpp:
     13        (main):
     14
    1152013-03-18  Andras Becsi  <andras.becsi@digia.com>
    216
  • trunk/Tools/ImageDiff/qt/ImageDiff.cpp

    r139727 r146206  
    3232    QCoreApplication app(argc, argv);
    3333
    34     qreal tolerance = 0;
     34    qreal tolerance = 0; // Tolerated percentage of error pixels.
    3535
    3636    QStringList args = app.arguments();
     
    9494                QImage diffImage(w, h, QImage::Format_ARGB32);
    9595
    96                 int count = 0;
    97                 qreal sum = 0;
    98                 qreal maxDistance = 0;
     96                int errorCount = 0;
    9997
    100                 for (int x = 0; x < w; ++x)
     98                for (int x = 0; x < w; ++x) {
    10199                    for (int y = 0; y < h; ++y) {
    102100                        QRgb pixel = actualImage.pixel(x, y);
     
    107105                        qreal alpha = (qAlpha(pixel) - qAlpha(basePixel)) / static_cast<float>(qMax(255 - qAlpha(basePixel), qAlpha(basePixel)));
    108106                        qreal distance = qSqrt(red * red + green * green + blue * blue + alpha * alpha) / 2.0f;
    109                         int gray = distance * qreal(255);
    110                         diffImage.setPixel(x, y, qRgb(gray, gray, gray));
    111107                        if (distance >= 1 / qreal(255)) {
    112                             count++;
    113                             sum += distance;
    114                             maxDistance = qMax(maxDistance, distance);
    115                         }
     108                            errorCount++;
     109                            diffImage.setPixel(x, y, qRgb(255, 0, 0));
     110                        } else
     111                            diffImage.setPixel(x, y, qRgba(qRed(basePixel), qGreen(basePixel), qBlue(basePixel), qAlpha(basePixel) * 0.5));
     112                    }
    116113                }
    117114
    118115                qreal difference = 0;
    119                 if (count)
    120                     difference = 100 * sum / static_cast<qreal>(w * h);
    121                 if (difference <= tolerance) {
    122                     difference = 0;
    123                 } else {
    124                     difference = qRound(difference * 100) / 100.0f;
    125                     difference = qMax(difference, qreal(0.01));
    126                 }
     116                if (errorCount)
     117                    difference = 100 * errorCount / static_cast<qreal>(w * h);
    127118
    128                 if (!difference)
     119                if (difference <= tolerance)
    129120                    fprintf(stdout, "diff: %01.2f%% passed\n", difference);
    130121                else {
Note: See TracChangeset for help on using the changeset viewer.