Highlight nodes that are being processed
authorJeroen Bakker <j.bakker@atmind.nl>
Wed, 4 Jul 2012 10:01:45 +0000 (10:01 +0000)
committerJeroen Bakker <j.bakker@atmind.nl>
Wed, 4 Jul 2012 10:01:45 +0000 (10:01 +0000)
28 files changed:
release/scripts/startup/bl_ui/space_node.py
source/blender/compositor/intern/COM_ExecutionGroup.cpp
source/blender/compositor/intern/COM_Node.cpp
source/blender/compositor/intern/COM_Node.h
source/blender/compositor/intern/COM_NodeBase.cpp
source/blender/compositor/intern/COM_NodeBase.h
source/blender/compositor/intern/COM_NodeOperation.cpp
source/blender/compositor/nodes/COM_BlurNode.cpp
source/blender/compositor/nodes/COM_BokehBlurNode.cpp
source/blender/compositor/nodes/COM_DefocusNode.cpp
source/blender/compositor/nodes/COM_DilateErodeNode.cpp
source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
source/blender/compositor/nodes/COM_FilterNode.cpp
source/blender/compositor/nodes/COM_GlareNode.cpp
source/blender/compositor/nodes/COM_KeyingNode.cpp
source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
source/blender/compositor/nodes/COM_LensDistortionNode.cpp
source/blender/compositor/nodes/COM_MaskNode.cpp
source/blender/compositor/nodes/COM_TonemapNode.cpp
source/blender/compositor/nodes/COM_VectorBlurNode.cpp
source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
source/blender/compositor/operations/COM_WriteBufferOperation.cpp
source/blender/editors/space_node/node_draw.c
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_space_types.h
source/blender/makesrna/intern/rna_space.c
source/blender/nodes/composite/node_composite_tree.c

index bb29e415c1955e07b72b3176d1a709a96e39dc5c..e29500858ee2e8e1460cc4e46fdd61fa0f38da3c 100644 (file)
@@ -217,7 +217,7 @@ class NODE_PT_properties(Panel):
 class NODE_PT_quality(bpy.types.Panel):
     bl_space_type = 'NODE_EDITOR'
     bl_region_type = 'UI'
-    bl_label = "Quality"
+    bl_label = "Performance"
 
     @classmethod
     def poll(cls, context):
@@ -233,6 +233,7 @@ class NODE_PT_quality(bpy.types.Panel):
         layout.prop(tree, "edit_quality", text="Edit")
         layout.prop(tree, "chunk_size")
         layout.prop(tree, "use_opencl")
+        layout.prop(snode, "show_highlight")
 
 
 class NODE_MT_node_color_presets(Menu):
index 2d3d24b296f6cb56b7448946ab02f8971bd717ff..e437b069e337313c58baf0f52e0ba07579ddc001 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "BLI_math.h"
 #include "PIL_time.h"
+#include "WM_api.h"
+#include "WM_types.h"
 
 #include "COM_ExecutionGroup.h"
 #include "COM_InputSocket.h"
@@ -347,6 +349,8 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
                                finished = false;
                                startEvaluated = true;
                                numberEvaluated++;
+
+                               WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
                        }
                        else if (state == COM_ES_SCHEDULED) {
                                finished = false;
index 15b8a3933a7baed97691092a68e084944ed2d405..320baacb6695f6826e236d95bf286009fc59ce1f 100644 (file)
@@ -39,9 +39,9 @@
 //#include <stdio.h>
 #include "COM_defines.h"
 
-Node::Node(bNode *editorNode, bool create_sockets)
+Node::Node(bNode *editorNode, bool create_sockets): NodeBase()
 {
-       this->m_editorNode = editorNode;
+       setbNode(editorNode);
        
        if (create_sockets) {
                bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
@@ -64,15 +64,6 @@ Node::Node(bNode *editorNode, bool create_sockets)
                }
        }
 }
-Node::Node()
-{
-       this->m_editorNode = NULL;
-}
-
-bNode *Node::getbNode()
-{
-       return this->m_editorNode;
-}
 
 void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex)
 {
index 5d6d232f37aa06b44ab0a37f8ca93ab9dda270c6..bc4a25db605443f8851c9765474b890fb4c81780 100644 (file)
@@ -48,10 +48,6 @@ typedef pair<NodeIterator, NodeIterator> NodeRange;
  */
 class Node : public NodeBase {
 private:
-       /**
-        * @brief stores the reference to the SDNA bNode struct
-        */
-       bNode *m_editorNode;
 
        /**
         * @brief Is this node part of the active group
@@ -60,12 +56,7 @@ private:
 
 public:
        Node(bNode *editorNode, bool create_sockets = true);
-       
-       /**
-        * @brief get the reference to the SDNA bNode struct
-        */
-       bNode *getbNode();
-       
+
        /**
         * @brief Is this node in the active group (the group that is being edited)
         * @param isInActiveGroup
@@ -137,9 +128,6 @@ public:
         */
        OutputSocket *findOutputSocketBybNodeSocket(bNodeSocket *socket);
 protected:
-       
-       Node();
-       
        void addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket);
        void addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket);
        
index 8dbda5f649c8979548be723381342400684650e9..5c2ce37bdea03c79ca0ea5a78482cdd83e5ee695 100644 (file)
@@ -33,7 +33,7 @@
 
 NodeBase::NodeBase()
 {
-       /* pass */
+       this->m_editorNode = NULL;
 }
 
 
index 7095cda39e322929c18740ada5b31863b969aa5e..3c390f6bcdb4912797f6cc1eb0404e0b28d7b2f3 100644 (file)
@@ -54,6 +54,11 @@ private:
         */
        vector<OutputSocket *> m_outputsockets;
 
+       /**
+        * @brief stores the reference to the SDNA bNode struct
+        */
+       bNode *m_editorNode;
+
 protected:
        /**
         * @brief get access to the vector of input sockets
@@ -73,6 +78,18 @@ public:
         */
        virtual ~NodeBase();
        
