Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/painting/qwindowsurface_raster.cpp

    r437 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4444#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
    4545#ifdef Q_WS_WIN
     46#include <qlibrary.h>
    4647#include <qt_windows.h>
    4748#endif
     
    8081QT_BEGIN_NAMESPACE
    8182
    82 #ifdef Q_WS_WIN
    83 PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect;
    84 #endif
    85 
    8683#if defined(Q_WS_PM) && defined(QT_LOG_BLITSPEED)
    8784unsigned long long qt_total_blit_ms = 0;
     
    9996    uint translucentBackground : 1;
    10097#endif
    101 #endif
    102 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
    103     uint canUseLayeredWindow : 1;
    10498#endif
    10599    uint inSetGeometry : 1;
     
    116110#endif
    117111#endif
    118 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
    119     d_ptr->canUseLayeredWindow = ptrUpdateLayeredWindowIndirect
    120         && (qt_widget_private(window)->data.window_flags & Qt::FramelessWindowHint);
    121 #endif
    122112    d_ptr->image = 0;
    123113    d_ptr->inSetGeometry = false;
     
    133123    if (d_ptr->image)
    134124        delete d_ptr->image;
    135 
    136     delete d_ptr;
    137125}
    138126
     
    145133void QRasterWindowSurface::beginPaint(const QRegion &rgn)
    146134{
    147 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_OS_WINCE))
    148     if (!qt_widget_private(window())->isOpaque) {
    149 #if defined(Q_WS_WIN) && !defined(Q_OS_WINCE)
    150         if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied
    151             && d_ptr->canUseLayeredWindow)
     135#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
     136    if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
     137#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
     138        if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied)
    152139            prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
    153140#endif
     
    160147        }
    161148    }
    162 #endif
    163 #if defined(Q_OS_WINCE)
     149#else
    164150    Q_UNUSED(rgn);
    165151#endif
     
    172158    // Not ready for painting yet, bail out. This can happen in
    173159    // QWidget::create_sys()
    174     if (!d->image)
     160    if (!d->image || rgn.rectCount() == 0)
    175161        return;
    176162
     
    178164    QRect br = rgn.boundingRect();
    179165
    180 #ifndef Q_OS_WINCE
    181     if (!qt_widget_private(window())->isOpaque && d->canUseLayeredWindow) {
     166#ifndef Q_WS_WINCE
     167    if (!qt_widget_private(window())->isOpaque
     168        && window()->testAttribute(Qt::WA_TranslucentBackground)
     169        && (qt_widget_private(window())->data.window_flags & Qt::FramelessWindowHint))
     170    {
    182171        QRect r = window()->frameGeometry();
    183172        QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft();
     
    187176        POINT ptDst = {r.x(), r.y()};
    188177        POINT ptSrc = {0, 0};
    189         Q_BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * window()->windowOpacity()), Q_AC_SRC_ALPHA};
     178        BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * window()->windowOpacity()), Q_AC_SRC_ALPHA};
    190179        RECT dirty = {dirtyRect.x(), dirtyRect.y(),
    191180            dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
    192181        Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, d->image->hdc, &ptSrc, 0, &blend, Q_ULW_ALPHA, &dirty};
    193 
    194         (*ptrUpdateLayeredWindowIndirect)(window()->internalWinId(), &info);
     182        ptrUpdateLayeredWindowIndirect(window()->internalWinId(), &info);
    195183    } else
    196184#endif
     
    395383    QRect wbr = wrgn.boundingRect();
    396384
    397     int num;
    398     XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
    399     XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
     385    if (wrgn.rectCount() != 1) {
     386        int num;
     387        XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
     388        XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
     389    }
    400390
    401391    QRect br = rgn.boundingRect().translated(offset);
     
    405395                  br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y());
    406396        XSync(X11->display, False);
     397    } else if (d_ptr->image->xshmimg) {
     398        const QImage &src = d->image->image;
     399        br = br.intersected(src.rect());
     400        XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
     401                     br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False);
     402        XSync(X11->display, False);
    407403    } else
    408404#endif
     
    410406        const QImage &src = d->image->image;
    411407        br = br.intersected(src.rect());
    412         if (src.format() != QImage::Format_RGB32) {
     408        if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) {
     409            Q_ASSERT(src.depth() >= 16);
     410            const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8),
     411                                 br.width(), br.height(), src.bytesPerLine(), src.format());
    413412            QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
    414413            data->xinfo = widget->x11Info();
    415             data->fromImage(src, Qt::AutoColor);
     414            data->fromImage(sub_src, Qt::NoOpaqueDetection);
    416415            QPixmap pm = QPixmap(data);
    417             XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, br.x() , br.y() , br.width(), br.height(), wbr.x(), wbr.y());
     416            XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wbr.x(), wbr.y());
    418417        } else {
    419418            // qpaintengine_x11.cpp
     
    422421        }
    423422    }
     423
     424    if (wrgn.rectCount() != 1)
     425        XSetClipMask(X11->display, d_ptr->gc, XNone);
    424426#endif // FALCON
    425427
     
    430432//     d->image->image.save("flush.png");
    431433
     434    Q_UNUSED(offset);
    432435    // Get a context for the widget.
    433436#ifndef QT_MAC_USE_COCOA
     
    476479#endif
    477480#endif
     481
     482#ifdef Q_OS_SYMBIAN
     483    Q_UNUSED(widget);
     484    Q_UNUSED(rgn);
     485    Q_UNUSED(offset);
     486#endif
    478487}
    479488
     
    484493    d->inSetGeometry = true;
    485494    if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) {
    486 #if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_OS_WINCE))
     495#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
    487496#ifndef Q_WS_WIN
    488497        if (d_ptr->translucentBackground)
    489498#else
    490         if (!qt_widget_private(window())->isOpaque && d->canUseLayeredWindow)
     499        if (!qt_widget_private(window())->isOpaque)
    491500#endif
    492501            prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
Note: See TracChangeset for help on using the changeset viewer.