|
Krita Source Code Documentation
|
#include <KisAsyncAnimationRendererBase.h>
Inheritance diagram for KisAsyncAnimationRendererBase:Public Types | |
| enum | CancelReason { UserCancelled = 0 , RenderingFailed , RenderingTimedOut } |
| enum | Flag { None = 0x0 , Cancellable = 0x1 } |
Public Slots | |
| void | cancelCurrentFrameRendering (CancelReason cancelReason) |
| cancels current rendering operation | |
Signals | |
| void | sigFrameCancelled (int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason) |
| void | sigFrameCompleted (int frame) |
Public Member Functions | |
| bool | isActive () const |
| KisAsyncAnimationRendererBase (QObject *parent=0) | |
| void | startFrameRegeneration (KisImageSP image, int frame, const KisRegion ®ionOfInterest, 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) | |
Public Attributes | |
| KisSignalAutoConnectionsStore | imageRequestConnections |
| bool | isCancelled = false |
| QTimer | regenerationTimeout |
| int | requestedFrame = -1 |
| KisImageSP | requestedImage |
| KisRegion | requestedRegion |
Public Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
Protected Slots | |
| void | notifyFrameCancelled (int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason) |
| void | notifyFrameCompleted (int frame) |
Protected Member Functions | |
| virtual void | clearFrameRegenerationState (bool isCancelled) |
| virtual void | frameCancelledCallback (int frame, CancelReason cancelReason)=0 |
| frameCancelledCallback is called when the rendering of the frame was cancelled. | |
| virtual void | frameCompletedCallback (int frame, const KisRegion &requestedRegion)=0 |
| frameCompletedCallback is called by the renderer when a new frame becomes ready | |
| KisImageSP | requestedImage () const |
Private Slots | |
| void | slotFrameRegenerationCancelled () |
| void | slotFrameRegenerationFinished (int frame) |
| void | slotFrameRegenerationTimedOut () |
Private Attributes | |
| const QScopedPointer< Private > | m_d |
KisAsyncAnimationRendererBase is a special class representing a single worker thread inside KisAsyncAnimationRenderDialogBase. It connects the specified image using correct Qt::DirectConnection connections and reacts on them. On sigFrameReady() signal it calls frameCompletedCallback(), so the derived class can fetch a frame from the image and process it. On sigFrameCancelled() it calls frameCancelledCallback(). The derived class should override these two methods to do the actual work.
Definition at line 23 of file KisAsyncAnimationRendererBase.cpp.
| Enumerator | |
|---|---|
| UserCancelled | |
| RenderingFailed | |
| RenderingTimedOut | |
Definition at line 40 of file KisAsyncAnimationRendererBase.h.
| Enumerator | |
|---|---|
| None | |
| Cancellable | |
Definition at line 33 of file KisAsyncAnimationRendererBase.h.
|
explicit |
Definition at line 35 of file KisAsyncAnimationRendererBase.cpp.
References connect(), KisImageConfig::frameRenderingTimeout(), m_d, and slotFrameRegenerationTimedOut().
|
virtual |
Definition at line 47 of file KisAsyncAnimationRendererBase.cpp.
|
slot |
cancels current rendering operation
After calling this slot requestedImage() becomes invalid.
Definition at line 88 of file KisAsyncAnimationRendererBase.cpp.
References frameCancelledCallback(), KIS_SAFE_ASSERT_RECOVER_RETURN, and m_d.
|
protectedvirtual |
Called by KisAsyncAnimationRendererBase when the processing has been completed and the internal state of the populator should be cleared
| isCancelled | tells if frame regeneration has failed to be regenerated |
Reimplemented in KisAsyncAnimationCacheRenderer, and KisAsyncStoryboardThumbnailRenderer.
Definition at line 165 of file KisAsyncAnimationRendererBase.cpp.
References isCancelled, and m_d.
|
protectedpure virtual |
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.
Implemented in KisAsyncAnimationCacheRenderer, KisAsyncAnimationFramesSavingRenderer, and KisAsyncStoryboardThumbnailRenderer.
|
protectedpure virtual |
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.
Implemented in KisAsyncAnimationCacheRenderer, KisAsyncAnimationFramesSavingRenderer, and KisAsyncStoryboardThumbnailRenderer.
| bool KisAsyncAnimationRendererBase::isActive | ( | ) | const |
Definition at line 83 of file KisAsyncAnimationRendererBase.cpp.
References m_d.
|
protectedslot |
Called by a derived class to cancel processing of the frames. After calling this method, the dialog will stop processing the frames and close.
Definition at line 144 of file KisAsyncAnimationRendererBase.cpp.
References clearFrameRegenerationState(), KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and sigFrameCancelled().
|
protectedslot |
Called by a derived class to continue processing of the frames
Definition at line 122 of file KisAsyncAnimationRendererBase.cpp.
References clearFrameRegenerationState(), KIS_SAFE_ASSERT_RECOVER_NOOP, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and sigFrameCompleted().
|
protected |
Please note that requestedImage() will become null as soon as the user cancels the processing. That happens in the GUI thread so frameCompletedCallback() should be extremely careful when requesting the value (check the shared pointer after fetching).
|
signal |
|
signal |
|
privateslot |
Definition at line 94 of file KisAsyncAnimationRendererBase.cpp.
References frameCancelledCallback(), m_d, and RenderingFailed.
|
privateslot |
Definition at line 108 of file KisAsyncAnimationRendererBase.cpp.
References frameCompletedCallback(), KIS_SAFE_ASSERT_RECOVER_NOOP, and m_d.
|
privateslot |
Definition at line 101 of file KisAsyncAnimationRendererBase.cpp.
References frameCancelledCallback(), m_d, and RenderingTimedOut.
| void KisAsyncAnimationRendererBase::startFrameRegeneration | ( | KisImageSP | image, |
| int | frame, | ||
| const KisRegion & | regionOfInterest, | ||
| Flags | flags, | ||
| KisLockFrameGenerationLock && | frameGenerationLock ) |
Initiates the rendering of the frame frame on an image image. Only regionOfInterest is regenerated. If regionOfInterest is empty, then entire bounds of the image is regenerated.
Definition at line 52 of file KisAsyncAnimationRendererBase.cpp.
References KisImage::bounds(), Cancellable, KisRegion::isEmpty(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, KisImageAnimationInterface::requestFrameRegeneration(), sigFrameCancelled(), slotFrameRegenerationCancelled(), and slotFrameRegenerationFinished().
| void KisAsyncAnimationRendererBase::startFrameRegeneration | ( | KisImageSP | image, |
| int | frame, | ||
| Flags | flags, | ||
| KisLockFrameGenerationLock && | frameGenerationLock ) |
Convenience overload that regenerates the full image
Definition at line 78 of file KisAsyncAnimationRendererBase.cpp.
References startFrameRegeneration().
| KisSignalAutoConnectionsStore KisAsyncAnimationRendererBase::imageRequestConnections |
Definition at line 26 of file KisAsyncAnimationRendererBase.cpp.
| bool KisAsyncAnimationRendererBase::isCancelled = false |
Definition at line 31 of file KisAsyncAnimationRendererBase.cpp.
|
private |
Definition at line 150 of file KisAsyncAnimationRendererBase.h.
| QTimer KisAsyncAnimationRendererBase::regenerationTimeout |
Definition at line 27 of file KisAsyncAnimationRendererBase.cpp.
| int KisAsyncAnimationRendererBase::requestedFrame = -1 |
Definition at line 30 of file KisAsyncAnimationRendererBase.cpp.
| KisImageSP KisAsyncAnimationRendererBase::requestedImage |
Definition at line 29 of file KisAsyncAnimationRendererBase.cpp.
| KisRegion KisAsyncAnimationRendererBase::requestedRegion |
Definition at line 32 of file KisAsyncAnimationRendererBase.cpp.