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/qpainterpath_p.h

    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**
     
    8282{
    8383public:
    84     QVectorPathConverter(const QVector<QPainterPath::Element> &path, uint fillRule)
    85         : pathData(path, fillRule),
     84    QVectorPathConverter(const QVector<QPainterPath::Element> &path, uint fillRule, bool convex)
     85        : pathData(path, fillRule, convex),
    8686          path(pathData.points.data(), path.size(),
    8787               pathData.elements.data(), pathData.flags) {}
     
    9292
    9393    struct QVectorPathData {
    94         QVectorPathData(const QVector<QPainterPath::Element> &path, uint fillRule)
     94        QVectorPathData(const QVector<QPainterPath::Element> &path, uint fillRule, bool convex)
    9595            : elements(path.size()),
    9696              points(path.size() * 2),
     
    104104                points[ptsPos++] = e.y;
    105105                if (e.type == QPainterPath::CurveToElement)
    106                     flags |= QVectorPath::CurvedShapeHint;
     106                    flags |= QVectorPath::CurvedShapeMask;
    107107            }
    108108
     
    112112                flags |= QVectorPath::OddEvenFill;
    113113
     114            if (!convex)
     115                flags |= QVectorPath::NonConvexShapeMask;
    114116        }
    115117        QVarLengthArray<QPainterPath::ElementType> elements;
     
    125127};
    126128
    127 class Q_GUI_EXPORT QPainterPathData : public QPainterPathPrivate
     129class QPainterPathData : public QPainterPathPrivate
    128130{
    129131public:
    130132    QPainterPathData() :
    131         cStart(0), fillRule(Qt::OddEvenFill),
    132         dirtyBounds(false), dirtyControlBounds(false),
     133        cStart(0),
     134        fillRule(Qt::OddEvenFill),
     135        dirtyBounds(false),
     136        dirtyControlBounds(false),
    133137        pathConverter(0)
    134138    {
    135139        ref = 1;
    136140        require_moveTo = false;
     141        convex = false;
    137142    }
    138143
    139144    QPainterPathData(const QPainterPathData &other) :
    140145        QPainterPathPrivate(), cStart(other.cStart), fillRule(other.fillRule),
    141         dirtyBounds(other.dirtyBounds), bounds(other.bounds),
     146        bounds(other.bounds),
     147        controlBounds(other.controlBounds),
     148        dirtyBounds(other.dirtyBounds),
    142149        dirtyControlBounds(other.dirtyControlBounds),
    143         controlBounds(other.controlBounds),
     150        convex(other.convex),
    144151        pathConverter(0)
    145152    {
     
    159166    const QVectorPath &vectorPath() {
    160167        if (!pathConverter)
    161             pathConverter = new QVectorPathConverter(elements, fillRule);
     168            pathConverter = new QVectorPathConverter(elements, fillRule, convex);
    162169        return pathConverter->path;
    163170    }
     
    166173    Qt::FillRule fillRule;
    167174
    168     bool require_moveTo;
    169 
    170     bool   dirtyBounds;
    171175    QRectF bounds;
    172     bool   dirtyControlBounds;
    173176    QRectF controlBounds;
     177
     178    uint require_moveTo : 1;
     179    uint dirtyBounds : 1;
     180    uint dirtyControlBounds : 1;
     181    uint convex : 1;
    174182
    175183    QVectorPathConverter *pathConverter;
     
    177185
    178186
     187inline const QPainterPath QVectorPath::convertToPainterPath() const
     188{
     189        QPainterPath path;
     190        path.ensureData();
     191        QPainterPathData *data = path.d_func();
     192        data->elements.reserve(m_count);
     193        int index = 0;
     194        data->elements[0].x = m_points[index++];
     195        data->elements[0].y = m_points[index++];
     196
     197        if (m_elements) {
     198            data->elements[0].type = m_elements[0];
     199            for (int i=1; i<m_count; ++i) {
     200                QPainterPath::Element element;
     201                element.x = m_points[index++];
     202                element.y = m_points[index++];
     203                element.type = m_elements[i];
     204                data->elements << element;
     205            }
     206        } else {
     207            data->elements[0].type = QPainterPath::MoveToElement;
     208            for (int i=1; i<m_count; ++i) {
     209                QPainterPath::Element element;
     210                element.x = m_points[index++];
     211                element.y = m_points[index++];
     212                element.type = QPainterPath::LineToElement;
     213                data->elements << element;
     214            }
     215        }
     216
     217        if (m_hints & OddEvenFill)
     218            data->fillRule = Qt::OddEvenFill;
     219        else
     220            data->fillRule = Qt::WindingFill;
     221        return path;
     222}
    179223
    180224void Q_GUI_EXPORT qt_find_ellipse_coords(const QRectF &r, qreal angle, qreal length,
Note: See TracChangeset for help on using the changeset viewer.