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=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
 
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
 
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
 
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
 
 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)
 
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}
 

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:438
friend class KisLayerProjectionPlane
Definition kis_layer.h:428
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 854 of file kis_layer.cc.

855{
857}
QRect exactBoundsAmortized() const
KisPaintDeviceSP projection() const override
Definition kis_layer.cc:820

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 657 of file kis_layer.cc.

663{
664 Q_ASSERT(source);
665 Q_ASSERT(destination);
666
667 QList<KisEffectMaskSP> masks = effectMasks(lastNode);
668 QRect changeRect;
669 QRect needRect;
670
671 if (masks.isEmpty()) {
672 changeRect = requestedRect;
673 if (source != destination) {
674 copyOriginalToProjection(source, destination, requestedRect);
675 }
676 } else {
677 QStack<QRect> applyRects;
678 bool changeRectVaries;
679 bool needRectVaries;
680
685 changeRectVaries = false;
686 changeRect = requestedRect;
687 //changeRect = masksChangeRect(masks, requestedRect,
688 // changeRectVaries);
689
691 applyRects, needRectVaries);
692
693 if (!changeRectVaries && !needRectVaries) {
700 Q_ASSERT(needRect == requestedRect);
701
702 if (source != destination) {
704 }
705
706 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
707 const QRect maskApplyRect = applyRects.pop();
708 const QRect maskNeedRect =
709 applyRects.isEmpty() ? needRect : applyRects.top();
710
711 PositionToFilthy maskPosition = calculatePositionToFilthy(mask, filthyNode, const_cast<KisLayer*>(this));
712 mask->apply(destination, maskApplyRect, maskNeedRect, maskPosition, flags);
713 }
714 Q_ASSERT(applyRects.isEmpty());
715 } else {
722 KisPaintDeviceSP tempDevice = new KisPaintDevice(colorSpace());
723 tempDevice->prepareClone(source);
725
726 QRect maskApplyRect = applyRects.pop();
727 QRect maskNeedRect = needRect;
728
729 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
730 PositionToFilthy maskPosition = calculatePositionToFilthy(mask, filthyNode, const_cast<KisLayer*>(this));
731 mask->apply(tempDevice, maskApplyRect, maskNeedRect, maskPosition, flags);
732
733 if (!applyRects.isEmpty()) {
734 maskNeedRect = maskApplyRect;
735 maskApplyRect = applyRects.pop();
736 }
737 }
738 Q_ASSERT(applyRects.isEmpty());
739
740 KisPainter::copyAreaOptimized(changeRect.topLeft(), tempDevice, destination, changeRect);
741 }
742 }
743
744 return changeRect;
745}
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:634
QList< KisEffectMaskSP > effectMasks() const
Definition kis_layer.cc:521
QRect changeRect(const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
Definition kis_layer.cc:859
QRect masksNeedRect(const QList< KisEffectMaskSP > &masks, const QRect &changeRect, QStack< QRect > &applyRects, bool &rectVariesFlag) const
Definition kis_layer.cc:610
virtual void copyOriginalToProjection(const KisPaintDeviceSP original, KisPaintDeviceSP projection, const QRect &rect) const
Definition kis_layer.cc:801
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 782 of file kis_layer.cc.

783{
784 QRect changeRect = partialChangeRect(lastNode, rect);
785
786 KisPaintDeviceSP originalDevice = original();
787
789
790 if (!changeRect.isEmpty()) {
791 applyMasks(originalDevice, projection,
793 }
794}
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
bool hasEffectMasks() const
Definition kis_layer.cc:562
QRect partialChangeRect(KisNodeSP lastNode, const QRect &rect)
Definition kis_layer.cc:769
QRect applyMasks(const KisPaintDeviceSP source, KisPaintDeviceSP destination, const QRect &requestedRect, KisNodeSP filthyNode, KisNodeSP lastNode, KisRenderPassFlags flags) const
Definition kis_layer.cc:657
KisPaintDeviceSP original() const override=0
virtual bool needProjection() const
Definition kis_layer.cc:796

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 859 of file kis_layer.cc.

860{
861 QRect changeRect = rect;
863
864 if(pos == KisNode::N_FILTHY) {
865 QRect projectionToBeUpdated = amortizedProjectionRectForCleanupInChangePass() & changeRect;
866
867 bool changeRectVaries;
869 changeRect = masksChangeRect(effectMasks(), changeRect, changeRectVaries);
870
878 if (!projectionToBeUpdated.isEmpty() &&
879 !changeRect.contains(projectionToBeUpdated)) {
880
881 changeRect |= projectionToBeUpdated;
882 }
883 }
884
885 // TODO: string comparison: optimize!
886 if (pos != KisNode::N_FILTHY &&
889
890 changeRect |= rect;
891 }
892
893 return changeRect;
894}
const QString COMPOSITE_COPY
virtual QRect outgoingChangeRect(const QRect &rect) const
Definition kis_layer.cc:908
virtual QRect amortizedProjectionRectForCleanupInChangePass() const
Definition kis_layer.cc:854
QRect masksChangeRect(const QList< KisEffectMaskSP > &masks, const QRect &requestedRect, bool &rectVariesFlag) const
Definition kis_layer.cc:584
virtual QRect incomingChangeRect(const QRect &rect) const
Definition kis_layer.cc:903
@ 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 896 of file kis_layer.cc.

897{
898 if (dynamic_cast<KisMask*>(changedChildNode.data())) {
900 }
901}
void notifyChildMaskChanged()
Definition kis_layer.cc:493

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 567 of file kis_layer.cc.

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

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 801 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 401 of file kis_layer.cc.

402{
403 const bool keepBlendingOptions = canMergeAndKeepBlendOptions(prevLayer);
404
405 KisLayerSP newLayer = new KisPaintLayer(image(), prevLayer->name(), OPACITY_OPAQUE_U8);
406
407 if (keepBlendingOptions) {
408 newLayer->setCompositeOpId(compositeOpId());
409 newLayer->setOpacity(opacity());
410 newLayer->setChannelFlags(channelFlags());
411 }
412
413 return newLayer;
414}
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 = Qt::IgnoreAspectRatio )
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 930 of file kis_layer.cc.

931{
932 if (w == 0 || h == 0) {
933 return QImage();
934 }
935
936 KisPaintDeviceSP originalDevice = original();
937
938 return originalDevice ?
939 originalDevice->createThumbnail(w, h, aspectRatioMode, 1,
942}
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())

References KisPaintDevice::createThumbnail(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), and original().

◆ createThumbnailForFrame()

QImage KisLayer::createThumbnailForFrame ( qint32 w,
qint32 h,
int time,
Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio )
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 950 of file kis_layer.cc.

951{
952 if (w == 0 || h == 0) {
953 return QImage();
954 }
955
956 KisPaintDeviceSP originalDevice = original();
957 if (originalDevice ) {
958 KisRasterKeyframeChannel *channel = originalDevice->keyframeChannel();
959
960 if (channel) {
961 KisPaintDeviceSP targetDevice = new KisPaintDevice(colorSpace());
962 KisRasterKeyframeSP keyframe = channel->activeKeyframeAt<KisRasterKeyframe>(time);
963 keyframe->writeFrameToDevice(targetDevice);
964 return targetDevice->createThumbnail(w, h, aspectRatioMode, 1,
967 }
968 }
969
970 return createThumbnail(w, h);
971}
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=Qt::IgnoreAspectRatio) override
Definition kis_layer.cc:930

References KisKeyframeChannel::activeKeyframeAt(), colorSpace(), KisPaintDevice::createThumbnail(), createThumbnail(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), 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 521 of file kis_layer.cc.

522{
523 return m_d->masksCache.effectMasks();
524}

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 526 of file kis_layer.cc.

527{
528 if (lastNode.isNull()) {
529 return effectMasks();
530 } else {
531 // happens rarely.
532 return searchEffectMasks(lastNode);
533 }
534}
bool isNull() const
QList< KisEffectMaskSP > searchEffectMasks(KisNodeSP lastNode) const
Definition kis_layer.cc:536

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 1030 of file kis_layer.cc.

1031{
1032 return layerExtentImpl(true);
1033}
QRect layerExtentImpl(bool exactBounds) const
Definition kis_layer.cc:996

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 1025 of file kis_layer.cc.

1026{
1027 return layerExtentImpl(false);
1028}

References layerExtentImpl().

◆ fillMergedLayerTemplate()

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

Reimplemented in KisGroupLayer, and KisShapeLayer.

Definition at line 416 of file kis_layer.cc.

417{
418 const bool keepBlendingOptions = canMergeAndKeepBlendOptions(prevLayer);
419
420 QRect layerProjectionExtent = this->projection()->extent();
421 QRect prevLayerProjectionExtent = prevLayer->projection()->extent();
422 bool alphaDisabled = this->alphaChannelDisabled();
423 bool prevAlphaDisabled = prevLayer->alphaChannelDisabled();
424
425 KisPaintDeviceSP mergedDevice = dstLayer->paintDevice();
426
427 if (!keepBlendingOptions) {
428 KisPainter gc(mergedDevice);
429
430 KisImageSP imageSP = image().toStrongRef();
431 if (!imageSP) {
432 return;
433 }
434
435 //Copy the pixels of previous layer with their actual alpha value
436 prevLayer->disableAlphaChannel(false);
437
438 prevLayer->projectionPlane()->apply(&gc, prevLayerProjectionExtent | imageSP->bounds());
439
440 //Restore the previous prevLayer disableAlpha status for correct undo/redo
441 prevLayer->disableAlphaChannel(prevAlphaDisabled);
442
443 if (!skipPaintingThisLayer) {
444 //Paint the pixels of the current layer, using their actual alpha value
445 if (alphaDisabled == prevAlphaDisabled) {
446 this->disableAlphaChannel(false);
447 }
448
449 this->projectionPlane()->apply(&gc, layerProjectionExtent | imageSP->bounds());
450
451 //Restore the layer disableAlpha status for correct undo/redo
452 this->disableAlphaChannel(alphaDisabled);
453 }
454 }
455 else {
456 //Copy prevLayer
457 KisPaintDeviceSP srcDev = prevLayer->projection();
458 mergedDevice->makeCloneFrom(srcDev, srcDev->extent());
459
460 if (!skipPaintingThisLayer) {
461 //Paint layer on the copy
462 KisPainter gc(mergedDevice);
463 gc.bitBlt(layerProjectionExtent.topLeft(), this->projection(), layerProjectionExtent);
464 }
465 }
466}
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 483 of file kis_layer.cc.

484{
485 return m_d->clonesList.hasClones();
486}

References m_d.

◆ hasEffectMasks()

bool KisLayer::hasEffectMasks ( ) const

Returns true if there are any effect masks present

Definition at line 562 of file kis_layer.cc.

563{
564 return !m_d->masksCache.effectMasks().isEmpty();
565}

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 903 of file kis_layer.cc.

904{
905 return rect;
906}

◆ 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 815 of file kis_layer.cc.

816{
817 return m_d->projectionPlane;
818}

References m_d.

◆ layerExtentImpl()

QRect KisLayer::layerExtentImpl ( bool exactBounds) const
private

Definition at line 996 of file kis_layer.cc.

997{
998 QRect additionalMaskExtent = QRect();
1000
1001 Q_FOREACH(KisEffectMaskSP mask, effectMasks) {
1002 additionalMaskExtent |= mask->nonDependentExtent();
1003 }
1004
1005 KisPaintDeviceSP originalDevice = original();
1006 QRect layerExtent;
1007
1008 if (originalDevice) {
1009 layerExtent = needExactBounds ?
1010 originalDevice->exactBounds() :
1011 originalDevice->extent();
1012 }
1013
1014 QRect additionalCompositeOpExtent;
1015 if (compositeOpId() == COMPOSITE_COPY ||
1018
1019 additionalCompositeOpExtent = originalDevice->defaultBounds()->bounds();
1020 }
1021
1022 return layerExtent | additionalMaskExtent | additionalCompositeOpExtent;
1023}
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 849 of file kis_layer.cc.

850{
851 return userVisibleBoundsImpl(false);
852}
QRect userVisibleBoundsImpl(bool exactBounds) const
Definition kis_layer.cc:828

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 584 of file kis_layer.cc.

587{
588 rectVariesFlag = false;
589
590 QRect prevChangeRect = requestedRect;
591
596 QRect changeRect = requestedRect;
597
598 Q_FOREACH (const KisEffectMaskSP& mask, masks) {
599 changeRect = mask->changeRect(prevChangeRect);
600
601 if (changeRect != prevChangeRect)
602 rectVariesFlag = true;
603
604 prevChangeRect = changeRect;
605 }
606
607 return changeRect;
608}

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 610 of file kis_layer.cc.

614{
615 rectVariesFlag = false;
616
617 QRect prevNeedRect = changeRect;
618 QRect needRect;
619
620 for (qint32 i = masks.size() - 1; i >= 0; i--) {
621 applyRects.push(prevNeedRect);
622
623 needRect = masks[i]->needRect(prevNeedRect);
624
625 if (prevNeedRect != needRect)
626 rectVariesFlag = true;
627
628 prevNeedRect = needRect;
629 }
630
631 return needRect;
632}

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

◆ metaData()

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

Definition at line 1040 of file kis_layer.cc.

1041{
1042 return m_d->metaDataStore;
1043}

References m_d.

◆ needProjection()

bool KisLayer::needProjection ( ) const
virtual

Reimplemented in KisCloneLayer, KisPaintLayer, and KisSelectionBasedLayer.

Definition at line 796 of file kis_layer.cc.

797{
798 return false;
799}

◆ 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 913 of file kis_layer.cc.

914{
915 QRect needRect = rect;
916
917 const QList<KisEffectMaskSP> masks = effectMasks();
918
919 if (!masks.isEmpty()) {
920 QStack<QRect> applyRects;
921 bool needRectVaries;
922
923 needRect = masksNeedRect(masks, rect,
924 applyRects, needRectVaries);
925 }
926
927 return needRect;
928}

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

◆ notifyChildMaskChanged()

void KisLayer::notifyChildMaskChanged ( )

Informs this layers that its masks might have changed.

Definition at line 493 of file kis_layer.cc.

494{
495 m_d->masksCache.setDirty();
496}

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 908 of file kis_layer.cc.

909{
910 return rect;
911}

◆ parentLayer()

KisLayerSP KisLayer::parentLayer ( ) const

Get the group layer that contains this layer.

Definition at line 1035 of file kis_layer.cc.

1036{
1037 return qobject_cast<KisLayer*>(parent().data());
1038}

References KisNode::parent.

◆ partialChangeRect()

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

Definition at line 769 of file kis_layer.cc.

770{
771 bool changeRectVaries = false;
774 changeRectVaries);
775
776 return changeRect;
777}

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 820 of file kis_layer.cc.

