[krita] libs/image: Fix working of WrapAround mode when Instant Preview is active

Dmitry Kazakov dimula73 at gmail.com
Fri Apr 1 08:31:50 UTC 2016


Git commit e87a019ea95d7e65da455dfcc6bb363bad2f10b6 by Dmitry Kazakov.
Committed on 01/04/2016 at 08:31.
Pushed by dkazakov into branch 'master'.

Fix working of WrapAround mode when Instant Preview is active

CC:kimageshop at kde.org
Fixes T1195
BUG:356756

M  +1    -1    libs/image/kis_default_bounds.cpp
M  +16   -1    libs/image/kis_image.cc
M  +7    -1    libs/image/kis_image.h
M  +1    -1    libs/image/kis_paint_device.cc

http://commits.kde.org/krita/e87a019ea95d7e65da455dfcc6bb363bad2f10b6

diff --git a/libs/image/kis_default_bounds.cpp b/libs/image/kis_default_bounds.cpp
index 1888f69..1002a14 100644
--- a/libs/image/kis_default_bounds.cpp
+++ b/libs/image/kis_default_bounds.cpp
@@ -55,7 +55,7 @@ QRect KisDefaultBounds::bounds() const
     /**
      * By default return infinite rect to cover everything
      */
-    return m_d->image ? m_d->image->bounds() : infiniteRect;
+    return m_d->image ? m_d->image->effectiveLodBounds() : infiniteRect;
 }
 
 bool KisDefaultBounds::wrapAroundMode() const
diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index 8afdc29..ea7dcac 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -1015,6 +1015,19 @@ QRect KisImage::bounds() const
     return QRect(0, 0, width(), height());
 }
 
+QRect KisImage::effectiveLodBounds() const
+{
+    QRect boundRect = bounds();
+
+    const int lod = currentLevelOfDetail();
+    if (lod > 0) {
+        KisLodTransform t(lod);
+        boundRect = t.map(boundRect);
+    }
+
+    return boundRect;
+}
+
 KisPostExecutionUndoAdapter* KisImage::postExecutionUndoAdapter() const
 {
     return &m_d->postExecutionUndoAdapter;
@@ -1404,6 +1417,8 @@ void KisImage::requestProjectionUpdateImpl(KisNode *node,
                                            const QRect &rect,
                                            const QRect &cropRect)
 {
+    if (rect.isEmpty()) return;
+
     KisNodeGraphListener::requestProjectionUpdate(node, rect);
     m_d->scheduler.updateProjection(node, rect, cropRect);
 }
@@ -1425,7 +1440,7 @@ void KisImage::requestProjectionUpdate(KisNode *node, const QRect& rect)
      * supporting the wrap-around mode will not make much harm.
      */
     if (m_d->wrapAroundModePermitted) {
-        QRect boundRect = bounds();
+        const QRect boundRect = effectiveLodBounds();
         KisWrappedRect splitRect(rect, boundRect);
 
         Q_FOREACH (const QRect &rc, splitRect) {
diff --git a/libs/image/kis_image.h b/libs/image/kis_image.h
index 03dbbff..f0c84a1 100644
--- a/libs/image/kis_image.h
+++ b/libs/image/kis_image.h
@@ -416,10 +416,16 @@ public:
      */
     void mergeMultipleLayers(QList<KisNodeSP> mergedLayers, KisNodeSP putAfter);
 
-    /// This overrides interface for KisDefaultBounds
     /// @return the exact bounds of the image in pixel coordinates.
     QRect bounds() const;
 
+    /**
+     * Returns the actual bounds of the image, taking LevelOfDetail
+     * into account.  This value is used as a bounds() value of
+     * KisDefaultBounds object.
+     */
+    QRect effectiveLodBounds() const;
+
     /// use if the layers have changed _completely_ (eg. when flattening)
     void notifyLayersChanged();
 
diff --git a/libs/image/kis_paint_device.cc b/libs/image/kis_paint_device.cc
index 6d4be13..f5e85bd 100644
--- a/libs/image/kis_paint_device.cc
+++ b/libs/image/kis_paint_device.cc
@@ -471,7 +471,7 @@ KisPaintDevice::Private::KisPaintDeviceStrategy* KisPaintDevice::Private::curren
 
     QRect wrapRect = defaultBounds->bounds();
     if (!wrappedStrategy || wrappedStrategy->wrapRect() != wrapRect) {
-        wrappedStrategy.reset(new KisPaintDeviceWrappedStrategy(defaultBounds->bounds(), q, this));
+        wrappedStrategy.reset(new KisPaintDeviceWrappedStrategy(wrapRect, q, this));
     }
 
     return wrappedStrategy.data();


More information about the kimageshop mailing list