src/hbcore/effects/hbeffectgroup.cpp
changeset 30 80e4d18b72f5
parent 21 4633027730f5
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
    39 #include <QGraphicsView>
    39 #include <QGraphicsView>
    40 
    40 
    41 #ifdef HB_FILTER_EFFECTS
    41 #ifdef HB_FILTER_EFFECTS
    42 #include "hbvgeffect_p.h"
    42 #include "hbvgeffect_p.h"
    43 #include "hbvgchainedeffect_p.h"
    43 #include "hbvgchainedeffect_p.h"
       
    44 #include "hbvgmaskeffect_p.h"
    44 #endif
    45 #endif
    45 
    46 
    46 static const char effect_fw_marker[] = "effw_chain";
    47 static const char effect_fw_marker[] = "effw_chain";
    47 
    48 
    48 HbEffectGroup::HbEffectGroup(
    49 HbEffectGroup::HbEffectGroup(
   284             // existing effects to the chain. Supporting the 'after' case is up
   285             // existing effects to the chain. Supporting the 'after' case is up
   285             // to the widget. However we can only support effects that are in a
   286             // to the widget. However we can only support effects that are in a
   286             // chain, keeping single effects is not possible due to ownership
   287             // chain, keeping single effects is not possible due to ownership
   287             // issues.
   288             // issues.
   288             HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(mTargetItem->graphicsEffect());
   289             HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(mTargetItem->graphicsEffect());
   289             // Effects set by another HbEffectGroup instance must be ignored
   290             if (c) {
   290             // here, those should go away because they probably would not work
       
   291             // well together anyway.
       
   292             if (c && c->objectName().compare(QLatin1String(effect_fw_marker))) {
       
   293                 QList<HbVgEffect *> effects = c->takeAll();
   291                 QList<HbVgEffect *> effects = c->takeAll();
   294                 HbVgChainedEffect *newChain = vgEffect();
   292                 HbVgChainedEffect *newChain = vgEffect();
       
   293                 // Effects set by another HbEffectGroup instance must be ignored
       
   294                 // here, those should go away because they probably would not work
       
   295                 // well together anyway.
       
   296                 bool chainIsFromEffectFw = c->objectName().compare(QLatin1String(effect_fw_marker)) == 0;
   295                 foreach (HbVgEffect *effect, effects) {
   297                 foreach (HbVgEffect *effect, effects) {
   296                     newChain->add(effect);
   298                     // Special handling for mask effects: These must be preserved always.
       
   299                     if (!chainIsFromEffectFw || qobject_cast<HbVgMaskEffect *>(effect) != 0) {
       
   300                         newChain->add(effect);
       
   301                     } else {
       
   302                         delete effect;
       
   303                     }
   297                 }
   304                 }
   298             }
   305             }
   299         }
   306         }
   300         vgEffect()->install(mTargetItem);
   307         vgEffect()->install(mTargetItem);
   301         mVgEffectActivated = true;
   308         mVgEffectActivated = true;