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

#include <kis_paint_layer.h>

+ Inheritance diagram for KisPaintLayer:

Public Slots

void slotExternalUpdateOnionSkins ()
 

Public Member Functions

bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
bool allowAsChild (KisNodeSP) const override
 
bool alphaLocked () const
 
const QBitArray & channelLockFlags () const
 
KisNodeSP clone () const override
 
bool decorationsVisible () const override
 
QRect exactBounds () const override
 
QRect extent () const override
 
void flushOnionSkinCache ()
 
KisPaintDeviceList getLodCapableDevices () const override
 
void handleKeyframeChannelFrameAdded (const KisKeyframeChannel *channel, int time) override
 
void handleKeyframeChannelFrameChange (const KisKeyframeChannel *channel, int time) override
 
KisFrameChangeUpdateRecipe handleRasterKeyframeChannelUpdateImpl (const KisKeyframeChannel *channel, int time)
 
QIcon icon () const override
 
 KisPaintLayer (const KisPaintLayer &rhs)
 
 KisPaintLayer (KisImageWSP image, const QString &name, quint8 opacity)
 
 KisPaintLayer (KisImageWSP image, const QString &name, quint8 opacity, const KoColorSpace *colorSpace)
 
 KisPaintLayer (KisImageWSP image, const QString &name, quint8 opacity, KisPaintDeviceSP dev)
 
KisLayerlayer ()
 
bool needProjection () const override
 
bool onionSkinEnabled () const
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
 Private (KisPaintLayer *_q)
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
void setAlphaLocked (bool lock)
 
void setChannelLockFlags (const QBitArray &channelFlags)
 
void setDecorationsVisible (bool value)
 
void setDecorationsVisible (bool value, bool update) override
 
virtual void setDecorationsVisible (bool value, bool update)=0
 
void setImage (KisImageWSP image) override
 
void setOnionSkinEnabled (bool state)
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
 ~KisPaintLayer () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- 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 createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
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
 
virtual KisSelectionSP selection () const
 
virtual KisSelectionMaskSP selectionMask () const
 
virtual void setChannelFlags (const QBitArray &channelFlags)
 
void setLayerStyle (KisPSDLayerStyleSP layerStyle)
 
void setTemporary (bool t)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool temporary () const
 
int thumbnailSeqNo () const override
 
QRect tightUserVisibleBounds () const
 
void unregisterClone (KisCloneLayerWSP clone)
 
void updateClones (const QRect &rect, bool dontInvalidateFrames)
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisLayer () override
 
- Public Member Functions inherited from KisNode
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
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (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)
 
virtual void setDirty ()
 
void setDirty (const KisRegion &region)
 
void setDirty (const QRect &rect)
 
virtual void setDirty (const QVector< QRect > &rects)
 
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 bool supportsLodPainting () 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 KisDecoratedNodeInterface
void setDecorationsVisible (bool value)
 
virtual ~KisDecoratedNodeInterface ()
 

Public Attributes

KisRasterKeyframeChannelcontentChannel
 
KisOnionSkinCache onionSkinCache
 
KisSignalAutoConnectionsStore onionSkinConnection
 
bool onionSkinVisibleOverride = true
 
QBitArray paintChannelFlags
 
KisPaintDeviceSP paintDevice
 
KisPaintLayerq
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- 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
 

Protected Member Functions

void copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const override
 
KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time) override
 
KisKeyframeChannelrequestKeyframeChannel (const QString &id) override
 
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 QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const
 
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)
 

Private Attributes

Private *const m_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>
 
- 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>
 

Detailed Description

This layer is of a type that can be drawn on. A paint layer can have any number of effect masks, a transparency mask, a local selection and a protection mask.

The protection mask can be read/write, read-only or write-only. The transparency mask has two rendering forms: as a selection mask and by changing the transparency of the paint layer's pixels.

Definition at line 40 of file kis_paint_layer.cc.

Constructor & Destructor Documentation

◆ KisPaintLayer() [1/4]

KisPaintLayer::KisPaintLayer ( KisImageWSP image,
const QString & name,
quint8 opacity,
KisPaintDeviceSP dev )

Construct a paint layer with the given parameters. The default bounds of the paintdevice are overwritten.

Parameters
imagethis layer belongs to, or null, if it shouldn't belong to any image
nameof the layer
opacityin the range between OPACITY_TRANSPARENT_U8 and OPACITY_OPAQUE_U8
devis the paint device, that should be used

Definition at line 63 of file kis_paint_layer.cc.

65 , m_d(new Private(this))
66{
67 Q_ASSERT(dev);
68
69 m_d->paintDevice = dev;
70 m_d->paintDevice->setDefaultBounds(new KisDefaultBounds(image));
71 m_d->paintDevice->setSupportsWraparoundMode(true);
72 m_d->paintDevice->setParentNode(this);
73}
KisImageWSP image
QString name() const
quint8 opacity() const
friend class KisLayer
Definition kis_node.h:383
Private *const m_d

References KisBaseNode::image, and m_d.

◆ KisPaintLayer() [2/4]

KisPaintLayer::KisPaintLayer ( KisImageWSP image,
const QString & name,
quint8 opacity )

Construct a paint layer with the given parameters

Parameters
imagethis layer belongs to. it must not be null and it must have a valid color space.
nameof the layer
opacityin the range between OPACITY_TRANSPARENT_U8 and OPACITY_OPAQUE_U8

Definition at line 76 of file kis_paint_layer.cc.

78 , m_d(new Private(this))
79{
80 Q_ASSERT(image);
81
82 m_d->paintDevice = new KisPaintDevice(this, image->colorSpace(), new KisDefaultBounds(image));
83 m_d->paintDevice->setSupportsWraparoundMode(true);
84}
const KoColorSpace * colorSpace() const

References KisImage::colorSpace(), KisBaseNode::image, and m_d.

◆ KisPaintLayer() [3/4]

KisPaintLayer::KisPaintLayer ( KisImageWSP image,
const QString & name,
quint8 opacity,
const KoColorSpace * colorSpace )

Construct a paint layer with the given parameters

Parameters
imagethis layer belongs to, or null, if it shouldn't belong to any image. image must not be null, if colorSpace is null
nameof the layer
opacityin the range between OPACITY_TRANSPARENT_U8 and OPACITY_OPAQUE_U8
colorSpaceis the color space, that should be used to construct the paint device. it can be null, if the image is valid.

Definition at line 86 of file kis_paint_layer.cc.

88 , m_d(new Private(this))
89{
90 if (!colorSpace) {
91 Q_ASSERT(image);
93 }
94 Q_ASSERT(colorSpace);
95 m_d->paintDevice = new KisPaintDevice(this, colorSpace, new KisDefaultBounds(image));
96 m_d->paintDevice->setSupportsWraparoundMode(true);
97}
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225

References KisImage::colorSpace(), KisLayer::colorSpace(), KisBaseNode::image, and m_d.

◆ KisPaintLayer() [4/4]

KisPaintLayer::KisPaintLayer ( const KisPaintLayer & rhs)

Copy Constructor

Definition at line 99 of file kis_paint_layer.cc.

100 : KisLayer(rhs)
102 , m_d(new Private(this))
103{
104 const bool copyFrames = (rhs.m_d->contentChannel != 0);
105 if (!copyFrames) {
106 m_d->paintDevice = new KisPaintDevice(*rhs.m_d->paintDevice.data(), KritaUtils::CopySnapshot, this);
107 m_d->paintDevice->setSupportsWraparoundMode(true);
108 m_d->paintChannelFlags = rhs.m_d->paintChannelFlags;
109 } else {
110 m_d->paintDevice = new KisPaintDevice(*rhs.m_d->paintDevice.data(), KritaUtils::CopyAllFrames, this);
111 m_d->paintDevice->setSupportsWraparoundMode(true);
112 m_d->paintChannelFlags = rhs.m_d->paintChannelFlags;
113
114 m_d->contentChannel = m_d->paintDevice->keyframeChannel();
115 addKeyframeChannel(m_d->contentChannel);
116
117 m_d->contentChannel->setOnionSkinsEnabled(rhs.onionSkinEnabled());
118
120 }
121}
void enableAnimation()
void addKeyframeChannel(KisKeyframeChannel *channel) override
Definition kis_node.cpp:351
bool onionSkinEnabled() const

