2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#ifndef RENDERTHREAD_H
|
|
|
|
#define RENDERTHREAD_H
|
|
|
|
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QSize>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QWaitCondition>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QImage;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
//! [0]
|
|
|
|
class RenderThread : public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-02-03 16:09:10 +00:00
|
|
|
RenderThread(QObject *parent = nullptr);
|
2011-04-27 10:05:43 +00:00
|
|
|
~RenderThread();
|
|
|
|
|
2020-01-14 12:36:39 +00:00
|
|
|
void render(double centerX, double centerY, double scaleFactor, QSize resultSize,
|
|
|
|
double devicePixelRatio);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2021-04-07 20:14:23 +00:00
|
|
|
static void setNumPasses(int n) { numPasses = n; }
|
|
|
|
|
|
|
|
static QString infoKey() { return QStringLiteral("info"); }
|
|
|
|
|
2011-04-27 10:05:43 +00:00
|
|
|
signals:
|
|
|
|
void renderedImage(const QImage &image, double scaleFactor);
|
|
|
|
|
|
|
|
protected:
|
2016-06-15 08:12:35 +00:00
|
|
|
void run() override;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private:
|
2020-01-14 07:31:02 +00:00
|
|
|
static uint rgbFromWaveLength(double wave);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
QMutex mutex;
|
|
|
|
QWaitCondition condition;
|
|
|
|
double centerX;
|
|
|
|
double centerY;
|
|
|
|
double scaleFactor;
|
2020-01-14 12:36:39 +00:00
|
|
|
double devicePixelRatio;
|
2011-04-27 10:05:43 +00:00
|
|
|
QSize resultSize;
|
2021-04-07 20:14:23 +00:00
|
|
|
static int numPasses;
|
2020-01-14 07:31:02 +00:00
|
|
|
bool restart = false;
|
|
|
|
bool abort = false;
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
enum { ColormapSize = 512 };
|
|
|
|
uint colormap[ColormapSize];
|
|
|
|
};
|
|
|
|
//! [0]
|
|
|
|
|
2012-11-23 13:27:50 +00:00
|
|
|
#endif // RENDERTHREAD_H
|