[Bf-blender-cvs] [4add09053cb] blender2.8: GP: Cleanup duplicate code moving to function

Antonioya noreply at git.blender.org
Thu Oct 11 16:05:21 CEST 2018


Commit: 4add09053cbf2e3d86ab0f23d46bba7eb2d47829
Author: Antonioya
Date:   Thu Oct 11 16:05:08 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4add09053cbf2e3d86ab0f23d46bba7eb2d47829

GP: Cleanup duplicate code moving to function

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

M	source/blender/draw/engines/gpencil/gpencil_shader_fx.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 6a3cbd4b39b..82a9d24162d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -857,7 +857,7 @@ static void draw_gpencil_blur_passes(
 	}
 }
 
-/* blur intermediate passes */
+/* blur intermediate pass */
 static void draw_gpencil_midpass_blur(
         struct GPENCIL_Data *vedata,
 		struct ShaderFxData_Runtime *runtime)
@@ -877,6 +877,35 @@ static void draw_gpencil_midpass_blur(
 	DRW_draw_pass(psl->mix_pass_noblend);
 }
 
+/* do blur of mid passes */
+static void draw_gpencil_do_blur(
+	struct GPENCIL_e_data *e_data,
+	struct GPENCIL_Data *vedata,
+	struct ShaderFxData_Runtime *runtime,
+	int samples, int bx, int by, int *blur)
+{
+	e_data->input_depth_tx = e_data->temp_depth_tx_b;
+	e_data->input_color_tx = e_data->temp_color_tx_b;
+
+	if ((samples > 0) && ((bx > 0) || (by > 0))) {
+		for (int x = 0; x < samples; x++) {
+
+			/* horizontal */
+			blur[0] = bx;
+			blur[1] = 0;
+			draw_gpencil_midpass_blur(vedata, runtime);
+
+			/* Vertical */
+			blur[0] = 0;
+			blur[1] = by;
+			draw_gpencil_midpass_blur(vedata, runtime);
+
+			blur[0] = bx;
+			blur[1] = by;
+		}
+	}
+}
+
 /* helper to draw RIM passes */
 static void draw_gpencil_rim_passes(
         struct GPENCIL_e_data *e_data,
@@ -891,8 +920,6 @@ static void draw_gpencil_rim_passes(
 	GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
 
 	static float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-	int bx = fxd->blur[0];
-	int by = fxd->blur[1];
 
 	/* prepare mask */
 	GPU_framebuffer_bind(fbl->temp_fb_fx);
@@ -902,26 +929,10 @@ static void draw_gpencil_rim_passes(
 	        fxd->runtime.fx_sh, fxd->runtime.fx_sh);
 
 	/* blur rim */
-	e_data->input_depth_tx = e_data->temp_depth_tx_b;
-	e_data->input_color_tx = e_data->temp_color_tx_b;
-
-	if ((fxd->samples > 0) && ((bx > 0) || (by > 0))) {
-		for (int x = 0; x < fxd->samples; x++) {
-
-			/* horizontal */
-			fxd->blur[0] = bx;
-			fxd->blur[1] = 0;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
-
-			/* Vertical */
-			fxd->blur[0] = 0;
-			fxd->blur[1] = by;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
-
-			fxd->blur[0] = bx;
-			fxd->blur[1] = by;
-		}
-	}
+	draw_gpencil_do_blur(e_data, vedata, &fxd->runtime,
+						fxd->samples,
+						fxd->blur[0], fxd->blur[1],
+						&fxd->blur[0]);
 
 	/* resolve */
 	GPU_framebuffer_bind(fbl->temp_fb_b);
@@ -953,8 +964,6 @@ static void draw_gpencil_shadow_passes(
 	GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
 
 	static float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-	int bx = fxd->blur[0];
-	int by = fxd->blur[1];
 
 	/* prepare shadow */
 	GPU_framebuffer_bind(fbl->temp_fb_fx);
@@ -964,26 +973,10 @@ static void draw_gpencil_shadow_passes(
 		fxd->runtime.fx_sh, fxd->runtime.fx_sh);
 
 	/* blur shadow */
-	e_data->input_depth_tx = e_data->temp_depth_tx_b;
-	e_data->input_color_tx = e_data->temp_color_tx_b;
-
-	if ((fxd->samples > 0) && ((bx > 0) || (by > 0))) {
-		for (int x = 0; x < fxd->samples; x++) {
-
-			/* horizontal */
-			fxd->blur[0] = bx;
-			fxd->blur[1] = 0;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
-
-			/* Vertical */
-			fxd->blur[0] = 0;
-			fxd->blur[1] = by;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
-
-			fxd->blur[0] = bx;
-			fxd->blur[1] = by;
-		}
-	}
+	draw_gpencil_do_blur(e_data, vedata, &fxd->runtime,
+						fxd->samples,
+						fxd->blur[0], fxd->blur[1],
+						&fxd->blur[0]);
 
 	/* resolve */
 	GPU_framebuffer_bind(fbl->temp_fb_b);
@@ -1015,8 +1008,6 @@ static void draw_gpencil_glow_passes(
 	GPENCIL_FramebufferList *fbl = ((GPENCIL_Data *)vedata)->fbl;
 
 	static float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
-	int bx = fxd->blur[0];
-	int by = fxd->blur[0];
 
 	/* prepare glow */
 	GPU_framebuffer_bind(fbl->temp_fb_fx);
@@ -1026,26 +1017,11 @@ static void draw_gpencil_glow_passes(
 		fxd->runtime.fx_sh, fxd->runtime.fx_sh);
 
 	/* blur glow */
-	e_data->input_depth_tx = e_data->temp_depth_tx_b;
-	e_data->input_color_tx = e_data->temp_color_tx_b;
-
-	if ((fxd->samples > 0) && ((bx > 0) || (by > 0))) {
-		for (int x = 0; x < fxd->samples; x++) {
-
-			/* horizontal */
-			fxd->blur[0] = bx;
-			fxd->blur[1] = 0;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
+	draw_gpencil_do_blur(e_data, vedata, &fxd->runtime,
+						fxd->samples,
+						fxd->blur[0], fxd->blur[0],
+						&fxd->blur[0]);
 
-			/* Vertical */
-			fxd->blur[0] = 0;
-			fxd->blur[1] = by;
-			draw_gpencil_midpass_blur(vedata, &fxd->runtime);
-
-			fxd->blur[0] = bx;
-			fxd->blur[1] = by;
-		}
-	}
 	/* resolve */
 	GPU_framebuffer_bind(fbl->temp_fb_b);
 	GPU_framebuffer_clear_color_depth(fbl->temp_fb_b, clearcol, 1.0f);



More information about the Bf-blender-cvs mailing list