References KisNode::addKeyframeChannel(), KritaUtils::CopyAllFrames, KritaUtils::CopySnapshot, KisBaseNode::enableAnimation(), m_d, and onionSkinEnabled().

◆ ~KisPaintLayer()

KisPaintLayer::~KisPaintLayer ( )
override

Definition at line 123 of file kis_paint_layer.cc.

124{
125 delete m_d;
126}

References m_d.

Member Function Documentation

◆ accept() [1/2]

bool KisPaintLayer::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 KisNode.

Definition at line 226 of file kis_paint_layer.cc.

227{
228 return v.visit(this);
229}
qreal v

References v.

◆ accept() [2/2]

void KisPaintLayer::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 KisNode.

Definition at line 231 of file kis_paint_layer.cc.

232{
233 return visitor.visit(this, undoAdapter);
234}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ allowAsChild()

bool KisPaintLayer::allowAsChild ( KisNodeSP ) const
overridevirtual

Re-implement this method to add constraints for the subclasses that can be added as children to this node

Returns
false if the given node is not allowed as a child to this node

Implements KisNode.

Definition at line 128 of file kis_paint_layer.cc.

129{
130 return node->inherits("KisMask");
131}

◆ alphaLocked()

bool KisPaintLayer::alphaLocked ( ) const
Returns
true when painting should not affect the alpha channel

Definition at line 263 of file kis_paint_layer.cc.

264{
265 QBitArray flags = colorSpace()->channelFlags(false, true) & m_d->paintChannelFlags;
266 return flags.count(true) == 0 && !m_d->paintChannelFlags.isEmpty();
267}
QBitArray channelFlags(bool color=true, bool alpha=false) const

References KoColorSpace::channelFlags(), KisLayer::colorSpace(), and m_d.

◆ channelLockFlags()

const QBitArray & KisPaintLayer::channelLockFlags ( ) const

Return a bit array where each bit indicates whether a particular channel is locked or not (used by painting tools). If the channelflags bit array is empty, all channels are active.

Definition at line 242 of file kis_paint_layer.cc.

243{
244 return m_d->paintChannelFlags;
245}

References m_d.

◆ clone()

KisNodeSP KisPaintLayer::clone ( ) const
inlineoverridevirtual

Implements KisNode.

Definition at line 65 of file kis_paint_layer.h.

65 {
66 return KisNodeSP(new KisPaintLayer(*this));
67 }
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86
KisPaintLayer(KisImageWSP image, const QString &name, quint8 opacity, KisPaintDeviceSP dev)

◆ copyOriginalToProjection()

void KisPaintLayer::copyOriginalToProjection ( const KisPaintDeviceSP original,
KisPaintDeviceSP projection,
const QRect & rect ) const
overrideprotectedvirtual

Layers can override this method to get some special behavior when copying data from original to projection, e.g. blend in indirect painting device. If you need to modify data outside rect, please also override outgoingChangeRect() method.

Reimplemented from KisLayer.

Definition at line 148 of file kis_paint_layer.cc.

