Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-04-12 21:16:43 +0300
committerMike Erwin <significant.bit@gmail.com>2017-04-12 21:20:55 +0300
commitc080702e73f1729897033343d44198488b6fed9f (patch)
treef69211a5e7f2b543b689f2ae9613dd144f52263b /source/blender/editors/space_file
parent2871bad8ea92646d3c10001e9f113a145d9a89b4 (diff)
fix drawing file column dividers (T51189)
Problem was an edge case where vertex_ct logic and draw logic disagreed on how many dividers to draw. Fix: copy draw logic to earlier vertex_ct I also skip any drawing or setup if vertex_ct = 0, and set color attribute only for each line's provoking vertex. Small optimizations but these things add up.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c72
1 files changed, 40 insertions, 32 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 329b3f7f525..61f33d72b71 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -477,46 +477,54 @@ static void draw_background(FileLayout *layout, View2D *v2d)
static void draw_dividers(FileLayout *layout, View2D *v2d)
{
- const int step = (layout->tile_w + 2 * layout->tile_border_x);
- int v1[2], v2[2];
- int sx;
- unsigned int vertex_ct = 0;
- unsigned char col_hi[3], col_lo[3];
+ /* vertical column dividers */
- VertexFormat *format = immVertexFormat();
- unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
- unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
+ const int step = (layout->tile_w + 2 * layout->tile_border_x);
- vertex_ct = (v2d->cur.xmax - v2d->tot.xmin) / step + 1; /* paint at least 1 divider */
- vertex_ct *= 4; /* vertex_count = 2 points per divider * 2 lines per divider */
+ unsigned int vertex_ct = 0;
+ int sx = (int)v2d->tot.xmin;
+ while (sx < v2d->cur.xmax) {
+ sx += step;
+ vertex_ct += 4; /* vertex_count = 2 points per line * 2 lines per divider */
+ }
- UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi);
- UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo);
+ if (vertex_ct > 0) {
+ int v1[2], v2[2];
+ unsigned char col_hi[3], col_lo[3];
- v1[1] = v2d->cur.ymax - layout->tile_border_y;
- v2[1] = v2d->cur.ymin;
+ UI_GetThemeColorShade3ubv(TH_BACK, 30, col_hi);
+ UI_GetThemeColorShade3ubv(TH_BACK, -30, col_lo);
- immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
- immBegin(PRIM_LINES, vertex_ct);
+ v1[1] = v2d->cur.ymax - layout->tile_border_y;
+ v2[1] = v2d->cur.ymin;
- /* vertical column dividers */
- sx = (int)v2d->tot.xmin;
- while (sx < v2d->cur.xmax) {
- sx += step;
-
- v1[0] = v2[0] = sx;
- immAttrib3ubv(color, col_lo);
- immVertex2iv(pos, v1);
- immVertex2iv(pos, v2);
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_I32, 2, CONVERT_INT_TO_FLOAT);
+ unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 3, NORMALIZE_INT_TO_FLOAT);
+
+ immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
+ immBegin(PRIM_LINES, vertex_ct);
+
+ sx = (int)v2d->tot.xmin;
+ while (sx < v2d->cur.xmax) {
+ sx += step;
+
+ v1[0] = v2[0] = sx;
+ immSkipAttrib(color);
+ immVertex2iv(pos, v1);
+ immAttrib3ubv(color, col_lo);
+ immVertex2iv(pos, v2);
+
+ v1[0] = v2[0] = sx + 1;
+ immSkipAttrib(color);
+ immVertex2iv(pos, v1);
+ immAttrib3ubv(color, col_hi);
+ immVertex2iv(pos, v2);
+ }
- v1[0] = v2[0] = sx + 1;
- immAttrib3ubv(color, col_hi);
- immVertex2iv(pos, v1);
- immVertex2iv(pos, v2);
+ immEnd();
+ immUnbindProgram();
}
-
- immEnd();
- immUnbindProgram();
}
void file_draw_list(const bContext *C, ARegion *ar)