From: Carl Hetherington Date: Fri, 10 May 2019 15:37:16 +0000 (+0100) Subject: Fix update on drag with GL canvas. X-Git-Tag: v2.15.1~3 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=e153d7f5dc128d97160e41bdda3c4e4a05c7140b;ds=sidebyside Fix update on drag with GL canvas. --- diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 00bc06e9b..cb12a78e2 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -215,9 +215,8 @@ FilmViewer::recreate_butler () void FilmViewer::refresh_view () { - _state_timer.set ("refresh-view"); - _video_view->get()->Refresh (); - _video_view->get()->Update (); + _state_timer.set ("update-view"); + _video_view->update (); _state_timer.unset (); } diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index f75d50f9d..b3f036ded 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -41,7 +41,7 @@ GLVideoView::GLVideoView (wxWindow *parent) { _canvas = new wxGLCanvas (parent, wxID_ANY, 0, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE); _context = new wxGLContext (_canvas); - _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this, _1)); + _canvas->Bind (wxEVT_PAINT, boost::bind(&GLVideoView::paint, this)); _canvas->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized))); glGenTextures (1, &_id); @@ -65,10 +65,26 @@ check_gl_error (char const * last) } void -GLVideoView::paint (wxPaintEvent &) +GLVideoView::paint () { _canvas->SetCurrent (*_context); wxPaintDC dc (_canvas); + draw (); +} + +void +GLVideoView::update () +{ + if (!_canvas->IsShownOnScreen()) { + return; + } + wxClientDC dc (_canvas); + draw (); +} + +void +GLVideoView::draw () +{ glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); check_gl_error ("glClear"); diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h index cdc9fd530..54c64e4ea 100644 --- a/src/wx/gl_video_view.h +++ b/src/wx/gl_video_view.h @@ -37,9 +37,11 @@ public: wxWindow* get () const { return _canvas; } + void update (); private: - void paint (wxPaintEvent& event); + void paint (); + void draw (); wxGLCanvas* _canvas; wxGLContext* _context; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index d0b18d421..ef0c96ef2 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -118,3 +118,10 @@ SimpleVideoView::paint () dc.DrawRectangle (inter_position.x, inter_position.y + (panel_size.GetHeight() - out_size.height) / 2, inter_size.width, inter_size.height); } } + +void +SimpleVideoView::update () +{ + _panel->Refresh (); + _panel->Update (); +} diff --git a/src/wx/simple_video_view.h b/src/wx/simple_video_view.h index 8b3ec9f0b..40924839f 100644 --- a/src/wx/simple_video_view.h +++ b/src/wx/simple_video_view.h @@ -36,6 +36,8 @@ public: return _panel; } + void update (); + private: void paint (); diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 060d982f7..44969ad2d 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -34,6 +34,7 @@ public: virtual void set_image (boost::shared_ptr image) = 0; virtual wxWindow* get () const = 0; + virtual void update () = 0; boost::signals2::signal Sized; };