Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Aug 17, 2024
1 parent e188f05 commit 6e4b25e
Show file tree
Hide file tree
Showing 65 changed files with 939 additions and 247 deletions.
14 changes: 7 additions & 7 deletions bin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ using namespace toucan;

int main(int argc, char** argv)
{
std::filesystem::path parentPath = std::filesystem::path(argv[0]).parent_path();
auto host = std::make_shared<Host>(std::vector<std::filesystem::path>{
parentPath,
parentPath / ".." / ".."});
return 0;

// Command line arguments.
if (argc < 3)
{
Expand All @@ -33,6 +27,7 @@ int main(int argc, char** argv)
std::cout << std::endl;
return 1;
}
const std::filesystem::path parentPath = std::filesystem::path(argv[0]).parent_path();
const std::filesystem::path inputPath(argv[1]);
const std::filesystem::path outputPath(argv[2]);
const auto outputSplit = splitFileNameNumber(outputPath.stem().string());
Expand Down Expand Up @@ -69,6 +64,11 @@ int main(int argc, char** argv)
const auto traverse = std::make_shared<TimelineTraverse>(inputPath.parent_path(), timeline);
const IMATH_NAMESPACE::V2d& imageSize = traverse->getImageSize();

// Create the host.
auto host = std::make_shared<Host>(std::vector<std::filesystem::path>{
parentPath,
parentPath / ".." / ".."});

// Initialize the filmstrip.
OIIO::ImageBuf filmstripBuf;
const int thumbnailWidth = 120;
Expand Down Expand Up @@ -97,7 +97,7 @@ int main(int argc, char** argv)
if (auto op = traverse->exec(time))
{
// Execute the image operation graph.
const auto buf = op->exec(time);
const auto buf = op->exec(time, host);

// Save the image.
if (!filmstrip)
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/BoxOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace toucan
_data = value;
}

OIIO::ImageBuf BoxOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf BoxOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -40,7 +42,7 @@ namespace toucan
{
offsetTime -= _timeOffset;
}
buf = _inputs[0]->exec(offsetTime);
buf = _inputs[0]->exec(offsetTime, host);
OIIO::ImageBufAlgo::render_box(
buf,
_data.pos1.x,
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/BoxOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace toucan
const BoxData& getData() const;
void setData(const BoxData&);

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;

private:
BoxData _data;
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ set(SOURCE
TransitionOp.cpp
Util.cpp)
if(WIN32)
list(APPEND SOURCE UtilWin32.cpp)
list(APPEND SOURCE
PluginWin32.cpp
UtilWin32.cpp)
endif()

add_library(toucan ${HEADERS} ${HEADERS_PRIVATE} ${SOURCE})
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/CheckersOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace toucan
_data = value;
}

OIIO::ImageBuf CheckersOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf CheckersOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -40,7 +42,7 @@ namespace toucan
{
offsetTime -= _timeOffset;
}
buf = _inputs[0]->exec(offsetTime);
buf = _inputs[0]->exec(offsetTime, host);
OIIO::ImageBufAlgo::checker(
buf,
_data.checkerSize.x,
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/CheckersOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace toucan
const CheckersData& getData() const;
void setData(const CheckersData&);

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;

private:
CheckersData _data;
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/ColorMapOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace toucan
_data = value;
}

OIIO::ImageBuf ColorMapOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf ColorMapOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -39,7 +41,7 @@ namespace toucan
offsetTime -= _timeOffset;
}
buf = OIIO::ImageBufAlgo::color_map(
_inputs[0]->exec(offsetTime),
_inputs[0]->exec(offsetTime, host),
-1,
_data.mapName);

Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/ColorMapOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ namespace toucan
const ColorMapData& getData() const;
void setData(const ColorMapData&);

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;

private:
ColorMapData _data;
Expand Down
10 changes: 6 additions & 4 deletions lib/toucan/CompOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ namespace toucan
_premult = premult;
}

OIIO::ImageBuf CompOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf CompOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
OTIO_NS::RationalTime offsetTime = time;
Expand All @@ -30,8 +32,8 @@ namespace toucan
}
if (_inputs.size() > 1 && _inputs[0] && _inputs[1])
{
auto fg = _inputs[0]->exec(offsetTime);
auto bg = _inputs[1]->exec(offsetTime);
auto fg = _inputs[0]->exec(offsetTime, host);
auto bg = _inputs[1]->exec(offsetTime, host);
if (_premult)
{
fg = OIIO::ImageBufAlgo::premult(fg);
Expand All @@ -40,7 +42,7 @@ namespace toucan
}
else if (1 == _inputs.size() && _inputs[0])
{
auto fg = _inputs[0]->exec(offsetTime);
auto fg = _inputs[0]->exec(offsetTime, host);
if (_premult)
{
fg = OIIO::ImageBufAlgo::premult(fg);
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/CompOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ namespace toucan
//! Set whether images are pre-multiplied before compositing.
void setPremult(bool);

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;

private:
bool _premult = false;
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/FillOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ namespace toucan
_data = value;
}

OIIO::ImageBuf FillOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf FillOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -40,7 +42,7 @@ namespace toucan
{
offsetTime -= _timeOffset;
}
buf = _inputs[0]->exec(offsetTime);
buf = _inputs[0]->exec(offsetTime, host);
OIIO::ImageBufAlgo::fill(
buf,
{ _data.color.x, _data.color.y, _data.color.z, _data.color.w });
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/FillOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ namespace toucan
const FillData& getData() const;
void setData(const FillData&);

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;

private:
FillData _data;
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/FlipOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace toucan
FlipOp::~FlipOp()
{}

OIIO::ImageBuf FlipOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf FlipOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -26,7 +28,7 @@ namespace toucan
{
offsetTime -= _timeOffset;
}
const auto input = _inputs[0]->exec(offsetTime);
const auto input = _inputs[0]->exec(offsetTime, host);
buf = OIIO::ImageBufAlgo::flip(input);
}
return buf;
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/FlipOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace toucan

virtual ~FlipOp();

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;
};

//! Flip OTIO effect.
Expand Down
6 changes: 4 additions & 2 deletions lib/toucan/FlopOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace toucan
FlopOp::~FlopOp()
{}

OIIO::ImageBuf FlopOp::exec(const OTIO_NS::RationalTime& time)
OIIO::ImageBuf FlopOp::exec(
const OTIO_NS::RationalTime& time,
const std::shared_ptr<Host>& host)
{
OIIO::ImageBuf buf;
if (!_inputs.empty() && _inputs[0])
Expand All @@ -26,7 +28,7 @@ namespace toucan
{
offsetTime -= _timeOffset;
}
const auto input = _inputs[0]->exec(offsetTime);
const auto input = _inputs[0]->exec(offsetTime, host);
buf = OIIO::ImageBufAlgo::flop(input);
}
return buf;
Expand Down
4 changes: 3 additions & 1 deletion lib/toucan/FlopOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace toucan

virtual ~FlopOp();

OIIO::ImageBuf exec(const OTIO_NS::RationalTime&) override;
OIIO::ImageBuf exec(
const OTIO_NS::RationalTime&,
const std::shared_ptr<Host>&) override;
};

//! Flop OTIO effect.
Expand Down
Loading

0 comments on commit 6e4b25e

Please sign in to comment.