Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLayer Class Referenceabstract

#include <kis_layer.h>

+ Inheritance diagram for KisLayer:

Public Member Functions

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, KisThumbnailBoundsMode boundsMode) override
 
QImage createThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode, KisThumbnailBoundsMode boundsMode) override
 
void disableAlphaChannel (bool disable)
 
QList< KisEffectMaskSPeffectMasks () const
 
QList< KisEffectMaskSPeffectMasks (KisNodeSP lastNode) const
 
QRect exactBounds () const override
 
QRect extent () const override
 
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 ()
 
virtual bool needProjection () const
 
void notifyChildMaskChanged ()
 
KisPaintDeviceSP original () const override=0
 
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 setImage (KisImageWSP image) override
 
void setLayerStyle (KisPSDLayerStyleSP layerStyle)
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setTemporary (bool t)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool temporary () const
 
int thumbnailSeqNo () const override
 
QRect tightUserVisibleBounds () const
 
virtual KisLayerSP tryCreateInternallyMergedLayerFromMutipleLayers (QList< KisLayerSP > layers)
 
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 Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KisNode
bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
virtual bool allowAsChild (KisNodeSP) const =0
 
KisNodeSP at (quint32 index) const
 
KisBusyProgressIndicatorbusyProgressIndicator () const
 
quint32 childCount () const
 
QList< KisNodeSPchildNodes (const QStringList &nodeTypes, const KoProperties &properties) const
 
virtual KisNodeSP clone () const =0
 
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)
 
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)
 
void setImage (KisImageWSP newImage) override
 
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
 
QImage createPreferredThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
QImage createPreferredThumbnailForFrame (qint32 w, qint32 h, int time, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio)
 
void enableAnimation ()
 
KisKeyframeChannelgetKeyframeChannel (const QString &id) const
 
KisKeyframeChannelgetKeyframeChannel (const QString &id, bool create)
 
bool hasEditablePaintDevice () const
 
virtual QIcon icon () 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
 
virtual KisPaintDeviceSP paintDevice () const =0
 
quint8 percentOpacity () const
 
KisThumbnailBoundsMode preferredThumbnailBoundsMode () 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)
 
void setPreferredThumbnailBoundsMode (KisThumbnailBoundsMode value) const
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
virtual void setVisible (bool visible, bool loading=false)
 
virtual bool supportsKeyframeChannel (const QString &id)
 
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 Attributes

QBitArray channelFlags
 
KisCloneLayersList clonesList
 
KisPSDLayerStyleSP layerStyle
 
KisLayerStyleProjectionPlaneSP layerStyleProjectionPlane
 
KisLayerMasksCache masksCache
 
KisMetaData::StoremetaDataStore {nullptr}
 
KisLayerProjectionPlaneSP projectionPlane
 
KisSafeNodeProjectionStoreSP safeProjection
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- 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}
 
KisThumbnailBoundsMode thumbnailBoundsMode { KisThumbnailBoundsMode::Precise }
 

Protected Member Functions

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 void copyOriginalToProjection (const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const
 
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)
 
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
virtual KisKeyframeChannelrequestKeyframeChannel (const QString &id)
 
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Private Member Functions

QRect layerExtentImpl (bool exactBounds) const
 
QRect userVisibleBoundsImpl (bool exactBounds) const
 

Private Attributes

Private *const m_d
 

Friends

class KisLayerMasksCache
 
class KisLayerProjectionPlane
 
class KisLayerTest
 
class KisTransformMask
 

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
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 

Detailed Description

Abstract class that represents the concept of a Layer in Krita. This is not related to the paint devices: this is merely an abstraction of how layers can be stacked and rendered differently. Regarding the previous-, first-, next- and lastChild() calls, first means that it the layer is at the top of the group in the layerlist, using next will iterate to the bottom to last, whereas previous will go up to first again.

TODO: Add a layer mode whereby the projection of the layer is used as a clipping path?

Definition at line 160 of file kis_layer.cc.

Constructor & Destructor Documentation

◆ KisLayer() [1/2]

KisLayer::KisLayer ( KisImageWSP image,
const QString & name,
quint8 opacity )
Parameters
imageis the pointer of the image or null
opacityis a value between OPACITY_TRANSPARENT_U8 and OPACITY_OPAQUE_U8

Definition at line 181 of file kis_layer.cc.

182 : KisNode(image)
183 , m_d(new Private(this))
184{
185 setName(name);
187 m_d->metaDataStore = new KisMetaData::Store();
188 m_d->projectionPlane = toQShared(new KisLayerProjectionPlane(this));
189 m_d->safeProjection = new KisSafeNodeProjectionStore();
190 m_d->safeProjection->setImage(image);
191}
QSharedPointer< T > toQShared(T *ptr)
void setOpacity(quint8 val)
void setName(const QString &name)
KisImageWSP image
QString name() const
quint8 opacity() const
Private *const m_d
Definition kis_layer.h:450
friend class KisLayerProjectionPlane
Definition kis_layer.h:440
KisNode(KisImageWSP image)
Definition kis_node.cpp:167

References KisBaseNode::image, KisLayerProjectionPlane, m_d, KisBaseNode::name(), KisBaseNode::opacity(), KisBaseNode::setName(), KisBaseNode::setOpacity(), and toQShared().

◆ KisLayer() [2/2]

KisLayer::KisLayer ( const KisLayer & rhs)

Definition at line 193 of file kis_layer.cc.

194 : KisNode(rhs)
195 , m_d(new Private(this))
196{
197 if (this != &rhs) {
198 m_d->metaDataStore = new KisMetaData::Store(*rhs.m_d->metaDataStore);
199 m_d->channelFlags = rhs.m_d->channelFlags;
200
201 setName(rhs.name());
202 m_d->projectionPlane = toQShared(new KisLayerProjectionPlane(this));
203 m_d->safeProjection = new KisSafeNodeProjectionStore(*rhs.m_d->safeProjection);
204 m_d->safeProjection->setImage(image());
205
206 if (rhs.m_d->layerStyle) {
207 m_d->layerStyle = rhs.m_d->layerStyle->clone().dynamicCast<KisPSDLayerStyle>();
208
209 if (rhs.m_d->layerStyleProjectionPlane) {
210 m_d->layerStyleProjectionPlane = toQShared(
211 new KisLayerStyleProjectionPlane(*rhs.m_d->layerStyleProjectionPlane,
212 this,
213 m_d->layerStyle));
214 }
215 }
216 }
217}
The KisPSDLayerStyle class implements loading, saving and applying the PSD layer effects.

References KisBaseNode::image, KisLayerProjectionPlane, m_d, KisBaseNode::name(), KisBaseNode::setName(), and toQShared().

◆ ~KisLayer()

KisLayer::~KisLayer ( )
override

Definition at line 219 of file kis_layer.cc.

220{
221 delete m_d->metaDataStore;
222 delete m_d;
223}

References m_d.

Member Function Documentation

◆ alphaChannelDisabled()

bool KisLayer::alphaChannelDisabled ( ) const

returns true if the channel flag for the alpha channel of this layer is not set. returns false otherwise.

Definition at line 334 of file kis_layer.cc.

