Remove QPainter::UniteClip
authorGunnar Sletta <gunnar.sletta@nokia.com>
Tue, 28 Jun 2011 13:08:12 +0000 (15:08 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 28 Jun 2011 14:52:44 +0000 (16:52 +0200)
Change-Id: I5413cb5e2cbb53998bb40f27b9bbc16342caafe6
Reviewed-on: http://codereview.qt.nokia.com/837
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
13 files changed:
dist/changes-5.0.0
src/corelib/global/qnamespace.h
src/gui/painting/qpaintengine_mac.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/painting/qpaintengine_x11.cpp
src/gui/painting/qpainter.cpp
src/gui/painting/qprintengine_win.cpp
src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
src/opengl/qpaintengine_opengl.cpp
src/openvg/qpaintengine_vg.cpp
tests/arthur/common/paintcommands.cpp
tests/auto/qgl/tst_qgl.cpp
tests/auto/qpainter/tst_qpainter.cpp

index f65f6b6..4c226aa 100644 (file)
@@ -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                                        *
index 99479d0..d63eb7a 100644 (file)
@@ -1494,8 +1494,7 @@ public:
     enum ClipOperation {
         NoClip,
         ReplaceClip,
-        IntersectClip,
-        UniteClip
+        IntersectClip
     };
 
     // Shape = 0x1, BoundingRect = 0x2
index 802c455..0d459a5 100644 (file)
@@ -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);
     }
 }
index c1b749a..e1802e6 100644 (file)
@@ -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 &region, 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;
index 994986b..5f613ee 100644 (file)
@@ -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;
     }
index 73addd2..83bdc5c 100644 (file)
@@ -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) {
index ebce404..5ba33c0 100644 (file)
@@ -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]);
index 3ac759c..a07b8b0 100644 (file)
@@ -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;
     }
index 31fe02c..56a6af1 100644 (file)
@@ -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;
     }
index c156cb8..b919b08 100644 (file)
@@ -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 &region, 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 &region, 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;
index d005ffd..8735baa 100644 (file)
@@ -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)];
index 9c51e02..7d46ada 100644 (file)
@@ -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:
index 5275778..8898a48 100644 (file)
@@ -1820,26 +1820,10 @@ int countPixels(const QImage &img, const QRgb &color)
 template <typename T>
 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);