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

#include <KisAsyncAnimationCacheRenderer.h>

+ Inheritance diagram for KisAsyncAnimationCacheRenderer:

Classes

struct  Private
 

Signals

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

Public Member Functions

 KisAsyncAnimationCacheRenderer ()
 
void setFrameCache (KisAnimationFrameCacheSP cache)
 
 ~KisAsyncAnimationCacheRenderer ()
 
- 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 clearFrameRegenerationState (bool isCancelled) override
 
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
KisImageSP requestedImage () const
 

Private Slots

void slotCompleteRegenerationInternal (int frame)
 

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 12 of file KisAsyncAnimationCacheRenderer.h.

Constructor & Destructor Documentation

◆ KisAsyncAnimationCacheRenderer()

KisAsyncAnimationCacheRenderer::KisAsyncAnimationCacheRenderer ( )

Definition at line 19 of file KisAsyncAnimationCacheRenderer.cpp.

20 : m_d(new Private)
21{
22 connect(this, SIGNAL(sigCompleteRegenerationInternal(int)), SLOT(slotCompleteRegenerationInternal(int)), Qt::QueuedConnection);
23}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void sigCompleteRegenerationInternal(int frame)

References connect(), sigCompleteRegenerationInternal(), and slotCompleteRegenerationInternal().

◆ ~KisAsyncAnimationCacheRenderer()

KisAsyncAnimationCacheRenderer::~KisAsyncAnimationCacheRenderer ( )

Definition at line 25 of file KisAsyncAnimationCacheRenderer.cpp.

26{
27}

Member Function Documentation

◆ clearFrameRegenerationState()

void KisAsyncAnimationCacheRenderer::clearFrameRegenerationState ( bool isCancelled)
overrideprotectedvirtual

Called by KisAsyncAnimationRendererBase when the processing has been completed and the internal state of the populator should be cleared

Parameters
isCancelledtells if frame regeneration has failed to be regenerated

Reimplemented from KisAsyncAnimationRendererBase.

Definition at line 69 of file KisAsyncAnimationCacheRenderer.cpp.

70{
71 m_d->requestInfo.clear();
72 m_d->requestedCache = nullptr; // TODO: implement clear() for weak pointers
73
75}
virtual void clearFrameRegenerationState(bool isCancelled)

References KisAsyncAnimationRendererBase::clearFrameRegenerationState(), KisAsyncAnimationRendererBase::isCancelled, and m_d.

◆ frameCancelledCallback()

void KisAsyncAnimationCacheRenderer::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 64 of file KisAsyncAnimationCacheRenderer.cpp.

65{
66 notifyFrameCancelled(frame, cancelReason);
67}
void notifyFrameCancelled(int frame, KisAsyncAnimationRendererBase::CancelReason cancelReason)

References KisAsyncAnimationRendererBase::notifyFrameCancelled().

◆ frameCompletedCallback()

void KisAsyncAnimationCacheRenderer::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 34 of file KisAsyncAnimationCacheRenderer.cpp.

35{
36 KisAnimationFrameCacheSP cache = m_d->requestedCache;
37 KisImageSP image = requestedImage();
38 if (!cache || !image) return;
39
40 m_d->requestInfo = cache->fetchFrameData(frame, image, requestedRegion);
42}
KisOpenGLUpdateInfoSP fetchFrameData(int time, KisImageSP image, const KisRegion &requestedRegion) const

References KisAnimationFrameCache::fetchFrameData(), m_d, KisAsyncAnimationRendererBase::requestedImage, KisAsyncAnimationRendererBase::requestedRegion, and sigCompleteRegenerationInternal().

◆ setFrameCache()

void KisAsyncAnimationCacheRenderer::setFrameCache ( KisAnimationFrameCacheSP cache)

Definition at line 29 of file KisAsyncAnimationCacheRenderer.cpp.

30{
31 m_d->requestedCache = cache;
32}

References m_d.

◆ sigCompleteRegenerationInternal

void KisAsyncAnimationCacheRenderer::sigCompleteRegenerationInternal ( int frame)
signal

◆ slotCompleteRegenerationInternal

void KisAsyncAnimationCacheRenderer::slotCompleteRegenerationInternal ( int frame)
privateslot

Definition at line 44 of file KisAsyncAnimationCacheRenderer.cpp.

45{
46 if (!isActive()) return;
47
48 KIS_SAFE_ASSERT_RECOVER(m_d->requestInfo) {
50 return;
51 }
52
53 KisAnimationFrameCacheSP cache = m_d->requestedCache;
54 if (!cache) {
56 return;
57 }
58
59 cache->addConvertedFrameData(m_d->requestInfo, frame);
61}
void addConvertedFrameData(KisOpenGLUpdateInfoSP info, int time)
void frameCancelledCallback(int frame, CancelReason cancelReason) override
frameCancelledCallback is called when the rendering of the frame was cancelled.
#define KIS_SAFE_ASSERT_RECOVER(cond)
Definition kis_assert.h:126

References KisAnimationFrameCache::addConvertedFrameData(), frameCancelledCallback(), KisAsyncAnimationRendererBase::isActive(), KIS_SAFE_ASSERT_RECOVER, m_d, KisAsyncAnimationRendererBase::notifyFrameCompleted(), KisAsyncAnimationRendererBase::RenderingFailed, and KisAsyncAnimationRendererBase::UserCancelled.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisAsyncAnimationCacheRenderer::m_d
private

Definition at line 35 of file KisAsyncAnimationCacheRenderer.h.


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