X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fgl_video_view.cc;h=0a82355373e60d78a6474170dc03b47ac2207709;hb=bdcc8d8487a08c8895ab7edf2e65a734e0e10863;hp=5d9f2742fa6b165ed94b611b6464cab94b4f0d96;hpb=1b6b469e927de081367b9cf861f0a551ee43422b;p=dcpomatic.git diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 5d9f2742f..0a8235537 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -30,12 +30,13 @@ #include "film_viewer.h" #include "wx_util.h" -#include "lib/image.h" +#include "lib/butler.h" +#include "lib/cross.h" #include "lib/dcpomatic_assert.h" +#include "lib/dcpomatic_log.h" #include "lib/exceptions.h" -#include "lib/cross.h" +#include "lib/image.h" #include "lib/player_video.h" -#include "lib/butler.h" #include #include @@ -103,12 +104,15 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent) void GLVideoView::size_changed (wxSizeEvent const& ev) { - _canvas_size = ev.GetSize (); + auto const scale = _canvas->GetDPIScaleFactor(); + int const width = std::round(ev.GetSize().GetWidth() * scale); + int const height = std::round(ev.GetSize().GetHeight() * scale); + _canvas_size = { width, height }; + LOG_GENERAL("GLVideoView canvas size changed to %1x%2", width, height); Sized (); } - GLVideoView::~GLVideoView () { boost::this_thread::disable_interruption dis; @@ -376,10 +380,9 @@ GLVideoView::setup_shaders () glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length); string log; if (log_length > 0) { - char* log_char = new char[log_length]; - glGetShaderInfoLog(shader, log_length, nullptr, log_char); - log = string(log_char); - delete[] log_char; + std::vector log_char(log_length); + glGetShaderInfoLog(shader, log_length, nullptr, log_char.data()); + log = string(log_char.data()); } glDeleteShader(shader); throw GLError(String::compose("Could not compile shader (%1)", log).c_str(), -1); @@ -405,10 +408,9 @@ GLVideoView::setup_shaders () glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length); string log; if (log_length > 0) { - char* log_char = new char[log_length]; - glGetProgramInfoLog(program, log_length, nullptr, log_char); - log = string(log_char); - delete[] log_char; + std::vector log_char(log_length); + glGetProgramInfoLog(program, log_length, nullptr, log_char.data()); + log = string(log_char.data()); } glDeleteProgram (program); throw GLError(String::compose("Could not link shader (%1)", log).c_str(), -1); @@ -622,7 +624,7 @@ GLVideoView::set_image (shared_ptr pv) glBufferSubData (GL_ARRAY_BUFFER, 0, video.size(), video.vertices()); check_gl_error ("glBufferSubData (video)"); - const auto border = Rectangle(canvas_size, inter_position.x, inter_position.y, inter_size); + const auto border = Rectangle(canvas_size, inter_position.x + x_offset, inter_position.y + y_offset, inter_size); glBufferSubData (GL_ARRAY_BUFFER, 8 * 5 * sizeof(float), border.size(), border.vertices()); check_gl_error ("glBufferSubData (border)"); } @@ -695,7 +697,11 @@ GLVideoView::set_image_and_draw () auto pv = player_video().first; if (pv) { set_image (pv); - draw (); + } + + draw (); + + if (pv) { _viewer->image_changed (pv); } }