Commit 3119ea69 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix saving animated transparency and filter masks, adjustment layer

In copy-ctor of the node we should also copy all the content channels
this node supports.

BUG:393302
parent b0275f3e
...@@ -499,7 +499,7 @@ public: ...@@ -499,7 +499,7 @@ public:
void setUseInTimeline(bool value); void setUseInTimeline(bool value);
bool isAnimated() const; bool isAnimated() const;
virtual void enableAnimation(); void enableAnimation();
virtual void setImage(KisImageWSP image); virtual void setImage(KisImageWSP image);
......
...@@ -88,6 +88,12 @@ KisMask::KisMask(const KisMask& rhs) ...@@ -88,6 +88,12 @@ KisMask::KisMask(const KisMask& rhs)
if (rhs.m_d->selection) { if (rhs.m_d->selection) {
m_d->selection = new KisSelection(*rhs.m_d->selection.data()); m_d->selection = new KisSelection(*rhs.m_d->selection.data());
m_d->selection->setParentNode(this); m_d->selection->setParentNode(this);
KisPixelSelectionSP pixelSelection = m_d->selection->pixelSelection();
if (pixelSelection->framesInterface()) {
addKeyframeChannel(pixelSelection->keyframeChannel());
enableAnimation();
}
} }
} }
......
...@@ -995,7 +995,7 @@ void KisPaintDevice::init(const KoColorSpace *colorSpace, ...@@ -995,7 +995,7 @@ void KisPaintDevice::init(const KoColorSpace *colorSpace,
setParentNode(parent); setParentNode(parent);
} }
KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames, KisNode *newParentNode) KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, KritaUtils::DeviceCopyMode copyMode, KisNode *newParentNode)
: QObject() : QObject()
, KisShared() , KisShared()
, m_d(new Private(this)) , m_d(new Private(this))
...@@ -1005,9 +1005,9 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames, KisNo ...@@ -1005,9 +1005,9 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames, KisNo
m_d->defaultBounds = m_d->transitionalDefaultBounds; m_d->defaultBounds = m_d->transitionalDefaultBounds;
// copy data objects with or without frames // copy data objects with or without frames
m_d->cloneAllDataObjects(rhs.m_d, copyFrames); m_d->cloneAllDataObjects(rhs.m_d, copyMode == KritaUtils::CopyAllFrames);
if (copyFrames) { if (copyMode == KritaUtils::CopyAllFrames) {
KIS_ASSERT_RECOVER_RETURN(rhs.m_d->framesInterface); KIS_ASSERT_RECOVER_RETURN(rhs.m_d->framesInterface);
KIS_ASSERT_RECOVER_RETURN(rhs.m_d->contentChannel); KIS_ASSERT_RECOVER_RETURN(rhs.m_d->contentChannel);
m_d->framesInterface.reset(new KisPaintDeviceFramesInterface(this)); m_d->framesInterface.reset(new KisPaintDeviceFramesInterface(this));
...@@ -1015,7 +1015,7 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames, KisNo ...@@ -1015,7 +1015,7 @@ KisPaintDevice::KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames, KisNo
} }
setDefaultBounds(rhs.m_d->defaultBounds); setDefaultBounds(rhs.m_d->defaultBounds);
setParentNode(0); setParentNode(newParentNode);
} }
} }
......
...@@ -54,6 +54,13 @@ class KisPaintDeviceFramesInterface; ...@@ -54,6 +54,13 @@ class KisPaintDeviceFramesInterface;
typedef KisSharedPtr<KisDataManager> KisDataManagerSP; typedef KisSharedPtr<KisDataManager> KisDataManagerSP;
namespace KritaUtils {
enum DeviceCopyMode {
CopySnapshot = 0,
CopyAllFrames
};
}
/** /**
* A paint device contains the actual pixel data and offers methods * A paint device contains the actual pixel data and offers methods
...@@ -93,12 +100,12 @@ public: ...@@ -93,12 +100,12 @@ public:
/** /**
* Creates a copy of this device. * Creates a copy of this device.
* *
* If \p copyFrames is false, the newly created device clones the * If \p copyMode is CopySnapshot, the newly created device clones the
* current frame of \p rhs only (default and efficient * current frame of \p rhs only (default and efficient
* behavior). If \p copyFrames is true, the new device is a deep * behavior). If \p copyFrames is CopyAllFrames, the new device is a deep
* copy of the source with all the frames included. * copy of the source with all the frames included.
*/ */
KisPaintDevice(const KisPaintDevice& rhs, bool copyFrames = false, KisNode *newParentNode = 0); KisPaintDevice(const KisPaintDevice& rhs, KritaUtils::DeviceCopyMode copyMode = KritaUtils::CopySnapshot, KisNode *newParentNode = 0);
~KisPaintDevice() override; ~KisPaintDevice() override;
protected: protected:
......
...@@ -102,7 +102,7 @@ KisPaintLayer::KisPaintLayer(const KisPaintLayer& rhs) ...@@ -102,7 +102,7 @@ KisPaintLayer::KisPaintLayer(const KisPaintLayer& rhs)
if (!copyFrames) { if (!copyFrames) {
init(new KisPaintDevice(*rhs.m_d->paintDevice.data()), rhs.m_d->paintChannelFlags); init(new KisPaintDevice(*rhs.m_d->paintDevice.data()), rhs.m_d->paintChannelFlags);
} else { } else {
init(new KisPaintDevice(*rhs.m_d->paintDevice.data(), true, this), rhs.m_d->paintChannelFlags); init(new KisPaintDevice(*rhs.m_d->paintDevice.data(), KritaUtils::CopyAllFrames), rhs.m_d->paintChannelFlags);
m_d->contentChannel = m_d->paintDevice->keyframeChannel(); m_d->contentChannel = m_d->paintDevice->keyframeChannel();
addKeyframeChannel(m_d->contentChannel); addKeyframeChannel(m_d->contentChannel);
......
...@@ -72,8 +72,8 @@ KisPixelSelection::KisPixelSelection(KisDefaultBoundsBaseSP defaultBounds, KisSe ...@@ -72,8 +72,8 @@ KisPixelSelection::KisPixelSelection(KisDefaultBoundsBaseSP defaultBounds, KisSe
m_d->parentSelection = parentSelection; m_d->parentSelection = parentSelection;
} }
KisPixelSelection::KisPixelSelection(const KisPixelSelection& rhs) KisPixelSelection::KisPixelSelection(const KisPixelSelection& rhs, KritaUtils::DeviceCopyMode copyMode)
: KisPaintDevice(rhs) : KisPaintDevice(rhs, copyMode)
, KisSelectionComponent(rhs) , KisSelectionComponent(rhs)
, m_d(new Private) , m_d(new Private)
{ {
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
/** /**
* Copy the selection * Copy the selection
*/ */
KisPixelSelection(const KisPixelSelection& rhs); KisPixelSelection(const KisPixelSelection& rhs, KritaUtils::DeviceCopyMode copyMode = KritaUtils::CopySnapshot);
~KisPixelSelection() override; ~KisPixelSelection() override;
......
...@@ -81,7 +81,7 @@ void KisSelection::copyFrom(const KisSelection &rhs) ...@@ -81,7 +81,7 @@ void KisSelection::copyFrom(const KisSelection &rhs)
m_d->parentNode = 0; // not supposed to be shared m_d->parentNode = 0; // not supposed to be shared
Q_ASSERT(rhs.m_d->pixelSelection); Q_ASSERT(rhs.m_d->pixelSelection);
m_d->pixelSelection = new KisPixelSelection(*rhs.m_d->pixelSelection); m_d->pixelSelection = new KisPixelSelection(*rhs.m_d->pixelSelection, KritaUtils::CopyAllFrames);
m_d->pixelSelection->setParentSelection(this); m_d->pixelSelection->setParentSelection(this);
......
...@@ -59,10 +59,12 @@ KisSelectionBasedLayer::KisSelectionBasedLayer(KisImageWSP image, ...@@ -59,10 +59,12 @@ KisSelectionBasedLayer::KisSelectionBasedLayer(KisImageWSP image,
KisNodeFilterInterface(filterConfig, useGeneratorRegistry), KisNodeFilterInterface(filterConfig, useGeneratorRegistry),
m_d(new Private()) m_d(new Private())
{ {
if (!selection) if (!selection) {
initSelection(); initSelection();
else } else {
setInternalSelection(selection); setInternalSelection(selection);
}
KisImageSP imageSP = image.toStrongRef(); KisImageSP imageSP = image.toStrongRef();
if (!imageSP) { if (!imageSP) {
return; return;
...@@ -223,6 +225,13 @@ void KisSelectionBasedLayer::setInternalSelection(KisSelectionSP selection) ...@@ -223,6 +225,13 @@ void KisSelectionBasedLayer::setInternalSelection(KisSelectionSP selection)
m_d->selection = new KisSelection(*selection.data()); m_d->selection = new KisSelection(*selection.data());
m_d->selection->setParentNode(this); m_d->selection->setParentNode(this);
m_d->selection->updateProjection(); m_d->selection->updateProjection();
KisPixelSelectionSP pixelSelection = m_d->selection->pixelSelection();
if (pixelSelection->framesInterface()) {
addKeyframeChannel(pixelSelection->keyframeChannel());
enableAnimation();
}
} else { } else {
m_d->selection = 0; m_d->selection = 0;
} }
......
...@@ -489,7 +489,7 @@ void KisKeyframingTest::testMovingFrames() ...@@ -489,7 +489,7 @@ void KisKeyframingTest::testMovingFrames()
srcChannel->addKeyframe(10); srcChannel->addKeyframe(10);
srcChannel->addKeyframe(50); srcChannel->addKeyframe(50);
KisPaintDeviceSP dev2 = new KisPaintDevice(*dev, true); KisPaintDeviceSP dev2 = new KisPaintDevice(*dev, KritaUtils::CopyAllFrames);
KisRasterKeyframeChannel * dstChannel = dev->keyframeChannel(); KisRasterKeyframeChannel * dstChannel = dev->keyframeChannel();
......
...@@ -2176,7 +2176,7 @@ void KisPaintDeviceTest::testCopyPaintDeviceWithFrames() ...@@ -2176,7 +2176,7 @@ void KisPaintDeviceTest::testCopyPaintDeviceWithFrames()
QCOMPARE(o.m_frames.size(), 2); QCOMPARE(o.m_frames.size(), 2);
//QVERIFY(o.m_currentData == o.m_frames[0]); //QVERIFY(o.m_currentData == o.m_frames[0]);
KisPaintDeviceSP newDev = new KisPaintDevice(*dev, true, 0); KisPaintDeviceSP newDev = new KisPaintDevice(*dev, KritaUtils::CopyAllFrames);
QVERIFY(channel->keyframeAt(0)); QVERIFY(channel->keyframeAt(0));
QVERIFY(channel->keyframeAt(10)); QVERIFY(channel->keyframeAt(10));
......
...@@ -1164,6 +1164,9 @@ void TimelineFramesView::slotUpdateFrameActions() ...@@ -1164,6 +1164,9 @@ void TimelineFramesView::slotUpdateFrameActions()
action->setEnabled(value); action->setEnabled(value);
}; };
enableAction("add_blank_frame", hasEditableFrames);
enableAction("add_duplicate_frame", hasEditableFrames);
enableAction("insert_keyframes_right", hasEditableFrames); enableAction("insert_keyframes_right", hasEditableFrames);
enableAction("insert_n_keyframes_right", hasEditableFrames); enableAction("insert_n_keyframes_right", hasEditableFrames);
......
...@@ -83,7 +83,7 @@ void WaveletDecompose::slotWaveletDecompose() ...@@ -83,7 +83,7 @@ void WaveletDecompose::slotWaveletDecompose()
image->barrierLock(); image->barrierLock();
KisPaintDeviceSP projection = new KisPaintDevice(*(image->projection()), false, 0); KisPaintDeviceSP projection = new KisPaintDevice(*(image->projection()));
if (!projection) return; if (!projection) return;
const KoColorSpace *cs = projection->colorSpace(); const KoColorSpace *cs = projection->colorSpace();
...@@ -103,7 +103,7 @@ void WaveletDecompose::slotWaveletDecompose() ...@@ -103,7 +103,7 @@ void WaveletDecompose::slotWaveletDecompose()
for(int level = 0; level < scales; ++level){ for(int level = 0; level < scales; ++level){
//copy original //copy original
KisPaintDeviceSP blur = new KisPaintDevice(*original, false, 0); KisPaintDeviceSP blur = new KisPaintDevice(*original);
//blur it //blur it
KisWaveletKernel::applyWavelet(blur, rc, 1 << level, 1 << level, flags, 0); KisWaveletKernel::applyWavelet(blur, rc, 1 << level, 1 << level, flags, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment