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

The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image frame on a KisPaintDevice. More...

#include <kis_raster_keyframe_channel.h>

+ Inheritance diagram for KisRasterKeyframe:

Public Member Functions

QRect contentBounds ()
 
KisKeyframeSP duplicate (KisKeyframeChannel *newChannel=0) override
 
int frameID () const
 Get the frameID of the "physical" raster frame on the associated KisPaintDevice.
 
bool hasContent ()
 
 KisRasterKeyframe (KisPaintDeviceWSP paintDevice)
 
 KisRasterKeyframe (KisPaintDeviceWSP paintDevice, const int &premadeFrameID, const int &colorLabelId=0)
 
void writeFrameToDevice (KisPaintDeviceSP writeTarget)
 Write this frame's raster content to another paint device. Useful for things like onion skinning where the contents of the frame are drawn to a second, external device.
 
 ~KisRasterKeyframe () override
 
- Public Member Functions inherited from KisKeyframe
int colorLabel () const
 
 KisKeyframe ()
 
void setColorLabel (int colorIndex)
 
virtual ~KisKeyframe ()
 

Private Member Functions

 KisRasterKeyframe (const KisRasterKeyframe &rhs)
 

Private Attributes

int m_frameID
 m_frameID is a handle that references the "physical" frame stored in this keyframe's KisPaintDevice, m_paintDevice. This handle is created by the KisPaintDevice upon construction of the KisRasterKeyframe, and it is passed back to the KisPaintDevice for cleanup upon destruction of the KisRasterKeyframe.
 
KisPaintDeviceWSP m_paintDevice
 

Detailed Description

The KisRasterKeyframe class is a concrete subclass of KisKeyframe that wraps a physical raster image frame on a KisPaintDevice.

Whenever a "virtual" KisRasterKeyframe is created, a "physical" raster frame is created on the associated KisPaintDevice and its frameID is stored. Likewise, whenever a "virtual" KisRasterKeyframe is destroyed, the "physical" frame associated with its frameID on the KisPaintDevice is automatically freed.

Definition at line 23 of file kis_raster_keyframe_channel.h.

Constructor & Destructor Documentation

◆ KisRasterKeyframe() [1/3]

KisRasterKeyframe::KisRasterKeyframe ( KisPaintDeviceWSP paintDevice)

Definition at line 20 of file kis_raster_keyframe_channel.cpp.

21 : KisKeyframe()
22{
23 m_paintDevice = paintDevice;
25
26 m_frameID = m_paintDevice->framesInterface()->createFrame(false, 0, QPoint(), nullptr);
27}
int createFrame(bool copy, int copySrc, const QPoint &offset, KUndo2Command *parentCommand)
KisPaintDeviceFramesInterface * framesInterface()
int m_frameID
m_frameID is a handle that references the "physical" frame stored in this keyframe's KisPaintDevice,...
#define KIS_ASSERT(cond)
Definition kis_assert.h:33

References KisPaintDeviceFramesInterface::createFrame(), KisPaintDevice::framesInterface(), KIS_ASSERT, m_frameID, and m_paintDevice.

◆ KisRasterKeyframe() [2/3]

KisRasterKeyframe::KisRasterKeyframe ( KisPaintDeviceWSP paintDevice,
const int & premadeFrameID,
const int & colorLabelId = 0 )

Definition at line 29 of file kis_raster_keyframe_channel.cpp.

30 : KisKeyframe()
31{
32 m_paintDevice = paintDevice;
33 m_frameID = premadeFrameID;
34 setColorLabel(colorLabelId);
35
37}
void setColorLabel(int colorIndex)

References KIS_ASSERT, m_frameID, m_paintDevice, and KisKeyframe::setColorLabel().

◆ ~KisRasterKeyframe()

KisRasterKeyframe::~KisRasterKeyframe ( )
override

Definition at line 39 of file kis_raster_keyframe_channel.cpp.

40{
41 // Note: Because keyframe ownership is shared, it's possible for them to outlive
42 // the paint device.
45 }
46}
void deleteFrame(int frame, KUndo2Command *parentCommand)

References KisPaintDeviceFramesInterface::deleteFrame(), KisPaintDevice::framesInterface(), m_frameID, and m_paintDevice.

◆ KisRasterKeyframe() [3/3]

KisRasterKeyframe::KisRasterKeyframe ( const KisRasterKeyframe & rhs)
private

Member Function Documentation

◆ contentBounds()

QRect KisRasterKeyframe::contentBounds ( )

◆ duplicate()

KisKeyframeSP KisRasterKeyframe::duplicate ( KisKeyframeChannel * newChannel = 0)
overridevirtual

Creates a copy of this keyframe.

Parameters
newChannel(Optional) The channel that will hold this duplicate. This is used when some action must be taken to insert a frame into a new channel, for example, the registration of a KisRasterKeyframe with the new channel's paint device.

Implements KisKeyframe.

Definition at line 74 of file kis_raster_keyframe_channel.cpp.

75{
76 if (newChannel) {
77 KisRasterKeyframeChannel* rasterChannel = dynamic_cast<KisRasterKeyframeChannel*>(newChannel);
78 KIS_ASSERT(rasterChannel);
79 KisPaintDeviceWSP targetDevice = rasterChannel->paintDevice();
80
81 if (targetDevice != m_paintDevice) {
82 int targetFrameID = targetDevice->framesInterface()->createFrame(false, 0, QPoint(), nullptr);
83 targetDevice->framesInterface()->uploadFrame(m_frameID, targetFrameID, m_paintDevice);
84 KisKeyframeSP key = toQShared(new KisRasterKeyframe(targetDevice, targetFrameID ));
85 key->setColorLabel(colorLabel());
86 return key;
87 }
88 }
89
90 int copyFrameID = m_paintDevice->framesInterface()->createFrame(true, m_frameID, QPoint(), nullptr);
92 key->setColorLabel(colorLabel());
93 return key;
94}
int colorLabel() const
void uploadFrame(int srcFrameId, int dstFrameId, KisPaintDeviceSP srcDevice)
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
KisRasterKeyframe(KisPaintDeviceWSP paintDevice)
QSharedPointer< T > toQShared(T *ptr)

References KisKeyframe::colorLabel(), KisPaintDeviceFramesInterface::createFrame(), KisPaintDevice::framesInterface(), KIS_ASSERT, KisRasterKeyframe(), m_frameID, m_paintDevice, KisRasterKeyframeChannel::paintDevice(), toQShared(), and KisPaintDeviceFramesInterface::uploadFrame().

◆ frameID()

int KisRasterKeyframe::frameID ( ) const

Get the frameID of the "physical" raster frame on the associated KisPaintDevice.

Definition at line 48 of file kis_raster_keyframe_channel.cpp.

49{
50 return m_frameID;
51}

References m_frameID.

◆ hasContent()

bool KisRasterKeyframe::hasContent ( )

◆ writeFrameToDevice()

void KisRasterKeyframe::writeFrameToDevice ( KisPaintDeviceSP writeTarget)

Write this frame's raster content to another paint device. Useful for things like onion skinning where the contents of the frame are drawn to a second, external device.

Definition at line 67 of file kis_raster_keyframe_channel.cpp.

68{
70
72}
void writeFrameToDevice(int frameId, KisPaintDeviceSP targetDevice)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KisPaintDevice::framesInterface(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_frameID, m_paintDevice, and KisPaintDeviceFramesInterface::writeFrameToDevice().

Member Data Documentation

◆ m_frameID

int KisRasterKeyframe::m_frameID
private

m_frameID is a handle that references the "physical" frame stored in this keyframe's KisPaintDevice, m_paintDevice. This handle is created by the KisPaintDevice upon construction of the KisRasterKeyframe, and it is passed back to the KisPaintDevice for cleanup upon destruction of the KisRasterKeyframe.

Definition at line 51 of file kis_raster_keyframe_channel.h.

◆ m_paintDevice

KisPaintDeviceWSP KisRasterKeyframe::m_paintDevice
private

Definition at line 52 of file kis_raster_keyframe_channel.h.


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