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 /source/blender/compositor
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
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/COM_compositor.h13
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp40
2 files changed, 50 insertions, 3 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
}
+