diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-29 13:46:13 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-29 13:46:13 (GMT) |
commit | 24f041b30f576a2f6ca1cd9e07cba91fc32fac59 (patch) | |
tree | f068c9beff2b5c38863cc00092e748552501ebe0 /src | |
parent | 07c2b17276057a8b47c3be57ab7c2cf66dac0edd (diff) | |
download | Qt-24f041b30f576a2f6ca1cd9e07cba91fc32fac59.zip Qt-24f041b30f576a2f6ca1cd9e07cba91fc32fac59.tar.gz Qt-24f041b30f576a2f6ca1cd9e07cba91fc32fac59.tar.bz2 |
Conflicts after merge commit 07c2b17276057a8b47c3be57ab7c2cf66dac0edd
Makes QGraphicsShaderEffect compatible with the new QGraphicsEffect API.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/graphicsview/qgraphicseffect.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgraphicsshadereffect.cpp | 36 | ||||
-rw-r--r-- | src/opengl/qgraphicsshadereffect.h | 2 |
3 files changed, 17 insertions, 23 deletions
diff --git a/src/gui/graphicsview/qgraphicseffect.cpp b/src/gui/graphicsview/qgraphicseffect.cpp index 1f9f944..45955f2 100644 --- a/src/gui/graphicsview/qgraphicseffect.cpp +++ b/src/gui/graphicsview/qgraphicseffect.cpp @@ -424,7 +424,7 @@ int QGraphicsBlurEffect::blurRadius() const void QGraphicsBlurEffect::setBlurRadius(int radius) { Q_D(QGraphicsBlurEffect); - d->filter->setBlurRadius(radius); + d->filter->setRadius(radius); updateBoundingRect(); } diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp index d4f5fa0..e8d9ae3 100644 --- a/src/opengl/qgraphicsshadereffect.cpp +++ b/src/opengl/qgraphicsshadereffect.cpp @@ -246,25 +246,11 @@ void QGraphicsShaderEffect::setPixelShaderFragment(const QByteArray& code) /*! \reimp */ -void QGraphicsShaderEffect::draw(QPainter *painter) +void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsShaderEffect); #ifdef QGL_HAVE_CUSTOM_SHADERS - // Find the item's bounds in device coordinates. - QTransform itemToPixmapTransform(painter->worldTransform()); - QRectF deviceBounds = itemToPixmapTransform.mapRect(sourceBoundingRect()); - QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1); - if (deviceRect.isEmpty()) - return; - - if (deviceRect.x() != 0 || deviceRect.y() != 0) - itemToPixmapTransform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y()); - - QPixmap pixmap(deviceRect.size()); - if (!d->source->drawIntoPixmap(&pixmap, itemToPixmapTransform)) - return; - // Set the custom shader on the paint engine. The setOnPainter() // call may fail if the paint engine is not GL2. In that case, // we fall through to drawing the pixmap normally. @@ -274,17 +260,25 @@ void QGraphicsShaderEffect::draw(QPainter *painter) } bool usingShader = d->customShaderStage->setOnPainter(painter); - // Draw using an untransformed painter. - QTransform restoreTransform = painter->worldTransform(); - painter->setWorldTransform(QTransform()); - painter->drawPixmap(deviceRect.topLeft(), pixmap); - painter->setWorldTransform(restoreTransform); + QPoint offset; + if (source->isPixmap()) { + // No point in drawing in device coordinates (pixmap will be scaled anyways). + const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset); + painter->drawPixmap(offset, pixmap); + } else { + // Draw pixmap in device coordinates to avoid pixmap scaling. + const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset); + QTransform restoreTransform = painter->worldTransform(); + painter->setWorldTransform(QTransform()); + painter->drawPixmap(offset, pixmap); + painter->setWorldTransform(restoreTransform); + } // Remove the custom shader to return to normal painting operations. if (usingShader) d->customShaderStage->removeFromPainter(painter); #else - drawSource(painter); + source->draw(painter); #endif } diff --git a/src/opengl/qgraphicsshadereffect.h b/src/opengl/qgraphicsshadereffect.h index 032a233..d9f2d4f 100644 --- a/src/opengl/qgraphicsshadereffect.h +++ b/src/opengl/qgraphicsshadereffect.h @@ -67,7 +67,7 @@ public: void setPixelShaderFragment(const QByteArray& code); protected: - void draw(QPainter *painter); + void draw(QPainter *painter, QGraphicsEffectSource *source); void setUniformsDirty(); virtual void setUniforms(QGLShaderProgram *program); |