335{
337 QBitArray flags = colorSpace()->channelFlags(false, true) & m_d->channelFlags;
338 return flags.count(true) == 0 && !m_d->channelFlags.isEmpty();
339}
QBitArray channelFlags(bool color=true, bool alpha=false) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
const KoColorSpace * colorSpace() const override
returns the image's colorSpace or null, if there is no image
Definition kis_layer.cc:225

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

◆ amortizedProjectionRectForCleanupInChangePass()

QRect KisLayer::amortizedProjectionRectForCleanupInChangePass ( ) const
protectedvirtual

Internal projection device that should be updated in the changeRect pass even when the change rect is cropped by masks or something like that

Reimplemented in KisGroupLayer.

Definition at line 860 of file kis_layer.cc.

861{
863}
QRect exactBoundsAmortized() const
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:826

References KisPaintDevice::exactBoundsAmortized(), and projection().

◆ applyMasks()

QRect KisLayer::applyMasks ( const KisPaintDeviceSP source,
KisPaintDeviceSP destination,
const QRect & requestedRect,
KisNodeSP filthyNode,
KisNodeSP lastNode,
KisRenderPassFlags flags ) const
protected

FIXME: Assume that varying of the changeRect has already been taken into account while preparing walkers

A bit of optimization: All filters will read/write exactly from/to the requested rect so we needn't create temporary paint device, just apply it onto destination

We can't eliminate additional copy-op as filters' behaviour may be quite insane here, so let them work on their own paintDevice =)

Definition at line 663 of file kis_layer.cc.

