[Bf-blender-cvs] [ec574b5b090] master: Cleanup: remove (unused) RNA update cache

Philipp Oeser noreply at git.blender.org
Wed Apr 15 17:09:33 CEST 2020


Commit: ec574b5b090f9ae779ca3e55021940ddd41115fb
Author: Philipp Oeser
Date:   Wed Apr 15 10:22:03 2020 +0200
Branches: master
https://developer.blender.org/rBec574b5b090f9ae779ca3e55021940ddd41115fb

Cleanup: remove (unused) RNA update cache

Introduced in 2011 in rB6a392e8cb505, it was disabled again soon after
in rBb062056c05a3 and traces to it partly removed in rB21744217cea9.

Now remove completely.

quote @sergey:
We shouldn't be having partially working unused code.
If we ever need some sort of update cache it would need to have clear
design first, and the code could be resurrected from history if needed.

Differential Revision: https://developer.blender.org/D7432

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

M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/blenkernel/intern/blendfile.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 18320ef0f8d..5f463be58b4 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -2547,13 +2547,6 @@ void BKE_animsys_evaluate_animdata(
    * - It is best that we execute this every time, so that no errors are likely to occur.
    */
   animsys_evaluate_overrides(&id_ptr, adt);
-
-  /* execute and clear all cached property update functions */
-  if (scene) {
-    Main *bmain = G.main;  // xxx - to get passed in!
-    RNA_property_update_cache_flush(bmain, scene);
-    RNA_property_update_cache_free();
-  }
 }
 
 /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 2a53a0b69a4..0d5d35e3508 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -258,9 +258,6 @@ static void setup_app_data(bContext *C,
   //  CTX_wm_manager_set(C, NULL);
   BKE_blender_globals_clear();
 
-  /* clear old property update cache, in case some old references are left dangling */
-  RNA_property_update_cache_free();
-
   bmain = G_MAIN = bfd->main;
   bfd->main = NULL;
 
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 31d1ed54fa1..26773e59feb 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -930,10 +930,6 @@ void RNA_property_update_main(struct Main *bmain,
                               PropertyRNA *prop);
 bool RNA_property_update_check(struct PropertyRNA *prop);
 
-void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop);
-void RNA_property_update_cache_flush(struct Main *bmain, struct Scene *scene);
-void RNA_property_update_cache_free(void);
-
 /* Property Data */
 
 bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index b56a18c18a9..501dd2109c2 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -98,8 +98,6 @@ void RNA_exit(void)
 {
   StructRNA *srna;
 
-  RNA_property_update_cache_free();
-
   for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
     if (srna->cont.prophash) {
       BLI_ghash_free(srna->cont.prophash, NULL, NULL);
@@ -2308,115 +2306,6 @@ void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, Proper
   rna_property_update(NULL, bmain, scene, ptr, prop);
 }
 
-/* RNA Updates Cache ------------------------ */
-/* Overview of RNA Update cache system:
- *
- * RNA Update calls need to be cached in order to maintain reasonable performance
- * of the animation system (i.e. maintaining a somewhat interactive framerate)
- * while still allowing updates to be called (necessary in particular for modifier
- * property updates to actually work).
- *
- * The cache is structured with a dual-layer structure
- * - L1 = PointerRNA used as key; owner_id is used (it should always be defined,
- *        and most updates end up using just that anyways)
- * - L2 = Update functions to be called on those PointerRNA's
- */
-
-/* cache element */
-typedef struct tRnaUpdateCacheElem {
-  struct tRnaUpdateCacheElem *next, *prev;
-
-  PointerRNA ptr;   /* L1 key - id as primary, data secondary/ignored? */
-  ListBase L2Funcs; /* L2 functions (LinkData<RnaUpdateFuncRef>) */
-} tRnaUpdateCacheElem;
-
-/* cache global (tRnaUpdateCacheElem's) - only accessible using these API calls */
-static ListBase rna_updates_cache = {NULL, NULL};
-
-/* ........................... */
-
-void RNA_property_update_cache_add(PointerRNA *ptr, PropertyRNA *prop)
-{
-  const bool is_rna = (prop->magic == RNA_MAGIC);
-  tRnaUpdateCacheElem *uce = NULL;
-  UpdateFunc fn = NULL;
-  LinkData *ld;
-
-  /* sanity check */
-  if (NULL == ptr) {
-    return;
-  }
-
-  prop = rna_ensure_property(prop);
-
-  /* we can only handle update calls with no context args for now (makes animsys updates easier) */
-  if ((is_rna == false) || (prop->update == NULL) || (prop->flag & PROP_CONTEXT_UPDATE)) {
-    return;
-  }
-  fn = prop->update;
-
-  /* find cache element for which key matches... */
-  for (uce = rna_updates_cache.first; uce; uce = uce->next) {
-    /* Just match by id only for now,
-     * since most update calls that we'll encounter only really care about this. */
-    /* TODO: later, the cache might need to have some nesting on L1 to cope better
-     * with these problems + some tagging to indicate we need this */
-    if (uce->ptr.owner_id == ptr->owner_id) {
-      break;
-    }
-  }
-  if (uce == NULL) {
-    /* create new instance */
-    uce = MEM_callocN(sizeof(tRnaUpdateCacheElem), "tRnaUpdateCacheElem");
-    BLI_addtail(&rna_updates_cache, uce);
-
-    /* copy pointer */
-    RNA_pointer_create(ptr->owner_id, ptr->type, ptr->data, &uce->ptr);
-  }
-
-  /* check on the update func */
-  for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
-    /* stop on match - function already cached */
-    if (fn == ld->data) {
-      return;
-    }
-  }
-  /* else... if still here, we need to add it */
-  BLI_addtail(&uce->L2Funcs, BLI_genericNodeN(fn));
-}
-
-void RNA_property_update_cache_flush(Main *bmain, Scene *scene)
-{
-  tRnaUpdateCacheElem *uce;
-
-  /* TODO: should we check that bmain and scene are valid? The above stuff doesn't! */
-
-  /* execute the cached updates */
-  for (uce = rna_updates_cache.first; uce; uce = uce->next) {
-    LinkData *ld;
-
-    for (ld = uce->L2Funcs.first; ld; ld = ld->next) {
-      UpdateFunc fn = (UpdateFunc)ld->data;
-      fn(bmain, scene, &uce->ptr);
-    }
-  }
-}
-
-void RNA_property_update_cache_free(void)
-{
-  tRnaUpdateCacheElem *uce, *ucn;
-
-  for (uce = rna_updates_cache.first; uce; uce = ucn) {
-    ucn = uce->next;
-
-    /* free L2 cache */
-    BLI_freelistN(&uce->L2Funcs);
-
-    /* remove self */
-    BLI_freelinkN(&rna_updates_cache, uce);
-  }
-}
-
 /* ---------------------------------------------------------------------- */
 
 /* Property Data */



More information about the Bf-blender-cvs mailing list