6#include "asyncimagerenderthread.h"
20AsyncImageRenderThread::AsyncImageRenderThread(
const pointerToRenderFunction &renderFunction, QObject *parent)
22 , m_renderFunction(renderFunction)
24 qRegisterMetaType<PerceptualColor::AsyncImageRenderCallback::InterlacingState>();
32AsyncImageRenderThread::~AsyncImageRenderThread()
36 m_loopCondition.wakeOne();
46 m_syncCondition.wakeAll();
62void AsyncImageRenderThread::startRenderingAsync(
const QVariant ¶meters)
64#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
70 if (m_imageParameters == parameters) {
75 m_imageParameters = parameters;
78#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
86#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0))
89 setServiceLevel(QThread::QualityOfService::High);
95 m_loopCondition.wakeOne();
105void AsyncImageRenderThread::run()
109 const QVariant parameters = m_imageParameters;
110 m_loopMutex.unlock();
129 m_renderFunction(parameters, *
this);
142 if (!m_loopRestart && !m_loopAbort) {
143#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
149 m_syncCondition.wakeOne();
151 while (!m_loopRestart && !m_loopAbort) {
166 m_loopCondition.wait(&m_loopMutex);
168 m_loopRestart =
false;
169 m_loopMutex.unlock();
195void AsyncImageRenderThread::deliverInterlacingPass(
const QImage &image,
198 const AsyncImageRenderCallback::InterlacingState state)
203 Q_EMIT interlacingPassCompleted(image, mask, parameters, state);
216bool AsyncImageRenderThread::shouldAbort()
const
219 return (m_loopAbort || m_loopRestart);
223void AsyncImageRenderThread::waitForIdle()
226 while (!m_syncIsIdle) {
241 m_syncCondition.wait(&m_syncMutex);
243 m_syncMutex.unlock();
Q_SCRIPTABLE Q_NOREPLY void start()
The namespace of this library.