Optimizing iteration

prefix ++i is faster than post i++
This commit is contained in:
Bruno
2021-04-18 11:38:03 +02:00
parent 8389010002
commit c6d01c1420
19 changed files with 84 additions and 77 deletions

View File

@@ -90,7 +90,7 @@ void Action::store(const std::string &label)
// save all sources using source visitor // save all sources using source visitor
SessionVisitor sv(&history_doc_, sessionNode); SessionVisitor sv(&history_doc_, sessionNode);
for (auto iter = se->begin(); iter != se->end(); iter++, sv.setRoot(sessionNode) ) for (auto iter = se->begin(); iter != se->end(); ++iter, sv.setRoot(sessionNode) )
(*iter)->accept(sv); (*iter)->accept(sv);
// debug // debug
@@ -189,7 +189,7 @@ void Action::snapshot(const std::string &label)
// save all sources using source visitor // save all sources using source visitor
SessionVisitor sv(&snapshots_doc_, sessionNode); SessionVisitor sv(&snapshots_doc_, sessionNode);
for (auto iter = se->begin(); iter != se->end(); iter++, sv.setRoot(sessionNode) ) for (auto iter = se->begin(); iter != se->end(); ++iter, sv.setRoot(sessionNode) )
(*iter)->accept(sv); (*iter)->accept(sv);
// TODO: copy action history instead? // TODO: copy action history instead?

View File

