diff --git a/libs/image/CMakeLists.txt b/libs/image/CMakeLists.txt index 62aef4a..5162541 100644 --- a/libs/image/CMakeLists.txt +++ b/libs/image/CMakeLists.txt @@ -124,6 +124,7 @@ set(kritaimage_LIB_SRCS lazybrush/kis_multiway_cut.cpp lazybrush/kis_colorize_mask.cpp lazybrush/kis_colorize_stroke_strategy.cpp + KisDelayedUpdateNodeInterface.cpp kis_adjustment_layer.cc kis_selection_based_layer.cpp kis_node_filter_interface.cpp diff --git a/libs/image/KisDelayedUpdateNodeInterface.cpp b/libs/image/KisDelayedUpdateNodeInterface.cpp new file mode 100644 index 0000000..f5fca71 --- /dev/null +++ b/libs/image/KisDelayedUpdateNodeInterface.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017 Dmitry Kazakov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "KisDelayedUpdateNodeInterface.h" + +KisDelayedUpdateNodeInterface::~KisDelayedUpdateNodeInterface() +{ +} + diff --git a/libs/image/KisDelayedUpdateNodeInterface.h b/libs/image/KisDelayedUpdateNodeInterface.h new file mode 100644 index 0000000..c0c7656 --- /dev/null +++ b/libs/image/KisDelayedUpdateNodeInterface.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017 Dmitry Kazakov + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KISDELAYEDUPDATENODEINTERFACE_H +#define KISDELAYEDUPDATENODEINTERFACE_H + +#include "kritaimage_export.h" + + +class KRITAIMAGE_EXPORT KisDelayedUpdateNodeInterface +{ +public: + virtual ~KisDelayedUpdateNodeInterface(); + + virtual void forceUpdateTimedNode() = 0; +}; + +#endif // KISDELAYEDUPDATENODEINTERFACE_H diff --git a/libs/image/kis_layer_utils.cpp b/libs/image/kis_layer_utils.cpp index 74926bb..da96b08 100644 --- a/libs/image/kis_layer_utils.cpp +++ b/libs/image/kis_layer_utils.cpp @@ -49,6 +49,7 @@ #include "kis_layer_properties_icons.h" #include "lazybrush/kis_colorize_mask.h" #include "commands/kis_node_property_list_command.h" +#include namespace KisLayerUtils { @@ -242,6 +243,26 @@ namespace KisLayerUtils { MergeDownInfoBaseSP m_info; }; + struct RefreshDelayedUpdateLayers : public KUndo2Command { + RefreshDelayedUpdateLayers(MergeDownInfoBaseSP info) : m_info(info) {} + + void redo() override { + foreach (KisNodeSP node, m_info->allSrcNodes()) { + recursiveApplyNodes(node, + [] (KisNodeSP node) { + KisDelayedUpdateNodeInterface *delayedUpdate = + dynamic_cast(node.data()); + if (delayedUpdate) { + delayedUpdate->forceUpdateTimedNode(); + } + }); + } + } + + private: + MergeDownInfoBaseSP m_info; + }; + struct KeepMergedNodesSelected : public KisCommandUtils::AggregateCommand { KeepMergedNodesSelected(MergeDownInfoSP info, bool finalizing) : m_singleInfo(info), @@ -778,12 +799,14 @@ namespace KisLayerUtils { applicator.applyCommand(new AddNewFrame(info, frame)); applicator.applyCommand(new RefreshHiddenAreas(info)); + applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new MergeLayers(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new SwitchFrameCommand(info->image, frame, true, info->storage)); } } else { applicator.applyCommand(new RefreshHiddenAreas(info)); + applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new MergeLayers(info), KisStrokeJobData::BARRIER); } @@ -1074,12 +1097,14 @@ namespace KisLayerUtils { applicator.applyCommand(new AddNewFrame(info, frame)); applicator.applyCommand(new RefreshHiddenAreas(info)); + applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new MergeLayersMultiple(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new SwitchFrameCommand(info->image, frame, true, info->storage)); } } else { applicator.applyCommand(new RefreshHiddenAreas(info)); + applicator.applyCommand(new RefreshDelayedUpdateLayers(info), KisStrokeJobData::BARRIER); applicator.applyCommand(new MergeLayersMultiple(info), KisStrokeJobData::BARRIER); } diff --git a/libs/image/kis_transform_mask.cpp b/libs/image/kis_transform_mask.cpp index 1816e39..568be0a 100644 --- a/libs/image/kis_transform_mask.cpp +++ b/libs/image/kis_transform_mask.cpp @@ -424,6 +424,16 @@ void KisTransformMask::setY(qint32 y) KisEffectMask::setY(y); } +void KisTransformMask::forceUpdateTimedNode() +{ + if (m_d->updateSignalCompressor.isActive()) { + KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->staticCacheValid); + + emit forceTerminateDelayedStaticUpdate(); + slotDelayedStaticUpdate(); + } +} + KisKeyframeChannel *KisTransformMask::requestKeyframeChannel(const QString &id) { if (id == KisKeyframeChannel::TransformArguments.id() || diff --git a/libs/image/kis_transform_mask.h b/libs/image/kis_transform_mask.h index a51c73f..7c96afc 100644 --- a/libs/image/kis_transform_mask.h +++ b/libs/image/kis_transform_mask.h @@ -22,12 +22,13 @@ #include "kis_types.h" #include "kis_effect_mask.h" +#include "KisDelayedUpdateNodeInterface.h" /** Transform a layer according to a matrix transform */ -class KRITAIMAGE_EXPORT KisTransformMask : public KisEffectMask +class KRITAIMAGE_EXPORT KisTransformMask : public KisEffectMask, public KisDelayedUpdateNodeInterface { Q_OBJECT @@ -73,6 +74,8 @@ public: void setX(qint32 x); void setY(qint32 y); + void forceUpdateTimedNode() override; + protected: KisKeyframeChannel *requestKeyframeChannel(const QString &id); @@ -81,6 +84,7 @@ private Q_SLOTS: Q_SIGNALS: void initiateDelayedStaticUpdate() const; + void forceTerminateDelayedStaticUpdate() const; private: struct Private; diff --git a/libs/image/processing/kis_transform_processing_visitor.cpp b/libs/image/processing/kis_transform_processing_visitor.cpp index d62099c..90fda3c 100644 --- a/libs/image/processing/kis_transform_processing_visitor.cpp +++ b/libs/image/processing/kis_transform_processing_visitor.cpp @@ -136,7 +136,7 @@ void KisTransformProcessingVisitor::visit(KisTransformMask *mask, KisUndoAdapter Q_UNUSED(mask); Q_UNUSED(undoAdapter); - warnKrita << "WARNING: transformation of the transform mask is not implemented"; + qDebug() << "WARNING: transformation of the transform mask is not implemented"; } void KisTransformProcessingVisitor::visit(KisTransparencyMask *mask, KisUndoAdapter *undoAdapter) diff --git a/libs/ui/flake/kis_shape_layer.cc b/libs/ui/flake/kis_shape_layer.cc index 157c517..f882411 100644 --- a/libs/ui/flake/kis_shape_layer.cc +++ b/libs/ui/flake/kis_shape_layer.cc @@ -376,7 +376,7 @@ void KisShapeLayer::setVisible(bool visible, bool isLoading) KisExternalLayer::setVisible(visible, isLoading); } -void KisShapeLayer::forceRepaint() +void KisShapeLayer::forceUpdateTimedNode() { m_d->canvas->forceRepaint(); } diff --git a/libs/ui/flake/kis_shape_layer.h b/libs/ui/flake/kis_shape_layer.h index fb4c469..ef466c3 100644 --- a/libs/ui/flake/kis_shape_layer.h +++ b/libs/ui/flake/kis_shape_layer.h @@ -25,6 +25,7 @@ #include #include #include +#include class QRect; class QIcon; @@ -48,7 +49,7 @@ const QString KIS_SHAPE_LAYER_ID = "KisShapeLayer"; XXX: what about removing shapes? */ -class KRITAUI_EXPORT KisShapeLayer : public KisExternalLayer, public KoShapeLayer +class KRITAUI_EXPORT KisShapeLayer : public KisExternalLayer, public KoShapeLayer, public KisDelayedUpdateNodeInterface { Q_OBJECT @@ -132,10 +133,11 @@ public: * * shapeLayer->setDirty(); * shapeLayer->image()->waitForDone(); - * shapeLayer->forceRepaint(); + * shapeLayer->forceUpdateTimedNode(); + * shapeLayer->image()->waitForDone(); * */ - void forceRepaint(); + void forceUpdateTimedNode() override; protected: using KoShape::isVisible; diff --git a/plugins/tools/tool_transform2/kis_tool_transform.cc b/plugins/tools/tool_transform2/kis_tool_transform.cc index 9f09c87..bdf1e10 100644 --- a/plugins/tools/tool_transform2/kis_tool_transform.cc +++ b/plugins/tools/tool_transform2/kis_tool_transform.cc @@ -83,7 +83,8 @@ #include "kis_transform_mask_adapter.h" #include "kis_layer_utils.h" -#include "kis_shape_layer.h" +//#include "kis_shape_layer.h" +#include #include "strokes/transform_stroke_strategy.h" @@ -1191,19 +1192,17 @@ void KisToolTransform::forceRepaintShapeLayers(KisNodeSP root) { KIS_SAFE_ASSERT_RECOVER_RETURN(root); - auto forceUpdateFunction = + KisLayerUtils::recursiveApplyNodes(root, [] (KisNodeSP node) { - KisShapeLayer *shapeLayer = dynamic_cast(node.data()); - if (shapeLayer) { - shapeLayer->forceRepaint(); + KisDelayedUpdateNodeInterface *delayedUpdate = + dynamic_cast(node.data()); + + if (delayedUpdate) { + delayedUpdate->forceUpdateTimedNode(); } - }; + }); - if (m_workRecursively) { - KisLayerUtils::recursiveApplyNodes(root, forceUpdateFunction); - } else { - forceUpdateFunction(root); - } + image()->waitForDone(); }