One fix for bug [#33785] compositor is (unnecessarily?) slow
authorMonique Dewanchand <m.dewanchand@atmind.nl>
Sun, 3 Feb 2013 17:22:26 +0000 (17:22 +0000)
committerMonique Dewanchand <m.dewanchand@atmind.nl>
Sun, 3 Feb 2013 17:22:26 +0000 (17:22 +0000)
Added additional buffers - new subtree - for groupnodes.
One needs to be aware of how groupnodes should be created.
Having translate & scale nodes, with the translate inside the groupnode and the scale node outside, causes artefacts.
Both should be inside or outside the groupnode. Same holds for other distort nodes.

source/blender/compositor/nodes/COM_GroupNode.cpp
source/blender/compositor/nodes/COM_SocketProxyNode.cpp
source/blender/compositor/nodes/COM_SocketProxyNode.h

index e10d7db..3219001 100644 (file)
@@ -58,7 +58,7 @@ void GroupNode::ungroup(ExecutionSystem &system)
                InputSocket *inputSocket = inputsockets[index];
                bNodeSocket *editorInput = inputSocket->getbNodeSocket();
                if (editorInput->groupsock) {
-                       SocketProxyNode *proxy = new SocketProxyNode(bnode, editorInput, editorInput->groupsock);
+            SocketProxyNode *proxy = new SocketProxyNode(bnode, editorInput, editorInput->groupsock, false);
                        inputSocket->relinkConnections(proxy->getInputSocket(0), index, &system);
                        ExecutionSystemHelper::addNode(system.getNodes(), proxy);
                }
@@ -68,7 +68,7 @@ void GroupNode::ungroup(ExecutionSystem &system)
                OutputSocket *outputSocket = outputsockets[index];
                bNodeSocket *editorOutput = outputSocket->getbNodeSocket();
                if (editorOutput->groupsock) {
-                       SocketProxyNode *proxy = new SocketProxyNode(bnode, editorOutput->groupsock, editorOutput);
+            SocketProxyNode *proxy = new SocketProxyNode(bnode, editorOutput->groupsock, editorOutput, true);
                        outputSocket->relinkConnections(proxy->getOutputSocket(0));
                        ExecutionSystemHelper::addNode(system.getNodes(), proxy);
                }
index bfb32a9..e602667 100644 (file)
 #include "COM_SetValueOperation.h"
 #include "COM_SetVectorOperation.h"
 #include "COM_SetColorOperation.h"
+#include "COM_WriteBufferOperation.h"
+#include "COM_ReadBufferOperation.h"
 
-SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput) : Node(editorNode, false)
+SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool buffer) : Node(editorNode, false)
 {
        DataType dt;
-       
+    this->m_buffer = buffer;
+
        dt = COM_DT_VALUE;
        if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR;
        if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
@@ -49,11 +52,22 @@ void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorCont
        InputSocket *inputsocket = this->getInputSocket(0);
        if (outputsocket->isConnected()) {
                if (inputsocket->isConnected()) {
-                       SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType());
+            SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType());
                        inputsocket->relinkConnections(operation->getInputSocket(0));
                        outputsocket->relinkConnections(operation->getOutputSocket(0));
                        graph->addOperation(operation);
-               }
+            if (m_buffer){
+                WriteBufferOperation * writeOperation = new WriteBufferOperation();
+                ReadBufferOperation * readOperation = new ReadBufferOperation();
+                readOperation->setMemoryProxy(writeOperation->getMemoryProxy());
+
+                operation->getOutputSocket()->relinkConnections(readOperation->getOutputSocket());
+                addLink(graph, operation->getOutputSocket(), writeOperation->getInputSocket(0));
+
+                graph->addOperation(writeOperation);
+                graph->addOperation(readOperation);
+            }
+        }
                else {
                        /* If input is not connected, add a constant value operation instead */
                        switch (outputsocket->getDataType()) {
index ea50be4..a83ac09 100644 (file)
  * @ingroup Node
  */
 class SocketProxyNode : public Node {
+private:
+    bool m_buffer;
 public:
-       SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+    SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool buffer);
        void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
 
        virtual bool isProxyNode() const { return true; }