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:
|
case 32:
|
||||||
{
|
{
|
||||||
blended = QImage(sw, sh, start.format());
|
blended = QImage(sw, sh, start.format());
|
||||||
|
blended.setDevicePixelRatio(start.devicePixelRatio());
|
||||||
uchar *mixed_data = blended.bits();
|
uchar *mixed_data = blended.bits();
|
||||||
const uchar *back_data = start.bits();
|
const uchar *back_data = start.bits();
|
||||||
const uchar *front_data = end.bits();
|
const uchar *front_data = end.bits();
|
||||||
|
@ -102,6 +102,15 @@ bool canAnimate(const QStyleOption *option) {
|
|||||||
&& !option->styleObject->property("_q_no_animation").toBool();
|
&& !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
|
/* \internal
|
||||||
Used by animations to clone a styleoption and shift its offset
|
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
|
// We create separate images for the initial and final transition states and store them in the
|
||||||
// Transition object.
|
// Transition object.
|
||||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage startImage = createAnimationBuffer(option, widget);
|
||||||
startImage.fill(0);
|
|
||||||
QPainter startPainter(&startImage);
|
QPainter startPainter(&startImage);
|
||||||
|
|
||||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage endImage = createAnimationBuffer(option, widget);
|
||||||
endImage.fill(0);
|
|
||||||
QPainter endPainter(&endImage);
|
QPainter endPainter(&endImage);
|
||||||
|
|
||||||
// If we have a running animation on the widget already, we will use that to paint the initial
|
// 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);
|
QStyleOption *styleOption = clonedAnimationStyleOption(option);
|
||||||
styleOption->state = (QStyle::State)oldState;
|
styleOption->state = (QStyle::State)oldState;
|
||||||
|
|
||||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage startImage = createAnimationBuffer(option, widget);
|
||||||
startImage.fill(0);
|
|
||||||
QPainter startPainter(&startImage);
|
QPainter startPainter(&startImage);
|
||||||
|
|
||||||
// Use current state of existing animation if already one is running
|
// 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);
|
t->setStartImage(startImage);
|
||||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage endImage = createAnimationBuffer(option, widget);
|
||||||
endImage.fill(0);
|
|
||||||
QPainter endPainter(&endImage);
|
QPainter endPainter(&endImage);
|
||||||
styleOption->state = option->state;
|
styleOption->state = option->state;
|
||||||
proxy()->drawControl(element, styleOption, &endPainter, widget);
|
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)));
|
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject(option)));
|
||||||
|
|
||||||
if (!anim) {
|
if (!anim) {
|
||||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage startImage = createAnimationBuffer(option, widget);
|
||||||
startImage.fill(0);
|
QImage alternateImage = createAnimationBuffer(option, widget);
|
||||||
QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
|
||||||
alternateImage.fill(0);
|
|
||||||
|
|
||||||
QWindowsVistaPulse *pulse = new QWindowsVistaPulse(styleObject(option));
|
QWindowsVistaPulse *pulse = new QWindowsVistaPulse(styleObject(option));
|
||||||
|
|
||||||
@ -1544,13 +1547,10 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (doTransition) {
|
if (doTransition) {
|
||||||
|
QImage startImage = createAnimationBuffer(option, widget);
|
||||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
|
||||||
startImage.fill(0);
|
|
||||||
QPainter startPainter(&startImage);
|
QPainter startPainter(&startImage);
|
||||||
|
|
||||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage endImage = createAnimationBuffer(option, widget);
|
||||||
endImage.fill(0);
|
|
||||||
QPainter endPainter(&endImage);
|
QPainter endPainter(&endImage);
|
||||||
|
|
||||||
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
|
||||||
|
Loading…
Reference in New Issue
Block a user