Remove storage of _frame in FilmViewer.
[dcpomatic.git] / src / wx / gl_video_view.cc
index 5c18d28cb895c34855775df41ee0f997ff6598d6..0f0118e00fde0699007c82431255006216a5d82a 100644 (file)
 
 using std::cout;
 using boost::shared_ptr;
+using boost::optional;
 
 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_SIZE, boost::bind(boost::ref(Sized)));
 
        glGenTextures (1, &_id);
        glBindTexture (GL_TEXTURE_2D, _id);
@@ -116,6 +118,11 @@ GLVideoView::paint (wxPaintEvent &)
 void
 GLVideoView::set_image (shared_ptr<const Image> image)
 {
+       if (!image) {
+               _size = optional<dcp::Size>();
+               return;
+       }
+
        DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_RGB24);
        DCPOMATIC_ASSERT (!image->aligned());
 
@@ -131,6 +138,4 @@ GLVideoView::set_image (shared_ptr<const Image> image)
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        check_gl_error ("glTexParameterf");
-
-       _canvas->Refresh ();
 }