diff libinterp/corefcn/gl-render.cc @ 26564:c40b3b671513 stable

Fixed dash pattern when figure "__device_pixel_ratio__" is not 1 (bug #55484) * gl-render.cc (opengl_renderer::set_linestyle): Compute the repetition factor based on m_devpixelratio.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Wed, 16 Jan 2019 23:38:19 +0100
parents bdf03ab385c2
children 879f22ca59c8
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Mon Jan 14 09:17:48 2019 +0900
+++ b/libinterp/corefcn/gl-render.cc	Wed Jan 16 23:38:19 2019 +0100
@@ -3875,10 +3875,10 @@
 
     if (vp_lim_min(0) > vp_lim_max(0))
       std::swap (vp_lim_min(0), vp_lim_max(0));
-        
+
     if (vp_lim_min(1) > vp_lim_max(1))
       std::swap (vp_lim_min(1), vp_lim_max(1));
-        
+
     float clip_xmin =
       (do_clip ? (vp_lim_min(0) > xmin ? vp_lim_min(0) : xmin) : vp_lim_min(0));
     float clip_ymin =
@@ -4246,21 +4246,26 @@
   {
 #if defined (HAVE_OPENGL)
 
+    int factor = math::round (linewidth * m_devpixratio);
+    if (factor < 1)
+      factor = 1;
+
+    uint16_t pattern = 0xFFFF;
+
     bool solid = false;
 
     if (s == "-")
-      {
-        m_glfcns.glLineStipple (1, static_cast<unsigned short> (0xFFFF));
-        solid = true;
-      }
+      solid = true;
     else if (s == ":")
-      m_glfcns.glLineStipple (linewidth, static_cast<unsigned short> (0x5555));
+      pattern = 0x5555;
     else if (s == "--")
-      m_glfcns.glLineStipple (linewidth, static_cast<unsigned short> (0x0F0F));
+      pattern = 0x0F0F;
     else if (s == "-.")
-      m_glfcns.glLineStipple (linewidth, static_cast<unsigned short> (0x6F6F));
+      pattern = 0x6F6F;
     else
-      m_glfcns.glLineStipple (1, static_cast<unsigned short> (0x0000));
+      pattern = 0x0000;
+
+    m_glfcns.glLineStipple (factor, pattern);
 
     if (solid && ! use_stipple)
       m_glfcns.glDisable (GL_LINE_STIPPLE);