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

#include <KisAsyncAnimationFramesSavingRenderer.h>

+ Inheritance diagram for KisAsyncAnimationFramesSavingRenderer:

Classes

struct  Private
 

Signals

void sigCancelRegenerationInternal (int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)
 
void sigCompleteRegenerationInternal (int frame)
 
- Signals inherited from KisAsyncAnimationRendererBase
void sigFrameCancelled (int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)
 
void sigFrameCompleted (int frame)
 

Public Member Functions

 KisAsyncAnimationFramesSavingRenderer (KisImageSP image, const QString &fileNamePrefix, const QString &fileNameSuffix, const QByteArray &outputMimeType, const KisTimeSpan &range, const int sequenceNumberingOffset, const bool onlyNeedsUniqueFrames, KisPropertiesConfigurationSP exportConfiguration)
 
 ~KisAsyncAnimationFramesSavingRenderer ()
 
- Public Member Functions inherited from KisAsyncAnimationRendererBase
bool isActive () const
 
 KisAsyncAnimationRendererBase (QObject *parent=0)
 
void startFrameRegeneration (KisImageSP image, int frame, const KisRegion &regionOfInterest, Flags flags, KisLockFrameGenerationLock &&frameGenerationLock)
 
void startFrameRegeneration (KisImageSP image, int frame, Flags flags, KisLockFrameGenerationLock &&frameGenerationLock)
 
virtual ~KisAsyncAnimationRendererBase ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Protected Member Functions

void frameCancelledCallback (int frame, CancelReason cancelReason) override
 frameCancelledCallback is called when the rendering of the frame was cancelled.
 
void frameCompletedCallback (int frame, const KisRegion &requestedRegion) override
 frameCompletedCallback is called by the renderer when a new frame becomes ready
 
- Protected Member Functions inherited from KisAsyncAnimationRendererBase
virtual void clearFrameRegenerationState (bool isCancelled)
 
KisImageSP requestedImage () const
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Public Types inherited from KisAsyncAnimationRendererBase
enum  CancelReason { UserCancelled = 0 , RenderingFailed , RenderingTimedOut }
 
enum  Flag { None = 0x0 , Cancellable = 0x1 }
 
- Public Slots inherited from KisAsyncAnimationRendererBase
void cancelCurrentFrameRendering (CancelReason cancelReason)
 cancels current rendering operation
 
- Public Attributes inherited from KisAsyncAnimationRendererBase
KisSignalAutoConnectionsStore imageRequestConnections
 
bool isCancelled = false
 
QTimer regenerationTimeout
 
int requestedFrame = -1
 
KisImageSP requestedImage
 
KisRegion requestedRegion
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Slots inherited from KisAsyncAnimationRendererBase
void notifyFrameCancelled (int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)
 
void notifyFrameCompleted (int frame)
 

Detailed Description

Definition at line 15 of file KisAsyncAnimationFramesSavingRenderer.h.

Constructor & Destructor Documentation

◆ KisAsyncAnimationFramesSavingRenderer()

KisAsyncAnimationFramesSavingRenderer::KisAsyncAnimationFramesSavingRenderer ( KisImageSP image,
const QString & fileNamePrefix,
const QString & fileNameSuffix,
const QByteArray & outputMimeType,
const KisTimeSpan & range,
const int sequenceNumberingOffset,
const bool onlyNeedsUniqueFrames,
KisPropertiesConfigurationSP exportConfiguration )

Definition at line 61 of file KisAsyncAnimationFramesSavingRenderer.cpp.

69 : m_d(new Private(image, range, sequenceNumberingOffset, onlyNeedsUniqueFrames, exportConfiguration))
70{
71 m_d->filenamePrefix = fileNamePrefix;
72 m_d->filenameSuffix = fileNameSuffix;
73 m_d->outputMimeType = outputMimeType;
74
75 connect(this, SIGNAL(sigCompleteRegenerationInternal(int)), SLOT(notifyFrameCompleted(int)));
77}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void sigCancelRegenerationInternal(int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)
void sigCompleteRegenerationInternal(int frame)
void notifyFrameCancelled(int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)

References connect(), m_d, KisAsyncAnimationRendererBase::notifyFrameCancelled(), KisAsyncAnimationRendererBase::notifyFrameCompleted(), sigCancelRegenerationInternal(), and sigCompleteRegenerationInternal().

◆ ~KisAsyncAnimationFramesSavingRenderer()

KisAsyncAnimationFramesSavingRenderer::~KisAsyncAnimationFramesSavingRenderer ( )

Definition at line 82 of file KisAsyncAnimationFramesSavingRenderer.cpp.

83{
84}

Member Function Documentation

◆ frameCancelledCallback()

void KisAsyncAnimationFramesSavingRenderer::frameCancelledCallback ( int frame,
CancelReason cancelReason )
overrideprotectedvirtual

frameCancelledCallback is called when the rendering of the frame was cancelled.

The rendering of the frame can be either cancelled by the image itself or by receiving a timeout signal (10 seconds).

NOTE: the slot is called in the GUI thread. Don't forget to call notifyFrameCancelled() in he end of your call.

Implements KisAsyncAnimationRendererBase.

Definition at line 136 of file KisAsyncAnimationFramesSavingRenderer.cpp.

137{
138 notifyFrameCancelled(frame, cancelReason);
139}

References KisAsyncAnimationRendererBase::notifyFrameCancelled().

◆ frameCompletedCallback()

void KisAsyncAnimationFramesSavingRenderer::frameCompletedCallback ( int frame,
const KisRegion & requestedRegion )
overrideprotectedvirtual

frameCompletedCallback is called by the renderer when a new frame becomes ready

NOTE1: the callback is called from the context of a image worker thread! So it is asynchronous from the GUI thread. NOTE2: in case of successful processing of the frame, the callback must issue some signal, connected to notifyFrameCompleted() via auto connection, to continue processing. Please do not call the method directly, because notifyFame*() slots should be called from the context of the GUI thread. NOTE3: In case of failure, notifyFrameCancelled(). The same threading rules apply.

Implements KisAsyncAnimationRendererBase.

Definition at line 86 of file KisAsyncAnimationFramesSavingRenderer.cpp.

87{
88 KisImageSP image = requestedImage();
89 if (!image) return;
90
93 return;
94 }
95
96 m_d->savingDevice->makeCloneFromRough(image->projection(), image->bounds());
97
99
100 QString frameNumber = QString("%1").arg(frame + m_d->sequenceNumberingOffset, 4, 10, QChar('0'));
101 QString filename = m_d->filenamePrefix + frameNumber + m_d->filenameSuffix;
102
103 if (!m_d->savingDoc->exportDocumentSync(filename, m_d->outputMimeType, m_d->exportConfiguration)) {
105 }
106
107 //Get all identical frames to this one and either copy or symlink based on settings.
109 identicals &= m_d->range;
110 if( !m_d->onlyNeedsUniqueFrames && identicals.start() < identicals.end() ) {
111 for (int identicalFrame = (identicals.start() + 1); identicalFrame <= identicals.end(); identicalFrame++) {
112 QString identicalFrameNumber = QString("%1").arg(identicalFrame + m_d->sequenceNumberingOffset, 4, 10, QChar('0'));
113 QString identicalFrameName = m_d->filenamePrefix + identicalFrameNumber + m_d->filenameSuffix;
114
115 QFile::copy(filename, identicalFrameName);
116
117 /* This would be nice to do but sym-linking on windows isn't possible without
118 * way more other work to be done. This works on linux though!
119 *
120 * if (m_d->linkRedundantFrames) {
121 * QFile::link(filename, identicalFrameName);
122 * } else {
123 * QFile::copy(filename, identicalFrameName);
124 * }
125 */
126 }
127 }
128
129 if (status.isOk()) {
131 } else {
133 }
134}
KisPaintDeviceSP projection() const
QRect bounds() const override
int start() const
static KisTimeSpan calculateIdenticalFramesRecursive(const KisNode *node, int time)
int end() const
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KisImage::bounds(), KisTimeSpan::calculateIdenticalFramesRecursive(), KisTimeSpan::end(), ImportExportCodes::InternalError, KisImportExportErrorCode::isOk(), KIS_SAFE_ASSERT_RECOVER, m_d, ImportExportCodes::OK, KisImage::projection(), KisAsyncAnimationRendererBase::RenderingFailed, KisAsyncAnimationRendererBase::requestedImage, KisAsyncAnimationRendererBase::requestedRegion, KisNodeFacade::root, sigCancelRegenerationInternal(), sigCompleteRegenerationInternal(), and KisTimeSpan::start().

◆ sigCancelRegenerationInternal

void KisAsyncAnimationFramesSavingRenderer::sigCancelRegenerationInternal ( int frame,
KisAsyncAnimationRendererBase::CancelReason cancelReason )
signal

◆ sigCompleteRegenerationInternal

void KisAsyncAnimationFramesSavingRenderer::sigCompleteRegenerationInternal ( int frame)
signal

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisAsyncAnimationFramesSavingRenderer::m_d
private

Definition at line 39 of file KisAsyncAnimationFramesSavingRenderer.h.


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