669{
670 Q_ASSERT(source);
671 Q_ASSERT(destination);
672
673 QList<KisEffectMaskSP> masks = effectMasks(lastNode);
674 QRect changeRect;
675 QRect needRect;
676
677 if (masks.isEmpty()) {
678 changeRect = requestedRect;
679 if (source != destination) {
680 copyOriginalToProjection(source, destination, requestedRect);
681 }
682 } else {
683 QStack<QRect> applyRects;
684 bool changeRectVaries;
685 bool needRectVaries;
686
691 changeRectVaries = false;
692 changeRect = requestedRect;
693 //changeRect = masksChangeRect(masks, requestedRect,
694 // changeRectVaries);
695
697 applyRects, needRectVaries);
698
699 if (!changeRectVaries && !needRectVaries) {
706 Q_ASSERT(needRect == requestedRect);
707
708 if (source != destination) {
710 }
711
712 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
713 const QRect maskApplyRect = applyRects.pop();
714 const QRect maskNeedRect =
715 applyRects.isEmpty() ? needRect : applyRects.top();
716
717 PositionToFilthy maskPosition = calculatePositionToFilthy(mask, filthyNode, const_cast<KisLayer*>(this));
718 mask->apply(destination, maskApplyRect, maskNeedRect, maskPosition, flags);
719 }
720 Q_ASSERT(applyRects.isEmpty());
721 } else {
728 KisPaintDeviceSP tempDevice = new KisPaintDevice(colorSpace());
729 tempDevice->prepareClone(source);
731
732 QRect maskApplyRect = applyRects.pop();
733 QRect maskNeedRect = needRect;
734
735 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
736 PositionToFilthy maskPosition = calculatePositionToFilthy(mask, filthyNode, const_cast<KisLayer*>(this));
737 mask->apply(tempDevice, maskApplyRect, maskNeedRect, maskPosition, flags);
738
739 if (!applyRects.isEmpty()) {
740 maskNeedRect = maskApplyRect;
741 maskApplyRect = applyRects.pop();
742 }
743 }
744 Q_ASSERT(applyRects.isEmpty());
745
746 KisPainter::copyAreaOptimized(changeRect.topLeft(), tempDevice, destination, changeRect);
747 }
748 }
749
750 return changeRect;
751}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
void prepareClone(KisPaintDeviceSP src)
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
KisNode::PositionToFilthy calculatePositionToFilthy(KisNodeSP nodeInQuestion, KisNodeSP filthy, KisNodeSP parent)
Definition kis_layer.cc:640
QList< KisEffectMaskSP > effectMasks() const
Definition kis_layer.cc:527
QRect changeRect(const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
Definition kis_layer.cc:865
QRect masksNeedRect(const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const
Definition kis_layer.cc:616
virtual void copyOriginalToProjection(const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const
Definition kis_layer.cc:807
virtual QRect needRect(const QRect &rect, PositionToFilthy pos=N_FILTHY) const
Definition kis_node.cpp:218
PositionToFilthy
Definition kis_node.h:58

References calculatePositionToFilthy(), changeRect(), colorSpace(), KisPainter::copyAreaOptimized(), copyOriginalToProjection(), effectMasks(), masksNeedRect(), KisNode::needRect(), KisPaintDevice::prepareClone(), and source().

◆ buildProjectionUpToNode()

void KisLayer::buildProjectionUpToNode ( KisPaintDeviceSP projection,
KisNodeSP lastNode,
const QRect & rect )

rect is a dirty rect in layer's original() coordinates!

Definition at line 788 of file kis_layer.cc.

789{
790 QRect changeRect = partialChangeRect(lastNode, rect);
791
792 KisPaintDeviceSP originalDevice = original();
793
795
796 if (!changeRect.isEmpty()) {
797 applyMasks(originalDevice, projection,
799 }
800}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
bool hasEffectMasks() const
Definition kis_layer.cc:568
QRect partialChangeRect(KisNodeSP lastNode, const QRect &rect)
Definition kis_layer.cc:775
QRect applyMasks(const KisPaintDeviceSP source, KisPaintDeviceSP destination, const QRect &requestedRect, KisNodeSP filthyNode, KisNodeSP lastNode, KisRenderPassFlags flags) const
Definition kis_layer.cc:663
KisPaintDeviceSP original() const override=0
virtual bool needProjection() const
Definition kis_layer.cc:802

References applyMasks(), changeRect(), hasEffectMasks(), KIS_SAFE_ASSERT_RECOVER_RETURN, needProjection(), NoTransformMaskUpdates, original(), partialChangeRect(), and projection().

◆ canMergeAndKeepBlendOptions()

bool KisLayer::canMergeAndKeepBlendOptions ( KisLayerSP otherLayer)
protected

Definition at line 390 of file kis_layer.cc.

391{
392 return
393 this->compositeOpId() == otherLayer->compositeOpId() &&
394 this->opacity() == otherLayer->opacity() &&
395 this->channelFlags() == otherLayer->channelFlags() &&
396 !this->layerStyle() && !otherLayer->layerStyle() &&
397 (this->colorSpace() == otherLayer->colorSpace() ||
398 *this->colorSpace() == *otherLayer->colorSpace());
399}
const QString & compositeOpId() const
QBitArray channelFlags
Definition kis_layer.cc:167
KisPSDLayerStyleSP layerStyle
Definition kis_layer.cc:171

References channelFlags, colorSpace(), KisBaseNode::compositeOpId(), layerStyle, and KisBaseNode::opacity().

◆ changeRect()

QRect KisLayer::changeRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
overrideprotectedvirtual
Returns
internal changeRect() of the node. Do not mix with
See also
projectionPlane()

Some filters will cause a change of pixels those are outside a requested rect. E.g. we change a rect of 2x2, then we want to apply a convolution filter with kernel 4x4 (changeRect is (2+2*3)x(2+2*3)=8x8) to that area. The rect that should be updated on the layer will be exactly 8x8. More than that the needRect for that update will be 14x14. See needRect.

If the projection contains some dirty areas we should also add them to the change rect, because they might have changed. E.g. when a visibility of the mask has changed while the parent layer was invincible.

Reimplemented from KisNode.

Definition at line 865 of file kis_layer.cc.

866{
867 QRect changeRect = rect;
869
870 if(pos == KisNode::N_FILTHY) {
871 QRect projectionToBeUpdated = amortizedProjectionRectForCleanupInChangePass() & changeRect;
872
873 bool changeRectVaries;
875 changeRect = masksChangeRect(effectMasks(), changeRect, changeRectVaries);
876
884 if (!projectionToBeUpdated.isEmpty() &&
885 !changeRect.contains(projectionToBeUpdated)) {
886
887 changeRect |= projectionToBeUpdated;
888 }
889 }
890
891 // TODO: string comparison: optimize!
892 if (pos != KisNode::N_FILTHY &&
895
896 changeRect |= rect;
897 }
898
899 return changeRect;
900}
const QString COMPOSITE_COPY
virtual QRect outgoingChangeRect(const QRect &rect) const
Definition kis_layer.cc:914
virtual QRect amortizedProjectionRectForCleanupInChangePass() const
Definition kis_layer.cc:860
QRect masksChangeRect(const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
Definition kis_layer.cc:590
virtual QRect incomingChangeRect(const QRect &rect) const
Definition kis_layer.cc:909
@ N_FILTHY
Definition kis_node.h:61
@ N_FILTHY_PROJECTION
Definition kis_node.h:60

References amortizedProjectionRectForCleanupInChangePass(), changeRect(), COMPOSITE_COPY, KisBaseNode::compositeOpId(), effectMasks(), incomingChangeRect(), masksChangeRect(), KisNode::N_FILTHY, KisNode::N_FILTHY_PROJECTION, and outgoingChangeRect().

◆ channelFlags()

QBitArray & KisLayer::channelFlags ( ) const

Return a bit array where each bit indicates whether a particular channel is active or not. If the channelflags bit array is empty, all channels are active.

◆ childNodeChanged()

void KisLayer::childNodeChanged ( KisNodeSP changedChildNode)
overrideprotectedvirtual

Called each time direct child nodes are added or removed under this node as parent. This does not track changes inside the child nodes or the child nodes' properties.

Reimplemented from KisNode.

Definition at line 902 of file kis_layer.cc.

903{
904 if (dynamic_cast<KisMask*>(changedChildNode.data())) {
906 }
907}
void notifyChildMaskChanged()
Definition kis_layer.cc:499

References KisSharedPtr< T >::data(), and notifyChildMaskChanged().

◆ colorOverlayMask()

KisFilterMaskSP KisLayer::colorOverlayMask ( ) const
Returns
the top fast color overlay mask, or nullptr if there's none.

Definition at line 573 of file kis_layer.cc.

574{
575 if (hasEffectMasks()) {
576 // Iterate the masks in reverse, the last element is on top of the stack.
577 auto allMasks = effectMasks();
578 for (auto iter = allMasks.rbegin(); iter != allMasks.rend(); ++iter) {
579 if ((*iter)->inherits("KisFilterMask")) {
580 KisFilterMaskSP filterMask = qobject_cast<KisFilterMask*>((*iter).data());
581 if (filterMask->filter()->name() == "fastcoloroverlay") {
582 return filterMask;
583 }
584 }
585 }
586 }
587 return nullptr;
588}

References effectMasks(), and hasEffectMasks().

◆ colorSpace()

const KoColorSpace * KisLayer::colorSpace ( ) const
overridevirtual

returns the image's colorSpace or null, if there is no image

Implements KisBaseNode.

Definition at line 225 of file kis_layer.cc.

226{
229 return dev->colorSpace();
230}
const KoColorSpace * colorSpace() const
#define KIS_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:85
static KoColorSpaceRegistry * instance()

References KisPaintDevice::colorSpace(), KoColorSpaceRegistry::instance(), KIS_ASSERT_RECOVER_RETURN_VALUE, and original().

◆ compositeOp()

const KoCompositeOp * KisLayer::compositeOp ( ) const
overridevirtual

returns the layer's composite op for the colorspace of the layer's parent.

FIXME: This function duplicates the same function from KisMask. We can't move it to KisBaseNode as it doesn't know anything about parent() method of KisNode Please think it over...

Implements KisBaseNode.

Definition at line 232 of file kis_layer.cc.

233{
241 KisNodeSP parentNode = parent();
242 if (!parentNode) return 0;
243
244 if (!parentNode->colorSpace()) return 0;
245 const KoCompositeOp* op = parentNode->colorSpace()->compositeOp(compositeOpId());
246 return op ? op : parentNode->colorSpace()->compositeOp(COMPOSITE_OVER);
247}
const QString COMPOSITE_OVER
const KoCompositeOp * compositeOp(const QString &id, const KoColorSpace *srcSpace=nullptr) const
virtual const KoColorSpace * colorSpace() const =0
KisNodeWSP parent
Definition kis_node.cpp:86

References KisBaseNode::colorSpace(), COMPOSITE_OVER, KoColorSpace::compositeOp(), KisBaseNode::compositeOpId(), and KisNode::parent.

◆ copyOriginalToProjection()

void KisLayer::copyOriginalToProjection ( const KisPaintDeviceSP original,
KisPaintDeviceSP projection,
const QRect & rect ) const
protectedvirtual

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 in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 807 of file kis_layer.cc.

References KisPainter::copyAreaOptimized(), original(), and projection().

◆ createMergedLayerTemplate()

KisLayerSP KisLayer::createMergedLayerTemplate ( KisLayerSP prevLayer)
virtual

Create and return a layer that is the result of merging this with layer.

This method is designed to be called only within KisImage::mergeLayerDown().

Descendants override this to create specific merged types when possible. The KisLayer one creates a KisPaintLayerSP via a bitBlt, and can work on all layer types.

Descendants that perform their own version do NOT call KisLayer::createMergedLayer

Reimplemented in KisGroupLayer, and KisShapeLayer.

Definition at line 407 of file kis_layer.cc.

408{
409 const bool keepBlendingOptions = canMergeAndKeepBlendOptions(prevLayer);
410
411 KisLayerSP newLayer = new KisPaintLayer(image(), prevLayer->name(), OPACITY_OPAQUE_U8);
412
413 if (keepBlendingOptions) {
414 newLayer->setCompositeOpId(compositeOpId());
415 newLayer->setOpacity(opacity());
416 newLayer->setChannelFlags(channelFlags());
417 }
418
419 return newLayer;
420}
const quint8 OPACITY_OPAQUE_U8
void setCompositeOpId(const QString &compositeOpId)
bool canMergeAndKeepBlendOptions(KisLayerSP otherLayer)
Definition kis_layer.cc:390
virtual void setChannelFlags(const QBitArray &channelFlags)
Definition kis_layer.cc:342

References canMergeAndKeepBlendOptions(), channelFlags, KisBaseNode::compositeOpId(), KisBaseNode::image, KisBaseNode::name(), KisBaseNode::opacity(), OPACITY_OPAQUE_U8, setChannelFlags(), KisBaseNode::setCompositeOpId(), and KisBaseNode::setOpacity().

◆ createThumbnail()

QImage KisLayer::createThumbnail ( qint32 w,
qint32 h,
Qt::AspectRatioMode aspectRatioMode,
KisThumbnailBoundsMode boundsMode )
overridevirtual
Returns
a thumbnail in requested size. The thumbnail is a rgba QImage and may have transparent parts. Returns a fully transparent QImage of the requested size if the current node type cannot generate a thumbnail. If the requested size is too big, return a null QImage.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionBasedLayer.

Definition at line 936 of file kis_layer.cc.

937{
938 if (w == 0 || h == 0) {
939 return QImage();
940 }
941
942 KisPaintDeviceSP originalDevice = original();
943
944 return originalDevice
945 ? originalDevice->createThumbnail(w, h, aspectRatioMode, boundsMode)
946 : QImage();
947}
QImage createThumbnail(qint32 maxw, qint32 maxh, KisThumbnailBoundsMode boundsMode=KisThumbnailBoundsMode::Precise, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())

References KisPaintDevice::createThumbnail(), and original().

◆ createThumbnailForFrame()

QImage KisLayer::createThumbnailForFrame ( qint32 w,
qint32 h,
int time,
Qt::AspectRatioMode aspectRatioMode,
KisThumbnailBoundsMode boundsMode )
overridevirtual
Returns
a thumbnail in requested size for the defined timestamp. The thumbnail is a rgba Image and may have transparent parts. Returns a fully transparent QImage of the requested size if the current node type cannot generate a thumbnail. If the requested size is too big, return a null QImage.

Reimplemented from KisBaseNode.

Definition at line 955 of file kis_layer.cc.

956{
957 if (w == 0 || h == 0) {
958 return QImage();
959 }
960
961 KisPaintDeviceSP originalDevice = original();
962 if (originalDevice ) {
963 KisRasterKeyframeChannel *channel = originalDevice->keyframeChannel();
964
965 if (channel) {
966 KisPaintDeviceSP targetDevice = new KisPaintDevice(colorSpace());
967 KisRasterKeyframeSP keyframe = channel->activeKeyframeAt<KisRasterKeyframe>(time);
968 keyframe->writeFrameToDevice(targetDevice);
969 return targetDevice->createThumbnail(w, h, aspectRatioMode, boundsMode);
970 }
971 }
972
973 return createThumbnail(w, h, aspectRatioMode, boundsMode);
974}
KisKeyframeSP activeKeyframeAt(int time) const
KisRasterKeyframeChannel * keyframeChannel() const
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image ...
QImage createThumbnail(qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode, KisThumbnailBoundsMode boundsMode) override
Definition kis_layer.cc:936

References KisKeyframeChannel::activeKeyframeAt(), colorSpace(), KisPaintDevice::createThumbnail(), createThumbnail(), KisPaintDevice::keyframeChannel(), and original().

◆ disableAlphaChannel()

void KisLayer::disableAlphaChannel ( bool disable)

set/unset the channel flag for the alpha channel of this layer

Definition at line 319 of file kis_layer.cc.

320{
321 QBitArray newChannelFlags = m_d->channelFlags;
322
323 if(newChannelFlags.isEmpty())
324 newChannelFlags = colorSpace()->channelFlags(true, true);
325
326 if(disable)
327 newChannelFlags &= colorSpace()->channelFlags(true, false);
328 else
329 newChannelFlags |= colorSpace()->channelFlags(false, true);
330
331 setChannelFlags(newChannelFlags);
332}

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

◆ effectMasks() [1/2]

QList< KisEffectMaskSP > KisLayer::effectMasks ( ) const
Returns
the list of effect masks

Definition at line 527 of file kis_layer.cc.

528{
529 return m_d->masksCache.effectMasks();
530}

References m_d.

◆ effectMasks() [2/2]

QList< KisEffectMaskSP > KisLayer::effectMasks ( KisNodeSP lastNode) const
Returns
the list of effect masks up to a certain node

Definition at line 532 of file kis_layer.cc.

533{
534 if (lastNode.isNull()) {
535 return effectMasks();
536 } else {
537 // happens rarely.
538 return searchEffectMasks(lastNode);
539 }
540}
bool isNull() const
QList< KisEffectMaskSP > searchEffectMasks(KisNodeSP lastNode) const
Definition kis_layer.cc:542

References effectMasks(), KisSharedPtr< T >::isNull(), and searchEffectMasks().

◆ exactBounds()

QRect KisLayer::exactBounds ( ) const
overridevirtual

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

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 1033 of file kis_layer.cc.

1034{
1035 return layerExtentImpl(true);
1036}
QRect layerExtentImpl(bool exactBounds) const
Definition kis_layer.cc:999

References layerExtentImpl().

◆ extent()

QRect KisLayer::extent ( ) const
overridevirtual

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

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 1028 of file kis_layer.cc.

1029{
1030 return layerExtentImpl(false);
1031}

References layerExtentImpl().

◆ fillMergedLayerTemplate()

void KisLayer::fillMergedLayerTemplate ( KisLayerSP dstLayer,
KisLayerSP prevLayer,
bool skipPaintingThisLayer = false )
virtual

Reimplemented in KisGroupLayer, and KisShapeLayer.

Definition at line 422 of file kis_layer.cc.

423{
424 const bool keepBlendingOptions = canMergeAndKeepBlendOptions(prevLayer);
425
426 QRect layerProjectionExtent = this->projection()->extent();
427 QRect prevLayerProjectionExtent = prevLayer->projection()->extent();
428 bool alphaDisabled = this->alphaChannelDisabled();
429 bool prevAlphaDisabled = prevLayer->alphaChannelDisabled();
430
431 KisPaintDeviceSP mergedDevice = dstLayer->paintDevice();
432
433 if (!keepBlendingOptions) {
434 KisPainter gc(mergedDevice);
435
436 KisImageSP imageSP = image().toStrongRef();
437 if (!imageSP) {
438 return;
439 }
440
441 //Copy the pixels of previous layer with their actual alpha value
442 prevLayer->disableAlphaChannel(false);
443
444 prevLayer->projectionPlane()->apply(&gc, prevLayerProjectionExtent | imageSP->bounds());
445
446 //Restore the previous prevLayer disableAlpha status for correct undo/redo
447 prevLayer->disableAlphaChannel(prevAlphaDisabled);
448
449 if (!skipPaintingThisLayer) {
450 //Paint the pixels of the current layer, using their actual alpha value
451 if (alphaDisabled == prevAlphaDisabled) {
452 this->disableAlphaChannel(false);
453 }
454
455 this->projectionPlane()->apply(&gc, layerProjectionExtent | imageSP->bounds());
456
457 //Restore the layer disableAlpha status for correct undo/redo
458 this->disableAlphaChannel(alphaDisabled);
459 }
460 }
461 else {
462 //Copy prevLayer
463 KisPaintDeviceSP srcDev = prevLayer->projection();
464 mergedDevice->makeCloneFrom(srcDev, srcDev->extent());
465
466 if (!skipPaintingThisLayer) {
467 //Paint layer on the copy
468 KisPainter gc(mergedDevice);
469 gc.bitBlt(layerProjectionExtent.topLeft(), this->projection(), layerProjectionExtent);
470 }
471 }
472}
QRect bounds() const override
QRect extent() const
void makeCloneFrom(KisPaintDeviceSP src, const QRect &rect)
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
virtual KisPaintDeviceSP paintDevice() const =0
void disableAlphaChannel(bool disable)
Definition kis_layer.cc:319
bool alphaChannelDisabled() const
Definition kis_layer.cc:334
KisLayerProjectionPlaneSP projectionPlane
Definition kis_layer.cc:174

References alphaChannelDisabled(), KisPainter::bitBlt(), KisImage::bounds(), canMergeAndKeepBlendOptions(), disableAlphaChannel(), KisPaintDevice::extent(), KisBaseNode::image, KisPaintDevice::makeCloneFrom(), KisBaseNode::paintDevice(), projection(), projectionPlane, and KisWeakSharedPtr< T >::toStrongRef().

◆ hasClones()

bool KisLayer::hasClones ( ) const

Returns whether we have a clone.

Be careful with it. It is not thread safe to add/remove clone while checking hasClones(). So there should be no updates.

Definition at line 489 of file kis_layer.cc.

490{
491 return m_d->clonesList.hasClones();
492}

References m_d.

◆ hasEffectMasks()

bool KisLayer::hasEffectMasks ( ) const

Returns true if there are any effect masks present

Definition at line 568 of file kis_layer.cc.

569{
570 return !m_d->masksCache.effectMasks().isEmpty();
571}

References m_d.

◆ incomingChangeRect()

QRect KisLayer::incomingChangeRect ( const QRect & rect) const
protectedvirtual

For KisLayer classes change rect transformation consists of two parts: incoming and outgoing.

1) incomingChangeRect(rect) chande rect transformation performed by the transformations done basing on global projection. It is performed in KisAsyncMerger + KisUpdateOriginalVisitor classes. It happens before data coming to KisLayer::original() therefore it is 'incoming'. See KisAdjustmentLayer for example of usage.

2) outgoingChangeRect(rect) change rect transformation that happens in KisLayer::copyOriginalToProjection(). It applies only when the layer is 'filthy', that is was the cause of the merge process. See KisCloneLayer for example of usage.

The flow of changed areas can be illustrated in the following way:

  1. Current projection of size R1 is stored in KisAsyncMerger::m_currentProjection | | <– KisUpdateOriginalVisitor writes data into layer's original() device. | The changed area on KisLayer::original() is | R2 = KisLayer::incomingChangeRect(R1) |
  2. KisLayer::original() / changed rect: R2 | | <– KisLayer::updateProjection() starts composing a layer | It calls KisLayer::copyOriginalToProjection() which copies some area | to a temporary device. The temporary device now stores | R3 = KisLayer::outgoingChangeRect(R2) |
  3. Temporary device / changed rect: R3 | | <– KisLayer::updateProjection() continues composing a layer. It merges a mask. | R4 = KisMask::changeRect(R3) |
  4. KisLayer::original() / changed rect: R4

So in the end rect R4 will be passed up to the next layers in the stack.

Reimplemented in KisAdjustmentLayer.

Definition at line 909 of file kis_layer.cc.

910{
911 return rect;
912}

◆ internalProjectionPlane()

KisLayerProjectionPlaneSP KisLayer::internalProjectionPlane ( ) const
virtual

The projection plane representing the layer itself without any styles or anything else. It is used by the layer styles projection plane to stack up the planes.

Definition at line 821 of file kis_layer.cc.

822{
823 return m_d->projectionPlane;
824}

References m_d.

◆ layerExtentImpl()

QRect KisLayer::layerExtentImpl ( bool exactBounds) const
private

Definition at line 999 of file kis_layer.cc.

1000{
1001 QRect additionalMaskExtent = QRect();
1003
1004 Q_FOREACH(KisEffectMaskSP mask, effectMasks) {
1005 additionalMaskExtent |= mask->nonDependentExtent();
1006 }
1007
1008 KisPaintDeviceSP originalDevice = original();
1009 QRect layerExtent;
1010
1011 if (originalDevice) {
1012 layerExtent = needExactBounds ?
1013 originalDevice->exactBounds() :
1014 originalDevice->extent();
1015 }
1016
1017 QRect additionalCompositeOpExtent;
1018 if (compositeOpId() == COMPOSITE_COPY ||
1021
1022 additionalCompositeOpExtent = originalDevice->defaultBounds()->bounds();
1023 }
1024
1025 return layerExtent | additionalMaskExtent | additionalCompositeOpExtent;
1026}
const QString COMPOSITE_DESTINATION_ATOP
const QString COMPOSITE_DESTINATION_IN
virtual QRect bounds() const =0
QRect exactBounds() const
KisDefaultBoundsBaseSP defaultBounds() const

References KisDefaultBoundsBase::bounds(), COMPOSITE_COPY, COMPOSITE_DESTINATION_ATOP, COMPOSITE_DESTINATION_IN, KisBaseNode::compositeOpId(), KisPaintDevice::defaultBounds(), effectMasks(), KisPaintDevice::exactBounds(), KisPaintDevice::extent(), and original().

◆ layerStyle()

KisPSDLayerStyleSP KisLayer::layerStyle ( ) const

◆ looseUserVisibleBounds()

QRect KisLayer::looseUserVisibleBounds ( ) const

Return an approximated (loose) rectangle, where the contents of the layer is placed from user's point of view. This rectangle includes all the masks and effects the layer has (excluding layer styles, they report their bounds via projection plane).

This rect is always equal or bigger than tightUserVisibleBounds()

Definition at line 855 of file kis_layer.cc.

856{
857 return userVisibleBoundsImpl(false);
858}
QRect userVisibleBoundsImpl(bool exactBounds) const
Definition kis_layer.cc:834

References userVisibleBoundsImpl().

◆ masksChangeRect()

QRect KisLayer::masksChangeRect ( const QList< KisEffectMaskSP > & masks,
const QRect & requestedRect,
bool & rectVariesFlag ) const
protected
Parameters
rectVariesFlag(out param) a flag, showing whether a rect varies from mask to mask
Returns
an area that should be updated because of the change of @requestedRect of the layer

We set default value of the change rect for the case when there is no mask at all

Definition at line 590 of file kis_layer.cc.

593{
594 rectVariesFlag = false;
595
596 QRect prevChangeRect = requestedRect;
597
602 QRect changeRect = requestedRect;
603
604 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
605 changeRect = mask->changeRect(prevChangeRect);
606
607 if (changeRect != prevChangeRect)
608 rectVariesFlag = true;
609
610 prevChangeRect = changeRect;
611 }
612
613 return changeRect;
614}

References changeRect().

◆ masksNeedRect()

QRect KisLayer::masksNeedRect ( const QList< KisEffectMaskSP > & masks,
const QRect & changeRect,
QStack< QRect > & applyRects,
bool & rectVariesFlag ) const
protected

Get needRects for all masks

Parameters
changeRectrequested rect to be updated on final projection. Should be a return value of masksChangedRect()
applyRects(out param) a stack of the rects where filters should be applied
rectVariesFlag(out param) a flag, showing whether a rect varies from mask to mask
Returns
a needRect that should be prepared on the layer's paintDevice for all masks to succeed

Definition at line 616 of file kis_layer.cc.

620{
621 rectVariesFlag = false;
622
623 QRect prevNeedRect = changeRect;
624 QRect needRect;
625
626 for (qint32 i = masks.size() - 1; i >= 0; i--) {
627 applyRects.push(prevNeedRect);
628
629 needRect = masks[i]->needRect(prevNeedRect);
630
631 if (prevNeedRect != needRect)
632 rectVariesFlag = true;
633
634 prevNeedRect = needRect;
635 }
636
637 return needRect;
638}

References changeRect(), and KisNode::needRect().

◆ metaData()

KisMetaData::Store * KisLayer::metaData ( )
Returns
the metadata object associated with this object.

Definition at line 1043 of file kis_layer.cc.

1044{
1045 return m_d->metaDataStore;
1046}

References m_d.

◆ needProjection()

bool KisLayer::needProjection ( ) const
virtual

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 802 of file kis_layer.cc.

803{
804 return false;
805}

◆ needRectForOriginal()

QRect KisLayer::needRectForOriginal ( const QRect & rect) const
protected

Return need rect that should be prepared on original() device of the layer to get rect on its projection.

This method is used either for layers that can have other layers as children (yes, KisGroupLayer, I'm looking at you!), or for layers that depend on the lower nodes (it's you, KisAdjustmentLayer!).

These layers may have some filter masks that need a bit more pixels than requested, therefore child nodes should do a bit more work to prepare them.

Definition at line 919 of file kis_layer.cc.

920{
921 QRect needRect = rect;
922
923 const QList<KisEffectMaskSP> masks = effectMasks();
924
925 if (!masks.isEmpty()) {
926 QStack<QRect> applyRects;
927 bool needRectVaries;
928
929 needRect = masksNeedRect(masks, rect,
930 applyRects, needRectVaries);
931 }
932
933 return needRect;
934}

References effectMasks(), masksNeedRect(), and KisNode::needRect().

◆ notifyChildMaskChanged()

void KisLayer::notifyChildMaskChanged ( )

Informs this layers that its masks might have changed.

Definition at line 499 of file kis_layer.cc.

500{
501 m_d->masksCache.setDirty();
502}

References m_d.

◆ original()

KisPaintDeviceSP KisLayer::original ( ) const
overridepure virtual

Return the layer data before the effect masks have had their go at it.

Implements KisBaseNode.

Implemented in KisCloneLayer, KisGroupLayer, KisPaintLayer, KisSelectionBasedLayer, KisShapeLayer, KisFileLayer, and KisDecorationsWrapperLayer.

◆ outgoingChangeRect()

QRect KisLayer::outgoingChangeRect ( const QRect & rect) const
protectedvirtual
See also
incomingChangeRect()

Reimplemented in KisCloneLayer.

Definition at line 914 of file kis_layer.cc.

915{
916 return rect;
917}

◆ parentLayer()

KisLayerSP KisLayer::parentLayer ( ) const

Get the group layer that contains this layer.

Definition at line 1038 of file kis_layer.cc.

1039{
1040 return qobject_cast<KisLayer*>(parent().data());
1041}

References KisNode::parent.

◆ partialChangeRect()

QRect KisLayer::partialChangeRect ( KisNodeSP lastNode,
const QRect & rect )

Definition at line 775 of file kis_layer.cc.

776{
777 bool changeRectVaries = false;
780 changeRectVaries);
781
782 return changeRect;
783}

References changeRect(), effectMasks(), masksChangeRect(), and outgoingChangeRect().

◆ Private()

KisLayer::Private ( KisLayer * q)
inline

Definition at line 162 of file kis_layer.cc.

163 : masksCache(q)
164 {
165 }
KisLayerMasksCache masksCache
Definition kis_layer.cc:177

◆ projection()

KisPaintDeviceSP KisLayer::projection ( ) const
overridevirtual

Return the fully rendered representation of this layer: its data and its effect masks

Implements KisBaseNode.

Definition at line 826 of file kis_layer.cc.

827{
828 KisPaintDeviceSP originalDevice = original();
829
830 return needProjection() || hasEffectMasks() ?
831 m_d->safeProjection->getDeviceLazy(originalDevice) : originalDevice;
832}

References hasEffectMasks(), m_d, needProjection(), and original().

◆ projectionPlane()

KisAbstractProjectionPlaneSP KisLayer::projectionPlane ( ) const
overridevirtual
See also
a comment in KisNode::projectionPlane()

Reimplemented from KisNode.

◆ registerClone()

void KisLayer::registerClone ( KisCloneLayerWSP clone)

Clones should be informed about updates of the original layer, so this is a way to register them

Definition at line 474 of file kis_layer.cc.

475{
476 m_d->clonesList.addClone(clone);
477}
virtual KisNodeSP clone() const =0

References KisNode::clone(), and m_d.

◆ registeredClones()

const QList< KisCloneLayerWSP > KisLayer::registeredClones ( ) const

Return the list of the clones of this node. Be careful with the list, because it is not thread safe.

Definition at line 484 of file kis_layer.cc.

485{
486 return m_d->clonesList.registeredClones();
487}

References m_d.

◆ searchEffectMasks()

QList< KisEffectMaskSP > KisLayer::searchEffectMasks ( KisNodeSP lastNode) const
protected

Definition at line 542 of file kis_layer.cc.

543{
545
547
548 KisProjectionLeafSP child = projectionLeaf()->firstChild();
549 while (child) {
550 if (child->node() == lastNode) break;
551
553 KIS_SAFE_ASSERT_RECOVER_NOOP(child->node());
554
555 if (child->visible()) {
556 KisEffectMaskSP mask = dynamic_cast<KisEffectMask*>(const_cast<KisNode*>(child->node().data()));
557 if (mask) {
558 masks.append(mask);
559 }
560 }
561
562 child = child->nextSibling();
563 }
564
565 return masks;
566}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
KisProjectionLeafSP projectionLeaf
Definition kis_node.cpp:93

References KIS_SAFE_ASSERT_RECOVER_NOOP, and KisNode::projectionLeaf.

◆ sectionModelProperties()

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

Reimplemented in KisPaintLayer, and KisShapeLayer.

Definition at line 272 of file kis_layer.cc.

273{
275 l << KisBaseNode::Property(KoID("opacity", i18n("Opacity")), i18n("%1%", percentOpacity()));
276
277 const KoCompositeOp * compositeOp = this->compositeOp();
278
279 if (compositeOp) {
280 l << KisBaseNode::Property(KoID("compositeop", i18n("Blending Mode")), compositeOp->description());
281 }
282
283 if (m_d->layerStyle && !m_d->layerStyle->isEmpty()) {
285 }
286
288
289 if (colorOverlayMask()) {
290 // Use an immutable property (with a string value), to hide it in the layer properties dialog.
292 }
293
294 return l;
295}
static KisBaseNode::Property getProperty(const KoID &id, bool state)
Definition KoID.h:30
quint8 percentOpacity() const
virtual PropertyList sectionModelProperties() const
const KoCompositeOp * compositeOp() const override
returns the layer's composite op for the colorspace of the layer's parent.
Definition kis_layer.cc:232
KisFilterMaskSP colorOverlayMask() const
Definition kis_layer.cc:573

References alphaChannelDisabled(), KisLayerPropertiesIcons::colorOverlay, colorOverlayMask(), compositeOp(), KoCompositeOp::description, KisLayerPropertiesIcons::getProperty(), KisLayerPropertiesIcons::inheritAlpha, KisLayerPropertiesIcons::layerStyle, m_d, KisBaseNode::percentOpacity(), and KisBaseNode::sectionModelProperties().

◆ selection()

KisSelectionSP KisLayer::selection ( ) const
virtual
Returns
the selection contained in the first KisSelectionMask associated with this layer or the image, if either exists, otherwise, return 0.

Definition at line 509 of file kis_layer.cc.

510{
512
513 if (mask) {
514 return mask->selection();
515 }
516
517 KisImageSP image = this->image();
518 if (image) {
519 return image->globalSelection();
520 }
521 return KisSelectionSP();
522}
KisSelectionSP globalSelection() const
Definition kis_image.cc:695
KisSharedPtr< KisSelection > KisSelectionSP
Definition kis_types.h:149
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:504
KisSelectionSP selection
Definition kis_mask.cc:44

References KisImage::globalSelection(), KisBaseNode::image, KisMask::selection, and selectionMask().

◆ selectionMask()

KisSelectionMaskSP KisLayer::selectionMask ( ) const
virtual
Returns
the selection associated with this layer, if there is one. Otherwise, return 0;

Definition at line 504 of file kis_layer.cc.

505{
506 return m_d->masksCache.selectionMask();
507}

References m_d.

◆ setChannelFlags()

void KisLayer::setChannelFlags ( const QBitArray & channelFlags)
virtual

set the channelflags 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.

Reimplemented in KisAdjustmentLayer.

Definition at line 342 of file kis_layer.cc.

343{
344 Q_ASSERT(channelFlags.isEmpty() ||((quint32)channelFlags.count() == colorSpace()->channelCount()));
345
347 this->channelFlags())) {
348 return;
349 }
350
351 if (!channelFlags.isEmpty() &&
352 channelFlags == QBitArray(channelFlags.size(), true)) {
353
354 m_d->channelFlags.clear();
355 } else {
356 m_d->channelFlags = channelFlags;
357 }
358
361}
bool compareChannelFlags(QBitArray f1, QBitArray f2)
void baseNodeInvalidateAllFramesCallback() override
Definition kis_node.cpp:337
void baseNodeChangedCallback() override
Definition kis_node.cpp:329

