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 "recorder_format.h"
11
12#include <QObject>
13#include <QPointer>
14#include <QMutex>
15
17class RecorderConfig;
18class KisCanvas2;
19class QDir;
20
32
33// This class is used to provide mechanism ro sync the number of available
34// and used recording threads between the GUI and the RecorderWriterManager
35class ThreadCounter : public QObject
36{
37 Q_OBJECT
38public:
39 ThreadCounter() = default;
40 ThreadCounter(const ThreadCounter&) = delete;
44
45 bool set(int value);
46 void setAndNotify(int value);
47 unsigned int get() const;
48
49 bool setUsed(int value);
50 void setUsedAndNotify(int value);
51 void incUsedAndNotify();
52 void decUsedAndNotify();
53 unsigned int getUsed() const;
54
55Q_SIGNALS:
56 void notifyValueChange(bool valueWasIncreased);
57 void notifyInUseChange(bool valueWasIncreased);
58
59private:
60 bool setUsedImpl(int value);
61
62private:
63 unsigned int threads;
64 unsigned int inUse;
65 QMutex inUseMutex;
66};
67
68class RecorderWriter : public QObject
69{
70 Q_OBJECT
71public:
73 unsigned int i,
76 const QDir& d);
78
79 RecorderWriter() = delete;
84
85Q_SIGNALS:
86 void capturingDone(int writerId, bool success);
87
88public Q_SLOTS:
89 void onCaptureImage(int writerId, int index);
90
91private:
92 class Private;
93 Private *const d;
94 unsigned int id;
95};
96
97class RecorderWriterManager : public QObject
98{
99 Q_OBJECT
100public:
103
109
110 // restarts recorder
111 void setCanvas(QPointer<KisCanvas2> canvas);
112 // restarts recorder
113 void setup(const RecorderWriterSettings &settings);
114
115 void start(bool toggleEnabled = true);
116 bool stop(bool toggleEnabled = true);
117
118 void setEnabled(bool enabled);
119
120Q_SIGNALS:
121 void started();
122 void stopped();
126
127 void startCapturing(int writerId, int index);
128
129private Q_SLOTS:
130 void onTimer();
131 void onCapturingDone(int workerId, bool success);
132 void onImageModified();
133 void onToolChanged(const QString &toolId);
134 void onToolPrimaryActionActivated(bool activated);
135
136public:
138
139private:
140 class Private;
141 Private *const d;
143
144};
145
146#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 startCapturing(int writerId, int index)
void onToolPrimaryActionActivated(bool activated)
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
unsigned int id
RecorderWriter(RecorderWriter &&)=delete
RecorderWriter & operator=(RecorderWriter &&)=delete
void onCaptureImage(int writerId, int index)
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