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:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/blender.c4
-rw-r--r--source/blender/blenkernel/intern/callbacks.c67
-rw-r--r--source/blender/blenkernel/intern/scene.c10
3 files changed, 74 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 805c098d238..ac432bf0b64 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -32,7 +32,6 @@
#include "BLI_string.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
-#include "BLI_callbacks.h"
#include "IMB_imbuf.h"
#include "IMB_moviecache.h"
@@ -44,6 +43,7 @@
#include "BKE_blendfile.h"
#include "BKE_brush.h"
#include "BKE_cachefile.h"
+#include "BKE_callbacks.h"
#include "BKE_global.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
@@ -95,7 +95,7 @@ void BKE_blender_free(void)
BKE_brush_system_exit();
RE_texture_rng_exit();
- BLI_callback_global_finalize();
+ BKE_callback_global_finalize();
IMB_moviecache_destruct();
diff --git a/source/blender/blenkernel/intern/callbacks.c b/source/blender/blenkernel/intern/callbacks.c
new file mode 100644
index 00000000000..cbecba2efe1
--- /dev/null
+++ b/source/blender/blenkernel/intern/callbacks.c
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
+
+#include "BKE_callbacks.h"
+
+#include "MEM_guardedalloc.h"
+
+static ListBase callback_slots[BKE_CB_EVT_TOT] = {{NULL}};
+
+void BKE_callback_exec(struct Main *bmain, struct ID *self, eCbEvent evt)
+{
+ ListBase *lb = &callback_slots[evt];
+ bCallbackFuncStore *funcstore;
+
+ for (funcstore = lb->first; funcstore; funcstore = funcstore->next) {
+ funcstore->func(bmain, self, funcstore->arg);
+ }
+}
+
+void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
+{
+ ListBase *lb = &callback_slots[evt];
+ BLI_addtail(lb, funcstore);
+}
+
+void BKE_callback_global_init(void)
+{
+ /* do nothing */
+}
+
+/* call on application exit */
+void BKE_callback_global_finalize(void)
+{
+ eCbEvent evt;
+ for (evt = 0; evt < BKE_CB_EVT_TOT; evt++) {
+ ListBase *lb = &callback_slots[evt];
+ bCallbackFuncStore *funcstore;
+ bCallbackFuncStore *funcstore_next;
+ for (funcstore = lb->first; funcstore; funcstore = funcstore_next) {
+ funcstore_next = funcstore->next;
+ BLI_remlink(lb, funcstore);
+ if (funcstore->alloc) {
+ MEM_freeN(funcstore);
+ }
+ }
+ }
+}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index b0e0f9f1efc..c55aa1b835c 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -48,7 +48,7 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
-#include "BLI_callbacks.h"
+#include "BKE_callbacks.h"
#include "BLI_string.h"
#include "BLI_string_utils.h"
#include "BLI_threads.h"
@@ -1554,7 +1554,7 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on
bool run_callbacks = DEG_id_type_any_updated(depsgraph);
if (run_callbacks) {
- BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_DEPSGRAPH_UPDATE_PRE);
+ BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE);
}
for (int pass = 0; pass < 2; pass++) {
@@ -1572,7 +1572,7 @@ static void scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain, bool on
BKE_scene_update_sound(depsgraph, bmain);
/* Notify python about depsgraph update. */
if (run_callbacks) {
- BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_DEPSGRAPH_UPDATE_POST);
+ BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_DEPSGRAPH_UPDATE_POST);
}
/* Inform editors about possible changes. */
DEG_ids_check_recalc(bmain, depsgraph, scene, view_layer, false);
@@ -1607,7 +1607,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
/* Keep this first. */
- BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_FRAME_CHANGE_PRE);
+ BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_PRE);
for (int pass = 0; pass < 2; pass++) {
/* Update animated image textures for particles, modifiers, gpu, etc,
@@ -1629,7 +1629,7 @@ void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph, Main *bmain)
/* Notify editors and python about recalc. */
if (pass == 0) {
- BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_FRAME_CHANGE_POST);
+ BKE_callback_exec(bmain, &scene->id, BKE_CB_EVT_FRAME_CHANGE_POST);
}
/* Inform editors about possible changes. */