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

#include <kis_mask.h>

+ Inheritance diagram for KisMask:

Public Member Functions

bool allowAsChild (KisNodeSP node) const override
 
QRect changeRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
const KoColorSpacecolorSpace () const override
 
const KoCompositeOpcompositeOp () const override
 
QImage createThumbnail (qint32 w, qint32 h, Qt::AspectRatioMode aspectRatioMode=Qt::IgnoreAspectRatio) override
 
QRect exactBounds () const override
 
QRect extent () const override
 
void initSelection (KisLayerSP parentLayer)
 initSelection initializes an empty selection
 
void initSelection (KisPaintDeviceSP copyFromDevice, KisLayerSP parentLayer)
 initSelection initializes the selection for the mask from the given paint device.
 
void initSelection (KisSelectionSP copyFrom, KisLayerSP parentLayer)
 initSelection initializes the selection for the mask from the given selection's projection.
 
void initSelectionImpl (KisSelectionSP copyFrom, KisLayerSP parentLayer, KisPaintDeviceSP copyFromDevice, KisImageWSP image)
 
 KisMask (const KisMask &rhs)
 
 KisMask (KisImageWSP image, const QString &name)
 
QRect needRect (const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
 
virtual QRect nonDependentExtent () const
 
KisPaintDeviceSP original () const override
 
KisPaintDeviceSP paintDevice () const override
 
 Private (KisMask *_q)
 
KisPaintDeviceSP projection () const override
 
KisAbstractProjectionPlaneSP projectionPlane () const override
 
void select (const QRect &rc, quint8 selectedness=MAX_SELECTED)
 
KisSelectionSP selection () const
 
void setImage (KisImageWSP image) override
 
void setSelection (KisSelectionSP selection)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool supportsLodPainting () const override
 
void testingInitSelection (const QRect &rect, KisLayerSP parentLayer)
 
int thumbnailSeqNo () const override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisMask () 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
 
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
 
virtual QImage createThumbnailForFrame (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
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
virtual PropertyList sectionModelProperties () const
 
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 setSectionModelProperties (const PropertyList &properties)
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
virtual void setVisible (bool visible, bool loading=false)
 
bool supportsLodMoves () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
virtual bool visible (bool recursive=false) const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 
- Public Member Functions inherited from KisIndirectPaintingSupport
bool hasTemporaryTarget () const
 
 KisIndirectPaintingSupport ()
 
void mergeToLayer (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
 
virtual void mergeToLayerThreaded (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, QVector< KisRunnableStrokeJobData * > *jobs)
 
virtual void setCurrentColor (const KoColor &color)
 
void setTemporaryChannelFlags (const QBitArray &channelFlags)
 
void setTemporaryCompositeOp (const QString &id)
 
void setTemporaryOpacity (qreal o)
 
void setTemporarySelection (KisSelectionSP selection)
 
void setTemporaryTarget (KisPaintDeviceSP t)
 
void setupTemporaryPainter (KisPainter *painter) const
 
virtual bool supportsNonIndirectPainting () const
 
KisPaintDeviceSP temporaryTarget () const
 
FinalMergeSuspenderSP trySuspendFinalMerge ()
 
virtual ~KisIndirectPaintingSupport ()
 

Public Attributes

QScopedPointer< QPoint > deferredSelectionOffset
 
KisCachedPaintDevice paintDeviceCache
 
KisAbstractProjectionPlaneSP projectionPlane
 
KisMaskq
 
KisSafeSelectionNodeProjectionStoreSP safeProjection
 
KisSelectionSP selection
 
- 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}
 
- Public Attributes inherited from KisIndirectPaintingSupport
QBitArray channelFlags
 
QString compositeOp
 
qreal compositeOpacity
 
bool finalMergeInProgress = true
 
QReadWriteLock lock
 
KisSelectionSP selection
 
KisPaintDeviceSP temporaryTarget
 

Protected Member Functions

void apply (KisPaintDeviceSP projection, const QRect &applyRect, const QRect &needRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
void baseNodeChangedCallback () override
 
virtual QRect decorateRect (KisPaintDeviceSP &src, KisPaintDeviceSP &dst, const QRect &rc, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
virtual void flattenSelectionProjection (KisSelectionSP selection, const QRect &dirtyRect) const
 
virtual void mergeInMaskInternal (KisPaintDeviceSP projection, KisSelectionSP effectiveSelection, const QRect &applyRect, const QRect &preparedNeedRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
virtual bool paintsOutsideSelection () const
 
KisKeyframeChannelrequestKeyframeChannel (const QString &id) override
 
bool supportsKeyframeChannel (const QString &id) override
 
- 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 void childNodeChanged (KisNodeSP changedChildNode)
 
virtual KisFrameChangeUpdateRecipe handleKeyframeChannelFrameAboutToBeRemovedImpl (const KisKeyframeChannel *channel, int time)
 
void notifyParentVisibilityChanged (bool value) override
 
KisBaseNodeSP parentCallback () const override
 
- Protected Member Functions inherited from KisBaseNode
void setSupportsLodMoves (bool value)
 
- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 
- Protected Member Functions inherited from KisIndirectPaintingSupport
void lockTemporaryTargetForWrite () const
 
void mergeToLayerImpl (KisPaintDeviceSP dst, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, bool cleanResources, WriteLockerSP sharedWriteLock, QVector< KisRunnableStrokeJobData * > *jobs)
 
void releaseResources ()
 
QString temporaryCompositeOp () const
 
virtual void writeMergeData (KisPainter *painter, KisPaintDeviceSP src, const QRect &rc)
 

Private Attributes

Private *const m_d
 

Friends

class KisMaskProjectionPlane
 

Additional Inherited Members

- Public Types inherited from KisNode
enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 
- Public Types inherited from KisIndirectPaintingSupport
using FinalMergeSuspenderSP = QSharedPointer<FinalMergeSuspender>
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 
- Protected Types inherited from KisIndirectPaintingSupport
using WriteLockerSP = QSharedPointer<WriteLocker>
 

Detailed Description

KisMask is the base class for all single channel mask-like paint devices in Krita. Masks can be rendered in different ways at different moments during the rendering stack. Masks are "owned" by layers (of any type), and cannot occur by themselves on themselves.

The properties that masks implement are made available through the iterators created on their parent layer, or through iterators that can be created on the paint device that holds the mask data: masks are just paint devices, too.

Masks should show up in the layerbox as sub-layers for the layer they are associated with and be cut/copy-able and draggable to other layers.

Examples of masks are:

  • filter masks: like the alpha filter mask that is the most common type of mask and is simply known as "mask" in the gui. Other filter masks use any of krita's filters to filter the pixels of their parent. (In this they differ from adjustment layers, which filter all layers under them in their group stack).
  • selections: the selection mask is rendered after composition and zooming and determines the selectedness of the pixels of the parent layer.
  • painterly overlays: painterly overlays indicate a particular property of the pixel in the parent paint device they are associated with, like wetness, height or gravity.

    XXX: For now, all masks are 8 bit. Make the channel depth settable.

Definition at line 37 of file kis_mask.cc.

Constructor & Destructor Documentation

◆ KisMask() [1/2]

KisMask::KisMask ( KisImageWSP image,
const QString & name )

Create a new KisMask.

Definition at line 64 of file kis_mask.cc.

65 : KisNode(image)
66 , m_d(new Private(this))
67{
69 m_d->safeProjection = new KisSafeSelectionNodeProjectionStore();
70 m_d->safeProjection->setImage(image);
71}
void setName(const QString &name)
KisImageWSP image
QString name() const
Private *const m_d
Definition kis_mask.h:226
KisNode(KisImageWSP image)
Definition kis_node.cpp:167

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

◆ KisMask() [2/2]

KisMask::KisMask ( const KisMask & rhs)

Copy the mask

Definition at line 73 of file kis_mask.cc.

74 : KisNode(rhs)
76 , m_d(new Private(this))
77{
78 setName(rhs.name());
79
80 m_d->safeProjection = new KisSafeSelectionNodeProjectionStore(*rhs.m_d->safeProjection);
81
82 if (rhs.m_d->selection) {
83 m_d->selection = new KisSelection(*rhs.m_d->selection.data());
84 m_d->selection->setParentNode(this);
85
86 KisPixelSelectionSP pixelSelection = m_d->selection->pixelSelection();
87 if (pixelSelection->framesInterface()) {
88 addKeyframeChannel(pixelSelection->keyframeChannel());
90 }
91 }
92}
KisRasterKeyframeChannel * keyframeChannel() const
KisPaintDeviceFramesInterface * framesInterface()
void enableAnimation()
void addKeyframeChannel(KisKeyframeChannel *channel) override
Definition kis_node.cpp:351

References KisNode::addKeyframeChannel(), KisBaseNode::enableAnimation(), KisPaintDevice::framesInterface(), KisPaintDevice::keyframeChannel(), m_d, KisBaseNode::name(), and KisBaseNode::setName().

◆ ~KisMask()

KisMask::~KisMask ( )
override

Definition at line 94 of file kis_mask.cc.

95{
96 if (m_d->selection) {
97 m_d->selection->setParentNode(0);
98 }
99
100 delete m_d;
101}

References m_d.

Member Function Documentation

◆ allowAsChild()

bool KisMask::allowAsChild ( KisNodeSP ) const
overridevirtual

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

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

Implements KisNode.

Definition at line 129 of file kis_mask.cc.

130{
131 Q_UNUSED(node);
132 return false;
133}

◆ apply()

void KisMask::apply ( KisPaintDeviceSP projection,
const QRect & applyRect,
const QRect & needRect,
PositionToFilthy maskPos,
KisRenderPassFlags flags ) const
protected

Apply the effect the projection using the mask as a selection. Made public in KisEffectMask

Definition at line 289 of file kis_mask.cc.

290{
291 if (selection()) {
292
293 flattenSelectionProjection(m_d->selection, applyRect);
294
295 KisSelectionSP effectiveSelection = m_d->selection;
296
297 {
298 // Access temporary target under the lock held
300
301 if (!paintsOutsideSelection()) {
302 // extent of m_d->selection should also be accessed under a lock,
303 // because it might be being merged in by the temporary target atm
304 QRect effectiveExtent = m_d->selection->selectedRect();
305
306 if (hasTemporaryTarget()) {
307 effectiveExtent |= temporaryTarget()->extent();
308 }
309
310 if(!effectiveExtent.intersects(applyRect)) {
311 return;
312 }
313 }
314
315 if (hasTemporaryTarget()) {
316 effectiveSelection = m_d->safeProjection->getDeviceLazy(m_d->selection);
317
318 KisPainter::copyAreaOptimized(applyRect.topLeft(),
319 m_d->selection->pixelSelection(),
320 effectiveSelection->pixelSelection(), applyRect);
321
322 KisPainter gc(effectiveSelection->pixelSelection());
324 gc.bitBlt(applyRect.topLeft(), temporaryTarget(), applyRect);
325 } else {
326 m_d->safeProjection->releaseDevice();
327 }
328
329 mergeInMaskInternal(projection, effectiveSelection, applyRect, needRect, maskPos, flags);
330 }
331
332 } else {
333 mergeInMaskInternal(projection, 0, applyRect, needRect, maskPos, flags);
334 }
335}
QRect extent() const
static void copyAreaOptimized(const QPoint &dstPt, KisPaintDeviceSP src, KisPaintDeviceSP dst, const QRect &originalSrcRect)
void setupTemporaryPainter(KisPainter *painter) const
KisPaintDeviceSP projection() const override
Definition kis_mask.cc:234
virtual bool paintsOutsideSelection() const
Definition kis_mask.cc:284
virtual void flattenSelectionProjection(KisSelectionSP selection, const QRect &dirtyRect) const
Definition kis_mask.cc:361
QRect needRect(const QRect &rect, PositionToFilthy pos=N_FILTHY) const override
Definition kis_mask.cc:366
virtual void mergeInMaskInternal(KisPaintDeviceSP projection, KisSelectionSP effectiveSelection, const QRect &applyRect, const QRect &preparedNeedRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
Definition kis_mask.cc:337
KisSelectionSP selection
Definition kis_mask.cc:44
KisPixelSelectionSP pixelSelection

References KisPainter::bitBlt(), KisPainter::copyAreaOptimized(), KisPaintDevice::extent(), flattenSelectionProjection(), KisIndirectPaintingSupport::hasTemporaryTarget(), m_d, mergeInMaskInternal(), needRect(), paintsOutsideSelection(), KisSelection::pixelSelection, projection(), selection, KisIndirectPaintingSupport::setupTemporaryPainter(), and KisIndirectPaintingSupport::temporaryTarget.

◆ baseNodeChangedCallback()

void KisMask::baseNodeChangedCallback ( )
overrideprotectedvirtual

This callback is called when some meta state of the base node that can be interesting to the UI has changed. E.g. visibility, lockness, opacity, compositeOp and etc. This signal is forwarded by the KisNode and KisNodeGraphListener to the model in KisLayerBox, so it can update its controls when information changes.

Reimplemented from KisBaseNode.

Definition at line 532 of file kis_mask.cc.

533{
534 KisNodeSP up = parent();
535 KisLayer *layer = dynamic_cast<KisLayer*>(up.data());
536 if (layer) {
537 layer->notifyChildMaskChanged();
538 }
540}
QAction * up(const QObject *recvr, const char *slot, QObject *parent)
void notifyChildMaskChanged()
Definition kis_layer.cc:493
void baseNodeChangedCallback() override
Definition kis_node.cpp:329
KisNodeWSP parent
Definition kis_node.cpp:86

References KisNode::baseNodeChangedCallback(), KisLayer::notifyChildMaskChanged(), and KisNode::parent.

◆ changeRect()

QRect KisMask::changeRect ( const QRect & rect,
PositionToFilthy pos = N_FILTHY ) const
overridevirtual
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.

Reimplemented from KisNode.

Reimplemented in KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 386 of file kis_mask.cc.

387{
388 return KisMask::needRect(rect, pos);
389}

References needRect().

◆ colorSpace()

const KoColorSpace * KisMask::colorSpace ( ) const
overridevirtual

Implements KisBaseNode.

Definition at line 135 of file kis_mask.cc.

136{
137 KisNodeSP parentNode = parent();
138 return parentNode ? parentNode->colorSpace() : 0;
139}
virtual const KoColorSpace * colorSpace() const =0

References KisBaseNode::colorSpace(), and KisNode::parent.

◆ compositeOp()

const KoCompositeOp * KisMask::compositeOp ( ) const
overridevirtual

Return the composite op associated with this layer.

FIXME: This function duplicates the same function from KisLayer. 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 141 of file kis_mask.cc.

142{
150 const KoColorSpace *colorSpace = this->colorSpace();
151 if (!colorSpace) return 0;
152
154 return op ? op : colorSpace->compositeOp(COMPOSITE_OVER);
155}
const QString COMPOSITE_OVER
const KoCompositeOp * compositeOp(const QString &id, const KoColorSpace *srcSpace=nullptr) const
const QString & compositeOpId() const
const KoColorSpace * colorSpace() const override
Definition kis_mask.cc:135

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

◆ createThumbnail()

QImage KisMask::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.

Definition at line 472 of file kis_mask.cc.

473{
474 KisPaintDeviceSP originalDevice =
475 selection() ? selection()->projection() : 0;
476
477 return originalDevice ?
478 originalDevice->createThumbnail(w, h, aspectRatioMode, 1,
481}
QImage createThumbnail(qint32 maxw, qint32 maxh, QRect rect, qreal oversample=1, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags())
KisPixelSelectionSP projection() const

References KisPaintDevice::createThumbnail(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KisSelection::projection(), and selection.

◆ decorateRect()

QRect KisMask::decorateRect ( KisPaintDeviceSP & src,
KisPaintDeviceSP & dst,
const QRect & rc,
PositionToFilthy maskPos,
KisRenderPassFlags flags ) const
protectedvirtual

Reimplemented in KisFilterMask, KisTransformMask, KisTransparencyMask, and KisColorizeMask.

Definition at line 270 of file kis_mask.cc.

275{
276 Q_UNUSED(src);
277 Q_UNUSED(dst);
278 Q_UNUSED(maskPos);
279 Q_UNUSED(flags);
280 Q_ASSERT_X(0, "KisMask::decorateRect", "Should be overridden by successors");
281 return rc;
282}

◆ exactBounds()

QRect KisMask::exactBounds ( ) const
overridevirtual

Returns the exact bounds of where the actual data resides in this node.

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 411 of file kis_mask.cc.

412{
413 QRect resultRect;
414
415 if (m_d->selection) {
416 resultRect = m_d->selection->selectedExactRect();
417
418 // copy for thread safety!
420
421 if (temporaryTarget) {
422 resultRect |= temporaryTarget->exactBounds();
423 }
424 } else if (KisNodeSP parent = this->parent()) {
425 resultRect = parent->exactBounds();
426 }
427
428 return resultRect;
429}
QRect exactBounds() const
virtual QRect exactBounds() const

References KisBaseNode::exactBounds(), KisPaintDevice::exactBounds(), m_d, KisNode::parent, and KisIndirectPaintingSupport::temporaryTarget.

◆ extent()

QRect KisMask::extent ( ) const
overridevirtual

The extent and bounds of the mask are those of the selection inside

Reimplemented from KisBaseNode.

Reimplemented in KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 391 of file kis_mask.cc.

392{
393 QRect resultRect;
394
395 if (m_d->selection) {
396 resultRect = m_d->selection->selectedRect();
397
398 // copy for thread safety!
400
401 if (temporaryTarget) {
402 resultRect |= temporaryTarget->extent();
403 }
404 } else if (KisNodeSP parent = this->parent()) {
405 resultRect = parent->extent();
406 }
407
408 return resultRect;
409}
virtual QRect extent() const

References KisBaseNode::extent(), KisPaintDevice::extent(), m_d, KisNode::parent, and KisIndirectPaintingSupport::temporaryTarget.

◆ flattenSelectionProjection()

void KisMask::flattenSelectionProjection ( KisSelectionSP selection,
const QRect & dirtyRect ) const
protectedvirtual

A special callback for calling selection->updateProjection() during the projection calculation process. Some masks (e.g. selection masks) don't need it, because they do it separately.

Reimplemented in KisSelectionMask.

Definition at line 361 of file kis_mask.cc.

362{
363 selection->updateProjection(dirtyRect);
364}
void updateProjection(const QRect &rect)

References selection, and KisSelection::updateProjection().

◆ initSelection() [1/3]

void KisMask::initSelection ( KisLayerSP parentLayer)

initSelection initializes an empty selection

Parameters
parentLayerthe parent of this mask; it determines the default bounds of the mask.

Definition at line 167 of file kis_mask.cc.

168{
169 m_d->initSelectionImpl(0, parentLayer, 0, image());
170}

References KisBaseNode::image, and m_d.

◆ initSelection() [2/3]

void KisMask::initSelection ( KisPaintDeviceSP copyFromDevice,
KisLayerSP parentLayer )

initSelection initializes the selection for the mask from the given paint device.

Parameters
copyFromDevicethe paint device we base the mask on
parentLayerthe parent of this mask; it determines the default bounds of the mask.

Definition at line 162 of file kis_mask.cc.

163{
164 m_d->initSelectionImpl(0, parentLayer, copyFromDevice, image());
165}

References KisBaseNode::image, and m_d.

◆ initSelection() [3/3]

void KisMask::initSelection ( KisSelectionSP copyFrom,
KisLayerSP parentLayer )

initSelection initializes the selection for the mask from the given selection's projection.

Parameters
copyFromthe selection we base the mask on
parentLayerthe parent of this mask; it determines the default bounds of the mask.

Definition at line 157 of file kis_mask.cc.

158{
159 m_d->initSelectionImpl(copyFrom, parentLayer, 0, image());
160}

References KisBaseNode::image, and m_d.

◆ initSelectionImpl()

void KisMask::initSelectionImpl ( KisSelectionSP copyFrom,
KisLayerSP parentLayer,
KisPaintDeviceSP copyFromDevice,
KisImageWSP image )

◆ mergeInMaskInternal()

void KisMask::mergeInMaskInternal ( KisPaintDeviceSP projection,
KisSelectionSP effectiveSelection,
const QRect & applyRect,
const QRect & preparedNeedRect,
KisNode::PositionToFilthy maskPos,
KisRenderPassFlags flags ) const
protectedvirtual

Reimplemented in KisSelectionMask.

Definition at line 337 of file kis_mask.cc.

343{
344 KisCachedPaintDevice::Guard d1(projection, m_d->paintDeviceCache);
345 KisPaintDeviceSP cacheDevice = d1.device();
346
347 if (effectiveSelection) {
348 QRect updatedRect = decorateRect(projection, cacheDevice, applyRect, maskPos, flags);
349
350 // masks don't have any compositing
351 KisPainter::copyAreaOptimized(updatedRect.topLeft(), cacheDevice, projection, updatedRect, effectiveSelection);
352
353 } else {
354 cacheDevice->makeCloneFromRough(projection, preparedNeedRect);
355 projection->clear(preparedNeedRect);
356
357 decorateRect(cacheDevice, projection, applyRect, maskPos, flags);
358 }
359}
virtual void clear()
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)
virtual QRect decorateRect(KisPaintDeviceSP &src, KisPaintDeviceSP &dst, const QRect &rc, PositionToFilthy maskPos, KisRenderPassFlags flags) const
Definition kis_mask.cc:270

References KisPaintDevice::clear(), KisPainter::copyAreaOptimized(), decorateRect(), KisCachedPaintDevice::Guard::device(), m_d, KisPaintDevice::makeCloneFromRough(), and projection().

◆ needRect()

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

Some filters need pixels outside the current processing rect to compute the new value (for instance, convolution filters) See changeRect See accessRect

Reimplemented from KisNode.

Reimplemented in KisSelectionMask, KisTransformMask, and KisTransparencyMask.

Definition at line 366 of file kis_mask.cc.

367{
368 Q_UNUSED(pos);
369 QRect resultRect = rect;
370 if (m_d->selection) {
371 QRect selectionExtent = m_d->selection->selectedRect();
372
373 // copy for thread safety!
375
376 if (temporaryTarget) {
377 selectionExtent |= temporaryTarget->extent();
378 }
379
380 resultRect &= selectionExtent;
381 }
382
383 return resultRect;
384}

References KisPaintDevice::extent(), m_d, and KisIndirectPaintingSupport::temporaryTarget.

◆ nonDependentExtent()

QRect KisMask::nonDependentExtent ( ) const
virtual

Usually masks themselves do not have any paint device and all their final effect on the layer stack is computed using the changeRect() of the dirty rect of the parent layer. Their extent() and exectBounds() methods work the same way: by taking the extent of the parent layer and computing the rect basing on it. But some of the masks like Colorize Mask may have their own "projection", which is painted independently from the changed area of the parent layer. This additional "non-dependent" extent is added to the extent of the parent layer.

Reimplemented in KisColorizeMask.

Definition at line 467 of file kis_mask.cc.

468{
469 return QRect();
470}

◆ original()

KisPaintDeviceSP KisMask::original ( ) const
overridevirtual
Returns
the same as paintDevice()

Implements KisBaseNode.

Definition at line 229 of file kis_mask.cc.

230{
231 return paintDevice();
232}
KisPaintDeviceSP paintDevice() const override
Definition kis_mask.cc:223

References paintDevice().

◆ paintDevice()

KisPaintDeviceSP KisMask::paintDevice ( ) const
overridevirtual
Returns
the selection: if you paint on mask, you paint on the selections

Implements KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 223 of file kis_mask.cc.

224{
226 return selection ? selection->pixelSelection() : 0;
227}

References KisSelection::pixelSelection, and selection.

◆ paintsOutsideSelection()

bool KisMask::paintsOutsideSelection ( ) const
protectedvirtual

Reimplemented in KisSelectionMask, and KisTransparencyMask.

Definition at line 284 of file kis_mask.cc.

285{
286 return false;
287}

◆ Private()

KisMask::Private ( KisMask * _q)
inline

Definition at line 38 of file kis_mask.cc.

39 : q(_q),
41 {
42 }
KisMask * q
Definition kis_mask.cc:46
friend class KisMaskProjectionPlane
Definition kis_mask.h:220
KisAbstractProjectionPlaneSP projectionPlane
Definition kis_mask.cc:58

◆ projection()

KisPaintDeviceSP KisMask::projection ( ) const
overridevirtual
Returns
the same as paintDevice()

Implements KisBaseNode.

Definition at line 234 of file kis_mask.cc.

235{
236 KisPaintDeviceSP originalDevice = original();
237 KisPaintDeviceSP result = originalDevice;
238
240 if (selection && hasTemporaryTarget()) {
241 result = m_d->safeProjection->getDeviceLazy(selection)->pixelSelection();
242 }
243
244 return result;
245}
KisPaintDeviceSP original() const override
Definition kis_mask.cc:229

References KisIndirectPaintingSupport::hasTemporaryTarget(), m_d, original(), and selection.

◆ projectionPlane()

KisAbstractProjectionPlaneSP KisMask::projectionPlane ( ) const
overridevirtual
Returns
a pointer to a KisAbstractProjectionPlane interface of the node. This interface is used by the image merging framework to get information and to blending for the layer.

Please note the difference between need/change/accessRect and the projectionPlane() interface. The former one gives information about internal composition of the layer, and the latter one about the total composition, including layer styles, pass-through blending and etc.

Reimplemented from KisNode.

◆ requestKeyframeChannel()

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

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

Parameters
idchannel to create
Returns
newly created channel or null

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 509 of file kis_mask.cc.

510{
511 if (id == KisKeyframeChannel::Raster.id()) {
512 KisPaintDeviceSP device = paintDevice();
513 if (device) {
515 contentChannel->setFilenameSuffix(".pixelselection");
516 return contentChannel;
517 }
518 }
519
521}
static const KoID Raster
KisRasterKeyframeChannel * createKeyframeChannel(const KoID &id)
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
void setFilenameSuffix(const QString &suffix)
virtual KisKeyframeChannel * requestKeyframeChannel(const QString &id)

References KisPaintDevice::createKeyframeChannel(), paintDevice(), KisKeyframeChannel::Raster, KisBaseNode::requestKeyframeChannel(), and KisRasterKeyframeChannel::setFilenameSuffix().

◆ select()

void KisMask::select ( const QRect & rc,
quint8 selectedness = MAX_SELECTED )

Selected the specified rect with the specified amount of selectedness.

Definition at line 261 of file kis_mask.cc.

262{
265 psel->select(rc, selectedness);
266 sel->updateProjection(rc);
267}
void select(const QRect &r, quint8 selectedness=MAX_SELECTED)

References KisSelection::pixelSelection, KisPixelSelection::select(), selection, and KisSelection::updateProjection().

◆ selection()

KisSelectionSP KisMask::selection ( ) const

Return the selection associated with this mask. A selection can contain both a paint device and shapes.

◆ setImage()

void KisMask::setImage ( KisImageWSP image)
overridevirtual

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 103 of file kis_mask.cc.

104{
105 KisPaintDeviceSP parentPaintDevice = parent() ? parent()->original() : 0;
106 KisDefaultBoundsBaseSP defaultBounds;
107
108 if (parentPaintDevice) {
109 defaultBounds = new KisSelectionDefaultBounds(parentPaintDevice);
110 } else {
111 if (image) {
112 qWarning() << "WARNING: KisMask::setImage() was called without any parent layer being set";
113 }
114
115 // just a fallback solution
116 defaultBounds = new KisDefaultBounds(image);
117 }
118
119 if (m_d->selection) {
120 m_d->selection->setDefaultBounds(defaultBounds);
121 m_d->selection->setResolutionProxy(m_d->selection->resolutionProxy()->createOrCloneDetached(image));
122 }
123
124 m_d->safeProjection->setImage(image);
125
127}
virtual KisPaintDeviceSP original() const =0
void setImage(KisImageWSP newImage) override
Definition kis_node.cpp:254

References KisBaseNode::image, m_d, KisBaseNode::original(), KisNode::parent, and KisNode::setImage().

◆ setSelection()

void KisMask::setSelection ( KisSelectionSP selection)

Change the selection to the specified selection object. The selection is deep copied.

Definition at line 252 of file kis_mask.cc.

253{
254 m_d->selection = selection;
255 m_d->selection->setDefaultBounds(new KisDefaultBounds(image()));
256 m_d->selection->setResolutionProxy(toQShared(new KisImageResolutionProxy(image())));
257 m_d->selection->setParentNode(this);
258 m_d->selection->pixelSelection()->setSupportsWraparoundMode(true);
259}
QSharedPointer< T > toQShared(T *ptr)

References KisBaseNode::image, m_d, selection, and toQShared().

◆ setX()

void KisMask::setX ( qint32 x)
overridevirtual

overridden from KisBaseNode

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 445 of file kis_mask.cc.

446{
447 if (m_d->selection) {
448 m_d->selection->setX(x);
449 } else if (!m_d->deferredSelectionOffset) {
450 m_d->deferredSelectionOffset.reset(new QPoint(x, 0));
451 } else {
452 m_d->deferredSelectionOffset->rx() = x;
453 }
454}
qint32 x() const override
Definition kis_mask.cc:431

References m_d, and x().

◆ setY()

void KisMask::setY ( qint32 y)
overridevirtual

overridden from KisBaseNode

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 456 of file kis_mask.cc.

457{
458 if (m_d->selection) {
459 m_d->selection->setY(y);
460 } else if (!m_d->deferredSelectionOffset) {
461 m_d->deferredSelectionOffset.reset(new QPoint(0, y));
462 } else {
463 m_d->deferredSelectionOffset->ry() = y;
464 }
465}
qint32 y() const override
Definition kis_mask.cc:438

References m_d, and y().

◆ supportsKeyframeChannel()

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

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

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

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 523 of file kis_mask.cc.

524{
525 if (id == KisKeyframeChannel::Raster.id() && paintDevice()) {
526 return true;
527 }
528
530}
virtual bool supportsKeyframeChannel(const QString &id)

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

◆ supportsLodPainting()

bool KisMask::supportsLodPainting ( ) const
overridevirtual

Returns true if the node can be painted via KisPaintDevice. Notable exceptions are selection-based layers and masks.

Reimplemented from KisBaseNode.

Definition at line 504 of file kis_mask.cc.

505{
506 return !m_d->selection || !m_d->selection->hasShapeSelection();
507}

References m_d.

◆ testingInitSelection()

void KisMask::testingInitSelection ( const QRect & rect,
KisLayerSP parentLayer )

Definition at line 490 of file kis_mask.cc.

491{
492 if (parentLayer) {
493 m_d->selection = new KisSelection(new KisSelectionDefaultBounds(parentLayer->paintDevice()), toQShared(new KisImageResolutionProxy(image())));
494 } else {
496 }
497
498 m_d->selection->pixelSelection()->select(rect, OPACITY_OPAQUE_U8);
499 m_d->selection->pixelSelection()->setSupportsWraparoundMode(true);
500 m_d->selection->updateProjection(rect);
501 m_d->selection->setParentNode(this);
502}
const quint8 OPACITY_OPAQUE_U8
virtual KisPaintDeviceSP paintDevice() const =0

References KisBaseNode::image, m_d, OPACITY_OPAQUE_U8, KisBaseNode::paintDevice(), and toQShared().

◆ thumbnailSeqNo()

int KisMask::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.

Definition at line 483 of file kis_mask.cc.

484{
485 KisPaintDeviceSP originalDevice =
486 selection() ? selection()->projection() : 0;
487 return originalDevice ? originalDevice->sequenceNumber() : -1;
488}
int sequenceNumber() const

References KisSelection::projection(), selection, and KisPaintDevice::sequenceNumber().

◆ x()

qint32 KisMask::x ( ) const
overridevirtual

overridden from KisBaseNode

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 431 of file kis_mask.cc.

432{
433 return m_d->selection ? m_d->selection->x() :
434 m_d->deferredSelectionOffset ? m_d->deferredSelectionOffset->x() :
435 parent() ? parent()->x() : 0;
436}
virtual qint32 x() const

References m_d, KisNode::parent, and KisBaseNode::x().

◆ y()

qint32 KisMask::y ( ) const
overridevirtual

overridden from KisBaseNode

Reimplemented from KisBaseNode.

Reimplemented in KisTransformMask.

Definition at line 438 of file kis_mask.cc.

439{
440 return m_d->selection ? m_d->selection->y() :
441 m_d->deferredSelectionOffset ? m_d->deferredSelectionOffset->y() :
442 parent() ? parent()->y() : 0;
443}
virtual qint32 y() const

References m_d, KisNode::parent, and KisBaseNode::y().

Friends And Related Symbol Documentation

◆ KisMaskProjectionPlane

friend class KisMaskProjectionPlane
friend

Definition at line 220 of file kis_mask.h.

Member Data Documentation

◆ deferredSelectionOffset

QScopedPointer<QPoint> KisMask::deferredSelectionOffset

Due to the design of the Kra format the X,Y offset of the paint device belongs to the node, but not to the device itself. So the offset is set when the node is created, but not when the selection is initialized. This causes the X,Y values to be lost, since the selection does not exist at the moment. That is why we save it separately.

Definition at line 56 of file kis_mask.cc.

◆ m_d

Private* const KisMask::m_d
private

Definition at line 226 of file kis_mask.h.

◆ paintDeviceCache

KisCachedPaintDevice KisMask::paintDeviceCache

Definition at line 45 of file kis_mask.cc.

◆ projectionPlane

KisAbstractProjectionPlaneSP KisMask::projectionPlane

Definition at line 58 of file kis_mask.cc.

◆ q

KisMask* KisMask::q

Definition at line 46 of file kis_mask.cc.

◆ safeProjection

KisSafeSelectionNodeProjectionStoreSP KisMask::safeProjection

Definition at line 59 of file kis_mask.cc.

◆ selection

KisSelectionSP KisMask::selection
mutable

Definition at line 44 of file kis_mask.cc.


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