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

#include <kis_image_animation_interface.h>

+ Inheritance diagram for KisImageAnimationInterface:

Classes

struct  Private
 

Public Types

enum  SwitchTimeAsyncOption { STAO_NONE = 0 , STAO_USE_UNDO = 1 << 1 , STAO_FORCE_REGENERATION = 1 << 2 }
 

Public Slots

void setDocumentRangeEndFrame (int column)
 
void setDocumentRangeStartFrame (int column)
 
void setFramerate (int fps)
 
void switchCurrentTimeAsync (int frameId, SwitchTimeAsyncFlags options=STAO_NONE)
 

Signals

void sigDocumentRangeChanged ()
 
void sigFrameCancelled ()
 
void sigFramerateChanged ()
 
void sigFrameReady (int time)
 sigFrameReady notifies when an External frame has been regenerated and is available.
 
void sigFrameRegenerated (int time)
 sigFrameRegenerated notifies when internal frame has been fully regenerated.
 
void sigFrameRegenerationSkipped (int time)
 sigFrameRegenerationSkipped notified when async frame changes are skipped.
 
void sigFramesChanged (const KisTimeSpan &range, const QRect &rect)
 
void sigInternalRequestTimeSwitch (int frameId, bool useUndo)
 
void sigKeyframeAdded (const KisKeyframeChannel *channel, int time)
 
void sigKeyframeRemoved (const KisKeyframeChannel *channel, int time)
 
void sigPlaybackRangeChanged ()
 
void sigUiTimeChanged (int newTime)
 

Public Member Functions

QSet< int > activeLayerSelectedTimes ()
 
const KisTimeSpanactivePlaybackRange () const
 activePlaybackRange
 
bool backgroundFrameGenerationBlocked () const
 
void blockBackgroundFrameGeneration ()
 
int currentTime () const
 
int currentUITime () const
 
const KisTimeSpandocumentPlaybackRange () const
 documentPlaybackRange
 
int exportInitialFrameNumber ()
 
QString exportSequenceBaseName ()
 
QString exportSequenceFilePath ()
 
bool externalFrameActive () const
 
int framerate () const
 
bool hasAnimation () const
 
KisImageWSP image () const
 
void invalidateFrame (const int time, KisNodeSP target)
 
void invalidateFrames (const KisTimeSpan &range, const QRect &rect)
 
 KisImageAnimationInterface (const KisImageAnimationInterface &rhs, KisImage *newImage)
 
 KisImageAnimationInterface (KisImage *image)
 
void lockFrameGeneration ()
 
void notifyNodeChanged (const KisNode *node, const QRect &rect, bool recursive)
 
void notifyNodeChanged (const KisNode *node, const QVector< QRect > &rects, bool recursive)
 
 Q_DECLARE_FLAGS (SwitchTimeAsyncFlags, SwitchTimeAsyncOption)
 
void requestFrameRegeneration (int frameId, const KisRegion &dirtyRegion, bool isCancellable, KisLockFrameGenerationLock &&lock)
 
void requestTimeSwitchNonGUI (int time, bool useUndo=false)
 
void requestTimeSwitchWithUndo (int time)
 
void setActiveLayerSelectedTimes (const QSet< int > &times)
 
void setActivePlaybackRange (const KisTimeSpan range)
 
void setDefaultProjectionColor (const KoColor &color)
 
void setDocumentRange (const KisTimeSpan range)
 
void setExportInitialFrameNumber (const int frameNum)
 
void setExportSequenceBaseName (const QString &baseName)
 
void setExportSequenceFilePath (const QString &filePath)
 
int totalLength ()
 
bool tryLockFrameGeneration ()
 
void unblockBackgroundFrameGeneration ()
 
void unlockFrameGeneration ()
 
 ~KisImageAnimationInterface () override
 

Private Member Functions

void blockFrameInvalidation (bool value)
 
void explicitlySetCurrentTime (int frameId)
 
void notifyFrameCancelled ()
 
void notifyFrameReady ()
 
void notifyFrameRegenerated ()
 
bool requiresOnionSkinRendering ()
 
void restoreCurrentTime (int *savedValue)
 
void saveAndResetCurrentTime (int frameId, int *savedValue)
 
KisUpdatesFacadeupdatesFacade () const
 

Private Attributes

const QScopedPointer< Privatem_d
 

Friends

class KisAnimationFrameCacheTest
 
class KisImageTest
 
struct KisLayerUtils::SwitchFrameCommand
 
class KisRegenerateFrameStrokeStrategy
 
class KisSuspendProjectionUpdatesStrokeStrategy
 
class KisSwitchTimeStrokeStrategy
 
class TransformStrokeStrategy
 

Detailed Description

Definition at line 27 of file kis_image_animation_interface.h.

Member Enumeration Documentation

◆ SwitchTimeAsyncOption

Constructor & Destructor Documentation

◆ KisImageAnimationInterface() [1/2]

KisImageAnimationInterface::KisImageAnimationInterface ( KisImage * image)

Definition at line 96 of file kis_image_animation_interface.cpp.

97 : QObject(image),
98 m_d(new Private)
99{
100 m_d->image = image;
101
102 m_d->framerate = 24;
103 m_d->documentRange = KisTimeSpan::fromTimeToTime(0, 100);
104
105 connect(this, &KisImageAnimationInterface::sigInternalRequestTimeSwitch, this, [this](int frame, bool useUndo) {
106 this->switchCurrentTimeAsync(frame, useUndo ? STAO_USE_UNDO : STAO_NONE);
107 });
108}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void switchCurrentTimeAsync(int frameId, SwitchTimeAsyncFlags options=STAO_NONE)
void sigInternalRequestTimeSwitch(int frameId, bool useUndo)
const QScopedPointer< Private > m_d
static KisTimeSpan fromTimeToTime(int start, int end)

References connect(), KisTimeSpan::fromTimeToTime(), image(), m_d, sigInternalRequestTimeSwitch(), STAO_NONE, STAO_USE_UNDO, and switchCurrentTimeAsync().

◆ KisImageAnimationInterface() [2/2]

KisImageAnimationInterface::KisImageAnimationInterface ( const KisImageAnimationInterface & rhs,
KisImage * newImage )

Definition at line 110 of file kis_image_animation_interface.cpp.

111 : m_d(new Private(*rhs.m_d, newImage))
112{
113 connect(this, &KisImageAnimationInterface::sigInternalRequestTimeSwitch, this, [this](int frame, bool useUndo) {
114 this->switchCurrentTimeAsync(frame, useUndo ? STAO_USE_UNDO : STAO_NONE);
115 });
116}

References connect(), sigInternalRequestTimeSwitch(), STAO_NONE, STAO_USE_UNDO, and switchCurrentTimeAsync().

◆ ~KisImageAnimationInterface()

KisImageAnimationInterface::~KisImageAnimationInterface ( )
override

Definition at line 118 of file kis_image_animation_interface.cpp.

119{
120}

Member Function Documentation

◆ activeLayerSelectedTimes()

QSet< int > KisImageAnimationInterface::activeLayerSelectedTimes ( )

Definition at line 216 of file kis_image_animation_interface.cpp.

217{
218 return m_d->activeLayerSelectedTimes;
219}

References m_d.

◆ activePlaybackRange()

const KisTimeSpan & KisImageAnimationInterface::activePlaybackRange ( ) const

activePlaybackRange

Returns
Returns the current clip range that the user wishes play through. Takes into account selection range when available as a custom loop override. Should be used in the PlaybackEngine to determine proper loop points.

Definition at line 169 of file kis_image_animation_interface.cpp.

170{
171 return m_d->activePlaybackRange.isValid() ? m_d->activePlaybackRange : m_d->documentRange;
172}

References KisTimeSpan::isValid(), and m_d.

◆ backgroundFrameGenerationBlocked()

bool KisImageAnimationInterface::backgroundFrameGenerationBlocked ( ) const

Reports if background generation process is blocked

See also
blockBackgroundFrameGeneration()

Definition at line 492 of file kis_image_animation_interface.cpp.

493{
494 return m_d->backgroundFrameGenerationBlocked.loadAcquire();
495}

References m_d.

◆ blockBackgroundFrameGeneration()

void KisImageAnimationInterface::blockBackgroundFrameGeneration ( )

Blocks background processes like frame cache populator from starting the generation process, hence giving priority to the interactive frame generation methods.

This method is not blocking, it just forbids further actions. If there is any background action running, it continues to run. Use lockFrameGeneration() to wait for completion of such actions.

See also
KisBlockBackgroundFrameGenerationLock for RAII wrapper

Definition at line 482 of file kis_image_animation_interface.cpp.

483{
484 m_d->backgroundFrameGenerationBlocked.ref();
485}

References m_d.

◆ blockFrameInvalidation()

void KisImageAnimationInterface::blockFrameInvalidation ( bool value)
private

Definition at line 445 of file kis_image_animation_interface.cpp.

446{
447 m_d->frameInvalidationBlocked = value;
448}
float value(const T *src, size_t ch)

References m_d, and value().

◆ currentTime()

int KisImageAnimationInterface::currentTime ( ) const

Returns currently active frame of the underlying image. Some strokes can override this value and it will report a different value.

Definition at line 135 of file kis_image_animation_interface.cpp.

136{
137 return m_d->currentTime();
138}

References m_d.

◆ currentUITime()

int KisImageAnimationInterface::currentUITime ( ) const

Same as currentTime, except it isn't changed when background strokes are running.

Definition at line 140 of file kis_image_animation_interface.cpp.

141{
142 return m_d->currentUITime();
143}

References m_d.

◆ documentPlaybackRange()

const KisTimeSpan & KisImageAnimationInterface::documentPlaybackRange ( ) const

documentPlaybackRange

Returns
A KisTimeSpan reflecting actual document time range. This is the actual play back range associated with a krita document.

Definition at line 145 of file kis_image_animation_interface.cpp.

146{
147 return m_d->documentRange;
148}

References m_d.

◆ explicitlySetCurrentTime()

void KisImageAnimationInterface::explicitlySetCurrentTime ( int frameId)
private

Definition at line 264 of file kis_image_animation_interface.cpp.

265{
266 m_d->setCurrentTime(frameId);
267}

References m_d.

◆ exportInitialFrameNumber()

int KisImageAnimationInterface::exportInitialFrameNumber ( )

Definition at line 206 of file kis_image_animation_interface.cpp.

207{
208 return m_d->exportInitialFrameNumber;
209}

References m_d.

◆ exportSequenceBaseName()

QString KisImageAnimationInterface::exportSequenceBaseName ( )

Definition at line 196 of file kis_image_animation_interface.cpp.

197{
198 return m_d->exportSequenceBaseName;
199}

References m_d.

◆ exportSequenceFilePath()

QString KisImageAnimationInterface::exportSequenceFilePath ( )

Definition at line 186 of file kis_image_animation_interface.cpp.

187{
188 return m_d->exportSequenceFilePath;
189}

References m_d.

◆ externalFrameActive()

bool KisImageAnimationInterface::externalFrameActive ( ) const

While any non-current frame is being regenerated by the strategy, the image is kept in a special state, named 'externalFrameActive'. Is this state the following applies:

1) All the animated paint devices switch its state into frameId() defined by global time.

2) All animation-not-capable devices switch to a temporary content device, which is in undefined state. The stroke should regenerate the image projection manually.

Definition at line 239 of file kis_image_animation_interface.cpp.

240{
241 return m_d->externalFrameActive;
242}

References m_d.

◆ framerate()

int KisImageAnimationInterface::framerate ( ) const

Definition at line 181 of file kis_image_animation_interface.cpp.

182{
183 return m_d->framerate;
184}

References m_d.

◆ hasAnimation()

bool KisImageAnimationInterface::hasAnimation ( ) const

Returns true of the image has at least one animated layer

Definition at line 122 of file kis_image_animation_interface.cpp.

123{
124 bool hasAnimation = false;
125
127 m_d->image->root(),
128 [&hasAnimation](KisNodeSP node) {
129 hasAnimation |= node->isAnimated();
130 });
131
132 return hasAnimation;
133}
void recursiveApplyNodes(NodePointer node, Functor func)

References hasAnimation(), m_d, and KisLayerUtils::recursiveApplyNodes().

◆ image()

KisImageWSP KisImageAnimationInterface::image ( ) const

Definition at line 234 of file kis_image_animation_interface.cpp.

235{
236 return m_d->image;
237}

References m_d.

◆ invalidateFrame()

void KisImageAnimationInterface::invalidateFrame ( const int time,
KisNodeSP target )

Definition at line 433 of file kis_image_animation_interface.cpp.

434{
435 m_d->cachedLastFrameValue = -1;
436
438
439 QSet<int> identicalFrames = KisLayerUtils::fetchLayerIdenticalRasterFrameTimes(target, time);
440 Q_FOREACH(const int& identicalTime, identicalFrames) {
441 Q_EMIT sigFramesChanged(KisLayerUtils::fetchLayerActiveRasterFrameSpan(target, identicalTime), m_d->image->bounds());
442 }
443}
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
void sigFramesChanged(const KisTimeSpan &range, const QRect &rect)
KisTimeSpan fetchLayerActiveRasterFrameSpan(KisNodeSP node, const int time)
QSet< int > fetchLayerIdenticalRasterFrameTimes(KisNodeSP node, const int &frameTime)

References KisLayerUtils::fetchLayerActiveRasterFrameSpan(), KisLayerUtils::fetchLayerIdenticalRasterFrameTimes(), m_d, sigFramesChanged(), and target().

◆ invalidateFrames()

void KisImageAnimationInterface::invalidateFrames ( const KisTimeSpan & range,
const QRect & rect )

Definition at line 427 of file kis_image_animation_interface.cpp.

428{
429 m_d->cachedLastFrameValue = -1;
430 Q_EMIT sigFramesChanged(range, rect);
431}

References m_d, and sigFramesChanged().

◆ lockFrameGeneration()

void KisImageAnimationInterface::lockFrameGeneration ( )

Acquire an exclusive lock for the frame generation process initiated by requestFrameRegeneration().

It is impossible to execute multiple background frame generation processes on a single image, because the image returns the result using global signals. Hence the initiator of the generation should acquire the lock first and pass it to requestFrameRegeneration(). The lock will be automatically released when the frame generation process is ended and all the signals are emitted.

Calling to lockFrameGeneration() may block until the currently executing frame generation process is running.

See also
KisLockFrameGenerationLock for RAII wrapper

Definition at line 502 of file kis_image_animation_interface.cpp.

503{
504 m_d->frameGenerationLock.lock();
505}

References m_d.

◆ notifyFrameCancelled()

void KisImageAnimationInterface::notifyFrameCancelled ( )
private

Definition at line 351 of file kis_image_animation_interface.cpp.

352{
353 Q_EMIT sigFrameCancelled();
354}

References sigFrameCancelled().

◆ notifyFrameReady()

void KisImageAnimationInterface::notifyFrameReady ( )
private

Definition at line 346 of file kis_image_animation_interface.cpp.

347{
348 Q_EMIT sigFrameReady(m_d->currentTime());
349}
void sigFrameReady(int time)
sigFrameReady notifies when an External frame has been regenerated and is available.

References m_d, and sigFrameReady().

◆ notifyFrameRegenerated()

void KisImageAnimationInterface::notifyFrameRegenerated ( )
private

Definition at line 356 of file kis_image_animation_interface.cpp.

357{
358 Q_EMIT sigFrameRegenerated(m_d->currentTime());
359}
void sigFrameRegenerated(int time)
sigFrameRegenerated notifies when internal frame has been fully regenerated.

References m_d, and sigFrameRegenerated().

◆ notifyNodeChanged() [1/2]

void KisImageAnimationInterface::notifyNodeChanged ( const KisNode * node,
const QRect & rect,
bool recursive )

Definition at line 376 of file kis_image_animation_interface.cpp.

379{
380 notifyNodeChanged(node, QVector<QRect>({rect}), recursive);
381}
void notifyNodeChanged(const KisNode *node, const QRect &rect, bool recursive)

References notifyNodeChanged().

◆ notifyNodeChanged() [2/2]

void KisImageAnimationInterface::notifyNodeChanged ( const KisNode * node,
const QVector< QRect > & rects,
bool recursive )

Definition at line 383 of file kis_image_animation_interface.cpp.

386{
387 if (externalFrameActive() || m_d->frameInvalidationBlocked) return;
388
389 // even overlay selection masks are not rendered in the cache
390 if (node->inherits("KisSelectionMask")) return;
391
392 QSet<int> affectedTimes;
393 affectedTimes << m_d->currentTime();
394
395 // We need to also invalidate ranges that contain cloned keyframe data.
396 if (recursive) {
397 QSet<int> clonedTimes;
398 const int time = m_d->currentTime();
399 KisLayerUtils::recursiveApplyNodes(node, [&clonedTimes, time](const KisNode* node){
400 clonedTimes += KisRasterKeyframeChannel::clonesOf(node, time);
401 });
402
403 affectedTimes += clonedTimes;
404 } else {
405 affectedTimes += KisRasterKeyframeChannel::clonesOf(node, m_d->currentTime());
406 }
407
408 foreach (const int& time, affectedTimes ){
409 KisTimeSpan invalidateRange;
410
411 if (recursive) {
412 invalidateRange = KisTimeSpan::calculateAffectedFramesRecursive(node, time);
413 } else {
414 invalidateRange = KisTimeSpan::calculateNodeAffectedFrames(node, time);
415 }
416
417 // we compress the updated rect (atm, no one uses it anyway)
418 QRect unitedRect;
419 Q_FOREACH (const QRect &rc, rects) {
420 unitedRect |= rc;
421 }
422
423 invalidateFrames(invalidateRange, unitedRect);
424 }
425}
void invalidateFrames(const KisTimeSpan &range, const QRect &rect)
static KisTimeSpan calculateNodeAffectedFrames(const KisNode *node, int time)
static KisTimeSpan calculateAffectedFramesRecursive(const KisNode *node, int time)

References KisTimeSpan::calculateAffectedFramesRecursive(), KisTimeSpan::calculateNodeAffectedFrames(), KisRasterKeyframeChannel::clonesOf(), externalFrameActive(), invalidateFrames(), m_d, and KisLayerUtils::recursiveApplyNodes().

◆ Q_DECLARE_FLAGS()

KisImageAnimationInterface::Q_DECLARE_FLAGS ( SwitchTimeAsyncFlags ,
SwitchTimeAsyncOption  )

◆ requestFrameRegeneration()

void KisImageAnimationInterface::requestFrameRegeneration ( int frameId,
const KisRegion & dirtyRegion,
bool isCancellable,
KisLockFrameGenerationLock && lock )

Start a background thread that will recalculate some extra frame. The result will be reported using two types of signals:

1) KisImage::sigImageUpdated() will be emitted for every chunk of updated area.

2) sigFrameReady() will be emitted in the end of the operation. IMPORTANT: to get the result you must connect to this signal with Qt::DirectConnection and fetch the result from frameProjection(). After the signal handler is exited, the data will no longer be available.

3) The passed lock will be released when the stroke is finished execution (and the strategy is destroyed)

Definition at line 315 of file kis_image_animation_interface.cpp.

316{
317 KisStrokeStrategy *strategy =
319 dirtyRegion,
320 isCancellable,
321 this,
322 std::move(lock));
323
325
326 KisStrokeId stroke = m_d->image->startStroke(strategy);
327 Q_FOREACH (KisStrokeJobData* job, jobs) {
328 m_d->image->addJob(stroke, job);
329 }
330 m_d->image->endStroke(stroke);
331}
static QList< KisStrokeJobData * > createJobsData(KisImageWSP image)

References KisRegenerateFrameStrokeStrategy::createJobsData(), KisRegenerateFrameStrokeStrategy, and m_d.

◆ requestTimeSwitchNonGUI()

void KisImageAnimationInterface::requestTimeSwitchNonGUI ( int time,
bool useUndo = false )

Definition at line 259 of file kis_image_animation_interface.cpp.

260{
261 Q_EMIT sigInternalRequestTimeSwitch(time, useUndo);
262}

References sigInternalRequestTimeSwitch().

◆ requestTimeSwitchWithUndo()

void KisImageAnimationInterface::requestTimeSwitchWithUndo ( int time)

Definition at line 244 of file kis_image_animation_interface.cpp.

245{
246 requestTimeSwitchNonGUI(time, true);
247}
void requestTimeSwitchNonGUI(int time, bool useUndo=false)

References requestTimeSwitchNonGUI().

◆ requiresOnionSkinRendering()

bool KisImageAnimationInterface::requiresOnionSkinRendering ( )
private

Definition at line 361 of file kis_image_animation_interface.cpp.

361 {
362
363 KisNodeSP onionskinned = KisLayerUtils::recursiveFindNode(m_d->image->root(), [](KisNodeSP p) {
364 bool onionSkinProp = p->nodeProperties().boolProperty("onionskin", false);
365 return onionSkinProp;
366 });
367
368 return onionskinned != nullptr;
369}
const Params2D p
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)

References m_d, p, and KisLayerUtils::recursiveFindNode().

◆ restoreCurrentTime()

void KisImageAnimationInterface::restoreCurrentTime ( int * savedValue)
private

Definition at line 340 of file kis_image_animation_interface.cpp.

341{
342 m_d->setCurrentTime(*savedValue);
343 m_d->externalFrameActive = false;
344}

References m_d.

◆ saveAndResetCurrentTime()

void KisImageAnimationInterface::saveAndResetCurrentTime ( int frameId,
int * savedValue )
private

Definition at line 333 of file kis_image_animation_interface.cpp.

334{
335 m_d->externalFrameActive = true;
336 *savedValue = m_d->currentTime();
337 m_d->setCurrentTime(frameId);
338}

References m_d.

◆ setActiveLayerSelectedTimes()

void KisImageAnimationInterface::setActiveLayerSelectedTimes ( const QSet< int > & times)

Definition at line 221 of file kis_image_animation_interface.cpp.

222{
223 m_d->activeLayerSelectedTimes = times;
224}

References m_d.

◆ setActivePlaybackRange()

void KisImageAnimationInterface::setActivePlaybackRange ( const KisTimeSpan range)

Definition at line 174 of file kis_image_animation_interface.cpp.

175{
177 m_d->activePlaybackRange = range;
179}
bool isInfinite() const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KisTimeSpan::isInfinite(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and sigPlaybackRangeChanged().

◆ setDefaultProjectionColor()

void KisImageAnimationInterface::setDefaultProjectionColor ( const KoColor & color)

Changes the default color of the "external frame" projection of the image's root layer. Please note that this command should be executed from a context of an exclusive job!

Definition at line 249 of file kis_image_animation_interface.cpp.

250{
251 int savedTime = 0;
253
254 m_d->image->setDefaultProjectionColor(color);
255
256 restoreCurrentTime(&savedTime);
257}
void saveAndResetCurrentTime(int frameId, int *savedValue)

References currentTime(), m_d, restoreCurrentTime(), and saveAndResetCurrentTime().

◆ setDocumentRange()

void KisImageAnimationInterface::setDocumentRange ( const KisTimeSpan range)

◆ setDocumentRangeEndFrame

void KisImageAnimationInterface::setDocumentRangeEndFrame ( int column)
slot

Definition at line 163 of file kis_image_animation_interface.cpp.

164{
165 KisTimeSpan newRange = KisTimeSpan::fromTimeToTime(m_d->documentRange.start(), column);
166 setDocumentRange(newRange);
167}
void setDocumentRange(const KisTimeSpan range)

References KisTimeSpan::fromTimeToTime(), m_d, and setDocumentRange().

◆ setDocumentRangeStartFrame

void KisImageAnimationInterface::setDocumentRangeStartFrame ( int column)
slot

Definition at line 157 of file kis_image_animation_interface.cpp.

158{
159 KisTimeSpan newRange = KisTimeSpan::fromTimeToTime(column, m_d->documentRange.end());
160 setDocumentRange(newRange);
161}

References KisTimeSpan::fromTimeToTime(), m_d, and setDocumentRange().

◆ setExportInitialFrameNumber()

void KisImageAnimationInterface::setExportInitialFrameNumber ( const int frameNum)

Definition at line 211 of file kis_image_animation_interface.cpp.

212{
213 m_d->exportInitialFrameNumber = frameNum;
214}

References m_d.

◆ setExportSequenceBaseName()

void KisImageAnimationInterface::setExportSequenceBaseName ( const QString & baseName)

Definition at line 201 of file kis_image_animation_interface.cpp.

202{
203 m_d->exportSequenceBaseName = baseName;
204}

References m_d.

◆ setExportSequenceFilePath()

void KisImageAnimationInterface::setExportSequenceFilePath ( const QString & filePath)

Definition at line 191 of file kis_image_animation_interface.cpp.

192{
193 m_d->exportSequenceFilePath = filePath;
194}

References m_d.

◆ setFramerate

void KisImageAnimationInterface::setFramerate ( int fps)
slot

Definition at line 226 of file kis_image_animation_interface.cpp.

227{
228 if (fps > 0) {
229 m_d->framerate = fps;
230 Q_EMIT sigFramerateChanged();
231 }
232}

References m_d, and sigFramerateChanged().

◆ sigDocumentRangeChanged

void KisImageAnimationInterface::sigDocumentRangeChanged ( )
signal

◆ sigFrameCancelled

void KisImageAnimationInterface::sigFrameCancelled ( )
signal

◆ sigFramerateChanged

void KisImageAnimationInterface::sigFramerateChanged ( )
signal

◆ sigFrameReady

void KisImageAnimationInterface::sigFrameReady ( int time)
signal

sigFrameReady notifies when an External frame has been regenerated and is available.

Parameters
time– frame index

Used for background processing of frames where we want to ensure that an external frame has been fully processed before updating.

◆ sigFrameRegenerated

void KisImageAnimationInterface::sigFrameRegenerated ( int time)
signal

sigFrameRegenerated notifies when internal frame has been fully regenerated.

Parameters
time

Used to notify switchCurrentTimeAsync clients that the frame is visible to the user. Only notifies when internal frame regeneration occurs, not external. Currently used in AnimationPlayer to update what it considers to be the "visible" frame

◆ sigFrameRegenerationSkipped

void KisImageAnimationInterface::sigFrameRegenerationSkipped ( int time)
signal

sigFrameRegenerationSkipped notified when async frame changes are skipped.

Parameters
time

Skipping frame regeneration occurs when the contents of the frame are deemed unimportant and not work updating the canvas for (generally for image-wide hold frames, for example.)

◆ sigFramesChanged

void KisImageAnimationInterface::sigFramesChanged ( const KisTimeSpan & range,
const QRect & rect )
signal

◆ sigInternalRequestTimeSwitch

void KisImageAnimationInterface::sigInternalRequestTimeSwitch ( int frameId,
bool useUndo )
signal

◆ sigKeyframeAdded

void KisImageAnimationInterface::sigKeyframeAdded ( const KisKeyframeChannel * channel,
int time )
signal

◆ sigKeyframeRemoved

void KisImageAnimationInterface::sigKeyframeRemoved ( const KisKeyframeChannel * channel,
int time )
signal

◆ sigPlaybackRangeChanged

void KisImageAnimationInterface::sigPlaybackRangeChanged ( )
signal

◆ sigUiTimeChanged

void KisImageAnimationInterface::sigUiTimeChanged ( int newTime)
signal

◆ switchCurrentTimeAsync

void KisImageAnimationInterface::switchCurrentTimeAsync ( int frameId,
SwitchTimeAsyncFlags options = STAO_NONE )
slot

Switches current frame (synchronously) and starts an asynchronous regeneration of the entire image.

Definition at line 269 of file kis_image_animation_interface.cpp.

270{
271 const bool useUndo = options & STAO_USE_UNDO;
272 const bool sameFrame = currentUITime() == frameId;
273 const bool needsCompositingUpdate = requiresOnionSkinRendering();
275 const bool needsRegeneration = !range.contains(frameId) || needsCompositingUpdate || (options & STAO_FORCE_REGENERATION);
276
277 KisSwitchTimeStrokeStrategy::SharedTokenSP token = m_d->switchToken.toStrongRef();
278
279 // Handle switching frame to new time..
280 if (!token || !token->tryResetDestinationTime(frameId, needsRegeneration)) {
281
282 if (!sameFrame) {
283 KisPostExecutionUndoAdapter *undoAdapter = useUndo ?
284 m_d->image->postExecutionUndoAdapter() : 0;
285
287 new KisSwitchTimeStrokeStrategy(frameId, needsRegeneration,
288 this, undoAdapter);
289
290 m_d->switchToken = strategy->token();
291
292 KisStrokeId stroke = m_d->image->startStroke(strategy);
293 m_d->image->endStroke(stroke);
294 }
295
296 if (needsRegeneration) {
297 KisStrokeStrategy *strategy =
299
300 KisStrokeId strokeId = m_d->image->startStroke(strategy);
301 m_d->image->endStroke(strokeId);
302 }
303 }
304
305 if (!needsRegeneration) {
307 }
308
309
310
311 m_d->setCurrentUITime(frameId);
312 Q_EMIT sigUiTimeChanged(frameId);
313}
void sigUiTimeChanged(int newTime)
void sigFrameRegenerationSkipped(int time)
sigFrameRegenerationSkipped notified when async frame changes are skipped.
bool contains(int time) const
static KisTimeSpan calculateIdenticalFramesRecursive(const KisNode *node, int time)

References KisTimeSpan::calculateIdenticalFramesRecursive(), KisTimeSpan::contains(), currentUITime(), KisRegenerateFrameStrokeStrategy, KisSwitchTimeStrokeStrategy, m_d, requiresOnionSkinRendering(), sigFrameRegenerationSkipped(), sigUiTimeChanged(), STAO_FORCE_REGENERATION, STAO_USE_UNDO, and KisSwitchTimeStrokeStrategy::token().

◆ totalLength()

int KisImageAnimationInterface::totalLength ( )

Definition at line 468 of file kis_image_animation_interface.cpp.

469{
470 if (m_d->cachedLastFrameValue < 0) {
471 m_d->cachedLastFrameValue = findLastKeyframeTimeRecursive(m_d->image->root());
472 }
473
474 int lastKey = m_d->cachedLastFrameValue;
475
476 lastKey = std::max(lastKey, m_d->documentRange.end());
477 lastKey = std::max(lastKey, m_d->currentUITime());
478
479 return lastKey + 1;
480}
int findLastKeyframeTimeRecursive(KisNodeSP node)

References findLastKeyframeTimeRecursive(), and m_d.

◆ tryLockFrameGeneration()

bool KisImageAnimationInterface::tryLockFrameGeneration ( )

Try to acquire frame generation lock

See also
lockFrameGeneration()

Definition at line 497 of file kis_image_animation_interface.cpp.

498{
499 return m_d->frameGenerationLock.tryLock();
500}

References m_d.

◆ unblockBackgroundFrameGeneration()

void KisImageAnimationInterface::unblockBackgroundFrameGeneration ( )

Unblocks background generation process.

See also
blockBackgroundFrameGeneration()

Definition at line 487 of file kis_image_animation_interface.cpp.

488{
489 m_d->backgroundFrameGenerationBlocked.deref();
490}

References m_d.

◆ unlockFrameGeneration()

void KisImageAnimationInterface::unlockFrameGeneration ( )

Release frame generation lock

See also
lockFrameGeneration()

Definition at line 507 of file kis_image_animation_interface.cpp.

508{
509 m_d->frameGenerationLock.unlock();
510}

References m_d.

◆ updatesFacade()

KisUpdatesFacade * KisImageAnimationInterface::updatesFacade ( ) const
private

Definition at line 371 of file kis_image_animation_interface.cpp.

372{
373 return m_d->image;
374}

References m_d.

Friends And Related Symbol Documentation

◆ KisAnimationFrameCacheTest

friend class KisAnimationFrameCacheTest
friend

Definition at line 264 of file kis_image_animation_interface.h.

◆ KisImageTest

friend class KisImageTest
friend

Definition at line 266 of file kis_image_animation_interface.h.

◆ KisLayerUtils::SwitchFrameCommand

friend struct KisLayerUtils::SwitchFrameCommand
friend

Definition at line 265 of file kis_image_animation_interface.h.

◆ KisRegenerateFrameStrokeStrategy

friend class KisRegenerateFrameStrokeStrategy
friend

Definition at line 262 of file kis_image_animation_interface.h.

◆ KisSuspendProjectionUpdatesStrokeStrategy

Definition at line 263 of file kis_image_animation_interface.h.

◆ KisSwitchTimeStrokeStrategy

friend class KisSwitchTimeStrokeStrategy
friend

Definition at line 278 of file kis_image_animation_interface.h.

◆ TransformStrokeStrategy

friend class TransformStrokeStrategy
friend

Definition at line 279 of file kis_image_animation_interface.h.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisImageAnimationInterface::m_d
private

Definition at line 282 of file kis_image_animation_interface.h.


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