Commit: 37994e0af2cf6f0d7ed8a072eb765dfb022ceaef
Author: Campbell Barton
Date:   Sun Jul 1 20:15:21 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB37994e0af2cf6f0d7ed8a072eb765dfb022ceaef

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc source/blender/editors/interface/interface_draw.c
index da1135da00a,50cd1c544c4..3e724fd5c5c
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@@ -81,84 -78,15 +81,86 @@@ int UI_draw_roundbox_corner_get(void
  {
        return roundboxtype;
  }
 +#endif
 +
 +void UI_draw_roundbox_3ubAlpha(bool filled, float minx, float miny, float 
maxx, float maxy, float rad, const unsigned char col[3], unsigned char alpha)
 +{
 +      float colv[4];
 +      colv[0] = ((float)col[0]) / 255;
 +      colv[1] = ((float)col[1]) / 255;
 +      colv[2] = ((float)col[2]) / 255;
 +      colv[3] = ((float)alpha) / 255;
 +      UI_draw_roundbox_4fv(filled, minx, miny, maxx, maxy, rad, colv);
 +}
 +
 +void UI_draw_roundbox_3fvAlpha(bool filled, float minx, float miny, float 
maxx, float maxy, float rad, const float col[3], float alpha)
 +{
 +      float colv[4];
 +      colv[0] = col[0];
 +      colv[1] = col[1];
 +      colv[2] = col[2];
 +      colv[3] = alpha;
 +      UI_draw_roundbox_4fv(filled, minx, miny, maxx, maxy, rad, colv);
 +}
  
 -void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, 
float maxy, float rad)
 +void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, 
float maxy, float rad, const float color[4])
  {
 +      uiWidgetBaseParameters widget_params = {
 +              .recti.xmin = minx, .recti.ymin = miny,
 +              .recti.xmax = maxx, .recti.ymax = maxy,
 +              .radi = rad,
 +              .round_corners[0] = (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 1.0f 
: 0.0f,
 +              .round_corners[1] = (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 1.0f 
: 0.0f,
 +              .round_corners[2] = (roundboxtype & UI_CNR_TOP_RIGHT) ? 1.0f : 
0.0f,
 +              .round_corners[3] = (roundboxtype & UI_CNR_TOP_LEFT) ? 1.0f : 
0.0f,
 +              .color_inner1[0] = color[0], .color_inner2[0] = color[0],
 +              .color_inner1[1] = color[1], .color_inner2[1] = color[1],
 +              .color_inner1[2] = color[2], .color_inner2[2] = color[2],
 +              .color_inner1[3] = color[3], .color_inner2[3] = color[3],
 +              .alpha_discard = 1.0f,
 +      };
 +
 +      GPU_blend(true);
 +
 +      if (filled) {
 +              /* plain antialiased filled box */
 +              widget_params.color_inner1[3] *= 0.125f;
 +              widget_params.color_inner2[3] *= 0.125f;
 +
 +              /* WATCH: This is assuming the ModelViewProjectionMatrix is 
area pixel space.
 +               * If it has been scaled, then it's no longer valid. */
 +              Gwn_Batch *batch = ui_batch_roundbox_get(filled, true);
 +              GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
 +              GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float 
*)&widget_params);
 +              GWN_batch_draw(batch);
 +      }
 +      else {
 +              /* plain antialiased unfilled box */
 +              GPU_line_smooth(true);
 +
 +              Gwn_Batch *batch = ui_batch_roundbox_get(filled, false);
 +              GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
 +              GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float 
*)&widget_params);
 +              GWN_batch_draw(batch);
 +
 +              GPU_line_smooth(false);
 +      }
 +
 +      GPU_blend(false);
 +}
 +
 +void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, 
float maxy, float rad, const float col[4])
 +{
 +#if 0
-       float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, 
{0.707, 0.293},
-                          {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+       float vec[7][2] = {
+               {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+               {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
+       };
        int a;
  
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 
2, GWN_FETCH_FLOAT);
 +
        /* mult */
        for (a = 0; a < 7; a++) {
                mul_v2_fl(vec[a], rad);
@@@ -263,24 -158,17 +265,26 @@@ static void round_box_shade_col(unsigne
  /* linear horizontal shade within button or in outline */
  /* view2d scrollers use it */
  void UI_draw_roundbox_shade_x(
 -        int mode, float minx, float miny, float maxx, float maxy,
 -        float rad, float shadetop, float shadedown)
 +        bool filled, float minx, float miny, float maxx, float maxy,
 +        float rad, float shadetop, float shadedown, const float col[4])
  {
 +#if 0
-       float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, 
{0.707, 0.293},
-                          {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+       float vec[7][2] = {
+               {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
 -              {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
++              {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
++      };
        const float div = maxy - miny;
        const float idiv = 1.0f / div;
 -      float coltop[3], coldown[3], color[4];
 +      float coltop[3], coldown[3];
 +      int vert_count = 0;
        int a;
  
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 
2, GWN_FETCH_FLOAT);
 +      unsigned int color = GWN_vertformat_attr_add(format, "color", 
GWN_COMP_F32, 4, GWN_FETCH_FLOAT);
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 +
        /* mult */
        for (a = 0; a < 7; a++) {
                mul_v2_fl(vec[a], rad);
@@@ -409,15 -267,15 +413,17 @@@
  /* linear vertical shade within button or in outline */
  /* view2d scrollers use it */
  void UI_draw_roundbox_shade_y(
 -        int mode, float minx, float miny, float maxx, float maxy,
 -        float rad, float shadeLeft, float shadeRight)
 +        bool filled, float minx, float miny, float maxx, float maxy,
 +        float rad, float shadeleft, float shaderight, const float col[4])
  {
-       float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, 
{0.707, 0.293},
-                          {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+       float vec[7][2] = {
+               {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
 -              {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
++              {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805},
++      };
        const float div = maxx - minx;
        const float idiv = 1.0f / div;
 -      float colLeft[3], colRight[3], color[4];
 +      float colLeft[3], colRight[3];
 +      int vert_count = 0;
        int a;
  
        /* mult */
@@@ -503,129 -351,60 +509,129 @@@
  
        /* corner left-bottom */
        if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
 -              round_box_shade_col(colLeft, colRight, 1.0);
 -              glVertex2f(minx, miny + rad);
 +              round_box_shade_col(color, colLeft, colRight, 1.0);
 +              immVertex2f(pos, minx, miny + rad);
  
                for (a = 0; a < 7; a++) {
 -                      round_box_shade_col(colLeft, colRight, (vec[a][0]) * 
idiv);
 -                      glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
 +                      round_box_shade_col(color, colLeft, colRight, 
(vec[a][0]) * idiv);
 +                      immVertex2f(pos, minx + vec[a][1], miny + rad - 
vec[a][0]);
                }
  
 -              round_box_shade_col(colLeft, colRight, 1.0);
 -              glVertex2f(minx + rad, miny);
 +              round_box_shade_col(color, colLeft, colRight, 1.0);
 +              immVertex2f(pos, minx + rad, miny);
        }
        else {
 -              round_box_shade_col(colLeft, colRight, 1.0);
 -              glVertex2f(minx, miny);
 +              round_box_shade_col(color, colLeft, colRight, 1.0);
 +              immVertex2f(pos, minx, miny);
        }
  
 -      glEnd();
 +      immEnd();
 +      immUnbindProgram();
  }
 +#endif /* unused */
  
 -/* plain antialiased unfilled rectangle */
 -void UI_draw_roundbox_unfilled(float minx, float miny, float maxx, float 
maxy, float rad)
 +void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const 
float color[4])
  {
 -      float color[4];
 -
 -      if (roundboxtype & UI_RB_ALPHA) {
 -              glGetFloatv(GL_CURRENT_COLOR, color);
 -              color[3] = 0.5;
 -              glColor4fv(color);
 -              glEnable(GL_BLEND);
 -      }
 +      int ofs_y = 4 * U.pixelsize;
  
 -      /* set antialias line */
 -      glEnable(GL_LINE_SMOOTH);
 -      glEnable(GL_BLEND);
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 
2, GWN_FETCH_INT_TO_FLOAT);
  
 -      UI_draw_roundbox_gl_mode(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
 +      immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 +      immUniformColor4fv(color);
  
 -      glDisable(GL_BLEND);
 -      glDisable(GL_LINE_SMOOTH);
 +      immRecti(pos, pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + 
(height * U.pixelsize));
 +      immUnbindProgram();
  }
  
 -/* (old, used in outliner) plain antialiased filled box */
 -void UI_draw_roundbox(float minx, float miny, float maxx, float maxy, float 
rad)
 -{
 -      ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad, 
roundboxtype & UI_RB_ALPHA);
 -}
 +/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */
  
 -void UI_draw_text_underline(int pos_x, int pos_y, int len, int height)
 +/* based on UI_draw_roundbox_gl_mode, check on making a version which allows 
us to skip some sides */
 +void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char 
highlight[3], unsigned char highlight_fade[3])
  {
 -      int ofs_y = 4 * U.pixelsize;
 -      glRecti(pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * 
U.pixelsize));
 -}
 +      Gwn_VertFormat *format = immVertexFormat();
 +      unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 
2, GWN_FETCH_FLOAT);
 +      unsigned int col = GWN_vertformat_attr_add(format, "color", 
GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT);
 +      /* add a 1px offset, looks nicer */
 +      const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - 
U.pixelsize;
 +      const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - 
U.pixelsize;
 +      int a;
 +      float vec[4][2] = {
-           {0.195, 0.02},
-           {0.55, 0.169},
-           {0.831, 0.45},
-           {0.98, 0.805},
++              {0.195, 0.02},
++              {0.55, 0.169},
++              {0.831, 0.45},
++              {0.98, 0.805},
 +      };
  
 -/* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */
 +
 +      /* mult */
 +      for (a = 0; a < 4; a++) {
 +              mul_v2_fl(vec[a], rad);
 +      }
 +
 +      immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 +      immBeginAtMost(GWN_PRIM_LINE_STRIP, 25);
 +
 +      immAttrib3ubv(col, highlight);
 +
 +      /* start with corner left-top */
 +      if (roundboxtype & UI_CNR_TOP_LEFT) {
 +              immVertex2f(pos, minx, maxy - rad);
 +              for (a = 0; a < 4; a++) {
 +                      immVertex2f(pos, minx + vec[a][1], maxy - rad + 
vec[a][0]);
 +              }
 +              immVertex2f(pos, minx + rad, maxy);
 +      }
 +      else {
 +              immVertex2f(pos, minx, maxy);
 +      }
 +
 +      /* corner right-top */
 +      if (roundboxtype & UI_CNR_TOP_RIGHT) {
 +              immVertex2f(pos, maxx - rad, maxy);
 +              for (a = 0; a < 4; a++) {
 +                      immVertex2f(pos, maxx - rad + vec[a][0], maxy - 
vec[a][1]);
 +              }
 +              immVertex2f(pos, maxx

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to