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

#include <kis_colorize_mask.h>

+ Inheritance diagram for KisColorizeMask:

Classes

struct  KeyStrokeColors
 
struct  Private
 

Signals

void sigKeyStrokesListChanged ()
 
void sigUpdateOnDirtyParent () const
 
- Signals inherited from KisNode
void sigNodeChangedInternal ()
 
- Signals inherited from KisBaseNode
void keyframeChannelAdded (KisKeyframeChannel *channel)
 
void opacityChanged (quint8 value)
 

Public Member Functions

bool accept (KisNodeVisitor &v) override
 
void accept (KisProcessingVisitor &visitor, KisUndoAdapter *undoAdapter) override
 
QVector< KisPaintDeviceSPallPaintDevices () const
 
qreal cleanUpAmount () const
 
KisNodeSP clone () const override
 
KisPaintDeviceSP coloringProjection () const
 
KisPaintDeviceSP colorSampleSourceDevice () const override
 
const KoColorSpacecolorSpace () const override
 
QRect decorateRect (KisPaintDeviceSP &src, KisPaintDeviceSP &dst, const QRect &rc, PositionToFilthy maskPos, KisRenderPassFlags flags) const override
 
qreal edgeDetectionSize () const
 
QRect exactBounds () const override
 
QRect extent () const override
 
QList< KisLazyFillTools::KeyStrokefetchKeyStrokesDirect () const
 
void forceRegenerateMask ()
 
qreal fuzzyRadius () const
 
KisPaintDeviceList getLodCapableDevices () const override
 
QIcon icon () const override
 
void initializeCompositeOp ()
 
KeyStrokeColors keyStrokesColors () const
 
 KisColorizeMask (const KisColorizeMask &rhs)
 
 KisColorizeMask (KisImageWSP image, const QString &name)
 
bool limitToDeviceBounds () const
 
void mergeToLayerThreaded (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, QVector< KisRunnableStrokeJobData * > *jobs) override
 
QRect nonDependentExtent () const override
 
KisPaintDeviceSP paintDevice () const override
 
void regeneratePrefilteredDeviceIfNeeded ()
 
void removeKeyStroke (const KoColor &color)
 
void resetCache ()
 
KisBaseNode::PropertyList sectionModelProperties () const override
 
void setCleanUpAmount (qreal value)
 
KUndo2CommandsetColorSpace (const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent=KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::ConversionFlags conversionFlags=KoColorConversionTransformation::internalConversionFlags(), KoUpdater *progressUpdater=nullptr)
 
void setCurrentColor (const KoColor &color) override
 
void setEdgeDetectionSize (qreal value)
 
void setFuzzyRadius (qreal value)
 
void setImage (KisImageWSP image) override
 
void setKeyStrokesColors (KeyStrokeColors colors)
 
void setKeyStrokesDirect (const QList< KisLazyFillTools::KeyStroke > &strokes)
 
void setLimitToDeviceBounds (bool value)
 
void setProfile (const KoColorProfile *profile, KUndo2Command *parentCommand)
 
void setSectionModelProperties (const KisBaseNode::PropertyList &properties) override
 
void setUseEdgeDetection (bool value)
 
void setX (qint32 x) override
 
void setY (qint32 y) override
 
bool supportsNonIndirectPainting () const override
 
void testingAddKeyStroke (KisPaintDeviceSP dev, const KoColor &color, bool isTransparent=false)
 
KisPaintDeviceSP testingFilteredSource () const
 
bool useEdgeDetection () const
 
void writeMergeData (KisPainter *painter, KisPaintDeviceSP src, const QRect &rc) override
 
qint32 x () const override
 
qint32 y () const override
 
 ~KisColorizeMask () override
 
- Public Member Functions inherited from KisEffectMask
void apply (KisPaintDeviceSP projection, const QRect &applyRect, const QRect &needRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
QIcon icon () const override
 
 KisEffectMask (const KisEffectMask &rhs)
 
 KisEffectMask (KisImageWSP image, const QString &name)
 
 ~KisEffectMask () override
 
- Public Member Functions inherited from KisMask
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
 
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
 
const KisNodefindSymmetricClone (const KisNode *srcRoot, const KisNode *dstRoot, const KisNode *srcTarget)
 
KisNodeSP firstChild () const
 
KisNodeGraphListenergraphListener () const
 
int graphSequenceNumber () const
 
void handleKeyframeChannelFrameAboutToBeRemoved (const KisKeyframeChannel *channel, int time)
 
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
 
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
 
KisImageWSP image () const
 
bool isAnimated () const
 
bool isEditable (bool checkVisibility=true) const
 
virtual bool isFakeNode () const
 
bool isIsolatedRoot () const
 
bool isPinnedToTimeline () const
 
QMap< QString, KisKeyframeChannel * > keyframeChannels () const
 
 KisBaseNode (const KisBaseNode &rhs)
 
 KisBaseNode (KisImageWSP image)
 
void mergeNodeProperties (const KoProperties &properties)
 
QString name () const
 
const KoPropertiesnodeProperties () const
 
quint8 opacity () const
 
quint8 percentOpacity () const
 
 Private (const Private &rhs)
 
 Private (KisImageWSP p_image)
 
void setCollapsed (bool collapsed)
 
void setColorLabelIndex (int index)
 
void setCompositeOpId (const QString &compositeOpId)
 
void setName (const QString &name)
 
void setNodeProperty (const QString &name, const QVariant &value)
 
void setOpacity (quint8 val)
 
void setPercentOpacity (quint8 val)
 
void setPinnedToTimeline (bool pinned)
 
virtual void setUserLocked (bool l)
 
void setUuid (const QUuid &id)
 
virtual void setVisible (bool visible, bool loading=false)
 
bool supportsLodMoves () const
 
virtual void updateSettings ()
 
bool userLocked () const
 
QUuid uuid () const
 
virtual bool visible (bool recursive=false) const
 
 ~KisBaseNode () override
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 
- Public Member Functions inherited from KisIndirectPaintingSupport
bool hasTemporaryTarget () const
 
 KisIndirectPaintingSupport ()
 
void mergeToLayer (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
 
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
 
KisPaintDeviceSP temporaryTarget () const
 
FinalMergeSuspenderSP trySuspendFinalMerge ()
 
virtual ~KisIndirectPaintingSupport ()
 

Private Slots

void slotRecalculatePrefilteredImage ()
 
void slotRegenerationCancelled ()
 
void slotRegenerationFinished (bool prefilterOnly)
 
void slotUpdateOnDirtyParent ()
 
void slotUpdateRegenerateFilling (bool prefilterOnly=false)
 

Private Member Functions

template<class DeviceMetricPolicy >
QRect calculateMaskBounds (DeviceMetricPolicy policy) const
 
void mergeToLayerUnthreaded (KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
 
void moveAllInternalDevices (const QPoint &diff)
 
bool needsUpdate () const
 
void rerenderFakePaintDevice ()
 
void setNeedsUpdate (bool value)
 
void setShowColoring (bool value)
 
void setShowKeyStrokes (bool value)
 
bool showColoring () const
 
bool showKeyStrokes () const
 

Private Attributes

const QScopedPointer< Privatem_d
 

Friends

struct KeyStrokeAddRemoveCommand
 
struct SetKeyStrokeColorsCommand
 
struct SetKeyStrokesColorSpaceCommand
 

Additional Inherited Members

- Public Types inherited from KisNode
enum  PositionToFilthy { N_ABOVE_FILTHY = 0x08 , N_FILTHY_PROJECTION = 0x20 , N_FILTHY = 0x40 , N_BELOW_FILTHY = 0x80 }
 
- Public Types inherited from KisBaseNode
typedef QList< PropertyPropertyList
 
- Public Types inherited from KisIndirectPaintingSupport
using FinalMergeSuspenderSP = QSharedPointer<FinalMergeSuspender>
 
- Public Attributes inherited from KisMask
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 Types inherited from KisIndirectPaintingSupport
using WriteLockerSP = QSharedPointer<WriteLocker>
 
- Protected Member Functions inherited from KisMask
void apply (KisPaintDeviceSP projection, const QRect &applyRect, const QRect &needRect, PositionToFilthy maskPos, KisRenderPassFlags flags) const
 
void baseNodeChangedCallback () override
 
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
 

Detailed Description

Definition at line 26 of file kis_colorize_mask.h.

Constructor & Destructor Documentation

◆ KisColorizeMask() [1/2]

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

Definition at line 138 of file kis_colorize_mask.cpp.

140 , m_d(new Private(this, image))
141{
142 connect(&m_d->updateCompressor,
143 SIGNAL(timeout()),
145
146 connect(this, SIGNAL(sigUpdateOnDirtyParent()),
147 &m_d->dirtyParentUpdateCompressor, SLOT(start()));
148
149 connect(&m_d->dirtyParentUpdateCompressor,
150 SIGNAL(timeout()),
152
153 connect(&m_d->prefilterRecalculationCompressor,
154 SIGNAL(timeout()),
156
157
158 m_d->updateCompressor.moveToThread(qApp->thread());
159}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
const QScopedPointer< Private > m_d
void slotUpdateRegenerateFilling(bool prefilterOnly=false)
void slotRecalculatePrefilteredImage()
void sigUpdateOnDirtyParent() const
KisEffectMask(KisImageWSP image, const QString &name)
KisImageWSP image
QString name() const

References connect(), m_d, sigUpdateOnDirtyParent(), slotRecalculatePrefilteredImage(), slotUpdateOnDirtyParent(), and slotUpdateRegenerateFilling().

◆ ~KisColorizeMask()

KisColorizeMask::~KisColorizeMask ( )
override

Definition at line 161 of file kis_colorize_mask.cpp.

162{
163}

◆ KisColorizeMask() [2/2]

KisColorizeMask::KisColorizeMask ( const KisColorizeMask & rhs)

Definition at line 165 of file kis_colorize_mask.cpp.

166 : KisEffectMask(rhs),
167 m_d(new Private(*rhs.m_d, this))
168{
169 connect(&m_d->updateCompressor,
170 SIGNAL(timeout()),
172
173 connect(this, SIGNAL(sigUpdateOnDirtyParent()),
174 &m_d->dirtyParentUpdateCompressor, SLOT(start()));
175
176 connect(&m_d->dirtyParentUpdateCompressor,
177 SIGNAL(timeout()),
179
180 m_d->updateCompressor.moveToThread(qApp->thread());
181}

References connect(), m_d, sigUpdateOnDirtyParent(), slotUpdateOnDirtyParent(), and slotUpdateRegenerateFilling().

Member Function Documentation

◆ accept() [1/2]

bool KisColorizeMask::accept ( KisNodeVisitor & )
overridevirtual

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

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

Reimplemented from KisBaseNode.

Definition at line 487 of file kis_colorize_mask.cpp.

488{
489 return v.visit(this);
490}
qreal v

References v.

◆ accept() [2/2]

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

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

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

Reimplemented from KisBaseNode.

Definition at line 492 of file kis_colorize_mask.cpp.

493{
494 return visitor.visit(this, undoAdapter);
495}
virtual void visit(KisNode *node, KisUndoAdapter *undoAdapter)=0

References KisProcessingVisitor::visit().

◆ allPaintDevices()

QVector< KisPaintDeviceSP > KisColorizeMask::allPaintDevices ( ) const

Definition at line 979 of file kis_colorize_mask.cpp.

980{
982
983 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
984 devices << stroke.dev;
985 }
986
987 devices << m_d->coloringProjection;
988 devices << m_d->fakePaintDevice;
989
990 return devices;
991}

References KisLazyFillTools::KeyStroke::dev, and m_d.

◆ calculateMaskBounds()

template<class DeviceMetricPolicy >
QRect KisColorizeMask::calculateMaskBounds ( DeviceMetricPolicy policy) const
private

Definition at line 619 of file kis_colorize_mask.cpp.

620{
621 QRect rc;
622
623 if (m_d->shouldShowFilteredSource()) {
624 rc |= boundsPolicy(m_d->filteredSource);
625 }
626
627 if (m_d->shouldShowColoring()) {
628 rc |= boundsPolicy(m_d->coloringProjection);
629 }
630
631 if (m_d->showKeyStrokes) {
632 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
633 rc |= boundsPolicy(stroke.dev);
634 }
635
637
639 if (temporaryTarget) {
640 rc |= boundsPolicy(temporaryTarget);
641 }
642 }
643
644 return rc;
645}

References KisLazyFillTools::KeyStroke::dev, m_d, and KisIndirectPaintingSupport::temporaryTarget.

◆ cleanUpAmount()

qreal KisColorizeMask::cleanUpAmount ( ) const

Definition at line 1045 of file kis_colorize_mask.cpp.

1046{
1047 return m_d->filteringOptions.cleanUpAmount;
1048}

References m_d.

◆ clone()

KisNodeSP KisColorizeMask::clone ( ) const
inlineoverridevirtual

Implements KisNode.

Definition at line 57 of file kis_colorize_mask.h.

57 {
58 return KisNodeSP(new KisColorizeMask(*this));
59 }
KisColorizeMask(KisImageWSP image, const QString &name)
KisSharedPtr< KisNode > KisNodeSP
Definition kis_types.h:86

◆ coloringProjection()

KisPaintDeviceSP KisColorizeMask::coloringProjection ( ) const

Definition at line 469 of file kis_colorize_mask.cpp.

470{
471 return m_d->coloringProjection;
472}

References m_d.

◆ colorSampleSourceDevice()

KisPaintDeviceSP KisColorizeMask::colorSampleSourceDevice ( ) const
overridevirtual
Returns
a special device from where the color sampler tool should sample color when in layer-only mode. For most of the nodes just shortcuts to projection() device. TODO: can it be null?

Reimplemented from KisBaseNode.

Definition at line 474 of file kis_colorize_mask.cpp.

475{
476 return
477 m_d->shouldShowColoring() && !m_d->coloringProjection->extent().isEmpty() ?
478 m_d->coloringProjection : projection();
479}
KisPaintDeviceSP projection() const override
Definition kis_mask.cc:234

References KisPaintDevice::extent(), m_d, and KisMask::projection().

◆ colorSpace()

const KoColorSpace * KisColorizeMask::colorSpace ( ) const
overridevirtual

Implements KisBaseNode.

Definition at line 200 of file kis_colorize_mask.cpp.

201{
202 return m_d->fakePaintDevice->colorSpace();
203}

References m_d.

◆ decorateRect()

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

Reimplemented from KisMask.

Definition at line 513 of file kis_colorize_mask.cpp.

518{
519 Q_UNUSED(maskPos);
520 Q_UNUSED(flags);
521
522 if (maskPos == N_ABOVE_FILTHY) {
523 // the source layer has changed, we should update the filtered cache!
524
525 if (!m_d->filteringDirty) {
526 Q_EMIT sigUpdateOnDirtyParent();
527 }
528 }
529
530 KIS_ASSERT(dst != src);
531
532 // Draw the filling and the original layer
533 {
534 KisPainter gc(dst);
535
536 if (m_d->shouldShowFilteredSource()) {
537 const QRect drawRect = m_d->limitToDeviceBounds ? rect & m_d->filteredDeviceBounds : rect;
538
539 gc.setOpacityF(0.5);
540 gc.bitBlt(drawRect.topLeft(), m_d->filteredSource, drawRect);
541 } else {
542 gc.setOpacityToUnit();
543 gc.bitBlt(rect.topLeft(), src, rect);
544 }
545
546 if (m_d->shouldShowColoring()) {
547
548 gc.setOpacityU8(opacity());
549 gc.setCompositeOpId(compositeOpId());
550 gc.bitBlt(rect.topLeft(), m_d->coloringProjection, rect);
551 }
552 }
553
554 // Draw the key strokes
555 if (m_d->showKeyStrokes) {
557
558 KisCachedSelection::Guard s1(m_d->cachedSelection);
559 KisCachedSelection::Guard s2(m_d->cachedSelection);
560
561 KisSelectionSP selection = s1.selection();
562 KisPixelSelectionSP tempSelection = s2.selection()->pixelSelection();
563
565 const bool isTemporaryTargetErasing = temporaryCompositeOp() == COMPOSITE_ERASE;
566 const QRect temporaryExtent = temporaryTarget ? temporaryTarget->extent() : QRect();
567
568
569 KisFillPainter gc(dst);
570
571 QList<KeyStroke> extendedStrokes = m_d->keyStrokes;
572
573 if (m_d->currentKeyStrokeDevice &&
574 m_d->needAddCurrentKeyStroke &&
575 !isTemporaryTargetErasing) {
576
577 extendedStrokes << KeyStroke(m_d->currentKeyStrokeDevice, m_d->currentColor);
578 }
579
580 Q_FOREACH (const KeyStroke &stroke, extendedStrokes) {
582 gc.setSelection(selection);
583
584 if (stroke.color == m_d->currentColor ||
585 (isTemporaryTargetErasing &&
586 temporaryExtent.intersects(selection->pixelSelection()->selectedRect()))) {
587
588 if (temporaryTarget) {
589 tempSelection->copyAlphaFrom(temporaryTarget, rect);
590
591 KisPainter selectionPainter(selection->pixelSelection());
592 setupTemporaryPainter(&selectionPainter);
593 selectionPainter.bitBlt(rect.topLeft(), tempSelection, rect);
594 }
595 }
596
597 gc.fillSelection(rect, stroke.color);
598 }
599 }
600
601 return rect;
602}
QPointF s1
QPointF s2
const QString COMPOSITE_ERASE
void makeCloneFromRough(KisPaintDeviceSP src, const QRect &minimalRect)
QRect extent() const
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
const QString & compositeOpId() const
quint8 opacity() const
void setupTemporaryPainter(KisPainter *painter) const
KisSelectionSP selection
Definition kis_mask.cc:44
@ N_ABOVE_FILTHY
Definition kis_node.h:59
void copyAlphaFrom(KisPaintDeviceSP src, const QRect &processRect)
KisPixelSelectionSP pixelSelection

References KisPainter::bitBlt(), KisLazyFillTools::KeyStroke::color, COMPOSITE_ERASE, KisBaseNode::compositeOpId(), KisPixelSelection::copyAlphaFrom(), KisLazyFillTools::KeyStroke::dev, KisPaintDevice::extent(), KisFillPainter::fillSelection(), KIS_ASSERT, m_d, KisPaintDevice::makeCloneFromRough(), KisNode::N_ABOVE_FILTHY, KisBaseNode::opacity(), KisSelection::pixelSelection, s1, s2, KisPixelSelection::selectedRect(), KisMask::selection, KisPainter::setCompositeOpId(), KisPainter::setOpacityF(), KisPainter::setOpacityToUnit(), KisPainter::setOpacityU8(), KisPainter::setSelection(), KisIndirectPaintingSupport::setupTemporaryPainter(), sigUpdateOnDirtyParent(), KisIndirectPaintingSupport::temporaryCompositeOp(), and KisIndirectPaintingSupport::temporaryTarget.

◆ edgeDetectionSize()

qreal KisColorizeMask::edgeDetectionSize ( ) const

Definition at line 1022 of file kis_colorize_mask.cpp.

1023{
1024 return m_d->filteringOptions.edgeDetectionSize;
1025}

References m_d.

◆ exactBounds()

QRect KisColorizeMask::exactBounds ( ) const
overridevirtual

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

Reimplemented from KisBaseNode.

Definition at line 653 of file kis_colorize_mask.cpp.

654{
656}
QRect calculateMaskBounds(DeviceMetricPolicy policy) const

References calculateMaskBounds().

◆ extent()

QRect KisColorizeMask::extent ( ) const
overridevirtual

Returns an approximation of where the bounds on actual data are in this node.

Reimplemented from KisBaseNode.

Definition at line 648 of file kis_colorize_mask.cpp.

References calculateMaskBounds().

◆ fetchKeyStrokesDirect()

QList< KeyStroke > KisColorizeMask::fetchKeyStrokesDirect ( ) const

Definition at line 1095 of file kis_colorize_mask.cpp.

1096{
1097 return m_d->keyStrokes;
1098}

References m_d.

◆ forceRegenerateMask()

void KisColorizeMask::forceRegenerateMask ( )

Definition at line 1084 of file kis_colorize_mask.cpp.

1085{
1087 m_d->updateIsRunning = false;
1088}

References m_d, and slotUpdateRegenerateFilling().

◆ fuzzyRadius()

qreal KisColorizeMask::fuzzyRadius ( ) const

Definition at line 1034 of file kis_colorize_mask.cpp.

1035{
1036 return m_d->filteringOptions.fuzzyRadius;
1037}

References m_d.

◆ getLodCapableDevices()

KisPaintDeviceList KisColorizeMask::getLodCapableDevices ( ) const
overridevirtual

Reimplemented from KisNode.

Definition at line 1136 of file kis_colorize_mask.cpp.

1137{
1138 KisPaintDeviceList list;
1139
1140 auto it = m_d->keyStrokes.begin();
1141 for(; it != m_d->keyStrokes.end(); ++it) {
1142 list << it->dev;
1143 }
1144
1145 list << m_d->coloringProjection;
1146 list << m_d->fakePaintDevice;
1147 list << m_d->filteredSource;
1148
1149 return list;
1150}

References m_d.

◆ icon()

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

Reimplemented from KisBaseNode.

Definition at line 481 of file kis_colorize_mask.cpp.

482{
483 return KisIconUtils::loadIcon("colorizeMask");
484}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ initializeCompositeOp()

void KisColorizeMask::initializeCompositeOp ( )

Definition at line 183 of file kis_colorize_mask.cpp.

184{
185 KisLayerSP parentLayer(qobject_cast<KisLayer*>(parent().data()));
186 if (!parentLayer || !parentLayer->original()) return;
187
188 KisImageSP image = parentLayer->image();
189 if (!image) return;
190
191 const qreal samplePortion = 0.1;
192 const qreal alphaPortion =
194 image->bounds(),
195 samplePortion);
196
197 setCompositeOpId(alphaPortion > 0.3 ? COMPOSITE_BEHIND : COMPOSITE_MULT);
198}
const QString COMPOSITE_MULT
const QString COMPOSITE_BEHIND
QRect bounds() const override
qreal estimatePortionOfTransparentPixels(KisPaintDeviceSP dev, const QRect &rect, qreal samplePortion)
void setCompositeOpId(const QString &compositeOpId)
KisNodeWSP parent
Definition kis_node.cpp:86

References KisImage::bounds(), COMPOSITE_BEHIND, COMPOSITE_MULT, KritaUtils::estimatePortionOfTransparentPixels(), KisBaseNode::image, KisLayer::original(), KisNode::parent, and KisBaseNode::setCompositeOpId().

◆ keyStrokesColors()

KisColorizeMask::KeyStrokeColors KisColorizeMask::keyStrokesColors ( ) const

Definition at line 884 of file kis_colorize_mask.cpp.

885{
886 KeyStrokeColors colors;
887
888 // TODO: thread safety!
889 for (int i = 0; i < m_d->keyStrokes.size(); i++) {
890 colors.colors << m_d->keyStrokes[i].color;
891
892 if (m_d->keyStrokes[i].isTransparent) {
893 colors.transparentIndex = i;
894 }
895 }
896
897 return colors;
898}

References KisColorizeMask::KeyStrokeColors::colors, m_d, and KisColorizeMask::KeyStrokeColors::transparentIndex.

◆ limitToDeviceBounds()

bool KisColorizeMask::limitToDeviceBounds ( ) const

Definition at line 1057 of file kis_colorize_mask.cpp.

1058{
1059 return m_d->limitToDeviceBounds;
1060}

References m_d.

◆ mergeToLayerThreaded()

void KisColorizeMask::mergeToLayerThreaded ( KisNodeSP layer,
KUndo2Command * parentCommand,
const KUndo2MagicString & transactionText,
int timedID,
QVector< KisRunnableStrokeJobData * > * jobs )
overridevirtual

Reimplemented from KisIndirectPaintingSupport.

Definition at line 736 of file kis_colorize_mask.cpp.

737{
738 // Just fake threaded merging. It is not supported for the colorize mask.
739
741 [=] () {
742 this->mergeToLayerUnthreaded(layer, parentCommand, transactionText, timedID);
743 }
744 );
745}
void mergeToLayerUnthreaded(KisNodeSP layer, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID)
void addJobSequential(QVector< Job * > &jobs, Func func)

References KritaUtils::addJobSequential(), and mergeToLayerUnthreaded().

◆ mergeToLayerUnthreaded()

void KisColorizeMask::mergeToLayerUnthreaded ( KisNodeSP layer,
KUndo2Command * parentCommand,
const KUndo2MagicString & transactionText,
int timedID )
private

Add a new key stroke plane

When erasing, the brush affects all the key strokes, not only the current one.

When merging, we use barrier jobs only for ensuring that the merge jobs are not split by the update jobs. Merge jobs hold the shared lock, so forcing them out of CPU will basically cause a deadlock. When running in the fake executor, the jobs cannot be split anyway, so there is no danger in that.

Try removing the key strokes that has been completely erased

Definition at line 747 of file kis_colorize_mask.cpp.

748{
749 Q_UNUSED(layer);
750
751 auto executeAndAdd = [parentCommand] (KUndo2Command *cmd) {
752 cmd->redo();
753 new KisCommandUtils::SkipFirstRedoWrapper(cmd, parentCommand);
754 };
755
756 WriteLockerSP sharedWriteLock(new WriteLocker(this));
757
759 const bool isTemporaryTargetErasing = temporaryCompositeOp() == COMPOSITE_ERASE;
760 const QRect temporaryExtent = temporaryTarget ? temporaryTarget->extent() : QRect();
761
765 if (m_d->needAddCurrentKeyStroke && !isTemporaryTargetErasing) {
766 KeyStroke key(m_d->currentKeyStrokeDevice, m_d->currentColor);
767 executeAndAdd(new KeyStrokeAddRemoveCommand(
768 true, m_d->keyStrokes.size(), key, &m_d->keyStrokes, KisColorizeMaskSP(this), nullptr));
769 }
770
772
777 if (!isTemporaryTargetErasing) {
778 mergeToLayerImpl(m_d->currentKeyStrokeDevice, parentCommand, transactionText, timedID, false, sharedWriteLock, &jobs);
779 } else {
780 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
781 if (temporaryExtent.intersects(stroke.dev->extent())) {
782 mergeToLayerImpl(stroke.dev, parentCommand, transactionText, timedID, false, sharedWriteLock, &jobs);
783 }
784 }
785 }
786
787 mergeToLayerImpl(m_d->fakePaintDevice, parentCommand, transactionText, timedID, false, sharedWriteLock, &jobs);
788
797 fakeExecutor.addRunnableJobs(implicitCastList<KisRunnableStrokeJobDataBase*>(jobs));
798
799 m_d->currentKeyStrokeDevice = 0;
800 m_d->currentColor = KoColor();
802
806 if (isTemporaryTargetErasing) {
807 for (int index = 0; index < m_d->keyStrokes.size(); /*noop*/) {
808 const KeyStroke &stroke = m_d->keyStrokes[index];
809
810 if (stroke.dev->exactBounds().isEmpty()) {
811 executeAndAdd(new KeyStrokeAddRemoveCommand(
812 false, index, stroke, &m_d->keyStrokes, KisColorizeMaskSP(this), nullptr));
813 } else {
814 index++;
815 }
816 }
817 }
818}
friend struct KeyStrokeAddRemoveCommand
QRect exactBounds() const
QSharedPointer< WriteLocker > WriteLockerSP
void mergeToLayerImpl(KisPaintDeviceSP dst, KUndo2Command *parentCommand, const KUndo2MagicString &transactionText, int timedID, bool cleanResources, WriteLockerSP sharedWriteLock, QVector< KisRunnableStrokeJobData * > *jobs)
int index(const KisNodeSP node) const
Definition kis_node.cpp:432

References KisFakeRunnableStrokeJobsExecutor::addRunnableJobs(), KisFakeRunnableStrokeJobsExecutor::AllowBarrierJobs, COMPOSITE_ERASE, KisLazyFillTools::KeyStroke::dev, KisPaintDevice::exactBounds(), KisPaintDevice::extent(), KisNode::index(), KeyStrokeAddRemoveCommand, m_d, KisIndirectPaintingSupport::mergeToLayerImpl(), KisIndirectPaintingSupport::releaseResources(), KisIndirectPaintingSupport::temporaryCompositeOp(), and KisIndirectPaintingSupport::temporaryTarget.

◆ moveAllInternalDevices()

void KisColorizeMask::moveAllInternalDevices ( const QPoint & diff)
private

Definition at line 1165 of file kis_colorize_mask.cpp.

1166{
1168
1169 Q_FOREACH (KisPaintDeviceSP dev, devices) {
1170 dev->moveTo(dev->offset() + diff);
1171 }
1172}
QVector< KisPaintDeviceSP > allPaintDevices() const
void moveTo(qint32 x, qint32 y)
QPoint offset() const

References allPaintDevices(), KisPaintDevice::moveTo(), and KisPaintDevice::offset().

◆ needsUpdate()

bool KisColorizeMask::needsUpdate ( ) const
private

Definition at line 292 of file kis_colorize_mask.cpp.

293{
294 return m_d->needsUpdate;
295}

References m_d.

◆ nonDependentExtent()

QRect KisColorizeMask::nonDependentExtent ( ) const
overridevirtual

Colorize mask has its own "projection", so it should report it to the parent layer using non-dependent-extent property

Reimplemented from KisMask.

Definition at line 658 of file kis_colorize_mask.cpp.

659{
660 return extent();
661}
QRect extent() const override

References extent().

◆ paintDevice()

KisPaintDeviceSP KisColorizeMask::paintDevice ( ) const
overridevirtual

Return the paintdevice you can use to change pixels on. For a paint layer these will be paint pixels, for an adjustment layer or a mask the selection paint device.

Returns
the paint device to paint on. Can be 0 if the actual node type does not support painting.

Implements KisBaseNode.

Definition at line 464 of file kis_colorize_mask.cpp.

465{
466 return m_d->showKeyStrokes && !m_d->updateIsRunning ? m_d->fakePaintDevice : KisPaintDeviceSP();
467}
KisSharedPtr< KisPaintDevice > KisPaintDeviceSP
Definition kis_types.h:73

References m_d.

◆ regeneratePrefilteredDeviceIfNeeded()

void KisColorizeMask::regeneratePrefilteredDeviceIfNeeded ( )

Definition at line 1152 of file kis_colorize_mask.cpp.

1153{
1154 if (!parent()) return;
1155
1158
1159 if (!m_d->filteredSourceValid(src)) {
1160 // update the prefiltered source if needed
1162 }
1163}
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75
virtual KisPaintDeviceSP original() const =0

References KIS_ASSERT_RECOVER_RETURN, m_d, KisBaseNode::original(), KisNode::parent, and slotUpdateRegenerateFilling().

◆ removeKeyStroke()

void KisColorizeMask::removeKeyStroke ( const KoColor & color)

Definition at line 953 of file kis_colorize_mask.cpp.

954{
955 KoColor color = _color;
956 color.convertTo(colorSpace());
957
959 std::find_if(m_d->keyStrokes.begin(),
960 m_d->keyStrokes.end(),
962
963 KIS_SAFE_ASSERT_RECOVER_RETURN(it != m_d->keyStrokes.end());
964
965 const int index = it - m_d->keyStrokes.begin();
966
967 KisProcessingApplicator applicator(image(), KisNodeSP(this),
970 kundo2_i18n("Remove Key Stroke"));
971 applicator.applyCommand(
973 false, index, *it, &m_d->keyStrokes, KisColorizeMaskSP(this)));
974
975 applicator.end();
976}
QVector< KisImageSignalType > KisImageSignalVector
const KoColorSpace * colorSpace() const override
void convertTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
Definition KoColor.cpp:136
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KUndo2MagicString kundo2_i18n(const char *text)
auto mem_equal_to(MemTypeNoRef Class::*ptr, MemType &&value)
mem_equal_to is an unary functor that compares a member of the object to a given value
Definition KisMpl.h:233

References KisProcessingApplicator::applyCommand(), KisLazyFillTools::KeyStroke::color, colorSpace(), KoColor::convertTo(), KisProcessingApplicator::end(), KisBaseNode::image, KisNode::index(), KeyStrokeAddRemoveCommand, KIS_SAFE_ASSERT_RECOVER_RETURN, kundo2_i18n(), m_d, kismpl::mem_equal_to(), and KisProcessingApplicator::NONE.

◆ rerenderFakePaintDevice()

void KisColorizeMask::rerenderFakePaintDevice ( )
private

Definition at line 1062 of file kis_colorize_mask.cpp.

1063{
1064 m_d->fakePaintDevice->clear();
1065 KisFillPainter gc(m_d->fakePaintDevice);
1066
1067 KisCachedSelection::Guard s1(m_d->cachedSelection);
1068 KisSelectionSP selection = s1.selection();
1069
1070 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
1071 const QRect rect = stroke.dev->extent();
1072
1074 gc.setSelection(selection);
1075 gc.fillSelection(rect, stroke.color);
1076 }
1077}

References KisLazyFillTools::KeyStroke::color, KisLazyFillTools::KeyStroke::dev, KisPaintDevice::extent(), KisFillPainter::fillSelection(), m_d, KisPaintDevice::makeCloneFromRough(), KisSelection::pixelSelection, s1, KisMask::selection, and KisPainter::setSelection().

◆ resetCache()

void KisColorizeMask::resetCache ( )

Definition at line 993 of file kis_colorize_mask.cpp.

994{
995 m_d->filteredSource->clear();
996 m_d->originalSequenceNumber = -1;
997 m_d->filteringDirty = true;
998
1001}

References m_d, rerenderFakePaintDevice(), and slotUpdateRegenerateFilling().

◆ sectionModelProperties()

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

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

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

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

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

Reimplemented from KisBaseNode.

Definition at line 431 of file kis_colorize_mask.cpp.

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisLayerPropertiesIcons::colorizeNeedsUpdate, KisLayerPropertiesIcons::colorizeShowColoring, KisLayerPropertiesIcons::getProperty(), needsUpdate(), KisBaseNode::sectionModelProperties(), showColoring(), and showKeyStrokes().

◆ setCleanUpAmount()

void KisColorizeMask::setCleanUpAmount ( qreal value)

Definition at line 1039 of file kis_colorize_mask.cpp.

1040{
1041 m_d->filteringOptions.cleanUpAmount = value;
1042 setNeedsUpdate(true);
1043}
float value(const T *src, size_t ch)
void setNeedsUpdate(bool value)

References m_d, setNeedsUpdate(), and value().

◆ setColorSpace()

KUndo2Command * KisColorizeMask::setColorSpace ( const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent = KoColorConversionTransformation::internalRenderingIntent(),
KoColorConversionTransformation::ConversionFlags conversionFlags = KoColorConversionTransformation::internalConversionFlags(),
KoUpdater * progressUpdater = nullptr )

Definition at line 269 of file kis_colorize_mask.cpp.

273{
274 using namespace KisCommandUtils;
275
276 CompositeCommand *composite = new CompositeCommand();
277
278 m_d->fakePaintDevice->convertTo(dstColorSpace, renderingIntent, conversionFlags, composite, progressUpdater);
279 m_d->coloringProjection->convertTo(dstColorSpace, renderingIntent, conversionFlags, composite, progressUpdater);
280
281 KUndo2Command *strokesConversionCommand =
283 dstColorSpace, renderingIntent, conversionFlags,
284 &m_d->keyStrokes, KisColorizeMaskSP(this));
285 strokesConversionCommand->redo();
286
287 composite->addCommand(new SkipFirstRedoWrapper(strokesConversionCommand));
288
289 return composite;
290}
virtual void redo()
friend struct SetKeyStrokesColorSpaceCommand

References KisCommandUtils::CompositeCommand::addCommand(), m_d, KUndo2Command::redo(), and SetKeyStrokesColorSpaceCommand.

◆ setCurrentColor()

void KisColorizeMask::setCurrentColor ( const KoColor & color)
overridevirtual

Reimplemented from KisIndirectPaintingSupport.

Definition at line 677 of file kis_colorize_mask.cpp.

678{
679 KoColor color = _color;
680 color.convertTo(colorSpace());
681
682 WriteLocker locker(this);
683
684 m_d->setNeedsUpdateImpl(true, false);
685
687 std::find_if(m_d->keyStrokes.constBegin(),
688 m_d->keyStrokes.constEnd(),
690
691 KisPaintDeviceSP activeDevice;
692 bool newKeyStroke = false;
693
694 if (it == m_d->keyStrokes.constEnd()) {
695 activeDevice = new KisPaintDevice(KoColorSpaceRegistry::instance()->alpha8());
696 activeDevice->setParentNode(this);
698 newKeyStroke = true;
699 } else {
700 activeDevice = it->dev;
701 }
702
703 m_d->currentColor = color;
704 m_d->currentKeyStrokeDevice = activeDevice;
705 m_d->needAddCurrentKeyStroke = newKeyStroke;
706}
void setDefaultBounds(KisDefaultBoundsBaseSP bounds)
void setParentNode(KisNodeWSP parent)
KisSharedPtr< KisDefaultBoundsBase > KisDefaultBoundsBaseSP
static KoColorSpaceRegistry * instance()

References KisLazyFillTools::KeyStroke::color, colorSpace(), KoColor::convertTo(), KisBaseNode::image, KoColorSpaceRegistry::instance(), m_d, kismpl::mem_equal_to(), KisPaintDevice::setDefaultBounds(), and KisPaintDevice::setParentNode().

◆ setEdgeDetectionSize()

void KisColorizeMask::setEdgeDetectionSize ( qreal value)

Definition at line 1015 of file kis_colorize_mask.cpp.

1016{
1017 m_d->filteringOptions.edgeDetectionSize = value;
1018 m_d->filteringDirty = true;
1019 setNeedsUpdate(true);
1020}

References m_d, setNeedsUpdate(), and value().

◆ setFuzzyRadius()

void KisColorizeMask::setFuzzyRadius ( qreal value)

Definition at line 1027 of file kis_colorize_mask.cpp.

1028{
1029 m_d->filteringOptions.fuzzyRadius = value;
1030 m_d->filteringDirty = true;
1031 setNeedsUpdate(true);
1032}

References m_d, setNeedsUpdate(), and value().

◆ setImage()

void KisColorizeMask::setImage ( KisImageWSP image)
overridevirtual

Reimplemented from KisBaseNode.

Definition at line 663 of file kis_colorize_mask.cpp.

664{
666
667 auto it = m_d->keyStrokes.begin();
668 for(; it != m_d->keyStrokes.end(); ++it) {
669 it->dev->setDefaultBounds(bounds);
670 }
671
672 m_d->coloringProjection->setDefaultBounds(bounds);
673 m_d->fakePaintDevice->setDefaultBounds(bounds);
674 m_d->filteredSource->setDefaultBounds(bounds);
675}
#define bounds(x, a, b)

References bounds, KisBaseNode::image, and m_d.

◆ setKeyStrokesColors()

void KisColorizeMask::setKeyStrokesColors ( KeyStrokeColors colors)

Definition at line 930 of file kis_colorize_mask.cpp.

931{
932 KIS_ASSERT_RECOVER_RETURN(colors.colors.size() == m_d->keyStrokes.size());
933
934 QList<KeyStroke> newList = m_d->keyStrokes;
935
936 for (int i = 0; i < newList.size(); i++) {
937 newList[i].color = colors.colors[i];
938 newList[i].color.convertTo(colorSpace());
939 newList[i].isTransparent = colors.transparentIndex == i;
940 }
941
942 KisProcessingApplicator applicator(image(), KisNodeSP(this),
945 kundo2_i18n("Change Key Stroke Color"));
946 applicator.applyCommand(
948 newList, &m_d->keyStrokes, KisColorizeMaskSP(this)));
949
950 applicator.end();
951}
friend struct SetKeyStrokeColorsCommand

References KisProcessingApplicator::applyCommand(), KisColorizeMask::KeyStrokeColors::colors, colorSpace(), KisProcessingApplicator::end(), KisBaseNode::image, KIS_ASSERT_RECOVER_RETURN, kundo2_i18n(), m_d, KisProcessingApplicator::NONE, SetKeyStrokeColorsCommand, and KisColorizeMask::KeyStrokeColors::transparentIndex.

◆ setKeyStrokesDirect()

void KisColorizeMask::setKeyStrokesDirect ( const QList< KisLazyFillTools::KeyStroke > & strokes)

Definition at line 1100 of file kis_colorize_mask.cpp.

1101{
1102 m_d->keyStrokes = strokes;
1103
1104 for (auto it = m_d->keyStrokes.begin(); it != m_d->keyStrokes.end(); ++it) {
1105 it->dev->setParentNode(this);
1106 }
1107
1109 {};
1110}
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER, and m_d.

◆ setLimitToDeviceBounds()

void KisColorizeMask::setLimitToDeviceBounds ( bool value)

Definition at line 1050 of file kis_colorize_mask.cpp.

1051{
1052 m_d->limitToDeviceBounds = value;
1053 m_d->filteringDirty = true;
1054 setNeedsUpdate(true);
1055}

References m_d, setNeedsUpdate(), and value().

◆ setNeedsUpdate()

void KisColorizeMask::setNeedsUpdate ( bool value)
private

Definition at line 297 of file kis_colorize_mask.cpp.

298{
299 m_d->setNeedsUpdateImpl(value, true);
300}

References m_d, and value().

◆ setProfile()

void KisColorizeMask::setProfile ( const KoColorProfile * profile,
KUndo2Command * parentCommand )

Definition at line 259 of file kis_colorize_mask.cpp.

260{
261 m_d->fakePaintDevice->setProfile(profile, parentCommand);
262 m_d->coloringProjection->setProfile(profile, parentCommand);
263
264 for (auto & stroke : m_d->keyStrokes) {
265 stroke.color.setProfile(profile);
266 }
267}

References m_d, and setProfile().

◆ setSectionModelProperties()

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

Change the section model properties.

Reimplemented from KisBaseNode.

Definition at line 441 of file kis_colorize_mask.cpp.

442{
444
445 Q_FOREACH (const KisBaseNode::Property &property, properties) {
447 if (m_d->needsUpdate && m_d->needsUpdate != property.state.toBool()) {
448 setNeedsUpdate(property.state.toBool());
449 }
450 }
452 if (m_d->showKeyStrokes != property.state.toBool()) {
453 setShowKeyStrokes(property.state.toBool());
454 }
455 }
457 if (m_d->showColoring != property.state.toBool()) {
458 setShowColoring(property.state.toBool());
459 }
460 }
461 }
462}
void setShowColoring(bool value)
void setShowKeyStrokes(bool value)
QString id() const
Definition KoID.cpp:63
KoProperties properties
virtual void setSectionModelProperties(const PropertyList &properties)

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisLayerPropertiesIcons::colorizeNeedsUpdate, KisLayerPropertiesIcons::colorizeShowColoring, KoID::id(), KisBaseNode::Property::id, m_d, KisBaseNode::properties, setNeedsUpdate(), KisBaseNode::setSectionModelProperties(), setShowColoring(), setShowKeyStrokes(), and KisBaseNode::Property::state.

