mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Fixed Session thumbnail
wait for all sources to be ready before creating the thumbnail.
This commit is contained in:
@@ -75,7 +75,12 @@ void RenderView::draw()
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), P);
|
||||
fading_overlay_->draw(glm::identity<glm::mat4>(), projection);
|
||||
frame_buffer_->end();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderView::drawThumbnail()
|
||||
{
|
||||
if (frame_buffer_) {
|
||||
// if a thumbnailer is pending
|
||||
if (thumbnailer_.size() > 0) {
|
||||
|
||||
@@ -97,14 +102,14 @@ void RenderView::draw()
|
||||
}
|
||||
|
||||
// return valid thumbnail promise
|
||||
thumbnailer_.front().set_value( frame_thumbnail->image() );
|
||||
thumbnailer_.back().set_value( frame_thumbnail->image() );
|
||||
|
||||
// done with thumbnailing framebuffer
|
||||
delete frame_thumbnail;
|
||||
}
|
||||
catch(...) {
|
||||
// return failed thumbnail promise
|
||||
thumbnailer_.front().set_exception(std::current_exception());
|
||||
thumbnailer_.back().set_exception(std::current_exception());
|
||||
}
|
||||
|
||||
// done with this promise
|
||||
@@ -113,7 +118,6 @@ void RenderView::draw()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FrameBufferImage *RenderView::thumbnail ()
|
||||
{
|
||||
// by default null image
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
RenderView ();
|
||||
~RenderView ();
|
||||
|
||||
// render frame (in opengl context)
|
||||
void draw () override;
|
||||
bool canSelect(Source *) override { return false; }
|
||||
|
||||
@@ -28,9 +29,11 @@ public:
|
||||
void setFading(float f = 0.f);
|
||||
float fading() const;
|
||||
|
||||
// current frame
|
||||
inline FrameBuffer *frame () const { return frame_buffer_; }
|
||||
|
||||
// get a thumbnail; wait for a promise to be fullfiled
|
||||
// get a thumbnail outside of opengl context; wait for a promise to be fullfiled after draw
|
||||
void drawThumbnail();
|
||||
FrameBufferImage *thumbnail ();
|
||||
};
|
||||
|
||||
|
||||
@@ -87,6 +87,7 @@ void Session::update(float dt)
|
||||
|
||||
// pre-render of all sources
|
||||
failedSource_ = nullptr;
|
||||
bool ready = true;
|
||||
for( SourceList::iterator it = sources_.begin(); it != sources_.end(); ++it){
|
||||
|
||||
// ensure the RenderSource is rendering this session
|
||||
@@ -98,6 +99,8 @@ void Session::update(float dt)
|
||||
failedSource_ = (*it);
|
||||
}
|
||||
else {
|
||||
if ( !(*it)->ready() )
|
||||
ready = false;
|
||||
// render the source
|
||||
(*it)->render();
|
||||
// update the source
|
||||
@@ -129,6 +132,10 @@ void Session::update(float dt)
|
||||
|
||||
// draw render view in Frame Buffer
|
||||
render_.draw();
|
||||
|
||||
// draw the thumbnail only after all sources are ready
|
||||
if (ready)
|
||||
render_.drawThumbnail();
|
||||
}
|
||||
|
||||
SourceList::iterator Session::addSource(Source *s)
|
||||
|
||||
Reference in New Issue
Block a user