put the to pixmap in the center if the two pixmap have a different size
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=866779
This commit is contained in:
parent
9d616e85b8
commit
7d9e7a74cb
@ -127,6 +127,10 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
|
|||||||
QColor color;
|
QColor color;
|
||||||
color.setAlphaF(amount);
|
color.setAlphaF(amount);
|
||||||
|
|
||||||
|
//paint to in the center of from
|
||||||
|
QRect toRect = to.rect();
|
||||||
|
toRect.moveCenter(from.rect().center());
|
||||||
|
|
||||||
// If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus
|
// If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus
|
||||||
if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff) &&
|
if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff) &&
|
||||||
from.paintEngine()->hasFeature(QPaintEngine::BlendModes)) {
|
from.paintEngine()->hasFeature(QPaintEngine::BlendModes)) {
|
||||||
@ -143,7 +147,7 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
|
|||||||
p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
|
p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
|
||||||
p.fillRect(under.rect(), color);
|
p.fillRect(under.rect(), color);
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Plus);
|
p.setCompositionMode(QPainter::CompositionMode_Plus);
|
||||||
p.drawPixmap(0, 0, over);
|
p.drawPixmap(toRect.topLeft(), over);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
return under;
|
return under;
|
||||||
@ -190,7 +194,7 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
|
|||||||
// Add source * opacity to the destination
|
// Add source * opacity to the destination
|
||||||
XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha,
|
XRenderComposite(dpy, PictOpAdd, source.x11PictureHandle(), alpha,
|
||||||
destination.x11PictureHandle(),
|
destination.x11PictureHandle(),
|
||||||
0, 0, 0, 0, 0, 0, destination.width(), destination.height());
|
toRect.x(), toRect.y(), 0, 0, 0, 0, destination.width(), destination.height());
|
||||||
|
|
||||||
XRenderFreePicture(dpy, alpha);
|
XRenderFreePicture(dpy, alpha);
|
||||||
return destination;
|
return destination;
|
||||||
@ -211,7 +215,7 @@ QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount)
|
|||||||
p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
|
p.setCompositionMode(QPainter::CompositionMode_DestinationOut);
|
||||||
p.fillRect(under.rect(), color);
|
p.fillRect(under.rect(), color);
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Plus);
|
p.setCompositionMode(QPainter::CompositionMode_Plus);
|
||||||
p.drawImage(0, 0, over);
|
p.drawImage(toRect.topLeft(), over);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
return QPixmap::fromImage(under);
|
return QPixmap::fromImage(under);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user