Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add some Resolve features #18

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion HostSupport/examples/hostDemoEffectInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,20 @@ namespace MyHost {
// make a parameter instance
OFX::Host::Param::Instance* MyEffectInstance::newParam(const std::string& name, OFX::Host::Param::Descriptor& descriptor)
{
if(descriptor.getType()==kOfxParamTypeInteger)
if(descriptor.getType()==kOfxParamTypeString)
return new MyStringInstance(this,name,descriptor);
else if(descriptor.getType()==kOfxParamTypeInteger)
return new MyIntegerInstance(this,name,descriptor);
else if(descriptor.getType()==kOfxParamTypeDouble)
return new MyDoubleInstance(this,name,descriptor);
else if(descriptor.getType()==kOfxParamTypeBoolean)
return new MyBooleanInstance(this,name,descriptor);
else if(descriptor.getType()==kOfxParamTypeChoice)
return new MyChoiceInstance(this,name,descriptor);
#ifdef OFX_EXTENSIONS_RESOLVE
else if(descriptor.getType()==kOfxParamTypeStrChoice)
return new MyStrChoiceInstance(this,name,descriptor);
#endif
else if(descriptor.getType()==kOfxParamTypeRGBA)
return new MyRGBAInstance(this,name,descriptor);
else if(descriptor.getType()==kOfxParamTypeRGB)
Expand Down
130 changes: 105 additions & 25 deletions HostSupport/examples/hostDemoParamInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,37 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

namespace MyHost {

//
// MyStringInstance
//

MyStringInstance::MyStringInstance(MyEffectInstance* effect,
const std::string& name,
OFX::Host::Param::Descriptor& descriptor)
: OFX::Host::Param::StringInstance(descriptor), _effect(effect), _descriptor(descriptor)
{
}

OfxStatus MyStringInstance::get(std::string&)
{
return kOfxStatOK;
}

OfxStatus MyStringInstance::get(OfxTime time, std::string&)
{
return kOfxStatOK;
}

OfxStatus MyStringInstance::set(const char*)
{
return kOfxStatOK;
}

OfxStatus MyStringInstance::set(OfxTime time, const char*)
{
return kOfxStatOK;
}

//
// MyIntegerInstance
//
Expand All @@ -64,25 +95,31 @@ namespace MyHost {
OFX::Host::Param::Descriptor& descriptor)
: OFX::Host::Param::IntegerInstance(descriptor), _effect(effect), _descriptor(descriptor)
{
_i = getProperties().getIntProperty(kOfxParamPropDefault);
}

OfxStatus MyIntegerInstance::get(int&)
OfxStatus MyIntegerInstance::get(int& i)
{
return kOfxStatErrMissingHostFeature;
i = _i;
return kOfxStatOK;
}

OfxStatus MyIntegerInstance::get(OfxTime time, int&)
OfxStatus MyIntegerInstance::get(OfxTime time, int& i)
{
return kOfxStatErrMissingHostFeature;
i = _i;
return kOfxStatOK;
}

OfxStatus MyIntegerInstance::set(int)
OfxStatus MyIntegerInstance::set(int i)
{
return kOfxStatErrMissingHostFeature;
_i = i;
return kOfxStatOK;
}

OfxStatus MyIntegerInstance::set(OfxTime time, int) {
return kOfxStatErrMissingHostFeature;
OfxStatus MyIntegerInstance::set(OfxTime time, int i)
{
_i = i;
return kOfxStatOK;
}

//
Expand All @@ -94,40 +131,41 @@ namespace MyHost {
OFX::Host::Param::Descriptor& descriptor)
: OFX::Host::Param::DoubleInstance(descriptor), _effect(effect), _descriptor(descriptor)
{
_d = getProperties().getDoubleProperty(kOfxParamPropDefault);
}

OfxStatus MyDoubleInstance::get(double& d)
{
// values for the Basic OFX plugin to work
d = 2.0;
d = _d;
return kOfxStatOK;
}

OfxStatus MyDoubleInstance::get(OfxTime time, double& d)
{
// values for the Basic OFX plugin to work
d = 2.0;
d = _d;
return kOfxStatOK;
}

OfxStatus MyDoubleInstance::set(double)
OfxStatus MyDoubleInstance::set(double d)
{
return kOfxStatErrMissingHostFeature;
_d = d;
return kOfxStatOK;
}

OfxStatus MyDoubleInstance::set(OfxTime time, double)
OfxStatus MyDoubleInstance::set(OfxTime time, double d)
{
return kOfxStatErrMissingHostFeature;
_d = d;
return kOfxStatOK;
}

OfxStatus MyDoubleInstance::derive(OfxTime time, double&)
{
return kOfxStatErrMissingHostFeature;
return kOfxStatOK;
}

OfxStatus MyDoubleInstance::integrate(OfxTime time1, OfxTime time2, double&)
{
return kOfxStatErrMissingHostFeature;
return kOfxStatOK;
}

//
Expand All @@ -139,31 +177,73 @@ namespace MyHost {
OFX::Host::Param::Descriptor& descriptor)
: OFX::Host::Param::BooleanInstance(descriptor), _effect(effect), _descriptor(descriptor)
{
_b = getProperties().getIntProperty(kOfxParamPropDefault);
}

OfxStatus MyBooleanInstance::get(bool& b)
{
b = true;
b = _b;
return kOfxStatOK;
}

OfxStatus MyBooleanInstance::get(OfxTime time, bool& b)
{
b = true;
b = _b;
return kOfxStatOK;
}

OfxStatus MyBooleanInstance::set(bool)
OfxStatus MyBooleanInstance::set(bool b)
{
return kOfxStatErrMissingHostFeature;
_b = b;
return kOfxStatOK;
}

OfxStatus MyBooleanInstance::set(OfxTime time, bool) {
return kOfxStatErrMissingHostFeature;
OfxStatus MyBooleanInstance::set(OfxTime time, bool b)
{
_b = b;
return kOfxStatOK;
}

#ifdef OFX_EXTENSIONS_RESOLVE
//
// MyStrChoiceInstance
//

MyStrChoiceInstance::MyStrChoiceInstance(MyEffectInstance* effect,
const std::string& name,
OFX::Host::Param::Descriptor& descriptor)
: OFX::Host::Param::StrChoiceInstance(descriptor), _effect(effect), _descriptor(descriptor)
{
_choice = getProperties().getStringProperty(kOfxParamPropDefault);
}

OfxStatus MyStrChoiceInstance::get(std::string& choice)
{
choice = _choice;
return kOfxStatOK;
}

OfxStatus MyStrChoiceInstance::get(OfxTime time, std::string& choice)
{
choice = _choice;
return kOfxStatOK;
}

OfxStatus MyStrChoiceInstance::set(const char* choice)
{
_choice = std::string(choice);
return kOfxStatOK;
}

OfxStatus MyStrChoiceInstance::set(OfxTime time, const char* choice)
{
_choice = std::string(choice);
return kOfxStatOK;
}
#endif

//
// MyChoiceInteger
// MyChoiceInstance
//

MyChoiceInstance::MyChoiceInstance(MyEffectInstance* effect,
Expand Down
30 changes: 30 additions & 0 deletions HostSupport/examples/hostDemoParamInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,20 @@ namespace MyHost {
MyPushbuttonInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
};

class MyStringInstance : public OFX::Host::Param::StringInstance {
protected:
MyEffectInstance* _effect;
OFX::Host::Param::Descriptor& _descriptor;
public:
MyStringInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(std::string&);
OfxStatus get(OfxTime time, std::string&);
OfxStatus set(const char*);
OfxStatus set(OfxTime time, const char*);
};

class MyIntegerInstance : public OFX::Host::Param::IntegerInstance {
int _i;
protected:
MyEffectInstance* _effect;
OFX::Host::Param::Descriptor& _descriptor;
Expand All @@ -52,6 +65,7 @@ namespace MyHost {
};

class MyDoubleInstance : public OFX::Host::Param::DoubleInstance {
double _d;
protected:
MyEffectInstance* _effect;
OFX::Host::Param::Descriptor& _descriptor;
Expand All @@ -66,6 +80,7 @@ namespace MyHost {
};

class MyBooleanInstance : public OFX::Host::Param::BooleanInstance {
bool _b;
protected:
MyEffectInstance* _effect;
OFX::Host::Param::Descriptor& _descriptor;
Expand All @@ -89,6 +104,21 @@ namespace MyHost {
OfxStatus set(OfxTime time, int);
};

#ifdef OFX_EXTENSIONS_RESOLVE
class MyStrChoiceInstance : public OFX::Host::Param::StrChoiceInstance {
std::string _choice;
protected:
MyEffectInstance* _effect;
OFX::Host::Param::Descriptor& _descriptor;
public:
MyStrChoiceInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor);
OfxStatus get(std::string&);
OfxStatus get(OfxTime time, std::string&);
OfxStatus set(const char*);
OfxStatus set(OfxTime time, const char*);
};
#endif

class MyRGBAInstance : public OFX::Host::Param::RGBAInstance {
protected:
MyEffectInstance* _effect;
Expand Down
32 changes: 32 additions & 0 deletions HostSupport/include/ofxhParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,38 @@ namespace OFX {
virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC;
};

#ifdef OFX_EXTENSIONS_RESOLVE
class StrChoiceInstance : public Instance, public KeyframeParam {
std::string _returnValue; ///< location to hold temporary return value. Should delegate this to implementation!!!
public:
StrChoiceInstance(Descriptor& descriptor, Param::SetInstance* instance = 0);

// callback which should set option as appropriate
virtual void setOption(int num);

// Deriving implementatation needs to overide these
virtual OfxStatus get(std::string &) = 0;
virtual OfxStatus get(OfxTime time, std::string &) = 0;
virtual OfxStatus set(const char*) = 0;
virtual OfxStatus set(OfxTime time, const char*) = 0;

/// implementation of var args function
virtual OfxStatus getV(va_list arg);

/// implementation of var args function
virtual OfxStatus getV(OfxTime time, va_list arg);

/// implementation of var args function
virtual OfxStatus setV(va_list arg);

/// implementation of var args function
virtual OfxStatus setV(OfxTime time, va_list arg);

/// overridden from Instance
virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC;
};
#endif

class DoubleInstance : public Instance, public KeyframeParam {
public:
DoubleInstance(Descriptor& descriptor, Param::SetInstance* instance = 0) : Instance(descriptor,instance) {}
Expand Down
13 changes: 13 additions & 0 deletions HostSupport/src/ofxhImageEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ namespace OFX {
#ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"},
{ kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" },
#endif
#ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" },
Expand Down Expand Up @@ -1301,7 +1303,10 @@ namespace OFX {
# ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" },
# endif
# ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropView, Property::eInt, 1, true, "0" },
Expand Down Expand Up @@ -1401,7 +1406,10 @@ namespace OFX {
# ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" },
# endif
# ifdef OFX_EXTENSIONS_VEGAS
{ kOfxImageEffectPropRenderView, Property::eInt, 1, true, "0" },
Expand Down Expand Up @@ -1518,7 +1526,10 @@ namespace OFX {
# ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" },
{ kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" },
{ kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" },
# endif
# ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropView, Property::eInt, 1, true, "0" },
Expand Down Expand Up @@ -4199,6 +4210,8 @@ namespace OFX {
# ifdef OFX_EXTENSIONS_RESOLVE
{ kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"},
{ kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" },
{ kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" },
# endif
# ifdef OFX_EXTENSIONS_NUKE
{ kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" },
Expand Down
3 changes: 2 additions & 1 deletion HostSupport/src/ofxhImageEffectAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,11 @@ namespace OFX {
# ifdef OFX_DEBUG_ACTIONS
OfxPlugin *op = _pluginHandle->getOfxPlugin();
std::cout << "OFX: "<<op->pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()"<<std::endl;
std::string pluginIdentifier(op->pluginIdentifier); // save it before it becomes invalid
# endif
stat = (*_pluginHandle)->mainEntry(kOfxActionUnload, 0, 0, 0);
# ifdef OFX_DEBUG_ACTIONS
std::cout << "OFX: "<<op->pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()->"<<StatStr(stat)<<std::endl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing that!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's it still a draft or is it ready to merge?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is still a draft as I am not sure of the way StrChoiceInstance::notify is supposed to work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About openfx-misc plugins, what is the issue ? They do not load on macOS and Windows and Linux or a specific OS and specific versions of Resolve ?

std::cout << "OFX: "<<pluginIdentifier<<"("<<(void*)op<<")->"<<kOfxActionUnload<<"()->"<<StatStr(stat)<<std::endl;
# endif
} CatchAllSetStatus(stat, gImageEffectHost, (*_pluginHandle), kOfxActionUnload);
(void)stat;
Expand Down
Loading