[graphics/krita] libs: Fill Layers: create layer without additional update jobs

L. E. Segovia null at kde.org
Wed Aug 19 00:05:53 BST 2020


Git commit 7c4230cf1e368d1fb03215700af3b0834e06c632 by L. E. Segovia.
Committed on 18/08/2020 at 22:55.
Pushed by lsegovia into branch 'master'.

Fill Layers: create layer without additional update jobs

This still preserves a last setFilter which fixes in-place the
configuration, as the updates are throttled via the dialog's signal
compressor.

CCMAIL: kimageshop at kde.org
(cherry picked from commit 8c3a4c8dc9268bf434007e4ce07b2a8821cec405)

M  +21   -4    libs/image/generator/kis_generator_layer.cpp
M  +13   -1    libs/image/generator/kis_generator_layer.h
M  +3    -3    libs/image/generator/kis_generator_stroke_strategy.cpp
M  +3    -2    libs/ui/dialogs/kis_dlg_generator_layer.cpp

https://invent.kde.org/graphics/krita/commit/7c4230cf1e368d1fb03215700af3b0834e06c632

diff --git a/libs/image/generator/kis_generator_layer.cpp b/libs/image/generator/kis_generator_layer.cpp
index 83f3edb34c..fc34d9394e 100644
--- a/libs/image/generator/kis_generator_layer.cpp
+++ b/libs/image/generator/kis_generator_layer.cpp
@@ -78,13 +78,18 @@ KisGeneratorLayer::~KisGeneratorLayer()
 }
 
 void KisGeneratorLayer::setFilter(KisFilterConfigurationSP filterConfig)
+{
+    setFilterWithoutUpdate(filterConfig);
+    m_d->updateSignalCompressor.start();
+}
+
+void KisGeneratorLayer::setFilterWithoutUpdate(KisFilterConfigurationSP filterConfig)
 {
     KisSelectionBasedLayer::setFilter(filterConfig);
     {
         QMutexLocker(&m_d->mutex);
         m_d->preparedRect = QRect();
     }
-    m_d->updateSignalCompressor.start();
 }
 
 void KisGeneratorLayer::slotDelayedStaticUpdate()
@@ -116,7 +121,7 @@ void KisGeneratorLayer::requestUpdateJobsWithStroke(KisStrokeId strokeId, KisFil
 
     if (filterConfig != m_d->preparedForFilter) {
         locker.unlock();
-        resetCache();
+        resetCacheWithoutUpdate();
         locker.relock();
     }
 
@@ -144,8 +149,9 @@ void KisGeneratorLayer::requestUpdateJobsWithStroke(KisStrokeId strokeId, KisFil
     m_d->preparedForFilter = filterConfig;
 }
 
-void KisGeneratorLayer::previewWithStroke(const KisStrokeId strokeId, const KisFilterConfigurationSP filterConfig)
+void KisGeneratorLayer::previewWithStroke(const KisStrokeId strokeId)
 {
+    KisFilterConfigurationSP filterConfig = filter();
     KIS_SAFE_ASSERT_RECOVER_RETURN(filterConfig);
 
     requestUpdateJobsWithStroke(strokeId, filterConfig);
@@ -215,6 +221,12 @@ void KisGeneratorLayer::setY(qint32 y)
 }
 
 void KisGeneratorLayer::resetCache()
+{
+    resetCacheWithoutUpdate();
+    m_d->updateSignalCompressor.start();
+}
+
+void KisGeneratorLayer::resetCacheWithoutUpdate()
 {
     KisSelectionBasedLayer::resetCache();
     {
@@ -225,6 +237,11 @@ void KisGeneratorLayer::resetCache()
 
 void KisGeneratorLayer::setDirty(const QVector<QRect> &rects)
 {
-    KisSelectionBasedLayer::setDirty(rects);
+    setDirtyWithoutUpdate(rects);
+    m_d->updateSignalCompressor.start();
 }
 
+void KisGeneratorLayer::setDirtyWithoutUpdate(const QVector<QRect> &rects)
+{
+    KisSelectionBasedLayer::setDirty(rects);
+}
diff --git a/libs/image/generator/kis_generator_layer.h b/libs/image/generator/kis_generator_layer.h
index ad8f1171b9..9ab60cc22d 100644
--- a/libs/image/generator/kis_generator_layer.h
+++ b/libs/image/generator/kis_generator_layer.h
@@ -54,6 +54,10 @@ public:
     }
 
     void setFilter(KisFilterConfigurationSP filterConfig) override;
+    /**
+     * Changes the filter configuration without triggering an update.
+     */
+    void setFilterWithoutUpdate(KisFilterConfigurationSP filterConfig);
 
     bool accept(KisNodeVisitor &) override;
     void accept(KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override;
@@ -70,10 +74,14 @@ public:
      * re-runs the generator with the specified configuration.
      * Used for previewing the layer inside the stroke.
      */
-    void previewWithStroke(const KisStrokeId stroke, const KisFilterConfigurationSP configuration);
+    void previewWithStroke(const KisStrokeId stroke);
 
     using KisSelectionBasedLayer::setDirty;
     void setDirty(const QVector<QRect> &rects) override;
+    /**
+     * Updates the selected tiles without triggering the update job.
+     */
+    void setDirtyWithoutUpdate(const QVector<QRect> &rects);
     void setX(qint32 x) override;
     void setY(qint32 y) override;
 
@@ -87,6 +95,10 @@ private:
      * Injects render jobs into the given stroke.
      */
     void requestUpdateJobsWithStroke(const KisStrokeId stroke, const KisFilterConfigurationSP configuration);
+    /**
+     * Resets the projection cache without triggering the update job.
+     */
+    void resetCacheWithoutUpdate();
 
 public:
     // KisIndirectPaintingSupport
diff --git a/libs/image/generator/kis_generator_stroke_strategy.cpp b/libs/image/generator/kis_generator_stroke_strategy.cpp
index 8a41803f3b..68060e3d80 100644
--- a/libs/image/generator/kis_generator_stroke_strategy.cpp
+++ b/libs/image/generator/kis_generator_stroke_strategy.cpp
@@ -28,7 +28,7 @@
 #include "kis_generator_stroke_strategy.h"
 
 KisGeneratorStrokeStrategy::KisGeneratorStrokeStrategy()
-    : KisRunnableBasedStrokeStrategy(QLatin1String("KisGenerator"), kundo2_noi18n("KisGenerator"))
+    : KisRunnableBasedStrokeStrategy(QLatin1String("KisGenerator"), kundo2_i18n("Fill Layer Render"))
 {
     enableJob(KisSimpleStrokeStrategy::JOB_INIT, true, KisStrokeJobData::BARRIER, KisStrokeJobData::EXCLUSIVE);
     enableJob(KisSimpleStrokeStrategy::JOB_DOSTROKE);
@@ -62,7 +62,7 @@ QVector<KisStrokeJobData *>KisGeneratorStrokeStrategy::createJobsData(const KisG
 
                     // HACK ALERT!!!
                     // this avoids cyclic loop with KisRecalculateGeneratorLayerJob::run()
-                    const_cast<KisGeneratorLayerSP &>(layer)->setDirty({tile});
+                    const_cast<KisGeneratorLayerSP &>(layer)->setDirtyWithoutUpdate({tile});
                 });
             }
         } else {
@@ -75,7 +75,7 @@ QVector<KisStrokeJobData *>KisGeneratorStrokeStrategy::createJobsData(const KisG
 
                 // HACK ALERT!!!
                 // this avoids cyclic loop with KisRecalculateGeneratorLayerJob::run()
-                const_cast<KisGeneratorLayerSP &>(layer)->setDirty({rc});
+                const_cast<KisGeneratorLayerSP &>(layer)->setDirtyWithoutUpdate({rc});
             });
         }
     }
diff --git a/libs/ui/dialogs/kis_dlg_generator_layer.cpp b/libs/ui/dialogs/kis_dlg_generator_layer.cpp
index 0ead04e147..24569621ce 100644
--- a/libs/ui/dialogs/kis_dlg_generator_layer.cpp
+++ b/libs/ui/dialogs/kis_dlg_generator_layer.cpp
@@ -72,7 +72,7 @@ KisDlgGeneratorLayer::KisDlgGeneratorLayer(const QString & defaultName, KisViewM
     connect(&m_compressor, SIGNAL(timeout()), this, SLOT(slotDelayedPreviewGenerator()));
 
     if (layer && !isEditing) {
-        layer->setFilter(configuration());
+        slotDelayedPreviewGenerator();
     }
 }
 
@@ -123,7 +123,8 @@ void KisDlgGeneratorLayer::slotNameChanged(const QString & text)
 void KisDlgGeneratorLayer::slotDelayedPreviewGenerator()
 {
     if (!m_stroke.isNull()) {
-        layer->previewWithStroke(m_stroke, configuration());
+        layer->setFilterWithoutUpdate(configuration());
+        layer->previewWithStroke(m_stroke);
     }
 }
 



More information about the kimageshop mailing list