-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstroke_testing_utils.h
98 lines (74 loc) · 3.15 KB
/
stroke_testing_utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* SPDX-FileCopyrightText: 2011 Dmitry Kazakov <dimula73@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __STROKE_TESTING_UTILS_H
#define __STROKE_TESTING_UTILS_H
#include <QString>
#include <KoCanvasResourceProvider.h>
#include "kis_node.h"
#include "kis_types.h"
#include "kis_stroke_strategy.h"
#include "kis_resources_snapshot.h"
class KisUndoStore;
namespace utils {
KisImageSP createImage(KisUndoStore *undoStore, const QSize &imageSize);
KoCanvasResourceProvider* createResourceManager(KisImageWSP image,
KisNodeSP node = 0,
const QString &presetFileName = "autobrush_300px.kpp");
class StrokeTester
{
public:
StrokeTester(const QString &name, const QSize &imageSize, const QString &presetFileName = "autobrush_300px.kpp");
virtual ~StrokeTester();
void testSimpleStroke();
void test();
void benchmark();
void testSimpleStrokeNoVerification();
void setNumIterations(int value);
void setBaseFuzziness(int value);
int lastStrokeTime() const;
protected:
KisStrokeId strokeId() {
return m_strokeId;
}
virtual void modifyResourceManager(KoCanvasResourceProvider *manager,
KisImageWSP image, int iteration);
virtual void initImage(KisImageWSP image, KisNodeSP activeNode, int iteration);
// overload
virtual void modifyResourceManager(KoCanvasResourceProvider *manager,
KisImageWSP image);
// overload
virtual void initImage(KisImageWSP image, KisNodeSP activeNode);
virtual void beforeCheckingResult(KisImageWSP image, KisNodeSP activeNode);
virtual KisStrokeStrategy* createStroke(KisResourcesSnapshotSP resources,
KisImageWSP image) = 0;
virtual void addPaintingJobs(KisImageWSP image,
KisResourcesSnapshotSP resources,
int iteration);
// overload
virtual void addPaintingJobs(KisImageWSP image,
KisResourcesSnapshotSP resources);
private:
void testOneStroke(bool cancelled, bool indirectPainting,
bool externalLayer, bool testUpdates = false);
QImage doStroke(bool cancelled,
bool externalLayer, bool testUpdates = false,
bool needQImage = true);
QString formatTestName(const QString &baseName, bool cancelled,
bool indirectPainting, bool externalLayer);
QString referenceFile(const QString &testName);
QString dumpReferenceFile(const QString &testName);
QString resultFile(const QString &testName);
private:
KisStrokeId m_strokeId;
QString m_name;
QSize m_imageSize;
QString m_presetFilename;
int m_numIterations;
int m_baseFuzziness;
int m_strokeTime = 0;
};
}
#endif /* __STROKE_TESTING_UTILS_H */