◆ setShowColoring()

void KisColorizeMask::setShowColoring ( bool value)
private

Definition at line 847 of file kis_colorize_mask.cpp.

848{
849 QRect savedExtent;
850 if (m_d->showColoring && !value) {
851 savedExtent = extent();
852 }
853
854 m_d->showColoring = value;
856
857 if (!savedExtent.isEmpty()) {
858 setDirty(savedExtent);
859 }
860}
void baseNodeChangedCallback() override
Definition kis_mask.cc:532
virtual void setDirty()
Definition kis_node.cpp:577

References KisMask::baseNodeChangedCallback(), extent(), m_d, KisNode::setDirty(), and value().

◆ setShowKeyStrokes()

void KisColorizeMask::setShowKeyStrokes ( bool value)
private

Definition at line 867 of file kis_colorize_mask.cpp.

868{
869 QRect savedExtent;
870 if (m_d->showKeyStrokes && !value) {
871 savedExtent = extent();
872 }
873
874 m_d->showKeyStrokes = value;
876
877 if (!savedExtent.isEmpty()) {
878 setDirty(savedExtent);
879 }
880
882}
void regeneratePrefilteredDeviceIfNeeded()

References KisMask::baseNodeChangedCallback(), extent(), m_d, regeneratePrefilteredDeviceIfNeeded(), KisNode::setDirty(), and value().