821{
822 KisPaintDeviceSP originalDevice = original();
823
824 return needProjection() || hasEffectMasks() ?
825 m_d->safeProjection->getDeviceLazy(originalDevice) : originalDevice;
826}

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 468 of file kis_layer.cc.

469{
470 m_d->clonesList.addClone(clone);
471}
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 478 of file kis_layer.cc.

479{
480 return m_d->clonesList.registeredClones();
481}

References m_d.

◆ searchEffectMasks()

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

Definition at line 536 of file kis_layer.cc.

537{
539
541
542 KisProjectionLeafSP child = projectionLeaf()->firstChild();
543 while (child) {
544 if (child->node() == lastNode) break;
545
547 KIS_SAFE_ASSERT_RECOVER_NOOP(child->node());
548
549 if (child->visible()) {
550 KisEffectMaskSP mask = dynamic_cast<KisEffectMask*>(const_cast<KisNode*>(child->node().data()));
551 if (mask) {
552 masks.append(mask);
553 }
554 }
555
556 child = child->nextSibling();
557 }
558
559 return masks;
560}
#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:567

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 503 of file kis_layer.cc.

504{
506
507 if (mask) {
508 return mask->selection();
509 }
510
511 KisImageSP image = this->image();
512 if (image) {
513 return image->globalSelection();
514 }
515 return KisSelectionSP();
516}
KisSelectionSP globalSelection() const
Definition kis_image.cc:695
KisSharedPtr< KisSelection > KisSelectionSP
Definition kis_types.h:149
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:498
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 498 of file kis_layer.cc.

