Commit 512c29ec authored by Marco Martin's avatar Marco Martin

use QtConcurrent for pixels iteration

parent d080e7f5
......@@ -6,7 +6,7 @@ set(bigscreen_SRCS
)
add_library(bigscreenplugin SHARED ${bigscreen_SRCS})
target_link_libraries(bigscreenplugin Qt5::Core Qt5::Qml Qt5::Quick)
target_link_libraries(bigscreenplugin Qt5::Core Qt5::Qml Qt5::Quick Qt5::Concurrent)
install(TARGETS bigscreenplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/mycroft/bigscreen)
......
This diff is collapsed.
......@@ -25,9 +25,28 @@
#include <QQuickItemGrabResult>
#include <QPointer>
#include <QQuickWindow>
#include <QFuture>
class QTimer;
struct ImageData {
struct colorStat {
QList<QRgb> colors;
QRgb centroid = 0;
qreal ratio = 0;
};
QList<QRgb> m_samples;
QList<colorStat> m_clusters;
QVariantList m_palette;
QColor m_dominant;
QColor m_suggestedContrast;
QColor m_mostSaturated;
QColor m_closestToBlack;
QColor m_closestToWhite;
};
class ImagePalette : public QObject
{
Q_OBJECT
......@@ -69,14 +88,8 @@ Q_SIGNALS:
void closestToWhiteChanged();
private:
inline void positionColor(QRgb rgb);
void generatePalette();
struct colorStat {
QList<QRgb> colors;
QRgb centroid = 0;
qreal ratio = 0;
};
inline void positionColor(QRgb rgb, QList<ImageData::colorStat> &clusters);
ImageData generatePalette(const QImage &sourceImage);
// Arbitrary number that seems to work well
const int s_minimumSquareDistance = 32000;
......@@ -85,15 +98,11 @@ private:
QPointer<QQuickItem> m_sourceItem;
QSharedPointer<QQuickItemGrabResult> m_grabResult;
QImage m_sourceImage;
QList<QRgb> m_samples;
QList<colorStat> m_clusters;
QVariantList m_palette;
QTimer *m_imageSyncTimer;
QColor m_dominant;
QColor m_suggestedContrast;
QColor m_mostSaturated;
QColor m_closestToBlack;
QColor m_closestToWhite;
QFutureWatcher<ImageData> *m_futureImageData = nullptr;
ImageData m_imageData;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment