Commit: f0517a84b43ba5d26b98e3248498948866d071e5
Author: Sergey Sharybin
Date:   Fri Dec 19 14:17:36 2014 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBf0517a84b43ba5d26b98e3248498948866d071e5

Depsgraph: Add utility functions for eval_ctx allocation/free

This started as an experiment about different aspect of dependency graph,
but this is gonna to be handy anyway when we'll need to couple evaluation
context with the storage.

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

M       source/blender/blenkernel/intern/library.c
M       source/blender/blenkernel/intern/mesh.c
M       source/blender/depsgraph/DEG_depsgraph.h
M       source/blender/depsgraph/intern/depsgraph_eval.cpp
M       source/blender/makesrna/intern/rna_object_api.c
M       source/blender/render/CMakeLists.txt
M       source/blender/render/SConscript
M       source/blender/render/intern/source/pipeline.c

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

diff --git a/source/blender/blenkernel/intern/library.c 
b/source/blender/blenkernel/intern/library.c
index b49eee3..fa8b245 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -115,6 +115,8 @@
 #include "BKE_texture.h"
 #include "BKE_world.h"
 
+#include "DEG_depsgraph.h"
+
 #include "RNA_access.h"
 
 #ifdef WITH_PYTHON
@@ -1069,8 +1071,7 @@ void BKE_libblock_free_us(Main *bmain, void *idv)      /* 
test users */
 Main *BKE_main_new(void)
 {
        Main *bmain = MEM_callocN(sizeof(Main), "new main");
-       bmain->eval_ctx = MEM_callocN(sizeof(EvaluationContext),
-                                     "EvaluationContext");
+       bmain->eval_ctx = DEG_evaluation_context_new(DAG_EVAL_VIEWPORT);
        bmain->lock = MEM_mallocN(sizeof(SpinLock), "main lock");
        BLI_spin_init((SpinLock *)bmain->lock);
        return bmain;
@@ -1137,7 +1138,7 @@ void BKE_main_free(Main *mainvar)
 
        BLI_spin_end((SpinLock *)mainvar->lock);
        MEM_freeN(mainvar->lock);
-       MEM_freeN(mainvar->eval_ctx);
+       DEG_evaluation_context_free(mainvar->eval_ctx);
        MEM_freeN(mainvar);
 }
 
diff --git a/source/blender/blenkernel/intern/mesh.c 
b/source/blender/blenkernel/intern/mesh.c
index 2e80379..9f9b499 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -61,6 +61,7 @@
 #include "BKE_object.h"
 #include "BKE_editmesh.h"
 
+#include "DEG_depsgraph.h"
 
 enum {
        MESHCMP_DVERT_WEIGHTMISMATCH = 1,
@@ -2199,8 +2200,8 @@ Mesh *BKE_mesh_new_from_object(
                                 *               only contains for_render flag. 
As soon as CoW is
                                 *               implemented, this is to be 
rethinked.
                                 */
-                               EvaluationContext eval_ctx = {0};
-                               eval_ctx.mode = DAG_EVAL_RENDER;
+                               EvaluationContext eval_ctx;
+                               DEG_evaluation_context_init(&eval_ctx, 
DAG_EVAL_RENDER);
                                BKE_displist_make_mball_forRender(&eval_ctx, 
sce, ob, &disp);
                                BKE_mesh_from_metaball(&disp, tmpmesh);
                                BKE_displist_free(&disp);
diff --git a/source/blender/depsgraph/DEG_depsgraph.h 
b/source/blender/depsgraph/DEG_depsgraph.h
index c1890de..440fc33 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -121,7 +121,21 @@ void DEG_graph_clear_tags(Depsgraph *graph);
 /* ************************************************ */
 /* Evaluation Engine API */
 
-/* ----------------------------------------------- */
+/* Evaluation Context ---------------------------- */
+
+/* Create new evaluation context. */
+struct EvaluationContext *DEG_evaluation_context_new(int mode);
+
+/* Initialize evaluation context.
+ * Used by the areas which currently overrides the context or doesn't have
+ * access to a proper one.
+ */
+void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx, int mode);
+
+/* Free evaluation context. */
+void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
+
+/* Graph Evaluation  ----------------------------- */
 
 /* Frame changed recalculation entrypoint 
  * < context_type: context to perform evaluation for
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp 
b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index d5dfbbf..93f3c77 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -36,7 +36,10 @@ extern "C" {
 
 #include "DNA_ID.h"
 
+#include "BKE_depsgraph.h"
 #include "BKE_global.h" /* XXX only for debug value, remove eventually */
+#include "BKE_main.h"
+
 } /* extern "C" */
 
 #include "atomic_ops.h"
