src/hbcore/ovgeffects/hbvgchainedeffect.cpp
changeset 5 627c4a0fd0e7
parent 0 16d8024aca5e
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
   142  * \reimp
   142  * \reimp
   143  */
   143  */
   144 QRectF HbVgChainedEffect::boundingRectFor(const QRectF &rect) const
   144 QRectF HbVgChainedEffect::boundingRectFor(const QRectF &rect) const
   145 {
   145 {
   146     Q_D(const HbVgChainedEffect);
   146     Q_D(const HbVgChainedEffect);
   147     if (d->effects.empty())
   147     if (d->effects.empty()) {
   148         return rect;
   148         return rect;
       
   149     }
   149     // find out the bounding rect that covers all the effects
   150     // find out the bounding rect that covers all the effects
   150     QRectF result;
   151     QRectF result;
   151     foreach (HbVgEffect *effect, d->effects) {
   152     foreach(HbVgEffect * effect, d->effects) {
   152         QRectF br = effect->boundingRectFor(rect);
   153         QRectF br = effect->boundingRectFor(rect);
   153         if (result.isNull()) {
   154         if (result.isNull()) {
   154             result = br;
   155             result = br;
   155         } else {
   156         } else {
   156             if (br.left() < result.left())
   157             if (br.left() < result.left()) {
   157                 result.setLeft(br.left());
   158                 result.setLeft(br.left());
   158             if (br.top() < result.top())
   159             }
       
   160             if (br.top() < result.top()) {
   159                 result.setTop(br.top());
   161                 result.setTop(br.top());
   160             if (br.right() > result.right())
   162             }
       
   163             if (br.right() > result.right()) {
   161                 result.setRight(br.right());
   164                 result.setRight(br.right());
   162             if (br.bottom() > result.bottom())
   165             }
       
   166             if (br.bottom() > result.bottom()) {
   163                 result.setBottom(br.bottom());
   167                 result.setBottom(br.bottom());
       
   168             }
   164         }
   169         }
   165     }
   170     }
   166     return result;
   171     return result;
   167 }
   172 }
   168 
   173 
   174                                       const QVariant &vgImage,
   179                                       const QVariant &vgImage,
   175                                       const QSize &vgImageSize)
   180                                       const QSize &vgImageSize)
   176 {
   181 {
   177 #ifdef HB_EFFECTS_OPENVG
   182 #ifdef HB_EFFECTS_OPENVG
   178     Q_D(HbVgChainedEffect);
   183     Q_D(HbVgChainedEffect);
   179     foreach (HbVgEffect *effect, d->effects) {
   184     foreach(HbVgEffect * effect, d->effects) {
   180         // Set up srcPixmap and others for the individual effects
   185         // Set up srcPixmap and others for the individual effects
   181         // because the base class does it only for us, not for the
   186         // because the base class does it only for us, not for the
   182         // contained ones.
   187         // contained ones.
   183         HbVgEffectPrivate *effD = HbVgEffectPrivate::d_ptr(effect);
   188         HbVgEffectPrivate *effD = HbVgEffectPrivate::d_ptr(effect);
   184         effD->srcPixmap = d->srcPixmap;
   189         effD->srcPixmap = d->srcPixmap;
   187         effect->performEffect(painter, offset, vgImage, vgImageSize);
   192         effect->performEffect(painter, offset, vgImage, vgImageSize);
   188         // The flags must be cleared manually for the contained effects.
   193         // The flags must be cleared manually for the contained effects.
   189         effD->paramsChanged = effD->cacheInvalidated = false;
   194         effD->paramsChanged = effD->cacheInvalidated = false;
   190     }
   195     }
   191     // If there are no effects in the chain then just draw the source.
   196     // If there are no effects in the chain then just draw the source.
   192     if (d->effects.isEmpty())
   197     if (d->effects.isEmpty()) {
   193         painter->drawPixmap(offset, d->srcPixmap);
   198         painter->drawPixmap(offset, d->srcPixmap);
       
   199     }
   194 
   200 
   195 #else
   201 #else
   196     Q_UNUSED(painter);
   202     Q_UNUSED(painter);
   197     Q_UNUSED(offset);
   203     Q_UNUSED(offset);
   198     Q_UNUSED(vgImage);
   204     Q_UNUSED(vgImage);
   205 */
   211 */
   206 void HbVgChainedEffectPrivate::notifyCacheInvalidated()
   212 void HbVgChainedEffectPrivate::notifyCacheInvalidated()
   207 {
   213 {
   208     // Distribute the new value of cacheInvalidated to all the
   214     // Distribute the new value of cacheInvalidated to all the
   209     // contained effects.
   215     // contained effects.
   210     foreach (HbVgEffect *effect, effects) {
   216     foreach(HbVgEffect * effect, effects) {
   211         HbVgEffectPrivate *effD = HbVgEffectPrivate::d_ptr(effect);
   217         HbVgEffectPrivate *effD = HbVgEffectPrivate::d_ptr(effect);
   212         effD->cacheInvalidated = true;
   218         effD->cacheInvalidated = true;
   213         effD->notifyCacheInvalidated();
   219         effD->notifyCacheInvalidated();
   214     }
   220     }
   215 }
   221 }