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 796 of file kis_layer_utils.cpp.

Constructor & Destructor Documentation

◆ SplitAlphaCommand()

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

Definition at line 797 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 802 of file kis_layer_utils.cpp.

802 {
803 KisPaintDeviceSP srcDevice = m_info->node->paintDevice();
804 const KoColorSpace *srcCS = srcDevice->colorSpace();
805 const QRect processRect =
806 srcDevice->exactBounds() |
807 srcDevice->defaultBounds()->bounds();
808
809 KisSequentialIterator srcIt(srcDevice, processRect);
810 KisSequentialIterator dstIt(m_info->getMaskDevice(), processRect);
811
812 while (srcIt.nextPixel() && dstIt.nextPixel()) {
813 quint8 *srcPtr = srcIt.rawData();
814 quint8 *alpha8Ptr = dstIt.rawData();
815
816 *alpha8Ptr = srcCS->opacityU8(srcPtr);
817 srcCS->setOpacity(srcPtr, OPACITY_OPAQUE_U8, 1);
818 }
819 }
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 821 of file kis_layer_utils.cpp.

821 {
822 KisPaintDeviceSP srcDevice = m_info->node->paintDevice();
823
824 if (srcDevice->framesInterface()) { //Swap contents of all frames to reflect the pre-operation state.
826 Q_FOREACH(const int& frame, srcDevice->framesInterface()->frames() ) {
827 if (m_cached->framesInterface()->frames().contains(frame)) {
829 srcDevice->framesInterface()->uploadFrame(frame, tempPD);
830 }
831 }
832 } else {
833 const QRect processRect =
834 srcDevice->exactBounds() |
835 srcDevice->defaultBounds()->bounds();
836
837 const KoColorSpace *srcCS = srcDevice->colorSpace();
838 KisSequentialIterator srcIt(m_cached, processRect);
839 KisSequentialIterator dstIt(srcDevice, processRect);
840
841 while (srcIt.nextPixel() && dstIt.nextPixel()) {
842 quint8 *srcPtr = srcIt.rawData();
843 quint8 *dstPtr = dstIt.rawData();
844 srcCS->setOpacity(dstPtr, srcCS->opacityU8(srcPtr), 1);
845 }
846 }
847 }
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 851 of file kis_layer_utils.cpp.

◆ m_info

SplitAlphaToMaskInfoSP KisLayerUtils::SplitAlphaCommand::m_info
private

Definition at line 850 of file kis_layer_utils.cpp.


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