151{
153
155
156 if (hasTemporaryTarget()) {
159 gc.bitBlt(rect.topLeft(), temporaryTarget(), rect);
160 }
161
162 if (m_d->contentChannel &&
163 m_d->contentChannel->keyframeCount() > 1 &&
165 m_d->onionSkinVisibleOverride &&
166 !m_d->paintDevice->defaultBounds()->externalFrameActive()) {
167
168 KisPaintDeviceSP skins = m_d->onionSkinCache.projection(m_d->paintDevice);
169
170 KisPainter gcDest(projection);
171 gcDest.setCompositeOpId(COMPOSITE_BEHIND);
172 gcDest.bitBlt(rect.topLeft(), skins, rect);
173 gcDest.end();
174 }
175
176 if (!m_d->contentChannel ||
177 (m_d->contentChannel->keyframeCount() <= 1) || !onionSkinEnabled()) {
178 m_d->onionSkinCache.reset();
179 }
180}
const QString COMPOSITE_BEHIND
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
void setupTemporaryPainter(KisPainter *painter) const
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:820
KisPaintDeviceSP original() const override

References KisPainter::bitBlt(), COMPOSITE_BEHIND, KisPainter::copyAreaOptimized(), KisPainter::end(), KisIndirectPaintingSupport::hasTemporaryTarget(), m_d, onionSkinEnabled(), original(), KisLayer::projection(), KisPainter::setCompositeOpId(), KisIndirectPaintingSupport::setupTemporaryPainter(), and KisIndirectPaintingSupport::temporaryTarget.

◆ decorationsVisible()

bool KisPaintLayer::decorationsVisible ( ) const
overridevirtual
Returns
true is the layer is allowed to write its decorative information into the stack. The value should be "true" by default.

Implements KisDecoratedNodeInterface.

Definition at line 415 of file kis_paint_layer.cc.

416{
417 return m_d->onionSkinVisibleOverride;
418}

References m_d.

◆ exactBounds()

QRect KisPaintLayer::exactBounds ( ) const
overridevirtual

Returns the exact bounds of where the actual data of this layer resides

Reimplemented from KisLayer.

Definition at line 255 of file kis_paint_layer.cc.

256{
258 QRect rect = t ? t->extent() : QRect();
259 if (onionSkinEnabled() && m_d->onionSkinVisibleOverride) rect |= KisOnionSkinCompositor::instance()->calculateExtent(m_d->paintDevice);
260 return rect | KisLayer::exactBounds();
261}
QRect calculateExtent(const KisPaintDeviceSP device, int time)
static KisOnionSkinCompositor * instance()
QRect extent() const
QRect exactBounds() const override

References KisOnionSkinCompositor::calculateExtent(), KisLayer::exactBounds(), KisPaintDevice::extent(), KisOnionSkinCompositor::instance(), m_d, onionSkinEnabled(), and KisIndirectPaintingSupport::temporaryTarget.

◆ extent()

QRect KisPaintLayer::extent ( ) const
overridevirtual

Returns an approximation of where the bounds of actual data of this layer are

Reimplemented from KisLayer.

Definition at line 247 of file kis_paint_layer.cc.

248{
250 QRect rect = t ? t->extent() : QRect();
251 if (onionSkinEnabled() && m_d->onionSkinVisibleOverride) rect |= KisOnionSkinCompositor::instance()->calculateExtent(m_d->paintDevice);
252 return rect | KisLayer::extent();
253}
QRect extent() const override

References KisOnionSkinCompositor::calculateExtent(), KisPaintDevice::extent(), KisLayer::extent(), KisOnionSkinCompositor::instance(), m_d, onionSkinEnabled(), and KisIndirectPaintingSupport::temporaryTarget.

◆ flushOnionSkinCache()

void KisPaintLayer::flushOnionSkinCache ( )

Reset the onion skin cache to initial state. Useful for ensuring that old and invalid onion skin projections are no longer used.

Definition at line 318 of file kis_paint_layer.cc.

318 {
319 m_d->onionSkinCache.reset();
320}

References m_d.

◆ getLodCapableDevices()

KisPaintDeviceList KisPaintLayer::getLodCapableDevices ( ) const
overridevirtual

Reimplemented from KisNode.

Definition at line 403 of file kis_paint_layer.cc.