◆ setUseEdgeDetection()

void KisColorizeMask::setUseEdgeDetection ( bool value)

Definition at line 1003 of file kis_colorize_mask.cpp.

1004{
1005 m_d->filteringOptions.useEdgeDetection = value;
1006 m_d->filteringDirty = true;
1007 setNeedsUpdate(true);
1008}

References m_d, setNeedsUpdate(), and value().

◆ setX()

void KisColorizeMask::setX ( qint32 )
overridevirtual

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

Reimplemented from KisBaseNode.

Definition at line 1122 of file kis_colorize_mask.cpp.

1123{
1124 const QPoint oldOffset = m_d->offset;
1125 m_d->offset.rx() = x;
1126 moveAllInternalDevices(m_d->offset - oldOffset);
1127}
void moveAllInternalDevices(const QPoint &diff)
qint32 x() const override

References m_d, moveAllInternalDevices(), and x().

◆ setY()

void KisColorizeMask::setY ( qint32 )
overridevirtual

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

Reimplemented from KisBaseNode.

Definition at line 1129 of file kis_colorize_mask.cpp.

1130{
1131 const QPoint oldOffset = m_d->offset;
1132 m_d->offset.ry() = y;
1133 moveAllInternalDevices(m_d->offset - oldOffset);
1134}
qint32 y() const override