@@ -72,7 +72,7 @@ GlmToolkit::AxisAlignedBoundingBox BoundingBoxVisitor::AABB(SourceList l, View *
{ {
// calculate bbox on selection // calculate bbox on selection
BoundingBoxVisitor selection_visitor_bbox; BoundingBoxVisitor selection_visitor_bbox;
for (auto it = l.begin(); it != l.end(); it++) { for (auto it = l.begin(); it != l.end(); ++it) {
// calculate bounding box of area covered by selection // calculate bounding box of area covered by selection
selection_visitor_bbox.setModelview( view->scene.ws()->transform_ ); selection_visitor_bbox.setModelview( view->scene.ws()->transform_ );
(*it)->group( view->mode() )->accept(selection_visitor_bbox); (*it)->group( view->mode() )->accept(selection_visitor_bbox);
@@ -86,7 +86,7 @@ GlmToolkit::OrientedBoundingBox BoundingBoxVisitor::OBB(SourceList l, View *view
GlmToolkit::OrientedBoundingBox obb_; GlmToolkit::OrientedBoundingBox obb_;
// try the orientation of each source in the list // try the orientation of each source in the list
for (auto source_it = l.begin(); source_it != l.end(); source_it++) { for (auto source_it = l.begin(); source_it != l.end(); ++source_it) {
float angle = (*source_it)->group( view->mode() )->rotation_.z; float angle = (*source_it)->group( view->mode() )->rotation_.z;
glm::mat4 transform = view->scene.ws()->transform_; glm::mat4 transform = view->scene.ws()->transform_;
@@ -94,7 +94,7 @@ GlmToolkit::OrientedBoundingBox BoundingBoxVisitor::OBB(SourceList l, View *view
// calculate bbox of the list in this orientation // calculate bbox of the list in this orientation
BoundingBoxVisitor selection_visitor_bbox; BoundingBoxVisitor selection_visitor_bbox;
for (auto it = l.begin(); it != l.end(); it++) { for (auto it = l.begin(); it != l.end(); ++it) {
// calculate bounding box of area covered by sources' nodes // calculate bounding box of area covered by sources' nodes
selection_visitor_bbox.setModelview( transform ); selection_visitor_bbox.setModelview( transform );
(*it)->group( view->mode() )->accept(selection_visitor_bbox); (*it)->group( view->mode() )->accept(selection_visitor_bbox);

View File

@@ -197,7 +197,7 @@ void GeometryView::draw()
std::vector<Node *> surfaces; std::vector<Node *> surfaces;
std::vector<Node *> overlays; std::vector<Node *> overlays;
for (auto source_iter = Mixer::manager().session()->begin(); for (auto source_iter = Mixer::manager().session()->begin();
source_iter != Mixer::manager().session()->end(); source_iter++) { source_iter != Mixer::manager().session()->end(); ++source_iter) {
// if it is in the current workspace // if it is in the current workspace
if ((*source_iter)->workspace() == Settings::application.current_workspace) { if ((*source_iter)->workspace() == Settings::application.current_workspace) {
// will draw its surface // will draw its surface
@@ -320,7 +320,7 @@ void GeometryView::draw()
// batch manipulation of sources in Geometry view // batch manipulation of sources in Geometry view
if (ImGui::Selectable( ICON_FA_EXPAND " Fit all" )){ if (ImGui::Selectable( ICON_FA_EXPAND " Fit all" )){
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){ for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->scale_ = glm::vec3(output_surface_->scale_.x/ (*sit)->frame()->aspectRatio(), 1.f, 1.f); (*sit)->group(mode_)->scale_ = glm::vec3(output_surface_->scale_.x/ (*sit)->frame()->aspectRatio(), 1.f, 1.f);
(*sit)->group(mode_)->rotation_.z = 0; (*sit)->group(mode_)->rotation_.z = 0;
(*sit)->group(mode_)->translation_ = glm::vec3(0.f); (*sit)->group(mode_)->translation_ = glm::vec3(0.f);
@@ -330,7 +330,7 @@ void GeometryView::draw()
} }
if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset all" )){ if (ImGui::Selectable( ICON_FA_VECTOR_SQUARE " Reset all" )){
// apply to every sources in selection // apply to every sources in selection
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){ for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->scale_ = glm::vec3(1.f); (*sit)->group(mode_)->scale_ = glm::vec3(1.f);
(*sit)->group(mode_)->rotation_.z = 0; (*sit)->group(mode_)->rotation_.z = 0;
(*sit)->group(mode_)->crop_ = glm::vec3(1.f); (*sit)->group(mode_)->crop_ = glm::vec3(1.f);
@@ -352,7 +352,7 @@ void GeometryView::draw()
} }
if (ImGui::Selectable( ICON_FA_COMPASS " Align" )){ if (ImGui::Selectable( ICON_FA_COMPASS " Align" )){
// apply to every sources in selection // apply to every sources in selection
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){ for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
(*sit)->group(mode_)->rotation_.z = overlay_selection_->rotation_.z; (*sit)->group(mode_)->rotation_.z = overlay_selection_->rotation_.z;
(*sit)->touch(); (*sit)->touch();
} }
@@ -414,7 +414,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
// find if the current source was picked // find if the current source was picked
auto itp = pv.rbegin(); auto itp = pv.rbegin();
for (; itp != pv.rend(); itp++){ for (; itp != pv.rend(); ++itp){
// test if source contains this node // test if source contains this node
Source::hasNode is_in_source((*itp).first ); Source::hasNode is_in_source((*itp).first );
if ( is_in_source( current ) ){ if ( is_in_source( current ) ){
@@ -452,7 +452,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
pick = { nullptr, glm::vec2(0.f) }; pick = { nullptr, glm::vec2(0.f) };
// loop over all nodes picked to detect clic on locks // loop over all nodes picked to detect clic on locks
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){ for (auto itp = pv.rbegin(); itp != pv.rend(); ++itp){
// get if a source was picked // get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first); Source *s = Mixer::manager().findSource((*itp).first);
// lock icon of a source (not current) is picked : unlock // lock icon of a source (not current) is picked : unlock
@@ -466,7 +466,7 @@ std::pair<Node *, glm::vec2> GeometryView::pick(glm::vec2 P)
if ( pick.first == nullptr) { if ( pick.first == nullptr) {
// loop over all nodes picked // loop over all nodes picked
for (auto itp = pv.rbegin(); itp != pv.rend(); itp++){ for (auto itp = pv.rbegin(); itp != pv.rend(); ++itp){
// get if a source was picked // get if a source was picked
Source *s = Mixer::manager().findSource((*itp).first); Source *s = Mixer::manager().findSource((*itp).first);
// accept picked sources in current workspaces // accept picked sources in current workspaces
@@ -518,7 +518,7 @@ bool GeometryView::canSelect(Source *s) {
void GeometryView::applySelectionTransform(glm::mat4 M) void GeometryView::applySelectionTransform(glm::mat4 M)
{ {
for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); sit++){ for (auto sit = Mixer::selection().begin(); sit != Mixer::selection().end(); ++sit){
// recompute all from matrix transform // recompute all from matrix transform
glm::mat4 transform = M * (*sit)->stored_status_->transform_; glm::mat4 transform = M * (*sit)->stored_status_->transform_;
glm::vec3 tra, rot, sca; glm::vec3 tra, rot, sca;
@@ -1010,7 +1010,7 @@ void GeometryView::terminate()
// restore of all handles overlays // restore of all handles overlays
glm::vec2 c(0.f, 0.f); glm::vec2 c(0.f, 0.f);
for (auto sit = Mixer::manager().session()->begin(); for (auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++){ sit != Mixer::manager().session()->end(); ++sit){
(*sit)->handles_[mode_][Handles::RESIZE]->overlayActiveCorner(c); (*sit)->handles_[mode_][Handles::RESIZE]->overlayActiveCorner(c);
(*sit)->handles_[mode_][Handles::RESIZE_H]->overlayActiveCorner(c); (*sit)->handles_[mode_][Handles::RESIZE_H]->overlayActiveCorner(c);
@@ -1038,7 +1038,7 @@ void GeometryView::arrow (glm::vec2 movement)
bool first = true; bool first = true;
glm::vec3 delta_translation(0.f); glm::vec3 delta_translation(0.f);
for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
// individual move with SHIFT // individual move with SHIFT
if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() ) if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() )

View File

@@ -79,7 +79,7 @@ void GlmToolkit::AxisAlignedBoundingBox::extend(const glm::vec3& point)
void GlmToolkit::AxisAlignedBoundingBox::extend(std::vector<glm::vec3> points) void GlmToolkit::AxisAlignedBoundingBox::extend(std::vector<glm::vec3> points)
{ {
for (auto p = points.begin(); p != points.end(); p++) for (auto p = points.begin(); p != points.end(); ++p)
extend(*p); extend(*p);
} }

View File

@@ -1,6 +1,9 @@
#include "Interpolator.h" #include "Interpolator.h"
Interpolator::Interpolator() Interpolator::Interpolator(Source *subject, const SourceCore &target) :
subject_(subject), cursor_(0.f)
{ {
from_ = static_cast<SourceCore> (*subject);
to_ = target;
} }

View File

@@ -6,9 +6,9 @@
class Interpolator class Interpolator
{ {
public: public:
Interpolator(); Interpolator(Source *subject, const SourceCore &target);
Source *target_; Source *subject_;
SourceCore from_; SourceCore from_;
SourceCore to_; SourceCore to_;

View File

@@ -19,7 +19,7 @@ MixingGroup::MixingGroup (SourceList sources) : parent_(nullptr), root_(nullptr)
id_ = GlmToolkit::uniqueId(); id_ = GlmToolkit::uniqueId();
// fill the vector of sources with the given list // fill the vector of sources with the given list
for (auto it = sources.begin(); it != sources.end(); it++){ for (auto it = sources.begin(); it != sources.end(); ++it){
// add only if not linked already // add only if not linked already
if ((*it)->mixinggroup_ == nullptr) { if ((*it)->mixinggroup_ == nullptr) {
(*it)->mixinggroup_ = this; (*it)->mixinggroup_ = this;
@@ -43,7 +43,7 @@ MixingGroup::MixingGroup (SourceList sources) : parent_(nullptr), root_(nullptr)
MixingGroup::~MixingGroup () MixingGroup::~MixingGroup ()
{ {
for (auto it = sources_.begin(); it != sources_.end(); it++) for (auto it = sources_.begin(); it != sources_.end(); ++it)
(*it)->clearMixingGroup(); (*it)->clearMixingGroup();
if (parent_) if (parent_)
@@ -71,7 +71,7 @@ void MixingGroup::recenter()
{ {
// compute barycenter (0) // compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f); center_pos_ = glm::vec2(0.f, 0.f);
for (auto it = sources_.begin(); it != sources_.end(); it++){ for (auto it = sources_.begin(); it != sources_.end(); ++it){
// compute barycenter (1) // compute barycenter (1)
center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_); center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
} }
@@ -126,7 +126,7 @@ void MixingGroup::update (float)
// compute barycenter (0) // compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f); center_pos_ = glm::vec2(0.f, 0.f);
auto it = sources_.begin(); auto it = sources_.begin();
for (; it != sources_.end(); it++){ for (; it != sources_.end(); ++it){
// update point // update point
p[ index_points_[*it] ] = glm::vec2((*it)->group(View::MIXING)->translation_); p[ index_points_[*it] ] = glm::vec2((*it)->group(View::MIXING)->translation_);
@@ -160,7 +160,7 @@ void MixingGroup::update (float)
// compute barycenter (0) // compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f); center_pos_ = glm::vec2(0.f, 0.f);
auto it = sources_.begin(); auto it = sources_.begin();
for (; it != sources_.end(); it++){ for (; it != sources_.end(); ++it){
// modify all but the already updated source // modify all but the already updated source
if ( *it != updated_source_ && !(*it)->locked() ) { if ( *it != updated_source_ && !(*it)->locked() ) {
@@ -196,7 +196,7 @@ void MixingGroup::update (float)
int numactions = 0; int numactions = 0;
auto it = sources_.begin(); auto it = sources_.begin();
for (; it != sources_.end(); it++){ for (; it != sources_.end(); ++it){
// modify all but the already updated source // modify all but the already updated source
if ( *it != updated_source_ && !(*it)->locked() ) { if ( *it != updated_source_ && !(*it)->locked() ) {
@@ -256,7 +256,7 @@ void MixingGroup::detach (Source *s)
void MixingGroup::detach (SourceList l) void MixingGroup::detach (SourceList l)
{ {
for (auto sit = l.begin(); sit != l.end(); sit++) { for (auto sit = l.begin(); sit != l.end(); ++sit) {
// find the source // find the source
SourceList::iterator its = std::find(sources_.begin(), sources_.end(), *sit); SourceList::iterator its = std::find(sources_.begin(), sources_.end(), *sit);
// ok, its in the list ! // ok, its in the list !
@@ -291,7 +291,7 @@ void MixingGroup::attach (Source *s)
void MixingGroup::attach (SourceList l) void MixingGroup::attach (SourceList l)
{ {
for (auto sit = l.begin(); sit != l.end(); sit++) { for (auto sit = l.begin(); sit != l.end(); ++sit) {
if ( (*sit)->mixinggroup_ == nullptr) { if ( (*sit)->mixinggroup_ == nullptr) {
// tell the source // tell the source
(*sit)->mixinggroup_ = this; (*sit)->mixinggroup_ = this;
@@ -359,7 +359,7 @@ void MixingGroup::createLineStrip()
// path linking all sources // path linking all sources
std::vector<glm::vec2> path; std::vector<glm::vec2> path;
for (auto it = sources_.begin(); it != sources_.end(); it++){ for (auto it = sources_.begin(); it != sources_.end(); ++it){
index_points_[*it] = path.size(); index_points_[*it] = path.size();
path.push_back(glm::vec2((*it)->group(View::MIXING)->translation_)); path.push_back(glm::vec2((*it)->group(View::MIXING)->translation_));
} }

View File

@@ -495,7 +495,7 @@ void MixingView::terminate()
// terminate all mixing group actions // terminate all mixing group actions
for (auto g = Mixer::manager().session()->beginMixingGroup(); for (auto g = Mixer::manager().session()->beginMixingGroup();
g != Mixer::manager().session()->endMixingGroup(); g++) g != Mixer::manager().session()->endMixingGroup(); ++g)
(*g)->setAction( MixingGroup::ACTION_FINISH ); (*g)->setAction( MixingGroup::ACTION_FINISH );
} }
@@ -528,7 +528,7 @@ void MixingView::arrow (glm::vec2 movement)
bool first = true; bool first = true;
glm::vec3 delta_translation(0.f); glm::vec3 delta_translation(0.f);
for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
// individual move with SHIFT // individual move with SHIFT
if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() ) if ( !Source::isCurrent(*it) && UserInterface::manager().shiftModifier() )

View File

@@ -61,7 +61,7 @@ void Selection::set(SourceList l)
{ {
clear(); clear();
for(auto it = l.begin(); it != l.end(); it++) for(auto it = l.begin(); it != l.end(); ++it)
(*it)->setMode(Source::SELECTED); (*it)->setMode(Source::SELECTED);
l.sort(); l.sort();
@@ -71,7 +71,7 @@ void Selection::set(SourceList l)
void Selection::add(SourceList l) void Selection::add(SourceList l)
{ {
for(auto it = l.begin(); it != l.end(); it++) for(auto it = l.begin(); it != l.end(); ++it)
(*it)->setMode(Source::SELECTED); (*it)->setMode(Source::SELECTED);
// generate new set as union of current selection and give list // generate new set as union of current selection and give list
@@ -86,7 +86,7 @@ void Selection::add(SourceList l)
void Selection::remove(SourceList l) void Selection::remove(SourceList l)
{ {
for(auto it = l.begin(); it != l.end(); it++) for(auto it = l.begin(); it != l.end(); ++it)
(*it)->setMode(Source::VISIBLE); (*it)->setMode(Source::VISIBLE);
// generate new set as difference of current selection and give list // generate new set as difference of current selection and give list
@@ -98,7 +98,7 @@ void Selection::remove(SourceList l)
void Selection::clear() void Selection::clear()
{ {
for(auto it = selection_.begin(); it != selection_.end(); it++) for(auto it = selection_.begin(); it != selection_.end(); ++it)
(*it)->setMode(Source::VISIBLE); (*it)->setMode(Source::VISIBLE);
selection_.clear(); selection_.clear();

View File

@@ -66,7 +66,7 @@ void Session::setActive (bool on)
{ {
if (active_ != on) { if (active_ != on) {
active_ = on; active_ = on;
for(auto it = sources_.begin(); it != sources_.end(); it++) { for(auto it = sources_.begin(); it != sources_.end(); ++it) {
(*it)->setActive(active_); (*it)->setActive(active_);
} }
} }
@@ -308,7 +308,7 @@ int Session::index(SourceList::iterator it) const
{ {
int index = -1; int index = -1;
int count = 0; int count = 0;
for(auto i = sources_.begin(); i != sources_.end(); i++, count++) { for(auto i = sources_.begin(); i != sources_.end(); ++i, ++count) {
if ( i == it ) { if ( i == it ) {
index = count; index = count;
break; break;
@@ -341,7 +341,7 @@ bool Session::canlink (SourceList sources)
// verify that all sources given are valid in the sesion // verify that all sources given are valid in the sesion
validate(sources); validate(sources);
for (auto it = sources.begin(); it != sources.end(); it++) { for (auto it = sources.begin(); it != sources.end(); ++it) {
// this source is linked // this source is linked
if ( (*it)->mixingGroup() != nullptr ) { if ( (*it)->mixingGroup() != nullptr ) {
// askt its group to detach it // askt its group to detach it
@@ -376,7 +376,7 @@ void Session::unlink (SourceList sources)
validate(sources); validate(sources);
// brute force : detach all given sources // brute force : detach all given sources
for (auto it = sources.begin(); it != sources.end(); it++) { for (auto it = sources.begin(); it != sources.end(); ++it) {
// this source is linked // this source is linked
if ( (*it)->mixingGroup() != nullptr ) { if ( (*it)->mixingGroup() != nullptr ) {
// askt its group to detach it // askt its group to detach it
@@ -413,7 +413,7 @@ std::list<SourceList> Session::getMixingGroups () const
{ {
std::list<SourceList> lmg; std::list<SourceList> lmg;
for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); group_it++) for (auto group_it = mixing_groups_.begin(); group_it!= mixing_groups_.end(); ++group_it)
lmg.push_back( (*group_it)->getCopy() ); lmg.push_back( (*group_it)->getCopy() );
return lmg; return lmg;

View File

@@ -97,7 +97,7 @@ void SessionCreator::load(const std::string& filename)
// create groups // create groups
std::list< SourceList > groups = getMixingGroups(); std::list< SourceList > groups = getMixingGroups();
for (auto group_it = groups.begin(); group_it != groups.end(); group_it++) for (auto group_it = groups.begin(); group_it != groups.end(); ++group_it)
session_->link( *group_it ); session_->link( *group_it );
// load snapshots // load snapshots
@@ -185,10 +185,10 @@ std::list< SourceList > SessionLoader::getMixingGroups() const
std::list< SourceList > groups_new_sources_id; std::list< SourceList > groups_new_sources_id;
// perform conversion from xml id to new id // perform conversion from xml id to new id
for (auto git = groups_sources_id_.begin(); git != groups_sources_id_.end(); git++) for (auto git = groups_sources_id_.begin(); git != groups_sources_id_.end(); ++git)
{ {
SourceList new_sources; SourceList new_sources;
for (auto sit = (*git).begin(); sit != (*git).end(); sit++ ) { for (auto sit = (*git).begin(); sit != (*git).end(); ++sit ) {
if (sources_id_.count(*sit) > 0) if (sources_id_.count(*sit) > 0)
new_sources.push_back( sources_id_.at(*sit) ); new_sources.push_back( sources_id_.at(*sit) );
} }

View File

@@ -45,7 +45,7 @@ bool SessionVisitor::saveSession(const std::string& filename, Session *session)
XMLElement *sessionNode = xmlDoc.NewElement("Session"); XMLElement *sessionNode = xmlDoc.NewElement("Session");
xmlDoc.InsertEndChild(sessionNode); xmlDoc.InsertEndChild(sessionNode);
SessionVisitor sv(&xmlDoc, sessionNode); SessionVisitor sv(&xmlDoc, sessionNode);
for (auto iter = session->begin(); iter != session->end(); iter++, sv.setRoot(sessionNode) ) for (auto iter = session->begin(); iter != session->end(); ++iter, sv.setRoot(sessionNode) )
// source visitor // source visitor
(*iter)->accept(sv); (*iter)->accept(sv);
@@ -184,7 +184,7 @@ void SessionVisitor::visit(Switch &n)
if (recursive_) { if (recursive_) {
// loop over members of the group // loop over members of the group
XMLElement *group = xmlCurrent_; XMLElement *group = xmlCurrent_;
for(uint i = 0; i < n.numChildren(); i++) { for(uint i = 0; i < n.numChildren(); ++i) {
n.child(i)->accept(*this); n.child(i)->accept(*this);
// revert to group as current // revert to group as current
xmlCurrent_ = group; xmlCurrent_ = group;
@@ -258,7 +258,7 @@ void SessionVisitor::visit(MediaPlayer &n)
// gaps in timeline // gaps in timeline
XMLElement *gapselement = xmlDoc_->NewElement("Gaps"); XMLElement *gapselement = xmlDoc_->NewElement("Gaps");
TimeIntervalSet gaps = n.timeline()->gaps(); TimeIntervalSet gaps = n.timeline()->gaps();
for( auto it = gaps.begin(); it!= gaps.end(); it++) { for( auto it = gaps.begin(); it!= gaps.end(); ++it) {
XMLElement *g = xmlDoc_->NewElement("Interval"); XMLElement *g = xmlDoc_->NewElement("Interval");
g->SetAttribute("begin", (*it).begin); g->SetAttribute("begin", (*it).begin);
g->SetAttribute("end", (*it).end); g->SetAttribute("end", (*it).end);
@@ -520,7 +520,7 @@ void SessionVisitor::visit (SessionGroupSource& s)
XMLElement *sessionNode = xmlDoc_->NewElement("Session"); XMLElement *sessionNode = xmlDoc_->NewElement("Session");
xmlCurrent_->InsertEndChild(sessionNode); xmlCurrent_->InsertEndChild(sessionNode);
for (auto iter = se->begin(); iter != se->end(); iter++){ for (auto iter = se->begin(); iter != se->end(); ++iter){
setRoot(sessionNode); setRoot(sessionNode);
(*iter)->accept(*this); (*iter)->accept(*this);
} }
@@ -569,7 +569,7 @@ void SessionVisitor::visit (MixingGroup& g)
{ {
xmlCurrent_->SetAttribute("size", g.size()); xmlCurrent_->SetAttribute("size", g.size());
for (auto it = g.begin(); it != g.end(); it++) { for (auto it = g.begin(); it != g.end(); ++it) {
XMLElement *sour = xmlDoc_->NewElement("source"); XMLElement *sour = xmlDoc_->NewElement("source");
sour->SetAttribute("id", (*it)->id()); sour->SetAttribute("id", (*it)->id());
xmlCurrent_->InsertEndChild(sour); xmlCurrent_->InsertEndChild(sour);
@@ -591,7 +591,7 @@ std::string SessionVisitor::getClipboard(SourceList list)
// fill doc by visiting sources // fill doc by visiting sources
SourceList selection_clones_; SourceList selection_clones_;
SessionVisitor sv(&xmlDoc, selectionNode); SessionVisitor sv(&xmlDoc, selectionNode);
for (auto iter = list.begin(); iter != list.end(); iter++, sv.setRoot(selectionNode) ){ for (auto iter = list.begin(); iter != list.end(); ++iter, sv.setRoot(selectionNode) ){
// start with clones // start with clones
CloneSource *clone = dynamic_cast<CloneSource *>(*iter); CloneSource *clone = dynamic_cast<CloneSource *>(*iter);
if (clone) if (clone)
@@ -600,7 +600,7 @@ std::string SessionVisitor::getClipboard(SourceList list)
selection_clones_.push_back(*iter); selection_clones_.push_back(*iter);
} }
// add others in front // add others in front
for (auto iter = selection_clones_.begin(); iter != selection_clones_.end(); iter++, sv.setRoot(selectionNode) ){ for (auto iter = selection_clones_.begin(); iter != selection_clones_.end(); ++iter, sv.setRoot(selectionNode) ){
(*iter)->accept(sv); (*iter)->accept(sv);
} }

View File

@@ -175,7 +175,7 @@ void Settings::Save()
recentsession->SetAttribute("autosave", application.recentSessions.save_on_exit); recentsession->SetAttribute("autosave", application.recentSessions.save_on_exit);
recentsession->SetAttribute("valid", application.recentSessions.front_is_valid); recentsession->SetAttribute("valid", application.recentSessions.front_is_valid);
for(auto it = application.recentSessions.filenames.begin(); for(auto it = application.recentSessions.filenames.begin();
it != application.recentSessions.filenames.end(); it++) { it != application.recentSessions.filenames.end(); ++it) {
XMLElement *fileNode = xmlDoc.NewElement("path"); XMLElement *fileNode = xmlDoc.NewElement("path");
XMLText *text = xmlDoc.NewText( (*it).c_str() ); XMLText *text = xmlDoc.NewText( (*it).c_str() );
fileNode->InsertEndChild( text ); fileNode->InsertEndChild( text );
@@ -185,7 +185,7 @@ void Settings::Save()
XMLElement *recentfolder = xmlDoc.NewElement( "Folder" ); XMLElement *recentfolder = xmlDoc.NewElement( "Folder" );
for(auto it = application.recentFolders.filenames.begin(); for(auto it = application.recentFolders.filenames.begin();
it != application.recentFolders.filenames.end(); it++) { it != application.recentFolders.filenames.end(); ++it) {
XMLElement *fileNode = xmlDoc.NewElement("path"); XMLElement *fileNode = xmlDoc.NewElement("path");
XMLText *text = xmlDoc.NewText( (*it).c_str() ); XMLText *text = xmlDoc.NewText( (*it).c_str() );
fileNode->InsertEndChild( text ); fileNode->InsertEndChild( text );
@@ -196,7 +196,7 @@ void Settings::Save()
XMLElement *recentmedia = xmlDoc.NewElement( "Import" ); XMLElement *recentmedia = xmlDoc.NewElement( "Import" );
recentmedia->SetAttribute("path", application.recentImport.path.c_str()); recentmedia->SetAttribute("path", application.recentImport.path.c_str());
for(auto it = application.recentImport.filenames.begin(); for(auto it = application.recentImport.filenames.begin();
it != application.recentImport.filenames.end(); it++) { it != application.recentImport.filenames.end(); ++it) {
XMLElement *fileNode = xmlDoc.NewElement("path"); XMLElement *fileNode = xmlDoc.NewElement("path");
XMLText *text = xmlDoc.NewText( (*it).c_str() ); XMLText *text = xmlDoc.NewText( (*it).c_str() );
fileNode->InsertEndChild( text ); fileNode->InsertEndChild( text );

View File

@@ -61,6 +61,11 @@ SourceCore::~SourceCore()
groups_.clear(); groups_.clear();
} }
void SourceCore::store (View::Mode m)
{
stored_status_->copyTransform(groups_[m]);
}
SourceCore& SourceCore::operator= (SourceCore const& other) SourceCore& SourceCore::operator= (SourceCore const& other)
{ {
if (this != &other) { // no self assignment if (this != &other) { // no self assignment
@@ -70,6 +75,7 @@ SourceCore& SourceCore::operator= (SourceCore const& other)
groups_[View::GEOMETRY]->copyTransform( other.group(View::GEOMETRY) ); groups_[View::GEOMETRY]->copyTransform( other.group(View::GEOMETRY) );
groups_[View::LAYER]->copyTransform( other.group(View::LAYER) ); groups_[View::LAYER]->copyTransform( other.group(View::LAYER) );
groups_[View::TEXTURE]->copyTransform( other.group(View::TEXTURE) ); groups_[View::TEXTURE]->copyTransform( other.group(View::TEXTURE) );
groups_[View::TRANSITION]->copyTransform( other.group(View::TRANSITION) );
stored_status_->copyTransform( other.stored_status_ ); stored_status_->copyTransform( other.stored_status_ );
// copy shader properties // copy shader properties
@@ -277,7 +283,7 @@ Source::~Source()
links_.front()->disconnect(); links_.front()->disconnect();
// inform clones that they lost their origin // inform clones that they lost their origin
for (auto it = clones_.begin(); it != clones_.end(); it++) for (auto it = clones_.begin(); it != clones_.end(); ++it)
(*it)->detach(); (*it)->detach();
clones_.clear(); clones_.clear();
@@ -320,18 +326,18 @@ void Source::setMode(Source::Mode m)
{ {
// make visible on first time // make visible on first time
if ( mode_ == Source::UNINITIALIZED ) { if ( mode_ == Source::UNINITIALIZED ) {
for (auto g = groups_.begin(); g != groups_.end(); g++) for (auto g = groups_.begin(); g != groups_.end(); ++g)
(*g).second->visible_ = true; (*g).second->visible_ = true;
} }
// choose frame 0 if visible, 1 if selected // choose frame 0 if visible, 1 if selected
uint index_frame = m == Source::VISIBLE ? 0 : 1; uint index_frame = m == Source::VISIBLE ? 0 : 1;
for (auto f = frames_.begin(); f != frames_.end(); f++) for (auto f = frames_.begin(); f != frames_.end(); ++f)
(*f).second->setActive(index_frame); (*f).second->setActive(index_frame);
// show overlay if current // show overlay if current
bool current = m >= Source::CURRENT; bool current = m >= Source::CURRENT;
for (auto o = overlays_.begin(); o != overlays_.end(); o++) for (auto o = overlays_.begin(); o != overlays_.end(); ++o)
(*o).second->visible_ = (current && !locked_); (*o).second->visible_ = (current && !locked_);
// the lock icon // the lock icon
@@ -483,7 +489,7 @@ void Source::setActive (bool on)
active_ = on; active_ = on;
// do not disactivate if a clone depends on it // do not disactivate if a clone depends on it
for(auto clone = clones_.begin(); clone != clones_.end(); clone++) { for(auto clone = clones_.begin(); clone != clones_.end(); ++clone) {
if ( (*clone)->active() ) if ( (*clone)->active() )
active_ = true; active_ = true;
} }
@@ -762,13 +768,13 @@ bool Source::hasNode::operator()(const Source* elem) const
// general case: traverse tree of all Groups recursively using a SearchVisitor // general case: traverse tree of all Groups recursively using a SearchVisitor
SearchVisitor sv(_n); SearchVisitor sv(_n);
// search in groups for all views // search in groups for all views
for (auto g = elem->groups_.begin(); g != elem->groups_.end(); g++) { for (auto g = elem->groups_.begin(); g != elem->groups_.end(); ++g) {
(*g).second->accept(sv); (*g).second->accept(sv);
if (sv.found()) if (sv.found())
return true; return true;
} }
// search in overlays for all views // search in overlays for all views
for (auto g = elem->overlays_.begin(); g != elem->overlays_.end(); g++) { for (auto g = elem->overlays_.begin(); g != elem->overlays_.end(); ++g) {
(*g).second->accept(sv); (*g).second->accept(sv);
if (sv.found()) if (sv.found())
return true; return true;

View File

@@ -32,6 +32,7 @@ public:
// get handle on the nodes used to manipulate the source in a view // get handle on the nodes used to manipulate the source in a view
inline Group *group (View::Mode m) const { return groups_.at(m); } inline Group *group (View::Mode m) const { return groups_.at(m); }
inline Node *groupNode (View::Mode m) const { return static_cast<Node*>(groups_.at(m)); } inline Node *groupNode (View::Mode m) const { return static_cast<Node*>(groups_.at(m)); }
void store (View::Mode m);
// a Source has a shader used to render in fbo // a Source has a shader used to render in fbo
inline Shader *renderingShader () const { return renderingshader_; } inline Shader *renderingShader () const { return renderingshader_; }

View File

@@ -49,7 +49,7 @@ SourceIdList ids (const SourceList &list)
{ {
SourceIdList idlist; SourceIdList idlist;
for( auto sit = list.begin(); sit != list.end(); sit++) for( auto sit = list.begin(); sit != list.end(); ++sit)
idlist.push_back( (*sit)->id() ); idlist.push_back( (*sit)->id() );
// make sure no duplicate // make sure no duplicate
@@ -67,7 +67,7 @@ SourceListCompare compare (const SourceList &first, const SourceList &second)
// a new test list: start with the second list and remove all commons with first list // a new test list: start with the second list and remove all commons with first list
SourceList test = second; SourceList test = second;
for (auto it = first.begin(); it != first.end(); it++){ for (auto it = first.begin(); it != first.end(); ++it){
test.remove(*it); test.remove(*it);
} }
@@ -100,12 +100,12 @@ SourceList intersect (const SourceList &first, const SourceList &second)
// take second list and remove all elements also in first list // take second list and remove all elements also in first list
// -> builds the list of what remains in second list // -> builds the list of what remains in second list
SourceList l1 = second; SourceList l1 = second;
for (auto it = first.begin(); it != first.end(); it++) for (auto it = first.begin(); it != first.end(); ++it)
l1.remove(*it); l1.remove(*it);
// take second list and remove all elements in the remainer list // take second list and remove all elements in the remainer list
// -> builds the list of what is in second list and was part of the first list // -> builds the list of what is in second list and was part of the first list
SourceList l2 = second; SourceList l2 = second;
for (auto it = l1.begin(); it != l1.end(); it++) for (auto it = l1.begin(); it != l1.end(); ++it)
l2.remove(*it); l2.remove(*it);
return l2; return l2;
} }
@@ -114,7 +114,7 @@ SourceList intersect (const SourceList &first, const SourceList &second)
SourceList join (const SourceList &first, const SourceList &second) SourceList join (const SourceList &first, const SourceList &second)
{ {
SourceList l = second; SourceList l = second;
for (auto it = first.begin(); it != first.end(); it++) for (auto it = first.begin(); it != first.end(); ++it)
l.push_back(*it); l.push_back(*it);
l.unique(); l.unique();
return l; return l;

View File

@@ -232,7 +232,7 @@ void Stream::close()
desired_state_ = GST_STATE_PAUSED; desired_state_ = GST_STATE_PAUSED;
// cleanup eventual remaining frame memory // cleanup eventual remaining frame memory
for(guint i = 0; i < N_FRAME; i++){ for(guint i = 0; i < N_FRAME; ++i){
frame_[i].access.lock(); frame_[i].access.lock();
frame_[i].unmap(); frame_[i].unmap();
frame_[i].access.unlock(); frame_[i].access.unlock();
@@ -710,7 +710,7 @@ void Stream::TimeCounter::tic ()
GstClockTime dt = t - last_time; GstClockTime dt = t - last_time;
// one more frame since last time // one more frame since last time
nbFrames++; ++nbFrames;
// calculate instantaneous framerate // calculate instantaneous framerate
// Exponential moving averate with previous framerate to filter jitter (50/50) // Exponential moving averate with previous framerate to filter jitter (50/50)

View File

@@ -561,7 +561,7 @@ void UserInterface::handleMouse()
{ {
if (!shift_modifier_active) { if (!shift_modifier_active) {
// grab others from selection // grab others from selection
for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); it++) { for (auto it = Mixer::selection().begin(); it != Mixer::selection().end(); ++it) {
if ( *it != current ) if ( *it != current )
Mixer::manager().view()->grab(*it, mouseclic[ImGuiMouseButton_Left], mouse_smooth, picked); Mixer::manager().view()->grab(*it, mouseclic[ImGuiMouseButton_Left], mouse_smooth, picked);
} }
@@ -1152,7 +1152,7 @@ void UserInterface::RenderPreview()
if (ls.size()>0) { if (ls.size()>0) {
ImGui::Separator(); ImGui::Separator();
ImGui::MenuItem("Active streams", nullptr, false, false); ImGui::MenuItem("Active streams", nullptr, false, false);
for (auto it = ls.begin(); it != ls.end(); it++) for (auto it = ls.begin(); it != ls.end(); ++it)
ImGui::Text(" %s", (*it).c_str() ); ImGui::Text(" %s", (*it).c_str() );
} }
@@ -2037,7 +2037,7 @@ void MediaController::Render()
setMediaPlayer(); setMediaPlayer();
// display list of available media // display list of available media
for (auto mpit = MediaPlayer::begin(); mpit != MediaPlayer::end(); mpit++ ) for (auto mpit = MediaPlayer::begin(); mpit != MediaPlayer::end(); ++mpit )
{ {
std::string label = (*mpit)->filename(); std::string label = (*mpit)->filename();
if (ImGui::MenuItem( label.c_str() )) if (ImGui::MenuItem( label.c_str() ))
@@ -2185,7 +2185,7 @@ void MediaController::Render()
if (ImGui::BeginMenu("Smooth curve")) if (ImGui::BeginMenu("Smooth curve"))
{ {
const char* names[] = { "Just a little", "A bit more", "Quite a lot"}; const char* names[] = { "Just a little", "A bit more", "Quite a lot"};
for (int i = 0; i < IM_ARRAYSIZE(names); i++) { for (int i = 0; i < IM_ARRAYSIZE(names); ++i) {
if (ImGui::MenuItem(names[i])) { if (ImGui::MenuItem(names[i])) {
mp_->timeline()->smoothFading( 10 * (int) pow(4, i) ); mp_->timeline()->smoothFading( 10 * (int) pow(4, i) );
Action::manager().store("Timeline Smooth curve"); Action::manager().store("Timeline Smooth curve");
@@ -2196,7 +2196,7 @@ void MediaController::Render()
if (ImGui::BeginMenu("Auto fading")) if (ImGui::BeginMenu("Auto fading"))
{ {
const char* names[] = { "250 ms", "500 ms", "1 second", "2 seconds"}; const char* names[] = { "250 ms", "500 ms", "1 second", "2 seconds"};
for (int i = 0; i < IM_ARRAYSIZE(names); i++) { for (int i = 0; i < IM_ARRAYSIZE(names); ++i) {
if (ImGui::MenuItem(names[i])) { if (ImGui::MenuItem(names[i])) {
mp_->timeline()->autoFading( 250 * (int ) pow(2, i) ); mp_->timeline()->autoFading( 250 * (int ) pow(2, i) );
mp_->timeline()->smoothFading( 10 * (i + 1) ); mp_->timeline()->smoothFading( 10 * (i + 1) );

View File

@@ -114,11 +114,8 @@ void View::initiate()
{ {
current_action_ = ""; current_action_ = "";
for (auto sit = Mixer::manager().session()->begin(); for (auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++){ sit != Mixer::manager().session()->end(); ++sit)
(*sit)->store(mode_);
(*sit)->stored_status_->copyTransform((*sit)->group(mode_));
}
} }
void View::terminate() void View::terminate()
@@ -190,7 +187,7 @@ void View::selectAll()
{ {
Mixer::selection().clear(); Mixer::selection().clear();
for(auto sit = Mixer::manager().session()->begin(); for(auto sit = Mixer::manager().session()->begin();
sit != Mixer::manager().session()->end(); sit++) { sit != Mixer::manager().session()->end(); ++sit) {
if (canSelect(*sit)) if (canSelect(*sit))
Mixer::selection().add(*sit); Mixer::selection().add(*sit);
} }