Krita Source Code Documentation
Loading...
Searching...
No Matches
recorder_writer.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Dmitrii Utkin <loentar@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#ifndef RECORDER_WRITER_H
8#define RECORDER_WRITER_H
9
10#include "kis_types.h"
11#include "recorder_format.h"
12
13#include <QObject>
14#include <QPointer>
15#include <QMutex>
16
18class RecorderConfig;
19class KisCanvas2;
20class QDir;
21
33
34// This class is used to provide mechanism ro sync the number of available
35// and used recording threads between the GUI and the RecorderWriterManager
36class ThreadCounter : public QObject
37{
38 Q_OBJECT
39public:
40 ThreadCounter() = default;
41 ThreadCounter(const ThreadCounter&) = delete;
45
46 bool set(int value);
47 void setAndNotify(int value);
48 unsigned int get() const;
49
50 bool setUsed(int value);
51 void setUsedAndNotify(int value);
52 void incUsedAndNotify();
53 void decUsedAndNotify();
54 unsigned int getUsed() const;
55
56Q_SIGNALS:
57 void notifyValueChange(bool valueWasIncreased);
58 void notifyInUseChange(bool valueWasIncreased);
59
60private:
61 bool setUsedImpl(int value);
62
63private:
64 unsigned int threads;
65 unsigned int inUse;
66 QMutex inUseMutex;
67};
68
69class RecorderWriter : public QObject
70{
71 Q_OBJECT
72public:
74 unsigned int i,
77 const QDir& d);
79
80 RecorderWriter() = delete;
85
86 bool isActive();
87
88Q_SIGNALS:
89 void capturingDone(int writerId, bool success);
90
91public Q_SLOTS:
92 void onCaptureImage(int writerId, int index, KisPaintDeviceSP device);
93
94private:
95 class Private;
96 Private *const d;
97 unsigned int id;
98};
99
100class RecorderWriterManager : public QObject
101{
102 Q_OBJECT
103public:
106
112
113 // restarts recorder
114 void setCanvas(QPointer<KisCanvas2> canvas);
115 // restarts recorder
116 void setup(const RecorderWriterSettings &settings);
117
118 void start(bool toggleEnabled = true);
119 bool stop(bool toggleEnabled = true);
120
121 void setEnabled(bool enabled);
122
123Q_SIGNALS:
124 void started();
125 void stopped();
129
130 void startCapturing(int writerId, int index, KisPaintDeviceSP device);
131
132private Q_SLOTS:
133 void onTimer();
134 void onCapturingDone(int workerId, bool success);
135 void onImageModified();
136 void onToolChanged(const QString &toolId);
137 void onToolPrimaryActionActivated(bool activated);
138
139public:
141
142private:
143 class Private;
144 Private *const d;
146
147};
148
149#endif // RECORDER_WRITER_H
float value(const T *src, size_t ch)
RecorderWriterManager()=delete
void start(bool toggleEnabled=true)
void onCapturingDone(int workerId, bool success)
void onToolPrimaryActionActivated(bool activated)
void startCapturing(int writerId, int index, KisPaintDeviceSP device)
RecorderWriterManager & operator=(RecorderWriterManager &&)=delete
void setCanvas(QPointer< KisCanvas2 > canvas)
bool stop(bool toggleEnabled=true)
void setEnabled(bool enabled)
void setup(const RecorderWriterSettings &settings)
ThreadCounter recorderThreads
RecorderWriterManager & operator=(const RecorderWriterManager &)=delete
const RecorderExportSettings & exporterSettings
RecorderWriterManager(const RecorderWriterManager &)=delete
void onToolChanged(const QString &toolId)
RecorderWriterManager(RecorderWriterManager &&)=delete
RecorderWriter()=delete
void onCaptureImage(int writerId, int index, KisPaintDeviceSP device)
unsigned int id
RecorderWriter(RecorderWriter &&)=delete
RecorderWriter & operator=(RecorderWriter &&)=delete
Private *const d
RecorderWriter & operator=(const RecorderWriter &)=delete
void capturingDone(int writerId, bool success)
RecorderWriter(const RecorderWriter &)=delete
void setUsedAndNotify(int value)
ThreadCounter(const ThreadCounter &)=delete
bool setUsedImpl(int value)
unsigned int getUsed() const
unsigned int get() const
void notifyValueChange(bool valueWasIncreased)
ThreadCounter(ThreadCounter &&)=delete
ThreadCounter & operator=(const ThreadCounter &)=delete
ThreadCounter()=default
unsigned int threads
void setAndNotify(int value)
bool setUsed(int value)
bool set(int value)
unsigned int inUse
ThreadCounter & operator=(ThreadCounter &&)=delete
void notifyInUseChange(bool valueWasIncreased)
RecorderFormat