404{
406
407 KisPaintDeviceSP onionSkinsDevice = m_d->onionSkinCache.lodCapableDevice();
408 if (onionSkinsDevice) {
409 list << onionSkinsDevice;
410 }
411
412 return list;
413}
virtual KisPaintDeviceList getLodCapableDevices() const
Definition kis_node.cpp:682

References KisNode::getLodCapableDevices(), and m_d.

◆ handleKeyframeChannelFrameAboutToBeRemovedImpl()

KisFrameChangeUpdateRecipe KisPaintLayer::handleKeyframeChannelFrameAboutToBeRemovedImpl ( const KisKeyframeChannel * channel,
int time )
overrideprotectedvirtual

Reimplemented from KisNode.

Definition at line 385 of file kis_paint_layer.cc.

386{
387 if (channel->id() == KisKeyframeChannel::Raster.id()) {
388 return m_d->handleRasterKeyframeChannelUpdateImpl(channel, time);
389 } else {
391 }
392}
static const KoID Raster
QString id() const
Definition KoID.cpp:63
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl(const KisKeyframeChannel *channel, int time)
Definition kis_node.cpp:652

References KisNode::handleKeyframeChannelFrameAboutToBeRemovedImpl(), KoID::id(), KisKeyframeChannel::id(), m_d, and KisKeyframeChannel::Raster.

◆ handleKeyframeChannelFrameAdded()

void KisPaintLayer::handleKeyframeChannelFrameAdded ( const KisKeyframeChannel * channel,
int time )
overridevirtual

Reimplemented from KisNode.

Definition at line 376 of file kis_paint_layer.cc.

377{
378 if (channel->id() == KisKeyframeChannel::Raster.id()) {
379 m_d->handleRasterKeyframeChannelUpdateImpl(channel, time).notify(this);
380 } else {
382 }
383}
virtual void handleKeyframeChannelFrameAdded(const KisKeyframeChannel *channel, int time)
Definition kis_node.cpp:647

References KisNode::handleKeyframeChannelFrameAdded(), KoID::id(), KisKeyframeChannel::id(), m_d, and KisKeyframeChannel::Raster.

◆ handleKeyframeChannelFrameChange()

void KisPaintLayer::handleKeyframeChannelFrameChange ( const KisKeyframeChannel * channel,
int time )
overridevirtual

Reimplemented from KisNode.

Definition at line 367 of file kis_paint_layer.cc.

368{
369 if (channel->id() == KisKeyframeChannel::Raster.id()) {
370 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "raster channel is not supposed to Q_EMIT sigKeyframeChanged");
371 } else {
373 }
374}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
virtual void handleKeyframeChannelFrameChange(const KisKeyframeChannel *channel, int time)
Definition kis_node.cpp:642

References KisNode::handleKeyframeChannelFrameChange(), KoID::id(), KisKeyframeChannel::id(), KIS_SAFE_ASSERT_RECOVER_NOOP, and KisKeyframeChannel::Raster.

◆ handleRasterKeyframeChannelUpdateImpl()

KisFrameChangeUpdateRecipe KisPaintLayer::handleRasterKeyframeChannelUpdateImpl ( const KisKeyframeChannel * channel,
int time )

◆ icon()

QIcon KisPaintLayer::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 182 of file kis_paint_layer.cc.

183{
184 return KisIconUtils::loadIcon("paintLayer");
185}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ layer()

KisLayer * KisPaintLayer::layer ( )
inline

Definition at line 156 of file kis_paint_layer.h.

156 {
157 return this;
158 }

◆ needProjection()

bool KisPaintLayer::needProjection ( ) const
overridevirtual

Reimplemented from KisLayer.

Definition at line 143 of file kis_paint_layer.cc.

144{
146}
bool isAnimated() const

References KisIndirectPaintingSupport::hasTemporaryTarget(), KisBaseNode::isAnimated(), and onionSkinEnabled().

◆ onionSkinEnabled()

bool KisPaintLayer::onionSkinEnabled ( ) const
Returns
true if onion skins should be rendered on this layer

Definition at line 285 of file kis_paint_layer.cc.

286{
287 return nodeProperties().boolProperty("onionskin", false);
288}
bool boolProperty(const QString &name, bool defaultValue=false) const
const KoProperties & nodeProperties() const

References KoProperties::boolProperty(), and KisBaseNode::nodeProperties().

◆ original()

KisPaintDeviceSP KisPaintLayer::original ( ) const
overridevirtual

Returns the original pixels before masks have been applied.

Implements KisLayer.

Definition at line 133 of file kis_paint_layer.cc.

134{
135 return m_d->paintDevice;
136}

References m_d.

◆ paintDevice()

KisPaintDeviceSP KisPaintLayer::paintDevice ( ) const
overridevirtual

Returns the paintDevice that accompanies this layer

Implements KisBaseNode.

◆ Private()

KisPaintLayer::Private ( KisPaintLayer * _q)
inline

Definition at line 43 of file kis_paint_layer.cc.

43: q(_q), contentChannel(0) {}
KisRasterKeyframeChannel * contentChannel
KisPaintLayer * q

◆ requestKeyframeChannel()

KisKeyframeChannel * KisPaintLayer::requestKeyframeChannel ( const QString & id)
overrideprotectedvirtual

Attempt to create the requested channel. Used internally by getKeyframeChannel. Subclasses should implement this method to catch any new channel types they support.

Parameters
idchannel to create
Returns
newly created channel or null

Reimplemented from KisBaseNode.

Definition at line 332 of file kis_paint_layer.cc.

333{
334 if (id == KisKeyframeChannel::Raster.id()) {
335 m_d->contentChannel = m_d->paintDevice->createKeyframeChannel(KisKeyframeChannel::Raster);
336 m_d->contentChannel->setOnionSkinsEnabled(onionSkinEnabled());
337
339 return m_d->contentChannel;
340 }
341
343}
virtual KisKeyframeChannel * requestKeyframeChannel(const QString &id)

References KisBaseNode::enableAnimation(), m_d, onionSkinEnabled(), KisKeyframeChannel::Raster, and KisBaseNode::requestKeyframeChannel().

◆ sectionModelProperties()

KisBaseNode::PropertyList KisPaintLayer::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 KisLayer.

Definition at line 193 of file kis_paint_layer.cc.

194{
196
198
199 if (isAnimated()) {
201 }
202
203 const KoColorSpace *cs = m_d->paintDevice->colorSpace();
204 KisImageSP image = this->image();
205 if (image && *image->colorSpace() != *cs) {
207 }
208
209 return l;
210}
static KisBaseNode::Property getColorSpaceMismatchProperty(const KoColorSpace *cs)
static KisBaseNode::Property getProperty(const KoID &id, bool state)
KisBaseNode::PropertyList sectionModelProperties() const override
Definition kis_layer.cc:272
bool alphaLocked() const

References KisLayerPropertiesIcons::alphaLocked, alphaLocked(), KisImage::colorSpace(), KisLayerPropertiesIcons::getColorSpaceMismatchProperty(), KisLayerPropertiesIcons::getProperty(), KisBaseNode::image, KisBaseNode::isAnimated(), m_d, onionSkinEnabled(), KisLayerPropertiesIcons::onionSkins, and KisLayer::sectionModelProperties().

◆ setAlphaLocked()

void KisPaintLayer::setAlphaLocked ( bool lock)
Parameters
lif true, the alpha channel will be protected from modification

Definition at line 269 of file kis_paint_layer.cc.

270{
271 const bool oldAlphaLocked = alphaLocked();
272 if (oldAlphaLocked == lock) return;
273
274 if(m_d->paintChannelFlags.isEmpty())
275 m_d->paintChannelFlags = colorSpace()->channelFlags(true, true);
276
277 if(lock)
278 m_d->paintChannelFlags &= colorSpace()->channelFlags(true, false);
279 else
280 m_d->paintChannelFlags |= colorSpace()->channelFlags(false, true);
281
283}
void baseNodeChangedCallback() override
Definition kis_node.cpp:329

