Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix clone layers resetting the animation cache

Dmitry Kazakov0dd3c7bf03ac
diff --git a/libs/image/KisProjectionUpdateFlags.h b/libs/image/KisProjectionUpdateFlags.h
new file mode 100644
index 0000000000..a769af3cbc
--- /dev/null
+++ b/libs/image/KisProjectionUpdateFlags.h
@@ -0,0 +1,35 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Dmitry Kazakov <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef KISPROJECTIONUPDATEFLAGS_H
+#define KISPROJECTIONUPDATEFLAGS_H
+
+enum class KisProjectionUpdateFlag
+{
+ None = 0x0,
+ /**
+ * NoFilthy:
+ *
+ * Initiate a stack regeneration skipping the recalculation of the
+ * filthy node's projection.
+ *
+ * Works exactly as pseudoFilthy->setDirty() with the only
+ * exception that pseudoFilthy::updateProjection() will not be
+ * called. That is used by KisRecalculateTransformMaskJob to avoid
+ * cyclic dependencies.
+ */
+ NoFilthy = 0x1,
+
+ /**
+ * DontInvalidateFrames
+ *
+ * This update pass will not trigger any frame cache invalidations
+ */
+ DontInvalidateFrames = 0x2
+};
+Q_DECLARE_FLAGS(KisProjectionUpdateFlags, KisProjectionUpdateFlag)
+Q_DECLARE_OPERATORS_FOR_FLAGS(KisProjectionUpdateFlags)
+
+#endif // KISPROJECTIONUPDATEFLAGS_H
diff --git a/libs/image/commands/kis_image_layer_move_command.cpp b/libs/image/commands/kis_image_layer_move_command.cpp
index e95922e152..4aad6b2265 100644
--- a/libs/image/commands/kis_image_layer_move_command.cpp
+++ b/libs/image/commands/kis_image_layer_move_command.cpp
@@ -60,7 +60,7 @@ void KisImageLayerMoveCommand::redo()
}
if (m_doUpdates) {
- image->refreshGraphAsync(m_prevParent, KisImage::NoFilthyUpdate);
+ image->refreshGraphAsync(m_prevParent, KisProjectionUpdateFlag::NoFilthy);
if (m_newParent != m_prevParent) {
m_layer->setDirty(image->bounds());
}
@@ -76,7 +76,7 @@ void KisImageLayerMoveCommand::undo()
image->moveNode(m_layer, m_prevParent, m_prevAbove);
if (m_doUpdates) {
- image->refreshGraphAsync(m_newParent, KisImage::NoFilthyUpdate);
+ image->refreshGraphAsync(m_newParent, KisProjectionUpdateFlag::NoFilthy);
if (m_newParent != m_prevParent) {
m_layer->setDirty(image->bounds());
}
diff --git a/libs/image/kis_base_rects_walker.h b/libs/image/kis_base_rects_walker.h
index 58fc40d8eb..118a607781 100644
--- a/libs/image/kis_base_rects_walker.h
+++ b/libs/image/kis_base_rects_walker.h
@@ -68,13 +68,15 @@ public:
struct CloneNotification {
CloneNotification() {}
- CloneNotification(KisNodeSP node, const QRect &dirtyRect)
+ CloneNotification(KisNodeSP node, const QRect &dirtyRect,
+ bool dontInvalidateFrames)
: m_layer(qobject_cast<KisLayer*>(node.data())),
- m_dirtyRect(dirtyRect) {}
+ m_dirtyRect(dirtyRect),
+ m_dontInvalidateFrames(dontInvalidateFrames) {}
void notify() {
Q_ASSERT(m_layer); // clones are possible for layers only
- m_layer->updateClones(m_dirtyRect);
+ m_layer->updateClones(m_dirtyRect, m_dontInvalidateFrames);
}
private:
@@ -82,6 +84,7 @@ public:
KisLayerSP m_layer;
QRect m_dirtyRect;
+ bool m_dontInvalidateFrames {false};
};
typedef QVector<CloneNotification> CloneNotificationsVector;
@@ -172,6 +175,14 @@ public:
m_graphChecksum == m_startNode->graphSequenceNumber();
}
+ inline void setClonesDontInvalidateFrames(bool value) {
+ m_clonesDontInvalidateFrames = value;
+ }
+
+ inline bool clonesDontInvalidateFrames() const {
+ return m_clonesDontInvalidateFrames;
+ }
+
inline void setCropRect(QRect cropRect) {
m_cropRect = cropRect;
}
@@ -323,7 +334,7 @@ protected:
if(hasClones(node) && position & (N_FILTHY | N_FILTHY_PROJECTION | N_EXTRA)) {
m_cloneNotifications.append(
- CloneNotification(node, m_resultUncroppedChangeRect));
+ CloneNotification(node, m_resultUncroppedChangeRect, m_clonesDontInvalidateFrames));
}
}
@@ -523,6 +534,8 @@ private:
QRect m_lastNeedRect;
int m_levelOfDetail {0};
+
+ bool m_clonesDontInvalidateFrames {false};
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KisBaseRectsWalker::SubtreeVisitFlags);
diff --git a/libs/image/kis_clone_layer.cpp b/libs/image/kis_clone_layer.cpp
index 54b4eedd96..56b8d6bf21 100644
--- a/libs/image/kis_clone_layer.cpp
+++ b/libs/image/kis_clone_layer.cpp
@@ -153,7 +153,7 @@ void KisCloneLayer::copyOriginalToProjection(const KisPaintDeviceSP original,
KisPainter::copyAreaOptimized(rect.topLeft(), original, projection, copyRect);
}
-void KisCloneLayer::setDirtyOriginal(const QRect &rect)
+void KisCloneLayer::setDirtyOriginal(const QRect &rect, bool dontInvalidateFrames)
{
/**
* The original will be updated when the clone becomes visible
@@ -167,7 +167,11 @@ void KisCloneLayer::setDirtyOriginal(const QRect &rect)
* "copyOriginalToProjection" coordinate system. Now
* everything is done in "original()" space.
*/
- KisLayer::setDirty(rect);
+ if (!dontInvalidateFrames) {
+ KisLayer::setDirty(rect);
+ } else {
+ KisLayer::setDirtyDontResetAnimationCache(rect);
+ }
}
void KisCloneLayer::notifyParentVisibilityChanged(bool value)
diff --git a/libs/image/kis_clone_layer.h b/libs/image/kis_clone_layer.h
index 2c8cad5989..2c0f675887 100644
--- a/libs/image/kis_clone_layer.h
+++ b/libs/image/kis_clone_layer.h
@@ -98,7 +98,7 @@ public:
* This function is called by the original to notify
* us that it is dirty
*/
- void setDirtyOriginal(const QRect &rect);
+ void setDirtyOriginal(const QRect &rect, bool dontInvalidateFrames);
QRect needRectOnSourceForMasks(const QRect &rc) const;
diff --git a/libs/image/kis_full_refresh_walker.h b/libs/image/kis_full_refresh_walker.h
index 57db8734b8..e85808d32b 100644
--- a/libs/image/kis_full_refresh_walker.h
+++ b/libs/image/kis_full_refresh_walker.h
@@ -20,7 +20,7 @@ public:
public:
KisFullRefreshWalker(QRect cropRect, Flags flags = None)
: KisRefreshSubtreeWalker(cropRect, flags | DontAdjustChangeRect),
- KisMergeWalker(cropRect, NO_FILTHY)
+ KisMergeWalker(cropRect, NO_FILTHY | (flags.testFlag(ClonesDontInvalidateFrames) ? CLONES_DONT_INVALIDATE_FRAMES : DEFAULT))
{
}
diff --git a/libs/image/kis_image.cc b/libs/image/kis_image.cc
index 5f6a3b16de..4f9df9c6e8 100644
--- a/libs/image/kis_image.cc
+++ b/libs/image/kis_image.cc
@@ -281,6 +281,11 @@ public:
QPointF axesCenter;
bool allowMasksOnRootNode = false;
+ void requestProjectionUpdateImpl(KisNode *node,
+ const QVector<QRect> &rects,
+ const QRect &cropRect,
+ KisProjectionUpdateFlags flags);
+
bool tryCancelCurrentStrokeAsync();
void notifyProjectionUpdatedInPatches(const QRect &rc, QVector<KisRunnableStrokeJobData *> &jobs);
@@ -2139,22 +2144,7 @@ void KisImage::initialRefreshGraph()
waitForDone();
}
-void KisImage::refreshGraphAsync(KisNodeSP root, UpdateFlags flags)
-{
- refreshGraphAsync(root, bounds(), bounds(), flags);
-}
-
-void KisImage::refreshGraphAsync(KisNodeSP root, const QRect &rc, UpdateFlags flags)
-{
- refreshGraphAsync(root, rc, bounds(), flags);
-}
-
-void KisImage::refreshGraphAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect, UpdateFlags flags)
-{
- refreshGraphAsync(root, QVector<QRect>({rc}), cropRect, flags);
-}
-
-void KisImage::refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect, UpdateFlags flags)
+void KisImage::refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
{
if (!root) root = m_d->rootLayer;
@@ -2173,50 +2163,11 @@ void KisImage::refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, co
}
}
- m_d->animationInterface->notifyNodeChanged(root.data(), rects, true);
-
- if (flags & NoFilthyUpdate) {
- m_d->scheduler.fullRefreshAsyncNoFilthy(root, rects, cropRect);
- } else {
- m_d->scheduler.fullRefreshAsync(root, rects, cropRect);
- }
-}
-
-
-void KisImage::requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QRect &rc, const QRect &cropRect)
-{
- requestProjectionUpdateNoFilthy(pseudoFilthy, rc, cropRect, true);
-}
-
-void KisImage::requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QRect &rc, const QRect &cropRect, const bool resetAnimationCache)
-{
- requestProjectionUpdateNoFilthy(pseudoFilthy, QVector<QRect>({rc}), cropRect, resetAnimationCache);
-}
-
-void KisImage::requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache)
-{
- KIS_ASSERT_RECOVER_RETURN(pseudoFilthy);
-
- /**
- * We iterate through the filters in a reversed way. It makes the most nested filters
- * to execute first.
- */
- for (auto it = m_d->projectionUpdatesFilters.rbegin();
- it != m_d->projectionUpdatesFilters.rend();
- ++it) {
-
- KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
-
- if ((*it)->filterProjectionUpdateNoFilthy(this, pseudoFilthy.data(), rects, cropRect, resetAnimationCache)) {
- return;
- }
- }
-
- if (resetAnimationCache) {
- m_d->animationInterface->notifyNodeChanged(pseudoFilthy.data(), rects, false);
+ if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
+ m_d->animationInterface->notifyNodeChanged(root.data(), rects, true);
}
- m_d->scheduler.updateProjectionNoFilthy(pseudoFilthy, rects, cropRect);
+ m_d->scheduler.fullRefreshAsync(root, rects, cropRect, flags);
}
void KisImage::addSpontaneousJob(KisSpontaneousJob *spontaneousJob)
@@ -2353,16 +2304,18 @@ void KisImage::notifySelectionChanged()
}
}
-void KisImage::requestProjectionUpdateImpl(KisNode *node,
- const QVector<QRect> &rects,
- const QRect &cropRect)
+void KisImage::KisImagePrivate::
+ requestProjectionUpdateImpl(KisNode *node,
+ const QVector<QRect> &rects,
+ const QRect &cropRect,
+ KisProjectionUpdateFlags flags)
{
if (rects.isEmpty()) return;
- m_d->scheduler.updateProjection(node, rects, cropRect);
+ scheduler.updateProjection(node, rects, cropRect, flags);
}
-void KisImage::requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache)
+void KisImage::requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags)
{
/**
* We iterate through the filters in a reversed way. It makes the most nested filters
@@ -2374,12 +2327,12 @@ void KisImage::requestProjectionUpdate(KisNode *node, const QVector<QRect> &rect
KIS_SAFE_ASSERT_RECOVER(*it) { continue; }
- if ((*it)->filter(this, node, rects, resetAnimationCache)) {
+ if ((*it)->filter(this, node, rects, flags)) {
return;
}
}
- if (resetAnimationCache) {
+ if (!flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames)) {
m_d->animationInterface->notifyNodeChanged(node, rects, false);
}
@@ -2389,7 +2342,9 @@ void KisImage::requestProjectionUpdate(KisNode *node, const QVector<QRect> &rect
* finished. And having some more updates for the stroke not
* supporting the wrap-around mode will not make much harm.
*/
- if (m_d->wrapAroundModePermitted) {
+ if (m_d->wrapAroundModePermitted && !flags.testFlag(KisProjectionUpdateFlag::NoFilthy)) {
+ /// TODO: Remove the no-filthy condition. I have no idea, why it is present.
+ /// Or replace it with an assert. (DK)
QVector<QRect> allSplitRects;
const QRect boundRect = effectiveLodBounds();
@@ -2398,13 +2353,13 @@ void KisImage::requestProjectionUpdate(KisNode *node, const QVector<QRect> &rect
allSplitRects.append(splitRect);
}
- requestProjectionUpdateImpl(node, allSplitRects, boundRect);
+ m_d->requestProjectionUpdateImpl(node, allSplitRects, boundRect, flags);
} else {
- requestProjectionUpdateImpl(node, rects, bounds());
+ m_d->requestProjectionUpdateImpl(node, rects, bounds(), flags);
}
- KisNodeGraphListener::requestProjectionUpdate(node, rects, resetAnimationCache);
+ KisNodeGraphListener::requestProjectionUpdate(node, rects, flags);
}
void KisImage::invalidateFrames(const KisTimeSpan &range, const QRect &rect)
diff --git a/libs/image/kis_image.h b/libs/image/kis_image.h
index 9da5091b0f..c6113357ee 100644
--- a/libs/image/kis_image.h
+++ b/libs/image/kis_image.h
@@ -82,7 +82,7 @@ public: // KisNodeGraphListener implementation
void nodeCollapsedChanged(KisNode *node) override;
void invalidateAllFrames() override;
void notifySelectionChanged() override;
- void requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache) override;
+ void requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) override;
void invalidateFrames(const KisTimeSpan &range, const QRect &rect) override;
void requestTimeSwitch(int time) override;
KisNode* graphOverlayNode() const override;
@@ -791,8 +791,10 @@ public:
*/
KisProofingConfigurationSP proofingConfiguration() const;
-public Q_SLOTS:
+
bool startIsolatedMode(KisNodeSP node, bool isolateLayer, bool isolateGroup);
+
+public Q_SLOTS:
void stopIsolatedMode();
public:
@@ -966,7 +968,7 @@ Q_SIGNALS:
*/
void sigInternalStopIsolatedModeRequested();
-public Q_SLOTS:
+public:
KisCompositeProgressProxy* compositeProgressProxy();
bool isIdle(bool allowLocked = false);
@@ -1135,11 +1137,8 @@ public Q_SLOTS:
*/
KisProjectionUpdatesFilterCookie currentProjectionUpdatesFilter() const override;
-
- void refreshGraphAsync(KisNodeSP root = KisNodeSP(), UpdateFlags flags = None) override;
- void refreshGraphAsync(KisNodeSP root, const QRect &rc, UpdateFlags flags = None) override;
- void refreshGraphAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect, UpdateFlags flags = None) override;
- void refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect, UpdateFlags flags = None) override;
+ using KisUpdatesFacade::refreshGraphAsync;
+ void refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None) override;
/**
* Triggers synchronous recomposition of the projection
@@ -1148,21 +1147,6 @@ public Q_SLOTS:
void refreshGraph(KisNodeSP root, const QRect& rc, const QRect &cropRect);
void initialRefreshGraph();
- /**
- * Initiate a stack regeneration skipping the recalculation of the
- * filthy node's projection.
- *
- * Works exactly as pseudoFilthy->setDirty() with the only
- * exception that pseudoFilthy::updateProjection() will not be
- * called. That is used by KisRecalculateTransformMaskJob to avoid
- * cyclic dependencies.
- */
- void requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QRect &rc, const QRect &cropRect);
-
- void requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QRect &rc, const QRect &cropRect, const bool notifyFrameChange );
-
- void requestProjectionUpdateNoFilthy(KisNodeSP pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache);
-
/**
* Adds a spontaneous job to the updates queue.
*
@@ -1180,6 +1164,8 @@ public Q_SLOTS:
*/
bool hasUpdatesRunning() const override;
+public Q_SLOTS:
+
/**
* This method is called by the UI (*not* by the creator of the
* stroke) when it thinks the current stroke should undo its last
@@ -1267,10 +1253,6 @@ private:
void refreshHiddenArea(KisNodeSP rootNode, const QRect &preparedArea);
- void requestProjectionUpdateImpl(KisNode *node,
- const QVector<QRect> &rects,
- const QRect &cropRect);
-
friend class KisImageResizeCommand;
void setSize(const QSize& size);
diff --git a/libs/image/kis_image_interfaces.cpp b/libs/image/kis_image_interfaces.cpp
index fa8ec82394..c2b4a2cdc7 100644
--- a/libs/image/kis_image_interfaces.cpp
+++ b/libs/image/kis_image_interfaces.cpp
@@ -6,6 +6,9 @@
#include "kis_image_interfaces.h"
+#include <kis_node.h>
+
+
KisStrokesFacade::~KisStrokesFacade()
{
}
@@ -14,6 +17,22 @@ KisUpdatesFacade::~KisUpdatesFacade()
{
}
+void KisUpdatesFacade::refreshGraphAsync(KisNodeSP root, KisProjectionUpdateFlags flags)
+{
+ refreshGraphAsync(root, bounds(), bounds(), flags);
+}
+
+void KisUpdatesFacade::refreshGraphAsync(KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags)
+{
+ refreshGraphAsync(root, rc, bounds(), flags);
+}
+
+void KisUpdatesFacade::refreshGraphAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags)
+{
+ refreshGraphAsync(root, QVector<QRect>({rc}), cropRect, flags);
+}
+
+
KisProjectionUpdateListener::~KisProjectionUpdateListener()
{
}
diff --git a/libs/image/kis_image_interfaces.h b/libs/image/kis_image_interfaces.h
index cff7eaff2c..7279a5b3b4 100644
--- a/libs/image/kis_image_interfaces.h
+++ b/libs/image/kis_image_interfaces.h
@@ -9,6 +9,7 @@
#include "kis_types.h"
#include <kritaimage_export.h>
+#include <KisProjectionUpdateFlags.h>
class QRect;
class KisStrokeStrategy;
@@ -48,16 +49,10 @@ public:
virtual void disableDirtyRequests() = 0;
virtual void enableDirtyRequests() = 0;
- enum UpdateFlag {
- None = 0x0,
- NoFilthyUpdate = 0x1
- };
- Q_DECLARE_FLAGS(UpdateFlags, UpdateFlag)
-
- virtual void refreshGraphAsync(KisNodeSP root, UpdateFlags flags = None) = 0;
- virtual void refreshGraphAsync(KisNodeSP root, const QRect &rc, UpdateFlags flags = None) = 0;
- virtual void refreshGraphAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect, UpdateFlags flags = None) = 0;
- virtual void refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rc, const QRect &cropRect, UpdateFlags flags = None) = 0;
+ void refreshGraphAsync(KisNodeSP root = nullptr, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None);
+ void refreshGraphAsync(KisNodeSP root, const QRect &rc, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None);
+ void refreshGraphAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None);
+ virtual void refreshGraphAsync(KisNodeSP root, const QVector<QRect> &rc, const QRect &cropRect, KisProjectionUpdateFlags flags = KisProjectionUpdateFlag::None) = 0;
virtual KisProjectionUpdatesFilterCookie addProjectionUpdatesFilter(KisProjectionUpdatesFilterSP filter) = 0;
virtual KisProjectionUpdatesFilterSP removeProjectionUpdatesFilter(KisProjectionUpdatesFilterCookie cookie) = 0;
@@ -65,8 +60,6 @@ public:
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(KisUpdatesFacade::UpdateFlags);
-
class KRITAIMAGE_EXPORT KisProjectionUpdateListener
{
public:
diff --git a/libs/image/kis_layer.cc b/libs/image/kis_layer.cc
index a9b88fc4af..12b0cdb2a9 100644
--- a/libs/image/kis_layer.cc
+++ b/libs/image/kis_layer.cc
@@ -60,10 +60,10 @@ public:
m_clonesList.removeOne(cloneLayer);
}
- void setDirty(const QRect &rect) {
+ void setDirty(const QRect &rect, bool dontInvalidateFrames) {
Q_FOREACH (KisCloneLayerSP clone, m_clonesList) {
if (clone) {
- clone->setDirtyOriginal(rect);
+ clone->setDirtyOriginal(rect, dontInvalidateFrames);
}
}
}
@@ -481,9 +481,9 @@ bool KisLayer::hasClones() const
return m_d->clonesList.hasClones();
}
-void KisLayer::updateClones(const QRect &rect)
+void KisLayer::updateClones(const QRect &rect, bool dontInvalidateFrames)
{
- m_d->clonesList.setDirty(rect);
+ m_d->clonesList.setDirty(rect, dontInvalidateFrames);
}
void KisLayer::notifyChildMaskChanged()
diff --git a/libs/image/kis_layer.h b/libs/image/kis_layer.h
index 5a38b22c54..926d68c304 100644
--- a/libs/image/kis_layer.h
+++ b/libs/image/kis_layer.h
@@ -210,7 +210,7 @@ public:
/**
* It is called by the async merger after projection update is done
*/
- void updateClones(const QRect &rect);
+ void updateClones(const QRect &rect, bool dontInvalidateFrames);
/**
* Informs this layers that its masks might have changed.
diff --git a/libs/image/kis_merge_walker.cc b/libs/image/kis_merge_walker.cc
index 009330e2d6..cc37d23544 100644
--- a/libs/image/kis_merge_walker.cc
+++ b/libs/image/kis_merge_walker.cc
@@ -13,6 +13,7 @@ KisMergeWalker::KisMergeWalker(QRect cropRect, Flags flags)
: m_flags(flags)
{
setCropRect(cropRect);
+ setClonesDontInvalidateFrames(flags.testFlag(CLONES_DONT_INVALIDATE_FRAMES));
}
KisMergeWalker::~KisMergeWalker()
@@ -21,7 +22,7 @@ KisMergeWalker::~KisMergeWalker()
KisBaseRectsWalker::UpdateType KisMergeWalker::type() const
{
- return m_flags == DEFAULT ? KisBaseRectsWalker::UPDATE : KisBaseRectsWalker::UPDATE_NO_FILTHY;
+ return !m_flags.testFlag(NO_FILTHY) ? KisBaseRectsWalker::UPDATE : KisBaseRectsWalker::UPDATE_NO_FILTHY;
}
void KisMergeWalker::startTripImpl(KisProjectionLeafSP startLeaf, KisMergeWalker::Flags flags)
@@ -32,7 +33,7 @@ void KisMergeWalker::startTripImpl(KisProjectionLeafSP startLeaf, KisMergeWalker
}
visitHigherNode(startLeaf,
- flags == DEFAULT ? N_FILTHY : N_ABOVE_FILTHY);
+ !flags.testFlag(NO_FILTHY) ? N_FILTHY : N_ABOVE_FILTHY);
KisProjectionLeafSP prevLeaf = startLeaf->prevSibling();
if(prevLeaf)
@@ -74,7 +75,7 @@ void KisMergeWalker::startTripWithMask(KisProjectionLeafSP filthyMask, KisMergeW
startTripImpl(parentLayer->parent(), DEFAULT);
NodePosition positionToFilthy =
- (flags == DEFAULT ? N_FILTHY_PROJECTION : N_ABOVE_FILTHY) |
+ (!flags.testFlag(NO_FILTHY) ? N_FILTHY_PROJECTION : N_ABOVE_FILTHY) |
calculateNodePosition(parentLayer);
registerNeedRect(parentLayer, positionToFilthy, KisRenderPassFlag::None);
diff --git a/libs/image/kis_merge_walker.h b/libs/image/kis_merge_walker.h
index 49c4a1c1ad..037113f96a 100644
--- a/libs/image/kis_merge_walker.h
+++ b/libs/image/kis_merge_walker.h
@@ -24,11 +24,14 @@ public:
* update all the higher-level nodes. Used by KisTransformMask
* regeneration code.
*/
- enum Flags {
+ enum Flag {
DEFAULT = 0,
- NO_FILTHY
+ NO_FILTHY = 0x1,
+ CLONES_DONT_INVALIDATE_FRAMES = 0x2
};
+ Q_DECLARE_FLAGS(Flags, Flag)
+
KisMergeWalker(QRect cropRect, Flags flags = DEFAULT);
~KisMergeWalker() override;
@@ -75,6 +78,7 @@ private:
const Flags m_flags;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(KisMergeWalker::Flags)
#endif /* __KIS_MERGE_WALKER_H */
diff --git a/libs/image/kis_node.cpp b/libs/image/kis_node.cpp
index 6feb407a92..ff6bcfae7c 100644
--- a/libs/image/kis_node.cpp
+++ b/libs/image/kis_node.cpp
@@ -581,7 +581,7 @@ void KisNode::setDirty()
void KisNode::setDirty(const QVector<QRect> &rects)
{
if(m_d->graphListener) {
- m_d->graphListener->requestProjectionUpdate(this, rects, true);
+ m_d->graphListener->requestProjectionUpdate(this, rects, KisProjectionUpdateFlag::None);
}
}
@@ -608,7 +608,7 @@ void KisNode::setDirtyDontResetAnimationCache(const QRect &rect)
void KisNode::setDirtyDontResetAnimationCache(const QVector<QRect> &rects)
{
if(m_d->graphListener) {
- m_d->graphListener->requestProjectionUpdate(this, rects, false);
+ m_d->graphListener->requestProjectionUpdate(this, rects, KisProjectionUpdateFlag::DontInvalidateFrames);
}
}
diff --git a/libs/image/kis_node_graph_listener.cpp b/libs/image/kis_node_graph_listener.cpp
index a78467262d..dae12a9958 100644
--- a/libs/image/kis_node_graph_listener.cpp
+++ b/libs/image/kis_node_graph_listener.cpp
@@ -88,7 +88,7 @@ void KisNodeGraphListener::notifySelectionChanged()
{
}
-void KisNodeGraphListener::requestProjectionUpdate(KisNode * /*node*/, const QVector<QRect> &/*rects*/, bool /*resetAnimationCache*/)
+void KisNodeGraphListener::requestProjectionUpdate(KisNode * /*node*/, const QVector<QRect> &/*rects*/, KisProjectionUpdateFlags /*flags*/)
{
}
diff --git a/libs/image/kis_node_graph_listener.h b/libs/image/kis_node_graph_listener.h
index ef6b248e77..fa83340be8 100644
--- a/libs/image/kis_node_graph_listener.h
+++ b/libs/image/kis_node_graph_listener.h
@@ -9,6 +9,7 @@
#include "kritaimage_export.h"
#include <QScopedPointer>
+#include <KisProjectionUpdateFlags.h>
class KisTimeSpan;
class KisNode;
@@ -86,7 +87,7 @@ public:
/**
* Inform the model that a node has been changed (setDirty)
*/
- virtual void requestProjectionUpdate(KisNode * node, const QVector<QRect> &rects, bool resetAnimationCache);
+ virtual void requestProjectionUpdate(KisNode * node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags);
virtual void invalidateFrames(const KisTimeSpan &range, const QRect &rect);
diff --git a/libs/image/kis_projection_updates_filter.cpp b/libs/image/kis_projection_updates_filter.cpp
index 64c05086b3..e7b198410f 100644
--- a/libs/image/kis_projection_updates_filter.cpp
+++ b/libs/image/kis_projection_updates_filter.cpp
@@ -14,16 +14,16 @@ KisProjectionUpdatesFilter::~KisProjectionUpdatesFilter()
{
}
-bool KisDropAllProjectionUpdatesFilter::filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache)
+bool KisDropAllProjectionUpdatesFilter::filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags)
{
Q_UNUSED(image);
Q_UNUSED(node);
Q_UNUSED(rects);
- Q_UNUSED(resetAnimationCache);
+ Q_UNUSED(flags);
return true;
}
-bool KisDropAllProjectionUpdatesFilter::filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisUpdatesFacade::UpdateFlags flags)
+bool KisDropAllProjectionUpdatesFilter::filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
{
Q_UNUSED(image);
Q_UNUSED(node);
@@ -32,13 +32,3 @@ bool KisDropAllProjectionUpdatesFilter::filterRefreshGraph(KisImage *image, KisN
Q_UNUSED(flags);
return true;
}
-
-bool KisDropAllProjectionUpdatesFilter::filterProjectionUpdateNoFilthy(KisImage *image, KisNode *pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache)
-{
- Q_UNUSED(image);
- Q_UNUSED(pseudoFilthy);
- Q_UNUSED(rects);
- Q_UNUSED(cropRect);
- Q_UNUSED(resetAnimationCache);
- return true;
-}
diff --git a/libs/image/kis_projection_updates_filter.h b/libs/image/kis_projection_updates_filter.h
index 123379f394..4bee813756 100644
--- a/libs/image/kis_projection_updates_filter.h
+++ b/libs/image/kis_projection_updates_filter.h
@@ -23,9 +23,8 @@ public:
/**
* \return true if an update should be dropped by the image
*/
- virtual bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache) = 0;
- virtual bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rect, const QRect &cropRect, KisUpdatesFacade::UpdateFlags flags) = 0;
- virtual bool filterProjectionUpdateNoFilthy(KisImage *image, KisNode* pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache) = 0;
+ virtual bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) = 0;
+ virtual bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rect, const QRect &cropRect, KisProjectionUpdateFlags flags) = 0;
};
@@ -36,9 +35,8 @@ public:
class KRITAIMAGE_EXPORT KisDropAllProjectionUpdatesFilter : public KisProjectionUpdatesFilter
{
public:
- bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache) override;
- bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisUpdatesFacade::UpdateFlags flags) override;
- bool filterProjectionUpdateNoFilthy(KisImage *image, KisNode* pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache) override;
+ bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) override;
+ bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags) override;
};
#endif /* __KIS_PROJECTION_UPDATES_FILTER_H */
diff --git a/libs/image/kis_recalculate_transform_mask_job.cpp b/libs/image/kis_recalculate_transform_mask_job.cpp
index 663b40b158..fb2244f0b5 100644
--- a/libs/image/kis_recalculate_transform_mask_job.cpp
+++ b/libs/image/kis_recalculate_transform_mask_job.cpp
@@ -76,7 +76,7 @@ void KisRecalculateTransformMaskJob::run()
}
} else {
/**
- * When we call requestProjectionUpdateNoFilthy() on a layer,
+ * When we call NoFilthy update on a layer,
* its masks' change rect is not counted, because it is considered
* to be N_ABOVE_FILTHY. Therefore, we should expand the dirty
* rect manually to get the correct update
@@ -86,7 +86,10 @@ void KisRecalculateTransformMaskJob::run()
updateRect |= m_extraUpdateRect;
- image->requestProjectionUpdateNoFilthy(layer, updateRect, image->bounds(), false); // Should there be a case where this is flushed?
+ // Should there be a case where this is flushed?
+ image->requestProjectionUpdate(layer.data(), {updateRect},
+ KisProjectionUpdateFlag::NoFilthy |
+ KisProjectionUpdateFlag::DontInvalidateFrames);
}
}
diff --git a/libs/image/kis_refresh_subtree_walker.h b/libs/image/kis_refresh_subtree_walker.h
index 1c0441fa56..d789878892 100644
--- a/libs/image/kis_refresh_subtree_walker.h
+++ b/libs/image/kis_refresh_subtree_walker.h
@@ -18,7 +18,8 @@ public:
None = 0x0,
SkipNonRenderableNodes = 0x1,
NoFilthyMode = 0x2,
- DontAdjustChangeRect = 0x4
+ DontAdjustChangeRect = 0x4,
+ ClonesDontInvalidateFrames = 0x8
};
Q_DECLARE_FLAGS(Flags, Flag);
@@ -28,6 +29,7 @@ public:
: m_flags(flags)
{
setCropRect(cropRect);
+ setClonesDontInvalidateFrames(flags.testFlag(ClonesDontInvalidateFrames));
}
UpdateType type() const override {
diff --git a/libs/image/kis_regenerate_frame_stroke_strategy.cpp b/libs/image/kis_regenerate_frame_stroke_strategy.cpp
index 64a5f7724c..d6a151acd6 100644
--- a/libs/image/kis_regenerate_frame_stroke_strategy.cpp
+++ b/libs/image/kis_regenerate_frame_stroke_strategy.cpp
@@ -143,7 +143,7 @@ void KisRegenerateFrameStrokeStrategy::initStrokeCallback()
m_d->interface->saveAndResetCurrentTime(m_d->frameId, &m_d->previousFrameId);
} else if (m_d->type == CURRENT_FRAME) {
m_d->interface->blockFrameInvalidation(true);
- m_d->interface->updatesFacade()->refreshGraphAsync(KisNodeSP());
+ m_d->interface->updatesFacade()->refreshGraphAsync(KisNodeSP(), KisProjectionUpdateFlag::DontInvalidateFrames);
}
}
diff --git a/libs/image/kis_simple_update_queue.cpp b/libs/image/kis_simple_update_queue.cpp
index 766924ff2a..3a9c52ac08 100644
--- a/libs/image/kis_simple_update_queue.cpp
+++ b/libs/image/kis_simple_update_queue.cpp
@@ -146,45 +146,45 @@ bool KisSimpleUpdateQueue::processOneJob(KisUpdaterContext &updaterContext)
return jobAdded;
}
-void KisSimpleUpdateQueue::addUpdateJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail)
+void KisSimpleUpdateQueue::addUpdateJob(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, int levelOfDetail, KisProjectionUpdateFlags flags)
{
- addJob(node, rects, cropRect, levelOfDetail, KisBaseRectsWalker::UPDATE);
+ KisBaseRectsWalker::UpdateType type =
+ !flags.testFlag(KisProjectionUpdateFlag::NoFilthy) ?
+ KisBaseRectsWalker::UPDATE :
+ KisBaseRectsWalker::UPDATE_NO_FILTHY;
+
+ addJob(node, rects, cropRect, levelOfDetail,
+ type,
+ flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames));
}
-void KisSimpleUpdateQueue::addUpdateJob(KisNodeSP node, const QRect &rc, const QRect& cropRect, int levelOfDetail)
-{
- addJob(node, {rc}, cropRect, levelOfDetail, KisBaseRectsWalker::UPDATE);
-}
-
-void KisSimpleUpdateQueue::addUpdateNoFilthyJob(KisNodeSP node, const QVector<QRect>& rects, const QRect& cropRect, int levelOfDetail)
+void KisSimpleUpdateQueue::addFullRefreshJob(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, int levelOfDetail, KisProjectionUpdateFlags flags)
{
- addJob(node, rects, cropRect, levelOfDetail, KisBaseRectsWalker::UPDATE_NO_FILTHY);
+ KisBaseRectsWalker::UpdateType type =
+ !flags.testFlag(KisProjectionUpdateFlag::NoFilthy) ?
+ KisBaseRectsWalker::FULL_REFRESH :
+ KisBaseRectsWalker::FULL_REFRESH_NO_FILTHY;
+
+ addJob(node, rects, cropRect, levelOfDetail,
+ type,
+ flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames));
}
-void KisSimpleUpdateQueue::addUpdateNoFilthyJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail)
+void KisSimpleUpdateQueue::addUpdateJob(KisNodeSP node, const QRect &rc, const QRect& cropRect, int levelOfDetail)
{
- addJob(node, {rc}, cropRect, levelOfDetail, KisBaseRectsWalker::UPDATE_NO_FILTHY);
+ addUpdateJob(node, {rc}, cropRect, levelOfDetail, KisProjectionUpdateFlag::None);
}
void KisSimpleUpdateQueue::addFullRefreshJob(KisNodeSP node, const QRect &rc, const QRect& cropRect, int levelOfDetail)
{
- addJob(node, {rc}, cropRect, levelOfDetail, KisBaseRectsWalker::FULL_REFRESH);
-}
-
-void KisSimpleUpdateQueue::addFullRefreshJob(KisNodeSP node, const QVector<QRect>& rects, const QRect& cropRect, int levelOfDetail)
-{
- addJob(node, rects, cropRect, levelOfDetail, KisBaseRectsWalker::FULL_REFRESH);
-}
-
-void KisSimpleUpdateQueue::addFullRefreshNoFilthyJob(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, int levelOfDetail)
-{
- addJob(node, rects, cropRect, levelOfDetail, KisBaseRectsWalker::FULL_REFRESH_NO_FILTHY);
+ addFullRefreshJob(node, {rc}, cropRect, levelOfDetail, KisProjectionUpdateFlag::None);
}
void KisSimpleUpdateQueue::addJob(KisNodeSP node, const QVector<QRect> &rects,
const QRect& cropRect,
int levelOfDetail,
- KisBaseRectsWalker::UpdateType type)
+ KisBaseRectsWalker::UpdateType type,
+ bool dontInvalidateFrames)
{
QList<KisBaseRectsWalkerSP> walkers;
@@ -193,19 +193,39 @@ void KisSimpleUpdateQueue::addJob(KisNodeSP node, const QVector<QRect> &rects,
KisBaseRectsWalkerSP walker;
- if(trySplitJob(node, rc, cropRect, levelOfDetail, type)) continue;
- if(tryMergeJob(node, rc, cropRect, levelOfDetail, type)) continue;
+ if(trySplitJob(node, rc, cropRect, levelOfDetail, type, dontInvalidateFrames)) continue;
+ if(tryMergeJob(node, rc, cropRect, levelOfDetail, type, dontInvalidateFrames)) continue;
if (type == KisBaseRectsWalker::UPDATE) {
- walker = new KisMergeWalker(cropRect, KisMergeWalker::DEFAULT);
+ KisMergeWalker::Flags flags = KisMergeWalker::DEFAULT;
+ if (dontInvalidateFrames) {
+ flags |= KisMergeWalker::CLONES_DONT_INVALIDATE_FRAMES;
+ }
+
+ walker = new KisMergeWalker(cropRect, flags);
}
else if (type == KisBaseRectsWalker::FULL_REFRESH) {
- walker = new KisFullRefreshWalker(cropRect);
+ KisFullRefreshWalker::Flags flags = KisFullRefreshWalker::None;
+ if (dontInvalidateFrames) {
+ flags |= KisFullRefreshWalker::ClonesDontInvalidateFrames;
+ }
+
+ walker = new KisFullRefreshWalker(cropRect, flags);
}
else if (type == KisBaseRectsWalker::UPDATE_NO_FILTHY) {
- walker = new KisMergeWalker(cropRect, KisMergeWalker::NO_FILTHY);
+ KisMergeWalker::Flags flags = KisMergeWalker::NO_FILTHY;
+ if (dontInvalidateFrames) {
+ flags |= KisMergeWalker::CLONES_DONT_INVALIDATE_FRAMES;
+ }
+
+ walker = new KisMergeWalker(cropRect, flags);
}
else if (type == KisBaseRectsWalker::FULL_REFRESH_NO_FILTHY) {
+ KisFullRefreshWalker::Flags flags = KisFullRefreshWalker::NoFilthyMode;
+ if (dontInvalidateFrames) {
+ flags |= KisFullRefreshWalker::ClonesDontInvalidateFrames;
+ }
+
walker = new KisFullRefreshWalker(cropRect, KisFullRefreshWalker::NoFilthyMode);
}
/* else if(type == KisBaseRectsWalker::UNSUPPORTED) fatalKrita; */
@@ -257,7 +277,8 @@ qint32 KisSimpleUpdateQueue::sizeMetric() const
bool KisSimpleUpdateQueue::trySplitJob(KisNodeSP node, const QRect& rc,
const QRect& cropRect,
int levelOfDetail,
- KisBaseRectsWalker::UpdateType type)
+ KisBaseRectsWalker::UpdateType type,
+ bool dontInvalidateFrames)
{
if(rc.width() <= m_patchWidth || rc.height() <= m_patchHeight)
return false;
@@ -282,7 +303,7 @@ bool KisSimpleUpdateQueue::trySplitJob(KisNodeSP node, const QRect& rc,
}
KIS_SAFE_ASSERT_RECOVER_NOOP(!splitRects.isEmpty());
- addJob(node, splitRects, cropRect, levelOfDetail, type);
+ addJob(node, splitRects, cropRect, levelOfDetail, type, dontInvalidateFrames);
return true;
}
@@ -290,7 +311,8 @@ bool KisSimpleUpdateQueue::trySplitJob(KisNodeSP node, const QRect& rc,
bool KisSimpleUpdateQueue::tryMergeJob(KisNodeSP node, const QRect& rc,
const QRect& cropRect,
int levelOfDetail,
- KisBaseRectsWalker::UpdateType type)
+ KisBaseRectsWalker::UpdateType type,
+ bool dontInvalidateFrames)
{
QMutexLocker locker(&m_lock);
@@ -312,6 +334,7 @@ bool KisSimpleUpdateQueue::tryMergeJob(KisNodeSP node, const QRect& rc,
if(item->startNode() != node) continue;
if(item->type() != type) continue;
+ if(item->clonesDontInvalidateFrames() != dontInvalidateFrames) continue;
if(item->cropRect() != cropRect) continue;
if(item->levelOfDetail() != levelOfDetail) continue;
@@ -352,6 +375,7 @@ void KisSimpleUpdateQueue::collectJobs(KisBaseRectsWalkerSP &baseWalker,
if(item == baseWalker) continue;
if(item->type() != baseWalker->type()) continue;
if(item->startNode() != baseWalker->startNode()) continue;
+ if(item->clonesDontInvalidateFrames() != baseWalker->clonesDontInvalidateFrames()) continue;
if(item->cropRect() != baseWalker->cropRect()) continue;
if(item->levelOfDetail() != baseWalker->levelOfDetail()) continue;
diff --git a/libs/image/kis_simple_update_queue.h b/libs/image/kis_simple_update_queue.h
index 36bd6c4551..3a573a7ce9 100644
--- a/libs/image/kis_simple_update_queue.h
+++ b/libs/image/kis_simple_update_queue.h
@@ -9,6 +9,7 @@
#include <QMutex>
#include "kis_updater_context.h"
+#include <KisProjectionUpdateFlags.h>
typedef QList<KisBaseRectsWalkerSP> KisWalkersList;
typedef QListIterator<KisBaseRectsWalkerSP> KisWalkersListIterator;
@@ -27,13 +28,15 @@ public:
void processQueue(KisUpdaterContext &updaterContext);
- void addUpdateJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail);
+ void addUpdateJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail, KisProjectionUpdateFlags flags);
+ void addFullRefreshJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail, KisProjectionUpdateFlags flags);
+
+ // simplified overload for testing purposes only
void addUpdateJob(KisNodeSP node, const QRect &rc, const QRect& cropRect, int levelOfDetail);
- void addUpdateNoFilthyJob(KisNodeSP node, const QVector<QRect>& rc, const QRect& cropRect, int levelOfDetail);
- void addUpdateNoFilthyJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail);
+
+ // simplified overload for testing purposes only
void addFullRefreshJob(KisNodeSP node, const QRect &rc, const QRect& cropRect, int levelOfDetail);
- void addFullRefreshJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail);
- void addFullRefreshNoFilthyJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail);
+
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob);
@@ -47,12 +50,12 @@ public:
int overrideLevelOfDetail() const;
protected:
- void addJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type);
+ void addJob(KisNodeSP node, const QVector<QRect> &rects, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type, bool dontInvalidateFrames);
bool processOneJob(KisUpdaterContext &updaterContext);
- bool trySplitJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type);
- bool tryMergeJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type);
+ bool trySplitJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type, bool dontInvalidateFrames);
+ bool tryMergeJob(KisNodeSP node, const QRect& rc, const QRect& cropRect, int levelOfDetail, KisBaseRectsWalker::UpdateType type, bool dontInvalidateFrames);
void collectJobs(KisBaseRectsWalkerSP &baseWalker, QRect baseRect,
const qreal maxAlpha);
diff --git a/libs/image/kis_suspend_projection_updates_stroke_strategy.cpp b/libs/image/kis_suspend_projection_updates_stroke_strategy.cpp
index 08a3b2a84b..792ebb6efb 100644
--- a/libs/image/kis_suspend_projection_updates_stroke_strategy.cpp
+++ b/libs/image/kis_suspend_projection_updates_stroke_strategy.cpp
@@ -42,43 +42,30 @@ struct KisSuspendProjectionUpdatesStrokeStrategy::Private
{
struct Request {
- Request() : resetAnimationCache(false) {}
- Request(const QRect &_rect, bool _resetAnimationCache)
- : rect(_rect), resetAnimationCache(_resetAnimationCache)
+ Request() : flags(KisProjectionUpdateFlag::None) {}
+ Request(const QRect &_rect, KisProjectionUpdateFlags _flags)
+ : rect(_rect), flags(_flags)
{
}
QRect rect;
- bool resetAnimationCache;
+ KisProjectionUpdateFlags flags;
};
struct FullRefreshRequest {
FullRefreshRequest() {}
- FullRefreshRequest(const QRect &_rect, const QRect &_cropRect, KisUpdatesFacade::UpdateFlags _flags)
+ FullRefreshRequest(const QRect &_rect, const QRect &_cropRect, KisProjectionUpdateFlags _flags)
: rect(_rect), cropRect(_cropRect), flags(_flags)
{
}
QRect rect;
QRect cropRect;
- KisUpdatesFacade::UpdateFlags flags;
- };
-
- struct NoFilthyUpdate {
- NoFilthyUpdate() {}
- NoFilthyUpdate(const QRect &_rect, const QRect &_cropRect, bool _resetAnimationCache)
- : rect(_rect), cropRect(_cropRect), resetAnimationCache(_resetAnimationCache)
- {
- }
-
- QRect rect;
- QRect cropRect;
- bool resetAnimationCache { false };
+ KisProjectionUpdateFlags flags;
};
typedef QHash<KisNodeSP, QVector<Request> > UpdatesHash;
typedef QHash<KisNodeSP, QVector<FullRefreshRequest> > RefreshesHash;
- typedef QHash<KisNodeSP, QVector<NoFilthyUpdate> > NoFilthyUpdatesHash;
public:
SuspendLod0Updates()
{
@@ -93,19 +80,19 @@ struct KisSuspendProjectionUpdatesStrokeStrategy::Private
return m_explicitUIUpdateRequest;
}
- bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache) override {
+ bool filter(KisImage *image, KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) override {
if (image->currentLevelOfDetail() > 0) return false;
QMutexLocker l(&m_mutex);
Q_FOREACH(const QRect &rc, rects) {
- m_requestsHash[KisNodeSP(node)].append(Request(rc, resetAnimationCache));
+ m_requestsHash[KisNodeSP(node)].append(Request(rc, flags));
}
return true;
}
- bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisUpdatesFacade::UpdateFlags flags) override {
+ bool filterRefreshGraph(KisImage *image, KisNode *node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags) override {
if (image->currentLevelOfDetail() > 0) return false;
QMutexLocker l(&m_mutex);
@@ -117,76 +104,43 @@ struct KisSuspendProjectionUpdatesStrokeStrategy::Private
return true;
}
- bool filterProjectionUpdateNoFilthy(KisImage *image, KisNode* pseudoFilthy, const QVector<QRect> &rects, const QRect &cropRect, const bool resetAnimationCache) override {
- if (image->currentLevelOfDetail() > 0) return false;
-
- QMutexLocker l(&m_mutex);
-
- Q_FOREACH(const QRect &rc, rects) {
- m_noFilthyRequestsHash[KisNodeSP(pseudoFilthy)].append(NoFilthyUpdate(rc, cropRect, resetAnimationCache));
- }
-
- return true;
- }
-
void notifyUpdates(KisImageSP image) {
const int step = 64;
- { // filthy refreshes
+ auto processRefreshes = [&] (bool noFilthyUpdates) {
RefreshesHash::const_iterator it = m_refreshesHash.constBegin();
RefreshesHash::const_iterator end = m_refreshesHash.constEnd();
-
for (; it != end; ++it) {
KisNodeSP node = it.key();
QHash<QRect, QVector<QRect>> fullRefreshRequests;
- Q_FOREACH (const FullRefreshRequest &req, it.value()) {
- if (!req.flags.testFlag(KisUpdatesFacade::NoFilthyUpdate)) {
- fullRefreshRequests[req.cropRect] += req.rect;
- }
- }
-
- auto reqIt = fullRefreshRequests.begin();
- for (; reqIt != fullRefreshRequests.end(); ++reqIt) {
- const QVector<QRect> simplifiedRects = KisRegion::fromOverlappingRects(reqIt.value(), step).rects();
-
- //Block frame cache drop here. We handle this manually later anyway, so we should just block invalidation.
- SuspendFrameInvalidationHandle handle(image->animationInterface());
- image->refreshGraphAsync(node, simplifiedRects, reqIt.key());
- }
- }
- }
-
- { // non-filthy refreshes
- RefreshesHash::const_iterator it = m_refreshesHash.constBegin();
- RefreshesHash::const_iterator end = m_refreshesHash.constEnd();
-
-
- for (; it != end; ++it) {
- KisNodeSP node = it.key();
-
- QHash<QRect, QVector<QRect>> fullRefreshRequests;
+ bool invalidateFrames = false;
Q_FOREACH (const FullRefreshRequest &req, it.value()) {
- if (req.flags.testFlag(KisUpdatesFacade::NoFilthyUpdate)) {
+ if (req.flags.testFlag(KisProjectionUpdateFlag::NoFilthy) == noFilthyUpdates) {
fullRefreshRequests[req.cropRect] += req.rect;
+ invalidateFrames |= !req.flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames);
}
}
+ KisProjectionUpdateFlags finalFlags(KisProjectionUpdateFlag::None);
+ finalFlags.setFlag(KisProjectionUpdateFlag::DontInvalidateFrames, !invalidateFrames);
+ finalFlags.setFlag(KisProjectionUpdateFlag::NoFilthy, noFilthyUpdates);
+
auto reqIt = fullRefreshRequests.begin();
for (; reqIt != fullRefreshRequests.end(); ++reqIt) {
const QVector<QRect> simplifiedRects = KisRegion::fromOverlappingRects(reqIt.value(), step).rects();
-
- //Block frame cache drop here. We handle this manually later anyway, so we should just block invalidation.
- SuspendFrameInvalidationHandle handle(image->animationInterface());
- image->refreshGraphAsync(node, simplifiedRects, reqIt.key());
+ image->refreshGraphAsync(node, simplifiedRects, reqIt.key(), finalFlags);
}
}
- }
+ };
- {
+ processRefreshes(false);
+ processRefreshes(true);
+
+ auto processUpdates = [&] (bool noFilthyUpdates) {
UpdatesHash::const_iterator it = m_requestsHash.constBegin();
UpdatesHash::const_iterator end = m_requestsHash.constEnd();
@@ -195,48 +149,33 @@ struct KisSuspendProjectionUpdatesStrokeStrategy::Private
QVector<QRect> dirtyRects;
- bool resetAnimationCache = false;
+ bool invalidateFrames = false;
+
Q_FOREACH (const Request &req, it.value()) {
- dirtyRects += req.rect;
- resetAnimationCache |= req.resetAnimationCache;
+ if (req.flags.testFlag(KisProjectionUpdateFlag::NoFilthy) == noFilthyUpdates) {
+ dirtyRects += req.rect;
+ invalidateFrames |= !req.flags.testFlag(KisProjectionUpdateFlag::DontInvalidateFrames);
+ }
}
+ KisProjectionUpdateFlags finalFlags(KisProjectionUpdateFlag::None);
+ finalFlags.setFlag(KisProjectionUpdateFlag::DontInvalidateFrames, !invalidateFrames);
+ finalFlags.setFlag(KisProjectionUpdateFlag::NoFilthy, noFilthyUpdates);
+
const QVector<QRect> simplifiedRects = KisRegion::fromOverlappingRects(dirtyRects, step).rects();
// FIXME: constness: port requestProjectionUpdate to shared pointers
- image->requestProjectionUpdate(const_cast<KisNode*>(node.data()), simplifiedRects, resetAnimationCache);
+ image->requestProjectionUpdate(const_cast<KisNode*>(node.data()), simplifiedRects, finalFlags);
}
- }
-
- {
- NoFilthyUpdatesHash::const_iterator it = m_noFilthyRequestsHash.constBegin();
- NoFilthyUpdatesHash::const_iterator end = m_noFilthyRequestsHash.constEnd();
+ };
- for (; it != end; ++it) {
- KisNodeSP node = it.key();
-
- QHash<QRect, std::pair<QVector<QRect>, bool>> noFilthyRequests;
-
- Q_FOREACH (const NoFilthyUpdate &req, it.value()) {
- noFilthyRequests[req.cropRect].first += req.rect;
- noFilthyRequests[req.cropRect].second |= req.resetAnimationCache;
- }
-
-
- auto reqIt = noFilthyRequests.begin();
- for (; reqIt != noFilthyRequests.end(); ++reqIt) {
- const QVector<QRect> simplifiedRects = KisRegion::fromOverlappingRects(reqIt.value().first, step).rects();
-
- image->requestProjectionUpdateNoFilthy(node, simplifiedRects, reqIt.key(), reqIt.value().second);
- }
- }
- }
+ processUpdates(false);
+ processUpdates(true);
}
private:
UpdatesHash m_requestsHash;
RefreshesHash m_refreshesHash;
- NoFilthyUpdatesHash m_noFilthyRequestsHash;
QRect m_explicitUIUpdateRequest;
QMutex m_mutex;
};
@@ -688,15 +627,3 @@ void KisSuspendProjectionUpdatesStrokeStrategy::resumeStrokeCallback()
runnableJobsInterface()->addRunnableJobs(jobs);
}
-
-KisSuspendProjectionUpdatesStrokeStrategy::SuspendFrameInvalidationHandle::SuspendFrameInvalidationHandle(KisImageAnimationInterface *interface)
- : m_interface(interface)
-{
- KIS_ASSERT(m_interface);
- m_interface->blockFrameInvalidation(true);
-}
-
-KisSuspendProjectionUpdatesStrokeStrategy::SuspendFrameInvalidationHandle::~SuspendFrameInvalidationHandle()
-{
- m_interface->blockFrameInvalidation(false);
-}
diff --git a/libs/image/kis_suspend_projection_updates_stroke_strategy.h b/libs/image/kis_suspend_projection_updates_stroke_strategy.h
index bff47619e0..74c1d8541d 100644
--- a/libs/image/kis_suspend_projection_updates_stroke_strategy.h
+++ b/libs/image/kis_suspend_projection_updates_stroke_strategy.h
@@ -25,16 +25,6 @@ public:
};
using SharedDataSP = QSharedPointer<SharedData>;
- struct SuspendFrameInvalidationHandle {
- public:
- SuspendFrameInvalidationHandle(class KisImageAnimationInterface* interface);
- ~SuspendFrameInvalidationHandle();
-
- private:
- KisImageAnimationInterface* m_interface;
- };
-
-
public:
KisSuspendProjectionUpdatesStrokeStrategy(KisImageWSP image, bool suspend, SharedDataSP sharedData);
~KisSuspendProjectionUpdatesStrokeStrategy() override;
diff --git a/libs/image/kis_update_scheduler.cpp b/libs/image/kis_update_scheduler.cpp
index 6290db7429..403b6da3c2 100644
--- a/libs/image/kis_update_scheduler.cpp
+++ b/libs/image/kis_update_scheduler.cpp
@@ -138,40 +138,26 @@ void KisUpdateScheduler::progressUpdate()
}
}
-void KisUpdateScheduler::updateProjection(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect)
+void KisUpdateScheduler::updateProjection(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
{
- m_d->updatesQueue.addUpdateJob(node, rects, cropRect, currentLevelOfDetail());
+ m_d->updatesQueue.addUpdateJob(node, rects, cropRect, currentLevelOfDetail(), flags);
processQueues();
}
-void KisUpdateScheduler::updateProjection(KisNodeSP node, const QRect &rc, const QRect &cropRect)
-{
- m_d->updatesQueue.addUpdateJob(node, rc, cropRect, currentLevelOfDetail());
- processQueues();
-}
-
-void KisUpdateScheduler::updateProjectionNoFilthy(KisNodeSP node, const QVector<QRect>& rects, const QRect &cropRect)
-{
- m_d->updatesQueue.addUpdateNoFilthyJob(node, rects, cropRect, currentLevelOfDetail());
- processQueues();
-}
-
-void KisUpdateScheduler::updateProjectionNoFilthy(KisNodeSP node, const QRect& rc, const QRect &cropRect)
+void KisUpdateScheduler::fullRefreshAsync(KisNodeSP root, const QVector<QRect>& rects, const QRect &cropRect, KisProjectionUpdateFlags flags)
{
- m_d->updatesQueue.addUpdateNoFilthyJob(node, rc, cropRect, currentLevelOfDetail());
+ m_d->updatesQueue.addFullRefreshJob(root, rects, cropRect, currentLevelOfDetail(), flags);
processQueues();
}
-void KisUpdateScheduler::fullRefreshAsync(KisNodeSP root, const QVector<QRect>& rects, const QRect &cropRect)
+void KisUpdateScheduler::updateProjection(KisNodeSP node, const QRect &rc, const QRect &cropRect)
{
- m_d->updatesQueue.addFullRefreshJob(root, rects, cropRect, currentLevelOfDetail());
- processQueues();
+ updateProjection(node, {rc}, cropRect, KisProjectionUpdateFlag::None);
}
-void KisUpdateScheduler::fullRefreshAsyncNoFilthy(KisNodeSP root, const QVector<QRect> &rects, const QRect &cropRect)
+void KisUpdateScheduler::fullRefreshAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect)
{
- m_d->updatesQueue.addFullRefreshNoFilthyJob(root, rects, cropRect, currentLevelOfDetail());
- processQueues();
+ fullRefreshAsync(root, {rc}, cropRect, KisProjectionUpdateFlag::None);
}
void KisUpdateScheduler::fullRefresh(KisNodeSP root, const QRect& rc, const QRect &cropRect)
diff --git a/libs/image/kis_update_scheduler.h b/libs/image/kis_update_scheduler.h
index ec5c63b606..e4ba3c5a32 100644
--- a/libs/image/kis_update_scheduler.h
+++ b/libs/image/kis_update_scheduler.h
@@ -15,6 +15,7 @@
#include "kis_stroke_strategy_factory.h"
#include "kis_strokes_queue_undo_result.h"
#include "KisLodPreferences.h"
+#include "KisProjectionUpdateFlags.h"
class QRect;
class KoProgressProxy;
@@ -124,13 +125,17 @@ public:
*/
void unblockUpdates();
- void updateProjection(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect);
+ void updateProjection(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags);
+ void fullRefreshAsync(KisNodeSP root, const QVector<QRect>& rects, const QRect &cropRect, KisProjectionUpdateFlags flags);
+
+ // simplified override for testing purposes
void updateProjection(KisNodeSP node, const QRect &rc, const QRect &cropRect);
- void updateProjectionNoFilthy(KisNodeSP node, const QVector<QRect>& rects, const QRect &cropRect);
- void updateProjectionNoFilthy(KisNodeSP node, const QRect& rc, const QRect &cropRect);
- void fullRefreshAsync(KisNodeSP root, const QVector<QRect>& rc, const QRect &cropRect);
- void fullRefreshAsyncNoFilthy(KisNodeSP root, const QVector<QRect>& rects, const QRect &cropRect);
+
+ // simplified override for testing purposes
+ void fullRefreshAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect);
+
void fullRefresh(KisNodeSP root, const QRect& rc, const QRect &cropRect);
+
void addSpontaneousJob(KisSpontaneousJob *spontaneousJob);
bool hasUpdatesRunning() const;
diff --git a/libs/image/tests/kis_simple_update_queue_test.cpp b/libs/image/tests/kis_simple_update_queue_test.cpp
index 2b4d07526c..0c4f83a476 100644
--- a/libs/image/tests/kis_simple_update_queue_test.cpp
+++ b/libs/image/tests/kis_simple_update_queue_test.cpp
@@ -215,23 +215,31 @@ void KisSimpleUpdateQueueTest::testMixingTypes()
KisTestableSimpleUpdateQueue queue;
KisWalkersList& walkersList = queue.getWalkersList();
- queue.addUpdateJob(paintLayer, dirtyRect1, imageRect, 0);
- queue.addFullRefreshJob(paintLayer, dirtyRect2, imageRect, 0);
- queue.addFullRefreshJob(paintLayer, dirtyRect3, imageRect, 0);
- queue.addUpdateNoFilthyJob(paintLayer, dirtyRect1, imageRect, 0);
- queue.addFullRefreshNoFilthyJob(paintLayer, {dirtyRect1}, imageRect, 0);
+ queue.addUpdateJob(paintLayer, {dirtyRect1}, imageRect, 0, KisProjectionUpdateFlag::None);
+ queue.addFullRefreshJob(paintLayer, {dirtyRect2}, imageRect, 0, KisProjectionUpdateFlag::None);
+ queue.addFullRefreshJob(paintLayer, {dirtyRect3}, imageRect, 0, KisProjectionUpdateFlag::None);
+ queue.addUpdateJob(paintLayer, {dirtyRect1}, imageRect, 0, KisProjectionUpdateFlag::NoFilthy);
+ queue.addFullRefreshJob(paintLayer, {dirtyRect1}, imageRect, 0, KisProjectionUpdateFlag::NoFilthy);
+ queue.addUpdateJob(paintLayer, {dirtyRect1}, imageRect, 0, KisProjectionUpdateFlag::DontInvalidateFrames);
+ queue.addFullRefreshJob(paintLayer, {dirtyRect1}, imageRect, 0, KisProjectionUpdateFlag::DontInvalidateFrames);
- QCOMPARE(walkersList.size(), 4);
+ QCOMPARE(walkersList.size(), 6);
QVERIFY(checkWalker(walkersList[0], QRect(0,0,200,200)));
QVERIFY(checkWalker(walkersList[1], QRect(0,0,220,220)));
QVERIFY(checkWalker(walkersList[2], QRect(0,0,200,200)));
QVERIFY(checkWalker(walkersList[3], QRect(0,0,200,200)));
+ QVERIFY(checkWalker(walkersList[4], QRect(0,0,200,200)));
+ QVERIFY(checkWalker(walkersList[5], QRect(0,0,200,200)));
QCOMPARE(walkersList[0]->type(), KisBaseRectsWalker::UPDATE);
QCOMPARE(walkersList[1]->type(), KisBaseRectsWalker::FULL_REFRESH);
QCOMPARE(walkersList[2]->type(), KisBaseRectsWalker::UPDATE_NO_FILTHY);
QCOMPARE(walkersList[3]->type(), KisBaseRectsWalker::FULL_REFRESH_NO_FILTHY);
+ QCOMPARE(walkersList[4]->type(), KisBaseRectsWalker::UPDATE);
+ QCOMPARE(walkersList[4]->clonesDontInvalidateFrames(), true);
+ QCOMPARE(walkersList[5]->type(), KisBaseRectsWalker::FULL_REFRESH);
+ QCOMPARE(walkersList[5]->clonesDontInvalidateFrames(), true);
}
void KisSimpleUpdateQueueTest::testSpontaneousJobsCompression()
diff --git a/libs/ui/kis_node_juggler_compressed.cpp b/libs/ui/kis_node_juggler_compressed.cpp
index df0450c800..f01a902492 100644
--- a/libs/ui/kis_node_juggler_compressed.cpp
+++ b/libs/ui/kis_node_juggler_compressed.cpp
@@ -72,7 +72,7 @@ struct MoveNodeStruct {
void doRedoUpdates() {
if (oldParent && !suppressOldParentRefresh) {
- image->refreshGraphAsync(oldParent, KisImage::NoFilthyUpdate);
+ image->refreshGraphAsync(oldParent, KisProjectionUpdateFlag::NoFilthy);
}
if (newParent && oldParent != newParent) {
@@ -82,7 +82,7 @@ struct MoveNodeStruct {
void doUndoUpdates() {
if (newParent && !suppressNewParentRefresh) {
- image->refreshGraphAsync(newParent, KisImage::NoFilthyUpdate);
+ image->refreshGraphAsync(newParent, KisProjectionUpdateFlag::NoFilthy);
}
if (oldParent && oldParent != newParent) {
diff --git a/libs/ui/widgets/kis_scratch_pad.cpp b/libs/ui/widgets/kis_scratch_pad.cpp
index 4a5b110d9f..4a11b8f7ae 100644
--- a/libs/ui/widgets/kis_scratch_pad.cpp
+++ b/libs/ui/widgets/kis_scratch_pad.cpp
@@ -48,8 +48,8 @@ public:
{
}
- void requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, bool resetAnimationCache) override {
- KisNodeGraphListener::requestProjectionUpdate(node, rects, resetAnimationCache);
+ void requestProjectionUpdate(KisNode *node, const QVector<QRect> &rects, KisProjectionUpdateFlags flags) override {
+ KisNodeGraphListener::requestProjectionUpdate(node, rects, flags);
QMutexLocker locker(&m_lock);