4#ifndef ASYNCIMAGEPROVIDER_H
5#define ASYNCIMAGEPROVIDER_H
7#include "asyncimageproviderbase.h"
8#include "asyncimagerenderthread.h"
9#include "rgbcolorspacefactory.h"
149class AsyncImageProvider final :
public AsyncImageProviderBase
156 virtual ~AsyncImageProvider() noexcept override;
158 [[nodiscard]]
QImage getCache() const;
159 [[nodiscard]] T imageParameters() const;
162 void setImageParameters(const T &newImageParameters);
165 Q_DISABLE_COPY(AsyncImageProvider)
168 friend class TestAsyncImageProvider;
170 void processInterlacingPassResult(const
QImage &deliveredImage);
186 bool m_lastRenderingRequestHasYetDeliveredAnImage = false;
189 std::optional<T> m_lastRenderingRequestImageParameters;
191 AsyncImageRenderThread m_renderThread;
199 : AsyncImageProviderBase(
parent)
200 , m_renderThread(&T::render)
204 qRegisterMetaType<T>();
207 &AsyncImageRenderThread::interlacingPassCompleted,
209 &AsyncImageProvider<T>::processInterlacingPassResult);
214AsyncImageProvider<T>::~AsyncImageProvider() noexcept
224QImage AsyncImageProvider<T>::getCache()
const
246void AsyncImageProvider<T>::setImageParameters(
const T &newImageParameters)
248 m_imageParameters = newImageParameters;
264T AsyncImageProvider<T>::imageParameters()
const
266 return m_imageParameters;
289void AsyncImageProvider<T>::processInterlacingPassResult(
const QImage &deliveredImage)
291 m_cache = deliveredImage;
292 Q_EMIT interlacingPassCompleted();
298void AsyncImageProvider<T>::refreshAsync()
300 if (imageParameters() == m_lastRenderingRequestImageParameters) {
304 m_lastRenderingRequestImageParameters = imageParameters();
309void AsyncImageProvider<T>::refreshSync()
312 m_renderThread.waitForIdle();
The namespace of this library.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
QVariant fromValue(T &&value)