Krita Source Code Documentation
Loading...
Searching...
No Matches
KisGeneratorLayer Class Reference

#include <kis_generator_layer.h>

+ Inheritance diagram for KisGeneratorLayer:

Public Member Functions

bool accept (KisNodeVisitor &) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
KisNodeSP clone () const override
 
void forceUpdateTimedNode () override
 forceUpdateTimedNode forces the node to regenerate its project. The update might be asynchronous, so you should call image->waitForDone() after that.
 
bool hasPendingTimedUpdates () const override
 
QIcon icon () const override
 
 KisGeneratorLayer (const KisGeneratorLayer &rhs)
 
 KisGeneratorLayer (KisImageWSP image, const QString &name, KisFilterConfigurationSP kfc, KisSelectionSP selection)
 
KisLayerlayer ()
 
QWeakPointer< boost::none_t > previewWithStroke (const KisStrokeId stroke)
 
 Private ()
 
void resetCache (const KoColorSpace *colorSpace) override
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
void setDirty () override
 
void setDirty (const QVector< QRect > &rects) override
 
void setDirtyWithoutUpdate (const QVector< QRect > &rects)
 
void setFilter (KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override
 
void setFilterWithoutUpdate (KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
void update ()
 
 ~KisGeneratorLayer () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisSelectionBasedLayer
bool allowAsChild (KisNodeSP node) const override
 
QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
QRect exactBounds () const override
 
QRect extent () const override
 
KisSelectionSP fetchComposedInternalSelection (const QRect &rect) const
 
KisSelectionSP internalSelection () const
 
 KisSelectionBasedLayer (const KisSelectionBasedLayer &rhs)
 
 KisSelectionBasedLayer (KisImageWSP image, const QString &name, KisSelectionSP selection, KisFilterConfigurationSP filterConfig)
 
bool needProjection () const override
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
 Private ()
 
 Private (const Private &rhs)
 
void setDirty () override
 
void setImage (KisImageWSP image) override
 
void setInternalSelection (KisSelectionSP selection)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool supportsLodPainting () const override
 
int thumbnailSeqNo () const override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisSelectionBasedLayer () override
 
- Public Member Functions inherited from KisLayer
bool alphaChannelDisabled () const
 
void buildProjectionUpToNode (KisPaintDeviceSP projection, KisNodeSP lastNode, const QRect &rect)
 
QBitArray & channelFlags () const
 
KisFilterMaskSP colorOverlayMask () const
 
const KoColorSpacecolorSpace () const override
 returns the image's colorSpace or null, if there is no image
 
const KoCompositeOpcompositeOp () const override
 returns the layer's composite op for the colorspace of the layer's parent.
 
virtual KisLayerSP createMergedLayerTemplate (KisLayerSP prevLayer)
 
QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
void disableAlphaChannel (bool disable)
 
QList< KisEffectMaskSPeffectMasks () const
 
QList< KisEffectMaskSPeffectMasks (KisNodeSP lastNode) const
 
virtual void fillMergedLayerTemplate (KisLayerSP dstLayer, KisLayerSP prevLayer, bool skipPaintingThisLayer=false)
 
bool hasClones () const
 
bool hasEffectMasks () const
 
virtual KisLayerProjectionPlaneSP internalProjectionPlane () const
 
 KisLayer (const KisLayer &rhs)
 
 KisLayer (KisImageWSP image, const QString &name, quint8 opacity)
 
KisPSDLayerStyleSP layerStyle () const
 
QRect looseUserVisibleBounds () const
 
KisMetaData::StoremetaData ()
 
void notifyChildMaskChanged ()
 
KisLayerSP parentLayer () const
 
QRect partialChangeRect (KisNodeSP lastNode, const QRect &rect)
 
 Private (KisLayer *q)
 
KisPaintDeviceSP projection () const override
 
KisAbstractProjectionPlaneSP projectionPlane () const override
 
void registerClone (KisCloneLayerWSP clone)
 
const QList< KisCloneLayerWSPregisteredClones () const
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
virtual KisSelectionSP selection () const
 
virtual KisSelectionMaskSP selectionMask () const
 
virtual void setChannelFlags (const QBitArray &channelFlags)
 
void setLayerStyle (KisPSDLayerStyleSP layerStyle)
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setTemporary (bool t)
 
bool temporary () const
 
QRect tightUserVisibleBounds () const
 
void unregisterClone (KisCloneLayerWSP clone)
 
void updateClones (const QRect &rect, bool dontInvalidateFrames)
 
 ~KisLayer () override
 
- Public Member Functions inherited from KisNode
bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
const KisNodefindSymmetricClone (const KisNode *srcRoot, const KisNode *dstRoot, const KisNode *srcTarget)
 
KisNodeSP firstChild () const
 
virtual KisPaintDeviceList getLodCapableDevices () const
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameAdded (const KisKeyframeChannel *channel, int time)
 
virtual void handleKeyframeChannelFrameChange (const KisKeyframeChannel *channel, int time)
 
void handleKeyframeChannelFrameHasBeenRemoved (const KisKeyframeChannel *channel, int time)
 
KisFrameChangeUpdateRecipe handleKeyframeChannelUpdateImpl (const KisKeyframeChannel *channel, int time)
 
int index (const KisNodeSP node) const
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect)
 
 KisNode (const KisNode &rhs)
 
 KisNode (KisImageWSP image)
 
KisNodeSP lastChild () const
 
KisNodeSP nextSibling () const
 
KisNodeProgressProxynodeProgressProxy () const
 
KisNodeSP parent () const
 
KisNodeSP prevSibling () const
 
 Private (KisNode *node)
 
void processDuplicatedClones (const KisNode *srcDuplicationRoot, const KisNode *dstDuplicationRoot, KisNode *node)
 
virtual KisProjectionLeafSP projectionLeaf () const
 
void requestTimeSwitch (int time)
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
void setDirtyDontResetAnimationCache ()
 
void setDirtyDontResetAnimationCache (const QRect &rect)
 
void setDirtyDontResetAnimationCache (const QVector< QRect > &rects)
 setDirtyDontResetAnimationCache does almost the same thing as usual setDirty() call, but doesn't reset the animation cache (since onion skins are not used when rendering animation.
 
void setGraphListener (KisNodeGraphListener *graphListener)
 
virtual void syncLodCache ()
 
 ~KisNode () override
 
- Public Member Functions inherited from KisBaseNode
bool belongsToIsolatedGroup () const
 
bool check (const KoProperties &properties) const
 
bool collapsed () const
 
int colorLabelIndex () const
 
virtual KisPaintDeviceSP colorSampleSourceDevice () const
 
const QString & compositeOpId () const
 
void enableAnimation ()
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
KisImageWSP image () const
 
bool isAnimated () const
 
bool isEditable (bool checkVisibility=true) const
 
virtual bool isFakeNode () const
 
bool isIsolatedRoot () const
 
bool isPinnedToTimeline () const
 
QMap< QString, KisKeyframeChannel * > keyframeChannels () const
 
 KisBaseNode (const KisBaseNode &rhs)
 
 KisBaseNode (KisImageWSP image)
 
void mergeNodeProperties (const KoProperties &properties)
 
QString name () const
 
const KoPropertiesnodeProperties () const
 
quint8 opacity () const
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
void setCollapsed (bool collapsed)
 
void setColorLabelIndex (int index)
 
void setCompositeOpId (const QString &compositeOpId)
 
void setName (const QString &name)
 
void setNodeProperty (const QString &name, const QVariant &value)
 
void setOpacity (quint8 val)
 
void setPercentOpacity (quint8 val)
 
void setPinnedToTimeline (bool pinned)
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
virtual void setVisible (bool visible, bool loading=false)
 
bool supportsLodMoves () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
virtual bool visible (bool recursive=false) const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 
- Public Member Functions inherited from KisIndirectPaintingSupport
bool hasTemporaryTarget () const
 
 KisIndirectPaintingSupport ()
 
void mergeToLayer (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
 
virtual void mergeToLayerThreaded (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, QVector< KisRunnableStrokeJobData * > *jobs)
 
virtual void setCurrentColor (const KoColor &color)
 
void setTemporaryChannelFlags (const QBitArray &channelFlags)
 
void setTemporaryCompositeOp (const QString &id)
 
void setTemporaryOpacity (qreal o)
 
void setTemporarySelection (KisSelectionSP selection)
 
void setTemporaryTarget (KisPaintDeviceSP t)
 
void setupTemporaryPainter (KisPainter *painter) const
 
virtual bool supportsNonIndirectPainting () const
 
KisPaintDeviceSP temporaryTarget () const
 
FinalMergeSuspenderSP trySuspendFinalMerge ()
 
virtual ~KisIndirectPaintingSupport ()
 
- Public Member Functions inherited from KisNodeFilterInterface
virtual KisFilterConfigurationSP filter () const
 
 KisNodeFilterInterface (const KisNodeFilterInterface &rhs)
 
 KisNodeFilterInterface (KisFilterConfigurationSP filterConfig)
 
virtual void notifyColorSpaceChanged ()
 
virtual ~KisNodeFilterInterface ()
 
- Public Member Functions inherited from KisDelayedUpdateNodeInterface
virtual ~KisDelayedUpdateNodeInterface ()
 

Public Attributes

QMutex mutex
 
KisFilterConfigurationSP preparedForFilter
 
QRect preparedImageBounds
 
QRect preparedRect
 
QWeakPointer< boost::none_t > updateCookie
 
KisThreadSafeSignalCompressor updateSignalCompressor
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Public Attributes inherited from KisSelectionBasedLayer
KisSignalAutoConnectionsStore imageConnections
 
KisPaintDeviceSP paintDevice
 
KisSelectionSP selection
 
bool useSelectionInProjection
 
- Public Attributes inherited from KisLayer
QBitArray channelFlags
 
KisCloneLayersList clonesList
 
KisPSDLayerStyleSP layerStyle
 
KisLayerStyleProjectionPlaneSP layerStyleProjectionPlane
 
KisLayerMasksCache masksCache
 
KisMetaData::StoremetaDataStore {nullptr}
 
KisLayerProjectionPlaneSP projectionPlane
 
KisSafeNodeProjectionStoreSP safeProjection
 
- Public Attributes inherited from KisNode
KisBusyProgressIndicatorbusyProgressIndicator
 
std::optional< KisFrameChangeUpdateRecipeframeRemovalUpdateRecipe
 
KisNodeGraphListenergraphListener
 
KisNodeProgressProxynodeProgressProxy
 
KisSafeReadNodeList nodes
 
QReadWriteLock nodeSubgraphLock
 
KisNodeWSP parent
 
KisProjectionLeafSP projectionLeaf
 
- Public Attributes inherited from KisBaseNode
bool animated {false}
 
bool collapsed {false}
 
QString compositeOp
 
KisBaseNode::Property hack_visible
 
QUuid id
 
KisImageWSP image
 
QMap< QString, KisKeyframeChannel * > keyframeChannels
 
KisAnimatedOpacityProperty opacityProperty
 
bool pinnedToTimeline {false}
 
KoProperties properties
 
bool supportsLodMoves {false}
 
- Public Attributes inherited from KisIndirectPaintingSupport
QBitArray channelFlags
 
QString compositeOp
 
qreal compositeOpacity
 
bool finalMergeInProgress = true
 
QReadWriteLock lock
 
KisSelectionSP selection
 
KisPaintDeviceSP temporaryTarget
 

Private Slots

void slotDelayedStaticUpdate ()
 

Private Member Functions

void requestUpdateJobsWithStroke (const KisStrokeId stroke, const KisFilterConfigurationSP configuration)
 
void resetCacheWithoutUpdate (const KoColorSpace *colorSpace)
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Public Types inherited from KisNode
enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 
- Public Types inherited from KisIndirectPaintingSupport
using FinalMergeSuspenderSP = QSharedPointer<FinalMergeSuspender>
 
- Public Slots inherited from KisSelectionBasedLayer
KisLayerlayer ()
 
void slotImageSizeChanged ()
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 
- Protected Types inherited from KisIndirectPaintingSupport
using WriteLockerSP = QSharedPointer<WriteLocker>
 
- Protected Member Functions inherited from KisSelectionBasedLayer
void copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const override
 
QRect cropChangeRectBySelection (const QRect &rect) const
 
void initSelection ()
 
QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
KisKeyframeChannelrequestKeyframeChannel (const QString &id) override
 
void setUseSelectionInProjection (bool value) const
 
bool supportsKeyframeChannel (const QString &id) override
 
- Protected Member Functions inherited from KisLayer
virtual QRect amortizedProjectionRectForCleanupInChangePass () const
 
QRect applyMasks (const KisPaintDeviceSP source, KisPaintDeviceSP destination, const QRect &requestedRect, KisNodeSP filthyNode, KisNodeSP lastNode, KisRenderPassFlags flags) const
 
bool canMergeAndKeepBlendOptions (KisLayerSP otherLayer)
 
QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
void childNodeChanged (KisNodeSP changedChildNode) override
 
virtual QRect incomingChangeRect (const QRect &rect) const
 
QRect masksChangeRect (const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
 
QRect masksNeedRect (const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const
 
QRect needRectForOriginal (const QRect &rect) const
 
virtual QRect outgoingChangeRect (const QRect &rect) const
 
QList< KisEffectMaskSPsearchEffectMasks (KisNodeSP lastNode) const
 
QRect updateProjection (const QRect &rect, KisNodeSP filthyNode, KisRenderPassFlags flags)
 
- Protected Member Functions inherited from KisNode
virtual QRect accessRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
void addKeyframeChannel (KisKeyframeChannel *channel) override
 
void baseNodeChangedCallback () override
 
void baseNodeCollapsedChangedCallback () override
 
void baseNodeInvalidateAllFramesCallback () override
 
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time)
 
void notifyParentVisibilityChanged (bool value) override
 
KisBaseNodeSP parentCallback () const override
 
- Protected Member Functions inherited from KisBaseNode
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 
- Protected Member Functions inherited from KisIndirectPaintingSupport
void lockTemporaryTargetForWrite () const
 
void mergeToLayerImpl (KisPaintDeviceSP dst, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, bool cleanResources, WriteLockerSP sharedWriteLock, QVector< KisRunnableStrokeJobData * > *jobs)
 
void releaseResources ()
 
QString temporaryCompositeOp () const
 
virtual void writeMergeData (KisPainter *painter, KisPaintDeviceSP src, const QRect &rc)
 

Detailed Description

A generator layer is a special kind of layer that can be prefilled with some pixel pattern generated by a KisGenerator plugin. A KisGenerator is similar to a filter, but doesn't take input pixel data and creates new pixel data.

It is not possible to destructively paint on a generator layer.

XXX: what about threadedness?

Definition at line 32 of file kis_generator_layer.cpp.

Constructor & Destructor Documentation

◆ KisGeneratorLayer() [1/2]

KisGeneratorLayer::KisGeneratorLayer ( KisImageWSP image,
const QString & name,
KisFilterConfigurationSP kfc,
KisSelectionSP selection )

Create a new Generator layer with the given configuration and selection. Note that the selection will be copied (using COW, though).

Definition at line 48 of file kis_generator_layer.cpp.

53 m_d(new Private)
54{
55 connect(&m_d->updateSignalCompressor, SIGNAL(timeout()), SLOT(slotDelayedStaticUpdate()));
56}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisImageWSP image
QString name() const
const QScopedPointer< Private > m_d
KisSelectionBasedLayer(KisImageWSP image, const QString &name, KisSelectionSP selection, KisFilterConfigurationSP filterConfig)

References connect(), m_d, and slotDelayedStaticUpdate().

◆ KisGeneratorLayer() [2/2]

KisGeneratorLayer::KisGeneratorLayer ( const KisGeneratorLayer & rhs)

Definition at line 58 of file kis_generator_layer.cpp.

60 m_d(new Private)
61{
62 connect(&m_d->updateSignalCompressor, SIGNAL(timeout()), SLOT(slotDelayedStaticUpdate()));
63}

References connect(), m_d, and slotDelayedStaticUpdate().

◆ ~KisGeneratorLayer()

KisGeneratorLayer::~KisGeneratorLayer ( )
override

Definition at line 65 of file kis_generator_layer.cpp.

66{
67}

Member Function Documentation

◆ accept() [1/2]

bool KisGeneratorLayer::accept ( KisNodeVisitor & )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisNodeVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

return false if the visitor could not successfully act on this node instance.

Reimplemented from KisBaseNode.

Definition at line 182 of file kis_generator_layer.cpp.

183{
184 return v.visit(this);
185}
qreal v

References v.

◆ accept() [2/2]

void KisGeneratorLayer::accept ( KisProcessingVisitor & visitor,
KisUndoAdapter * undoAdapter )
overridevirtual

Accept the KisNodeVisitor (for the Visitor design pattern), should call the correct function on the KisProcessingVisitor for this node type, so you need to override it for all leaf classes in the node inheritance hierarchy.

The processing visitor differs from node visitor in the way that it accepts undo adapter, that allows the processing to be multithreaded

Reimplemented from KisBaseNode.

Definition at line 187 of file kis_generator_layer.cpp.

188{
189 return visitor.visit(this, undoAdapter);
190}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ clone()

KisNodeSP KisGeneratorLayer::clone ( ) const
inlineoverridevirtual

Implements KisNode.

Definition at line 45 of file kis_generator_layer.h.

45 {
46 return KisNodeSP(new KisGeneratorLayer(*this));
47 }
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86
KisGeneratorLayer(KisImageWSP image, const QString &name, KisFilterConfigurationSP kfc, KisSelectionSP selection)

◆ forceUpdateTimedNode()

void KisGeneratorLayer::forceUpdateTimedNode ( )
overridevirtual

forceUpdateTimedNode forces the node to regenerate its project. The update might be asynchronous, so you should call image->waitForDone() after that.

Implements KisDelayedUpdateNodeInterface.

Definition at line 234 of file kis_generator_layer.cpp.

235{
237 m_d->updateSignalCompressor.stop();
238 m_d->updateCookie.clear();
239
241 }
242}
bool hasPendingTimedUpdates() const override

References hasPendingTimedUpdates(), m_d, and slotDelayedStaticUpdate().

◆ hasPendingTimedUpdates()

bool KisGeneratorLayer::hasPendingTimedUpdates ( ) const
overridevirtual
Returns
true if forceUpdateTimedNode() is going to produce any real updates, that is the node has any updates still pending

Implements KisDelayedUpdateNodeInterface.

Definition at line 244 of file kis_generator_layer.cpp.

245{
246 return m_d->updateSignalCompressor.isActive();
247}

References m_d.

◆ icon()

QIcon KisGeneratorLayer::icon ( ) const
overridevirtual
Returns
the icon used to represent the node type, for instance in the layerbox and in the menu.

Reimplemented from KisBaseNode.

Definition at line 192 of file kis_generator_layer.cpp.

193{
194 return KisIconUtils::loadIcon("fillLayer");
195}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ layer()

KisLayer * KisGeneratorLayer::layer ( )
inline

Definition at line 101 of file kis_generator_layer.h.

101 {
102 return this;
103 }

◆ previewWithStroke()

QWeakPointer< boost::none_t > KisGeneratorLayer::previewWithStroke ( const KisStrokeId stroke)

re-runs the generator with the specified configuration. Used for previewing the layer inside the stroke.

Definition at line 157 of file kis_generator_layer.cpp.

158{
159 KisFilterConfigurationSP filterConfig = filter();
161
162 requestUpdateJobsWithStroke(strokeId, filterConfig);
163 return m_d->updateCookie;
164}
virtual KisFilterConfigurationSP filter() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
void requestUpdateJobsWithStroke(const KisStrokeId stroke, const KisFilterConfigurationSP configuration)

References KisNodeFilterInterface::filter(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_d, and requestUpdateJobsWithStroke().

◆ Private()

KisGeneratorLayer::Private ( )
inline

Definition at line 34 of file kis_generator_layer.cpp.

◆ requestUpdateJobsWithStroke()

void KisGeneratorLayer::requestUpdateJobsWithStroke ( const KisStrokeId stroke,
const KisFilterConfigurationSP configuration )
private

Injects render jobs into the given stroke.

Definition at line 117 of file kis_generator_layer.cpp.

118{
119 QMutexLocker locker(&m_d->mutex);
120
121 KisImageSP image = this->image().toStrongRef();
122 const QRect updateRect = extent() | image->bounds();
123
124 if (filterConfig != m_d->preparedForFilter) {
125 locker.unlock();
127 locker.relock();
128 }
129
130 if (m_d->preparedImageBounds != image->bounds()) {
131 m_d->preparedRect = QRect();
132 }
133
134 const QRegion processRegion(QRegion(updateRect) - m_d->preparedRect);
135 if (processRegion.isEmpty())
136 return;
137
138 KisGeneratorSP f = KisGeneratorRegistry::instance()->value(filterConfig->name());
140
141 KisPaintDeviceSP originalDevice = original();
142
143 QSharedPointer<boost::none_t> cookie(new boost::none_t(boost::none));
144
145 auto jobs = KisGeneratorStrokeStrategy::createJobsData(this, cookie, f, originalDevice, processRegion, filterConfig);
146
147 Q_FOREACH (auto job, jobs) {
148 image->addJob(strokeId, job);
149 }
150
151 m_d->updateCookie = cookie;
152 m_d->preparedRect = updateRect;
153 m_d->preparedImageBounds = image->bounds();
154 m_d->preparedForFilter = filterConfig;
155}
static KisGeneratorRegistry * instance()
static QVector< KisStrokeJobData * > createJobsData(const KisGeneratorLayerSP layer, QSharedPointer< boost::none_t > cookie, const KisGeneratorSP f, const KisPaintDeviceSP dev, const QRegion &rc, const KisFilterConfigurationSP filterConfig)
const KoColorSpace * colorSpace() const
void addJob(KisStrokeId id, KisStrokeJobData *data) override
QRect bounds() const override
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
const T value(const QString &id) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
void resetCacheWithoutUpdate(const KoColorSpace *colorSpace)
KisPaintDeviceSP original() const override

References KisImage::addJob(), KisImage::bounds(), KisImage::colorSpace(), KisGeneratorStrokeStrategy::createJobsData(), KisSelectionBasedLayer::extent(), KisBaseNode::image, KisGeneratorRegistry::instance(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KisSelectionBasedLayer::original(), resetCacheWithoutUpdate(), KisWeakSharedPtr< T >::toStrongRef(), and KoGenericRegistry< T >::value().

◆ resetCache()

void KisGeneratorLayer::resetCache ( const KoColorSpace * colorSpace)
overridevirtual

resets cached projection of lower layer to a new device

Returns
void

Reimplemented from KisSelectionBasedLayer.

Definition at line 228 of file kis_generator_layer.cpp.

229{
231 m_d->updateSignalCompressor.start();
232}
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225

References KisLayer::colorSpace(), m_d, and resetCacheWithoutUpdate().

◆ resetCacheWithoutUpdate()

void KisGeneratorLayer::resetCacheWithoutUpdate ( const KoColorSpace * colorSpace)
private

Resets the projection cache without triggering the update job.

Definition at line 249 of file kis_generator_layer.cpp.

250{
252 {
253 QMutexLocker locker(&m_d->mutex);
254 m_d->preparedRect = QRect();
255 }
256}
virtual void resetCache(const KoColorSpace *colorSpace)

References KisLayer::colorSpace(), m_d, and KisSelectionBasedLayer::resetCache().

◆ sectionModelProperties()

KisBaseNode::PropertyList KisGeneratorLayer::sectionModelProperties ( ) const
overridevirtual

Return a the properties of this base node (locked, visible etc, with the right icons for their representation and their state.

Subclasses can extend this list with new properties, like opacity for layers or visualized for masks.

The order of properties is, unfortunately, for now, important, so take care which properties superclasses of your class define.

KisBaseNode defines visible = 0, locked = 1 KisLayer defines opacity = 2, compositeOp = 3 KisMask defines active = 2 (KisMask does not inherit kislayer)

Reimplemented from KisBaseNode.

Definition at line 197 of file kis_generator_layer.cpp.

198{
199 KisFilterConfigurationSP filterConfig = filter();
200
202 l << KisBaseNode::Property(KoID("generator", i18n("Generator")),
203 KisGeneratorRegistry::instance()->value(filterConfig->name())->name());
204
205 return l;
206}
float value(const T *src, size_t ch)
Definition KoID.h:30
KisBaseNode::PropertyList sectionModelProperties() const override
Definition kis_layer.cc:272

References KisNodeFilterInterface::filter(), KisGeneratorRegistry::instance(), KisLayer::sectionModelProperties(), and value().

◆ setDirty() [1/2]

void KisSelectionBasedLayer::setDirty ( )
overridevirtual

Mark a layer as dirty. We can't use KisLayer's one as our extent() function doesn't fit for this

Reimplemented from KisNode.

Definition at line 75 of file kis_selection_based_layer.cpp.

315{
316 Q_ASSERT(image());
317 KisImageSP imageSP = image().toStrongRef();
318 if (!imageSP) {
319 return;
320 }
321 setDirty(imageSP->bounds());
322}

◆ setDirty() [2/2]

void KisGeneratorLayer::setDirty ( const QVector< QRect > & rects)
overridevirtual

Add the given rects to the set of dirty rects for this node; this percolates up to parent nodes all the way to the root node.

Reimplemented from KisNode.

Definition at line 258 of file kis_generator_layer.cpp.

259{
261 m_d->updateSignalCompressor.start();
262}
void setDirtyWithoutUpdate(const QVector< QRect > &rects)

References m_d, and setDirtyWithoutUpdate().

◆ setDirtyWithoutUpdate()

void KisGeneratorLayer::setDirtyWithoutUpdate ( const QVector< QRect > & rects)

Updates the selected tiles without triggering the update job.

Definition at line 264 of file kis_generator_layer.cpp.

References KisSelectionBasedLayer::setDirty().

◆ setFilter()

void KisGeneratorLayer::setFilter ( KisFilterConfigurationSP filterConfig,
bool checkCompareConfig = true )
overridevirtual

Sets the filter configuration for this node. The filter might differ from the filter that is currently set up on this node.

WARNING: the filterConfig becomes owned by the node right after you've set it. Don't try to access the configuration after you've associated it with the node.

Parameters
filterConfigthe new configuration object
checkCompareConfigif true, the update code will check whether the config is the same as the old config, and if so, do nothing. If false, the filter node will be updated always.

Reimplemented from KisNodeFilterInterface.

Definition at line 69 of file kis_generator_layer.cpp.

70{
71 setFilterWithoutUpdate(filterConfig, checkCompareConfig);
72 m_d->updateSignalCompressor.start();
73}
void setFilterWithoutUpdate(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)

References m_d, and setFilterWithoutUpdate().

◆ setFilterWithoutUpdate()

void KisGeneratorLayer::setFilterWithoutUpdate ( KisFilterConfigurationSP filterConfig,
bool checkCompareConfig = true )

Changes the filter configuration without triggering an update.

Definition at line 75 of file kis_generator_layer.cpp.

76{
77 if (filter().isNull() || (!checkCompareConfig || !filter()->compareTo(filterConfig.constData()))) {
79 {
80 QMutexLocker locker(&m_d->mutex);
81 m_d->preparedRect = QRect();
82 }
83 }
84}
virtual void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true)
const T * constData() const

References KisSharedPtr< T >::constData(), KisNodeFilterInterface::filter(), m_d, and KisNodeFilterInterface::setFilter().

◆ setX()

void KisGeneratorLayer::setX ( qint32 )
overridevirtual

Set the x offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented from KisBaseNode.

Definition at line 208 of file kis_generator_layer.cpp.

209{
211 {
212 QMutexLocker locker(&m_d->mutex);
213 m_d->preparedRect = QRect();
214 }
215 m_d->updateSignalCompressor.start();
216}

References m_d, KisSelectionBasedLayer::setX(), and KisSelectionBasedLayer::x().

◆ setY()

void KisGeneratorLayer::setY ( qint32 )
overridevirtual

Set the y offset of this layer in the image place. Re-implement this where it makes sense, by default it does nothing. It should not move child nodes.

Reimplemented from KisBaseNode.

Definition at line 218 of file kis_generator_layer.cpp.

219{
221 {
222 QMutexLocker locker(&m_d->mutex);
223 m_d->preparedRect = QRect();
224 }
225 m_d->updateSignalCompressor.start();
226}

References m_d, KisSelectionBasedLayer::setY(), and KisSelectionBasedLayer::y().

◆ slotDelayedStaticUpdate

void KisGeneratorLayer::slotDelayedStaticUpdate ( )
privateslot

Don't try to start a regeneration stroke while image is locked. It may happen on loading, when all necessary conversions are not yet finished.

The mask might have been deleted from the layers stack in the meanwhile. Just ignore the updates in the case.

Definition at line 86 of file kis_generator_layer.cpp.

87{
93 if (KisImageSP image = this->image(); image && image->locked()) {
94 m_d->updateSignalCompressor.start();
95 return;
96 }
97
103 KisLayerSP parentLayer(qobject_cast<KisLayer*>(parent().data()));
104 if (!parentLayer) return;
105
107
108 if (image) {
109 if (!m_d->updateCookie) {
110 this->update();
111 } else {
112 m_d->updateSignalCompressor.start();
113 }
114 }
115}
bool locked() const
Definition kis_image.cc:751
KisLayerSP parentLayer() const
KisNodeWSP parent
Definition kis_node.cpp:86

References KisBaseNode::image, KisImage::locked(), m_d, KisNode::parent, KisLayer::parentLayer(), and update().

◆ update()

void KisGeneratorLayer::update ( )

re-run the generator. This happens over the bounds of the associated selection.

Definition at line 166 of file kis_generator_layer.cpp.

167{
168 KisImageSP image = this->image().toStrongRef();
169
170 KisFilterConfigurationSP filterConfig = filter();
171 KIS_SAFE_ASSERT_RECOVER_RETURN(filterConfig);
172
174
175 KisStrokeId strokeId = image->startStroke(stroke);
176
177 requestUpdateJobsWithStroke(strokeId, filterConfig);
178
179 image->endStroke(strokeId);
180}
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override

References KisImage::endStroke(), KisNodeFilterInterface::filter(), KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN, requestUpdateJobsWithStroke(), KisImage::startStroke(), and KisWeakSharedPtr< T >::toStrongRef().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisGeneratorLayer::m_d
private

Definition at line 107 of file kis_generator_layer.h.

◆ mutex

QMutex KisGeneratorLayer::mutex

Definition at line 44 of file kis_generator_layer.cpp.

◆ preparedForFilter

KisFilterConfigurationSP KisGeneratorLayer::preparedForFilter

Definition at line 42 of file kis_generator_layer.cpp.

◆ preparedImageBounds

QRect KisGeneratorLayer::preparedImageBounds

Definition at line 41 of file kis_generator_layer.cpp.

◆ preparedRect

QRect KisGeneratorLayer::preparedRect

Definition at line 40 of file kis_generator_layer.cpp.

◆ updateCookie

QWeakPointer<boost::none_t> KisGeneratorLayer::updateCookie

Definition at line 43 of file kis_generator_layer.cpp.

◆ updateSignalCompressor

KisThreadSafeSignalCompressor KisGeneratorLayer::updateSignalCompressor

Definition at line 39 of file kis_generator_layer.cpp.


The documentation for this class was generated from the following files: