Commit b7875041 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Do not invalidate all frames cache when Onion Skins are enabled/disabled

Conflicts:
	krita/image/kis_image.cc
parent 8a97a54e
......@@ -105,10 +105,12 @@ quint8 KisBaseNode::opacity() const
void KisBaseNode::setOpacity(quint8 val)
{
if (opacity() != val) {
nodeProperties().setProperty("opacity", val);
}
if (opacity() == val) return;
nodeProperties().setProperty("opacity", val);
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
quint8 KisBaseNode::percentOpacity() const
......@@ -128,8 +130,11 @@ const QString& KisBaseNode::compositeOpId() const
void KisBaseNode::setCompositeOpId(const QString& compositeOp)
{
if (m_d->compositeOp == compositeOp) return;
m_d->compositeOp = compositeOp;
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
KisNodeModel::PropertyList KisBaseNode::sectionModelProperties() const
......@@ -160,6 +165,7 @@ void KisBaseNode::mergeNodeProperties(const KoProperties & properties)
m_d->properties.setProperty(iter.key(), iter.value());
}
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
bool KisBaseNode::check(const KoProperties & properties) const
......@@ -199,12 +205,16 @@ bool KisBaseNode::visible(bool recursive) const
void KisBaseNode::setVisible(bool visible, bool loading)
{
const bool isVisible = m_d->properties.boolProperty("visible", true);
if (!loading && isVisible == visible) return;
m_d->properties.setProperty("visible", visible);
notifyParentVisibilityChanged(visible);
if (!loading) {
emit visibilityChanged(visible);
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
}
......@@ -215,6 +225,9 @@ bool KisBaseNode::userLocked() const
void KisBaseNode::setUserLocked(bool locked)
{
const bool isLocked = m_d->properties.boolProperty("locked", true);
if (isLocked == locked) return;
m_d->properties.setProperty("locked", locked);
emit userLockingChanged(locked);
baseNodeChangedCallback();
......
......@@ -423,6 +423,9 @@ protected:
virtual void baseNodeChangedCallback() {
}
virtual void baseNodeInvalidateAllFramesCallback() {
}
Q_SIGNALS:
/**
......
......@@ -280,7 +280,12 @@ bool KisGroupLayer::passThroughMode() const
void KisGroupLayer::setPassThroughMode(bool value)
{
if (m_d->passThroughMode == value) return;
m_d->passThroughMode = value;
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
KisNodeModel::PropertyList KisGroupLayer::sectionModelProperties() const
......
......@@ -279,7 +279,10 @@ void KisImage::nodeChanged(KisNode* node)
KisNodeGraphListener::nodeChanged(node);
requestStrokeEnd();
m_d->signalRouter.emitNodeChanged(node);
}
void KisImage::invalidateAllFrames()
{
invalidateFrames(KisTimeRange::infinite(0), QRect());
}
......
......@@ -89,6 +89,7 @@ public: // KisNodeGraphListener implementation
void nodeHasBeenAdded(KisNode *parent, int index);
void aboutToRemoveANode(KisNode *parent, int index);
void nodeChanged(KisNode * node);
void invalidateAllFrames();
void notifySelectionChanged();
void requestProjectionUpdate(KisNode *node, const QRect& rect);
void invalidateFrames(const KisTimeRange &range, const QRect &rect);
......
......@@ -51,6 +51,8 @@
#include "kis_layer_projection_plane.h"
#include "layerstyles/kis_layer_style_projection_plane.h"
#include "krita_utils.h"
class KisSafeProjection {
public:
......@@ -235,8 +237,13 @@ void KisLayer::setSectionModelProperties(const KisNodeModel::PropertyList &prope
}
if (property.name == i18n("Layer Style")) {
if (m_d->layerStyle) {
if (m_d->layerStyle &&
m_d->layerStyle->isEnabled() != property.state.toBool()) {
m_d->layerStyle->setEnabled(property.state.toBool());
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
}
}
......@@ -268,6 +275,11 @@ void KisLayer::setChannelFlags(const QBitArray & channelFlags)
{
Q_ASSERT(channelFlags.isEmpty() ||((quint32)channelFlags.count() == colorSpace()->channelCount()));
if (KritaUtils::compareChannelFlags(channelFlags,
this->channelFlags())) {
return;
}
if (!channelFlags.isEmpty() &&
channelFlags == QBitArray(channelFlags.size(), true)) {
......@@ -275,6 +287,9 @@ void KisLayer::setChannelFlags(const QBitArray & channelFlags)
} else {
m_d->channelFlags = channelFlags;
}
baseNodeChangedCallback();
baseNodeInvalidateAllFramesCallback();
}
QBitArray & KisLayer::channelFlags() const
......
......@@ -358,6 +358,13 @@ void KisNode::baseNodeChangedCallback()
}
}
void KisNode::baseNodeInvalidateAllFramesCallback()
{
if(m_d->graphListener) {
m_d->graphListener->invalidateAllFrames();
}
}
KisNodeSP KisNode::firstChild() const
{
QReadLocker l(&m_d->nodeSubgraphLock);
......
......@@ -368,6 +368,7 @@ protected:
KisBaseNodeSP parentCallback() const;
void notifyParentVisibilityChanged(bool value);
void baseNodeChangedCallback();
void baseNodeInvalidateAllFramesCallback();
private:
friend class KisNodeFacade;
......
......@@ -79,6 +79,10 @@ void KisNodeGraphListener::nodeChanged(KisNode * /*node*/)
{
}
void KisNodeGraphListener::invalidateAllFrames()
{
}
void KisNodeGraphListener::notifySelectionChanged()
{
}
......
......@@ -79,6 +79,8 @@ public:
virtual void nodeChanged(KisNode * node);
virtual void invalidateAllFrames();
/**
* Inform the model that one of the selections in the graph is
* changed. The sender is not passed to the function (at least for
......
......@@ -247,6 +247,8 @@ void KisPaintLayer::setAlphaLocked(bool lock)
m_d->paintChannelFlags &= colorSpace()->channelFlags(true, false);
else
m_d->paintChannelFlags |= colorSpace()->channelFlags(false, true);
baseNodeChangedCallback();
}
bool KisPaintLayer::onionSkinEnabled() const
......@@ -262,6 +264,8 @@ void KisPaintLayer::setOnionSkinEnabled(bool state)
}
nodeProperties().setProperty("onionskin", state);
baseNodeChangedCallback();
}
void KisPaintLayer::enableAnimation()
......
......@@ -341,6 +341,21 @@ namespace KritaUtils
return flags;
}
bool compareChannelFlags(QBitArray f1, QBitArray f2)
{
if (f1.isNull() && f2.isNull()) return true;
if (f1.isNull()) {
f1.fill(true, f2.size());
}
if (f2.isNull()) {
f2.fill(true, f1.size());
}
return f1 == f2;
}
QString KRITAIMAGE_EXPORT toLocalizedOnOff(bool value) {
return value ? i18n("on") : i18n("off");
}
......
......@@ -63,6 +63,8 @@ namespace KritaUtils
quint8 KRITAIMAGE_EXPORT mergeOpacity(quint8 opacity, quint8 parentOpacity);
QBitArray KRITAIMAGE_EXPORT mergeChannelFlags(const QBitArray &flags, const QBitArray &parentFlags);
bool KRITAIMAGE_EXPORT compareChannelFlags(QBitArray f1, QBitArray f2);
QString KRITAIMAGE_EXPORT toLocalizedOnOff(bool value);
}
......
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