diff libinterp/corefcn/gl-render.cc @ 25896:c1cd5561d1dc

Fix clipping of patch/surface markers (bug #54690) * gl-render.h (opengl_renderer::clip_code): Return uint8_t instead of octave_uint8. * gl-render.cc (opengl_renderer::draw_patch, opengl_renderer::draw_surface): Make use of clip_code method to decide whether to draw markers or not. Use uint8_t instead of octave_uint8 for clip codes.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 25 Sep 2018 17:24:53 +0200
parents 2da65009cc7f
children 12d4271aed87
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Mon Sep 24 21:45:36 2018 +0200
+++ b/libinterp/corefcn/gl-render.cc	Tue Sep 25 17:24:53 2018 +0200
@@ -2240,9 +2240,10 @@
     int n = static_cast<int> (std::min (std::min (x.numel (), y.numel ()),
                                         (has_z ? z.numel ()
                                          : std::numeric_limits<int>::max ())));
-    octave_uint8 clip_mask = (props.is_clipping () ? 0x7F : 0x40), clip_ok (0x40);
-
-    std::vector<octave_uint8> clip (n);
+    uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
+    uint8_t clip_ok = 0x40;
+
+    std::vector<uint8_t> clip (n);
 
     if (has_z)
       for (int i = 0; i < n; i++)
@@ -2962,6 +2963,9 @@
         init_marker (props.get_marker (), props.get_markersize (),
                      props.get_linewidth ());
 
+        uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
+        uint8_t clip_ok = 0x40;
+
         for (int i = 0; i < zc; i++)
           {
             if (y_mat)
@@ -2969,12 +2973,13 @@
 
             for (int j = 0; j < zr; j++)
               {
-                if (clip(j,i))
-                  continue;
-
                 if (x_mat)
                   j1 = j;
 
+                if ((clip_code (x(j1,i), y(j,i1), z(j,i)) & clip_mask)
+                    != clip_ok)
+                  continue;
+
                 if ((do_edge && mecolor.isempty ())
                     || (do_face && mfcolor.isempty ()))
                   {
@@ -3519,12 +3524,16 @@
         init_marker (props.get_marker (), props.get_markersize (),
                      props.get_linewidth ());
 
+        uint8_t clip_mask = (props.is_clipping () ? 0x7F : 0x40);
+        uint8_t clip_ok = 0x40;
+
         for (int i = 0; i < nf; i++)
           for (int j = 0; j < count_f(i); j++)
             {
               int idx = int (f(i,j) - 1);
 
-              if (clip(idx))
+              if ((clip_code (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0))
+                   & clip_mask) != clip_ok)
                 continue;
 
               Matrix cc;
@@ -3615,8 +3624,7 @@
 
     // Handle clipping manually when drawing text background
     if (! props.is_clipping () ||
-        (clip_code (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0) ==
-         octave_uint8 (0x40)))
+        (clip_code (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0) == 0x40))
       {
         set_clipping (false);
         draw_text_background (props);