Skip to content

Commit 8d4b751

Browse files
Fixes for OpenFX plugin search paths (#43)
Signed-off-by: Darby Johnston <darbyjohnston@yahoo.com>
1 parent 9b95b13 commit 8d4b751

7 files changed

Lines changed: 63 additions & 36 deletions

File tree

bin/toucan-filmstrip/App.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,7 @@ namespace toucan
8686
const IMATH_NAMESPACE::V2d imageSize = _graph->getImageSize();
8787

8888
// Create the image host.
89-
std::vector<std::filesystem::path> searchPath;
90-
searchPath.push_back(parentPath);
91-
#if defined(_WINDOWS)
92-
searchPath.push_back(parentPath / ".." / ".." / "..");
93-
#else // _WINDOWS
94-
searchPath.push_back(parentPath / ".." / "..");
95-
#endif // _WINDOWS
96-
_host = std::make_shared<ImageEffectHost>(_context, searchPath);
89+
_host = std::make_shared<ImageEffectHost>(_context, getOpenFXPluginPaths(getExeName()));
9790

9891
// Initialize the filmstrip.
9992
OIIO::ImageBuf filmstripBuf;

bin/toucan-render/App.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,7 @@ namespace toucan
199199
}
200200

201201
// Create the image host.
202-
std::vector<std::filesystem::path> searchPath;
203-
searchPath.push_back(parentPath);
204-
#if defined(_WINDOWS)
205-
searchPath.push_back(parentPath / ".." / ".." / "..");
206-
#else // _WINDOWS
207-
searchPath.push_back(parentPath / ".." / "..");
208-
#endif // _WINDOWS
209-
_host = std::make_shared<ImageEffectHost>(_context, searchPath);
202+
_host = std::make_shared<ImageEffectHost>(_context, getOpenFXPluginPaths(getExeName()));
210203

211204
// Open the movie file.
212205
std::shared_ptr<ffmpeg::Write> ffWrite;

lib/toucanRender/Plugin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ namespace toucan
4949
const std::filesystem::path& path,
5050
std::vector<std::filesystem::path>& out)
5151
{
52-
_findPlugins(path, out, 0, 2);
52+
_findPlugins(path, out, 0, 10);
5353
}
54-
5554
}

lib/toucanRender/Util.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,52 @@ namespace toucan
185185
out.w = std::any_cast<double>(any[3]);
186186
}
187187
}
188+
189+
std::vector<std::filesystem::path> getOpenFXPluginPaths(
190+
const std::filesystem::path& executablePath)
191+
{
192+
const std::filesystem::path parentPath = executablePath.parent_path();
193+
std::vector<std::filesystem::path> searchPath;
194+
195+
// Add executable directory and relative paths
196+
searchPath.push_back(parentPath);
197+
#if defined(_WINDOWS)
198+
searchPath.push_back(parentPath / ".." / ".." / "..");
199+
// Add standard Windows OpenFX plugin path
200+
searchPath.push_back("C:\\Program Files\\Common Files\\OFX\\Plugins");
201+
#else // _WINDOWS
202+
searchPath.push_back(parentPath / ".." / "..");
203+
#if defined(__APPLE__)
204+
// Add standard macOS OpenFX plugin path
205+
searchPath.push_back("/Library/OFX/Plugins");
206+
#else
207+
// Add standard Linux/Unix OpenFX plugin path
208+
searchPath.push_back("/usr/OFX/Plugins");
209+
#endif // __APPLE__
210+
#endif // _WINDOWS
211+
212+
// Add paths from environment variable OFX_PLUGIN_PATH if it exists
213+
if (const char* envPath = std::getenv("OFX_PLUGIN_PATH")) {
214+
#if defined(_WINDOWS)
215+
const char delimiter = ';';
216+
#else
217+
const char delimiter = ':';
218+
#endif
219+
std::string envPathStr(envPath);
220+
size_t pos = 0;
221+
std::string token;
222+
while ((pos = envPathStr.find(delimiter)) != std::string::npos) {
223+
token = envPathStr.substr(0, pos);
224+
if (!token.empty()) {
225+
searchPath.push_back(token);
226+
}
227+
envPathStr.erase(0, pos + 1);
228+
}
229+
if (!envPathStr.empty()) {
230+
searchPath.push_back(envPathStr);
231+
}
232+
}
233+
234+
return searchPath;
235+
}
188236
}

lib/toucanRender/Util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@ namespace toucan
4848
//! Conversion from any vector.
4949
void anyToVec(const OTIO_NS::AnyVector&, IMATH_NAMESPACE::V2i&);
5050
void anyToVec(const OTIO_NS::AnyVector&, IMATH_NAMESPACE::V4f&);
51+
52+
//! Get standard OpenFX plugin search paths.
53+
//! Includes executable directory, standard OS-specific plugin directories,
54+
//! and paths from the OFX_PLUGIN_PATH environment variable.
55+
std::vector<std::filesystem::path> getOpenFXPluginPaths(
56+
const std::filesystem::path& executablePath);
5157
}

lib/toucanView/App.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "ViewModel.h"
1010
#include "WindowModel.h"
1111

12+
#include <toucanRender/Util.h>
13+
1214
#include <dtk/ui/DialogSystem.h>
1315
#include <dtk/ui/FileBrowser.h>
1416
#include <dtk/ui/MessageDialog.h>
@@ -41,15 +43,7 @@ namespace toucan
4143

4244
_timeUnitsModel = std::make_shared<TimeUnitsModel>(context);
4345

44-
std::vector<std::filesystem::path> searchPath;
45-
const std::filesystem::path parentPath = std::filesystem::path(argv[0]).parent_path();
46-
searchPath.push_back(parentPath);
47-
#if defined(_WINDOWS)
48-
searchPath.push_back(parentPath / ".." / ".." / "..");
49-
#else // _WINDOWS
50-
searchPath.push_back(parentPath / ".." / "..");
51-
#endif // _WINDOWS
52-
_host = std::make_shared<ImageEffectHost>(context, searchPath);
46+
_host = std::make_shared<ImageEffectHost>(context, getOpenFXPluginPaths(getExeName()));
5347

5448
auto fileBrowserSystem = context->getSystem<dtk::FileBrowserSystem>();
5549
fileBrowserSystem->setNativeFileDialog(false);

tests/toucan-test/main.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <toucanRenderTest/PropertySetTest.h>
1515
#include <toucanRenderTest/ReadTest.h>
1616

17+
#include <toucanRender/Util.h>
18+
1719
#if defined(toucan_VIEW)
1820
#include <dtk/ui/Init.h>
1921
#endif // toucan_VIEW
@@ -31,7 +33,6 @@ int main(int argc, char** argv)
3133
std::cout << "Usage: toucan-test (path to test data)" << std::endl;
3234
return 1;
3335
}
34-
const std::filesystem::path parentPath = std::filesystem::path(argv[0]).parent_path();
3536
const std::filesystem::path path(argv[1]);
3637

3738
auto context = dtk::Context::create();
@@ -40,14 +41,7 @@ int main(int argc, char** argv)
4041
dtk::uiInit(context);
4142
#endif // toucan_VIEW
4243

43-
std::vector<std::filesystem::path> searchPath;
44-
searchPath.push_back(parentPath);
45-
#if defined(_WINDOWS)
46-
searchPath.push_back(parentPath / ".." / ".." / "..");
47-
#else // _WINDOWS
48-
searchPath.push_back(parentPath / ".." / "..");
49-
#endif // _WINDOWS
50-
auto host = std::make_shared<ImageEffectHost>(context, searchPath);
44+
auto host = std::make_shared<ImageEffectHost>(context, getOpenFXPluginPaths(argv[0]));
5145

5246
compTest(path);
5347
propertySetTest();

0 commit comments

Comments
 (0)