From 01b72952c38b9193138eabdab6bdab632cd75ebd Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 28 Jun 2011 15:08:12 +0200 Subject: Remove QPainter::UniteClip Change-Id: I5413cb5e2cbb53998bb40f27b9bbc16342caafe6 Reviewed-on: http://codereview.qt.nokia.com/837 Reviewed-by: Qt Sanity Bot Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 2 + src/corelib/global/qnamespace.h | 3 +- src/gui/painting/qpaintengine_mac.cpp | 5 --- src/gui/painting/qpaintengine_raster.cpp | 19 +------- src/gui/painting/qpaintengine_x11.cpp | 5 --- src/gui/painting/qpainter.cpp | 19 ++------ src/gui/painting/qprintengine_win.cpp | 3 +- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 35 --------------- src/opengl/qpaintengine_opengl.cpp | 5 --- src/openvg/qpaintengine_vg.cpp | 44 ------------------- tests/arthur/common/paintcommands.cpp | 6 +-- tests/auto/qgl/tst_qgl.cpp | 17 -------- tests/auto/qpainter/tst_qpainter.cpp | 51 ---------------------- 13 files changed, 13 insertions(+), 201 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index f65f6b671d..4c226aa9d6 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -14,6 +14,8 @@ information about a particular change. - QSslCertificate::subjectInfo() and QSslCertificate::issuerInfo() now return a QStringList instead of a QString +- Unite clipping support has been removed from QPainter. The alternative is + to unite QRegion's and using the result on QPainter. **************************************************************************** * General * diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 99479d0b63..d63eb7ad50 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1494,8 +1494,7 @@ public: enum ClipOperation { NoClip, ReplaceClip, - IntersectClip, - UniteClip + IntersectClip }; // Shape = 0x1, BoundingRect = 0x2 diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index 802c455ab8..0d459a5d89 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -798,9 +798,6 @@ QCoreGraphicsPaintEngine::updateClipPath(const QPainterPath &p, Qt::ClipOperatio } else if(op == Qt::IntersectClip) { d->current.clip = d->current.clip.intersected(clipRegion); d->setClip(&d->current.clip); - } else if(op == Qt::UniteClip) { - d->current.clip = d->current.clip.united(clipRegion); - d->setClip(&d->current.clip); } } } @@ -822,8 +819,6 @@ QCoreGraphicsPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOp d->current.clip = d->current.clip.intersected(clipRegion); else if(op == Qt::ReplaceClip) d->current.clip = clipRegion; - else if(op == Qt::UniteClip) - d->current.clip = d->current.clip.united(clipRegion); d->setClip(&d->current.clip); } } diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index c1b749ad01..e1802e6552 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1162,8 +1162,7 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) const QPainterPath::ElementType *types = path.elements(); // There are some cases that are not supported by clip(QRect) - if (op != Qt::UniteClip && (op != Qt::IntersectClip || !s->clip - || s->clip->hasRectClip || s->clip->hasRegionClip)) { + if (op != Qt::IntersectClip || !s->clip || s->clip->hasRectClip || s->clip->hasRegionClip) { if (s->matrix.type() <= QTransform::TxScale && ((path.shape() == QVectorPath::RectangleHint) || (isRect(points, path.elementCount()) @@ -1206,18 +1205,6 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) newClip->fixup(); - if (op == Qt::UniteClip) { - // merge clips - QClipData *result = new QClipData(d->rasterBuffer->height()); - QClipData *current = s->clip ? s->clip : new QClipData(d->rasterBuffer->height()); - qt_merge_clip(current, newClip, result); - result->fixup(); - delete newClip; - if (!s->clip) - delete current; - newClip = result; - } - if (s->flags.has_clip_ownership) delete s->clip; @@ -1243,7 +1230,7 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) if (op == Qt::NoClip) { qrasterpaintengine_state_setNoClip(s); - } else if (op == Qt::UniteClip || s->matrix.type() > QTransform::TxScale) { + } else if (s->matrix.type() > QTransform::TxScale) { QPaintEngineEx::clip(rect, op); return; @@ -1328,7 +1315,6 @@ void QRasterPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) if (op == Qt::NoClip) { qrasterpaintengine_state_setNoClip(s); } else if (s->matrix.type() > QTransform::TxScale - || op == Qt::UniteClip || (op == Qt::IntersectClip && !clip->hasRectClip && !clip->hasRegionClip) || (op == Qt::ReplaceClip && !baseClip->hasRectClip && !baseClip->hasRegionClip)) { QPaintEngineEx::clip(region, op); @@ -4450,7 +4436,6 @@ static void qt_span_clip(int count, const QSpan *spans, void *userData) } break; - case Qt::UniteClip: case Qt::ReplaceClip: clipData->newClip->appendSpans(spans, count); break; diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 994986b0d6..5f613ee001 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -2078,11 +2078,6 @@ void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOp else d->crgn = clipRegion; break; - case Qt::UniteClip: - d->crgn |= clipRegion; - if (!sysClip.isEmpty()) - d->crgn = d->crgn.intersected(sysClip); - break; default: break; } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 73addd2679..83bdc5cb30 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2576,8 +2576,6 @@ QRegion QPainter::clipRegion() const } if (info.operation == Qt::IntersectClip) region &= info.region * matrix; - else if (info.operation == Qt::UniteClip) - region |= info.region * matrix; else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); @@ -2597,9 +2595,6 @@ QRegion QPainter::clipRegion() const if (info.operation == Qt::IntersectClip) { region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(), info.path.fillRule()); - } else if (info.operation == Qt::UniteClip) { - region |= QRegion((info.path * matrix).toFillPolygon().toPolygon(), - info.path.fillRule()); } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); @@ -2623,8 +2618,6 @@ QRegion QPainter::clipRegion() const region &= matrix.mapRect(info.rect); else region &= matrix.map(QRegion(info.rect)); - } else if (info.operation == Qt::UniteClip) { - region |= QRegion(info.rect) * matrix; } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); @@ -2647,8 +2640,6 @@ QRegion QPainter::clipRegion() const region &= matrix.mapRect(info.rectf.toRect()); else region &= matrix.map(QRegion(info.rectf.toRect())); - } else if (info.operation == Qt::UniteClip) { - region |= QRegion(info.rectf.toRect()) * matrix; } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); @@ -2759,8 +2750,6 @@ QRectF QPainter::clipBoundingRect() const bounds = r; else if (info.operation == Qt::IntersectClip) bounds &= r; - else if (info.operation == Qt::UniteClip) - bounds |= r; } @@ -2789,7 +2778,7 @@ void QPainter::setClipRect(const QRectF &rect, Qt::ClipOperation op) Q_D(QPainter); if (d->extended) { - if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip)) + if ((!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (!d->engine) { @@ -2847,7 +2836,7 @@ void QPainter::setClipRect(const QRect &rect, Qt::ClipOperation op) return; } - if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip)) + if ((!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { @@ -2902,7 +2891,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op) return; } - if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip)) + if ((!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { @@ -3307,7 +3296,7 @@ void QPainter::setClipPath(const QPainterPath &path, Qt::ClipOperation op) return; } - if ((!d->state->clipEnabled && op != Qt::NoClip) || (d->state->clipOperation == Qt::NoClip && op == Qt::UniteClip)) + if ((!d->state->clipEnabled && op != Qt::NoClip)) op = Qt::ReplaceClip; if (d->extended) { diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index ebce404c3c..5ba33c043c 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -586,8 +586,7 @@ void QWin32PrintEngine::updateClipPath(const QPainterPath &clipPath, Qt::ClipOpe const int ops[] = { -1, // Qt::NoClip, covered above RGN_COPY, // Qt::ReplaceClip - RGN_AND, // Qt::IntersectClip - RGN_OR // Qt::UniteClip + RGN_AND // Qt::IntersectClip }; Q_ASSERT(op > 0 && unsigned(op) <= sizeof(ops) / sizeof(int)); SelectClipPath(d->hdc, ops[op]); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 3ac759c7ec..a07b8b0b07 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -2319,41 +2319,6 @@ void QGL2PaintEngineEx::clip(const QVectorPath &path, Qt::ClipOperation op) state()->currentClip = d->maxClip; state()->clipTestEnabled = true; break; - case Qt::UniteClip: { - d->resetClipIfNeeded(); - ++d->maxClip; - if (state()->rectangleClip.isValid()) { - QPainterPath path; - path.addRect(state()->rectangleClip); - - // flush the existing clip rectangle to the depth buffer - d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(path)), d->maxClip); - } - - state()->clipTestEnabled = false; -#ifndef QT_GL_NO_SCISSOR_TEST - QRect oldRectangleClip = state()->rectangleClip; - - state()->rectangleClip = state()->rectangleClip.united(pathRect); - d->updateClipScissorTest(); - - QRegion extendRegion = QRegion(state()->rectangleClip) - oldRectangleClip; - - if (!extendRegion.isEmpty()) { - QPainterPath extendPath; - extendPath.addRegion(extendRegion); - - // first clear the depth buffer in the extended region - d->writeClip(qtVectorPathForPath(state()->matrix.inverted().map(extendPath)), 0); - } -#endif - // now write the clip path - d->writeClip(path, d->maxClip); - state()->canRestoreClip = false; - state()->currentClip = d->maxClip; - state()->clipTestEnabled = true; - break; - } default: break; } diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 31fe02c1b3..56a6af1cfe 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -2413,11 +2413,6 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe else state()->clipRegion = region; break; - case Qt::UniteClip: - state()->clipRegion |= region; - if (d->use_system_clip) - state()->clipRegion &= sysClip; - break; default: break; } diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index c156cb8710..b919b087cf 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1693,12 +1693,6 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) region = s->clipRegion.intersect(d->transform.map(region)); } break; - - case Qt::UniteClip: - { - region = s->clipRegion.unite(d->transform.map(region)); - } - break; } if (region.numRects() <= d->maxScissorRects) { // We haven't reached the maximum scissor count yet, so we can @@ -1738,12 +1732,6 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) s->clipRegion = s->clipRegion.intersect(d->transform.map(QRegion(rect))); } break; - - case Qt::UniteClip: - { - s->clipRegion = s->clipRegion.unite(d->transform.map(QRegion(rect))); - } - break; } updateScissor(); @@ -1774,12 +1762,6 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) s->clipRegion = s->clipRegion.intersect(d->transform.map(region)); } break; - - case Qt::UniteClip: - { - s->clipRegion = s->clipRegion.unite(d->transform.map(region)); - } - break; } updateScissor(); @@ -1835,10 +1817,6 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) VGPath vgpath = d->vectorPathToVGPath(path); switch (op) { case Qt::ReplaceClip: - case Qt::UniteClip: - vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK); - break; - case Qt::IntersectClip: vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK); break; @@ -1955,15 +1933,6 @@ void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) } } break; - - case Qt::UniteClip: - { - // If we already have a full-window clip, then uniting a - // region with it will do nothing. Otherwise union. - if (!(d->maskIsSet)) - d->modifyMask(this, VG_UNION_MASK, d->transform.mapRect(rect)); - } - break; } } @@ -2059,15 +2028,6 @@ void QVGPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) } } break; - - case Qt::UniteClip: - { - // If we already have a full-window clip, then uniting a - // region with it will do nothing. Otherwise union. - if (!(d->maskIsSet)) - d->modifyMask(this, VG_UNION_MASK, d->transform.map(region)); - } - break; } } @@ -2152,10 +2112,6 @@ void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op) VGPath vgpath = d->painterPathToVGPath(path); switch (op) { case Qt::ReplaceClip: - case Qt::UniteClip: - vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK); - break; - case Qt::IntersectClip: vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK); break; diff --git a/tests/arthur/common/paintcommands.cpp b/tests/arthur/common/paintcommands.cpp index d005ffd215..8735baa3f0 100644 --- a/tests/arthur/common/paintcommands.cpp +++ b/tests/arthur/common/paintcommands.cpp @@ -1879,7 +1879,7 @@ void PaintCommands::command_setClipRect(QRegExp re) int w = convertToInt(caps.at(3)); int h = convertToInt(caps.at(4)); - int combine = translateEnum(clipOperationTable, caps.at(5), Qt::UniteClip + 1); + int combine = translateEnum(clipOperationTable, caps.at(5), Qt::IntersectClip + 1); if (combine == -1) combine = Qt::ReplaceClip; @@ -1892,7 +1892,7 @@ void PaintCommands::command_setClipRect(QRegExp re) /***************************************************************************************************/ void PaintCommands::command_setClipPath(QRegExp re) { - int combine = translateEnum(clipOperationTable, re.cap(2), Qt::UniteClip + 1); + int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1); if (combine == -1) combine = Qt::ReplaceClip; @@ -1907,7 +1907,7 @@ void PaintCommands::command_setClipPath(QRegExp re) /***************************************************************************************************/ void PaintCommands::command_setClipRegion(QRegExp re) { - int combine = translateEnum(clipOperationTable, re.cap(2), Qt::UniteClip + 1); + int combine = translateEnum(clipOperationTable, re.cap(2), Qt::IntersectClip + 1); if (combine == -1) combine = Qt::ReplaceClip; QRegion r = m_regionMap[re.cap(1)]; diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 9c51e026d2..7d46ada820 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1742,12 +1742,6 @@ public: painter->fillRect(rect(), Qt::green); painter->restore(); - painter->save(); - painter->setClipRect(0, 60, 60, 25, Qt::IntersectClip); - painter->setClipRect(60, 60, 50, 25, Qt::UniteClip); - painter->fillRect(rect(), Qt::yellow); - painter->restore(); - painter->restore(); painter->translate(100, 100); @@ -1793,17 +1787,6 @@ public: } painter->fillRect(rect(), Qt::green); painter->restore(); - - painter->save(); - { - QPainterPath path; - path.addRect(0, 60, 60, 25); - path.addRect(10, 10, 10, 10); - painter->setClipPath(path, Qt::IntersectClip); - } - painter->setClipRect(60, 60, 50, 25, Qt::UniteClip); - painter->fillRect(rect(), Qt::yellow); - painter->restore(); } protected: diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 5275778320..8898a4874d 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -1820,26 +1820,10 @@ int countPixels(const QImage &img, const QRgb &color) template void testClipping(QImage &img) { - img.fill(0x0); QPainterPath a, b; a.addRect(QRect(2, 2, 4, 4)); b.addRect(QRect(4, 4, 4, 4)); - QPainter p(&img); - p.setClipPath(a); - p.setClipPath(b, Qt::UniteClip); - - p.setClipping(false); - p.setPen(Qt::NoPen); - p.setBrush(QColor(0xff0000)); - p.drawRect(T(0, 0, 10, 10)); - - p.setClipping(true); - p.setBrush(QColor(0x00ff00)); - p.drawRect(T(0, 0, 10, 10)); - - QCOMPARE(countPixels(img, 0xff0000), 72); - QCOMPARE(countPixels(img, 0x00ff00), 28); p.end(); img.fill(0x0); @@ -2002,43 +1986,8 @@ void tst_QPainter::setEqualClipRegionAndPath() QCOMPARE(img1, img2); #endif - // simple uniteclip img1.fill(0x12345678); img2.fill(0x12345678); - { - QPainter p(&img1); - p.setClipRegion(region); - p.setClipRegion(region, Qt::UniteClip); - p.fillRect(0, 0, img1.width(), img1.height(), QColor(Qt::red)); - } - { - QPainter p(&img2); - p.setClipPath(path); - p.setClipPath(path, Qt::UniteClip); - p.fillRect(0, 0, img2.width(), img2.height(), QColor(Qt::red)); - } - QCOMPARE(img1, img2); - img1.fill(0x12345678); - img2.fill(0x12345678); - { - QPainter p(&img1); - p.setClipPath(path); - p.setClipRegion(region, Qt::UniteClip); - p.fillRect(0, 0, img1.width(), img1.height(), QColor(Qt::red)); - } - { - QPainter p(&img2); - p.setClipRegion(region); - p.setClipPath(path, Qt::UniteClip); - p.fillRect(0, 0, img2.width(), img2.height(), QColor(Qt::red)); - } -#if 0 - if (img1 != img2) { - img1.save("setEqualClipRegionAndPath_1.xpm", "XPM"); - img2.save("setEqualClipRegionAndPath_2.xpm", "XPM"); - } -#endif - QCOMPARE(img1, img2); // simple intersectclip img1.fill(0x12345678); -- cgit v1.2.3