References KisNode::baseNodeChangedCallback(), KisNode::baseNodeInvalidateAllFramesCallback(), channelFlags, colorSpace(), KritaUtils::compareChannelFlags(), and m_d.

◆ setImage()

void KisLayer::setImage ( KisImageWSP image)
overridevirtual

Set the image this layer belongs to.

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer, KisSelectionBasedLayer, and KisShapeLayer.

Definition at line 378 of file kis_layer.cc.

379{
380 // we own the projection device, so we should take care about it
382 if (projection && projection != original()) {
384 }
385 m_d->safeProjection->setImage(image);
386
388}
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
void setImage(KisImageWSP newImage) override
Definition kis_node.cpp:254

References KisBaseNode::image, m_d, original(), projection(), KisPaintDevice::setDefaultBounds(), and KisNode::setImage().

◆ setLayerStyle()

void KisLayer::setLayerStyle ( KisPSDLayerStyleSP layerStyle)

Definition at line 254 of file kis_layer.cc.

255{
256 if (layerStyle) {
257 KIS_SAFE_ASSERT_RECOVER_NOOP(layerStyle->hasLocalResourcesSnapshot());
258
259 m_d->layerStyle = layerStyle;
260
261 KisLayerStyleProjectionPlaneSP plane = !layerStyle->isEmpty() ?
264
265 m_d->layerStyleProjectionPlane = plane;
266 } else {
267 m_d->layerStyleProjectionPlane.clear();
268 m_d->layerStyle.clear();
269 }
270}
QSharedPointer< KisLayerStyleProjectionPlane > KisLayerStyleProjectionPlaneSP

References KIS_SAFE_ASSERT_RECOVER_NOOP, layerStyle, and m_d.

◆ setSectionModelProperties()

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

Change the section model properties.

Reimplemented from KisBaseNode.

Reimplemented in KisPaintLayer, and KisShapeLayer.

Definition at line 297 of file kis_layer.cc.

298{
300
301 Q_FOREACH (const KisBaseNode::Property &property, properties) {
302 if (property.id == KisLayerPropertiesIcons::inheritAlpha.id()) {
303 disableAlphaChannel(property.state.toBool());
304 }
305
306 if (property.id == KisLayerPropertiesIcons::layerStyle.id()) {
307 if (m_d->layerStyle &&
308 m_d->layerStyle->isEnabled() != property.state.toBool()) {
309
310 m_d->layerStyle->setEnabled(property.state.toBool());
311
314 }
315 }
316 }
317}
QString id() const
Definition KoID.cpp:63
KoProperties properties
virtual void setSectionModelProperties(const PropertyList &properties)

References KisNode::baseNodeChangedCallback(), KisNode::baseNodeInvalidateAllFramesCallback(), disableAlphaChannel(), KoID::id(), KisBaseNode::Property::id, KisLayerPropertiesIcons::inheritAlpha, KisLayerPropertiesIcons::layerStyle, m_d, KisBaseNode::properties, KisBaseNode::setSectionModelProperties(), and KisBaseNode::Property::state.

◆ setTemporary()

void KisLayer::setTemporary ( bool t)

Set to true if this layer should not appear in the layerbox, even though it is temporarily in the layer stack and taken into account on recomposition.

Definition at line 373 of file kis_layer.cc.

374{
375 setNodeProperty("temporary", t);
376}
void setNodeProperty(const QString &name, const QVariant &value)

References KisBaseNode::setNodeProperty().

◆ setX()

void KisLayer::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.

Reimplemented in KisSelectionBasedLayer, and KisShapeLayer.

Definition at line 986 of file kis_layer.cc.

987{
988 KisPaintDeviceSP originalDevice = original();
989 if (originalDevice)
990 originalDevice->setX(x);
991}
void setX(qint32 x)
qint32 x() const override
Definition kis_layer.cc:976

References original(), KisPaintDevice::setX(), and x().

◆ setY()

void KisLayer::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.

Reimplemented in KisSelectionBasedLayer, and KisShapeLayer.

Definition at line 992 of file kis_layer.cc.

993{
994 KisPaintDeviceSP originalDevice = original();
995 if (originalDevice)
996 originalDevice->setY(y);
997}
void setY(qint32 y)
qint32 y() const override
Definition kis_layer.cc:981

References original(), KisPaintDevice::setY(), and y().

◆ temporary()

bool KisLayer::temporary ( ) const

Returns true if this layer is temporary: i.e., it should not appear in the layerbox, even though it is temporarily in the layer stack and taken into account on recomposition.

Definition at line 368 of file kis_layer.cc.

369{
370 return nodeProperties().boolProperty("temporary", false);
371}
bool boolProperty(const QString &name, bool defaultValue=false) const
const KoProperties & nodeProperties() const

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

◆ thumbnailSeqNo()

int KisLayer::thumbnailSeqNo ( ) const
overridevirtual
Returns
a sequence number of the thumbnail of the node. Every time the layer changes, the sequence number increases.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionBasedLayer.

Definition at line 949 of file kis_layer.cc.

950{
951 KisPaintDeviceSP originalDevice = original();
952 return originalDevice ? originalDevice->sequenceNumber() : -1;
953}
int sequenceNumber() const

References original(), and KisPaintDevice::sequenceNumber().

◆ tightUserVisibleBounds()

QRect KisLayer::tightUserVisibleBounds ( ) const

Return a tight rectangle, where the contents of the layer is placed from user's point of view. This rectangle includes all the masks and effects the layer has (excluding layer styles, they report their bounds via projection plane).

Definition at line 850 of file kis_layer.cc.

851{
852 return userVisibleBoundsImpl(true);
853}