+       /**
+        * @brief get the reference to the SDNA bNode struct
+        */
+       bNode *getbNode() {return m_editorNode;}
+       
+       /**
+        * @brief set the reference to the bNode
+        * @note used in Node instances to receive the storage/settings and complex node for highlight during execution
+        * @param bNode
+        */
+       void setbNode(bNode *bNode) {this->m_editorNode = bNode;}
+       
        /**
         * @brief is this node an operation?
         * This is true when the instance is of the subclass NodeOperation.
index 6ef8a5ff07871f2ba44325dad2da9493129854b9..c3fa308971c37748f254c7b81b1989d21cabbf90 100644 (file)
@@ -28,7 +28,7 @@
 #include "COM_SocketConnection.h"
 #include "COM_defines.h"
 
-NodeOperation::NodeOperation()
+NodeOperation::NodeOperation() : NodeBase()
 {
        this->m_resolutionInputSocketIndex = 0;
        this->m_complex = false;
index 1b541d81c33e238fc835d590865f818bf2c71ce4..5447652c238a5af65640259ae066dc38ce33fd2a 100644 (file)
@@ -49,6 +49,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
        if (data->filtertype == R_FILTER_FAST_GAUSS) {
                FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
                operationfgb->setData(data);
+               operationfgb->setbNode(editorNode);
                this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), 0, graph);
                this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph);
                this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0));
@@ -58,12 +59,14 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
        else if (!data->bokeh) {
                GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
                operationx->setData(data);
+               operationx->setbNode(editorNode);
                operationx->setQuality(quality);
                this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph);
                this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph);
                graph->addOperation(operationx);
                GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
                operationy->setData(data);
+               operationy->setbNode(editorNode);
                operationy->setQuality(quality);
                this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket());
                graph->addOperation(operationy);
@@ -79,6 +82,7 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
        else {
                GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
                operation->setData(data);
+               operation->setbNode(editorNode);
                this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
                operation->setQuality(quality);
index 59ec9525fa670c590d8aaac457be0cf9de0b6738..0ea4b20c79359f84e60367af038db625556faf27 100644 (file)
@@ -61,6 +61,7 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex
                this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
                operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
                operation->setQuality(context->getQuality());
+               operation->setbNode(this->getbNode());
                graph->addOperation(operation);
                this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
 //     }
index 461505871c635be0afe9e5cfce71d50efc7c3857..4c6b3ad137b44aaa0ffedd15e884f49b0c699a2d 100644 (file)
@@ -46,6 +46,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
        NodeDefocus *data = (NodeDefocus *)node->storage;
 
        NodeOperation *radiusOperation;
+       OutputSocket * depthOperation;
        if (data->no_zbuf) {
                MathMultiplyOperation *multiply = new MathMultiplyOperation();
                SetValueOperation *multiplier = new SetValueOperation();
@@ -63,6 +64,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
                graph->addOperation(maxRadius);
                graph->addOperation(minimize);
                radiusOperation = minimize;
+               depthOperation = minimize->getOutputSocket(0);
        }
        else {
                ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
@@ -72,6 +74,7 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
                this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), 1, graph);
                graph->addOperation(converter);
                radiusOperation = converter;
+               depthOperation = converter->getInputSocket(0)->getConnection()->getFromSocket();
        }
        
        BokehImageOperation *bokeh = new BokehImageOperation();
@@ -89,7 +92,15 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
        bokeh->setData(bokehdata);
        bokeh->deleteDataOnFinish();
        graph->addOperation(bokeh);
-       
+
+#ifdef COM_DEFOCUS_SEARCH      
+       InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation();
+       addLink(graph, radiusOperation->getOutputSocket(0), search->getInputSocket(0));
+       addLink(graph, depthOperation, search->getInputSocket(1));
+       search->setMaxBlur(data->maxblur);
+       search->setThreshold(data->bthresh);
+       graph->addOperation(search);
+#endif
        VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
        if (data->preview) {
                operation->setQuality(COM_QUALITY_LOW);
@@ -97,10 +108,14 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
                operation->setQuality(context->getQuality());
        }
        operation->setMaxBlur(data->maxblur);
+       operation->setbNode(node);
        operation->setThreshold(data->bthresh);
        addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
        addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
-       addLink(graph, radiusOperation->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(3));
+       addLink(graph, depthOperation, operation->getInputSocket(3));
+#ifdef COM_DEFOCUS_SEARCH
+       addLink(graph, search->getOutputSocket(), operation->getInputSocket(4));
+#endif
        if (data->gamco) {
                GammaCorrectOperation *correct = new GammaCorrectOperation();
                GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
@@ -115,6 +130,5 @@ void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext
                this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
        }
-       
        graph->addOperation(operation);
 }
index 3f4e3736bbe965ddc455ce21f6b6d35ed1daf5a6..043ae367fbb72ff0125d9a9cc6de37ab00b9d669 100644 (file)
@@ -40,6 +40,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        bNode *editorNode = this->getbNode();
        if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) {
                DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation();
+               operation->setbNode(editorNode);
                operation->setDistance(editorNode->custom2);
                operation->setInset(editorNode->custom3);
                
@@ -59,6 +60,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) {
                if (editorNode->custom2 > 0) {
                        DilateDistanceOperation *operation = new DilateDistanceOperation();
+                       operation->setbNode(editorNode);
                        operation->setDistance(editorNode->custom2);
                        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
@@ -66,6 +68,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
                }
                else {
                        ErodeDistanceOperation *operation = new ErodeDistanceOperation();
+                       operation->setbNode(editorNode);
                        operation->setDistance(-editorNode->custom2);
                        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
@@ -90,12 +93,14 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
                }
 
                GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
+               operationx->setbNode(editorNode);
                operationx->setData(data);
                operationx->setQuality(quality);
                this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph);
                // this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph); // no size input yet
                graph->addOperation(operationx);
                GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
+               operationy->setbNode(editorNode);
                operationy->setData(data);
                operationy->setQuality(quality);
                this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket());
@@ -127,6 +132,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        else {
                if (editorNode->custom2 > 0) {
                        DilateStepOperation *operation = new DilateStepOperation();
+                       operation->setbNode(editorNode);
                        operation->setIterations(editorNode->custom2);
                        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
@@ -134,6 +140,7 @@ void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorCont
                }
                else {
                        ErodeStepOperation *operation = new ErodeStepOperation();
+                       operation->setbNode(editorNode);
                        operation->setIterations(-editorNode->custom2);
                        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
index 57c319e763028e3cc0e00a70d8e1fb2c557b26aa..ab1d83385c701c11e9c4513442c9c0909584f4eb 100644 (file)
@@ -36,6 +36,7 @@ void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, Compositor
        bNode *bnode = this->getbNode();
        
        operation = new DoubleEdgeMaskOperation();
+       operation->setbNode(bnode);
        operation->setAdjecentOnly(bnode->custom1);
        operation->setKeepInside(bnode->custom2);
        
index 23f87805821c8ac4a9bfc6974347dfe1e57fea6f..021ec6c250873b502f2f6a79edec8a7ddf87eca7 100644 (file)
@@ -73,7 +73,7 @@ void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
                        operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);
                        break;
        }
-       
+       operation->setbNode(this->getbNode());
        inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
        inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
        outputSocket->relinkConnections(operation->getOutputSocket());
index 7b34fa4d286a50428d121cf70a6e9d33607bab7d..8782e6bb6d9fbb13a3fba903deac273b2958e856 100644 (file)
@@ -63,6 +63,8 @@ void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext *
        SetValueOperation *mixvalueoperation = new SetValueOperation();
        MixGlareOperation *mixoperation = new MixGlareOperation();
        mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT);
+       thresholdOperation->setbNode(node);
+       glareoperation->setbNode(node);
 
        this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), 0, system);
        addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
index cc6fc6e12365ad424ded29c194d8f4f054586317..7c39765fbf1f4f8fc305c42408240aea91110e71 100644 (file)
@@ -74,9 +74,11 @@ OutputSocket *KeyingNode::setupPreBlur(ExecutionSystem *graph, InputSocket *inpu
 
                        blurXOperation->setSize(size);
                        blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
+                       blurXOperation->setbNode(this->getbNode());
 
                        blurYOperation->setSize(size);
                        blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
+                       blurYOperation->setbNode(this->getbNode());
 
                        addLink(graph, separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0));
                        addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
@@ -104,9 +106,11 @@ OutputSocket *KeyingNode::setupPostBlur(ExecutionSystem *graph, OutputSocket *po
 
        blurXOperation->setSize(size);
        blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X);
+       blurXOperation->setbNode(this->getbNode());
 
        blurYOperation->setSize(size);
        blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y);
+       blurYOperation->setbNode(this->getbNode());
 
        addLink(graph, postBlurInput, blurXOperation->getInputSocket(0));
        addLink(graph, blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
@@ -129,6 +133,7 @@ OutputSocket *KeyingNode::setupDilateErode(ExecutionSystem *graph, OutputSocket
                dilateErodeOperation = new ErodeDistanceOperation();
                dilateErodeOperation->setDistance(-distance);
        }
+       dilateErodeOperation->setbNode(this->getbNode());
 
        addLink(graph, dilateErodeInput, dilateErodeOperation->getInputSocket(0));
 
@@ -161,14 +166,16 @@ OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext
        operationx->setSize(1.0f);
        operationx->setSubtract(distance < 0);
        operationx->setFalloff(falloff);
+       operationx->setbNode(this->getbNode());
        graph->addOperation(operationx);
-
+       
        GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
        operationy->setData(data);
        operationy->setQuality(quality);
        operationy->setSize(1.0f);
        operationy->setSubtract(distance < 0);
        operationy->setFalloff(falloff);
+       operationy->setbNode(this->getbNode());
        graph->addOperation(operationy);
 
        addLink(graph, featherInput, operationx->getInputSocket(0));
index 0fb8d45d066061d35ce3ea6eb4359da458bade53..cd1f79235ea54808ced78b4378d91744e6f10466 100644 (file)
@@ -45,6 +45,7 @@ void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorCon
 
        // always connect the output image
        KeyingScreenOperation *operation = new KeyingScreenOperation();
+       operation->setbNode(editorNode);
 
        if (outputScreen->isConnected()) {
                outputScreen->relinkConnections(operation->getOutputSocket());
index bb431f86897181c25acf9d8da16701acfbdbee14..4870e252b74f40918a4f039bb0d51745d6efbd24 100644 (file)
@@ -37,7 +37,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
        NodeLensDist *data = (NodeLensDist *)editorNode->storage;
        if (data->proj) {
                ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
-
+               operation->setbNode(editorNode);
                this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
                this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph);
                this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
@@ -48,6 +48,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
        }
        else {
                ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
+               operation->setbNode(editorNode);
                operation->setData(data);
                if (!(this->getInputSocket(1)->isConnected() || this->getInputSocket(2)->isConnected())) 
                {
index 13037b61a56f004e2170d9b9db6e333d762336a2..b6300300f6ff88e9de9bce01f6205cf88c148462 100644 (file)
@@ -45,7 +45,7 @@ void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
 
        // always connect the output image
        MaskOperation *operation = new MaskOperation();
-
+       operation->setbNode(editorNode);
        operation->setMaskWidth(data->xsch * data->size / 100.0f);
        operation->setMaskHeight(data->ysch * data->size / 100.0f);
 
index a1f33ed464bb9dce4c0a6107a9d2b7b728a5acfc..68e322e9dcf2d92e62ccf11234f279262e01dcb8 100644 (file)
@@ -34,7 +34,7 @@ void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext
 {
        NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
        TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation();
-
+       operation->setbNode(this->getbNode());
        operation->setData(data);
        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
        this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
index 5ef384a9984785652c754db5ea5ccf9dbd5036fb..07c8120b1d204b76c9ef33e4c3486376a04d4ec6 100644 (file)
@@ -34,6 +34,7 @@ void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorCont
        bNode *node = this->getbNode();
        NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
        VectorBlurOperation *operation = new VectorBlurOperation();
+       operation->setbNode(node);
        operation->setVectorBlurSettings(vectorBlurSettings);
        operation->setQuality(context->getQuality());
        this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
index 9eb004b3686d12f87ec7d926cb9493f9786c5049..46101f6355dc3b78b904cfa2a94ae98cef979b09 100644 (file)
@@ -33,6 +33,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
        this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
        this->addInputSocket(COM_DT_VALUE); // radius
        this->addInputSocket(COM_DT_VALUE); // depth
+#ifdef COM_DEFOCUS_SEARCH
+       this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure.
+#endif
        this->addOutputSocket(COM_DT_COLOR);
        this->setComplex(true);
 
@@ -42,6 +45,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation
        this->m_inputDepthProgram = NULL;
        this->m_maxBlur = 32.0f;
        this->m_threshold = 1.0f;
+#ifdef COM_DEFOCUS_SEARCH
+       this->m_inputSearchProgram = NULL;
+#endif
 }
 
 
@@ -51,6 +57,9 @@ void VariableSizeBokehBlurOperation::initExecution()
        this->m_inputBokehProgram = getInputSocketReader(1);
        this->m_inputSizeProgram = getInputSocketReader(2);
        this->m_inputDepthProgram = getInputSocketReader(3);
+#ifdef COM_DEFOCUS_SEARCH
+       this->m_inputSearchProgram = getInputSocketReader(4);
+#endif
        QualityStepHelper::initExecution(COM_QH_INCREASE);
 }
 
@@ -63,10 +72,19 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
        float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
        float color_accum[4]      = {0.0f, 0.0f, 0.0f, 0.0f};
 
-       int miny = y - this->m_maxBlur;
-       int maxy = y + this->m_maxBlur;
-       int minx = x - this->m_maxBlur;
-       int maxx = x + this->m_maxBlur;
+#ifdef COM_DEFOCUS_SEARCH
+       float search[4];
+       this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y/InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL);
+       int minx = search[0];
+       int miny = search[1];
+       int maxx = search[2];
+       int maxy = search[3];
+#else
+       int minx = MAX2(x - this->m_maxBlur, 0.0f);
+       int miny = MAX2(y - this->m_maxBlur, 0.0f);
+       int maxx = MIN2(x + this->m_maxBlur, m_width);
+       int maxy = MIN2(y + this->m_maxBlur, m_height);
+#endif
        {
                this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers);
                this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers);
@@ -80,9 +98,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
                        for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) {
                                if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
                                        this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers);
-                                       this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
-                                       float size = tempSize[0];
                                        if (tempDepth[0] < centerDepth) {
+                                               this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
+                                               float size = tempSize[0];
                                                if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) {
                                                        float dx = nx - x;
                                                        float dy = ny - y;
@@ -115,6 +133,10 @@ void VariableSizeBokehBlurOperation::deinitExecution()
        this->m_inputProgram = NULL;
        this->m_inputBokehProgram = NULL;
        this->m_inputSizeProgram = NULL;
+       this->m_inputDepthProgram = NULL;
+#ifdef COM_DEFOCUS_SEARCH
+       this->m_inputSearchProgram = NULL;
+#endif
 }
 
 bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -130,6 +152,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
        bokehInput.xmin = 0;
        bokehInput.ymax = 512;
        bokehInput.ymin = 0;
+       
 
        NodeOperation *operation = getInputOperation(2);
        if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
@@ -143,9 +166,118 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
        if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
                return true;
        }
+#ifdef COM_DEFOCUS_SEARCH
+       rcti searchInput;
+       searchInput.xmax = (input->xmax/InverseSearchRadiusOperation::DIVIDER)+1;
+       searchInput.xmin = (input->xmin/InverseSearchRadiusOperation::DIVIDER)-1;
+       searchInput.ymax = (input->ymax/InverseSearchRadiusOperation::DIVIDER)+1;
+       searchInput.ymin = (input->ymin/InverseSearchRadiusOperation::DIVIDER)-1;
+       operation = getInputOperation(4);
+       if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) {
+               return true;
+       }
+#endif
        operation = getInputOperation(0);
        if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
                return true;
        }
        return false;
 }
+
+#ifdef COM_DEFOCUS_SEARCH
+// InverseSearchRadiusOperation
+InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation() 
+{
+       this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius
+       this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth
+       this->addOutputSocket(COM_DT_COLOR);
+       this->setComplex(true);
+       this->inputRadius = NULL;
+       this->inputDepth = NULL;
+}
+
+void InverseSearchRadiusOperation::initExecution() 
+{
+       this->inputRadius = this->getInputSocketReader(0);
+       this->inputDepth = this->getInputSocketReader(1);
+}
+
+void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) 
+{
+       MemoryBuffer * data = new MemoryBuffer(NULL, rect);
+       int x, y;
+       float width = this->inputRadius->getWidth();
+       float height = this->inputRadius->getHeight();
+               
+       for (x = rect->xmin; x < rect->xmax ; x++) {
+               for (y = rect->ymin; y < rect->ymax ; y++) {
+                       float[4] temp;
+                       int rx = x * DIVIDER;
+                       int ry = y * DIVIDER;
+                       this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL);
+                       float centerRadius = temp[0];
+                       this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL);
+                       float centerDepth = temp[0];
+                       t[0] = MAX2(rx - this->maxBlur, 0.0f);
+                       t[1] = MAX2(ry - this->maxBlur, 0.0f);
+                       t[2] = MIN2(rx + this->maxBlur, width);
+                       t[3] = MIN2(ry + this->maxBlur, height);
+                       int minx = t[0];
+                       int miny = t[1];
+                       int maxx = t[2];
+                       int maxy = t[3];
+                       int sminx = rx;
+                       int smaxx = rx;
+                       int sminy = ry;
+                       int smaxy = ry;
+                       for (int nx = minx ; nx < maxx ; nx ++) {
+                               for (int ny = miny ; ny < maxy ; ny ++) {
+                                       this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL);
+                                       if (nx < rx && temp[0])
+                                       
+                               }
+                       }
+                       float t[4];
+                       data->writePixel(x, y, t);
+               }
+       }
+       return data;
+}
+
+void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) 
+{
+       MemoryBuffer *buffer = (MemoryBuffer*)data;
+       buffer->read(color, x, y);
+}
+
+void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) 
+{
+       if (data) {
+               MemoryBuffer* mb = (MemoryBuffer*)data;
+               delete mb;
+       }
+}
+
+void InverseSearchRadiusOperation::deinitExecution() 
+{
+       this->inputRadius = NULL;
+       this->inputDepth = NULL;
+}
+
+void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
+{
+       NodeOperation::determineResolution(resolution, preferredResolution);
+       resolution[0] = resolution[0] / DIVIDER;
+       resolution[1] = resolution[1] / DIVIDER;
+}
+
+bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
+       rcti newRect;
+       newRect.ymin = input->ymin*DIVIDER;
+       newRect.ymax = input->ymax*DIVIDER;
+       newRect.xmin = input->xmin*DIVIDER;
+       newRect.xmax = input->xmax*DIVIDER;
+       return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output);
+}
+#endif
index 8e59a43fcb112f87f4260b4b6a14f4cb38a96b55..4bf597ff831613d3f131138d939958c3f8e25932 100644 (file)
@@ -25,6 +25,7 @@
 #include "COM_NodeOperation.h"
 #include "COM_QualityStepHelper.h"
 
+
 class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper {
 private:
        int m_maxBlur;
@@ -33,6 +34,9 @@ private:
        SocketReader *m_inputBokehProgram;
        SocketReader *m_inputSizeProgram;
        SocketReader *m_inputDepthProgram;
+#ifdef COM_DEFOCUS_SEARCH
+       SocketReader *inputSearchProgram;
+#endif
 
 public:
        VariableSizeBokehBlurOperation();
@@ -60,4 +64,42 @@ public:
 
 
 };
+
+#ifdef COM_DEFOCUS_SEARCH
+class InverseSearchRadiusOperation : public NodeOperation {
+private:
+       int maxBlur;
+       float threshold;
+       SocketReader *inputDepth;
+       SocketReader *inputRadius;
+public:
+       static const int DIVIDER = 4;
+       
+       InverseSearchRadiusOperation();
+
+       /**
+        * the inner loop of this program
+        */
+       void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
+       
+       /**
+        * Initialize the execution
+        */
+       void initExecution();
+       void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+       void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
+       
+       /**
+        * Deinitialize the execution
+        */
+       void deinitExecution();
+       
+       bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+       void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+       
+       void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; }
+
+       void setThreshold(float threshold) { this->threshold = threshold; }
+};
+#endif
 #endif
index 7259db34134d75b75a10af3c6b0e1c33e77147e0..1a319d67115d853a12ac53f8ec782db492c5a860 100644 (file)
@@ -63,6 +63,9 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
        MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
        float *buffer = memoryBuffer->getBuffer();
        if (this->m_input->isComplex()) {
+               bNode* bnode = this->m_input->getbNode();
+               if (bnode&& bnode->new_node) bnode->new_node->highlight++;
+
                void *data = this->m_input->initializeTileData(rect, memoryBuffers);
                int x1 = rect->xmin;
                int y1 = rect->ymin;
@@ -87,6 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me
                        this->m_input->deinitializeTileData(rect, memoryBuffers, data);
                        data = NULL;
                }
+               if (bnode&& bnode->new_node) bnode->new_node->highlight++;
        }
        else {
                int x1 = rect->xmin;
@@ -139,6 +143,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
        list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
        clMemToCleanUp->push_back(clOutputBuffer);
        list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
+       bNode* bnode = this->m_input->getbNode();
+       if (bnode&& bnode->new_node) bnode->new_node->highlight++;
 
        this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
 
@@ -156,7 +162,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect,
        if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error));  }
        
        this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
-       
+
+       if (bnode&& bnode->new_node) bnode->new_node->highlight++;
        // STEP 4
 
        