References m_d, moveAllInternalDevices(), and y().

◆ showColoring()

bool KisColorizeMask::showColoring ( ) const
private

Definition at line 842 of file kis_colorize_mask.cpp.

843{
844 return m_d->showColoring;
845}

References m_d.

◆ showKeyStrokes()

bool KisColorizeMask::showKeyStrokes ( ) const
private

Definition at line 862 of file kis_colorize_mask.cpp.

863{
864 return m_d->showKeyStrokes;
865}

References m_d.

◆ sigKeyStrokesListChanged

void KisColorizeMask::sigKeyStrokesListChanged ( )
signal

◆ sigUpdateOnDirtyParent

void KisColorizeMask::sigUpdateOnDirtyParent ( ) const
signal

◆ slotRecalculatePrefilteredImage

void KisColorizeMask::slotRecalculatePrefilteredImage ( )
privateslot

Definition at line 401 of file kis_colorize_mask.cpp.

402{
404}

References slotUpdateRegenerateFilling().

◆ slotRegenerationCancelled

void KisColorizeMask::slotRegenerationCancelled ( )
privateslot

Definition at line 425 of file kis_colorize_mask.cpp.

426{
428 m_d->setNeedsUpdateImpl(true, false);
429}
void slotRegenerationFinished(bool prefilterOnly)

