Merge branch 'master' into 28
authorCampbell Barton <ideasman42@gmail.com>
Thu, 20 Apr 2017 08:16:01 +0000 (18:16 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 20 Apr 2017 08:16:01 +0000 (18:16 +1000)
1  2 
source/blender/editors/include/UI_interface.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_view3d/drawobject.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_window.c

index a6550b322650445378ccdc3dcdac4d81ebb229d1,2a63d09411690d0064c16bc93f861f00f2c55a9b..8170ee9b2b364b4a279226eec1253e69263aac3b
@@@ -3373,9 -3425,7 +3373,8 @@@ void node_draw_link_bezier(View2D *v2d
                /* store current linewidth */
                float linew;
                float arrow[2], arrow1[2], arrow2[2];
-               const float px_fac = UI_DPI_WINDOW_FAC;
                glGetFloatv(GL_LINE_WIDTH, &linew);
 +              unsigned int pos;
                
                /* we can reuse the dist variable here to increment the GL curve eval amount*/
                dist = 1.0f / (float)LINK_RESOL;
                        arrow[0] = coord_array[LINK_ARROW][0];
                        arrow[1] = coord_array[LINK_ARROW][1];
                }
 +
 +              if (do_triple || drawarrow || (!do_shaded)) {
 +                      pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
 +                      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +              }
 +
                if (do_triple) {
 -                      UI_ThemeColorShadeAlpha(th_col3, -80, -120);
 +                      immUniformThemeColorShadeAlpha(th_col3, -80, -120);
-                       glLineWidth(4.0f * px_fac);
+                       glLineWidth(4.0f);
 -                      
 -                      glBegin(GL_LINE_STRIP);
 +
 +                      immBegin(PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
                        for (i = 0; i <= LINK_RESOL; i++) {
 -                              glVertex2fv(coord_array[i]);
 +                              immVertex2fv(pos, coord_array[i]);
                        }
 -                      glEnd();
 +
 +                      immEnd();
 +
                        if (drawarrow) {
 -                              glBegin(GL_LINE_STRIP);
 -                              glVertex2fv(arrow1);
 -                              glVertex2fv(arrow);
 -                              glVertex2fv(arrow2);
 -                              glEnd();
 +                              immBegin(PRIM_LINE_STRIP, 3);
 +                              immVertex2fv(pos, arrow1);
 +                              immVertex2fv(pos, arrow);
 +                              immVertex2fv(pos, arrow2);
 +                              immEnd();
                        }
                }
 -              
 -              /* XXX using GL_LINES for shaded node lines is a workaround
 -               * for Intel hardware, this breaks with GL_LINE_STRIP and
 -               * changing color in begin/end blocks.
 -               */
 +
-               glLineWidth(1.5f * px_fac);
+               glLineWidth(1.5f);
 -              if (do_shaded) {
 -                      glBegin(GL_LINES);
 -                      for (i = 0; i < LINK_RESOL; i++) {
 -                              UI_ThemeColorBlend(th_col1, th_col2, spline_step);
 -                              glVertex2fv(coord_array[i]);
 -                              
 -                              UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist);
 -                              glVertex2fv(coord_array[i + 1]);
 -                              
 -                              spline_step += dist;
 -                      }
 -                      glEnd();
 +
 +              if (drawarrow) {
 +                      immUniformThemeColorBlend(th_col1, th_col2, 0.5f);
 +
 +                      immBegin(PRIM_LINE_STRIP, 3);
 +                      immVertex2fv(pos, arrow1);
 +                      immVertex2fv(pos, arrow);
 +                      immVertex2fv(pos, arrow2);
 +                      immEnd();
                }
 -              else {
 -                      UI_ThemeColor(th_col1);
 -                      glBegin(GL_LINE_STRIP);
 +
 +              if (!do_shaded) {
 +                      immUniformThemeColor(th_col1);
 +
 +                      immBegin(PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
                        for (i = 0; i <= LINK_RESOL; i++) {
 -                              glVertex2fv(coord_array[i]);
 +                              immVertex2fv(pos, coord_array[i]);
                        }
 -                      glEnd();
 +
 +                      immEnd();
                }
 -              
 -              if (drawarrow) {
 -                      glBegin(GL_LINE_STRIP);
 -                      glVertex2fv(arrow1);
 -                      glVertex2fv(arrow);
 -                      glVertex2fv(arrow2);
 -                      glEnd();
 +
 +              if (do_triple || drawarrow || (!do_shaded)) {
 +                      immUnbindProgram();
                }
 -              
 -              glDisable(GL_LINE_SMOOTH);
 -      }
 -}
  
 -#if 0 /* not used in 2.5x yet */
 -static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2])
 -{
 -      if (link->fromsock) {
 -              coord_array[0][0] = link->fromsock->locx;
 -              coord_array[0][1] = link->fromsock->locy;
 -      }
 -      else {
 -              if (snode == NULL) return;
 -              coord_array[0][0] = snode->mx;
 -              coord_array[0][1] = snode->my;
 -      }
 -      if (link->tosock) {
 -              coord_array[1][0] = link->tosock->locx;
 -              coord_array[1][1] = link->tosock->locy;
 -      }
 -      else {
 -              if (snode == NULL) return;
 -              coord_array[1][0] = snode->mx;
 -              coord_array[1][1] = snode->my;
 -      }
 -}
 +              if (do_shaded) {
 +                      unsigned char col[3];
  
 -void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
 -                             int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
 -{
 -      float coord_array[2][2];
 -      int i;
 -      
 -      node_link_straight_points(v2d, snode, link, coord_array);
 -      
 -      glEnable(GL_LINE_SMOOTH);
 -      
 -      if (do_triple) {
 -              UI_ThemeColorShadeAlpha(th_col3, -80, -120);
 -              glLineWidth(4.0f);
 -              
 -              glBegin(GL_LINES);
 -              glVertex2fv(coord_array[0]);
 -              glVertex2fv(coord_array[1]);
 -              glEnd();
 -      }
 -      
 -      UI_ThemeColor(th_col1);
 -      glLineWidth(1.5f);
 -      
 -      /* XXX using GL_LINES for shaded node lines is a workaround
 -       * for Intel hardware, this breaks with GL_LINE_STRIP and
 -       * changing color in begin/end blocks.
 -       */
 -      if (do_shaded) {
 -              glBegin(GL_LINES);
 -              for (i = 0; i < LINK_RESOL - 1; ++i) {
 -                      float t = (float)i / (float)(LINK_RESOL - 1);
 -                      UI_ThemeColorBlend(th_col1, th_col2, t);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 -                      
 -                      t = (float)(i + 1) / (float)(LINK_RESOL - 1);
 -                      UI_ThemeColorBlend(th_col1, th_col2, t);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 -              }
 -              glEnd();
 -      }
 -      else {
 -              glBegin(GL_LINE_STRIP);
 -              for (i = 0; i < LINK_RESOL; ++i) {
 -                      float t = (float)i / (float)(LINK_RESOL - 1);
 -                      glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 -                                 (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
 +                      VertexFormat *format = immVertexFormat();
 +                      pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
 +                      unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
 +
 +                      immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 +
 +                      immBegin(PRIM_LINE_STRIP, (LINK_RESOL + 1));
 +
 +                      for (i = 0; i <= LINK_RESOL; i++) {
 +                              UI_GetThemeColorBlend3ubv(th_col1, th_col2, spline_step, col);
 +                              immAttrib3ubv(color, col);
 +
 +                              immVertex2fv(pos, coord_array[i]);
 +
 +                              spline_step += dist;
 +                      }
 +
 +                      immEnd();
 +
 +                      immUnbindProgram();
                }
 -              glEnd();
 +              
 +              glDisable(GL_LINE_SMOOTH);
        }
 -      
 -      glDisable(GL_LINE_SMOOTH);
  }
 -#endif
  
  /* note; this is used for fake links in groups too */
  void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
index b80167ce676ee938edb6ae76950736f7b406ff98,71e10c9dffc2e22c9921187be1936f64d365c65b..adf17117dae63508467877cdbc7b62460b019403
@@@ -7336,82 -6405,49 +7336,79 @@@ static void draw_editnurb
         * when at its lowest, don't render normals */
        if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
                BevList *bl;
 +
 +              VertexFormat *format = immVertexFormat();
 +              unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
 +              immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 +              immUniformThemeColor(TH_WIRE_EDIT);
 +
                glLineWidth(1.0f);
 +
 +              int count = 0;
 +              int count_used = 0;
                for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
 -                      BevPoint *bevp = bl->bevpoints;
                        int nr = bl->nr;
                        int skip = nu->resolu / 16;
 -                      
 +
 +#if 0
                        while (nr-- > 0) { /* accounts for empty bevel lists */
 -                              const float fac = bevp->radius * ts->normalsize;
 -                              float vec_a[3]; /* Offset perpendicular to the curve */
 -                              float vec_b[3]; /* Delta along the curve */
 +                              count += 4;
 +                              nr -= skip;
 +                      }
 +#else
 +                      /* Same as loop above */
 +                      count += 4 * max_ii((nr + max_ii(skip - 1, 0)) / (skip + 1), 0);
 +#endif
 +              }
  
 -                              vec_a[0] = fac;
 -                              vec_a[1] = 0.0f;
 -                              vec_a[2] = 0.0f;
 -                              
 -                              mul_qt_v3(bevp->quat, vec_a);
 -                              madd_v3_v3fl(vec_a, bevp->dir, -fac);
 +              if (count > 2) {
 +                      immBegin(PRIM_LINES, count);
 +                      for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
 +                              BevPoint *bevp = bl->bevpoints;
 +                              int nr = bl->nr;
 +                              int skip = nu->resolu / 16;
  
 -                              reflect_v3_v3v3(vec_b, vec_a, bevp->dir);
 -                              negate_v3(vec_b);
 +                              while (nr-- > 0) { /* accounts for empty bevel lists */
 +                                      const float fac = bevp->radius * ts->normalsize;
 +                                      float vec_a[3]; /* Offset perpendicular to the curve */
 +                                      float vec_b[3]; /* Delta along the curve */
  
 -                              add_v3_v3(vec_a, bevp->vec);
 -                              add_v3_v3(vec_b, bevp->vec);
 +                                      vec_a[0] = fac;
 +                                      vec_a[1] = 0.0f;
 +                                      vec_a[2] = 0.0f;
++                      
++                                      mul_qt_v3(bevp->quat, vec_a);
++                                      madd_v3_v3fl(vec_a, bevp->dir, -fac);
  
-                                       vec_b[0] = -fac;
-                                       vec_b[1] = 0.0f;
-                                       vec_b[2] = 0.0f;
 -                              glBegin(GL_LINE_STRIP);
 -                              glVertex3fv(vec_a);
 -                              glVertex3fv(bevp->vec);
 -                              glVertex3fv(vec_b);
 -                              glEnd();
 -                              
 -                              bevp += skip + 1;
 -                              nr -= skip;
++                                      reflect_v3_v3v3(vec_b, vec_a, bevp->dir);
++                                      negate_v3(vec_b);
 +
-                                       mul_qt_v3(bevp->quat, vec_a);
-                                       mul_qt_v3(bevp->quat, vec_b);
 +                                      add_v3_v3(vec_a, bevp->vec);
 +                                      add_v3_v3(vec_b, bevp->vec);
 +
-                                       madd_v3_v3fl(vec_a, bevp->dir, -fac);
-                                       madd_v3_v3fl(vec_b, bevp->dir, -fac);
 +                                      immVertex3fv(pos, vec_a);
 +                                      immVertex3fv(pos, bevp->vec);
 +                                      immVertex3fv(pos, bevp->vec);
 +                                      immVertex3fv(pos, vec_b);
 +
 +                                      bevp += skip + 1;
 +                                      nr -= skip;
 +                                      count_used += 4;
 +                              }
                        }
 +                      BLI_assert(count == count_used);
 +                      UNUSED_VARS_NDEBUG(count_used);
 +
 +                      immEnd();
                }
 +              immUnbindProgram();
        }
  
 -      if (v3d->zbuf) glDepthFunc(GL_ALWAYS);
 -      
 -      for (nu = nurb; nu; nu = nu->next) {
 -              drawvertsN(nu, 1, hide_handles, vert);
 -      }
 -      
 -      if (v3d->zbuf) glDepthFunc(GL_LEQUAL);
 +      if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
 +
 +      drawvertsN(nurb, hide_handles, vert);
 +
 +      if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
  }
  
  static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
Simple merge