Cleanup: remove unused parameter to PlayerVideo::force.
[dcpomatic.git] / src / wx / gl_video_view.cc
index 5d9f2742fa6b165ed94b611b6464cab94b4f0d96..dee45cd13bc4e99fafd1313265d353c3a707e02f 100644 (file)
 
 #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 <boost/bind/bind.hpp>
 #include <iostream>
 
@@ -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;
@@ -504,7 +508,7 @@ GLVideoView::draw ()
 void
 GLVideoView::set_image (shared_ptr<const PlayerVideo> pv)
 {
-       shared_ptr<const Image> video = _optimise_for_j2k ? pv->raw_image() : pv->image(bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+       shared_ptr<const Image> video = _optimise_for_j2k ? pv->raw_image() : pv->image(boost::bind(&PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, true);
 
        /* Only the player's black frames should be aligned at this stage, so this should
         * almost always have no work to do.
@@ -622,7 +626,7 @@ GLVideoView::set_image (shared_ptr<const PlayerVideo> 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 +699,11 @@ GLVideoView::set_image_and_draw ()
        auto pv = player_video().first;
        if (pv) {
                set_image (pv);
-               draw ();
+       }
+
+       draw ();
+
+       if (pv) {
                _viewer->image_changed (pv);
        }
 }