Changeset 115 for trunk/src


Ignore:
Timestamp:
Aug 17, 2009, 7:06:32 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Added OS/2 support to QRasterWindowSurface and to QNativeImage (this gives us rendering of the widget contents in double-buffer mode).

Location:
trunk/src/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/image/qnativeimage.cpp

    r2 r115  
    141141}
    142142
     143#elif defined(Q_WS_PM)
     144
     145QNativeImage::QNativeImage(int width, int height, QImage::Format format,
     146                           bool isTextBuffer, QWidget *widget)
     147{
     148    image = QImage(width, height, format);
     149}
     150
     151QNativeImage::~QNativeImage()
     152{
     153}
     154
     155QImage::Format QNativeImage::systemFormat()
     156{
     157    // @todo support 8-bit indexed colors?
     158//  if (QColormap::instance().depth() == 16)
     159//      return QImage::Format_RGB16;
     160    return QImage::Format_RGB32;
     161}
    143162
    144163#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
  • trunk/src/gui/image/qnativeimage_p.h

    r2 r115  
    5656#include "qimage.h"
    5757
    58 #ifdef Q_WS_WIN
     58#if defined(Q_WS_WIN)
    5959#include "qt_windows.h"
    6060
     
    8484    static QImage::Format systemFormat();
    8585
    86 #ifdef Q_WS_WIN
     86#if defined(Q_WS_WIN)
    8787    HDC hdc;
    8888    HBITMAP bitmap;
  • trunk/src/gui/kernel/qwidget.cpp

    r112 r115  
    1035910359        qErrnoWarning("QWidget::releaseDC(): failed to release HDC");
    1036010360}
     10361#elif defined (Q_WS_PM)
     10362/*!
     10363    Returns the window system handle of the widget, for low-level
     10364    access. Using this function is not portable.
     10365
     10366    An HPS acquired with getPS() has to be released with releasePS().
     10367
     10368    \warning Using this function is not portable.
     10369*/
     10370HPS QWidget::getPS() const
     10371{
     10372    Q_D(const QWidget);
     10373    if (d->hd != NULLHANDLE)
     10374        return (HPS) d->hd;
     10375    return WinGetPS(winId());
     10376}
     10377
     10378/*!
     10379    Releases the HPS \a hdc acquired by a previous call to getPS().
     10380
     10381    \warning Using this function is not portable.
     10382*/
     10383void QWidget::releasePS(HPS hps) const
     10384{
     10385    Q_D(const QWidget);
     10386    // If there is a widget's own ps, the release operation is ignored because
     10387    // it will be released elsewhere. Otherwise, we assume that the given hps
     10388    // was acquired by WinGetPS in the getPS() call and release it.
     10389    if (d->hd == NULLHANDLE)
     10390        WinReleasePS(hps);
     10391}
    1036110392#else
    1036210393/*!
  • trunk/src/gui/kernel/qwidget.h

    r92 r115  
    583583    HDC getDC() const;
    584584    void releaseDC(HDC) const;
     585#elif defined(Q_WS_PM)
     586    HPS getPS() const;
     587    void releasePS(HPS) const;
    585588#else
    586589    Qt::HANDLE handle() const;
  • trunk/src/gui/painting/qwindowsurface_raster.cpp

    r2 r115  
    199199#endif
    200200
     201#endif
     202
     203#ifdef Q_WS_PM
     204    QRect br = rgn.boundingRect();
     205#if 1
     206    qDebug("QRasterWindowSurface::flush: [%s] br=%d,%d/%d,%d",
     207           QWidgetPrivate::name(widget).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
     214    // @todo check if it's really slower than flipping the image bits instead
     215    // @todo I guess we can use DIVE here; check it too
     216    MATRIXLF m;
     217    m.fxM11 = MAKEFIXED(1, 0);
     218    m.fxM12 = 0;
     219    m.lM13 = 0;
     220    m.fxM21 = 0;
     221    m.fxM22 = MAKEFIXED(-1, 0);
     222    m.lM23 = 0;
     223    m.lM31 = 0;
     224    m.lM32 = widget->height() - 1;
     225    GpiSetDefaultViewMatrix(wps, 8, &m, TRANSFORM_REPLACE);
     226
     227    QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
     228    QRect wbr = br.translated(-wOffset);
     229
     230    br.translate(offset);
     231
     232    BITMAPINFOHEADER2 bmh;
     233    memset(&bmh, 0, sizeof(BITMAPINFOHEADER2));
     234    bmh.cbFix = sizeof(BITMAPINFOHEADER2);
     235    bmh.cPlanes = 1;
     236    bmh.cBitCount = 32; // @todo support 8-bit indexed colors?
     237    bmh.cx = d->image->width();
     238    bmh.cy = d->image->height();
     239
     240    // Note: target is inclusive-inclusive, source is inclusive-exclusive
     241    POINTL ptls[] = { { wbr.left(), wbr.top() },
     242                      { wbr.right(), wbr.bottom() },
     243                      { br.left(), br.top() },
     244                      { br.right() + 1, br.bottom() + 1 } };
     245    GpiDrawBits(wps, (PVOID) d->image->image.bits(), (PBITMAPINFO2) &bmh, 4, ptls,
     246                ROP_SRCCOPY, BBO_IGNORE);
     247
     248    widget->releasePS(wps);
    201249#endif
    202250
Note: See TracChangeset for help on using the changeset viewer.