More accurate reporting of whether vsync is enabled.
authorCarl Hetherington <cth@carlh.net>
Mon, 3 Jun 2019 16:10:53 +0000 (17:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 3 Jun 2019 16:10:53 +0000 (17:10 +0100)
src/tools/dcpomatic.cc
src/wx/gl_video_view.cc
src/wx/gl_video_view.h
src/wx/system_information_dialog.cc
src/wx/system_information_dialog.h

index 1e93977d7cee5993c0378b40eb48edf2f775d790..2fe5187b4732912c0eb3dfe56b3b015200f36d61 100644 (file)
@@ -994,7 +994,7 @@ private:
        void view_system_information ()
        {
                if (!_system_information_dialog) {
-                       _system_information_dialog = new SystemInformationDialog (this);
+                       _system_information_dialog = new SystemInformationDialog (this, _film_viewer);
                }
 
                _system_information_dialog->Show ();
index d16ac444185f59a7c2c3bd2ee2e158f078d06b1c..0e8e459d87b66cc0695f60ae85ef07c98226c0ea 100644 (file)
@@ -51,6 +51,7 @@ using boost::optional;
 
 GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
        : VideoView (viewer)
+       , _vsync_enabled (false)
 {
        _canvas = new wxGLCanvas (parent, wxID_ANY, 0, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE);
        _context = new wxGLContext (_canvas);
@@ -62,6 +63,7 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
                /* Enable vsync */
                Display* dpy = wxGetX11Display();
                glXSwapIntervalEXT (dpy, DefaultScreen(dpy), 1);
+               _vsync_enabled = true;
        }
 #endif
 
@@ -69,6 +71,7 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
        if (_canvas->IsExtensionSupported("WGL_EXT_swap_control")) {
                /* Enable vsync */
                wglSwapIntervalEXT (1);
+               _vsync_enabled = true;
        }
 
 #endif
@@ -77,6 +80,7 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
        /* Enable vsync */
        GLint swapInterval = 1;
        CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &swapInterval);
+       _vsync_enabled = true;
 #endif
 
        glGenTextures (1, &_id);
index c10f32335ec627433c12d50195354095dca6722f..ba4c7cfdc92df3a32afbc9642f3de5d8264b8fdc 100644 (file)
@@ -38,6 +38,10 @@ public:
        }
        void update ();
 
+       bool vsync_enabled () const {
+               return _vsync_enabled;
+       }
+
 private:
         void paint ();
         void draw ();
@@ -46,4 +50,5 @@ private:
         wxGLContext* _context;
         GLuint _id;
         boost::optional<dcp::Size> _size;
+       bool _vsync_enabled;
 };
index 894239b65d39c2951da638ab79aa81e5232b0a8a..0e19162027570b3222e64af29c12662c34b9c840 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -20,6 +20,8 @@
 
 #include "system_information_dialog.h"
 #include "wx_util.h"
+#include "gl_video_view.h"
+#include "film_viewer.h"
 
 #ifdef DCPOMATIC_OSX
 #include <OpenGL/glu.h>
 #endif
 
 using std::string;
+using boost::weak_ptr;
+using boost::shared_ptr;
 
-SystemInformationDialog::SystemInformationDialog (wxWindow* parent)
+SystemInformationDialog::SystemInformationDialog (wxWindow* parent, weak_ptr<FilmViewer> weak_viewer)
        : TableDialog (parent, _("System information"), 2, 1, false)
 {
        add (_("OpenGL version"), true);
@@ -42,11 +46,20 @@ SystemInformationDialog::SystemInformationDialog (wxWindow* parent)
                add (_("unknown (OpenGL not enabled in DCP-o-matic)"), false);
        }
 
+
        add (_("vsync"), true);
-#if !defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_HAVE_GLX_SWAP_INTERVAL_EXT)
-       add (_("enabled"), false);
-#else
-        add (_("disabled"), false);
-#endif
+       shared_ptr<FilmViewer> viewer = weak_viewer.lock ();
+
+       if (!viewer) {
+               add (_("unknown"), false);
+       } else {
+               GLVideoView* gl = dynamic_cast<GLVideoView*>(viewer->panel());
+               if (!gl) {
+                       add (_("unknown"), false);
+               } else {
+                       add (gl->vsync_enabled() ? _("enabled") : _("not enabled"), false);
+               }
+       }
+
        layout ();
 }
index b82c6341bad60d0af51f5072eb7b1f63e26cd5c3..63c70fba5e6fb540ef2872b0bb2812c98e5b7be2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 */
 
 #include "table_dialog.h"
+#include <boost/weak_ptr.hpp>
+
+class FilmViewer;
 
 class SystemInformationDialog : public TableDialog
 {
 public:
-       SystemInformationDialog (wxWindow* parent);
+       SystemInformationDialog (wxWindow* parent, boost::weak_ptr<FilmViewer> viewer);
 
 };