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:
authorBastien Montagne <montagne29@wanadoo.fr>2017-05-01 17:21:53 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-05-01 17:32:55 +0300
commitd7d4bca23be91ec5b0ce562d47a34ee49dd337b8 (patch)
tree6184684f5300324294dbaa103522e7e817e3d6bd /source/blender/editors/space_sequencer/sequencer_draw.c
parent6ef497d401e5e7842d1e9d33e491672bb77d60e0 (diff)
Reworked version of dashed line shader.
Using geometry shader allows us to get rid of the 'line origin' extra vertex attribute, which means dashed shader no longer requires fiddling with those vertex attributes definition, and, most importantly, does not require anymore special drawing code! As you can see, this makes code much simpler, and much less verbose, especially in complex cases. In addition, changed how dashes are handled, to have two 'modes', a simple one with single color (using default "color" uniform name), and a more advanced one allowing more complex and multi-color patterns. Note that since GLSL 1.2 does not support geometry shaders, a hack was added for now (which gives solid lines, but at least does not make Blender crash).
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_draw.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 6a9437bb892..e7c7b3d67b9 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1033,13 +1033,7 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
glLineWidth(1.0f);
/* border */
- VertexFormat *format = immVertexFormat();
- unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
- unsigned int line_origin = VertexFormat_add_attrib(format, "line_origin", COMP_F32, 2, KEEP_FLOAT);
- float color1[4];
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
+ const uint shdr_pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_COLOR);
@@ -1047,36 +1041,31 @@ static void sequencer_draw_borders(const SpaceSeq *sseq, const View2D *v2d, cons
glGetFloatv(GL_VIEWPORT, viewport_size);
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
- UI_GetThemeColor4fv(TH_BACK, color1);
- immUniform4fv("color1", color1);
- immUniform4f("color2", 0.0f, 0.0f, 0.0f, 0.0f);
+ immUniformThemeColor(TH_BACK);
+ immUniform1i("num_colors", 0); /* Simple dashes. */
immUniform1f("dash_width", 6.0f);
- immUniform1f("dash_width_on", 3.0f);
+ immUniform1f("dash_factor", 0.5f);
- imm_draw_line_box_dashed(pos, line_origin, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
+ imm_draw_line_box(shdr_pos, x1 - 0.5f, y1 - 0.5f, x2 + 0.5f, y2 + 0.5f);
/* safety border */
if (sseq->flag & SEQ_SHOW_SAFE_MARGINS) {
- UI_GetThemeColorBlend3f(TH_VIEW_OVERLAY, TH_BACK, 0.25f, color1);
- color1[3] = 1.0f;
- immUniform4fv("color1", color1);
+ immUniformThemeColorBlend(TH_VIEW_OVERLAY, TH_BACK, 0.25f);
UI_draw_safe_areas(
- pos, line_origin, x1, x2, y1, y2,
+ shdr_pos, x1, x2, y1, y2,
scene->safe_areas.title,
scene->safe_areas.action);
if (sseq->flag & SEQ_SHOW_SAFE_CENTER) {
UI_draw_safe_areas(
- pos, line_origin, x1, x2, y1, y2,
+ shdr_pos, x1, x2, y1, y2,
scene->safe_areas.title_center,
scene->safe_areas.action_center);
}
}
immUnbindProgram();
-
- glDisable(GL_BLEND);
}
/* draws checkerboard background for transparent content */