References userVisibleBoundsImpl().

◆ tryCreateInternallyMergedLayerFromMutipleLayers()

KisLayerSP KisLayer::tryCreateInternallyMergedLayerFromMutipleLayers ( QList< KisLayerSP > layers)
virtual

Try create a layer of this type from multiple layers (of the same type).

The implementation will check if all the layers passed as layer have the same type, verify if they could be merged in a non-rasterizing fasion, merge them and return the layer of the proper type.

Currently only used for merging a set of shape layers into a single shape layer.

Reimplemented in KisShapeLayer.

Definition at line 401 of file kis_layer.cc.

402{
403 Q_UNUSED(layers);
404 return nullptr;
405}

◆ unregisterClone()

void KisLayer::unregisterClone ( KisCloneLayerWSP clone)

Deregisters the clone from the update list

See also
registerClone()

Definition at line 479 of file kis_layer.cc.

480{
481 m_d->clonesList.removeClone(clone);
482}

References KisNode::clone(), and m_d.

◆ updateClones()

void KisLayer::updateClones ( const QRect & rect,
bool dontInvalidateFrames )

It is called by the async merger after projection update is done

Definition at line 494 of file kis_layer.cc.

495{
496 m_d->clonesList.setDirty(rect, dontInvalidateFrames);
497}

References m_d.

◆ updateProjection()

QRect KisLayer::updateProjection ( const QRect & rect,
KisNodeSP filthyNode,
KisRenderPassFlags flags )
protected

Ask the layer to assemble its data & apply all the effect masks to it.

Definition at line 753 of file kis_layer.cc.

754{
755 QRect updatedRect = rect;
756 KisPaintDeviceSP originalDevice = original();
757 if (!rect.isValid() ||
758 (!visible() && !isIsolatedRoot() && !hasClones()) ||
759 !originalDevice) return QRect();
760
761 if (!needProjection() && !hasEffectMasks()) {
762 m_d->safeProjection->releaseDevice();
763 } else {
764
765 if (!updatedRect.isEmpty()) {
766 KisPaintDeviceSP projection = m_d->safeProjection->getDeviceLazy(originalDevice);
767 updatedRect = applyMasks(originalDevice, projection,
768 updatedRect, filthyNode, 0, flags);
769 }
770 }
771
772 return updatedRect;
773}
bool isIsolatedRoot() const
virtual bool visible(bool recursive=false) const
bool hasClones() const
Definition kis_layer.cc:489

References applyMasks(), hasClones(), hasEffectMasks(), KisBaseNode::isIsolatedRoot(), m_d, needProjection(), original(), projection(), and KisBaseNode::visible().

◆ userVisibleBoundsImpl()

QRect KisLayer::userVisibleBoundsImpl ( bool exactBounds) const
private

we do not use incomingChangeRect() here, because exactBounds() already takes it into account (it was used while preparing original())

Definition at line 834 of file kis_layer.cc.

835{
836 QRect changeRect = exactBounds ? this->exactBounds() : this->extent();
837
841
842 bool changeRectVaries;
844 changeRect = masksChangeRect(effectMasks(), changeRect, changeRectVaries);
845
846 return changeRect;
847}
QRect exactBounds() const override
QRect extent() const override

References changeRect(), effectMasks(), exactBounds(), extent(), masksChangeRect(), and outgoingChangeRect().

◆ x()

qint32 KisLayer::x ( ) const
overridevirtual
Returns
the x-offset of this layer in the image plane.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionBasedLayer, and KisShapeLayer.

Definition at line 976 of file kis_layer.cc.

977{
978 KisPaintDeviceSP originalDevice = original();
979 return originalDevice ? originalDevice->x() : 0;
980}

References original(), and KisPaintDevice::x().

◆ y()

qint32 KisLayer::y ( ) const
overridevirtual
Returns
the y-offset of this layer in the image plane.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionBasedLayer, and KisShapeLayer.

Definition at line 981 of file kis_layer.cc.

982{
983 KisPaintDeviceSP originalDevice = original();
984 return originalDevice ? originalDevice->y() : 0;
985}

References original(), and KisPaintDevice::y().

Friends And Related Symbol Documentation

◆ KisLayerMasksCache

friend class KisLayerMasksCache
friend

Definition at line 439 of file kis_layer.h.

◆ KisLayerProjectionPlane

friend class KisLayerProjectionPlane
friend

Definition at line 440 of file kis_layer.h.

◆ KisLayerTest

friend class KisLayerTest
friend

Definition at line 442 of file kis_layer.h.

◆ KisTransformMask

friend class KisTransformMask
friend

Definition at line 441 of file kis_layer.h.

Member Data Documentation

◆ channelFlags

QBitArray & KisLayer::channelFlags

Definition at line 167 of file kis_layer.cc.

◆ clonesList

KisCloneLayersList KisLayer::clonesList

Definition at line 169 of file kis_layer.cc.

◆ layerStyle

KisPSDLayerStyleSP KisLayer::layerStyle

Definition at line 171 of file kis_layer.cc.

◆ layerStyleProjectionPlane

KisLayerStyleProjectionPlaneSP KisLayer::layerStyleProjectionPlane

Definition at line 172 of file kis_layer.cc.

◆ m_d

Private* const KisLayer::m_d
private

Definition at line 450 of file kis_layer.h.

◆ masksCache

KisLayerMasksCache KisLayer::masksCache

Definition at line 177 of file kis_layer.cc.

◆ metaDataStore

KisMetaData::Store* KisLayer::metaDataStore {nullptr}

Definition at line 168 of file kis_layer.cc.

168{nullptr};

◆ projectionPlane

KisAbstractProjectionPlaneSP KisLayer::projectionPlane

Definition at line 174 of file kis_layer.cc.

◆ safeProjection

KisSafeNodeProjectionStoreSP KisLayer::safeProjection

Definition at line 175 of file kis_layer.cc.


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