diff options
Diffstat (limited to 'src/gui/effects/qgraphicseffect.cpp')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 10ef5ea..ce4ce6a 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -699,12 +699,17 @@ void QGraphicsColorizeEffect::draw(QPainter *painter) if (sourceIsPixmap()) { // No point in drawing in device coordinates (pixmap will be scaled anyways). const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); - d->filter->draw(painter, offset, pixmap); + if (!pixmap.isNull()) + d->filter->draw(painter, offset, pixmap); + return; } // Draw pixmap in deviceCoordinates to avoid pixmap scaling. const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); + if (pixmap.isNull()) + return; + QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); @@ -721,7 +726,8 @@ void QGraphicsColorizeEffect::draw(QPainter *painter) elements. The level of detail can be modified using the setBlurRadius() function. Use setBlurHints() to choose the blur hints. - By default, the blur radius is 5 pixels. + By default, the blur radius is 5 pixels. The blur radius is specified in + device coordinates. \img graphicseffect-blur.png @@ -776,6 +782,9 @@ QGraphicsBlurEffect::~QGraphicsBlurEffect() radius results in a more blurred appearance. By default, the blur radius is 5 pixels. + + The radius is given in device coordinates, meaning it is + unaffected by scale. */ qreal QGraphicsBlurEffect::blurRadius() const { @@ -858,9 +867,11 @@ void QGraphicsBlurEffect::draw(QPainter *painter) if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) mode = NoPad; - // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode); + if (pixmap.isNull()) + return; + d->filter->draw(painter, offset, pixmap); } @@ -877,7 +888,8 @@ void QGraphicsBlurEffect::draw(QPainter *painter) By default, the drop shadow is a semi-transparent dark gray (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset - of 8 pixels towards the lower right. + of 8 pixels towards the lower right. The drop shadow offset is specified + in device coordinates. \img graphicseffect-drop-shadow.png @@ -906,6 +918,9 @@ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() By default, the offset is 8 pixels towards the lower right. + The offset is given in device coordinates, which means it is + unaffected by scale. + \sa xOffset(), yOffset(), blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const @@ -1047,6 +1062,9 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter) // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); + if (pixmap.isNull()) + return; + QTransform restoreTransform = painter->worldTransform(); painter->setWorldTransform(QTransform()); d->filter->draw(painter, offset, pixmap); |