@@ -67,9 +70,38 @@ void DEG_set_eval_mode(eDEG_EvalMode mode)
        }
 }
 
+/* ****************** */
+/* Evaluation Context */
+
+/* Create new evaluation context. */
+EvaluationContext *DEG_evaluation_context_new(int mode)
+{
+       EvaluationContext *eval_ctx =
+               (EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
+                                                "EvaluationContext");
+       eval_ctx->mode = mode;
+       return eval_ctx;
+}
+
+/* Initialize evaluation context.
+ * Used by the areas which currently overrides the context or doesn't have
+ * access to a proper one.
+ */
+void DEG_evaluation_context_init(EvaluationContext *eval_ctx, int mode)
+{
+       eval_ctx->mode = mode;
+}
+
+/* Free evaluation context. */
+void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
+{
+       MEM_freeN(eval_ctx);
+}
+
 /* ********************** */
 /* Evaluation Entrypoints */
 
+/* Forward declarations. */
 static void deg_schedule_children(TaskPool *pool, EvaluationContext *eval_ctx,
                                   Depsgraph *graph, OperationDepsNode *node);
 
diff --git a/source/blender/makesrna/intern/rna_object_api.c 
b/source/blender/makesrna/intern/rna_object_api.c
index 831e548..e97278f 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -87,6 +87,8 @@ static EnumPropertyItem space_items[] = {
 
 #include "MEM_guardedalloc.h"
 
+#include "DEG_depsgraph.h"
+
 /* Convert a given matrix from a space to another (using the object and/or a 
bone as reference). */
 static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, 
bPoseChannel *pchan,
                                         float *mat, float *mat_ret, int from, 
int to)
@@ -169,8 +171,8 @@ static void dupli_render_particle_set(Scene *scene, Object 
*ob, int level, int e
 static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene 
*sce, int settings)
 {
        bool for_render = (settings == DAG_EVAL_RENDER);
-       EvaluationContext eval_ctx = {0};
-       eval_ctx.mode = settings;
+       EvaluationContext eval_ctx;
+       DEG_evaluation_context_init(&eval_ctx, settings);
 
        if (!(ob->transflag & OB_DUPLI)) {
                BKE_report(reports, RPT_ERROR, "Object does not have duplis");
diff --git a/source/blender/render/CMakeLists.txt 
b/source/blender/render/CMakeLists.txt
index e516c95..ad68484 100644
--- a/source/blender/render/CMakeLists.txt
+++ b/source/blender/render/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
        ../blenkernel
        ../blenlib
        ../imbuf
+       ../depsgraph
        ../makesdna
        ../makesrna
        ../../../intern/guardedalloc
diff --git a/source/blender/render/SConscript b/source/blender/render/SConscript
index ebd1310..0d07a56 100644
--- a/source/blender/render/SConscript
+++ b/source/blender/render/SConscript
@@ -38,6 +38,7 @@ incs = [
     '../blenkernel',
     '../blenlib',
     '../imbuf',
+    '../depsgraph',
     '../makesdna',
     '../makesrna',
     '../../../intern/mikktspace',
diff --git a/source/blender/render/intern/source/pipeline.c 
b/source/blender/render/intern/source/pipeline.c
index 1f17b82..a1f61c5 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -83,6 +83,8 @@
 #  include "FRS_freestyle.h"
 #endif
 
+#include "DEG_depsgraph.h"
+
 /* internal */
 #include "render_result.h"
 #include "render_types.h"
@@ -385,8 +387,7 @@ Render *RE_NewRender(const char *name)
                BLI_addtail(&RenderGlobal.renderlist, re);
                BLI_strncpy(re->name, name, RE_MAXNAME);
                BLI_rw_mutex_init(&re->resultmutex);
-               re->eval_ctx = MEM_callocN(sizeof(EvaluationContext), 
"re->eval_ctx");
-               re->eval_ctx->mode = DAG_EVAL_RENDER;
+               re->eval_ctx = DEG_evaluation_context_new(DAG_EVAL_RENDER);
        }
        
        RE_InitRenderCB(re);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to