summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/painting/qpainter.cpp')
-rw-r--r--src/gui/painting/qpainter.cpp68
1 files changed, 36 insertions, 32 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 51c0f3e22a..2c5e0672b1 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1,31 +1,37 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** 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:LGPL21$
+** $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 http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** 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 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** 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.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** 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$
**
@@ -397,8 +403,7 @@ void QPainterPrivate::draw_helper(const QPainterPath &originalPath, DrawOperatio
if (q->hasClipping()) {
bool hasPerspectiveTransform = false;
- for (int i = 0; i < state->clipInfo.size(); ++i) {
- const QPainterClipInfo &info = state->clipInfo.at(i);
+ for (const QPainterClipInfo &info : qAsConst(state->clipInfo)) {
if (info.matrix.type() == QTransform::TxProject) {
hasPerspectiveTransform = true;
break;
@@ -1629,8 +1634,7 @@ void QPainter::restore()
tmp->clipPath = QPainterPath();
d->engine->updateState(*tmp);
// replay the list of clip states,
- for (int i=0; i<d->state->clipInfo.size(); ++i) {
- const QPainterClipInfo &info = d->state->clipInfo.at(i);
+ for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
tmp->matrix = info.matrix;
tmp->matrix *= d->state->redirectionMatrix;
tmp->clipOperation = info.operation;
@@ -2464,7 +2468,7 @@ void QPainter::setClipping(bool enable)
// we can't enable clipping if we don't have a clip
if (enable
- && (d->state->clipInfo.isEmpty() || d->state->clipInfo.last().operation == Qt::NoClip))
+ && (d->state->clipInfo.isEmpty() || d->state->clipInfo.constLast().operation == Qt::NoClip))
return;
d->state->clipEnabled = enable;
@@ -2505,8 +2509,7 @@ QRegion QPainter::clipRegion() const
const_cast<QPainter *>(this)->d_ptr->updateInvMatrix();
// ### Falcon: Use QPainterPath
- for (int i=0; i<d->state->clipInfo.size(); ++i) {
- const QPainterClipInfo &info = d->state->clipInfo.at(i);
+ for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
switch (info.clipType) {
case QPainterClipInfo::RegionClip: {
@@ -2620,7 +2623,7 @@ QPainterPath QPainter::clipPath() const
}
// No clip, return empty
- if (d->state->clipInfo.size() == 0) {
+ if (d->state->clipInfo.isEmpty()) {
return QPainterPath();
} else {
@@ -2672,9 +2675,9 @@ QRectF QPainter::clipBoundingRect() const
// precise, but it fits within the guarantee and it is reasonably
// fast.
QRectF bounds;
- for (int i=0; i<d->state->clipInfo.size(); ++i) {
+ bool first = true;
+ for (const QPainterClipInfo &info : qAsConst(d->state->clipInfo)) {
QRectF r;
- const QPainterClipInfo &info = d->state->clipInfo.at(i);
if (info.clipType == QPainterClipInfo::RectClip)
r = info.rect;
@@ -2687,10 +2690,11 @@ QRectF QPainter::clipBoundingRect() const
r = info.matrix.mapRect(r);
- if (i == 0)
+ if (first)
bounds = r;
else if (info.operation == Qt::IntersectClip)
bounds &= r;
+ first = false;
}
@@ -2738,7 +2742,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op)
d->extended->clip(vp, op);
if (op == Qt::ReplaceClip || op == Qt::NoClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));
d->state->clipOperation = op;
return;
}
@@ -2787,7 +2791,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op)
d->extended->clip(rect, op);
if (op == Qt::ReplaceClip || op == Qt::NoClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));
d->state->clipOperation = op;
return;
}
@@ -2799,7 +2803,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op)
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(rect, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(rect, op, d->state->matrix));
d->state->clipEnabled = true;
d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled;
d->updateState(d->state);
@@ -2846,7 +2850,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
d->extended->clip(r, op);
if (op == Qt::NoClip || op == Qt::ReplaceClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(r, op, d->state->matrix));
d->state->clipOperation = op;
return;
}
@@ -2858,7 +2862,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(r, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(r, op, d->state->matrix));
d->state->clipEnabled = true;
d->state->dirtyFlags |= QPaintEngine::DirtyClipRegion | QPaintEngine::DirtyClipEnabled;
d->updateState(d->state);
@@ -3250,7 +3254,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
d->extended->clip(path, op);
if (op == Qt::NoClip || op == Qt::ReplaceClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(path, op, d->state->matrix));
d->state->clipOperation = op;
return;
}
@@ -3262,7 +3266,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op)
d->state->clipOperation = op;
if (op == Qt::NoClip || op == Qt::ReplaceClip)
d->state->clipInfo.clear();
- d->state->clipInfo << QPainterClipInfo(path, op, d->state->matrix);
+ d->state->clipInfo.append(QPainterClipInfo(path, op, d->state->matrix));
d->state->clipEnabled = true;
d->state->dirtyFlags |= QPaintEngine::DirtyClipPath | QPaintEngine::DirtyClipEnabled;
d->updateState(d->state);