diff options
author | Antonioya <blendergit@gmail.com> | 2019-04-27 13:02:26 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-04-27 13:02:26 +0300 |
commit | 19ebee657e965c5aad627156afa3ce62e47a3379 (patch) | |
tree | aaaf592fb07e115c1886ce7d6707b582f1a84cdd /source/blender | |
parent | aa42da03859d28900a1d01130f07c38b1e2ad34b (diff) |
GPencil: Cleanup derived frame code
This is a previous step to move away the derived frame logic to be used in edit modes.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/engines/gpencil/gpencil_draw_utils.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c index 8c2dee66d92..f28c6fa11b5 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c @@ -1909,6 +1909,28 @@ void DRW_gpencil_populate_multiedit(GPENCIL_e_data *e_data, cache->is_dirty = false; } +/* ensure there is a derived frame */ +static void gpencil_ensure_derived_frame(bGPdata *gpd, + bGPDlayer *gpl, + bGPDframe *gpf, + GpencilBatchCache *cache, + bGPDframe **derived_gpf) +{ + /* create derived frames array data or expand */ + int derived_idx = BLI_findindex(&gpd->layers, gpl); + *derived_gpf = &cache->derived_array[derived_idx]; + + /* if no derived frame or dirty cache, create a new one */ + if ((*derived_gpf == NULL) || (cache->is_dirty)) { + if (*derived_gpf != NULL) { + /* first clear temp data */ + BKE_gpencil_free_frame_runtime_data(*derived_gpf); + } + /* create new data (do not assign new memory)*/ + gpencil_copy_frame(gpf, *derived_gpf); + } +} + /* helper for populate a complete grease pencil datablock */ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, @@ -2001,18 +2023,7 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, } /* create derived frames array data or expand */ - int derived_idx = BLI_findindex(&gpd->layers, gpl); - derived_gpf = &cache->derived_array[derived_idx]; - - /* if no derived frame or dirty cache, create a new one */ - if ((derived_gpf == NULL) || (cache->is_dirty)) { - if (derived_gpf != NULL) { - /* first clear temp data */ - BKE_gpencil_free_frame_runtime_data(derived_gpf); - } - /* create new data (do not assign new memory)*/ - gpencil_copy_frame(gpf, derived_gpf); - } + gpencil_ensure_derived_frame(gpd, gpl, gpf, cache, &derived_gpf); /* draw onion skins */ if (!ID_IS_LINKED(&gpd->id)) { |