References alphaLocked(), KisNode::baseNodeChangedCallback(), KoColorSpace::channelFlags(), KisLayer::colorSpace(), KisIndirectPaintingSupport::lock, and m_d.

◆ setChannelLockFlags()

void KisPaintLayer::setChannelLockFlags ( const QBitArray & channelFlags)

set the channelflags for locking certain channels (used by painting tools) for this layer to the specified bit array. The bit array must have exactly the same number of channels as the colorspace this layer is in, or be empty, in which case all channels are active.

Definition at line 236 of file kis_paint_layer.cc.

237{
238 Q_ASSERT(((quint32)channelFlags.count() == colorSpace()->channelCount() || channelFlags.isEmpty()));
239 m_d->paintChannelFlags = channelFlags;
240}

References KisIndirectPaintingSupport::channelFlags, KisLayer::colorSpace(), and m_d.

◆ setDecorationsVisible() [1/3]

void KisDecoratedNodeInterface::setDecorationsVisible ( bool value)

Convenience override for setDecorationsVisible()

Definition at line 38 of file KisDecoratedNodeInterface.cpp.

14{
16}
float value(const T *src, size_t ch)
void setDecorationsVisible(bool value, bool update) override

◆ setDecorationsVisible() [2/3]

void KisPaintLayer::setDecorationsVisible ( bool value,
bool update )
overridevirtual

Enable or disable writing decorative information into layer stack.

Implements KisDecoratedNodeInterface.

Definition at line 420 of file kis_paint_layer.cc.

421{
422 if (value == decorationsVisible()) return;
423
424 const QRect oldExtent = extent();
425
426 m_d->onionSkinVisibleOverride = value;
427
428 if (update && onionSkinEnabled()) {
429 setDirty(oldExtent | extent());
430 }
431}
virtual void setDirty()
Definition kis_node.cpp:577
QRect extent() const override
bool decorationsVisible() const override

References decorationsVisible(), extent(), m_d, onionSkinEnabled(), KisNode::setDirty(), and value().

◆ setDecorationsVisible() [3/3]

virtual void KisDecoratedNodeInterface::setDecorationsVisible ( bool value,
bool update )
virtual

Enable or disable writing decorative information into layer stack.

Implements KisDecoratedNodeInterface.

◆ setImage()

void KisPaintLayer::setImage ( KisImageWSP image)
overridevirtual

Set the image this layer belongs to.

Reimplemented from KisLayer.

Definition at line 187 of file kis_paint_layer.cc.

188{
189 m_d->paintDevice->setDefaultBounds(new KisDefaultBounds(image));
191}
void setImage(KisImageWSP image) override
Definition kis_layer.cc:378

References KisBaseNode::image, m_d, and KisLayer::setImage().

◆ setOnionSkinEnabled()

void KisPaintLayer::setOnionSkinEnabled ( bool state)
Parameters
statewhether onion skins should be rendered

Definition at line 290 of file kis_paint_layer.cc.