index 17d7530d2a7858aacdc47190e783982430a3f6da..65646c855b74e690eb963c03319e87eacda13e71 100644 (file)
@@ -724,6 +724,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        if (node->flag & NODE_MUTED)
                UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
 
+       if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) {
+               if (node->highlight) {
+                       UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
+                       node->highlight = 0;
+               }
+       }
        uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
        uiRoundBox(rct->xmin, rct->ymax-NODE_DY, rct->xmax, rct->ymax, BASIS_RAD);
        
@@ -805,7 +811,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        glDisable(GL_BLEND);
 
        /* outline active and selected emphasis */
-       if ( node->flag & (NODE_ACTIVE|SELECT) ) {
+       if ( node->flag & (NODE_ACTIVE|SELECT)) {
                glEnable(GL_BLEND);
                glEnable(GL_LINE_SMOOTH);
                
@@ -862,7 +868,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
        node->block= NULL;
 }
 
-static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNode *node)
+static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node)
 {
        bNodeSocket *sock;
        rctf *rct= &node->totr;
@@ -879,10 +885,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b
        UI_ThemeColor(color_id);
        if (node->flag & NODE_MUTED)
                UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
+
+       if (ntree->type == NTREE_COMPOSIT && (snode->flag&SNODE_SHOW_HIGHLIGHT)) {
+               if (node->highlight) {
+                       UI_ThemeColorBlend(color_id, TH_ACTIVE, 0.5f);
+                       node->highlight = 0;
+               }
+       }
+       
        uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad);
        
        /* outline active and selected emphasis */
