Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLayerUtils::SplitAlphaCommand Struct Reference
+ Inheritance diagram for KisLayerUtils::SplitAlphaCommand:

Public Member Functions

void redo () override
 
 SplitAlphaCommand (SplitAlphaToMaskInfoSP info)
 
void undo () override
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () const
 
bool hasParent () const
 
virtual int id () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual bool mergeWith (const KUndo2Command *other)
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Private Attributes

KisPaintDeviceSP m_cached
 
SplitAlphaToMaskInfoSP m_info
 

Detailed Description

Definition at line 765 of file kis_layer_utils.cpp.

Constructor & Destructor Documentation

◆ SplitAlphaCommand()

KisLayerUtils::SplitAlphaCommand::SplitAlphaCommand ( SplitAlphaToMaskInfoSP info)
inline

Definition at line 766 of file kis_layer_utils.cpp.

References KritaUtils::CopyAllFrames, m_cached, and m_info.

Member Function Documentation

◆ redo()

void KisLayerUtils::SplitAlphaCommand::redo ( )
inlineoverridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 771 of file kis_layer_utils.cpp.

771 {
772 KisPaintDeviceSP srcDevice = m_info->node->paintDevice();
773 const KoColorSpace *srcCS = srcDevice->colorSpace();
774 const QRect processRect =
775 srcDevice->exactBounds() |
776 srcDevice->defaultBounds()->bounds();
777
778 KisSequentialIterator srcIt(srcDevice, processRect);
779 KisSequentialIterator dstIt(m_info->getMaskDevice(), processRect);
780
781 while (srcIt.nextPixel() && dstIt.nextPixel()) {
782 quint8 *srcPtr = srcIt.rawData();
783 quint8 *alpha8Ptr = dstIt.rawData();
784
785 *alpha8Ptr = srcCS->opacityU8(srcPtr);
786 srcCS->setOpacity(srcPtr, OPACITY_OPAQUE_U8, 1);
787 }
788 }
const quint8 OPACITY_OPAQUE_U8
virtual QRect bounds() const =0
QRect exactBounds() const
const KoColorSpace * colorSpace() const
KisDefaultBoundsBaseSP defaultBounds() const
virtual void setOpacity(quint8 *pixels, quint8 alpha, qint32 nPixels) const =0
virtual quint8 opacityU8(const quint8 *pixel) const =0

References KisDefaultBoundsBase::bounds(), KisPaintDevice::colorSpace(), KisPaintDevice::defaultBounds(), KisPaintDevice::exactBounds(), m_info, KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::nextPixel(), OPACITY_OPAQUE_U8, KoColorSpace::opacityU8(), KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::rawData(), and KoColorSpace::setOpacity().

◆ undo()

void KisLayerUtils::SplitAlphaCommand::undo ( )
inlineoverridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 790 of file kis_layer_utils.cpp.

790 {
791 KisPaintDeviceSP srcDevice = m_info->node->paintDevice();
792
793 if (srcDevice->framesInterface()) { //Swap contents of all frames to reflect the pre-operation state.
795 Q_FOREACH(const int& frame, srcDevice->framesInterface()->frames() ) {
796 if (m_cached->framesInterface()->frames().contains(frame)) {
798 srcDevice->framesInterface()->uploadFrame(frame, tempPD);
799 }
800 }
801 } else {
802 const QRect processRect =
803 srcDevice->exactBounds() |
804 srcDevice->defaultBounds()->bounds();
805
806 const KoColorSpace *srcCS = srcDevice->colorSpace();
807 KisSequentialIterator srcIt(m_cached, processRect);
808 KisSequentialIterator dstIt(srcDevice, processRect);
809
810 while (srcIt.nextPixel() && dstIt.nextPixel()) {
811 quint8 *srcPtr = srcIt.rawData();
812 quint8 *dstPtr = dstIt.rawData();
813 srcCS->setOpacity(dstPtr, srcCS->opacityU8(srcPtr), 1);
814 }
815 }
816 }
void writeFrameToDevice(int frameId, KisPaintDeviceSP targetDevice)
void uploadFrame(int srcFrameId, int dstFrameId, KisPaintDeviceSP srcDevice)
KisPaintDeviceFramesInterface * framesInterface()

References KisDefaultBoundsBase::bounds(), KisPaintDevice::colorSpace(), KritaUtils::CopySnapshot, KisPaintDevice::defaultBounds(), KisPaintDevice::exactBounds(), KisPaintDeviceFramesInterface::frames(), KisPaintDevice::framesInterface(), m_cached, m_info, KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::nextPixel(), KoColorSpace::opacityU8(), KisSequentialIteratorBase< IteratorPolicy, SourcePolicy, ProgressPolicy >::rawData(), KoColorSpace::setOpacity(), KisPaintDeviceFramesInterface::uploadFrame(), and KisPaintDeviceFramesInterface::writeFrameToDevice().

Member Data Documentation

◆ m_cached

KisPaintDeviceSP KisLayerUtils::SplitAlphaCommand::m_cached
private

Definition at line 820 of file kis_layer_utils.cpp.

◆ m_info

SplitAlphaToMaskInfoSP KisLayerUtils::SplitAlphaCommand::m_info
private

Definition at line 819 of file kis_layer_utils.cpp.


The documentation for this struct was generated from the following file: