GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
: VideoView (viewer)
+ , _have_storage (false)
, _vsync_enabled (false)
, _thread (0)
, _playing (false)
DCPOMATIC_ASSERT (image->pixel_format() == AV_PIX_FMT_RGB24);
DCPOMATIC_ASSERT (!image->aligned());
+ if (image->size() != _size) {
+ _have_storage = false;
+ }
+
_size = image->size ();
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
check_gl_error ("glPixelStorei");
- glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB8, _size->width, _size->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->data()[0]);
- check_gl_error ("glTexImage2D");
+ if (_have_storage) {
+ glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, _size->width, _size->height, GL_RGB, GL_UNSIGNED_BYTE, image->data()[0]);
+ check_gl_error ("glTexSubImage2D");
+ } else {
+ glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB8, _size->width, _size->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->data()[0]);
+ _have_storage = true;
+ check_gl_error ("glTexImage2D");
+ }
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
get_next_frame (false);
- //--
- set_image (player_video().first->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true));
- inter_position = player_video().first->inter_position();
- inter_size = player_video().first->inter_size();
+ shared_ptr<PlayerVideo> pv = player_video().first;
+ if (pv) {
+ set_image (pv->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), false, true));
+ inter_position = pv->inter_position();
+ inter_size = pv->inter_size();
+ }
}
draw (inter_position, inter_size);
- while (time_until_next_frame() < 5) {
+ while (true) {
+ optional<int> n = time_until_next_frame();
+ if (!n || *n > 5) {
+ break;
+ }
get_next_frame (true);
add_dropped ();
}
boost::this_thread::interruption_point ();
- dcpomatic_sleep_milliseconds (time_until_next_frame());
+ dcpomatic_sleep_milliseconds (time_until_next_frame().get_value_or(0));
}
/* XXX: leaks _context, but that seems preferable to deleting it here