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/qpaintengine_x11.cpp

    r2 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**
     
    147147// hack, so we don't have to make QRegion::clipRectangles() public or include
    148148// X11 headers in qregion.h
    149 Q_AUTOTEST_EXPORT void *qt_getClipRects(const QRegion &r, int &num)
     149Q_GUI_EXPORT void *qt_getClipRects(const QRegion &r, int &num)
    150150{
    151151    return r.clipRectangles(num);
     
    272272    if (size == allocated) {
    273273        allocated = qMax(2*allocated, 64);
    274         traps = (XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid));
     274        traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
    275275    }
    276276    traps[size].top = Q27Dot5ToXFixed(trap.top);
     
    483483    } else if (pdev->devType() == QInternal::Pixmap) {
    484484        const QPixmap *pm = static_cast<const QPixmap *>(pdev);
    485         QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data);
     485        QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
    486486        if (X11->use_xrender && data->depth() != 32 && data->x11_mask)
    487487            data->convertToARGB32();
     
    13661366                attrs.repeat = true;
    13671367                XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
    1368                 QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data);
     1368                QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
    13691369                if (data->mask_picture)
    13701370                    XRenderChangePicture(d->dpy, data->mask_picture, CPRepeat, &attrs);
     
    14031403#ifndef QT_NO_XRENDER
    14041404            if (d->pdev_depth == 32 && d->brush_pm.depth() != 32) {
    1405                 QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data);
     1405                d->brush_pm.detach();
     1406                QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
    14061407                brushData->convertToARGB32();
    14071408            }
     
    14091410            vals.tile = (d->brush_pm.depth() == d->pdev_depth
    14101411                         ? d->brush_pm.handle()
    1411                          : static_cast<QX11PixmapData*>(d->brush_pm.data)->x11ConvertToDefaultDepth());
     1412                         : static_cast<QX11PixmapData*>(d->brush_pm.data.data())->x11ConvertToDefaultDepth());
    14121413            s = FillTiled;
    14131414#if !defined(QT_NO_XRENDER)
     
    15441545                                             QPaintEngine::PolygonDrawMode mode)
    15451546{
     1547    Q_Q(QX11PaintEngine);
     1548
    15461549    int clippedCount = 0;
    15471550    qt_float_point *clippedPoints = 0;
     
    16181621#endif
    16191622        if (fill.style() != Qt::NoBrush) {
    1620             if (clippedCount > 0) {
     1623            if (clippedCount > 200000) {
     1624                QPolygon poly;
     1625                for (int i = 0; i < clippedCount; ++i)
     1626                    poly << QPoint(qFloor(clippedPoints[i].x), qFloor(clippedPoints[i].y));
     1627
     1628                const QRect bounds = poly.boundingRect();
     1629                const QRect aligned = bounds
     1630                    & QRect(QPoint(), QSize(pdev->width(), pdev->height()));
     1631
     1632                QImage img(aligned.size(), QImage::Format_ARGB32_Premultiplied);
     1633                img.fill(0);
     1634
     1635                QPainter painter(&img);
     1636                painter.translate(-aligned.x(), -aligned.y());
     1637                painter.setPen(Qt::NoPen);
     1638                painter.setBrush(fill);
     1639                if (gcMode == BrushGC)
     1640                    painter.setBrushOrigin(q->painter()->brushOrigin());
     1641                painter.drawPolygon(poly);
     1642                painter.end();
     1643
     1644                q->drawImage(aligned, img, img.rect(), Qt::AutoColor);
     1645            } else if (clippedCount > 0) {
    16211646                QVarLengthArray<XPoint> xpoints(clippedCount);
    16221647                for (int i = 0; i < clippedCount; ++i) {
     
    18031828
    18041829    QImage im;
    1805     if ((QSysInfo::ByteOrder == QSysInfo::BigEndian
    1806          && ((ImageByteOrder(X11->display) == LSBFirst) || bgr_layout))
    1807         || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
     1830    int image_byte_order = ImageByteOrder(X11->display);
     1831    if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
     1832        || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
     1833        || (image_byte_order == LSBFirst && bgr_layout))
    18081834    {
    18091835        im = image.copy(rect);
     
    18131839            uint *p = data;
    18141840            uint *end = p + w;
    1815             if (bgr_layout && ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
     1841            if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
    18161842                while (p < end) {
    18171843                    *p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
    18181844                    p++;
    18191845                }
    1820             } else if ((ImageByteOrder(X11->display) == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
    1821                     || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
     1846            } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
     1847                    || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
    18221848                while (p < end) {
    18231849                    *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
     
    18251851                    p++;
    18261852                }
    1827             } else if (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian) {
     1853            } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
     1854                       || (image_byte_order == LSBFirst && bgr_layout))
     1855            {
    18281856                while (p < end) {
    18291857                    *p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
     
    18891917
    18901918#ifndef QT_NO_XRENDER
    1891     ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data)->picture;
     1919    ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data.data())->picture;
    18921920    if (src_pict && d->picture) {
    18931921        const int pDepth = pixmap.depth();
     
    19081936    bool restore_clip = false;
    19091937
    1910     if (static_cast<QX11PixmapData*>(pixmap.data)->x11_mask) { // pixmap has a mask
     1938    if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) { // pixmap has a mask
    19111939        QBitmap comb(sw, sh);
    19121940        GC cgc = XCreateGC(d->dpy, comb.handle(), 0, 0);
     
    19251953        XSetTSOrigin(d->dpy, cgc, -sx, -sy);
    19261954        XSetStipple(d->dpy, cgc,
    1927                     static_cast<QX11PixmapData*>(pixmap.data)->x11_mask);
     1955                    static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask);
    19281956        XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
    19291957        XFreeGC(d->dpy, cgc);
     
    19681996    if (d->pdev->devType() == QInternal::Pixmap) {
    19691997        const QPixmap *px = static_cast<const QPixmap*>(d->pdev);
    1970         Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data)->x11_mask;
    1971         Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data)->x11_mask;
     1998        Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask;
     1999        Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data.data())->x11_mask;
    19722000        if (dst_mask) {
    19732001            GC cgc = XCreateGC(d->dpy, dst_mask, 0, 0);
     
    21882216    } else
    21892217#endif // !QT_NO_XRENDER
    2190         if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data)->x11_mask) {
     2218        if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
    21912219            XSetTile(d->dpy, d->gc, pixmap.handle());
    21922220            XSetFillStyle(d->dpy, d->gc, FillTiled);
     
    23532381        const QColor &pen = d->cpen.color();
    23542382        ::Picture src = X11->getSolidFill(d->scrn, pen);
    2355         XRenderPictFormat *maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
     2383        XRenderPictFormat *maskFormat = 0;
     2384        if (ft->xglyph_format != PictStandardA1)
     2385            maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
    23562386
    23572387        enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
     
    24312461    int num_rects = 0;
    24322462
     2463    QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
     2464    QRect clip(d->polygonClipper.boundingRect());
    24332465    for (int i=0; i < path.elementCount(); i+=5) {
    24342466        int x = qRound(path.elementAt(i).x);
     
    24362468        int w = qRound(path.elementAt(i+1).x) - x;
    24372469        int h = qRound(path.elementAt(i+2).y) - y;
    2438         rects[num_rects].x = x + qRound(d->matrix.dx());
    2439         rects[num_rects].y = y + qRound(d->matrix.dy());
    2440         rects[num_rects].width = w;
    2441         rects[num_rects].height = h;
     2470
     2471        QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
     2472        rect = rect.intersected(clip);
     2473        if (rect.isEmpty())
     2474            continue;
     2475
     2476        rects[num_rects].x = short(rect.x());
     2477        rects[num_rects].y = short(rect.y());
     2478        rects[num_rects].width = ushort(rect.width());
     2479        rects[num_rects].height = ushort(rect.height());
    24422480        ++num_rects;
    24432481        if (num_rects == rectcount) {
Note: See TracChangeset for help on using the changeset viewer.