499{
500 return m_d->masksCache.selectionMask();
501}

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 983 of file kis_layer.cc.

984{
985 KisPaintDeviceSP originalDevice = original();
986 if (originalDevice)
987 originalDevice->setX(x);
988}
void setX(qint32 x)
qint32 x() const override
Definition kis_layer.cc:973

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 989 of file kis_layer.cc.

990{
991 KisPaintDeviceSP originalDevice = original();
992 if (originalDevice)
993 originalDevice->setY(y);
994}
void setY(qint32 y)
qint32 y() const override
Definition kis_layer.cc:978

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 944 of file kis_layer.cc.

945{
946 KisPaintDeviceSP originalDevice = original();
947 return originalDevice ? originalDevice->sequenceNumber() : -1;
948}
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 844 of file kis_layer.cc.

845{
846 return userVisibleBoundsImpl(true);
847}

References userVisibleBoundsImpl().

◆ unregisterClone()

void KisLayer::unregisterClone ( KisCloneLayerWSP clone)

Deregisters the clone from the update list

See also
registerClone()

Definition at line 473 of file kis_layer.cc.

474{
475 m_d->clonesList.removeClone(clone);
476}

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 488 of file kis_layer.cc.

489{
490 m_d->clonesList.setDirty(rect, dontInvalidateFrames);
491}

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 747 of file kis_layer.cc.

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

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 828 of file kis_layer.cc.

829{
830 QRect changeRect = exactBounds ? this->exactBounds() : this->extent();
831
835
836 bool changeRectVaries;
838 changeRect = masksChangeRect(effectMasks(), changeRect, changeRectVaries);
839
840 return changeRect;
841}
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 973 of file kis_layer.cc.

974{
975 KisPaintDeviceSP originalDevice = original();
976 return originalDevice ? originalDevice->x() : 0;
977}

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 978 of file kis_layer.cc.

979{
980 KisPaintDeviceSP originalDevice = original();
981 return originalDevice ? originalDevice->y() : 0;
982}

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

Friends And Related Symbol Documentation

◆ KisLayerMasksCache

friend class KisLayerMasksCache
friend

Definition at line 427 of file kis_layer.h.

◆ KisLayerProjectionPlane

friend class KisLayerProjectionPlane
friend

Definition at line 428 of file kis_layer.h.

◆ KisLayerTest

friend class KisLayerTest
friend

Definition at line 430 of file kis_layer.h.

◆ KisTransformMask

friend class KisTransformMask
friend

Definition at line 429 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 438 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: