Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Aug 11, 2024
1 parent e65b60d commit 169f23f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion data/CompOver.otio → data/CompositeTracks.otio
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"OTIO_SCHEMA": "Timeline.1",
"metadata": {},
"name": "CompOver",
"name": "ComppositeTracks",
"tracks": {
"OTIO_SCHEMA": "Stack.1",
"children": [
Expand Down
38 changes: 23 additions & 15 deletions lib/toucan/TimelineTraverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "TransitionOp.h"

#include <opentimelineio/externalReference.h>
#include <opentimelineio/gap.h>
#include <opentimelineio/imageSequenceReference.h>
#include <opentimelineio/linearTimeWarp.h>

Expand Down Expand Up @@ -69,15 +70,15 @@ namespace toucan

std::shared_ptr<IImageOp> TimelineTraverse::exec(const OTIO_NS::RationalTime& time)
{
_op = std::make_shared<FillOp>(FillData{ _size, IMATH_NAMESPACE::V4f(0.F, 0.F, 0.F, 1.F )});
std::shared_ptr<IImageOp> op = std::make_shared<FillOp>(FillData{ _size, IMATH_NAMESPACE::V4f(0.F, 0.F, 0.F, 1.F )});
for (const auto& i : _timeline->tracks()->children())
{
if (auto track = OTIO_NS::dynamic_retainer_cast<OTIO_NS::Track>(i))
{
_track(time, track);
op = _track(time, track, op);
}
}
return _op;
return op;
}

namespace
Expand Down Expand Up @@ -121,10 +122,13 @@ namespace toucan
}
}

void TimelineTraverse::_track(
std::shared_ptr<IImageOp> TimelineTraverse::_track(
const OTIO_NS::RationalTime& time,
const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Track>& track)
const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Track>& track,
const std::shared_ptr<IImageOp>& trackOp)
{
std::shared_ptr<CompOp> comp;

for (const auto& i : track->children())
{
std::shared_ptr<IImageOp> op;
Expand Down Expand Up @@ -180,19 +184,23 @@ namespace toucan
}

// Composite over the previous track.
std::vector<std::shared_ptr<IImageOp> > ops;
if (op)
{
ops.push_back(op);
}
if (_op)
{
ops.push_back(_op);
std::vector<std::shared_ptr<IImageOp> > ops;
if (op)
{
ops.push_back(op);
}
if (trackOp)
{
ops.push_back(trackOp);
}
comp = std::make_shared<CompOp>(ops);
comp->setPremult(true);
}
auto comp = std::make_shared<CompOp>(ops);
comp->setPremult(true);
_op = comp;
}

return comp;
}

std::shared_ptr<IImageOp> TimelineTraverse::_item(
Expand Down Expand Up @@ -230,7 +238,7 @@ namespace toucan
out = read;
}
}
else if (auto gap = OTIO_NS::dynamic_retainer_cast<OTIO_NS::Clip>(item))
else if (auto gap = OTIO_NS::dynamic_retainer_cast<OTIO_NS::Gap>(item))
{
out = std::make_shared<FillOp>(FillData{ _size });
}
Expand Down
6 changes: 3 additions & 3 deletions lib/toucan/TimelineTraverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ namespace toucan
std::shared_ptr<IImageOp> exec(const OTIO_NS::RationalTime&);

private:
void _track(
std::shared_ptr<IImageOp> _track(
const OTIO_NS::RationalTime&,
const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Track>&);
const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Track>&,
const std::shared_ptr<IImageOp>&);
std::shared_ptr<IImageOp> _item(
const OTIO_NS::TimeRange& trimmedRangeInParent,
const OTIO_NS::RationalTime&,
Expand All @@ -41,6 +42,5 @@ namespace toucan
std::filesystem::path _path;
OTIO_NS::SerializableObject::Retainer<OTIO_NS::Timeline> _timeline;
IMATH_NAMESPACE::V2d _size = IMATH_NAMESPACE::V2d(0, 0);
std::shared_ptr<IImageOp> _op;
};
}
6 changes: 3 additions & 3 deletions tests/TimelineTraverseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ namespace toucan
std::cout << "timelineTraverseTest" << std::endl;
const std::vector<std::string> otioFiles =
{
"CompOver",
"CompositeTracks",
"Filters",
"Gap",
"LinearTimeWarp",
"Patterns",
"Text",
"Transforms",
"Transition",
"Transition2",
"Transforms"
"Transition2"
};
for (const auto& otioFile : otioFiles)
{
Expand Down

0 comments on commit 169f23f

Please sign in to comment.