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:
authorAntonioya <blendergit@gmail.com>2018-10-11 17:05:08 +0300
committerAntonioya <blendergit@gmail.com>2018-10-11 17:05:08 +0300
commit4add09053cbf2e3d86ab0f23d46bba7eb2d47829 (patch)
tree79be474cfac4ae625991fe9fa80d71eac77c1c02 /source/blender/draw/engines/gpencil/gpencil_shader_fx.c
parent250ba17c83411c77100c6ea974626b3787a465b0 (diff)
GP: Cleanup duplicate code moving to function
Diffstat (limited to 'source/blender/draw/engines/gpencil/gpencil_shader_fx.c')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c108
1 files changed, 42 insertions, 66 deletions
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);