References m_d, and slotRegenerationFinished().

◆ slotRegenerationFinished

void KisColorizeMask::slotRegenerationFinished ( bool prefilterOnly)
privateslot

Definition at line 406 of file kis_colorize_mask.cpp.

407{
408 m_d->updateIsRunning = false;
409
410 if (!prefilterOnly) {
411 m_d->setNeedsUpdateImpl(false, false);
412 }
413
414 QRect oldExtent;
415
416 if (!m_d->extentBeforeUpdateStart.isEmpty()) {
417 oldExtent = m_d->extentBeforeUpdateStart.pop();
418 } else {
419 KIS_SAFE_ASSERT_RECOVER_NOOP(!m_d->extentBeforeUpdateStart.isEmpty()); // always fail!
420 }
421
422 setDirty(oldExtent | extent());
423}
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References extent(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, and KisNode::setDirty().

◆ slotUpdateOnDirtyParent

void KisColorizeMask::slotUpdateOnDirtyParent ( )
privateslot

Definition at line 377 of file kis_colorize_mask.cpp.

378{
379 if (!parent()) {
380 // When the colorize mask is being merged,
381 // the update is performed for all the layers,
382 // so the invisible areas around the canvas are included in the merged layer.
383 // Colorize Mask gets the info that its parent is "dirty" (needs updating),
384 // but when it arrives, the parent doesn't exist anymore and is set to null.
385 // Colorize Mask doesn't work outside of the canvas anyway (at least in time of writing).
386 return;
387 }
390
391 if (!m_d->filteredSourceValid(src)) {
392 const QRect &oldExtent = extent();
393
394 m_d->setNeedsUpdateImpl(true, false);
395 m_d->filteringDirty = true;
396
397 setDirty(oldExtent | extent());
398 }
399}

References extent(), KIS_ASSERT_RECOVER_RETURN, m_d, KisBaseNode::original(), KisNode::parent, and KisNode::setDirty().

◆ slotUpdateRegenerateFilling

void KisColorizeMask::slotUpdateRegenerateFilling ( bool prefilterOnly = false)
privateslot

Definition at line 314 of file kis_colorize_mask.cpp.

315{
318
319 const bool filteredSourceValid = m_d->filteredSourceValid(src);
320 m_d->originalSequenceNumber = src->sequenceNumber();
321 m_d->filteringDirty = false;
322
323 if (!prefilterOnly) {
324 m_d->coloringProjection->clear();
325 }
326
327 KisLayerSP parentLayer(qobject_cast<KisLayer*>(parent().data()));
328 if (!parentLayer) return;
329
330 KisImageSP image = parentLayer->image();
331 if (image) {
332 m_d->updateIsRunning = true;
333
334 QRect fillBounds;
335
336 if (m_d->limitToDeviceBounds) {
337 fillBounds |= src->exactBounds();
338 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
339 fillBounds |= stroke.dev->exactBounds();
340 }
341 fillBounds &= image->bounds();
342 } else {
343 fillBounds = image->bounds();
344 }
345
346 m_d->filteredDeviceBounds = fillBounds;
347
348 KisColorizeStrokeStrategy *strategy =
350 m_d->coloringProjection,
351 m_d->filteredSource,
352 filteredSourceValid,
353 fillBounds,
354 this,
355 prefilterOnly);
356
357 strategy->setFilteringOptions(m_d->filteringOptions);
358
359 Q_FOREACH (const KeyStroke &stroke, m_d->keyStrokes) {
360 const KoColor color =
361 !stroke.isTransparent ?
362 stroke.color :
364
365 strategy->addKeyStroke(stroke.dev, color);
366 }
367
368 m_d->extentBeforeUpdateStart.push(extent());
369
370 connect(strategy, SIGNAL(sigFinished(bool)), SLOT(slotRegenerationFinished(bool)));
371 connect(strategy, SIGNAL(sigCancelled()), SLOT(slotRegenerationCancelled()));
372 KisStrokeId id = image->startStroke(strategy);
373 image->endStroke(id);
374 }
375}
void setFilteringOptions(const KisLazyFillTools::FilteringOptions &value)
void addKeyStroke(KisPaintDeviceSP dev, const KoColor &color)
KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override
void endStroke(KisStrokeId id) override
static KoColor createTransparent(const KoColorSpace *cs)
Definition KoColor.cpp:681
const KoColorSpace * colorSpace() const
return the current colorSpace
Definition KoColor.h:82

