Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_update_scheduler.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef __KIS_UPDATE_SCHEDULER_H
8#define __KIS_UPDATE_SCHEDULER_H
9
10#include <QObject>
11#include "kritaimage_export.h"
12#include "kis_types.h"
13
17#include "KisLodPreferences.h"
19
20class QRect;
21class KoProgressProxy;
25
26
27class KRITAIMAGE_EXPORT KisUpdateScheduler : public QObject, public KisStrokesFacade
28{
29 Q_OBJECT
30
31public:
32 KisUpdateScheduler(KisProjectionUpdateListener *projectionUpdateListener, QObject *parent = 0);
33 ~KisUpdateScheduler() override;
34
38 void setThreadsLimit(int value);
39
43 int threadsLimit() const;
44
52 void setProgressProxy(KoProgressProxy *progressProxy);
53
63 void immediateLockForReadOnly();
64
70 void unlock(bool resetLodLevels = true);
71
80 void waitForDone();
81
91 void barrierLock();
92
93
100 bool tryBarrierLock();
101
106 bool isIdle();
107
119 void blockUpdates();
120
126 void unblockUpdates();
127
128 void updateProjection(KisNodeSP node, const QVector<QRect> &rects, const QRect &cropRect, KisProjectionUpdateFlags flags);
129 void fullRefreshAsync(KisNodeSP root, const QVector<QRect>& rects, const QRect &cropRect, KisProjectionUpdateFlags flags);
130
131 // simplified override for testing purposes
132 void updateProjection(KisNodeSP node, const QRect &rc, const QRect &cropRect);
133
134 // simplified override for testing purposes
135 void fullRefreshAsync(KisNodeSP root, const QRect &rc, const QRect &cropRect);
136
137 void addSpontaneousJob(KisSpontaneousJob *spontaneousJob);
138
139 bool hasUpdatesRunning() const;
140
141 KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy) override;
142 void addJob(KisStrokeId id, KisStrokeJobData *data) override;
143 void endStroke(KisStrokeId id) override;
144 bool cancelStroke(KisStrokeId id) override;
145
152 void setLodPreferences(const KisLodPreferences &value);
153
157 KisLodPreferences lodPreferences() const;
158
164 void explicitRegenerateLevelOfDetail();
165
171 void setLod0ToNStrokeStrategyFactory(const KisLodSyncStrokeStrategyFactory &factory);
172
178 void setSuspendResumeUpdatesStrokeStrategyFactory(const KisSuspendResumeStrategyPairFactory &factory);
179
185 void setPurgeRedoStateCallback(const std::function<void()> &callback);
186
195 void setPostSyncLod0GUIPlaneRequestForResumeCallback(const std::function<void()> &callback);
196
197 KisPostExecutionUndoAdapter* lodNPostExecutionUndoAdapter() const;
198
199
212 bool tryCancelCurrentStrokeAsync();
213
214 UndoResult tryUndoLastStrokeAsync();
215
216 bool wrapAroundModeSupported() const;
217 int currentLevelOfDetail() const;
218
219 void continueUpdate(const QRect &rect);
220 void doSomeUsefulWork();
221 void spareThreadAppeared();
222
223protected:
224 // Trivial constructor for testing support
226 void connectSignals();
227 void processQueues();
228
229protected Q_SLOTS:
233 void updateSettings();
234
235private:
236 friend class UpdatesBlockTester;
237 bool haveUpdatesRunning();
238 void tryProcessUpdatesQueue();
239 void wakeUpWaitingThreads();
240
241 void progressUpdate();
242
243protected:
244 struct Private;
245 Private * const m_d;
246};
247
248
251
252class KRITAIMAGE_EXPORT KisTestableUpdateScheduler : public KisUpdateScheduler
253{
254public:
256 qint32 threadCount);
257
258 KisUpdaterContext* updaterContext();
260};
261
262#endif /* __KIS_UPDATE_SCHEDULER_H */
263
float value(const T *src, size_t ch)
virtual KisStrokeId startStroke(KisStrokeStrategy *strokeStrategy)=0
virtual void endStroke(KisStrokeId id)=0
virtual void addJob(KisStrokeId id, KisStrokeJobData *data)=0
virtual bool cancelStroke(KisStrokeId id)=0
std::function< std::pair< KisSuspendResumePair, KisSuspendResumePair >()> KisSuspendResumeStrategyPairFactory
std::function< KisLodSyncPair(bool)> KisLodSyncStrokeStrategyFactory