- 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 *
enum ClipOperation {
NoClip,
ReplaceClip,
- IntersectClip,
- UniteClip
+ IntersectClip
};
// Shape = 0x1, BoundingRect = 0x2
} 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);
}
}
}
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);
}
}
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())
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;
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;
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);
}
break;
- case Qt::UniteClip:
case Qt::ReplaceClip:
clipData->newClip->appendSpans(spans, count);
break;
else
d->crgn = clipRegion;
break;
- case Qt::UniteClip:
- d->crgn |= clipRegion;
- if (!sysClip.isEmpty())
- d->crgn = d->crgn.intersected(sysClip);
- break;
default:
break;
}
}
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();
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();
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();
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();
bounds = r;
else if (info.operation == Qt::IntersectClip)
bounds &= r;
- else if (info.operation == Qt::UniteClip)
- bounds |= r;
}
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) {
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) {
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) {
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) {
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]);
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;
}
else
state()->clipRegion = region;
break;
- case Qt::UniteClip:
- state()->clipRegion |= region;
- if (d->use_system_clip)
- state()->clipRegion &= sysClip;
- break;
default:
break;
}
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
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();
s->clipRegion = s->clipRegion.intersect(d->transform.map(region));
}
break;
-
- case Qt::UniteClip:
- {
- s->clipRegion = s->clipRegion.unite(d->transform.map(region));
- }
- break;
}
updateScissor();
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;
}
}
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;
}
}
}
}
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;
}
}
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;
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;
/***************************************************************************************************/
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;
/***************************************************************************************************/
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)];
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);
}
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:
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);
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);