[Bf-blender-cvs] [26812a185f4] blender2.8: Fix masks not drawing with draw type set to dashed.

Brecht Van Lommel noreply at git.blender.org
Tue Aug 14 20:07:48 CEST 2018


Commit: 26812a185f42d52a42ebb5fdc1bb7fff58066cd1
Author: Brecht Van Lommel
Date:   Tue Aug 14 19:54:33 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB26812a185f42d52a42ebb5fdc1bb7fff58066cd1

Fix masks not drawing with draw type set to dashed.

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

M	source/blender/editors/mask/mask_draw.c

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

diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 506dec2aa3e..a660eb1aa22 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -58,6 +58,7 @@
 #include "GPU_matrix.h"
 #include "GPU_state.h"
 
+#include "UI_interface.h"
 #include "UI_resources.h"
 #include "UI_view2d.h"
 
@@ -453,27 +454,30 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*
 			break;
 
 		case MASK_DT_DASH:
-			/* TODO(merwin): use dashed line shader here
-			 * probably better with geometry shader (after core profile switch)
-			 */
-#if 0
-			GPU_line_width(1.0f);
-
-			GPU_basic_shader_bind_enable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
-			GPU_basic_shader_line_stipple(3, 0xAAAA);
+		{
+			float colors[8];
 
 			mask_color_active_tint(rgb_tmp, rgb_spline, is_active);
-			immUniformColor4ubv(rgb_tmp);
-			mask_draw_array(pos, draw_method, points, tot_point);
-
+			rgba_uchar_to_float(colors, rgb_tmp);
 			mask_color_active_tint(rgb_tmp, rgb_black, is_active);
-			immUniformColor4ubv(rgb_tmp);
-			GPU_basic_shader_line_stipple(3, 0x5555);
+			rgba_uchar_to_float(colors+4, rgb_tmp);
+
+			immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
+
+			float viewport_size[4];
+			GPU_viewport_size_get_f(viewport_size);
+			immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
+
+			immUniform1i("colors_len", 2);  /* "advanced" mode */
+			immUniformArray4fv("colors", colors, 2);
+			immUniform1f("dash_width", 4.0f);
+			GPU_line_width(1.0f);
+
 			mask_draw_array(pos, draw_method, points, tot_point);
 
-			GPU_basic_shader_bind_disable(GPU_SHADER_LINE | GPU_SHADER_STIPPLE);
-#endif
+			immUnbindProgram();
 			break;
+		}
 
 		default:
 			BLI_assert(false);



More information about the Bf-blender-cvs mailing list