Commit: e1a798c375c308b594e814dd07fc7d9863bebcf2
Author: Antonio Vazquez
Date:   Sun Aug 6 15:55:52 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBe1a798c375c308b594e814dd07fc7d9863bebcf2

Cleanup: Reorganize code

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

M       source/blender/draw/engines/gpencil/gpencil_engine.c
M       source/blender/draw/engines/gpencil/gpencil_engine.h
M       source/blender/draw/engines/gpencil/gpencil_vfx.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 5d634717114..9a3106d3743 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -155,6 +155,10 @@ static void GPENCIL_cache_init(void *vedata)
                 */
                stl->shgroups = MEM_mallocN(sizeof(GPENCIL_shgroup) * 
GPENCIL_MAX_SHGROUPS, "GPENCIL_shgroup");
        }
+
+       if (!stl->vfx) {
+               stl->vfx = MEM_mallocN(sizeof(GPENCIL_vfx) * 
GPENCIL_MAX_GP_OBJ, "GPENCIL_vfx");
+       }
        
        /* init gp objects cache */
        stl->g_data->gp_cache_used = 0;
@@ -275,7 +279,7 @@ static void GPENCIL_cache_finish(void *vedata)
                        }
                        /* VFX pass */
                        cache = &stl->g_data->gp_object_cache[i];
-                       DRW_gpencil_vfx_blur(&e_data, vedata, ob, cache);
+                       DRW_gpencil_vfx_blur(i, &e_data, vedata, ob, cache);
                }
        }
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 97cba5a717f..f7afc034246 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -33,6 +33,8 @@ struct ModifierData;
 struct GPENCIL_StorageList;
 
  /* TODO: these could be system parameter in userprefs screen */
+#define GPENCIL_MAX_GP_OBJ 256 
+
 #define GPENCIL_CACHE_BLOCK_SIZE 8 
 #define GPENCIL_MAX_SHGROUPS 65536
 #define GPENCIL_MIN_BATCH_SLOTS_CHUNK 8
@@ -42,10 +44,10 @@ struct GPENCIL_StorageList;
 #define GPENCIL_COLOR_PATTERN 2
 
  /* *********** OBJECTS CACHE *********** */
-typedef struct tGPencilVFXBlur {
+typedef struct GPencilVFXBlur {
        float x;
        float y;
-} tGPencilVFXBlur;
+} GPencilVFXBlur;
 
  /* used to save gpencil objects */
 typedef struct tGPencilObjectCache {
@@ -57,6 +59,10 @@ typedef struct tGPencilObjectCache {
 } tGPencilObjectCache;
 
   /* *********** LISTS *********** */
+typedef struct GPENCIL_vfx {
+       GPencilVFXBlur vfx_blur;
+} GPENCIL_vfx;
+
 typedef struct GPENCIL_shgroup {
        int s_clamp;
        int stroke_style;
@@ -67,9 +73,6 @@ typedef struct GPENCIL_shgroup {
        int fill_style;
        int keep_size;
        float obj_scale;
-       /* vfx data */
-       tGPencilVFXBlur vfx_blur;
-
        struct DRWShadingGroup *shgrps_fill;
        struct DRWShadingGroup *shgrps_stroke;
 } GPENCIL_shgroup;
@@ -89,6 +92,7 @@ typedef struct GPENCIL_StorageList {
        struct GPENCIL_Storage *storage;
        struct g_data *g_data;
        struct GPENCIL_shgroup *shgroups;
+       struct GPENCIL_vfx *vfx;
 } GPENCIL_StorageList;
 
 typedef struct GPENCIL_PassList {
@@ -199,6 +203,6 @@ void gpencil_object_cache_add(struct tGPencilObjectCache 
*cache, struct Object *
 
 void gpencil_array_modifiers(struct GPENCIL_StorageList *stl, struct Object 
*ob);
 
-void DRW_gpencil_vfx_blur(struct GPENCIL_e_data *e_data, struct GPENCIL_Data 
*vedata, struct Object *ob, struct tGPencilObjectCache *cache);
+void DRW_gpencil_vfx_blur(int ob_idx, struct GPENCIL_e_data *e_data, struct 
GPENCIL_Data *vedata, struct Object *ob, struct tGPencilObjectCache *cache);
 
 #endif /* __GPENCIL_ENGINE_H__ */
diff --git a/source/blender/draw/engines/gpencil/gpencil_vfx.c 
b/source/blender/draw/engines/gpencil/gpencil_vfx.c
index a8a68b4f538..dd05dbe988e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_vfx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_vfx.c
@@ -67,7 +67,7 @@ static ModifierData *modifier_available(Object *ob, 
ModifierType type)
  * The effect is done using two shading groups because is faster to apply 
horizontal
  * and vertical in different operations.
  */
-void DRW_gpencil_vfx_blur(GPENCIL_e_data *e_data, GPENCIL_Data *vedata, Object 
*ob, tGPencilObjectCache *cache)
+void DRW_gpencil_vfx_blur(int ob_idx, GPENCIL_e_data *e_data, GPENCIL_Data 
*vedata, Object *ob, tGPencilObjectCache *cache)
 {
        ModifierData *md = modifier_available(ob, eModifierType_GpencilBlur);
        if (md == NULL) {
@@ -79,9 +79,8 @@ void DRW_gpencil_vfx_blur(GPENCIL_e_data *e_data, 
GPENCIL_Data *vedata, Object *
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
        const float *viewport_size = DRW_viewport_size_get();
-       int id = cache->init_grp;
-       stl->shgroups[id].vfx_blur.x = mmd->radius[0];
-       stl->shgroups[id].vfx_blur.y = mmd->radius[1] * (viewport_size[1] / 
viewport_size[0]);
+       stl->vfx[ob_idx].vfx_blur.x = mmd->radius[0];
+       stl->vfx[ob_idx].vfx_blur.y = mmd->radius[1] * (viewport_size[1] / 
viewport_size[0]);
 
        struct Gwn_Batch *vfxquad = DRW_cache_fullscreen_quad_get();
        /* horizontal blur */
@@ -90,7 +89,7 @@ void DRW_gpencil_vfx_blur(GPENCIL_e_data *e_data, 
GPENCIL_Data *vedata, Object *
        DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeColor", 
&e_data->temp_fbcolor_color_tx);
        DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeDepth", 
&e_data->temp_fbcolor_depth_tx);
        DRW_shgroup_uniform_vec2(vfx_shgrp, "dir", stl->storage->blur1, 1);
-       DRW_shgroup_uniform_float(vfx_shgrp, "blur", 
&stl->shgroups[id].vfx_blur.x, 1);
+       DRW_shgroup_uniform_float(vfx_shgrp, "blur", 
&stl->vfx[ob_idx].vfx_blur.x, 1);
 
        /* set first effect sh */
        if (cache->init_vfx_sh == NULL) {
@@ -103,7 +102,7 @@ void DRW_gpencil_vfx_blur(GPENCIL_e_data *e_data, 
GPENCIL_Data *vedata, Object *
        DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeColor", 
&e_data->temp_fbcolor_color_tx);
        DRW_shgroup_uniform_buffer(vfx_shgrp, "strokeDepth", 
&e_data->temp_fbcolor_depth_tx);
        DRW_shgroup_uniform_vec2(vfx_shgrp, "dir", stl->storage->blur2, 1);
-       DRW_shgroup_uniform_float(vfx_shgrp, "blur", 
&stl->shgroups[id].vfx_blur.y, 1);
+       DRW_shgroup_uniform_float(vfx_shgrp, "blur", 
&stl->vfx[ob_idx].vfx_blur.y, 1);
 
        /* set last effect sh */
        cache->end_vfx_sh = vfx_shgrp;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to