Vista style animation: Create images with device pixel ratio.
Change-Id: Ic404c8ac8b0e4c1b8d0dd7877611443e0afac270 Task-number: QTBUG-49374 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
parent
34a984c807
commit
16e7bcc4cd
@ -267,6 +267,7 @@ static QImage blendedImage(const QImage &start, const QImage &end, float alpha)
|
||||
case 32:
|
||||
{
|
||||
blended = QImage(sw, sh, start.format());
|
||||
blended.setDevicePixelRatio(start.devicePixelRatio());
|
||||
uchar *mixed_data = blended.bits();
|
||||
const uchar *back_data = start.bits();
|
||||
const uchar *front_data = end.bits();
|
||||
|
@ -102,6 +102,15 @@ bool canAnimate(const QStyleOption *option) {
|
||||
&& !option->styleObject->property("_q_no_animation").toBool();
|
||||
}
|
||||
|
||||
static inline QImage createAnimationBuffer(const QStyleOption *option, const QWidget *widget)
|
||||
{
|
||||
const int devicePixelRatio = widget ? widget->devicePixelRatio() : 1;
|
||||
QImage result(option->rect.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
|
||||
result.setDevicePixelRatio(devicePixelRatio);
|
||||
result.fill(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* \internal
|
||||
Used by animations to clone a styleoption and shift its offset
|
||||
*/
|
||||
@ -314,12 +323,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
||||
|
||||
// We create separate images for the initial and final transition states and store them in the
|
||||
// Transition object.
|
||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
startImage.fill(0);
|
||||
QImage startImage = createAnimationBuffer(option, widget);
|
||||
QPainter startPainter(&startImage);
|
||||
|
||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
endImage.fill(0);
|
||||
QImage endImage = createAnimationBuffer(option, widget);
|
||||
QPainter endPainter(&endImage);
|
||||
|
||||
// If we have a running animation on the widget already, we will use that to paint the initial
|
||||
@ -867,8 +874,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
||||
styleOption->state = (QStyle::State)oldState;
|
||||
|
||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
startImage.fill(0);
|
||||
QImage startImage = createAnimationBuffer(option, widget);
|
||||
QPainter startPainter(&startImage);
|
||||
|
||||
// Use current state of existing animation if already one is running
|
||||
@ -880,8 +886,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
}
|
||||
|
||||
t->setStartImage(startImage);
|
||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
endImage.fill(0);
|
||||
QImage endImage = createAnimationBuffer(option, widget);
|
||||
QPainter endPainter(&endImage);
|
||||
styleOption->state = option->state;
|
||||
proxy()->drawControl(element, styleOption, &endPainter, widget);
|
||||
@ -943,10 +948,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
||||
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject(option)));
|
||||
|
||||
if (!anim) {
|
||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
startImage.fill(0);
|
||||
QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
alternateImage.fill(0);
|
||||
QImage startImage = createAnimationBuffer(option, widget);
|
||||
QImage alternateImage = createAnimationBuffer(option, widget);
|
||||
|
||||
QWindowsVistaPulse *pulse = new QWindowsVistaPulse(styleObject(option));
|
||||
|
||||
@ -1544,13 +1547,10 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
||||
}
|
||||
|
||||
if (doTransition) {
|
||||
|
||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
startImage.fill(0);
|
||||
QImage startImage = createAnimationBuffer(option, widget);
|
||||
QPainter startPainter(&startImage);
|
||||
|
||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
endImage.fill(0);
|
||||
QImage endImage = createAnimationBuffer(option, widget);
|
||||
QPainter endPainter(&endImage);
|
||||
|
||||
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
||||
|
Loading…
Reference in New Issue
Block a user