src/opengl/qgraphicsshadereffect.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   239 }
   239 }
   240 
   240 
   241 /*#
   241 /*#
   242     \reimp
   242     \reimp
   243 */
   243 */
   244 void QGraphicsShaderEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
   244 void QGraphicsShaderEffect::draw(QPainter *painter)
   245 {
   245 {
   246     Q_D(QGraphicsShaderEffect);
   246     Q_D(QGraphicsShaderEffect);
   247 
   247 
   248 #ifdef QGL_HAVE_CUSTOM_SHADERS
   248 #ifdef QGL_HAVE_CUSTOM_SHADERS
   249     // Set the custom shader on the paint engine.  The setOnPainter()
   249     // Set the custom shader on the paint engine.  The setOnPainter()
   254             (this, d->pixelShaderFragment);
   254             (this, d->pixelShaderFragment);
   255     }
   255     }
   256     bool usingShader = d->customShaderStage->setOnPainter(painter);
   256     bool usingShader = d->customShaderStage->setOnPainter(painter);
   257 
   257 
   258     QPoint offset;
   258     QPoint offset;
   259     if (source->isPixmap()) {
   259     if (sourceIsPixmap()) {
   260         // No point in drawing in device coordinates (pixmap will be scaled anyways).
   260         // No point in drawing in device coordinates (pixmap will be scaled anyways).
   261         const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
   261         const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset);
   262         painter->drawPixmap(offset, pixmap);
   262         painter->drawPixmap(offset, pixmap);
   263     } else {
   263     } else {
   264         // Draw pixmap in device coordinates to avoid pixmap scaling.
   264         // Draw pixmap in device coordinates to avoid pixmap scaling.
   265         const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
   265         const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
   266         QTransform restoreTransform = painter->worldTransform();
   266         QTransform restoreTransform = painter->worldTransform();
   267         painter->setWorldTransform(QTransform());
   267         painter->setWorldTransform(QTransform());
   268         painter->drawPixmap(offset, pixmap);
   268         painter->drawPixmap(offset, pixmap);
   269         painter->setWorldTransform(restoreTransform);
   269         painter->setWorldTransform(restoreTransform);
   270     }
   270     }
   271 
   271 
   272     // Remove the custom shader to return to normal painting operations.
   272     // Remove the custom shader to return to normal painting operations.
   273     if (usingShader)
   273     if (usingShader)
   274         d->customShaderStage->removeFromPainter(painter);
   274         d->customShaderStage->removeFromPainter(painter);
   275 #else
   275 #else
   276     source->draw(painter);
   276     drawSource(painter);
   277 #endif
   277 #endif
   278 }
   278 }
   279 
   279 
   280 /*#
   280 /*#
   281     Sets the custom uniform variables on this shader effect to
   281     Sets the custom uniform variables on this shader effect to