forked from NatronGitHub/Natron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OfxEffectInstance.h
325 lines (281 loc) · 17.1 KB
/
OfxEffectInstance.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2021 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Natron is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */
#ifndef NATRON_ENGINE_OFXNODE_H
#define NATRON_ENGINE_OFXNODE_H
// ***** BEGIN PYTHON BLOCK *****
// from <https://docs.python.org/3/c-api/intro.html#include-files>:
// "Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included."
#include <Python.h>
// ***** END PYTHON BLOCK *****
#include "Global/Macros.h"
#include <map>
#include <string>
#if !defined(Q_MOC_RUN) && !defined(SBK_RUN)
#include <boost/shared_ptr.hpp>
#endif
CLANG_DIAG_OFF(deprecated)
#include <QtCore/QMutex>
#include <QtCore/QString>
#include <QtCore/QObject>
CLANG_DIAG_ON(deprecated)
#include <QtCore/QStringList>
#include "Engine/OutputEffectInstance.h"
#include "Engine/ViewIdx.h"
#include "Engine/EngineFwd.h"
NATRON_NAMESPACE_ENTER
class AbstractOfxEffectInstance
: public OutputEffectInstance
{
public:
AbstractOfxEffectInstance(NodePtr node)
: OutputEffectInstance(node)
{
}
protected:
AbstractOfxEffectInstance(const AbstractOfxEffectInstance& other)
: OutputEffectInstance(other)
{
}
public:
virtual ~AbstractOfxEffectInstance()
{
}
virtual void createOfxImageEffectInstance(OFX::Host::ImageEffect::ImageEffectPlugin* plugin,
OFX::Host::ImageEffect::Descriptor* desc,
ContextEnum context,
const NodeSerialization* serialization,
const CreateNodeArgs& args
#ifndef NATRON_ENABLE_IO_META_NODES
, bool allowFileDialogs,
bool *hasUsedFileDialog
#endif
) = 0;
static QStringList makePluginGrouping(const std::string & pluginIdentifier,
int versionMajor, int versionMinor,
const std::string & pluginLabel,
const std::string & grouping) WARN_UNUSED_RETURN;
static std::string makePluginLabel(const std::string & shortLabel,
const std::string & label,
const std::string & longLabel) WARN_UNUSED_RETURN;
};
struct OfxEffectInstancePrivate;
class OfxEffectInstance
: public AbstractOfxEffectInstance
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
OfxEffectInstance(NodePtr node);
OfxEffectInstance(const OfxEffectInstance& other);
virtual ~OfxEffectInstance();
void createOfxImageEffectInstance(OFX::Host::ImageEffect::ImageEffectPlugin* plugin,
OFX::Host::ImageEffect::Descriptor* desc,
ContextEnum context,
const NodeSerialization* serialization,
const CreateNodeArgs& args
#ifndef NATRON_ENABLE_IO_META_NODES
, bool allowFileDialogs,
bool *hasUsedFileDialog
#endif
) OVERRIDE FINAL;
OfxImageEffectInstance* effectInstance() WARN_UNUSED_RETURN;
const OfxImageEffectInstance* effectInstance() const WARN_UNUSED_RETURN;
const std::string & getShortLabel() const WARN_UNUSED_RETURN;
typedef std::vector<OFX::Host::ImageEffect::ClipDescriptor*> MappedInputV;
MappedInputV inputClipsCopyWithoutOutput() const WARN_UNUSED_RETURN;
bool isCreated() const;
bool isInitialized() const;
const std::string & ofxGetOutputPremultiplication() const;
/**
* @brief Calls syncPrivateDataAction from another thread than the main thread. The actual
* call of the action will take place in the main-thread.
**/
void syncPrivateData_other_thread();
public:
/********OVERRIDDEN FROM EFFECT INSTANCE*************/
virtual int getMajorVersion() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual int getMinorVersion() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isGenerator() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isReader() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isVideoReader() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isWriter() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isVideoWriter() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isOutput() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isFilter() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isTrackerNodePlugin() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isOpenFX() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
virtual void onScriptNameChanged(const std::string& fullyQualifiedName) OVERRIDE FINAL;
virtual bool isEffectCreated() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual int getNInputs() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual std::string getPluginID() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual std::string getPluginLabel() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void getPluginGrouping(std::list<std::string>* grouping) const OVERRIDE FINAL;
virtual std::string getPluginDescription() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isPluginDescriptionInMarkdown() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual std::string getInputLabel (int inputNb) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual std::string getInputHint(int inputNb) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isInputOptional(int inputNb) const OVERRIDE WARN_UNUSED_RETURN;
virtual bool isInputMask(int inputNb) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isInputRotoBrush(int inputNb) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual int getRotoBrushInputIndex() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum getRegionOfDefinition(U64 hash, double time, const RenderScale & scale, ViewIdx view, RectD* rod) OVERRIDE WARN_UNUSED_RETURN;
/// calculate the default rod for this effect instance
virtual void calcDefaultRegionOfDefinition(U64 hash, double time, const RenderScale & scale, ViewIdx view, RectD *rod) OVERRIDE;
virtual void getRegionsOfInterest(double time,
const RenderScale & scale,
const RectD & outputRoD, //!< full RoD in canonical coordinates
const RectD & renderWindow, //!< the region to be rendered in the output image, in Canonical Coordinates
ViewIdx view,
RoIMap* ret) OVERRIDE FINAL;
virtual FramesNeededMap getFramesNeeded(double time, ViewIdx view) OVERRIDE WARN_UNUSED_RETURN;
virtual void getFrameRange(double *first, double *last) OVERRIDE;
virtual void initializeOverlayInteract() OVERRIDE FINAL;
virtual bool hasOverlay() const OVERRIDE FINAL;
virtual void redrawOverlayInteract() OVERRIDE FINAL;
virtual void drawOverlay(double time, const RenderScale & renderScale, ViewIdx view) OVERRIDE FINAL;
virtual bool onOverlayPenDown(double time, const RenderScale & renderScale, ViewIdx view, const QPointF & viewportPos, const QPointF & pos, double pressure, double timestamp, PenType pen) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool onOverlayPenMotion(double time, const RenderScale & renderScale, ViewIdx view,
const QPointF & viewportPos, const QPointF & pos, double pressure, double timestamp) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool onOverlayPenUp(double time, const RenderScale & renderScale, ViewIdx view, const QPointF & viewportPos, const QPointF & pos, double pressure, double timestamp) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool onOverlayKeyDown(double time, const RenderScale & renderScale, ViewIdx view, Key key, KeyboardModifiers modifiers) OVERRIDE FINAL;
virtual bool onOverlayKeyUp(double time, const RenderScale & renderScale, ViewIdx view, Key key, KeyboardModifiers modifiers) OVERRIDE FINAL;
virtual bool onOverlayKeyRepeat(double time, const RenderScale & renderScale, ViewIdx view, Key key, KeyboardModifiers modifiers) OVERRIDE FINAL;
virtual bool onOverlayFocusGained(double time, const RenderScale & renderScale, ViewIdx view) OVERRIDE FINAL;
virtual bool onOverlayFocusLost(double time, const RenderScale & renderScale, ViewIdx view) OVERRIDE FINAL;
virtual bool canHandleRenderScaleForOverlays() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void setCurrentViewportForOverlays(OverlaySupport* viewport) OVERRIDE FINAL;
virtual void beginKnobsValuesChanged(ValueChangedReasonEnum reason) OVERRIDE;
virtual void endKnobsValuesChanged(ValueChangedReasonEnum reason) OVERRIDE;
virtual bool knobChanged(KnobI* k,
ValueChangedReasonEnum reason,
ViewSpec view,
double time,
bool originatedFromMainThread) OVERRIDE;
virtual void beginEditKnobs() OVERRIDE;
virtual StatusEnum render(const RenderActionArgs& args) OVERRIDE WARN_UNUSED_RETURN;
virtual bool isIdentity(double time,
const RenderScale & scale,
const RectI & renderWindow, //!< render window in pixel coords
ViewIdx view,
double* inputTime,
ViewIdx* inputView,
int* inputNb) OVERRIDE;
virtual RenderSafetyEnum renderThreadSafety() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void purgeCaches() OVERRIDE;
/**
* @brief Does this effect supports tiling ?
* http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#kOfxImageEffectPropSupportsTiles
* If a clip or plugin does not support tiled images, then the host should supply
* full RoD images to the effect whenever it fetches one.
**/
virtual bool supportsTiles() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool supportsRenderQuality() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual PluginOpenGLRenderSupport supportsOpenGLRender() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool doesTemporalClipAccess() const OVERRIDE FINAL WARN_UNUSED_RETURN;
/**
* @brief Does this effect supports multiresolution ?
* http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#kOfxImageEffectPropSupportsMultiResolution
* Multiple resolution images mean...
* input and output images can be of any size
* input and output images can be offset from the origin
**/
virtual bool supportsMultiResolution() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool supportsMultipleClipPARs() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool supportsMultipleClipDepths() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isHostChannelSelectorSupported(bool* defaultR, bool* defaultG, bool* defaultB, bool* defaultA) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void onInputChanged(int inputNo) OVERRIDE FINAL;
virtual StatusEnum beginSequenceRender(double first,
double last,
double step,
bool interactive,
const RenderScale & scale,
bool isSequentialRender,
bool isRenderResponseToUserInteraction,
bool draftMode,
ViewIdx view,
bool isOpenGLRender,
const EffectInstance::OpenGLContextEffectDataPtr& glContextData) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum endSequenceRender(double first,
double last,
double step,
bool interactive,
const RenderScale & scale,
bool isSequentialRender,
bool isRenderResponseToUserInteraction,
bool draftMode,
ViewIdx view,
bool isOpenGLRender,
const EffectInstance::OpenGLContextEffectDataPtr& glContextData) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void addAcceptedComponents(int inputNb, std::list<ImagePlaneDesc>* comps) OVERRIDE FINAL;
virtual void addSupportedBitDepth(std::list<ImageBitDepthEnum>* depths) const OVERRIDE FINAL;
virtual SequentialPreferenceEnum getSequentialPreference() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum getPreferredMetadata(NodeMetadata& metadata) OVERRIDE FINAL;
virtual void onMetadataRefreshed(const NodeMetadata& metadata) OVERRIDE FINAL;
virtual void getComponentsNeededAndProduced(double time, ViewIdx view,
EffectInstance::ComponentsNeededMap* comps,
double* passThroughTime,
int* passThroughView,
int* passThroughInput) OVERRIDE;
virtual bool isMultiPlanar() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual EffectInstance::PassThroughEnum isPassThroughForNonRenderedPlanes() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isViewAware() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual EffectInstance::ViewInvarianceLevel isViewInvariant() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool supportsConcurrentOpenGLRenders() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum attachOpenGLContext(OpenGLContextEffectDataPtr* data) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum dettachOpenGLContext(const OpenGLContextEffectDataPtr& data) OVERRIDE FINAL;
virtual EffectInstancePtr createRenderClone() OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void onInteractViewportSelectionCleared() OVERRIDE FINAL;
virtual void onInteractViewportSelectionUpdated(const RectD& rectangle, bool onRelease) OVERRIDE FINAL;
virtual void setInteractColourPicker(const OfxRGBAColourD& color, bool setColor, bool hasColor) OVERRIDE FINAL;
public:
virtual bool getCanTransform() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool getInputsHoldingTransform(std::list<int>* inputs) const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual StatusEnum getTransform(double time,
const RenderScale & renderScale,
bool draftRender,
ViewIdx view,
EffectInstancePtr* inputToTransform,
Transform::Matrix3x3* transform) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isHostMaskingEnabled() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isHostMixingEnabled() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void onEnableOpenGLKnobValueChanged(bool activated) OVERRIDE FINAL;
/********OVERRIDDEN FROM EFFECT INSTANCE: END*************/
OfxClipInstance* getClipCorrespondingToInput(int inputNo) const;
static ContextEnum mapToContextEnum(const std::string &s);
static std::string mapContextToString(ContextEnum ctx);
static std::string natronValueChangedReasonToOfxValueChangedReason(ValueChangedReasonEnum reason);
int getClipInputNumber(const OfxClipInstance* clip) const;
void onClipLabelChanged(int inputNb, const std::string& label);
void onClipHintChanged(int inputNb, const std::string& hint);
void onClipSecretChanged(int inputNb, bool isSecret);
public Q_SLOTS:
void onSyncPrivateDataRequested();
Q_SIGNALS:
void syncPrivateDataRequested();
private:
void tryInitializeOverlayInteracts();
private:
boost::scoped_ptr<OfxEffectInstancePrivate> _imp;
};
NATRON_NAMESPACE_EXIT
#endif // NATRON_ENGINE_OFXNODE_H