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:
authorJeroen Bakker <j.bakker@atmind.nl>2012-07-10 16:23:49 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-07-10 16:23:49 +0400
commitdc65a26bf6216440d7470be900f3b211c49f22d4 (patch)
tree40d442aa5ae6681e8e9a9a8e2f33e374ce58e745
parent5cc0e5f751e2428db9ca3cf263f3a44f77a2bc5c (diff)
refactor node highlight code. New implementation will not write to
uninitialized memory. it happened when you delete a node that was being executed. in the compostor
-rw-r--r--source/blender/compositor/COM_compositor.h13
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp40
-rw-r--r--source/blender/editors/space_node/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_node/SConscript2
-rw-r--r--source/blender/editors/space_node/node_draw.c11
-rw-r--r--source/blender/makesdna/DNA_node_types.h4
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c2
7 files changed, 61 insertions, 12 deletions
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index 86390e5650a..60bceba5765 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -299,6 +299,19 @@ extern "C" {
*/
void COM_execute(RenderData* rd, bNodeTree *editingtree, int rendering);
+/**
+ * @brief Return a list of highlighted bnodes pointers.
+ * @return
+ */
+void COM_startReadHighlights();
+
+/**
+ * @brief check if a bnode is highlighted
+ * @param bnode
+ * @return
+ */
+int COM_isHighlightedbNode(bNode* bnode);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index 120b4d6d0f2..c7544be1bb4 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -66,6 +66,12 @@ static bool g_openclActive = false;
#endif
#endif
+#define MAX_HIGHLIGHT 8
+extern "C" {
+int g_highlightIndex;
+void ** g_highlightedNodes;
+void ** g_highlightedNodesRead;
+
#define HIGHLIGHT(wp) \
{ \
ExecutionGroup* group = wp->getExecutionGroup(); \
@@ -77,14 +83,38 @@ static bool g_openclActive = false;
bNode *node = complexOperation->getbNode(); \
if (node) { \
if (node->original) { \
- node->original->highlight = 1;\
- } else {\
- node->highlight = 1; \
+ node = node->original;\
+ }\
+ if (g_highlightIndex < MAX_HIGHLIGHT) {\
+ g_highlightedNodes[g_highlightIndex++] = node;\
}\
} \
} \
} \
}
+void COM_startReadHighlights() {
+ if (g_highlightedNodesRead) {
+ delete g_highlightedNodesRead;
+ }
+
+ g_highlightedNodesRead = g_highlightedNodes;
+ g_highlightedNodes = new void*[MAX_HIGHLIGHT];
+ g_highlightIndex = 0;
+ for (int i = 0 ; i < MAX_HIGHLIGHT; i++) {
+ g_highlightedNodes[i] = 0;
+ }
+}
+
+int COM_isHighlightedbNode(bNode* bnode) {
+ if (!g_highlightedNodesRead) return false;
+ for (int i = 0 ; i < MAX_HIGHLIGHT; i++) {
+ void* p = g_highlightedNodesRead[i];
+ if (!p) return false;
+ if (p == bnode) return true;
+ }
+ return false;
+}
+} // end extern "C"
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
void *WorkScheduler::thread_execute_cpu(void *data)
@@ -219,6 +249,9 @@ extern void clContextError(const char *errinfo, const void *private_info, size_t
void WorkScheduler::initialize()
{
+ g_highlightedNodesRead = 0;
+ g_highlightedNodes = 0;
+ COM_startReadHighlights();
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
int numberOfCPUThreads = BLI_system_thread_count();
@@ -313,3 +346,4 @@ void WorkScheduler::deinitialize()
#endif
#endif
}
+
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index 8c3397b9ddd..9c48ce4034d 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
../../nodes
../../render/extern/include
../../windowmanager
+ ../../compositor
../../../../intern/guardedalloc
../../../../intern/opennl/extern
)
diff --git a/source/blender/editors/space_node/SConscript b/source/blender/editors/space_node/SConscript
index 2dee750f8c0..4c6e94484e4 100644
--- a/source/blender/editors/space_node/SConscript
+++ b/source/blender/editors/space_node/SConscript
@@ -4,7 +4,7 @@ Import ('env')
sources = env.Glob('*.c')
incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../makesrna ../../imbuf'
-incs += ' ../../nodes ../../render/extern/include ../../blenloader ../../gpu'
+incs += ' ../../nodes ../../render/extern/include ../../blenloader ../../gpu ../../compositor'
incs += ' ../../windowmanager #intern/guardedalloc #extern/glew/include'
defs = []
cf = []
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 89a4d92b295..7be76bd7884 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -80,6 +80,7 @@
#include "intern/node_util.h"
#include "node_intern.h"
+#include "COM_compositor.h"
/* width of socket columns in group display */
#define NODE_GROUP_FRAME 120
@@ -726,9 +727,8 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) {
- if (node->highlight) {
+ if (COM_isHighlightedbNode(node)) {
UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
- node->highlight = 0;
}
}
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
@@ -893,9 +893,8 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) {
- if (node->highlight) {
+ if (COM_isHighlightedbNode(node)) {
UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
- node->highlight = 0;
}
}
@@ -1133,6 +1132,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
if (snode->nodetree) {
bNode *node;
+ void** highlights = 0;
node_uiblocks_init(C, snode->nodetree);
@@ -1145,6 +1145,9 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
}
node_update_nodetree(C, snode->nodetree, 0.0f, 0.0f);
+ if (snode->nodetree->type == NTREE_COMPOSIT) {
+ COM_startReadHighlights();
+ }
node_draw_nodetree(C, ar, snode, snode->nodetree);
#if 0
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index ea894ff7a0d..58a6332515e 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -178,9 +178,7 @@ typedef struct bNode {
char label[64]; /* custom user-defined label, MAX_NAME */
short custom1, custom2; /* to be abused for buttons */
float custom3, custom4;
- int highlight; /* 0 = not highlighted, 1-N = highlighted*/
- int pad;
-
+
short need_exec, exec; /* need_exec is set as UI execution event, exec is flag during exec */
void *threaddata; /* optional extra storage for use in thread (read only then!) */
rctf totr; /* entire boundbox */
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index b9acf821efe..43edc06194d 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -61,7 +61,7 @@
#include "node_composite_util.h"
#ifdef WITH_COMPOSITOR
-# include "COM_compositor.h"
+ #include "COM_compositor.h"
#endif
static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)