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:
authorLukas Tönne <lukas.toenne@gmail.com>2014-04-15 18:06:12 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2014-04-15 18:28:10 +0400
commit09874df135888b89f51d7becaa369ebb1d1623c6 (patch)
treebccf5950d42963992adff95dbc3f00ed7db1cf16 /source/blender/compositor/intern/COM_ExecutionSystem.h
parent28a829893c702918afc5ac1945a06eaefa611594 (diff)
Structural cleanup and improvements for the compositor.
Many parts of the compositor are unnecessarily complicated. This patch aims at reducing the complexity of writing nodes and making the code more transparent. == Separating Nodes and Operations == Currently these are both mixed in the same graph, even though they have very different purposes and are used at distinct stages in the compositing process. The patch introduces dedicated graph classes for nodes and for operations. This removes the need for a lot of special case checks (isOperation etc.) and explicit type casts. It simplifies the code since it becomes clear at every stage what type of node we are dealing with. The compiler can use static typing to avoid common bugs from mixing up these types and fewer runtime sanity checks are needed. == Simplified Node Conversion == Converting nodes to operations was previously based on "relinking", i.e. nodes would start with by mirroring links in the Blender DNA node trees, then add operations and redirect these links to them. This was very hard to follow in many cases and required a lot of attention to avoid invalid states. Now there is a helper class called the NodeConverter, which is passed to nodes and implements a much simpler API for this process. Nodes can add operations and explicit connections as before, but defining "external" links to the inputs/outputs of the original node now uses mapping instead of directly modifying link data. Input data (node graph) and result (operations graph) are cleanly separated. == Removed Redundant Data Structures == A few redundant data structures have been removed, notably the SocketConnection. These are only needed temporarily during graph construction. For executing the compositor operations it is perfectly sufficient to store only the direct input link pointers. A common pointer indirection is avoided this way (which might also give a little performance improvement). == Avoid virtual recursive functions == Recursive virtual functions are evil. They are very hard to follow during debugging. At least in the parts this patch is concerned with these functions have been replaced by a non-virtual recursive core function (which might then call virtual non-recursive functions if needed). See for example NodeOperationBuilder::group_operations.
Diffstat (limited to 'source/blender/compositor/intern/COM_ExecutionSystem.h')
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h91
1 files changed, 12 insertions, 79 deletions
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 7402ff90fb5..ab903206f0a 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -29,7 +29,6 @@ class ExecutionGroup;
#include "DNA_node_types.h"
#include <vector>
#include "COM_Node.h"
-#include "COM_SocketConnection.h"
#include "BKE_text.h"
#include "COM_ExecutionGroup.h"
#include "COM_NodeOperation.h"
@@ -73,7 +72,7 @@ using namespace std;
* As values are ordered differently than colors a conversion happens.
*
* - Image size conversions: the system can automatically convert when resolutions do not match.
- * An InputSocket has a resize mode. This can be any of the following settings.
+ * An NodeInput has a resize mode. This can be any of the following settings.
* - [@ref InputSocketResizeMode.COM_SC_CENTER]: The center of both images are aligned
* - [@ref InputSocketResizeMode.COM_SC_FIT_WIDTH]: The width of both images are aligned
* - [@ref InputSocketResizeMode.COM_SC_FIT_HEIGHT]: the height of both images are aligned
@@ -115,6 +114,10 @@ using namespace std;
* @brief the ExecutionSystem contains the whole compositor tree.
*/
class ExecutionSystem {
+public:
+ typedef std::vector<NodeOperation*> Operations;
+ typedef std::vector<ExecutionGroup*> Groups;
+
private:
/**
* @brief the context used during execution
@@ -122,34 +125,17 @@ private:
CompositorContext m_context;
/**
- * @brief vector of nodes
- */
- vector<Node *> m_nodes;
-
- /**
* @brief vector of operations
*/
- vector<NodeOperation *> m_operations;
+ Operations m_operations;
/**
* @brief vector of groups
*/
- vector<ExecutionGroup *> m_groups;
-
- /**
- * @brief vector of connections
- */
- vector<SocketConnection *> m_connections;
+ Groups m_groups;
private: //methods
/**
- * @brief add ReadBufferOperation and WriteBufferOperation around an operation
- * @param operation the operation to add the bufferoperations around.
- */
- void addReadWriteBufferOperations(NodeOperation *operation);
-
-
- /**
* find all execution group with output nodes
*/
void findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const;
@@ -175,6 +161,7 @@ public:
*/
~ExecutionSystem();
+ void set_operations(const Operations &operations, const Groups &groups);
/**
* @brief execute this system
@@ -185,70 +172,16 @@ public:
void execute();
/**
- * @brief Add an operation to the operation list
- *
- * @param operation the operation to add
- */
- void addOperation(NodeOperation *operation);
-
- /**
- * Add an editor link to the system. convert it to an socketconnection (CPP-representative)
- * this converted socket is returned.
- */
- SocketConnection *addNodeLink(bNodeLink *bNodeLink);
- void addSocketConnection(SocketConnection *connection);
-
- /**
- * Remove a socket connection from the system.
- */
- void removeSocketConnection(SocketConnection *connection);
-
- /**
- * @brief Convert all nodes to operations
- */
- void convertToOperations();
-
- /**
- * @brief group operations in ExecutionGroup's
- * @see ExecutionGroup
- */
- void groupOperations();
-
- /**
* @brief get the reference to the compositor context
*/
- CompositorContext &getContext() { return this->m_context; }
-
- /**
- * @brief get the reference to the compositor nodes
- */
- vector<Node *> &getNodes() { return this->m_nodes; }
-
- /**
- * @brief get the reference to the compositor connections
- */
- vector<SocketConnection *>& getConnections() { return this->m_connections; }
-
- /**
- * @brief get the reference to the list of execution groups
- */
- vector<ExecutionGroup *>& getExecutionGroups() { return this->m_groups; }
-
- /**
- * @brief get the reference to the list of operations
- */
- vector<NodeOperation *>& getOperations() { return this->m_operations; }
+ const CompositorContext &getContext() const { return this->m_context; }
private:
-
- /**
- * @brief determine the actual data types of all sockets
- * @param nodes list of nodes or operations to do the data type determination
- */
- void determineActualSocketDataTypes(vector<NodeBase *> &nodes);
-
void executeGroups(CompositorPriority priority);
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
+
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem")
#endif