Krita Source Code Documentation
Loading...
Searching...
No Matches
KisStabilizerDelayedPaintHelper.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Alvin Wong <alvinhochun-at-gmail-com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_STABILIZER_DELAYED_PAINT_HELPER_H
8#define KIS_STABILIZER_DELAYED_PAINT_HELPER_H
9
10#include <QElapsedTimer>
11#include <QQueue>
12#include <QTimer>
13#include <QVector>
14
15#include <functional>
16
18#include "kritaui_export.h"
19
20class KRITAUI_EXPORT KisStabilizerDelayedPaintHelper : public QObject
21{
22 Q_OBJECT
23
30
32 QQueue<TimedPaintInfo> m_paintQueue;
33 int m_lastPendingTime {0};
34 int m_lastPaintTime {0};
35 QElapsedTimer m_elapsedTimer;
36
37 // Callbacks
38 std::function<void(const KisPaintInformation &, const KisPaintInformation &)> m_paintLine;
39 std::function<void()> m_requestUpdateOutline;
40
41public:
44
45 bool running() const {
46 return m_paintTimer.isActive();
47 }
48
50 return !m_paintQueue.isEmpty();
51 }
52
54 // Please call hasLastPaintInformation before this
55 return m_paintQueue.head().paintInfo;
56 }
57
58 void setPaintLineCallback(std::function<void(const KisPaintInformation &, const KisPaintInformation &)> paintLine) {
59 m_paintLine = paintLine;
60 }
61
62 void setUpdateOutlineCallback(std::function<void()> requestUpdateOutline) {
63 m_requestUpdateOutline = requestUpdateOutline;
64 }
65
66 void start(const KisPaintInformation &firstPaintInfo);
67 void update(const QVector<KisPaintInformation> &newPaintInfos);
68 void paintSome();
69 void end();
70 void cancel();
71
72private Q_SLOTS:
73 void stabilizerDelayedPaintTimer();
74};
75
76#endif // KIS_STABILIZER_DELAYED_PAINT_HELPER_H
void setUpdateOutlineCallback(std::function< void()> requestUpdateOutline)
std::function< void(const KisPaintInformation &, const KisPaintInformation &) m_paintLine)
void setPaintLineCallback(std::function< void(const KisPaintInformation &, const KisPaintInformation &)> paintLine)
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)