src/hbcore/ovgeffects/hbvgchainedeffect.cpp
changeset 30 80e4d18b72f5
parent 21 4633027730f5
--- a/src/hbcore/ovgeffects/hbvgchainedeffect.cpp	Fri Sep 17 08:32:10 2010 +0300
+++ b/src/hbcore/ovgeffects/hbvgchainedeffect.cpp	Mon Oct 04 00:38:12 2010 +0300
@@ -25,6 +25,7 @@
 
 #include "hbvgchainedeffect_p.h"
 #include "hbvgchainedeffect_p_p.h"
+#include "hbinstance_p.h"
 #include <QPainter>
 
 /*!
@@ -202,17 +203,29 @@
     // into a pixmap first (works only for sw-based effects).
     QPixmap src = d->srcPixmap;
     QVariant srcVgImage = vgImage;
-    QSize srcVgImageSize = vgImageSize;
-    QPointF srcOffset = offset;
     foreach(HbVgEffect * effect, d->effects) {
         if (effect->chainBehavior() == ChainBehavAsSource) {
             // Restore the world transform temporarily because the sw
             // version has slightly different semantics.
             painter->setWorldTransform(d->worldTransform);
-            effect->performEffectSw(painter, &src, &srcOffset);
+            QPixmap modSrc = src;
+            QPointF modOffset;
+            // This can be nothing but a mask effect and it can produce smaller output if
+            // the source is based on a scroll area (or anything that clips its children,
+            // as long as the source pixmaps are not restricted to obey the clipping). So
+            // have its output in a temporary pixmap and copy it into the original source
+            // pixmap to the (hopefully) appropriate position afterwards.
+            effect->performEffectSw(painter, &modSrc, &modOffset);
+            qreal dx = modOffset.x() - offset.x();
+            qreal dy = modOffset.y() - offset.y(); 
             painter->setWorldTransform(QTransform());
-            srcVgImage = QVariant::fromValue<VGImage>(qPixmapToVGImage(src));
-            srcVgImageSize = src.size();
+            if (dx >= 0 && dy >= 0) {
+                src.fill(Qt::transparent);
+                QPainter p(&src);
+                p.drawPixmap(QPointF(dx, dy), modSrc);
+                p.end();
+                srcVgImage = QVariant::fromValue<VGImage>(qPixmapToVGImage(src));
+            }
             break;
         }
     }
@@ -228,14 +241,17 @@
         effD->srcPixmap = src;
         effD->worldTransform = d->worldTransform;
         // Draw.
-        effect->performEffect(painter, srcOffset, srcVgImage, srcVgImageSize);
+        effect->performEffect(painter, offset, srcVgImage, vgImageSize);
         // The flags must be cleared manually for the contained effects.
         effD->paramsChanged = effD->cacheInvalidated = false;
+        if (effD->alwaysClearPixmaps || HbInstancePrivate::d_ptr()->mDropHiddenIconData) {
+            effD->clearPixmaps();
+        }
         hadNormalEffects = true;
     }
     // If there are no effects in the chain then just draw the source.
     if (d->effects.isEmpty() || !hadNormalEffects) {
-        painter->drawPixmap(srcOffset, src);
+        painter->drawPixmap(offset, src);
     }
 
 #else