From: Carl Hetherington Date: Thu, 21 Nov 2019 21:38:33 +0000 (+0100) Subject: Remove some friends from FilmViewer. X-Git-Tag: v2.15.40^2~14 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=b3b371294ed5e6cc18ef64ba1b06ca76726b903a Remove some friends from FilmViewer. --- diff --git a/src/wx/closed_captions_dialog.cc b/src/wx/closed_captions_dialog.cc index 061262cdd..afcf5fa87 100644 --- a/src/wx/closed_captions_dialog.cc +++ b/src/wx/closed_captions_dialog.cc @@ -53,6 +53,7 @@ ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer , _display (new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(640, (640 / 10) + 64))) , _track (new wxChoice(this, wxID_ANY)) , _current_in_lines (false) + , _timer (this) { _lines.resize (CLOSED_CAPTION_LINES); @@ -65,18 +66,30 @@ ClosedCaptionsDialog::ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer sizer->Add (track_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP); sizer->Add (_display, 1, wxEXPAND); + Bind (wxEVT_SHOW, boost::bind(&ClosedCaptionsDialog::shown, this, _1)); + Bind (wxEVT_TIMER, boost::bind(&ClosedCaptionsDialog::update, this)); _display->Bind (wxEVT_PAINT, boost::bind(&ClosedCaptionsDialog::paint, this)); _track->Bind (wxEVT_CHOICE, boost::bind(&ClosedCaptionsDialog::track_selected, this)); SetSizerAndFit (sizer); } +void +ClosedCaptionsDialog::shown (wxShowEvent ev) +{ + if (ev.IsShown ()) { + _timer.Start (40); + } else { + _timer.Stop (); + } +} + void ClosedCaptionsDialog::track_selected () { _current = optional (); _viewer->slow_refresh (); - update (_last_update); + update (); } void @@ -131,9 +144,9 @@ private: }; void -ClosedCaptionsDialog::update (DCPTime time) +ClosedCaptionsDialog::update () { - _last_update = time; + DCPTime const time = _viewer->time (); if (_current_in_lines && _current && _current->period.to > time) { /* Current one is fine */ diff --git a/src/wx/closed_captions_dialog.h b/src/wx/closed_captions_dialog.h index fb4e9d59b..5c366ca7b 100644 --- a/src/wx/closed_captions_dialog.h +++ b/src/wx/closed_captions_dialog.h @@ -31,11 +31,12 @@ class ClosedCaptionsDialog : public wxDialog public: explicit ClosedCaptionsDialog (wxWindow* parent, FilmViewer* viewer); - void update (dcpomatic::DCPTime); void clear (); void set_film_and_butler (boost::shared_ptr, boost::weak_ptr); private: + void shown (wxShowEvent); + void update (); void paint (); void track_selected (); @@ -47,5 +48,5 @@ private: std::vector _lines; std::vector _tracks; boost::weak_ptr _butler; - dcpomatic::DCPTime _last_update; + wxTimer _timer; }; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 7437612af..dcbfedc81 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -88,12 +88,10 @@ FilmViewer::FilmViewer (wxWindow* p) , _latency_history_count (0) , _closed_captions_dialog (new ClosedCaptionsDialog(p, this)) , _outline_content (false) - , _eyes (EYES_LEFT) , _pad_black (false) #ifdef DCPOMATIC_VARIANT_SWAROOP , _background_image (false) #endif - , _gets (0) , _idle_get (false) { switch (Config::instance()->video_view_type()) { @@ -234,7 +232,7 @@ FilmViewer::set_outline_content (bool o) void FilmViewer::set_eyes (Eyes e) { - _eyes = e; + _video_view->set_eyes (e); slow_refresh (); } @@ -651,3 +649,10 @@ FilmViewer::dropped () const return _video_view->dropped (); } +int +FilmViewer::gets () const +{ + return _video_view->gets (); +} + + diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 21195e747..ec481f34e 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -92,7 +92,11 @@ public: void slow_refresh (); + dcpomatic::DCPTime time () const; + boost::optional audio_time () const; + int dropped () const; + int gets () const; int audio_callback (void* out, unsigned int frames); @@ -107,10 +111,6 @@ public: } #endif - int gets () const { - return _gets; - } - StateTimer const & state_timer () const { return _video_view->state_timer (); } @@ -143,11 +143,6 @@ public: private: - /* XXX_b: to remove */ - friend class SimpleVideoView; - friend class GLVideoView; - friend class VideoView; - void video_view_sized (); void calculate_sizes (); void player_change (ChangeType type, int, bool); @@ -158,8 +153,6 @@ private: void config_changed (Config::Property); void film_length_change (); - dcpomatic::DCPTime time () const; - boost::optional audio_time () const; dcpomatic::DCPTime uncorrected_time () const; Frame average_latency () const; @@ -192,7 +185,6 @@ private: ClosedCaptionsDialog* _closed_captions_dialog; bool _outline_content; - Eyes _eyes; /** true to pad the viewer panel with black, false to use the normal window background colour. */ @@ -202,8 +194,6 @@ private: bool _background_image; #endif - int _gets; - /** true if an get() is required next time we are idle */ bool _idle_get; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 63dc10200..22e4db887 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -253,6 +253,4 @@ SimpleVideoView::display_player_video () _inter_size = player_video().first->inter_size (); update (); - - _viewer->closed_captions_dialog()->update (_viewer->time()); } diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index e65888656..5dd857fab 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -30,7 +30,9 @@ VideoView::VideoView (FilmViewer* viewer) #endif , _state_timer ("viewer") , _video_frame_rate (0) + , _eyes (EYES_LEFT) , _dropped (0) + , _gets (0) { } @@ -54,7 +56,7 @@ VideoView::get_next_frame (bool non_blocking) } DCPOMATIC_ASSERT (_viewer->butler()); - _viewer->_gets++; + add_get (); boost::mutex::scoped_lock lm (_mutex); @@ -67,7 +69,7 @@ VideoView::get_next_frame (bool non_blocking) } while ( _player_video.first && _viewer->film()->three_d() && - _viewer->_eyes != _player_video.first->eyes() && + _eyes != _player_video.first->eyes() && _player_video.first->eyes() != EYES_BOTH ); diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 4a94aa879..fd2684e41 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -23,6 +23,7 @@ #include "lib/dcpomatic_time.h" #include "lib/timer.h" +#include "lib/types.h" #include #include #include @@ -63,6 +64,11 @@ public: return _dropped; } + int gets () const { + boost::mutex::scoped_lock lm (_mutex); + return _gets; + } + StateTimer const & state_timer () const { return _state_timer; } @@ -82,6 +88,11 @@ public: _length = len; } + void set_eyes (Eyes eyes) { + boost::mutex::scoped_lock lm (_mutex); + _eyes = eyes; + } + protected: /* XXX_b: to remove */ friend class FilmViewer; @@ -110,6 +121,11 @@ protected: ++_dropped; } + void add_get () { + boost::mutex::scoped_lock lm (_mutex); + ++_gets; + } + FilmViewer* _viewer; #ifdef DCPOMATIC_VARIANT_SWAROOP @@ -128,8 +144,10 @@ private: int _video_frame_rate; /** length of the film we are playing, or 0 if there is none */ dcpomatic::DCPTime _length; + Eyes _eyes; int _dropped; + int _gets; }; #endif