References KisColorizeStrokeStrategy::addKeyStroke(), KisImage::bounds(), KisLazyFillTools::KeyStroke::color, KoColor::colorSpace(), connect(), KoColor::createTransparent(), KisLazyFillTools::KeyStroke::dev, KisImage::endStroke(), KisPaintDevice::exactBounds(), extent(), KisBaseNode::image, KisLazyFillTools::KeyStroke::isTransparent, KIS_ASSERT_RECOVER_RETURN, m_d, KisBaseNode::original(), KisNode::parent, KisColorizeStrokeStrategy::setFilteringOptions(), slotRegenerationCancelled(), slotRegenerationFinished(), and KisImage::startStroke().

◆ supportsNonIndirectPainting()

bool KisColorizeMask::supportsNonIndirectPainting ( ) const
overridevirtual

Reimplemented from KisIndirectPaintingSupport.

Definition at line 837 of file kis_colorize_mask.cpp.

838{
839 return false;
840}

◆ testingAddKeyStroke()

void KisColorizeMask::testingAddKeyStroke ( KisPaintDeviceSP dev,
const KoColor & color,
bool isTransparent = false )

Definition at line 1079 of file kis_colorize_mask.cpp.

1080{
1081 m_d->keyStrokes << KeyStroke(dev, color, isTransparent);
1082}

