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

#include <kis_animation_cache_populator.h>

+ Inheritance diagram for KisAnimationCachePopulator:

Classes

struct  Private
 

Public Slots

void slotRequestRegeneration ()
 

Public Member Functions

 KisAnimationCachePopulator (KisPart *part)
 
bool regenerate (KisAnimationFrameCacheSP cache, int frame)
 
void requestRegenerationWithPriorityFrame (KisImageSP image, int frameIndex)
 
 ~KisAnimationCachePopulator () override
 

Private Slots

void slotConfigChanged ()
 
void slotRegeneratorFrameCancelled ()
 
void slotRegeneratorFrameReady ()
 
void slotTimer ()
 

Private Attributes

QScopedPointer< Privatem_d
 

Detailed Description

Definition at line 15 of file kis_animation_cache_populator.h.

Constructor & Destructor Documentation

◆ KisAnimationCachePopulator()

KisAnimationCachePopulator::KisAnimationCachePopulator ( KisPart * part)

Definition at line 336 of file kis_animation_cache_populator.cpp.

337 : m_d(new Private(this, part))
338{
339 connect(&m_d->timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
340
341 connect(&m_d->regenerator, SIGNAL(sigFrameCancelled(int, KisAsyncAnimationRendererBase::CancelReason)), SLOT(slotRegeneratorFrameCancelled()));
342 connect(&m_d->regenerator, SIGNAL(sigFrameCompleted(int)), SLOT(slotRegeneratorFrameReady()));
343
344 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
346}
quint64 part(quint64 n1, quint64 n2, int p)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
static KisConfigNotifier * instance()

References connect(), KisConfigNotifier::instance(), m_d, slotConfigChanged(), slotRegeneratorFrameCancelled(), slotRegeneratorFrameReady(), and slotTimer().

◆ ~KisAnimationCachePopulator()

KisAnimationCachePopulator::~KisAnimationCachePopulator ( )
override

Definition at line 348 of file kis_animation_cache_populator.cpp.

349{
350 m_d->priorityFrames.clear();
351}

References m_d.

Member Function Documentation

◆ regenerate()

bool KisAnimationCachePopulator::regenerate ( KisAnimationFrameCacheSP cache,
int frame )

Request generation of given frame. The request will be ignored if the populator is already requesting a frame.

Returns
true if generation requested, false if busy

Definition at line 353 of file kis_animation_cache_populator.cpp.

354{
355 return m_d->regenerate(cache, frame);
356}

References m_d.

◆ requestRegenerationWithPriorityFrame()

void KisAnimationCachePopulator::requestRegenerationWithPriorityFrame ( KisImageSP image,
int frameIndex )

Definition at line 358 of file kis_animation_cache_populator.cpp.

359{
360 if (!m_d->calculateAnimationCacheInBackground) return;
361 if (!KisAnimationFrameCache::cacheForImage(image)) return;
362 if (!image->animationInterface()->hasAnimation()) return;
363
364 m_d->priorityFrames.append(qMakePair(image, frameIndex));
365
366 if (m_d->state == Private::NotWaitingForAnything) {
367 m_d->generateIfIdle();
368 }
369}
static const KisAnimationFrameCacheSP cacheForImage(KisImageWSP image)
KisImageAnimationInterface * animationInterface() const

References KisImage::animationInterface(), KisAnimationFrameCache::cacheForImage(), KisImageAnimationInterface::hasAnimation(), m_d, and KisAnimationCachePopulator::Private::NotWaitingForAnything.

◆ slotConfigChanged

void KisAnimationCachePopulator::slotConfigChanged ( )
privateslot

Definition at line 395 of file kis_animation_cache_populator.cpp.

396{
397 KisConfig cfg(true);
398 m_d->calculateAnimationCacheInBackground = cfg.calculateAnimationCacheInBackground();
399 QTimer::singleShot(1000, Qt::CoarseTimer, this, SLOT(slotRequestRegeneration()));
400}

References KisConfig::calculateAnimationCacheInBackground(), m_d, and slotRequestRegeneration().

◆ slotRegeneratorFrameCancelled

◆ slotRegeneratorFrameReady

void KisAnimationCachePopulator::slotRegeneratorFrameReady ( )
privateslot

◆ slotRequestRegeneration

void KisAnimationCachePopulator::slotRequestRegeneration ( )
slot

Definition at line 376 of file kis_animation_cache_populator.cpp.

377{
378 // skip if the user forbade background regeneration
379 if (!m_d->calculateAnimationCacheInBackground) return;
380
381 m_d->enterState(Private::WaitingForIdle);
382}

References m_d, and KisAnimationCachePopulator::Private::WaitingForIdle.

◆ slotTimer

void KisAnimationCachePopulator::slotTimer ( )
privateslot

Definition at line 371 of file kis_animation_cache_populator.cpp.

372{
373 m_d->timerTimeout();
374}

References m_d.

Member Data Documentation

◆ m_d

QScopedPointer<Private> KisAnimationCachePopulator::m_d
private

Definition at line 44 of file kis_animation_cache_populator.h.


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