Structural cleanup and improvements for the compositor.
authorLukas Tönne <lukas.toenne@gmail.com>
Tue, 15 Apr 2014 14:06:12 +0000 (16:06 +0200)
committerLukas Tönne <lukas.toenne@gmail.com>
Tue, 15 Apr 2014 14:28:10 +0000 (16:28 +0200)
commit09874df135888b89f51d7becaa369ebb1d1623c6
treebccf5950d42963992adff95dbc3f00ed7db1cf16
parent28a829893c702918afc5ac1945a06eaefa611594
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.
251 files changed:
source/blender/compositor/CMakeLists.txt
source/blender/compositor/COM_compositor.h
source/blender/compositor/COM_defines.h
source/blender/compositor/intern/COM_CPUDevice.cpp
source/blender/compositor/intern/COM_ChannelInfo.h
source/blender/compositor/intern/COM_CompositorContext.h
source/blender/compositor/intern/COM_Converter.cpp
source/blender/compositor/intern/COM_Converter.h
source/blender/compositor/intern/COM_Debug.cpp
source/blender/compositor/intern/COM_Debug.h
source/blender/compositor/intern/COM_ExecutionGroup.cpp
source/blender/compositor/intern/COM_ExecutionGroup.h
source/blender/compositor/intern/COM_ExecutionSystem.cpp
source/blender/compositor/intern/COM_ExecutionSystem.h
source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp [deleted file]
source/blender/compositor/intern/COM_ExecutionSystemHelper.h [deleted file]
source/blender/compositor/intern/COM_InputSocket.cpp [deleted file]
source/blender/compositor/intern/COM_InputSocket.h [deleted file]
source/blender/compositor/intern/COM_MemoryBuffer.cpp
source/blender/compositor/intern/COM_MemoryBuffer.h
source/blender/compositor/intern/COM_MemoryProxy.h
source/blender/compositor/intern/COM_Node.cpp
source/blender/compositor/intern/COM_Node.h
source/blender/compositor/intern/COM_NodeBase.cpp [deleted file]
source/blender/compositor/intern/COM_NodeBase.h [deleted file]
source/blender/compositor/intern/COM_NodeConverter.cpp [new file with mode: 0644]
source/blender/compositor/intern/COM_NodeConverter.h [new file with mode: 0644]
source/blender/compositor/intern/COM_NodeGraph.cpp [new file with mode: 0644]
source/blender/compositor/intern/COM_NodeGraph.h [new file with mode: 0644]
source/blender/compositor/intern/COM_NodeOperation.cpp
source/blender/compositor/intern/COM_NodeOperation.h
source/blender/compositor/intern/COM_NodeOperationBuilder.cpp [new file with mode: 0644]
source/blender/compositor/intern/COM_NodeOperationBuilder.h [new file with mode: 0644]
source/blender/compositor/intern/COM_OpenCLDevice.cpp
source/blender/compositor/intern/COM_OpenCLDevice.h
source/blender/compositor/intern/COM_OutputSocket.cpp [deleted file]
source/blender/compositor/intern/COM_OutputSocket.h [deleted file]
source/blender/compositor/intern/COM_SingleThreadedOperation.cpp [moved from source/blender/compositor/intern/COM_SingleThreadedNodeOperation.cpp with 77% similarity]
source/blender/compositor/intern/COM_SingleThreadedOperation.h [moved from source/blender/compositor/intern/COM_SingleThreadedNodeOperation.h with 88% similarity]
source/blender/compositor/intern/COM_Socket.cpp [deleted file]
source/blender/compositor/intern/COM_Socket.h [deleted file]
source/blender/compositor/intern/COM_SocketConnection.cpp [deleted file]
source/blender/compositor/intern/COM_SocketConnection.h [deleted file]
source/blender/compositor/intern/COM_WorkScheduler.cpp
source/blender/compositor/nodes/COM_AlphaOverNode.cpp
source/blender/compositor/nodes/COM_AlphaOverNode.h
source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
source/blender/compositor/nodes/COM_BilateralBlurNode.h
source/blender/compositor/nodes/COM_BlurNode.cpp
source/blender/compositor/nodes/COM_BlurNode.h
source/blender/compositor/nodes/COM_BokehBlurNode.cpp
source/blender/compositor/nodes/COM_BokehBlurNode.h
source/blender/compositor/nodes/COM_BokehImageNode.cpp
source/blender/compositor/nodes/COM_BokehImageNode.h
source/blender/compositor/nodes/COM_BoxMaskNode.cpp
source/blender/compositor/nodes/COM_BoxMaskNode.h
source/blender/compositor/nodes/COM_BrightnessNode.cpp
source/blender/compositor/nodes/COM_BrightnessNode.h
source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
source/blender/compositor/nodes/COM_ChannelMatteNode.h
source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
source/blender/compositor/nodes/COM_ChromaMatteNode.h
source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
source/blender/compositor/nodes/COM_ColorBalanceNode.h
source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
source/blender/compositor/nodes/COM_ColorCorrectionNode.h
source/blender/compositor/nodes/COM_ColorCurveNode.cpp
source/blender/compositor/nodes/COM_ColorCurveNode.h
source/blender/compositor/nodes/COM_ColorMatteNode.cpp
source/blender/compositor/nodes/COM_ColorMatteNode.h
source/blender/compositor/nodes/COM_ColorNode.cpp
source/blender/compositor/nodes/COM_ColorNode.h
source/blender/compositor/nodes/COM_ColorRampNode.cpp
source/blender/compositor/nodes/COM_ColorRampNode.h
source/blender/compositor/nodes/COM_ColorSpillNode.cpp
source/blender/compositor/nodes/COM_ColorSpillNode.h
source/blender/compositor/nodes/COM_ColorToBWNode.cpp
source/blender/compositor/nodes/COM_ColorToBWNode.h
source/blender/compositor/nodes/COM_CombineColorNode.cpp [new file with mode: 0644]
source/blender/compositor/nodes/COM_CombineColorNode.h [new file with mode: 0644]
source/blender/compositor/nodes/COM_CombineHSVANode.cpp [deleted file]
source/blender/compositor/nodes/COM_CombineHSVANode.h [deleted file]
source/blender/compositor/nodes/COM_CombineRGBANode.cpp [deleted file]
source/blender/compositor/nodes/COM_CombineRGBANode.h [deleted file]
source/blender/compositor/nodes/COM_CombineYCCANode.cpp [deleted file]
source/blender/compositor/nodes/COM_CombineYCCANode.h [deleted file]
source/blender/compositor/nodes/COM_CombineYUVANode.cpp [deleted file]
source/blender/compositor/nodes/COM_CombineYUVANode.h [deleted file]
source/blender/compositor/nodes/COM_CompositorNode.cpp
source/blender/compositor/nodes/COM_CompositorNode.h
source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
source/blender/compositor/nodes/COM_ConvertAlphaNode.h
source/blender/compositor/nodes/COM_CornerPinNode.cpp
source/blender/compositor/nodes/COM_CornerPinNode.h
source/blender/compositor/nodes/COM_CropNode.cpp
source/blender/compositor/nodes/COM_CropNode.h
source/blender/compositor/nodes/COM_DefocusNode.cpp
source/blender/compositor/nodes/COM_DefocusNode.h
source/blender/compositor/nodes/COM_DespeckleNode.cpp
source/blender/compositor/nodes/COM_DespeckleNode.h
source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
source/blender/compositor/nodes/COM_DifferenceMatteNode.h
source/blender/compositor/nodes/COM_DilateErodeNode.cpp
source/blender/compositor/nodes/COM_DilateErodeNode.h
source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
source/blender/compositor/nodes/COM_DirectionalBlurNode.h
source/blender/compositor/nodes/COM_DisplaceNode.cpp
source/blender/compositor/nodes/COM_DisplaceNode.h
source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
source/blender/compositor/nodes/COM_DistanceMatteNode.h
source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
source/blender/compositor/nodes/COM_EllipseMaskNode.h
source/blender/compositor/nodes/COM_FilterNode.cpp
source/blender/compositor/nodes/COM_FilterNode.h
source/blender/compositor/nodes/COM_FlipNode.cpp
source/blender/compositor/nodes/COM_FlipNode.h
source/blender/compositor/nodes/COM_GammaNode.cpp
source/blender/compositor/nodes/COM_GammaNode.h
source/blender/compositor/nodes/COM_GlareNode.cpp
source/blender/compositor/nodes/COM_GlareNode.h
source/blender/compositor/nodes/COM_GroupNode.cpp [deleted file]
source/blender/compositor/nodes/COM_GroupNode.h [deleted file]
source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
source/blender/compositor/nodes/COM_HueSaturationValueNode.h
source/blender/compositor/nodes/COM_IDMaskNode.cpp
source/blender/compositor/nodes/COM_IDMaskNode.h
source/blender/compositor/nodes/COM_ImageNode.cpp
source/blender/compositor/nodes/COM_ImageNode.h
source/blender/compositor/nodes/COM_InpaintNode.cpp
source/blender/compositor/nodes/COM_InpaintNode.h
source/blender/compositor/nodes/COM_InvertNode.cpp
source/blender/compositor/nodes/COM_InvertNode.h
source/blender/compositor/nodes/COM_KeyingNode.cpp
source/blender/compositor/nodes/COM_KeyingNode.h
source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
source/blender/compositor/nodes/COM_KeyingScreenNode.h
source/blender/compositor/nodes/COM_LensDistortionNode.cpp
source/blender/compositor/nodes/COM_LensDistortionNode.h
source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
source/blender/compositor/nodes/COM_LuminanceMatteNode.h
source/blender/compositor/nodes/COM_MapRangeNode.cpp
source/blender/compositor/nodes/COM_MapRangeNode.h
source/blender/compositor/nodes/COM_MapUVNode.cpp
source/blender/compositor/nodes/COM_MapUVNode.h
source/blender/compositor/nodes/COM_MapValueNode.cpp
source/blender/compositor/nodes/COM_MapValueNode.h
source/blender/compositor/nodes/COM_MaskNode.cpp
source/blender/compositor/nodes/COM_MaskNode.h
source/blender/compositor/nodes/COM_MathNode.cpp
source/blender/compositor/nodes/COM_MathNode.h
source/blender/compositor/nodes/COM_MixNode.cpp
source/blender/compositor/nodes/COM_MixNode.h
source/blender/compositor/nodes/COM_MovieClipNode.cpp
source/blender/compositor/nodes/COM_MovieClipNode.h
source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
source/blender/compositor/nodes/COM_MovieDistortionNode.h
source/blender/compositor/nodes/COM_MuteNode.cpp [deleted file]
source/blender/compositor/nodes/COM_MuteNode.h [deleted file]
source/blender/compositor/nodes/COM_NormalNode.cpp
source/blender/compositor/nodes/COM_NormalNode.h
source/blender/compositor/nodes/COM_NormalizeNode.cpp
source/blender/compositor/nodes/COM_NormalizeNode.h
source/blender/compositor/nodes/COM_OutputFileNode.cpp
source/blender/compositor/nodes/COM_OutputFileNode.h
source/blender/compositor/nodes/COM_PixelateNode.cpp
source/blender/compositor/nodes/COM_PixelateNode.h
source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
source/blender/compositor/nodes/COM_RenderLayersNode.cpp
source/blender/compositor/nodes/COM_RenderLayersNode.h
source/blender/compositor/nodes/COM_RotateNode.cpp
source/blender/compositor/nodes/COM_RotateNode.h
source/blender/compositor/nodes/COM_ScaleNode.cpp
source/blender/compositor/nodes/COM_ScaleNode.h
source/blender/compositor/nodes/COM_SeparateColorNode.cpp [new file with mode: 0644]
source/blender/compositor/nodes/COM_SeparateColorNode.h [new file with mode: 0644]
source/blender/compositor/nodes/COM_SeparateHSVANode.cpp [deleted file]
source/blender/compositor/nodes/COM_SeparateHSVANode.h [deleted file]
source/blender/compositor/nodes/COM_SeparateRGBANode.cpp [deleted file]
source/blender/compositor/nodes/COM_SeparateRGBANode.h [deleted file]
source/blender/compositor/nodes/COM_SeparateYCCANode.cpp [deleted file]
source/blender/compositor/nodes/COM_SeparateYCCANode.h [deleted file]
source/blender/compositor/nodes/COM_SeparateYUVANode.cpp [deleted file]
source/blender/compositor/nodes/COM_SeparateYUVANode.h [deleted file]
source/blender/compositor/nodes/COM_SetAlphaNode.cpp
source/blender/compositor/nodes/COM_SetAlphaNode.h
source/blender/compositor/nodes/COM_SocketProxyNode.cpp
source/blender/compositor/nodes/COM_SocketProxyNode.h
source/blender/compositor/nodes/COM_SplitViewerNode.cpp
source/blender/compositor/nodes/COM_SplitViewerNode.h
source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
source/blender/compositor/nodes/COM_Stabilize2dNode.h
source/blender/compositor/nodes/COM_SwitchNode.cpp
source/blender/compositor/nodes/COM_SwitchNode.h
source/blender/compositor/nodes/COM_TextureNode.cpp
source/blender/compositor/nodes/COM_TextureNode.h
source/blender/compositor/nodes/COM_TimeNode.cpp
source/blender/compositor/nodes/COM_TimeNode.h
source/blender/compositor/nodes/COM_TonemapNode.cpp
source/blender/compositor/nodes/COM_TonemapNode.h
source/blender/compositor/nodes/COM_TrackPositionNode.cpp
source/blender/compositor/nodes/COM_TrackPositionNode.h
source/blender/compositor/nodes/COM_TransformNode.cpp
source/blender/compositor/nodes/COM_TransformNode.h
source/blender/compositor/nodes/COM_TranslateNode.cpp
source/blender/compositor/nodes/COM_TranslateNode.h
source/blender/compositor/nodes/COM_ValueNode.cpp
source/blender/compositor/nodes/COM_ValueNode.h
source/blender/compositor/nodes/COM_VectorBlurNode.cpp
source/blender/compositor/nodes/COM_VectorBlurNode.h
source/blender/compositor/nodes/COM_VectorCurveNode.cpp
source/blender/compositor/nodes/COM_VectorCurveNode.h
source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
source/blender/compositor/nodes/COM_ViewLevelsNode.h
source/blender/compositor/nodes/COM_ViewerNode.cpp
source/blender/compositor/nodes/COM_ViewerNode.h
source/blender/compositor/nodes/COM_ZCombineNode.cpp
source/blender/compositor/nodes/COM_ZCombineNode.h
source/blender/compositor/operations/COM_BlurBaseOperation.cpp
source/blender/compositor/operations/COM_BlurBaseOperation.h
source/blender/compositor/operations/COM_CompositorOperation.cpp
source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
source/blender/compositor/operations/COM_GlareBaseOperation.cpp
source/blender/compositor/operations/COM_GlareBaseOperation.h
source/blender/compositor/operations/COM_MathBaseOperation.cpp
source/blender/compositor/operations/COM_MixOperation.cpp
source/blender/compositor/operations/COM_OutputFileOperation.cpp
source/blender/compositor/operations/COM_OutputFileOperation.h
source/blender/compositor/operations/COM_PreviewOperation.cpp
source/blender/compositor/operations/COM_PreviewOperation.h
source/blender/compositor/operations/COM_ReadBufferOperation.h
source/blender/compositor/operations/COM_SetVectorOperation.h
source/blender/compositor/operations/COM_SocketProxyOperation.cpp
source/blender/compositor/operations/COM_SocketProxyOperation.h
source/blender/compositor/operations/COM_SplitOperation.cpp
source/blender/compositor/operations/COM_TextureOperation.cpp
source/blender/compositor/operations/COM_TextureOperation.h
source/blender/compositor/operations/COM_TonemapOperation.cpp
source/blender/compositor/operations/COM_ViewerOperation.cpp
source/blender/compositor/operations/COM_ViewerOperation.h
source/blender/compositor/operations/COM_WriteBufferOperation.h
source/blender/makesdna/DNA_node_types.h