summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-02-09 14:05:46 +0100
committerCarl Hetherington <cth@carlh.net>2021-02-09 14:05:46 +0100
commit09606d58511bddc4c1abe3f2dff1a8eaff13a991 (patch)
treeecb3e794f5042332f174ec83a26855d80f7d6b9f
parentabe21002bc84db630d860bc304261497cfd71f9b (diff)
Handle pending player changes more efficiently.
Rather than looping over all changes, possibly calling a refresh method for each, coalesce them.
-rw-r--r--src/wx/film_viewer.cc50
-rw-r--r--src/wx/film_viewer.h1
2 files changed, 33 insertions, 18 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 1993f0011..b9e9bd533 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -67,6 +67,7 @@ using std::make_pair;
using std::exception;
using std::shared_ptr;
using std::dynamic_pointer_cast;
+using std::vector;
using std::weak_ptr;
using boost::optional;
#if BOOST_VERSION >= 106100
@@ -384,25 +385,40 @@ FilmViewer::player_change (ChangeType type, int property, bool frequent)
return;
}
+ player_change ({property});
+}
+
+void
+FilmViewer::player_change (vector<int> properties)
+{
calculate_sizes ();
- bool refreshed = false;
- if (
- property == VideoContentProperty::CROP ||
- property == VideoContentProperty::SCALE ||
- property == VideoContentProperty::FADE_IN ||
- property == VideoContentProperty::FADE_OUT ||
- property == VideoContentProperty::COLOUR_CONVERSION ||
- property == PlayerProperty::VIDEO_CONTAINER_SIZE ||
- property == PlayerProperty::FILM_CONTAINER
- ) {
- refreshed = quick_refresh ();
- }
-
- if (!refreshed) {
+
+ bool try_quick_refresh = false;
+ bool update_ccap_tracks = false;
+
+ for (auto i: properties) {
+ if (
+ i == VideoContentProperty::CROP ||
+ i == VideoContentProperty::SCALE ||
+ i == VideoContentProperty::FADE_IN ||
+ i == VideoContentProperty::FADE_OUT ||
+ i == VideoContentProperty::COLOUR_CONVERSION ||
+ i == PlayerProperty::VIDEO_CONTAINER_SIZE ||
+ i == PlayerProperty::FILM_CONTAINER
+ ) {
+ try_quick_refresh = true;
+ }
+
+ if (i == TextContentProperty::USE || i == TextContentProperty::TYPE || i == TextContentProperty::DCP_TRACK) {
+ update_ccap_tracks = true;
+ }
+ }
+
+ if (!try_quick_refresh || !quick_refresh()) {
slow_refresh ();
}
- if (property == TextContentProperty::USE || property == TextContentProperty::TYPE || property == TextContentProperty::DCP_TRACK) {
+ if (update_ccap_tracks) {
_closed_captions_dialog->update_tracks (_film);
}
}
@@ -466,9 +482,7 @@ FilmViewer::set_coalesce_player_changes (bool c)
_coalesce_player_changes = c;
if (!c) {
- for (auto i: _pending_player_changes) {
- player_change (ChangeType::DONE, i, false);
- }
+ player_change (_pending_player_changes);
_pending_player_changes.clear ();
}
}
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 125e4fd2d..8024bb1bf 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -153,6 +153,7 @@ private:
void video_view_sized ();
void calculate_sizes ();
void player_change (ChangeType type, int, bool);
+ void player_change (std::vector<int> properties);
void idle_handler ();
void request_idle_display_next_frame ();
void film_change (ChangeType, Film::Property);