From e4eec95eb4c671a527c02cba2d5fa75f60d8a9ea Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Fri, 21 Aug 2015 18:28:08 +0300 Subject: [PATCH] Make a transform tool work with Pass Through group layers BUG:351548 --- krita/image/kis_projection_leaf.cpp | 32 +++++++++++++++++++ krita/image/kis_projection_leaf.h | 9 ++++++ .../strokes/transform_stroke_strategy.cpp | 4 ++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/krita/image/kis_projection_leaf.cpp b/krita/image/kis_projection_leaf.cpp index 4ca1ed4d01..ecb61f0737 100644 --- a/krita/image/kis_projection_leaf.cpp +++ b/krita/image/kis_projection_leaf.cpp @@ -27,6 +27,9 @@ #include "krita_utils.h" +#include "kis_refresh_subtree_walker.h" +#include "kis_async_merger.h" + struct KisProjectionLeaf::Private { @@ -46,6 +49,13 @@ struct KisProjectionLeaf::Private bool checkThisPassThrough() { return checkPassThrough(node); } + + void temporarySetPassThrough(bool value) { + KisGroupLayer *group = qobject_cast(node); + if (!group) return; + + group->setPassThroughMode(value); + } }; KisProjectionLeaf::KisProjectionLeaf(KisNode *node) @@ -247,3 +257,25 @@ bool KisProjectionLeaf::isDroppedMask() const return qobject_cast(m_d->node) && m_d->checkParentPassThrough(); } + + +/** + * This method is rather slow and dangerous. It should be executes in + * exclusive environment only. + */ +void KisProjectionLeaf::explicitlyRegeneratePassThroughProjection() +{ + if (!m_d->checkThisPassThrough()) return; + + m_d->temporarySetPassThrough(false); + + const QRect updateRect = projection()->defaultBounds()->bounds(); + + KisRefreshSubtreeWalker walker(updateRect); + walker.collectRects(m_d->node, updateRect); + + KisAsyncMerger merger; + merger.startMerge(walker); + + m_d->temporarySetPassThrough(true); +} diff --git a/krita/image/kis_projection_leaf.h b/krita/image/kis_projection_leaf.h index a18b1c746c..a9a4eba407 100644 --- a/krita/image/kis_projection_leaf.h +++ b/krita/image/kis_projection_leaf.h @@ -62,6 +62,15 @@ public: bool isDroppedMask() const; + /** + * Regenerate projection of the current group layer iff it is + * pass-through mode. + * + * WARNING: must be called either under the image lock held + * or in the context of an exclusive stroke job. + */ + void explicitlyRegeneratePassThroughProjection(); + private: struct Private; const QScopedPointer m_d; diff --git a/krita/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp b/krita/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp index 0892026853..fcb984d6e2 100644 --- a/krita/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp +++ b/krita/plugins/tools/tool_transform2/strokes/transform_stroke_strategy.cpp @@ -33,6 +33,8 @@ #include "kis_transform_mask_adapter.h" #include "kis_transform_utils.h" +#include "kis_projection_leaf.h" + class ModifyTransformMaskCommand : public KUndo2Command { public: @@ -102,8 +104,8 @@ TransformStrokeStrategy::TransformStrokeStrategy(KisNodeSP rootNode, * taken into account. */ m_selection = 0; - } else { + rootNode->projectionLeaf()->explicitlyRegeneratePassThroughProjection(); device = rootNode->projection(); } -- GitLab