Changeset 308 for trunk/src


Ignore:
Timestamp:
Nov 10, 2009, 1:49:03 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Use manual image flipping (from Qt to PM) instead of setting the world transformation matrix. Added a simple pixel/ms counter for measurements.

Location:
trunk/src/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r307 r308  
    390390        displayPS = 0;
    391391    }
     392
     393#ifdef QT_LOG_BLITSPEED
     394    extern unsigned long long qt_total_blit_ms;
     395    extern unsigned long long qt_total_blit_pixels;
     396    printf("*** qt_total_blit_ms %llu\n"
     397           "*** qt_total_blit_pixels %llu\n"
     398           "*** speed %llu pixels/ms",
     399           qt_total_blit_ms, qt_total_blit_pixels,
     400           qt_total_blit_pixels / qt_total_blit_ms);
     401#endif
    392402}
    393403
  • trunk/src/gui/painting/qwindowsurface_raster.cpp

    r143 r308  
    6666#endif
    6767
     68#if defined(Q_WS_PM) && defined(QT_LOG_BLITSPEED)
     69#include <InnotekLIBC/FastInfoBlocks.h>
     70#endif
     71
    6872QT_BEGIN_NAMESPACE
    6973
    7074#ifdef Q_WS_WIN
    7175PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect;
     76#endif
     77
     78#if defined(Q_WS_PM) && defined(QT_LOG_BLITSPEED)
     79unsigned long long qt_total_blit_ms = 0;
     80unsigned long long qt_total_blit_pixels = 0;
    7281#endif
    7382
     
    203212#ifdef Q_WS_PM
    204213    QRect br = rgn.boundingRect();
     214
     215    HPS wps = widget->getPS();
     216
    205217#if 0
    206     qDebug("QRasterWindowSurface::flush: [%s] br=%d,%d/%d,%d",
     218    qDebug("QRasterWindowSurface::flush: [%s] wps %x br %d,%d/%d,%d",
     219           qWidgetName(widget).toUtf8().constData(), (unsigned int)wps,
     220           br.x(), br.y(), br.width(), br.height());
     221#endif
     222
     223#ifdef QT_LOG_BLITSPEED
     224    unsigned long ticks = fibGetMsCount();
     225#endif
     226
     227#if 1
     228    // flip the image vertically for PM
     229    QImage img = d->image->image.mirrored();
     230
     231    QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
     232    QRect wbr = br.translated(-wOffset);
     233
     234    br.translate(offset);
     235
     236    BITMAPINFOHEADER2 bmh;
     237    memset(&bmh, 0, sizeof(BITMAPINFOHEADER2));
     238    bmh.cbFix = sizeof(BITMAPINFOHEADER2);
     239    bmh.cPlanes = 1;
     240    bmh.cBitCount = 32; // @todo support 8-bit indexed colors?
     241    bmh.cx = img.width();
     242    bmh.cy = img.height();
     243
     244    int wh = widget->height();
     245    int ih = img.height();
     246
     247    // Note: target is inclusive-inclusive, source is inclusive-exclusive
     248    POINTL ptls[] = { { wbr.left(), wh - wbr.bottom() - 1 },
     249                      { wbr.right(), wh - wbr.top() - 1 },
     250                      { br.left(), ih - br.bottom() - 1 },
     251                      { br.right() + 1, ih - br.top() } };
     252#if 0
     253    qDebug("QRasterWindowSurface::flush: [%s] ptls %ld,%ld-%ld,%ld %ld,%ld-%ld,%ld",
    207254           qWidgetName(widget).toUtf8().constData(),
    208            br.x(), br.y(), br.width(), br.height());
    209 #endif
    210 
    211     HPS wps = widget->getPS();
    212 
    213     // use the reflection + transformation matrix to flip the y axis
     255           ptls[0].x, ptls[0].y, ptls[1].x, ptls[1].y,
     256           ptls[2].x, ptls[2].y, ptls[3].x, ptls[3].y);
     257#endif
     258    GpiDrawBits(wps, (PVOID) img.bits(), (PBITMAPINFO2) &bmh, 4, ptls,
     259                ROP_SRCCOPY, BBO_IGNORE);
     260#else
     261    // use the reflection + transformation matrix to flip the y axis.
     262    // This should be slower than flipping the image ourselves (unless this
     263    // particular matrix is recognized by the driver which then enters some
     264    // special mode that doesn't require any flipping at all but uses the
     265    // image as is) hence disabled for now.
    214266    // @todo check if it's really slower than flipping the image bits instead
    215267    // @todo I guess we can use DIVE here; check it too
     
    246298                ROP_SRCCOPY, BBO_IGNORE);
    247299
     300#ifndef QT_NO_DEBUG
     301    // for debug flushing
     302    const QImage img = d->image->image;
     303#endif
     304#endif
     305
    248306    widget->releasePS(wps);
    249 #endif
     307
     308#ifdef QT_LOG_BLITSPEED
     309    ticks = fibGetMsCount() - ticks;
     310    qt_total_blit_ms += ticks;
     311    qt_total_blit_pixels += br.width() * br.height();
     312#endif
     313
     314#ifndef QT_NO_DEBUG
     315    static bool flush = !qgetenv("QT_FLUSH_WINDOWSURFACE").isEmpty();
     316    if (flush) {
     317        HPS dps = qt_display_ps();
     318        RECTL rcl = { 10, 50, 10 + img.width() + 2, 50 + img.height() + 2 };
     319        WinDrawBorder(dps, &rcl, 1, 1, CLR_BLACK, CLR_BLACK, 0);
     320        POINTL ptls[] = { { 11, 51, },
     321                          { 11 + img.width() - 1, 51 + img.height() - 1 },
     322                          { 0, 0 },
     323                          { img.width(), img.height() } };
     324        GpiDrawBits(dps, (PVOID) img.bits(), (PBITMAPINFO2) &bmh, 4, ptls,
     325                    ROP_SRCCOPY, BBO_IGNORE);
     326    }
     327#endif
     328
     329#endif // Q_WS_PM
    250330
    251331#ifdef Q_WS_X11
Note: See TracChangeset for help on using the changeset viewer.