References m_d.

◆ testingFilteredSource()

KisPaintDeviceSP KisColorizeMask::testingFilteredSource ( ) const

Definition at line 1090 of file kis_colorize_mask.cpp.

1091{
1092 return m_d->filteredSource;
1093}

References m_d.

◆ useEdgeDetection()

bool KisColorizeMask::useEdgeDetection ( ) const

Definition at line 1010 of file kis_colorize_mask.cpp.

1011{
1012 return m_d->filteringOptions.useEdgeDetection;
1013}

References m_d.

◆ writeMergeData()

void KisColorizeMask::writeMergeData ( KisPainter * painter,
KisPaintDeviceSP src,
const QRect & rc )
overridevirtual

Reimplemented from KisIndirectPaintingSupport.

Definition at line 821 of file kis_colorize_mask.cpp.

822{
824 const bool nonAlphaDst = !(*painter->device()->colorSpace() == *alpha8);
825
826 if (nonAlphaDst) {
827 painter->bitBlt(rc.topLeft(), src, rc);
828 } else {
829 KisCachedSelection::Guard s1(m_d->cachedSelection);
830 KisPixelSelectionSP tempSelection = s1.selection()->pixelSelection();
831
832 tempSelection->copyAlphaFrom(src, rc);
833 painter->bitBlt(rc.topLeft(), tempSelection, rc);
834 }
835}
const KoColorSpace * colorSpace() const
void bitBlt(qint32 dstX, qint32 dstY, const KisPaintDeviceSP srcDev, qint32 srcX, qint32 srcY, qint32 srcWidth, qint32 srcHeight)
KisPaintDeviceSP device
const KoColorSpace * alpha8()

References KoColorSpaceRegistry::alpha8(), KisPainter::bitBlt(), KisPaintDevice::colorSpace(), KisPixelSelection::copyAlphaFrom(), KisPainter::device, KoColorSpaceRegistry::instance(), m_d, and s1.

◆ x()

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

Reimplemented from KisBaseNode.

Definition at line 1112 of file kis_colorize_mask.cpp.

1113{
1114 return m_d->offset.x();
1115}

References m_d.

◆ y()

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

Reimplemented from KisBaseNode.

Definition at line 1117 of file kis_colorize_mask.cpp.

1118{
1119 return m_d->offset.y();
1120}

References m_d.

Friends And Related Symbol Documentation

◆ KeyStrokeAddRemoveCommand

friend struct KeyStrokeAddRemoveCommand
friend

Definition at line 164 of file kis_colorize_mask.h.

◆ SetKeyStrokeColorsCommand

friend struct SetKeyStrokeColorsCommand
friend

Definition at line 165 of file kis_colorize_mask.h.

◆ SetKeyStrokesColorSpaceCommand

friend struct SetKeyStrokesColorSpaceCommand
friend

Definition at line 163 of file kis_colorize_mask.h.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisColorizeMask::m_d
private

Definition at line 169 of file kis_colorize_mask.h.


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