mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Optimize reordering of sources nodes in Views (perfom sorting on scenes
only if layer view changed)
This commit is contained in:
15
Mixer.cpp
15
Mixer.cpp
@@ -125,7 +125,6 @@ Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullpt
|
|||||||
setCurrentView( (View::Mode) Settings::application.current_view );
|
setCurrentView( (View::Mode) Settings::application.current_view );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mixer::update()
|
void Mixer::update()
|
||||||
{
|
{
|
||||||
// change session when threaded loading is finished
|
// change session when threaded loading is finished
|
||||||
@@ -140,6 +139,7 @@ void Mixer::update()
|
|||||||
Settings::application.recentSessions.push(sessionFilename_);
|
Settings::application.recentSessions.push(sessionFilename_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirm when threaded saving is finished
|
// confirm when threaded saving is finished
|
||||||
if (sessionSaveFinished_) {
|
if (sessionSaveFinished_) {
|
||||||
sessionSaveFinished_ = false;
|
sessionSaveFinished_ = false;
|
||||||
@@ -155,16 +155,17 @@ void Mixer::update()
|
|||||||
float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
|
float dt = static_cast<float>( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f;
|
||||||
update_time_ = current_time;
|
update_time_ = current_time;
|
||||||
|
|
||||||
// update session and associted sources
|
// update session and associated sources
|
||||||
session_->update(dt);
|
session_->update(dt);
|
||||||
|
|
||||||
// update views
|
// update views
|
||||||
mixing_.update(dt);
|
mixing_.update(dt);
|
||||||
geometry_.update(dt);
|
geometry_.update(dt);
|
||||||
layer_.update(dt);
|
layer_.update(dt);
|
||||||
// TODO other views
|
// TODO other views?
|
||||||
|
|
||||||
|
|
||||||
|
// optimize the reordering in depth for views
|
||||||
|
View::need_reordering_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::draw()
|
void Mixer::draw()
|
||||||
@@ -199,10 +200,8 @@ void Mixer::insertSource(Source *s)
|
|||||||
mixing_.scene.fg()->attach(s->group(View::MIXING));
|
mixing_.scene.fg()->attach(s->group(View::MIXING));
|
||||||
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
geometry_.scene.fg()->attach(s->group(View::GEOMETRY));
|
||||||
layer_.scene.fg()->attach(s->group(View::LAYER));
|
layer_.scene.fg()->attach(s->group(View::LAYER));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mixer::deleteCurrentSource()
|
void Mixer::deleteCurrentSource()
|
||||||
{
|
{
|
||||||
deleteSource( currentSource() );
|
deleteSource( currentSource() );
|
||||||
@@ -366,7 +365,6 @@ void Mixer::saveas(const std::string& filename)
|
|||||||
|
|
||||||
// launch a thread to save the session
|
// launch a thread to save the session
|
||||||
std::thread (saveSession, filename, session_).detach();
|
std::thread (saveSession, filename, session_).detach();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::open(const std::string& filename)
|
void Mixer::open(const std::string& filename)
|
||||||
@@ -382,10 +380,8 @@ void Mixer::open(const std::string& filename)
|
|||||||
|
|
||||||
// launch a thread to load the session into back_session
|
// launch a thread to load the session into back_session
|
||||||
std::thread (loadSession, filename, back_session_).detach();
|
std::thread (loadSession, filename, back_session_).detach();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mixer::swap()
|
void Mixer::swap()
|
||||||
{
|
{
|
||||||
if (!back_session_)
|
if (!back_session_)
|
||||||
@@ -434,7 +430,6 @@ void Mixer::swap()
|
|||||||
back_session_ = nullptr;
|
back_session_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mixer::newSession()
|
void Mixer::newSession()
|
||||||
{
|
{
|
||||||
// delete previous back session if needed
|
// delete previous back session if needed
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ void Node::update( float )
|
|||||||
{
|
{
|
||||||
// update transform matrix from attributes
|
// update transform matrix from attributes
|
||||||
transform_ = GlmToolkit::transform(translation_, rotation_, scale_);
|
transform_ = GlmToolkit::transform(translation_, rotation_, scale_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::accept(Visitor& v)
|
void Node::accept(Visitor& v)
|
||||||
|
|||||||
16
View.cpp
16
View.cpp
@@ -22,6 +22,8 @@
|
|||||||
#define CIRCLE_PIXELS 64
|
#define CIRCLE_PIXELS 64
|
||||||
#define CIRCLE_PIXEL_RADIUS 1024.0
|
#define CIRCLE_PIXEL_RADIUS 1024.0
|
||||||
|
|
||||||
|
bool View::need_reordering_ = true;
|
||||||
|
|
||||||
View::View(Mode m) : mode_(m)
|
View::View(Mode m) : mode_(m)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -43,8 +45,9 @@ void View::update(float dt)
|
|||||||
// recursive update from root of scene
|
// recursive update from root of scene
|
||||||
scene.update( dt );
|
scene.update( dt );
|
||||||
|
|
||||||
// reorder depth
|
// reorder depth if needed
|
||||||
scene.fg()->sort();
|
if (View::need_reordering_)
|
||||||
|
scene.fg()->sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::drag (glm::vec2 from, glm::vec2 to)
|
void View::drag (glm::vec2 from, glm::vec2 to)
|
||||||
@@ -84,7 +87,6 @@ MixingView::MixingView() : View(MIXING)
|
|||||||
Mesh *circle = new Mesh("mesh/circle.ply");
|
Mesh *circle = new Mesh("mesh/circle.ply");
|
||||||
circle->shader()->color = pink;
|
circle->shader()->color = pink;
|
||||||
scene.bg()->attach(circle);
|
scene.bg()->attach(circle);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MixingView::~MixingView()
|
MixingView::~MixingView()
|
||||||
@@ -106,7 +108,6 @@ void MixingView::zoom( float factor )
|
|||||||
scene.root()->scale_.y = z;
|
scene.root()->scale_.y = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>)
|
void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>)
|
||||||
{
|
{
|
||||||
if (!s)
|
if (!s)
|
||||||
@@ -133,7 +134,6 @@ void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *
|
|||||||
s->touch();
|
s->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint MixingView::textureMixingQuadratic()
|
uint MixingView::textureMixingQuadratic()
|
||||||
{
|
{
|
||||||
static GLuint texid = 0;
|
static GLuint texid = 0;
|
||||||
@@ -194,7 +194,6 @@ RenderView::~RenderView()
|
|||||||
delete frame_buffer_;
|
delete frame_buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderView::setResolution(glm::vec3 resolution)
|
void RenderView::setResolution(glm::vec3 resolution)
|
||||||
{
|
{
|
||||||
if (resolution.x < 128.f || resolution.y < 128.f)
|
if (resolution.x < 128.f || resolution.y < 128.f)
|
||||||
@@ -355,7 +354,6 @@ LayerView::LayerView() : View(LAYER), aspect_ratio(1.f)
|
|||||||
Frame *border = new Frame(Frame::ROUND_SHADOW);
|
Frame *border = new Frame(Frame::ROUND_SHADOW);
|
||||||
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 0.7f );
|
border->color = glm::vec4( 0.8f, 0.f, 0.8f, 0.7f );
|
||||||
scene.bg()->attach(border);
|
scene.bg()->attach(border);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerView::~LayerView()
|
LayerView::~LayerView()
|
||||||
@@ -365,7 +363,6 @@ LayerView::~LayerView()
|
|||||||
|
|
||||||
void LayerView::draw ()
|
void LayerView::draw ()
|
||||||
{
|
{
|
||||||
|
|
||||||
// update rendering of render frame
|
// update rendering of render frame
|
||||||
FrameBuffer *output = Mixer::manager().session()->frame();
|
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||||
if (output)
|
if (output)
|
||||||
@@ -420,5 +417,8 @@ void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *,
|
|||||||
|
|
||||||
// request update
|
// request update
|
||||||
s->touch();
|
s->touch();
|
||||||
|
|
||||||
|
// request reordering
|
||||||
|
View::need_reordering_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
View.h
4
View.h
@@ -27,6 +27,9 @@ public:
|
|||||||
|
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
|
||||||
|
// hack to avoid reordering scene of view if not necessary
|
||||||
|
static bool need_reordering_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Mode mode_;
|
Mode mode_;
|
||||||
};
|
};
|
||||||
@@ -60,7 +63,6 @@ public:
|
|||||||
glm::vec3 resolution() const { return frame_buffer_->resolution(); }
|
glm::vec3 resolution() const { return frame_buffer_->resolution(); }
|
||||||
|
|
||||||
inline FrameBuffer *frameBuffer () const { return frame_buffer_; }
|
inline FrameBuffer *frameBuffer () const { return frame_buffer_; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GeometryView : public View
|
class GeometryView : public View
|
||||||
|
|||||||
Reference in New Issue
Block a user