diff options
Diffstat (limited to 'src/gui/painting/qregion.cpp')
-rw-r--r-- | src/gui/painting/qregion.cpp | 69 |
1 files changed, 17 insertions, 52 deletions
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index df1f2575fe..8b712ee46d 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qregion.h" #include "qpainterpath.h" @@ -48,6 +12,7 @@ #include "qbitmap.h" #include "qtransform.h" +#include <memory> #include <private/qdebug_p.h> #ifdef Q_OS_WIN @@ -86,7 +51,7 @@ QT_BEGIN_NAMESPACE contains() a QPoint or QRect. The bounding rectangle can be found with boundingRect(). - Iteration over the region (with begin(), end(), or C++11 + Iteration over the region (with begin(), end(), or ranged-for loops) gives a decomposition of the region into rectangles. @@ -300,7 +265,7 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt quint32 n; s >> n; QRect r; - for (int i=0; i<(int)n; i++) { + for (int i=0; i < static_cast<int>(n); i++) { s >> r; rgn = rgn.united(QRegion(r)); } @@ -349,19 +314,19 @@ QDataStream &operator<<(QDataStream &s, const QRegion &r) { auto b = r.begin(), e = r.end(); if (b == e) { - s << (quint32)0; + s << static_cast<quint32>(0); } else { const auto size = e - b; if (s.version() == 1) { for (auto i = size - 1; i > 0; --i) { - s << (quint32)(12 + i * 24); - s << (int)QRGN_OR; + s << static_cast<quint32>(12 + i * 24); + s << static_cast<int>(QRGN_OR); } for (auto it = b; it != e; ++it) - s << (quint32)(4+8) << (int)QRGN_SETRECT << *it; + s << static_cast<quint32>(4+8) << static_cast<int>(QRGN_SETRECT) << *it; } else { s << quint32(4 + 4 + 16 * size); // 16: storage size of QRect - s << (qint32)QRGN_RECTS; + s << static_cast<qint32>(QRGN_RECTS); s << quint32(size); for (auto it = b; it != e; ++it) s << *it; @@ -671,7 +636,7 @@ bool QRegion::intersects(const QRegion ®ion) const */ -#if !defined (Q_OS_UNIX) && !defined (Q_OS_WIN) || defined(Q_CLANG_QDOC) +#if !defined (Q_OS_UNIX) && !defined (Q_OS_WIN) || defined(Q_QDOC) /* \overload \since 4.4 @@ -3226,8 +3191,7 @@ static void CreateETandAET(int count, const QPoint *pts, int iSLLBlock = 0; int dy; - if (count < 2) - return; + Q_ASSERT(count > 1); /* * initialize the Active Edge Table @@ -3569,10 +3533,11 @@ static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule) int fixWAET = false; POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */ FirstPtBlock.pts = reinterpret_cast<QPoint *>(FirstPtBlock.data); + FirstPtBlock.next = nullptr; POINTBLOCK *tmpPtBlock; int numFullPtBlocks = 0; - Q_ASSUME(Count > 1); + Q_ASSERT(Count > 1); region = new QRegionPrivate; @@ -3852,7 +3817,7 @@ QRegion::QRegion(const QRect &r, RegionType t) QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule) { - if (a.count() > 2) { + if (a.size() > 2) { QRegionPrivate *qt_rgn = PolygonRegion(a.constData(), a.size(), fillRule == Qt::WindingFill ? WindingRule : EvenOddRule); if (qt_rgn) { @@ -3914,7 +3879,7 @@ QRegion &QRegion::operator=(const QRegion &r) QRegion QRegion::copy() const { QRegion r; - QScopedPointer<QRegionData> x(new QRegionData); + auto x = std::make_unique<QRegionData>(); x->ref.initializeOwned(); if (d->qt_rgn) x->qt_rgn = new QRegionPrivate(*d->qt_rgn); @@ -3922,7 +3887,7 @@ QRegion QRegion::copy() const x->qt_rgn = new QRegionPrivate; if (!r.d->ref.deref()) cleanUp(r.d); - r.d = x.take(); + r.d = x.release(); return r; } |