Skip to content

Commit

Permalink
Add an option for passing in the offscreen window for thumbnail gener…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
darbyjohnston committed Feb 5, 2024
1 parent c91fc5f commit 8a65985
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lib/tlTimelineUI/TimelineItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ namespace tl
double scale,
const ItemOptions& options,
const std::shared_ptr<ItemData>& itemData,
const std::shared_ptr<gl::GLFWWindow>& window,
const std::shared_ptr<system::Context>& context,
const std::shared_ptr<IWidget>& parent)
{
Expand All @@ -143,7 +144,7 @@ namespace tl

p.player = player;

p.thumbnailGenerator = ui::ThumbnailGenerator::create(context);
p.thumbnailGenerator = ui::ThumbnailGenerator::create(context, window);

const auto otioTimeline = p.player->getTimeline()->getTimeline();
int trackIndex = 0;
Expand Down Expand Up @@ -268,11 +269,12 @@ namespace tl
double scale,
const ItemOptions& options,
const std::shared_ptr<ItemData>& itemData,
const std::shared_ptr<gl::GLFWWindow>& window,
const std::shared_ptr<system::Context>& context,
const std::shared_ptr<IWidget>& parent)
{
auto out = std::shared_ptr<TimelineItem>(new TimelineItem);
out->_init(player, stack, scale, options, itemData, context, parent);
out->_init(player, stack, scale, options, itemData, window, context, parent);
return out;
}

Expand Down
7 changes: 7 additions & 0 deletions lib/tlTimelineUI/TimelineItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

namespace tl
{
namespace gl
{
class GLFWWindow;
}

namespace timelineui
{
//! Track types.
Expand All @@ -36,6 +41,7 @@ namespace tl
double scale,
const ItemOptions&,
const std::shared_ptr<ItemData>&,
const std::shared_ptr<gl::GLFWWindow>&,
const std::shared_ptr<system::Context>&,
const std::shared_ptr<IWidget>& parent);

Expand All @@ -51,6 +57,7 @@ namespace tl
double scale,
const ItemOptions&,
const std::shared_ptr<ItemData>&,
const std::shared_ptr<gl::GLFWWindow>&,
const std::shared_ptr<system::Context>&,
const std::shared_ptr<IWidget>& parent = nullptr);

Expand Down
12 changes: 12 additions & 0 deletions lib/tlTimelineUI/TimelineWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include <tlUI/ScrollWidget.h>

#include <tlGL/GL.h>
#include <tlGL/GLFWWindow.h>

namespace tl
{
namespace timelineui
Expand All @@ -25,6 +28,8 @@ namespace tl
std::shared_ptr<observer::Value<ItemOptions> > itemOptions;
bool sizeInit = true;

std::shared_ptr<gl::GLFWWindow> window;

std::shared_ptr<ui::ScrollWidget> scrollWidget;
std::shared_ptr<TimelineItem> timelineItem;

Expand Down Expand Up @@ -61,6 +66,12 @@ namespace tl
p.stopOnScrub = observer::Value<bool>::create(true);
p.itemOptions = observer::Value<ItemOptions>::create();

p.window = gl::GLFWWindow::create(
"tl::timelineui::TimelineWidget",
math::Size2i(1, 1),
context,
static_cast<int>(gl::GLFWWindowOptions::None));

p.scrollWidget = ui::ScrollWidget::create(
context,
ui::ScrollType::Both,
Expand Down Expand Up @@ -505,6 +516,7 @@ namespace tl
p.scale,
p.itemOptions->get(),
p.itemData,
p.window,
context);
p.timelineItem->setEditable(p.editable->get());
p.timelineItem->setStopOnScrub(p.stopOnScrub->get());
Expand Down
22 changes: 14 additions & 8 deletions lib/tlUI/ThumbnailSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,24 @@ namespace tl
};

void ThumbnailGenerator::_init(
const std::shared_ptr<system::Context>& context)
const std::shared_ptr<system::Context>& context,
const std::shared_ptr<gl::GLFWWindow>& window)
{
TLRENDER_P();

p.context = context;

p.cache = context->getSystem<ThumbnailSystem>()->getCache();

p.window = gl::GLFWWindow::create(
"tl::ui::ThumbnailGenerator",
math::Size2i(1, 1),
context,
static_cast<int>(gl::GLFWWindowOptions::None));
p.window = window;
if (!p.window)
{
p.window = gl::GLFWWindow::create(
"tl::ui::ThumbnailGenerator",
math::Size2i(1, 1),
context,
static_cast<int>(gl::GLFWWindowOptions::None));
}

p.thread.ioCache.setMax(1000);
p.thread.running = true;
Expand Down Expand Up @@ -335,10 +340,11 @@ namespace tl
}

std::shared_ptr<ThumbnailGenerator> ThumbnailGenerator::create(
const std::shared_ptr<system::Context>& context)
const std::shared_ptr<system::Context>& context,
const std::shared_ptr<gl::GLFWWindow>& window)
{
auto out = std::shared_ptr<ThumbnailGenerator>(new ThumbnailGenerator);
out->_init(context);
out->_init(context, window);
return out;
}

Expand Down
12 changes: 10 additions & 2 deletions lib/tlUI/ThumbnailSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

namespace tl
{
namespace gl
{
class GLFWWindow;
}

namespace ui
{
//! Information request.
Expand Down Expand Up @@ -135,7 +140,9 @@ namespace tl
class ThumbnailGenerator : public std::enable_shared_from_this<ThumbnailGenerator>
{
protected:
void _init(const std::shared_ptr<system::Context>&);
void _init(
const std::shared_ptr<system::Context>&,
const std::shared_ptr<gl::GLFWWindow>&);

ThumbnailGenerator();

Expand All @@ -144,7 +151,8 @@ namespace tl

//! Create a new thumbnail generator.
static std::shared_ptr<ThumbnailGenerator> create(
const std::shared_ptr<system::Context>&);
const std::shared_ptr<system::Context>&,
const std::shared_ptr<gl::GLFWWindow>& = nullptr);

//! Get information.
InfoRequest getInfo(
Expand Down

0 comments on commit 8a65985

Please sign in to comment.