-       if ( node->flag & (NODE_ACTIVE|SELECT) ) {
+       if ( node->flag & (NODE_ACTIVE|SELECT)) {
                glEnable(GL_BLEND);
                glEnable(GL_LINE_SMOOTH);
                
@@ -1005,7 +1019,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode)
 void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node)
 {
        if (node->flag & NODE_HIDDEN)
-               node_draw_hidden(C, ar, snode, node);
+               node_draw_hidden(C, ar, snode, ntree, node);
        else
                node_draw_basis(C, ar, snode, ntree, node);
 }
index 15641d9770996e0e9a04756257b7e685274f43b1..79be4d0842d042114a9a09ca62d9e3517d9afe96 100644 (file)
@@ -177,10 +177,11 @@ 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 */
        rctf butr;                              /* optional buttons area */
        rctf prvr;                              /* optional preview area */
index 2f6ea861cbada7bbb29d46d7c83ad666b2ed3d2c..28c386241a7af75e1bb1ca09162b247df830f635 100644 (file)
@@ -875,11 +875,12 @@ typedef struct SpaceNode {
 
 /* snode->flag */
 typedef enum eSpaceNode_Flag {
-       SNODE_BACKDRAW     = (1 << 1),
-/*  SNODE_DISPGP       = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */
-       SNODE_USE_ALPHA    = (1 << 3),
-       SNODE_SHOW_ALPHA   = (1 << 4),
-       SNODE_AUTO_RENDER  = (1 << 5),
+       SNODE_BACKDRAW       = (1 << 1),
+/*  SNODE_DISPGP         = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */
+       SNODE_USE_ALPHA      = (1 << 3),
+       SNODE_SHOW_ALPHA     = (1 << 4),
+       SNODE_AUTO_RENDER    = (1 << 5),
+       SNODE_SHOW_HIGHLIGHT = (1 << 6),
 } eSpaceNode_Flag;
 
 /* snode->texfrom */
index e4af06a501206bec7511cb6152f7dc8eef5e75ba..09d2668d10b5daf07c2dc1ffd9fd4270ec6affeb 100644 (file)
@@ -2926,6 +2926,11 @@ static void rna_def_space_node(BlenderRNA *brna)
        RNA_def_property_enum_items(prop, backdrop_channels_items);
        RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
+
+       prop = RNA_def_property(srna, "show_highlight", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", SNODE_SHOW_HIGHLIGHT);
+       RNA_def_property_ui_text(prop, "Highlight", "Highlight nodes that are being calculated");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
 }
 
 static void rna_def_space_logic(BlenderRNA *brna)
index 72112180bc82c22b371c194b8b3cd4eee20e0c31..58357bdd59d087553633b77de77b5b15d013ccc2 100644 (file)
@@ -118,7 +118,6 @@ static void update_node(bNodeTree *ntree, bNode *node)
                }
        }
        node->need_exec= 1;
-       
        /* individual node update call */
        if (node->typeinfo->updatefunc)
                node->typeinfo->updatefunc(ntree, node);
@@ -192,6 +191,8 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
        
        /* move over the compbufs and previews */
        for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
+               lnode->new_node->new_node = lnode;
+               lnode->highlight = 0;
                if ( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) {
                        if (ntreeNodeExists(ntree, lnode->new_node)) {
                                
@@ -200,6 +201,7 @@ static void local_sync(bNodeTree *localtree, bNodeTree *ntree)
                                        lnode->new_node->preview= lnode->preview;
                                        lnode->preview= NULL;
                                }
+                               
                        }
                }
        }
@@ -212,6 +214,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
        
        /* move over the compbufs and previews */
        for (lnode= localtree->nodes.first; lnode; lnode= lnode->next) {
+               lnode->highlight = 0;
                if (ntreeNodeExists(ntree, lnode->new_node)) {
                        if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
                                if (lnode->id && (lnode->flag & NODE_DO_OUTPUT)) {