plasma: assume QPixmap paint engines support composition

the backbone of QPixmap is QImage

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-19 20:31:07 +03:00
parent 2ad07c5a86
commit 174f6a30e0

View file

@ -218,11 +218,6 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
// paint to in the center of from, skipping setAlphaF() // paint to in the center of from, skipping setAlphaF()
QColor color(0, 0, 0, amount); QColor color(0, 0, 0, amount);
// If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus
QPaintEngine *paintEngine = from.paintEngine();
if (paintEngine &&
paintEngine->hasFeature(QPaintEngine::PorterDuff) &&
paintEngine->hasFeature(QPaintEngine::BlendModes)) {
QPixmap startPixmap(pixmapSize); QPixmap startPixmap(pixmapSize);
startPixmap.fill(Qt::transparent); startPixmap.fill(Qt::transparent);
@ -245,30 +240,6 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
p.end(); p.end();
return startPixmap; return startPixmap;
} else {
// Fall back to using QRasterPaintEngine to do the transition.
QImage under(pixmapSize, QImage::Format_ARGB32_Premultiplied);
under.fill(Qt::transparent);
QImage over(pixmapSize, QImage::Format_ARGB32_Premultiplied);
over.fill(Qt::transparent);
QPainter p;
p.begin(&over);
p.drawPixmap(targetRect, to);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(over.rect(), color);
p.end();
p.begin(&under);
p.drawPixmap(startRect, from);
p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
p.fillRect(startRect, color);
p.setCompositionMode(QPainter::CompositionMode_Plus);
p.drawImage(toRect.topLeft(), over);
p.end();
return QPixmap::fromImage(under);
}
} }
} // PaintUtils namespace } // PaintUtils namespace