Commit 54df09f8 authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Wolthera van Hövell

Make this class safe

It means we don't cache the QImage, but there is no alternative
parent 362c78b8
......@@ -51,8 +51,6 @@ public:
qreal angle;
qreal border;
qreal opacity;
mutable QImage buffer;
};
......@@ -126,22 +124,25 @@ void KoOdfGradientBackground::saveOdf(KoGenStyle& styleFill, KoGenStyles& mainSt
void KoOdfGradientBackground::paint(QPainter& painter, const KoViewConverter &/*converter*/, KoShapePaintingContext &/*context*/, const QPainterPath& fillPath) const
{
Q_D(const KoOdfGradientBackground);
QImage buffer;
QRectF targetRect = fillPath.boundingRect();
QRectF pixels = painter.transform().mapRect(QRectF(0,0,targetRect.width(), targetRect.height()));
QSize currentSize( qCeil(pixels.size().width()), qCeil(pixels.size().height()) );
if (d->buffer.isNull() || d->buffer.size() != currentSize){
d->buffer = QImage(currentSize, QImage::Format_ARGB32_Premultiplied);
if (buffer.isNull() || buffer.size() != currentSize){
buffer = QImage(currentSize, QImage::Format_ARGB32_Premultiplied);
if (d->style == "square") {
renderSquareGradient(d->buffer);
renderSquareGradient(buffer);
} else {
renderRectangleGradient(d->buffer);
renderRectangleGradient(buffer);
}
}
painter.setClipPath(fillPath);
painter.setOpacity(d->opacity);
painter.drawImage(targetRect, d->buffer, QRectF(QPointF(0,0), d->buffer.size()));
painter.drawImage(targetRect, buffer, QRectF(QPointF(0,0), buffer.size()));
}
void KoOdfGradientBackground::fillStyle(KoGenStyle& style, KoShapeSavingContext& context)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment