[Bf-blender-cvs] [8c6a4a65124] greasepencil-object: Cleanup: Remove redundant function (and cleanup compiler warnings in the process)
Joshua Leung
noreply at git.blender.org
Fri May 4 18:53:25 CEST 2018
Commit: 8c6a4a6512452b0ac036525be485473193ef6d31
Author: Joshua Leung
Date: Fri May 4 18:47:57 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB8c6a4a6512452b0ac036525be485473193ef6d31
Cleanup: Remove redundant function (and cleanup compiler warnings in the process)
BKE_gpencil_frame_color_duplicate() is no longer needed to perform Grease Pencil's
in-house "COW" operations. It was previously used to create a copy of the palette
datablock being used, and to then reassign all the color pointers. Now that that's
no longer needed, we can just use the standard one.
Note: BKE_gpencil_stroke_duplicate() has now been modified to NOT clear the triangles
array anymore. Instead, since most places that use this will clear/reallocate it
themselves, it's easier to just keep it there, making the COW stuff easier.
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 2832787d3a5..77d26802b4d 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -32,7 +32,6 @@
*/
struct CurveMapping;
-struct bContext;
struct Depsgraph;
struct ToolSettings;
struct ListBase;
@@ -76,7 +75,6 @@ struct bGPDlayer *BKE_gpencil_layer_addnew(struct bGPdata *gpd, const char *name
struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]);
struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
-struct bGPDframe *BKE_gpencil_frame_color_duplicate(const struct bContext *C, struct bGPdata *gpd, const struct bGPDframe *gpf_src);
struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 529e0d25269..e6f11b6d3dc 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -551,9 +551,13 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src)
gps_dst->points = MEM_dupallocN(gps_src->points);
BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
- gps_dst->triangles = NULL;
- gps_dst->tot_triangles = 0;
- gps_dst->flag |= GP_STROKE_RECALC_CACHES;
+
+ /* Don't clear triangles, so that modifier evaluation can just use
+ * this without extra work first. Most places that need to force
+ * this data to get recalculated will destroy the data anyway though.
+ */
+ gps_dst->triangles = MEM_dupallocN(gps_dst->triangles);
+ /* gps_dst->flag |= GP_STROKE_RECALC_CACHES; */
/* return new stroke */
return gps_dst;
@@ -604,37 +608,6 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds
}
}
-/* make a copy of a given gpencil frame and copy colors too */
-// XXX: C and GPD unused... deprecate this function?
-bGPDframe *BKE_gpencil_frame_color_duplicate(const bContext *C, bGPdata *gpd, const bGPDframe *gpf_src)
-{
- bGPDstroke *gps_dst;
- bGPDframe *gpf_dst;
-
- /* error checking */
- if (gpf_src == NULL) {
- return NULL;
- }
-
- /* make a copy of the source frame */
- gpf_dst = MEM_dupallocN(gpf_src);
-
- /* copy strokes */
- BLI_listbase_clear(&gpf_dst->strokes);
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
- /* make copy of source stroke */
- gps_dst = MEM_dupallocN(gps_src);
- gps_dst->points = MEM_dupallocN(gps_src->points);
- BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
-
- gps_dst->triangles = MEM_dupallocN(gps_src->triangles);
-
- BLI_addtail(&gpf_dst->strokes, gps_dst);
- }
- /* return new frame */
- return gpf_dst;
-}
-
/* make a copy of a given gpencil layer */
bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
{
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 4b287d73ff5..ab8ab70f79e 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -1004,7 +1004,8 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
BLI_ghash_remove(gpl->derived_data, ob->id.name, NULL, NULL);
}
/* create new data */
- derived_gpf = BKE_gpencil_frame_color_duplicate(C, gpd, gpf);
+ // TODO: we want the triangles data kept!
+ derived_gpf = BKE_gpencil_frame_duplicate(gpf);
BLI_ghash_insert(gpl->derived_data, ob->id.name, derived_gpf);
}
More information about the Bf-blender-cvs
mailing list