diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 11 | ||||
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 31 | ||||
-rw-r--r-- | src/gui/painting/qpathclipper.cpp | 16 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 4 |
4 files changed, 31 insertions, 31 deletions
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8defcfb28d..6472481e7a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2186,11 +2186,10 @@ void QPainter::setBrushOrigin(const QPointF &p) destination pixel in such a way that the alpha component of the source defines the translucency of the pixel. - When the paint device is a QImage, the image format must be set to - \l {QImage::Format}{Format_ARGB32_Premultiplied} or - \l {QImage::Format}{Format_ARGB32} for the composition modes to have - any effect. For performance the premultiplied version is the preferred - format. + Several composition modes require an alpha channel in the source or + target images to have an effect. For optimal performance the + image format \l {QImage::Format}{Format_ARGB32_Premultiplied} is + preferred. When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing. @@ -2469,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; diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 7072a2d79c..7dbc83b338 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -690,7 +690,7 @@ void QPainterPath::moveTo(const QPointF &p) d->require_moveTo = false; - if (d->elements.last().type == MoveToElement) { + if (d->elements.constLast().type == MoveToElement) { d->elements.last().x = p.x(); d->elements.last().y = p.y(); } else { @@ -738,7 +738,7 @@ void QPainterPath::lineTo(const QPointF &p) QPainterPathData *d = d_func(); Q_ASSERT(!d->elements.isEmpty()); d->maybeMoveTo(); - if (p == QPointF(d->elements.last())) + if (p == QPointF(d->elements.constLast())) return; Element elm = { p.x(), p.y(), LineToElement }; d->elements.append(elm); @@ -801,7 +801,7 @@ void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF & // Abort on empty curve as a stroker cannot handle this and the // curve is irrelevant anyway. - if (d->elements.last() == c1 && c1 == c2 && c2 == e) + if (d->elements.constLast() == c1 && c1 == c2 && c2 == e) return; d->maybeMoveTo(); @@ -984,7 +984,7 @@ QPointF QPainterPath::currentPosition() const { return !d_ptr || d_func()->elements.isEmpty() ? QPointF() - : QPointF(d_func()->elements.last().x, d_func()->elements.last().y); + : QPointF(d_func()->elements.constLast().x, d_func()->elements.constLast().y); } @@ -1073,7 +1073,7 @@ void QPainterPath::addPolygon(const QPolygonF &polygon) d_func()->elements.reserve(d_func()->elements.size() + polygon.size()); - moveTo(polygon.first()); + moveTo(polygon.constFirst()); for (int i=1; i<polygon.size(); ++i) { Element elm = { polygon.at(i).x(), polygon.at(i).y(), LineToElement }; d_func()->elements << elm; @@ -1178,12 +1178,12 @@ void QPainterPath::addText(const QPointF &point, const QFont &f, const QString & QVarLengthArray<int> visualOrder(nItems); QVarLengthArray<uchar> levels(nItems); for (int i = 0; i < nItems; ++i) - levels[i] = eng->layoutData->items[i].analysis.bidiLevel; + levels[i] = eng->layoutData->items.at(i).analysis.bidiLevel; QTextEngine::bidiReorder(nItems, levels.data(), visualOrder.data()); for (int i = 0; i < nItems; ++i) { int item = visualOrder[i]; - QScriptItem &si = eng->layoutData->items[item]; + const QScriptItem &si = eng->layoutData->items.at(item); if (si.analysis.flags < QScriptAnalysis::TabOrObject) { QGlyphLayout glyphs = eng->shapedGlyphs(&si); @@ -1230,7 +1230,7 @@ void QPainterPath::addPath(const QPainterPath &other) QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func()); // Remove last moveto so we don't get multiple moveto's - if (d->elements.last().type == MoveToElement) + if (d->elements.constLast().type == MoveToElement) d->elements.remove(d->elements.size()-1); // Locate where our own current subpath will start after the other path is added. @@ -1261,7 +1261,7 @@ void QPainterPath::connectPath(const QPainterPath &other) QPainterPathData *d = reinterpret_cast<QPainterPathData *>(d_func()); // Remove last moveto so we don't get multiple moveto's - if (d->elements.last().type == MoveToElement) + if (d->elements.constLast().type == MoveToElement) d->elements.remove(d->elements.size()-1); // Locate where our own current subpath will start after the other path is added. @@ -1273,7 +1273,7 @@ void QPainterPath::connectPath(const QPainterPath &other) d->elements[first].type = LineToElement; // avoid duplicate points - if (first > 0 && QPointF(d->elements[first]) == QPointF(d->elements[first - 1])) { + if (first > 0 && QPointF(d->elements.at(first)) == QPointF(d->elements.at(first - 1))) { d->elements.remove(first--); --cStart; } @@ -1685,8 +1685,9 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const int isect_j = current_isects.at(j); if (isect_j == i) continue; - for (int k=0; k<isects[isect_j].size(); ++k) { - int isect_k = isects[isect_j][k]; + const QVector<int> &isects_j = isects.at(isect_j); + for (int k = 0, size = isects_j.size(); k < size; ++k) { + int isect_k = isects_j.at(k); if (isect_k != i && !isects.at(i).contains(isect_k)) { isects[i] += isect_k; } @@ -1708,7 +1709,7 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const // Join the intersected subpaths as rewinded polygons for (int i=0; i<count; ++i) { - const QVector<int> &subpath_list = isects[i]; + const QVector<int> &subpath_list = isects.at(i); if (!subpath_list.isEmpty()) { QPolygonF buildUp; for (int j=0; j<subpath_list.size(); ++j) { @@ -1717,7 +1718,7 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const if (!subpath.isClosed()) buildUp += subpath.first(); if (!buildUp.isClosed()) - buildUp += buildUp.first(); + buildUp += buildUp.constFirst(); } polys += buildUp; } @@ -2789,7 +2790,7 @@ void QPainterPathStroker::setDashOffset(qreal offset) QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const { - QList<QPolygonF> flats = toSubpathPolygons(matrix); + const QList<QPolygonF> flats = toSubpathPolygons(matrix); QPolygonF polygon; if (flats.isEmpty()) return polygon; diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 48ae3cfc80..4f2b59c775 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1648,7 +1648,7 @@ bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode) #ifdef QDEBUG_CLIPPER printf("sorted y coords:\n"); for (int i = 0; i < y_coords.size(); ++i) { - printf("%.9f\n", y_coords[i]); + printf("%.9f\n", y_coords.at(i)); } #endif @@ -1686,23 +1686,23 @@ bool QPathClipper::doClip(QWingedEdge &list, ClipperMode mode) QPathVertex *b = list.vertex(edge->second); // FIXME: this can be optimized by using binary search - const int first = qFuzzyFind(y_coords.begin(), y_coords.end(), qMin(a->y, b->y)) - y_coords.begin(); - const int last = qFuzzyFind(y_coords.begin() + first, y_coords.end(), qMax(a->y, b->y)) - y_coords.begin(); + const int first = qFuzzyFind(y_coords.cbegin(), y_coords.cend(), qMin(a->y, b->y)) - y_coords.cbegin(); + const int last = qFuzzyFind(y_coords.cbegin() + first, y_coords.cend(), qMax(a->y, b->y)) - y_coords.cbegin(); Q_ASSERT(first < y_coords.size() - 1); Q_ASSERT(last < y_coords.size()); - qreal bestY = 0.5 * (y_coords[first] + y_coords[first+1]); - qreal biggestGap = y_coords[first+1] - y_coords[first]; - + qreal biggestGap = y_coords.at(first + 1) - y_coords.at(first); + int bestIdx = first; for (int i = first + 1; i < last; ++i) { - qreal gap = y_coords[i+1] - y_coords[i]; + qreal gap = y_coords.at(i + 1) - y_coords.at(i); if (gap > biggestGap) { - bestY = 0.5 * (y_coords[i] + y_coords[i+1]); + bestIdx = i; biggestGap = gap; } } + const qreal bestY = 0.5 * (y_coords.at(bestIdx) + y_coords.at(bestIdx + 1)); #ifdef QDEBUG_CLIPPER printf("y: %.9f, gap: %.9f\n", bestY, biggestGap); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index b014305796..34f1c51f6d 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1674,7 +1674,7 @@ void QPdfEnginePrivate::writePage() uint resources = requestObject(); uint annots = requestObject(); - addXrefEntry(pages.last()); + addXrefEntry(pages.constLast()); xprintf("<<\n" "/Type /Page\n" "/Parent %d 0 R\n" @@ -1767,7 +1767,7 @@ void QPdfEnginePrivate::writeTail() ">>\n" "startxref\n%d\n" "%%%%EOF\n", - xrefPositions.size()-1, info, catalog, xrefPositions.last()); + xrefPositions.size()-1, info, catalog, xrefPositions.constLast()); } int QPdfEnginePrivate::addXrefEntry(int object, bool printostr) |