diff options
Diffstat (limited to 'src/declarative/fx/qfxblendedimage.cpp')
-rw-r--r-- | src/declarative/fx/qfxblendedimage.cpp | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/src/declarative/fx/qfxblendedimage.cpp b/src/declarative/fx/qfxblendedimage.cpp index b5d9a9a..ec2b9cc 100644 --- a/src/declarative/fx/qfxblendedimage.cpp +++ b/src/declarative/fx/qfxblendedimage.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE secondary image. */ QFxBlendedImage::QFxBlendedImage(QFxItem *parent) -: QFxItem(parent), _blend(0), dirty(false) +: QFxItem(parent), _blend(0), _smooth(false), dirty(false) { #if defined(QFX_RENDER_OPENGL2) setOptions(HasContents); @@ -103,9 +103,9 @@ void QFxBlendedImage::setPrimaryUrl(const QString &url) if (!primSrc.isEmpty()) QFxPixmap::cancelGet(primUrl,this,SLOT(primaryLoaded())); primSrc = url; - primUrl = itemContext()->resolvedUrl(url); + primUrl = qmlContext(this)->resolvedUrl(url); if (!primSrc.isEmpty()) - QFxPixmap::get(itemContext()->engine(), primUrl,this,SLOT(primaryLoaded())); + QFxPixmap::get(qmlEngine(this), primUrl,this,SLOT(primaryLoaded())); } /*! @@ -131,9 +131,9 @@ void QFxBlendedImage::setSecondaryUrl(const QString &url) if (!secSrc.isEmpty()) QFxPixmap::cancelGet(secUrl,this,SLOT(secondaryLoaded())); secSrc = url; - secUrl = itemContext()->resolvedUrl(url); + secUrl = qmlContext(this)->resolvedUrl(url); if (!secSrc.isEmpty()) - QFxPixmap::get(itemContext()->engine(), secUrl,this,SLOT(secondaryLoaded())); + QFxPixmap::get(qmlEngine(this), secUrl,this,SLOT(secondaryLoaded())); } /*! @@ -154,16 +154,51 @@ void QFxBlendedImage::setBlend(qreal b) update(); } +/*! + \qmlproperty bool BlendedImage::smooth + + Set this property if you want the image to be smoothly filtered when scaled or + transformed. Smooth filtering gives better visual quality, but is slower. If + the BlendedImage is displayed at its natural size, this property has no visual or + performance effect. + + \note Generally scaling artifacts are only visible if the image is stationary on + the screen. A common pattern when animating an image is to disable smooth + filtering at the beginning of the animation and reenable it at the conclusion. + */ +bool QFxBlendedImage::smoothTransform() const +{ + return _smooth; +} + +void QFxBlendedImage::setSmoothTransform(bool s) +{ + if(_smooth == s) + return; + _smooth = s; + update(); +} + #if defined(QFX_RENDER_QPAINTER) void QFxBlendedImage::paintContents(QPainter &p) { if (primSrc.isNull() && secSrc.isNull()) return; + + if(_smooth) { + p.save(); + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, _smooth); + } + if (_blend < 0.75) p.drawImage(0, 0, primPix); else p.drawImage(0, 0, secPix); + + if(_smooth) { + p.restore(); + } } #elif defined(QFX_RENDER_OPENGL2) |