src/hbcore/ovgeffects/hbvgeffect.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 30 80e4d18b72f5
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
   396  *
   396  *
   397  * Note that the source pixmap is not requested and the painter's
   397  * Note that the source pixmap is not requested and the painter's
   398  * world transform is not reset before calling this, in contrast to
   398  * world transform is not reset before calling this, in contrast to
   399  * performEffect(). (this means that neither d->srcPixmap nor
   399  * performEffect(). (this means that neither d->srcPixmap nor
   400  * d->worldTransform is available).
   400  * d->worldTransform is available).
   401  */
   401  *
   402 void HbVgEffect::performEffectSw(QPainter *painter)
   402  * If the effect is able to render itself into a pixmap then it should do so
   403 {
   403  * when \a result and \a resultPos are not 0. In this case the effect should not
   404     drawSource(painter);
   404  * paint anything onto \a devicePainter but all its output should go into a
       
   405  * newly created pixmap starting at position (0, 0). This pixmap is then
       
   406  * returned to the caller in \a result. The offset that will be needed when
       
   407  * painting the pixmap onto the devicePainter is passed back in \a resultPos.
       
   408  */
       
   409 void HbVgEffect::performEffectSw(QPainter *devicePainter, QPixmap *result, QPointF *resultPos)
       
   410 {
       
   411     Q_UNUSED(result);
       
   412     Q_UNUSED(resultPos);
       
   413     drawSource(devicePainter);
   405 }
   414 }
   406 
   415 
   407 /*!
   416 /*!
   408  * \reimp
   417  * \reimp
   409  *
   418  *
   426     // is not using OpenVG.
   435     // is not using OpenVG.
   427     QPaintEngine *paintEngine = painter->paintEngine();
   436     QPaintEngine *paintEngine = painter->paintEngine();
   428     if (d->forceSwMode || !paintEngine || paintEngine->type() != QPaintEngine::OpenVG) {
   437     if (d->forceSwMode || !paintEngine || paintEngine->type() != QPaintEngine::OpenVG) {
   429         // No sourcePixmap() and world transform change here because
   438         // No sourcePixmap() and world transform change here because
   430         // in most cases we will just call drawSource().
   439         // in most cases we will just call drawSource().
   431         performEffectSw(painter);
   440         performEffectSw(painter, 0, 0);
   432         d->paramsChanged = d->cacheInvalidated = false;
   441         d->paramsChanged = d->cacheInvalidated = false;
   433         return;
   442         return;
   434     }
   443     }
   435 
   444 
   436 #ifdef HB_EFFECTS_OPENVG
   445 #ifdef HB_EFFECTS_OPENVG
   618     Q_D(const HbVgEffect);
   627     Q_D(const HbVgEffect);
   619     return d->rootEffect ? d->rootEffect->sourceBoundingRect() : sourceBoundingRect();
   628     return d->rootEffect ? d->rootEffect->sourceBoundingRect() : sourceBoundingRect();
   620 }
   629 }
   621 
   630 
   622 /*!
   631 /*!
       
   632  * Calls sourcePixmap() for this effect, or, in case of chained effects, for the
       
   633  * root of the chain.
       
   634  */
       
   635 QPixmap HbVgEffect::sourcePixmapForRoot(Qt::CoordinateSystem system, QPoint *offset)
       
   636 {
       
   637     Q_D(HbVgEffect);
       
   638     return d->rootEffect
       
   639         ? d->rootEffect->sourcePixmapForRoot(system, offset)
       
   640         : sourcePixmap(system, offset);
       
   641 }
       
   642 
       
   643 /*!
   623  * Installs the effect on a given graphics item. This is merely a wrapper to
   644  * Installs the effect on a given graphics item. This is merely a wrapper to
   624  * QGraphicsItem::setGraphicsEffect(). To uninstall the effect use
   645  * QGraphicsItem::setGraphicsEffect(). To uninstall the effect use
   625  * setGraphicsEffect in the usual way (i.e. pass null). This function will do
   646  * setGraphicsEffect in the usual way (i.e. pass null). This function will do
   626  * nothing if \a item is null.
   647  * nothing if \a item is null.
   627  *
   648  *
   635         Q_D(HbVgEffect);
   656         Q_D(HbVgEffect);
   636         d->sourceGraphicsItem = item;
   657         d->sourceGraphicsItem = item;
   637         item->setGraphicsEffect(this);
   658         item->setGraphicsEffect(this);
   638     }
   659     }
   639 }
   660 }
       
   661 
       
   662 /*!
       
   663  * A sw-based mask effect should return ChainBehavAsSource. Anything else should
       
   664  * stick to the default ChainBehavNormal. There can only be 0 or 1 effect with
       
   665  * ChainBehavAsSource in a chain.
       
   666  */
       
   667 HbVgEffect::ChainBehavior HbVgEffect::chainBehavior() const
       
   668 {
       
   669     return ChainBehavNormal;
       
   670 }