From 322c03f13cb5a756902f310c2a34cf78825fe02d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Sep 2019 15:52:38 +0200 Subject: Move callbacks API from BLI to BKE Preparing for the bigger changes which will be related on passing dependency graph to various callbacks which need it. Differential Revision: https://developer.blender.org/D5725 --- source/blender/blenkernel/BKE_callbacks.h | 73 ++++++++++++++++++++++ source/blender/blenkernel/CMakeLists.txt | 2 + source/blender/blenkernel/intern/blender.c | 4 +- source/blender/blenkernel/intern/callbacks.c | 67 ++++++++++++++++++++ source/blender/blenkernel/intern/scene.c | 10 +-- source/blender/blenlib/BLI_callbacks.h | 73 ---------------------- source/blender/blenlib/BLI_timer.h | 2 +- source/blender/blenlib/CMakeLists.txt | 2 - source/blender/blenlib/intern/callbacks.c | 66 ------------------- source/blender/blenlib/intern/fileops.c | 2 +- source/blender/editors/undo/ed_undo.c | 10 +-- .../intern/blender_interface/FRS_freestyle.cpp | 4 +- source/blender/python/intern/bpy_app_handlers.c | 19 +++--- source/blender/render/intern/source/pipeline.c | 30 ++++----- source/blender/windowmanager/intern/wm_files.c | 22 +++---- source/blender/windowmanager/intern/wm_init_exit.c | 8 +-- 16 files changed, 198 insertions(+), 196 deletions(-) create mode 100644 source/blender/blenkernel/BKE_callbacks.h create mode 100644 source/blender/blenkernel/intern/callbacks.c delete mode 100644 source/blender/blenlib/BLI_callbacks.h delete mode 100644 source/blender/blenlib/intern/callbacks.c (limited to 'source/blender') diff --git a/source/blender/blenkernel/BKE_callbacks.h b/source/blender/blenkernel/BKE_callbacks.h new file mode 100644 index 00000000000..380ce30668d --- /dev/null +++ b/source/blender/blenkernel/BKE_callbacks.h @@ -0,0 +1,73 @@ +/* + * 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 + */ + +#ifndef __BKE_CALLBACKS_H__ +#define __BKE_CALLBACKS_H__ + +struct ID; +struct Main; + +/** + * Common suffix uses: + * - ``_PRE/_POST``: + * For handling discrete non-interactive events. + * - ``_INIT/_COMPLETE/_CANCEL``: + * For handling jobs (which may in turn cause other handlers to be called). + */ +typedef enum { + BKE_CB_EVT_FRAME_CHANGE_PRE, + BKE_CB_EVT_FRAME_CHANGE_POST, + BKE_CB_EVT_RENDER_PRE, + BKE_CB_EVT_RENDER_POST, + BKE_CB_EVT_RENDER_WRITE, + BKE_CB_EVT_RENDER_STATS, + BKE_CB_EVT_RENDER_INIT, + BKE_CB_EVT_RENDER_COMPLETE, + BKE_CB_EVT_RENDER_CANCEL, + BKE_CB_EVT_LOAD_PRE, + BKE_CB_EVT_LOAD_POST, + BKE_CB_EVT_SAVE_PRE, + BKE_CB_EVT_SAVE_POST, + BKE_CB_EVT_UNDO_PRE, + BKE_CB_EVT_UNDO_POST, + BKE_CB_EVT_REDO_PRE, + BKE_CB_EVT_REDO_POST, + BKE_CB_EVT_DEPSGRAPH_UPDATE_PRE, + BKE_CB_EVT_DEPSGRAPH_UPDATE_POST, + BKE_CB_EVT_VERSION_UPDATE, + BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST, + BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST, + BKE_CB_EVT_TOT, +} eCbEvent; + +typedef struct bCallbackFuncStore { + struct bCallbackFuncStore *next, *prev; + void (*func)(struct Main *, struct ID *, void *arg); + void *arg; + short alloc; +} bCallbackFuncStore; + +void BKE_callback_exec(struct Main *bmain, struct ID *self, eCbEvent evt); +void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt); + +void BKE_callback_global_init(void); +void BKE_callback_global_finalize(void); + +#endif /* __BKE_CALLBACKS_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 669abff6599..a1c47ba6d06 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -83,6 +83,7 @@ set(SRC intern/brush.c intern/bvhutils.c intern/cachefile.c + intern/callbacks.c intern/camera.c intern/cdderivedmesh.c intern/cloth.c @@ -243,6 +244,7 @@ set(SRC BKE_brush.h BKE_bvhutils.h BKE_cachefile.h + BKE_callbacks.h BKE_camera.h BKE_ccg.h BKE_cdderivedmesh.h 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. */ diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h deleted file mode 100644 index 4d9fc66a806..00000000000 --- a/source/blender/blenlib/BLI_callbacks.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 bli - */ - -#ifndef __BLI_CALLBACKS_H__ -#define __BLI_CALLBACKS_H__ - -struct ID; -struct Main; - -/** - * Common suffix uses: - * - ``_PRE/_POST``: - * For handling discrete non-interactive events. - * - ``_INIT/_COMPLETE/_CANCEL``: - * For handling jobs (which may in turn cause other handlers to be called). - */ -typedef enum { - BLI_CB_EVT_FRAME_CHANGE_PRE, - BLI_CB_EVT_FRAME_CHANGE_POST, - BLI_CB_EVT_RENDER_PRE, - BLI_CB_EVT_RENDER_POST, - BLI_CB_EVT_RENDER_WRITE, - BLI_CB_EVT_RENDER_STATS, - BLI_CB_EVT_RENDER_INIT, - BLI_CB_EVT_RENDER_COMPLETE, - BLI_CB_EVT_RENDER_CANCEL, - BLI_CB_EVT_LOAD_PRE, - BLI_CB_EVT_LOAD_POST, - BLI_CB_EVT_SAVE_PRE, - BLI_CB_EVT_SAVE_POST, - BLI_CB_EVT_UNDO_PRE, - BLI_CB_EVT_UNDO_POST, - BLI_CB_EVT_REDO_PRE, - BLI_CB_EVT_REDO_POST, - BLI_CB_EVT_DEPSGRAPH_UPDATE_PRE, - BLI_CB_EVT_DEPSGRAPH_UPDATE_POST, - BLI_CB_EVT_VERSION_UPDATE, - BLI_CB_EVT_LOAD_FACTORY_USERDEF_POST, - BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST, - BLI_CB_EVT_TOT, -} eCbEvent; - -typedef struct bCallbackFuncStore { - struct bCallbackFuncStore *next, *prev; - void (*func)(struct Main *, struct ID *, void *arg); - void *arg; - short alloc; -} bCallbackFuncStore; - -void BLI_callback_exec(struct Main *bmain, struct ID *self, eCbEvent evt); -void BLI_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt); - -void BLI_callback_global_init(void); -void BLI_callback_global_finalize(void); - -#endif /* __BLI_CALLBACKS_H__ */ diff --git a/source/blender/blenlib/BLI_timer.h b/source/blender/blenlib/BLI_timer.h index 959ac4a2b2b..56cafb1bd36 100644 --- a/source/blender/blenlib/BLI_timer.h +++ b/source/blender/blenlib/BLI_timer.h @@ -50,7 +50,7 @@ void BLI_timer_execute(void); void BLI_timer_free(void); -/* This function is to be called next to BLI_CB_EVT_LOAD_PRE, to make sure the module +/* This function is to be called next to BKE_CB_EVT_LOAD_PRE, to make sure the module * is properly configured for the new file. */ void BLI_timer_on_file_load(void); diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 7f6e9d49b17..73652e18a56 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -61,7 +61,6 @@ set(SRC intern/bitmap_draw_2d.c intern/boxpack_2d.c intern/buffer.c - intern/callbacks.c intern/convexhull_2d.c intern/delaunay_2d.c intern/dynlib.c @@ -145,7 +144,6 @@ set(SRC BLI_blenlib.h BLI_boxpack_2d.h BLI_buffer.h - BLI_callbacks.h BLI_compiler_attrs.h BLI_compiler_compat.h BLI_compiler_typecheck.h diff --git a/source/blender/blenlib/intern/callbacks.c b/source/blender/blenlib/intern/callbacks.c deleted file mode 100644 index c4f93a9831d..00000000000 --- a/source/blender/blenlib/intern/callbacks.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 bli - */ - -#include "BLI_utildefines.h" -#include "BLI_listbase.h" -#include "BLI_callbacks.h" - -#include "MEM_guardedalloc.h" - -static ListBase callback_slots[BLI_CB_EVT_TOT] = {{NULL}}; - -void BLI_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 BLI_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt) -{ - ListBase *lb = &callback_slots[evt]; - BLI_addtail(lb, funcstore); -} - -void BLI_callback_global_init(void) -{ - /* do nothing */ -} - -/* call on application exit */ -void BLI_callback_global_finalize(void) -{ - eCbEvent evt; - for (evt = 0; evt < BLI_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/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index c203c45bb93..4c1f08f0117 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -35,8 +35,8 @@ #ifdef WIN32 # include # include "BLI_winstuff.h" -# include "BLI_callbacks.h" # include "BLI_fileops_types.h" +# include "BKE_callbacks.h" # include "utf_winfunc.h" # include "utfconv.h" #else diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index dac420ff2e4..df927726e82 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -31,12 +31,12 @@ #include "DNA_object_types.h" #include "BLI_utildefines.h" -#include "BLI_callbacks.h" #include "BLI_listbase.h" #include "BLT_translation.h" #include "BKE_blender_undo.h" +#include "BKE_callbacks.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_main.h" @@ -172,8 +172,8 @@ static int ed_undo_step_impl( /* Note: ignore grease pencil for now. */ Main *bmain = CTX_data_main(C); wm->op_undo_depth++; - BLI_callback_exec( - bmain, &scene->id, (step_for_callback > 0) ? BLI_CB_EVT_UNDO_PRE : BLI_CB_EVT_REDO_PRE); + BKE_callback_exec( + bmain, &scene->id, (step_for_callback > 0) ? BKE_CB_EVT_UNDO_PRE : BKE_CB_EVT_REDO_PRE); wm->op_undo_depth--; } @@ -220,8 +220,8 @@ static int ed_undo_step_impl( Main *bmain = CTX_data_main(C); scene = CTX_data_scene(C); wm->op_undo_depth++; - BLI_callback_exec( - bmain, &scene->id, step_for_callback > 0 ? BLI_CB_EVT_UNDO_POST : BLI_CB_EVT_REDO_POST); + BKE_callback_exec( + bmain, &scene->id, step_for_callback > 0 ? BKE_CB_EVT_UNDO_POST : BKE_CB_EVT_REDO_POST); wm->op_undo_depth--; } diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 4552ce849f2..9fee340e62e 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -42,6 +42,7 @@ extern "C" { #include "DNA_material_types.h" #include "DNA_text_types.h" +#include "BKE_callbacks.h" #include "BKE_context.h" #include "BKE_freestyle.h" #include "BKE_global.h" @@ -55,7 +56,6 @@ extern "C" { #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_math_color_blend.h" -#include "BLI_callbacks.h" #include "BPY_extern.h" @@ -111,7 +111,7 @@ void FRS_initialize() g_freestyle.scene = NULL; lineset_copied = false; - BLI_callback_add(&load_post_callback_funcstore, BLI_CB_EVT_LOAD_POST); + BKE_callback_add(&load_post_callback_funcstore, BKE_CB_EVT_LOAD_POST); freestyle_is_initialized = 1; } diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index dde3d026d47..77d036532f4 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -24,7 +24,8 @@ #include #include "BLI_utildefines.h" -#include "BLI_callbacks.h" + +#include "BKE_callbacks.h" #include "RNA_types.h" #include "RNA_access.h" @@ -80,7 +81,7 @@ static PyStructSequence_Desc app_cb_info_desc = { }; #if 0 -# if (BLI_CB_EVT_TOT != ARRAY_SIZE(app_cb_info_fields)) +# if (BKE_CB_EVT_TOT != ARRAY_SIZE(app_cb_info_fields)) # error "Callbacks are out of sync" # endif #endif @@ -175,7 +176,7 @@ static PyTypeObject BPyPersistent_Type = { 0, /* tp_free */ }; -static PyObject *py_cb_array[BLI_CB_EVT_TOT] = {NULL}; +static PyObject *py_cb_array[BKE_CB_EVT_TOT] = {NULL}; static PyObject *make_app_cb_info(void) { @@ -187,7 +188,7 @@ static PyObject *make_app_cb_info(void) return NULL; } - for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) { + for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { if (app_cb_info_fields[pos].name == NULL) { Py_FatalError("invalid callback slots 1"); } @@ -227,16 +228,16 @@ PyObject *BPY_app_handlers_struct(void) /* assign the C callbacks */ if (ret) { - static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT] = {{NULL}}; + static bCallbackFuncStore funcstore_array[BKE_CB_EVT_TOT] = {{NULL}}; bCallbackFuncStore *funcstore; int pos = 0; - for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) { + for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { funcstore = &funcstore_array[pos]; funcstore->func = bpy_app_generic_callback; funcstore->alloc = 0; funcstore->arg = POINTER_FROM_INT(pos); - BLI_callback_add(funcstore, pos); + BKE_callback_add(funcstore, pos); } } @@ -251,7 +252,7 @@ void BPY_app_handlers_reset(const short do_all) gilstate = PyGILState_Ensure(); if (do_all) { - for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) { + for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { /* clear list */ PyList_SetSlice(py_cb_array[pos], 0, PY_SSIZE_T_MAX, NULL); } @@ -260,7 +261,7 @@ void BPY_app_handlers_reset(const short do_all) /* save string conversion thrashing */ PyObject *perm_id_str = PyUnicode_FromString(PERMINENT_CB_ID); - for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) { + for (pos = 0; pos < BKE_CB_EVT_TOT; pos++) { /* clear only items without PERMINENT_CB_ID */ PyObject *ls = py_cb_array[pos]; Py_ssize_t i; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 8308048ddba..e7ac70dd57f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -48,11 +48,11 @@ #include "BLI_timecode.h" #include "BLI_fileops.h" #include "BLI_threads.h" -#include "BLI_callbacks.h" #include "BLT_translation.h" #include "BKE_animsys.h" /* <------ should this be here?, needed for sequencer update */ +#include "BKE_callbacks.h" #include "BKE_camera.h" #include "BKE_colortools.h" #include "BKE_context.h" /* XXX needed by wm_window.h */ @@ -226,7 +226,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) /* NOTE: using G_MAIN seems valid here??? * Not sure it's actually even used anyway, we could as well pass NULL? */ - BLI_callback_exec(G_MAIN, NULL, BLI_CB_EVT_RENDER_STATS); + BKE_callback_exec(G_MAIN, NULL, BKE_CB_EVT_RENDER_STATS); fputc('\n', stdout); fflush(stdout); @@ -2090,7 +2090,7 @@ void RE_RenderFrame(Render *re, int frame, const bool write_still) { - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_INIT); /* Ugly global still... * is to prevent preview events and signal subsurfs etc to make full resol. */ @@ -2105,7 +2105,7 @@ void RE_RenderFrame(Render *re, render_init_depsgraph(re); - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_PRE); do_render_all_options(re); @@ -2131,14 +2131,14 @@ void RE_RenderFrame(Render *re, } /* keep after file save */ - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_POST); if (write_still) { - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_WRITE); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_WRITE); } } - BLI_callback_exec( - re->main, (ID *)scene, G.is_break ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); + BKE_callback_exec( + re->main, (ID *)scene, G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE); RE_CleanAfterRender(re); @@ -2429,7 +2429,7 @@ static int do_write_image_or_movie(Render *re, /* NOTE: using G_MAIN seems valid here??? * Not sure it's actually even used anyway, we could as well pass NULL? */ - BLI_callback_exec(G_MAIN, NULL, BLI_CB_EVT_RENDER_STATS); + BKE_callback_exec(G_MAIN, NULL, BKE_CB_EVT_RENDER_STATS); BLI_timecode_string_from_time_simple(name, sizeof(name), re->i.lastframetime - render_time); printf(" (Saving: %s)\n", name); @@ -2495,7 +2495,7 @@ void RE_RenderAnim(Render *re, const bool is_multiview_name = ((rd.scemode & R_MULTIVIEW) != 0 && (rd.im_format.views_format == R_IMF_VIEWS_INDIVIDUAL)); - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_INIT); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_INIT); /* do not fully call for each frame, it initializes & pops output window */ if (!render_initialize_from_main(re, &rd, bmain, scene, single_layer, camera_override, 0, 1)) { @@ -2661,7 +2661,7 @@ void RE_RenderAnim(Render *re, re->r.cfra = scene->r.cfra; /* weak.... */ /* run callbacs before rendering, before the scene is updated */ - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_PRE); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_PRE); do_render_all_options(re); totrendered++; @@ -2712,8 +2712,8 @@ void RE_RenderAnim(Render *re, if (G.is_break == false) { /* keep after file save */ - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_POST); - BLI_callback_exec(re->main, (ID *)scene, BLI_CB_EVT_RENDER_WRITE); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_POST); + BKE_callback_exec(re->main, (ID *)scene, BKE_CB_EVT_RENDER_WRITE); } } } @@ -2731,8 +2731,8 @@ void RE_RenderAnim(Render *re, re->flag &= ~R_ANIMATION; - BLI_callback_exec( - re->main, (ID *)scene, G.is_break ? BLI_CB_EVT_RENDER_CANCEL : BLI_CB_EVT_RENDER_COMPLETE); + BKE_callback_exec( + re->main, (ID *)scene, G.is_break ? BKE_CB_EVT_RENDER_CANCEL : BKE_CB_EVT_RENDER_COMPLETE); BKE_sound_reset_scene_specs(re->pipeline_scene_eval); RE_CleanAfterRender(re); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e70640d2f22..ae5235c7f58 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -54,7 +54,6 @@ #include "BLI_utildefines.h" #include "BLI_timer.h" #include "BLI_threads.h" -#include "BLI_callbacks.h" #include "BLI_system.h" #include BLI_SYSTEM_PID_H @@ -75,6 +74,7 @@ #include "BKE_blender.h" #include "BKE_blendfile.h" #include "BKE_blender_undo.h" +#include "BKE_callbacks.h" #include "BKE_context.h" #include "BKE_global.h" #include "BKE_idprop.h" @@ -537,16 +537,16 @@ static void wm_file_read_post(bContext *C, if (use_userdef) { if (is_factory_startup) { - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_USERDEF_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_USERDEF_POST); } } if (use_data) { /* important to do before NULL'ing the context */ - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_VERSION_UPDATE); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_POST); if (is_factory_startup) { - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST); } } @@ -609,7 +609,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) WM_cursor_wait(1); - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); + BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE); BLI_timer_on_file_load(); UI_view2d_zoom_cache_reset(); @@ -807,7 +807,7 @@ void wm_homefile_read(bContext *C, } if (use_data) { - BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_PRE); + BKE_callback_exec(CTX_data_main(C), NULL, BKE_CB_EVT_LOAD_PRE); BLI_timer_on_file_load(); G.relbase_valid = 0; @@ -1368,7 +1368,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo /* Call pre-save callbacks before writing preview, * that way you can generate custom file thumbnail. */ - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE); /* Enforce full override check/generation on file save. */ BKE_main_override_library_operations_create(bmain, true); @@ -1421,7 +1421,7 @@ static bool wm_file_write(bContext *C, const char *filepath, int fileflags, Repo wm_history_file_update(); } - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST); /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { @@ -1646,7 +1646,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_PRE); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_PRE); /* check current window and close it if temp */ if (win && WM_window_is_temp_screen(win)) { @@ -1674,7 +1674,7 @@ static int wm_homefile_write_exec(bContext *C, wmOperator *op) G.save_over = 0; - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_SAVE_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_SAVE_POST); return OPERATOR_FINISHED; } diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 1e3c8a0aedd..736a3315efa 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -41,7 +41,6 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" -#include "BLI_callbacks.h" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -55,6 +54,7 @@ #include "BKE_blendfile.h" #include "BKE_blender.h" #include "BKE_blender_undo.h" +#include "BKE_callbacks.h" #include "BKE_context.h" #include "BKE_font.h" #include "BKE_global.h" @@ -378,10 +378,10 @@ void WM_init(bContext *C, int argc, const char **argv) * note that recovering the last session does its own callbacks. */ CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_VERSION_UPDATE); - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_VERSION_UPDATE); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_POST); if (is_factory_startup) { - BLI_callback_exec(bmain, NULL, BLI_CB_EVT_LOAD_FACTORY_STARTUP_POST); + BKE_callback_exec(bmain, NULL, BKE_CB_EVT_LOAD_FACTORY_STARTUP_POST); } wm_file_read_report(C, bmain); -- cgit v1.2.3