changeset 27169:031a3c85ddb7

maint: merge stable to default
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Mon, 10 Jun 2019 20:43:10 +0200
parents ec6d31ef6bb6 (current diff) e6bc258df691 (diff)
children 7206b8c222eb
files libgui/graphics/GLCanvas.cc
diffstat 1 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/GLCanvas.cc	Mon Jun 10 12:59:54 2019 -0500
+++ b/libgui/graphics/GLCanvas.cc	Mon Jun 10 20:43:10 2019 +0200
@@ -135,11 +135,11 @@
                       const graphics_handle& handle)
   {
     gh_manager::auto_lock lock;
-    graphics_object obj = gh_manager::get_object (handle);
+    graphics_object go = gh_manager::get_object (handle);
 
-    if (obj.valid_object ())
+    if (go.valid_object ())
       {
-        graphics_object figObj (obj.get_ancestor ("figure"));
+        graphics_object fig (go.get_ancestor ("figure"));
 
         // Make sure we have a valid current context
         if (! begin_rendering ())
@@ -147,8 +147,34 @@
 
         try
           {
-            octave::gl2ps_print (m_glfcns, figObj, file_cmd.toStdString (),
+#if defined (Q_OS_MAC)
+            if (fig.get ("visible").string_value () == "on")
+              octave::gl2ps_print (m_glfcns, fig, file_cmd.toStdString (),
+                                   term.toStdString ());
+            else
+              {
+                // When the figure is not visible, we use a framebuffer object
+                // to make sure we are rendering on a suitably large frame.
+                Matrix pos = fig.get ("position").matrix_value ();
+                double dpr = fig.get ("__device_pixel_ratio__").double_value ();
+                pos(2) *= dpr;
+                pos(3) *= dpr;
+
+                OCTAVE_QT_OPENGL_FBO
+                  fbo (pos(2), pos(3),
+                       OCTAVE_QT_OPENGL_FBO::Attachment::Depth);
+
+                fbo.bind ();
+
+                octave::gl2ps_print (m_glfcns, fig, file_cmd.toStdString (),
+                                     term.toStdString ());
+
+                fbo.release ();
+              }
+#else
+            octave::gl2ps_print (m_glfcns, fig, file_cmd.toStdString (),
                                  term.toStdString ());
+#endif
           }
         catch (octave::execution_exception& e)
           {