291{
292 const auto oldState = onionSkinEnabled();
293 if (oldState == state) return;
294
295 if (!state && oldState) {
296 // FIXME: change ordering! race condition possible!
297
298 // Turning off onionskins shrinks our extent. Let's clean up the onion skins first
299 setDirty(KisOnionSkinCompositor::instance()->calculateExtent(m_d->paintDevice));
300 }
301
302 if (state) {
303 m_d->onionSkinConnection.addConnection(KisOnionSkinCompositor::instance(),
304 SIGNAL(sigOnionSkinChanged()),
305 this,
307 } else {
308 m_d->onionSkinConnection.clear();
309 }
310
311 if (m_d->contentChannel) {
312 m_d->contentChannel->setOnionSkinsEnabled(state);
313 }
314
315 setNodeProperty("onionskin", state);
316}
void setNodeProperty(const QString &name, const QVariant &value)
void slotExternalUpdateOnionSkins()

References KisOnionSkinCompositor::instance(), m_d, onionSkinEnabled(), KisNode::setDirty(), KisBaseNode::setNodeProperty(), and slotExternalUpdateOnionSkins().

◆ setSectionModelProperties()

void KisPaintLayer::setSectionModelProperties ( const KisBaseNode::PropertyList & properties)
overridevirtual

Change the section model properties.

Reimplemented from KisLayer.

Definition at line 212 of file kis_paint_layer.cc.

213{
214 Q_FOREACH (const KisBaseNode::Property &property, properties) {
215 if (property.name == i18n("Alpha Locked")) {
216 setAlphaLocked(property.state.toBool());
217 }
218 else if (property.name == i18n("Onion Skins")) {
219 setOnionSkinEnabled(property.state.toBool());
220 }
221 }
222
224}
KoProperties properties
void setSectionModelProperties(const KisBaseNode::PropertyList &properties) override
Definition kis_layer.cc:297
void setOnionSkinEnabled(bool state)
void setAlphaLocked(bool lock)

References KisBaseNode::Property::name, KisBaseNode::properties, setAlphaLocked(), setOnionSkinEnabled(), KisLayer::setSectionModelProperties(), and KisBaseNode::Property::state.

◆ slotExternalUpdateOnionSkins

void KisPaintLayer::slotExternalUpdateOnionSkins ( )
slot

Definition at line 322 of file kis_paint_layer.cc.

323{
324 if (!onionSkinEnabled()) return;
325
326 const QRect dirtyRect =
328
329 setDirty(dirtyRect);
330}
QRect calculateFullExtent(const KisPaintDeviceSP device)

References KisOnionSkinCompositor::calculateFullExtent(), KisOnionSkinCompositor::instance(), m_d, onionSkinEnabled(), and KisNode::setDirty().

◆ supportsKeyframeChannel()

bool KisPaintLayer::supportsKeyframeChannel ( const QString & id)
overrideprotectedvirtual

Ideally, this function would be used to query for keyframe support before trying to create channels. The ability to query would help in cases such as animation curves where you might want to ask which channels it supports before allowing the user to add.

Parameters
idqueried channel
Returns
bool whether it supports said channel or not.

Reimplemented from KisBaseNode.

Definition at line 394 of file kis_paint_layer.cc.

395{
396 if (id == KisKeyframeChannel::Raster.id()) {
397 return true;
398 }
399
401}
virtual bool supportsKeyframeChannel(const QString &id)

References KisKeyframeChannel::Raster, and KisBaseNode::supportsKeyframeChannel().

Member Data Documentation

◆ contentChannel

KisRasterKeyframeChannel* KisPaintLayer::contentChannel

Definition at line 51 of file kis_paint_layer.cc.

◆ m_d

Private* const KisPaintLayer::m_d
private

Definition at line 172 of file kis_paint_layer.h.

◆ onionSkinCache

KisOnionSkinCache KisPaintLayer::onionSkinCache

Definition at line 54 of file kis_paint_layer.cc.

◆ onionSkinConnection

KisSignalAutoConnectionsStore KisPaintLayer::onionSkinConnection

Definition at line 53 of file kis_paint_layer.cc.

◆ onionSkinVisibleOverride

bool KisPaintLayer::onionSkinVisibleOverride = true

Definition at line 56 of file kis_paint_layer.cc.

◆ paintChannelFlags

QBitArray KisPaintLayer::paintChannelFlags

Definition at line 48 of file kis_paint_layer.cc.

◆ paintDevice

KisPaintDeviceSP KisPaintLayer::paintDevice

Definition at line 47 of file kis_paint_layer.cc.

◆ q

KisPaintLayer* KisPaintLayer::q

Definition at line 45 of file kis_paint_layer.cc.


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