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-05-17 16:49:33 +0400
committerJeroen Bakker <j.bakker@atmind.nl>2012-05-17 16:49:33 +0400
commit044e818cf89ab8587c8acb7927edd740db3a164d (patch)
tree52611bf4cfd0d8cde1d4d80352987737a4cfa559 /source/blender
parenteb57856a19127f8867974470dfbfb7524740cd70 (diff)
____
`````|````` | | | ..'''' | | | |______ .'' | | | | ..' | | |_______ |___________ ....'' merge to TRUNK! * The old compositor is still available (Debug Menu: 200) This commit was brought to you by: Developers: * Monique Dewanchand * Jeroen Bakker * Dalai Felinto * Lukas Tönne Review: * Brecht van Lommel Testers: * Nate Wiebe * Wolfgang Faehnle * Carlo Andreacchio * Daniel Salazar * Artur Mag * Christian Krupa * Francesco Siddi * Dan McGrath * Bassam Kurdali But mostly by the community: Gold: Joshua Faulkner Michael Tiemann Francesco Paglia Blender Guru Blender Developers Fund Silver: Pablo Vazquez Joel Heethaar Amrein Olivier Ilias Karasavvidis Thomas Kumlehn Sebastian Koenig Hannu Hoffrén Benjamin Dansie Fred M'ule Michel Vilain Bradley Cathey Gianmichele Mariani Gottfried Hofmann Bjørnar Frøyse Valentijn Bruning Paul Holmes Clemens Rudolph Juris Graphix David Strebel Ronan Zeegers François Tarlier Felipe Andres Esquivel Reed Olaf Beckman Jesus Alberto Olmos Linares Kajimba Maria Figueiredo Alexandr Galperin Francesco Siddi Julio Iglesias Lopez Kjartan Tysdal Thomas Torfs Film Works Teruyuki Nakamura Roger Luethi Benoit Bolsee Stefan Abrahamsen Andreas Mattijat Xavier Bouchoux Blender 3D Graphics and Animation Henk Vostermans Daniel Blanco Delgado BlenderDay/2011 Bradley Cathey Matthieu Dupont de Dinechin Gianmichele Mariani Jérôme Scaillet Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó, Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli, Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein, Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio, Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel, Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey, Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter, Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini, Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch, Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson, Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song, Dylan Urquidi )
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/CMakeLists.txt2
-rw-r--r--source/blender/SConscript2
-rw-r--r--source/blender/blenkernel/BKE_node.h13
-rw-r--r--source/blender/blenkernel/intern/node.c7
-rw-r--r--source/blender/blenloader/intern/readfile.c17
-rw-r--r--source/blender/compositor/CMakeLists.txt607
-rw-r--r--source/blender/compositor/COM_compositor.h278
-rw-r--r--source/blender/compositor/COM_defines.h99
-rw-r--r--source/blender/compositor/SConscript14
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp41
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h41
-rw-r--r--source/blender/compositor/intern/COM_ChannelInfo.cpp34
-rw-r--r--source/blender/compositor/intern/COM_ChannelInfo.h121
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp48
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h45
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp38
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.h37
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp47
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h147
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp492
-rw-r--r--source/blender/compositor/intern/COM_Converter.h70
-rw-r--r--source/blender/compositor/intern/COM_Device.cpp24
-rw-r--r--source/blender/compositor/intern/COM_Device.h57
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp566
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h404
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp310
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h229
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp310
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystemHelper.h127
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.cpp217
-rw-r--r--source/blender/compositor/intern/COM_InputSocket.h162
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp338
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h170
-rw-r--r--source/blender/compositor/intern/COM_MemoryManager.cpp68
-rw-r--r--source/blender/compositor/intern/COM_MemoryManager.h146
-rw-r--r--source/blender/compositor/intern/COM_MemoryManagerState.cpp94
-rw-r--r--source/blender/compositor/intern/COM_MemoryManagerState.h87
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.cpp37
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h106
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp182
-rw-r--r--source/blender/compositor/intern/COM_Node.h131
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.cpp128
-rw-r--r--source/blender/compositor/intern/COM_NodeBase.h174
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp114
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h247
-rw-r--r--source/blender/compositor/intern/COM_NodeProgram.cpp0
-rw-r--r--source/blender/compositor/intern/COM_NodeProgram.h7
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp61
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h88
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.cpp146
-rw-r--r--source/blender/compositor/intern/COM_OutputSocket.h105
-rw-r--r--source/blender/compositor/intern/COM_Socket.cpp47
-rw-r--r--source/blender/compositor/intern/COM_Socket.h100
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.cpp86
-rw-r--r--source/blender/compositor/intern/COM_SocketConnection.h123
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.cpp25
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h113
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.cpp28
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h64
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp313
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h127
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp59
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp67
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp41
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp79
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp63
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp37
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cpp41
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp89
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.cpp70
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp68
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.cpp44
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.cpp67
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.cpp51
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.cpp55
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_CombineHSVANode.h38
-rw-r--r--source/blender/compositor/nodes/COM_CombineRGBANode.cpp59
-rw-r--r--source/blender/compositor/nodes/COM_CombineRGBANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_CombineYCCANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.cpp37
-rw-r--r--source/blender/compositor/nodes/COM_CombineYUVANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp46
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h36
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp110
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp52
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp46
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp45
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.h36
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.cpp59
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cpp41
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp81
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp53
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp128
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.cpp69
-rw-r--r--source/blender/compositor/nodes/COM_GroupNode.h57
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp69
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp68
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.cpp48
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp150
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h44
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp57
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp60
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cpp41
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.h36
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp92
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp131
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp118
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.cpp44
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.cpp91
-rw-r--r--source/blender/compositor/nodes/COM_MuteNode.h40
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.cpp56
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h39
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.cpp36
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp89
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h40
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp109
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.cpp60
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp86
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_SeparateHSVANode.cpp42
-rw-r--r--source/blender/compositor/nodes/COM_SeparateHSVANode.h39
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.cpp70
-rw-r--r--source/blender/compositor/nodes/COM_SeparateRGBANode.h37
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYCCANode.cpp44
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYCCANode.h38
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_SeparateYUVANode.h38
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cpp35
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp89
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h46
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp49
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp87
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h34
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp49
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h34
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp55
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cpp77
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h34
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp45
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.cpp40
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp64
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h38
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp54
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h37
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp64
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h38
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp58
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp61
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp59
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp97
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h61
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp115
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp102
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h58
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp159
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp112
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h67
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp110
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h65
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp78
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h56
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp122
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.h69
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp94
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h47
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp50
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp117
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h76
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp97
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp71
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h81
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp76
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h81
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp134
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp95
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h56
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp80
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp53
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp110
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_CombineChannelsOperation.cpp72
-rw-r--r--source/blender/compositor/operations/COM_CombineChannelsOperation.h42
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp122
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h69
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h78
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp43
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToBWOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp41
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp43
-rw-r--r--source/blender/compositor/operations/COM_ConvertColourToValueProg.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp97
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h72
-rw-r--r--source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp46
-rw-r--r--source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp53
-rw-r--r--source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h49
-rw-r--r--source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp60
-rw-r--r--source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp44
-rw-r--r--source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp45
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToColourProg.h53
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp46
-rw-r--r--source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp42
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp43
-rw-r--r--source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h58
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp95
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h34
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp136
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp104
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h63
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp84
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h53
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp145
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.h70
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp115
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp147
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.h63
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp127
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.h63
-rw-r--r--source/blender/compositor/operations/COM_DistanceMatteOperation.cpp86
-rw-r--r--source/blender/compositor/operations/COM_DistanceMatteOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp51
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h41
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp1195
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp114
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h65
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp197
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp68
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_FogGlowImageOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_FogGlowImageOperation.h39
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp98
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h80
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp56
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h54
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp174
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp128
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h49
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp125
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h49
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp75
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h70
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp113
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.h35
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.cpp94
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.h35
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp74
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h53
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp149
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h94
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp70
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_LensGhostOperation.cpp792
-rw-r--r--source/blender/compositor/operations/COM_LensGhostOperation.h82
-rw-r--r--source/blender/compositor/operations/COM_LensGlowImageOperation.cpp51
-rw-r--r--source/blender/compositor/operations/COM_LensGlowImageOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_LensGlowOperation.cpp54
-rw-r--r--source/blender/compositor/operations/COM_LensGlowOperation.h56
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp79
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp153
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h62
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp52
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h66
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp239
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h150
-rw-r--r--source/blender/compositor/operations/COM_MixAddOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MixAddOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixBaseOperation.cpp89
-rw-r--r--source/blender/compositor/operations/COM_MixBaseOperation.h67
-rw-r--r--source/blender/compositor/operations/COM_MixBlendOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MixBlendOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixBurnOperation.cpp84
-rw-r--r--source/blender/compositor/operations/COM_MixBurnOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixColorOperation.cpp59
-rw-r--r--source/blender/compositor/operations/COM_MixColorOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixDarkenOperation.cpp54
-rw-r--r--source/blender/compositor/operations/COM_MixDarkenOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixDifferenceOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MixDifferenceOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixDivideOperation.cpp57
-rw-r--r--source/blender/compositor/operations/COM_MixDivideOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixDodgeOperation.cpp89
-rw-r--r--source/blender/compositor/operations/COM_MixDodgeOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixHueOperation.cpp58
-rw-r--r--source/blender/compositor/operations/COM_MixHueOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixLightenOperation.cpp52
-rw-r--r--source/blender/compositor/operations/COM_MixLightenOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_MixLinearLightOperation.cpp54
-rw-r--r--source/blender/compositor/operations/COM_MixLinearLightOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixMultiplyOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_MixMultiplyOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixOverlayOperation.cpp60
-rw-r--r--source/blender/compositor/operations/COM_MixOverlayOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixSaturationOperation.cpp54
-rw-r--r--source/blender/compositor/operations/COM_MixSaturationOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixScreenOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_MixScreenOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_MixSoftLightOperation.cpp53
-rw-r--r--source/blender/compositor/operations/COM_MixSoftLightOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixSubtractOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_MixSubtractOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_MixValueOperation.cpp52
-rw-r--r--source/blender/compositor/operations/COM_MixValueOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h61
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp94
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp89
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h113
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp96
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp108
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.h69
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl9
-rw-r--r--source/blender/compositor/operations/COM_OpenCLKernels.cl.cpp14
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp260
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h89
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp127
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h56
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp71
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.cpp69
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.h53
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp70
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAOOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp46
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersAlphaProg.h35
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp130
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersBaseProg.h99
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersColorOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersCyclesOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp28
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDepthProg.h34
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEmitOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersImageProg.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersImageProg.h34
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersIndirectOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersMistOperation.h11
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersNormalOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersReflectionOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersRefractionOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersShadowOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpecularOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersSpeedOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp27
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersUVOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp93
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h46
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp196
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h77
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp164
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h74
-rw-r--r--source/blender/compositor/operations/COM_SeparateChannelOperation.cpp43
-rw-r--r--source/blender/compositor/operations/COM_SeparateChannelOperation.h42
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp51
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp39
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp39
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp36
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h54
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp45
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp41
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h39
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.cpp102
-rw-r--r--source/blender/compositor/operations/COM_SplitViewerOperation.h44
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp100
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h81
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp163
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.h103
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h47
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp142
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h62
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp113
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.h73
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp56
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.cpp92
-rw-r--r--source/blender/compositor/operations/COM_ViewerBaseOperation.h71
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp108
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h41
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp161
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp87
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h57
-rw-r--r--source/blender/editors/space_image/image_ops.c2
-rw-r--r--source/blender/editors/space_node/drawnode.c287
-rw-r--r--source/blender/editors/space_node/node_edit.c8
-rw-r--r--source/blender/makesdna/DNA_node_types.h74
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c391
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h7
-rw-r--r--source/blender/nodes/CMakeLists.txt8
-rw-r--r--source/blender/nodes/NOD_composite.h8
-rw-r--r--source/blender/nodes/SConscript1
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c50
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.c60
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehimage.c66
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_boxmask.c75
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorcorrection.c89
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_ellipsemask.c75
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c1
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switch.c58
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.c2
-rw-r--r--source/blender/opencl/CMakeLists.txt39
-rw-r--r--source/blender/opencl/OCL_opencl.h37
-rw-r--r--source/blender/opencl/SConscript8
-rw-r--r--source/blender/opencl/intern/OCL_opencl.c37
-rw-r--r--source/blender/opencl/intern/clew.c311
-rw-r--r--source/blender/opencl/intern/clew.h1317
-rw-r--r--source/blender/render/intern/source/pipeline.c4
539 files changed, 40099 insertions, 31 deletions
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index cb17a87fd76..e0fd33d1316 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -94,11 +94,13 @@ add_subdirectory(blenkernel)
add_subdirectory(blenlib)
add_subdirectory(bmesh)
add_subdirectory(render)
+add_subdirectory(compositor)
add_subdirectory(blenfont)
add_subdirectory(blenloader)
add_subdirectory(blenpluginapi)
add_subdirectory(ikplugin)
add_subdirectory(gpu)
+add_subdirectory(opencl)
add_subdirectory(imbuf)
add_subdirectory(avi)
add_subdirectory(nodes)
diff --git a/source/blender/SConscript b/source/blender/SConscript
index c3a7089f425..411a04528c5 100644
--- a/source/blender/SConscript
+++ b/source/blender/SConscript
@@ -9,9 +9,11 @@ SConscript(['avi/SConscript',
'blenloader/SConscript',
'blenpluginapi/SConscript',
'gpu/SConscript',
+ 'opencl/SConscript',
'editors/SConscript',
'imbuf/SConscript',
'makesdna/SConscript',
+ 'compositor/SConscript',
'render/SConscript',
'nodes/SConscript',
'modifiers/SConscript',
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 68b3e01b9ff..a6018a45821 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -145,9 +145,13 @@ typedef struct bNodeType {
void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
/// Additional parameters in the side panel.
void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
+ /// Additional drawing on backdrop.
+ void (*uibackdropfunc)(struct SpaceNode* snode, struct ImBuf* backdrop, struct bNode* node, int x, int y);
+
/// Draw a node socket. Default draws the input value button.
NodeSocketButtonFunction drawinputfunc;
NodeSocketButtonFunction drawoutputfunc;
+
/// Optional custom label function for the node header.
const char *(*labelfunc)(struct bNode *);
/// Optional custom resize handle polling.
@@ -647,6 +651,13 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
#define CMP_NODE_TONEMAP 302
#define CMP_NODE_LENSDIST 303
+#define CMP_NODE_COLORCORRECTION 312
+#define CMP_NODE_MASK_BOX 313
+#define CMP_NODE_MASK_ELLIPSE 314
+#define CMP_NODE_BOKEHIMAGE 315
+#define CMP_NODE_BOKEHBLUR 316
+#define CMP_NODE_SWITCH 317
+
/* channel toggles */
#define CMP_CHAN_RGB 1
#define CMP_CHAN_A 2
@@ -674,7 +685,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
struct CompBuf;
struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
-void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int do_previews);
+void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews);
void ntreeCompositTagRender(struct Scene *sce);
int ntreeCompositTagAnimated(struct bNodeTree *ntree);
void ntreeCompositTagGenerators(struct bNodeTree *ntree);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index a25cd0d3b38..c6424580a31 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1930,6 +1930,13 @@ static void registerCompositNodes(bNodeTreeType *ttype)
register_node_type_cmp_transform(ttype);
register_node_type_cmp_stabilize2d(ttype);
register_node_type_cmp_moviedistortion(ttype);
+
+ register_node_type_cmp_colorcorrection(ttype);
+ register_node_type_cmp_boxmask(ttype);
+ register_node_type_cmp_ellipsemask(ttype);
+ register_node_type_cmp_bokehimage(ttype);
+ register_node_type_cmp_bokehblur(ttype);
+ register_node_type_cmp_switch(ttype);
}
static void registerShaderNodes(bNodeTreeType *ttype)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f57310dab74..2e023868e45 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7402,6 +7402,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (main->versionfile < 263) {
+ /* Default for old files is to save particle rotations to pointcache */
+ ParticleSettings *part;
+ for (part = main->particle.first; part; part = part->id.next)
+ part->flag |= PART_ROTATIONS;
{
/* Default for old files is to save particle rotations to pointcache */
ParticleSettings *part;
@@ -7419,6 +7423,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
for (ntree = main->nodetree.first; ntree; ntree=ntree->id.next)
do_versions_nodetree_multi_file_output_path_2_64_0(ntree);
}
+
+
+
}
if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 3)) {
@@ -7525,7 +7532,15 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
-
+ {
+ Scene *scene;
+ // composite redesign
+ for (scene=main->scene.first; scene; scene=scene->id.next)
+ if (scene->nodetree)
+ if ( scene->nodetree->chunksize == 0) {
+ scene->nodetree->chunksize = 256;
+ }
+ }
/* don't forget to set version number in blender.c! */
}
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
new file mode 100644
index 00000000000..6c26c481977
--- /dev/null
+++ b/source/blender/compositor/CMakeLists.txt
@@ -0,0 +1,607 @@
+# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2011, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Jeroen Bakker, Monique Dewanchand, Blender Developers Fund.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+ ../blenkernel
+ ../blenlib
+ ../makesdna
+ ../render/extern/include
+ ../render/intern/include
+ ../makesrna
+ ../blenloader
+ ../blenlib
+ ../windowmanager
+ ../imbuf
+ ../../../intern/guardedalloc
+ nodes
+ ../nodes/
+ ../nodes/composite
+ ../nodes/intern
+ intern
+ operations
+ ../opencl
+)
+
+set(SRC
+ COM_compositor.h
+ COM_defines.h
+
+ intern/COM_compositor.cpp
+ intern/COM_ExecutionSystem.cpp
+ intern/COM_ExecutionSystem.h
+ intern/COM_ExecutionSystemHelper.cpp
+ intern/COM_ExecutionSystemHelper.h
+ intern/COM_Converter.cpp
+ intern/COM_Converter.h
+ intern/COM_ExecutionGroup.cpp
+ intern/COM_ExecutionGroup.h
+ intern/COM_Node.cpp
+ intern/COM_Node.h
+ intern/COM_NodeBase.cpp
+ intern/COM_NodeBase.h
+ intern/COM_NodeOperation.cpp
+ intern/COM_NodeOperation.h
+ intern/COM_Socket.cpp
+ intern/COM_Socket.h
+ intern/COM_SocketReader.cpp
+ intern/COM_SocketReader.h
+ intern/COM_InputSocket.cpp
+ intern/COM_InputSocket.h
+ intern/COM_OutputSocket.cpp
+ intern/COM_OutputSocket.h
+ intern/COM_SocketConnection.cpp
+ intern/COM_SocketConnection.h
+ intern/COM_MemoryProxy.cpp
+ intern/COM_MemoryProxy.h
+ intern/COM_MemoryBuffer.cpp
+ intern/COM_MemoryBuffer.h
+ intern/COM_MemoryManager.cpp
+ intern/COM_MemoryManager.h
+ intern/COM_MemoryManagerState.cpp
+ intern/COM_MemoryManagerState.h
+ intern/COM_WorkScheduler.cpp
+ intern/COM_WorkScheduler.h
+ intern/COM_WorkPackage.cpp
+ intern/COM_WorkPackage.h
+ intern/COM_ChunkOrder.cpp
+ intern/COM_ChunkOrder.h
+ intern/COM_ChunkOrderHotspot.cpp
+ intern/COM_ChunkOrderHotspot.h
+ intern/COM_Device.cpp
+ intern/COM_Device.h
+ intern/COM_CPUDevice.cpp
+ intern/COM_CPUDevice.h
+ intern/COM_OpenCLDevice.cpp
+ intern/COM_OpenCLDevice.h
+ intern/COM_CompositorContext.cpp
+ intern/COM_CompositorContext.h
+ intern/COM_ChannelInfo.cpp
+ intern/COM_ChannelInfo.h
+ operations/COM_QualityStepHelper.h
+ operations/COM_QualityStepHelper.cpp
+
+# Internal nodes
+ nodes/COM_MuteNode.cpp
+ nodes/COM_MuteNode.h
+ nodes/COM_GroupNode.cpp
+ nodes/COM_GroupNode.h
+ nodes/COM_SocketProxyNode.cpp
+ nodes/COM_SocketProxyNode.h
+
+# input nodes
+ nodes/COM_RenderLayersNode.cpp
+ nodes/COM_RenderLayersNode.h
+ nodes/COM_ImageNode.cpp
+ nodes/COM_ImageNode.h
+ nodes/COM_TextureNode.cpp
+ nodes/COM_TextureNode.h
+ nodes/COM_BokehImageNode.cpp
+ nodes/COM_BokehImageNode.h
+ nodes/COM_ColorNode.cpp
+ nodes/COM_ColorNode.h
+ nodes/COM_ValueNode.cpp
+ nodes/COM_ValueNode.h
+ nodes/COM_TimeNode.cpp
+ nodes/COM_TimeNode.h
+ nodes/COM_SwitchNode.cpp
+ nodes/COM_SwitchNode.h
+ nodes/COM_MovieClipNode.cpp
+ nodes/COM_MovieClipNode.h
+ nodes/COM_OutputFileNode.cpp
+ nodes/COM_OutputFileNode.h
+
+# output nodes
+ nodes/COM_CompositorNode.cpp
+ nodes/COM_CompositorNode.h
+ nodes/COM_ViewerNode.cpp
+ nodes/COM_ViewerNode.h
+ nodes/COM_SplitViewerNode.cpp
+ nodes/COM_SplitViewerNode.h
+ nodes/COM_ViewLevelsNode.cpp
+ nodes/COM_ViewLevelsNode.h
+ operations/COM_CalculateStandardDeviationOperation.cpp
+ operations/COM_CalculateStandardDeviationOperation.h
+ operations/COM_CalculateMeanOperation.cpp
+ operations/COM_CalculateMeanOperation.h
+
+# distort nodes
+ nodes/COM_TranslateNode.cpp
+ nodes/COM_TranslateNode.h
+ nodes/COM_ScaleNode.cpp
+ nodes/COM_ScaleNode.h
+ nodes/COM_RotateNode.cpp
+ nodes/COM_RotateNode.h
+ nodes/COM_FlipNode.cpp
+ nodes/COM_FlipNode.h
+
+ nodes/COM_MapUVNode.cpp
+ nodes/COM_MapUVNode.h
+ nodes/COM_DisplaceNode.cpp
+ nodes/COM_DisplaceNode.h
+
+ nodes/COM_DifferenceMatteNode.cpp
+ nodes/COM_DifferenceMatteNode.h
+ nodes/COM_LuminanceMatteNode.cpp
+ nodes/COM_LuminanceMatteNode.h
+ nodes/COM_DistanceMatteNode.cpp
+ nodes/COM_DistanceMatteNode.h
+ nodes/COM_ChromaMatteNode.cpp
+ nodes/COM_ChromaMatteNode.h
+ nodes/COM_ColorMatteNode.cpp
+ nodes/COM_ColorMatteNode.h
+ nodes/COM_ChannelMatteNode.cpp
+ nodes/COM_ChannelMatteNode.h
+ nodes/COM_LensDistortionNode.cpp
+ nodes/COM_LensDistortionNode.h
+
+ nodes/COM_GlareNode.cpp
+ nodes/COM_GlareNode.h
+
+ nodes/COM_CropNode.cpp
+ nodes/COM_CropNode.h
+ operations/COM_CropOperation.cpp
+ operations/COM_CropOperation.h
+
+ operations/COM_LensGlowOperation.cpp
+ operations/COM_LensGlowOperation.h
+ operations/COM_LensGhostOperation.cpp
+ operations/COM_LensGhostOperation.h
+ nodes/COM_TransformNode.cpp
+ nodes/COM_TransformNode.h
+ nodes/COM_Stabilize2dNode.cpp
+ nodes/COM_Stabilize2dNode.h
+ nodes/COM_MovieDistortionNode.cpp
+ nodes/COM_MovieDistortionNode.h
+ nodes/COM_DefocusNode.cpp
+ nodes/COM_DefocusNode.h
+
+# color nodes
+ nodes/COM_VectorCurveNode.cpp
+ nodes/COM_VectorCurveNode.h
+ nodes/COM_ColorCurveNode.cpp
+ nodes/COM_ColorCurveNode.h
+ nodes/COM_ColorToBWNode.cpp
+ nodes/COM_ColorToBWNode.h
+ nodes/COM_ColorRampNode.cpp
+ nodes/COM_ColorRampNode.h
+ nodes/COM_MixNode.cpp
+ nodes/COM_MixNode.h
+ nodes/COM_AlphaOverNode.cpp
+ nodes/COM_AlphaOverNode.h
+ nodes/COM_ZCombineNode.cpp
+ nodes/COM_ZCombineNode.h
+ nodes/COM_BrightnessNode.cpp
+ nodes/COM_BrightnessNode.h
+ nodes/COM_ColorBalanceNode.cpp
+ nodes/COM_ColorBalanceNode.h
+ nodes/COM_InvertNode.cpp
+ nodes/COM_InvertNode.h
+ nodes/COM_GammaNode.cpp
+ nodes/COM_GammaNode.h
+ nodes/COM_SetAlphaNode.cpp
+ nodes/COM_SetAlphaNode.h
+ nodes/COM_ConvertAlphaNode.cpp
+ nodes/COM_ConvertAlphaNode.h
+ nodes/COM_AlphaOverNode.cpp
+ nodes/COM_AlphaOverNode.h
+ nodes/COM_HueSaturationValueNode.cpp
+ nodes/COM_HueSaturationValueNode.h
+ nodes/COM_HueSaturationValueCorrectNode.cpp
+ nodes/COM_HueSaturationValueCorrectNode.h
+ nodes/COM_ColorCorrectionNode.cpp
+ nodes/COM_ColorCorrectionNode.h
+ nodes/COM_TonemapNode.cpp
+ nodes/COM_TonemapNode.h
+ operations/COM_TonemapOperation.cpp
+ operations/COM_TonemapOperation.h
+
+# converter nodes
+ nodes/COM_IDMaskNode.cpp
+ nodes/COM_IDMaskNode.h
+ nodes/COM_SeparateRGBANode.cpp
+ nodes/COM_SeparateRGBANode.h
+ nodes/COM_CombineRGBANode.cpp
+ nodes/COM_CombineRGBANode.h
+ nodes/COM_SeparateHSVANode.cpp
+ nodes/COM_SeparateHSVANode.h
+ nodes/COM_CombineHSVANode.cpp
+ nodes/COM_CombineHSVANode.h
+ nodes/COM_SeparateYUVANode.cpp
+ nodes/COM_SeparateYUVANode.h
+ nodes/COM_CombineYUVANode.cpp
+ nodes/COM_CombineYUVANode.h
+ nodes/COM_SeparateYCCANode.cpp
+ nodes/COM_SeparateYCCANode.h
+ nodes/COM_CombineYCCANode.cpp
+ nodes/COM_CombineYCCANode.h
+
+ nodes/COM_NormalNode.cpp
+ nodes/COM_NormalNode.h
+ nodes/COM_NormalizeNode.cpp
+ nodes/COM_NormalizeNode.h
+ nodes/COM_MathNode.cpp
+ nodes/COM_MathNode.h
+ nodes/COM_MapValueNode.cpp
+ nodes/COM_MapValueNode.h
+
+ operations/COM_NormalizeOperation.cpp
+ operations/COM_NormalizeOperation.h
+
+# Filter nodes
+ nodes/COM_BilateralBlurNode.cpp
+ nodes/COM_BilateralBlurNode.h
+ operations/COM_BilateralBlurOperation.cpp
+ operations/COM_BilateralBlurOperation.h
+ nodes/COM_VectorBlurNode.cpp
+ nodes/COM_VectorBlurNode.h
+ operations/COM_VectorBlurOperation.cpp
+ operations/COM_VectorBlurOperation.h
+
+
+
+ nodes/COM_FilterNode.cpp
+ nodes/COM_FilterNode.h
+ nodes/COM_DilateErodeNode.cpp
+ nodes/COM_DilateErodeNode.h
+ nodes/COM_BlurNode.cpp
+ nodes/COM_BlurNode.h
+ nodes/COM_BokehBlurNode.cpp
+ nodes/COM_BokehBlurNode.h
+ nodes/COM_DirectionalBlurNode.cpp
+ nodes/COM_DirectionalBlurNode.h
+ operations/COM_GaussianXBlurOperation.cpp
+ operations/COM_GaussianXBlurOperation.h
+ operations/COM_GaussianYBlurOperation.cpp
+ operations/COM_GaussianYBlurOperation.h
+ operations/COM_GaussianBokehBlurOperation.cpp
+ operations/COM_GaussianBokehBlurOperation.h
+ operations/COM_BokehBlurOperation.cpp
+ operations/COM_BokehBlurOperation.h
+ operations/COM_VariableSizeBokehBlurOperation.cpp
+ operations/COM_VariableSizeBokehBlurOperation.h
+ operations/COM_FastGaussianBlurOperation.cpp
+ operations/COM_FastGaussianBlurOperation.h
+ operations/COM_BlurBaseOperation.cpp
+ operations/COM_BlurBaseOperation.h
+ operations/COM_DirectionalBlurOperation.cpp
+ operations/COM_DirectionalBlurOperation.h
+ operations/COM_MovieClipAttributeOperation.cpp
+ operations/COM_MovieClipAttributeOperation.h
+ operations/COM_MovieDistortionOperation.cpp
+ operations/COM_MovieDistortionOperation.h
+ operations/COM_GammaCorrectOperation.h
+ operations/COM_GammaCorrectOperation.cpp
+
+# Matte nodes
+ nodes/COM_BoxMaskNode.cpp
+ nodes/COM_BoxMaskNode.h
+ nodes/COM_EllipseMaskNode.cpp
+ nodes/COM_EllipseMaskNode.h
+ nodes/COM_ColorSpillNode.cpp
+ nodes/COM_ColorSpillNode.h
+ nodes/COM_DoubleEdgeMaskNode.cpp
+ nodes/COM_DoubleEdgeMaskNode.h
+
+ operations/COM_DoubleEdgeMaskOperation.cpp
+ operations/COM_DoubleEdgeMaskOperation.h
+operations/COM_ColorSpillOperation.cpp
+operations/COM_ColorSpillOperation.h
+ operations/COM_RenderLayersBaseProg.cpp
+ operations/COM_RenderLayersBaseProg.h
+ operations/COM_RenderLayersImageProg.cpp
+ operations/COM_RenderLayersImageProg.h
+ operations/COM_RenderLayersAlphaProg.cpp
+ operations/COM_RenderLayersAlphaProg.h
+ operations/COM_RenderLayersDepthProg.cpp
+ operations/COM_RenderLayersDepthProg.h
+ operations/COM_RenderLayersNormalOperation.cpp
+ operations/COM_RenderLayersNormalOperation.h
+ operations/COM_RenderLayersSpeedOperation.cpp
+ operations/COM_RenderLayersSpeedOperation.h
+ operations/COM_RenderLayersColorOperation.cpp
+ operations/COM_RenderLayersColorOperation.h
+ operations/COM_RenderLayersUVOperation.cpp
+ operations/COM_RenderLayersUVOperation.h
+ operations/COM_RenderLayersMistOperation.cpp
+ operations/COM_RenderLayersMistOperation.h
+ operations/COM_RenderLayersObjectIndexOperation.cpp
+ operations/COM_RenderLayersObjectIndexOperation.h
+ operations/COM_RenderLayersMaterialIndexOperation.cpp
+ operations/COM_RenderLayersMaterialIndexOperation.h
+ operations/COM_RenderLayersDiffuseOperation.cpp
+ operations/COM_RenderLayersDiffuseOperation.h
+ operations/COM_RenderLayersSpecularOperation.cpp
+ operations/COM_RenderLayersSpecularOperation.h
+ operations/COM_RenderLayersShadowOperation.cpp
+ operations/COM_RenderLayersShadowOperation.h
+ operations/COM_RenderLayersAOOperation.cpp
+ operations/COM_RenderLayersAOOperation.h
+ operations/COM_RenderLayersEmitOperation.cpp
+ operations/COM_RenderLayersEmitOperation.h
+ operations/COM_RenderLayersReflectionOperation.cpp
+ operations/COM_RenderLayersReflectionOperation.h
+ operations/COM_RenderLayersRefractionOperation.cpp
+ operations/COM_RenderLayersRefractionOperation.h
+ operations/COM_RenderLayersEnvironmentOperation.cpp
+ operations/COM_RenderLayersEnvironmentOperation.h
+ operations/COM_RenderLayersIndirectOperation.cpp
+ operations/COM_RenderLayersIndirectOperation.h
+ operations/COM_RenderLayersCyclesOperation.cpp
+ operations/COM_RenderLayersCyclesOperation.h
+
+operations/COM_ImageOperation.cpp
+operations/COM_ImageOperation.h
+operations/COM_MultilayerImageOperation.cpp
+operations/COM_MultilayerImageOperation.h
+operations/COM_TextureOperation.cpp
+operations/COM_TextureOperation.h
+operations/COM_BokehImageOperation.cpp
+operations/COM_BokehImageOperation.h
+operations/COM_LensGlowImageOperation.cpp
+operations/COM_LensGlowImageOperation.h
+
+
+ operations/COM_SocketProxyOperation.h
+ operations/COM_SocketProxyOperation.cpp
+
+ operations/COM_CompositorOperation.h
+ operations/COM_CompositorOperation.cpp
+ operations/COM_OutputFileOperation.h
+ operations/COM_OutputFileOperation.cpp
+ operations/COM_ViewerBaseOperation.h
+ operations/COM_ViewerBaseOperation.cpp
+ operations/COM_ViewerOperation.h
+ operations/COM_ViewerOperation.cpp
+ operations/COM_PreviewOperation.h
+ operations/COM_PreviewOperation.cpp
+ operations/COM_SplitViewerOperation.h
+ operations/COM_SplitViewerOperation.cpp
+ operations/COM_ConvertValueToColourProg.h
+ operations/COM_ConvertValueToColourProg.cpp
+ operations/COM_ConvertColourToValueProg.h
+ operations/COM_ConvertColourToValueProg.cpp
+ operations/COM_ConvertColorToBWOperation.h
+ operations/COM_ConvertColorToBWOperation.cpp
+ operations/COM_ConvertColorToVectorOperation.h
+ operations/COM_ConvertColorToVectorOperation.cpp
+ operations/COM_ConvertValueToVectorOperation.h
+ operations/COM_ConvertValueToVectorOperation.cpp
+ operations/COM_ConvertVectorToColorOperation.h
+ operations/COM_ConvertVectorToColorOperation.cpp
+ operations/COM_ConvertVectorToValueOperation.h
+ operations/COM_ConvertVectorToValueOperation.cpp
+operations/COM_ConvertDepthToRadiusOperation.h
+operations/COM_ConvertDepthToRadiusOperation.cpp
+ operations/COM_ZCombineOperation.cpp
+ operations/COM_ZCombineOperation.h
+
+ operations/COM_ConvertRGBToYCCOperation.h
+ operations/COM_ConvertRGBToYCCOperation.cpp
+ operations/COM_ConvertYCCToRGBOperation.h
+ operations/COM_ConvertYCCToRGBOperation.cpp
+ operations/COM_ConvertRGBToYUVOperation.h
+ operations/COM_ConvertRGBToYUVOperation.cpp
+ operations/COM_ConvertYUVToRGBOperation.h
+ operations/COM_ConvertYUVToRGBOperation.cpp
+ operations/COM_ConvertRGBToHSVOperation.h
+ operations/COM_ConvertRGBToHSVOperation.cpp
+ operations/COM_ConvertHSVToRGBOperation.h
+ operations/COM_ConvertHSVToRGBOperation.cpp
+ operations/COM_ChangeHSVOperation.h
+ operations/COM_ChangeHSVOperation.cpp
+ operations/COM_ColorCurveOperation.h
+ operations/COM_ColorCurveOperation.cpp
+ operations/COM_ColorRampOperation.h
+ operations/COM_ColorRampOperation.cpp
+ operations/COM_VectorCurveOperation.h
+ operations/COM_VectorCurveOperation.cpp
+ operations/COM_CurveBaseOperation.h
+ operations/COM_CurveBaseOperation.cpp
+ operations/COM_HueSaturationValueCorrectOperation.cpp
+ operations/COM_HueSaturationValueCorrectOperation.h
+ operations/COM_DifferenceMatteOperation.cpp
+ operations/COM_DifferenceMatteOperation.h
+ operations/COM_LuminanceMatteOperation.cpp
+ operations/COM_LuminanceMatteOperation.h
+ operations/COM_DistanceMatteOperation.cpp
+ operations/COM_DistanceMatteOperation.h
+ operations/COM_ChromaMatteOperation.cpp
+ operations/COM_ChromaMatteOperation.h
+ operations/COM_ColorMatteOperation.cpp
+ operations/COM_ColorMatteOperation.h
+ operations/COM_ChannelMatteOperation.cpp
+ operations/COM_ChannelMatteOperation.h
+ operations/COM_ConvertPremulToKeyOperation.cpp
+ operations/COM_ConvertPremulToKeyOperation.h
+ operations/COM_ConvertKeyToPremulOperation.cpp
+ operations/COM_ConvertKeyToPremulOperation.h
+
+ operations/COM_ReadBufferOperation.cpp
+ operations/COM_ReadBufferOperation.h
+ operations/COM_WriteBufferOperation.cpp
+ operations/COM_WriteBufferOperation.h
+ operations/COM_MixBaseOperation.h
+ operations/COM_MixBaseOperation.cpp
+ operations/COM_MixBlendOperation.cpp
+ operations/COM_MixBlendOperation.h
+ operations/COM_MixAddOperation.h
+ operations/COM_MixAddOperation.cpp
+ operations/COM_MixMultiplyOperation.h
+ operations/COM_MixMultiplyOperation.cpp
+ operations/COM_BrightnessOperation.cpp
+ operations/COM_BrightnessOperation.h
+ operations/COM_GammaOperation.cpp
+ operations/COM_GammaOperation.h
+ operations/COM_ColorCorrectionOperation.cpp
+ operations/COM_ColorCorrectionOperation.h
+ operations/COM_SetValueOperation.h
+ operations/COM_SetValueOperation.cpp
+ operations/COM_SetColorOperation.h
+ operations/COM_SetColorOperation.cpp
+ operations/COM_SetVectorOperation.h
+ operations/COM_SetVectorOperation.cpp
+
+ operations/COM_MixBurnOperation.h
+ operations/COM_MixBurnOperation.cpp
+ operations/COM_MixColorOperation.h
+ operations/COM_MixColorOperation.cpp
+ operations/COM_MixDarkenOperation.h
+ operations/COM_MixDarkenOperation.cpp
+ operations/COM_MixDodgeOperation.h
+ operations/COM_MixDodgeOperation.cpp
+ operations/COM_MixDifferenceOperation.h
+ operations/COM_MixDifferenceOperation.cpp
+ operations/COM_MixDivideOperation.h
+ operations/COM_MixDivideOperation.cpp
+ operations/COM_MixHueOperation.h
+ operations/COM_MixHueOperation.cpp
+ operations/COM_MixLightenOperation.h
+ operations/COM_MixLightenOperation.cpp
+ operations/COM_MixLinearLightOperation.h
+ operations/COM_MixLinearLightOperation.cpp
+ operations/COM_MixOverlayOperation.h
+ operations/COM_MixOverlayOperation.cpp
+ operations/COM_MixSaturationOperation.h
+ operations/COM_MixSaturationOperation.cpp
+ operations/COM_MixScreenOperation.h
+ operations/COM_MixScreenOperation.cpp
+ operations/COM_MixSoftLightOperation.h
+ operations/COM_MixSoftLightOperation.cpp
+ operations/COM_MixValueOperation.h
+ operations/COM_MixValueOperation.cpp
+ operations/COM_MixSubtractOperation.h
+ operations/COM_MixSubtractOperation.cpp
+
+ operations/COM_MathBaseOperation.h
+ operations/COM_MathBaseOperation.cpp
+
+ operations/COM_AlphaOverMixedOperation.h
+ operations/COM_AlphaOverMixedOperation.cpp
+ operations/COM_AlphaOverPremultiplyOperation.h
+ operations/COM_AlphaOverPremultiplyOperation.cpp
+ operations/COM_AlphaOverKeyOperation.h
+ operations/COM_AlphaOverKeyOperation.cpp
+
+ operations/COM_ColorBalanceLGGOperation.h
+ operations/COM_ColorBalanceLGGOperation.cpp
+ operations/COM_ColorBalanceASCCDLOperation.h
+ operations/COM_ColorBalanceASCCDLOperation.cpp
+ operations/COM_InvertOperation.cpp
+ operations/COM_InvertOperation.h
+ operations/COM_SetAlphaOperation.cpp
+ operations/COM_SetAlphaOperation.h
+ operations/COM_MapValueOperation.cpp
+ operations/COM_MapValueOperation.h
+
+# Distort operation
+ operations/COM_TranslateOperation.h
+ operations/COM_TranslateOperation.cpp
+ operations/COM_RotateOperation.h
+ operations/COM_RotateOperation.cpp
+ operations/COM_ScaleOperation.h
+ operations/COM_ScaleOperation.cpp
+ operations/COM_MapUVOperation.h
+ operations/COM_MapUVOperation.cpp
+ operations/COM_DisplaceOperation.h
+ operations/COM_DisplaceOperation.cpp
+ operations/COM_DisplaceSimpleOperation.h
+ operations/COM_DisplaceSimpleOperation.cpp
+ operations/COM_FlipOperation.h
+ operations/COM_FlipOperation.cpp
+ operations/COM_ProjectorLensDistortionOperation.cpp
+ operations/COM_ProjectorLensDistortionOperation.h
+ operations/COM_ScreenLensDistortionOperation.cpp
+ operations/COM_ScreenLensDistortionOperation.h
+
+#Filter operations
+ operations/COM_ConvolutionFilterOperation.h
+ operations/COM_ConvolutionFilterOperation.cpp
+ operations/COM_ConvolutionEdgeFilterOperation.h
+ operations/COM_ConvolutionEdgeFilterOperation.cpp
+ operations/COM_DilateErodeOperation.cpp
+ operations/COM_DilateErodeOperation.h
+ operations/COM_FogGlowImageOperation.cpp
+ operations/COM_FogGlowImageOperation.h
+ operations/COM_GlareThresholdOperation.cpp
+ operations/COM_GlareThresholdOperation.h
+ operations/COM_GlareBaseOperation.cpp
+ operations/COM_GlareBaseOperation.h
+ operations/COM_GlareSimpleStarOperation.cpp
+ operations/COM_GlareSimpleStarOperation.h
+ operations/COM_GlareStreaksOperation.cpp
+ operations/COM_GlareStreaksOperation.h
+ operations/COM_SetSamplerOperation.cpp
+ operations/COM_SetSamplerOperation.h
+
+
+#Convert operations
+ operations/COM_IDMaskOperation.cpp
+ operations/COM_IDMaskOperation.h
+
+ operations/COM_SeparateChannelOperation.cpp
+ operations/COM_SeparateChannelOperation.h
+ operations/COM_CombineChannelsOperation.cpp
+ operations/COM_CombineChannelsOperation.h
+
+ operations/COM_DotproductOperation.cpp
+ operations/COM_DotproductOperation.h
+# Matte operation
+ operations/COM_BoxMaskOperation.h
+ operations/COM_BoxMaskOperation.cpp
+ operations/COM_EllipseMaskOperation.h
+ operations/COM_EllipseMaskOperation.cpp
+
+ operations/COM_MovieClipOperation.cpp
+ operations/COM_MovieClipOperation.h
+ operations/COM_ConvertColorProfileOperation.cpp
+ operations/COM_ConvertColorProfileOperation.h
+
+ operations/COM_AntiAliasOperation.cpp
+ operations/COM_AntiAliasOperation.h
+)
+
+blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
new file mode 100644
index 00000000000..2891d8cdfa0
--- /dev/null
+++ b/source/blender/compositor/COM_compositor.h
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+#include "DNA_node_types.h"
+
+
+/**
+ * @defgroup Model The data model of the compositor
+ * @defgroup Memory The memory management stuff
+ * @defgroup Execution The execution logic
+ * @defgroup Conversion Conversion logic
+ * @defgroup Node All nodes of the compositor
+ * @defgroup Operation All operations of the compositor
+ *
+ * @mainpage Introduction of the Blender Compositor
+ *
+ * @section bcomp Blender compositor
+ * This project redesigns the interals of Blender's compositor. The project has been executed in 2011 by At Mind. At Mind is a technology company located in Amsterdam, The Netherlands.
+ * The project has been crowdfunded. This code has been released under GPL2 to be used in Blender.
+ *
+ * @section goals The goals of the project
+ * the new compositor has 2 goals.
+ * - Make a faster compositor (speed of calculation)
+ * - Make the compositor work faster for you (workflow)
+ *
+ * @section speed Faster compositor
+ * The speedup has been done by making better use of the hardware Blenders is working on. The previous compositor only used a single threaded model to calculate a node. The only exception to this is the Defocus node.
+ * Only when it is possible to calculate two full nodes in parallel a second thread was used. Current workstations have 8-16 threads available, and most of the time these are idle.
+ *
+ * In the new compositor we want to use as much of threads as possible. Even new OpenCL capable GPU-hardware can be used for calculation.
+ *
+ * @section workflow Work faster
+ * The previous compositor only showed the final image. The compositor could wait a long time before seeing the result of his work. The new compositor will work in a way that it will focus on getting information back to the user.
+ * It will prioritise its work to get earlier user feedback.
+ *
+ * @page memory Memory model
+ * The main issue is the type of memory model to use. Blender is used by consumers and professionals. Ranging from low-end machines to very high-end machines. The system should work on high-end machines and on low-end machines.
+ *
+ *
+ * @page executing Executing
+ * @section prepare Prepare execution
+ *
+ * during the preparation of the execution All ReadBufferOperation will receive an offset. this offset is used during execution as an optimization trick
+ * Next all operations will be initialized for execution @see NodeOperation.initExecution
+ * Next all ExecutionGroup's will be initialized for execution @see ExecutionGroup.initExecution
+ * this all is controlled from @see ExecutionSystem.execute
+ *
+ * @section priority Render priority
+ * Render priority is an priority of an output node. A user has a different need of Render priorities of output nodes than during editing.
+ * for example. the Active ViewerNode has top priority during editing, but during rendering a CompositeNode has.
+ * All NodeOperation has a setting for their renderpriority, but only for output NodeOperation these have effect.
+ * In ExecutionSystem.execute all priorities are checked. For every priority the ExecutionGroup's are check if the priority do match.
+ * When match the ExecutionGroup will be executed (this happens in serial)
+ *
+ * @see ExecutionSystem.execute control of the Render priority
+ * @see NodeOperation.getRenderPriority receive the render priority
+ * @see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup
+ *
+ * @section order Chunk order
+ *
+ * When a ExecutionGroup is executed, first the order of chunks are determined.
+ * The settings are stored in the ViewerNode inside the ExecutionGroup. ExecutionGroups that have no viewernode, will use a default one.
+ * There are several possible chunk orders
+ * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]: Start calculating from a configurable point and order by nearest chunk
+ * - [@ref OrderOfChunks.COM_TO_RANDOM]: Randomize all chunks.
+ * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]: Start calculation from the bottom to the top of the image
+ * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]: Experimental order based on 9 hotspots in the image
+ *
+ * When the chunkorder is determined, the first few chunks will be checked if they can be scheduled.
+ * Chunks can have three states:
+ * - [@ref ChunkExecutionState.COM_ES_NOT_SCHEDULED]: Chunk is not yet scheduled, or dependacies are not met
+ * - [@ref ChunkExecutionState.COM_ES_SCHEDULED]: All dependacies are met, chunk is scheduled, but not finished
+ * - [@ref ChunkExecutionState.COM_ES_EXECUTED]: Chunk is finished
+ *
+ * @see ExecutionGroup.execute
+ * @see ViewerBaseOperation.getChunkOrder
+ * @see OrderOfChunks
+ *
+ * @section interest Area of interest
+ * An ExecutionGroup can have dependancies to other ExecutionGroup's. Data passing from one ExecutionGroup to another one are stored in 'chunks'.
+ * If not all input chunks are available the chunk execution will not be scheduled.
+ * <pre>
+ * +-------------------------------------+ +--------------------------------------+
+ * | ExecutionGroup A | | ExecutionGroup B |
+ * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
+ * | | NodeOperation a| | WriteBuffer | | | | ReadBuffer | | ViewerOperation | |
+ * | | *==* Operation | | | | Operation *===* | |
+ * | | | | | | | | | | | |
+ * | +----------------+ +-------------+ | | +------------+ +-----------------+ |
+ * | | | | | |
+ * +--------------------------------|----+ +---|----------------------------------+
+ * | |
+ * | |
+ * +---------------------------+
+ * | MemoryProxy |
+ * | +----------+ +---------+ |
+ * | | Chunk a | | Chunk b | |
+ * | | | | | |
+ * | +----------+ +---------+ |
+ * | |
+ * +---------------------------+
+ * </pre>
+ *
+ * In the above example ExecutionGroup B has an outputoperation (ViewerOperation) and is being executed.
+ * The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible], but not all input chunks are available. The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A) is
+ * Asked to calculate the area ExecutionGroup B is missing. [@ref ExecutionGroup.scheduleAreaWhenPossible]
+ * ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks. If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
+ *
+ * <pre>
+ *
+ * +-------------------------+ +----------------+ +----------------+
+ * | ExecutionSystem.execute | | ExecutionGroup | | ExecutionGroup |
+ * +-------------------------+ | (B) | | (A) |
+ * O +----------------+ +----------------+
+ * O | |
+ * O ExecutionGroup.execute | |
+ * O------------------------------->O |
+ * . O |
+ * . O-------\ |
+ * . . | ExecutionGroup.scheduleChunkWhenPossible
+ * . . O----/ (*) |
+ * . . O |
+ * . . O |
+ * . . O ExecutionGroup.scheduleAreaWhenPossible|
+ * . . O---------------------------------------->O
+ * . . . O----------\ ExecutionGroup.scheduleChunkWhenPossible
+ * . . . . | (*)
+ * . . . . O-------/
+ * . . . . O
+ * . . . . O
+ * . . . . O-------\ ExecutionGroup.scheduleChunk
+ * . . . . . |
+ * . . . . . O----/
+ * . . . . O<=O
+ * . . . O<=O
+ * . . . O
+ * . . O<========================================O
+ * . . O |
+ * . O<=O |
+ * . O |
+ * . O |
+ * </pre>
+ *
+ * This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process.
+ *
+ * NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the [@ref NodeOperation.determineAreaOfInterest] method
+ *
+ * <pre>
+ *
+ * +--------------------------+ +---------------------------------+
+ * | ExecutionGroup A | | ExecutionGroup B |
+ * | | | |
+ * +--------------------------+ +---------------------------------+
+ * Needed chunks from ExecutionGroup A | Chunk of ExecutionGroup B (to be evaluated)
+ * +-------+ +-------+ | +--------+
+ * |Chunk 1| |Chunk 2| +----------------+ |Chunk 1 |
+ * | | | | | ScaleOperation | | |
+ * +-------+ +-------+ +----------------+ +--------+
+ *
+ * +-------+ +-------+
+ * |Chunk 3| |Chunk 4|
+ * | | | |
+ * +-------+ +-------+
+ *
+ * </pre>
+ *
+ * @see ExecutionGroup.execute Execute a complete ExecutionGroup. Halts until finished or breaked by user
+ * @see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk, checks if all input data is available. Can trigger dependant chunks to be calculated
+ * @see ExecutionGroup.scheduleAreaWhenPossible Tries to schedule an area. This can be multiple chunks (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
+ * @see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
+ * @see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
+ * @see WriteBufferOperation NodeOperation to write to a MemoryProxy/MemoryBuffer
+ * @see ReadBufferOperation NodeOperation to read from a MemoryProxy/MemoryBuffer
+ * @see MemoryProxy proxy for information about memory image (a image consist out of multiple chunks)
+ * @see MemoryBuffer Allocated memory for a single chunk
+ *
+ * @section workscheduler WorkScheduler
+ * the WorkScheduler is implemented as a static class. the responsibility of the WorkScheduler is to balance WorkPackages to the available and free devices.
+ * the workscheduler can work in 2 states. For witching these between the state you need to recompile blender
+ *
+ * @subsection multithread Multi threaded
+ * Default the workscheduler will place all work as WorkPackage in a queue.
+ * For every CPUcore a working thread is created. These working threads will ask the WorkScheduler if there is work for a specific Device.
+ * the workscheduler will find work for the device and the device will be asked to execute the WorkPackage
+
+ * @subsection singlethread Single threaded
+ * For debugging reasons the multi-threading can be disabled. This is done by changing the COM_CURRENT_THREADING_MODEL to COM_TM_NOTHREAD. When compiling the workscheduler
+ * will be changes to support no threading and run everything on the CPU.
+ *
+ * @section devices Devices
+ * A Device within the compositor context is a Hardware component that can used to calculate chunks. This chunk is encapseled in a WorkPackage.
+ * the WorkScheduler controls the devices and selects the device where a WorkPackage will be calculated.
+ *
+ * @subsection WS_Devices Workscheduler
+ * The WorkScheduler controls all Devices. When initializing the compositor the WorkScheduler selects all devices that will be used during compositor.
+ * There are two types of Devices, CPUDevice and OpenCLDevice.
+ * When an ExecutionGroup schedules a Chunk the schedule method of the WorkScheduler
+ * The Workscheduler determines if the chunk can be run on an OpenCLDevice (and that there are available OpenCLDevice). If this is the case the chunk will be added to the worklist for OpenCLDevice's
+ * otherwise the chunk will be added to the worklist of CPUDevices.
+ *
+ * A thread will read the work-list and sends a workpackage to its device.
+ *
+ * @see WorkScheduler.schedule method that is called to schedule a chunk
+ * @see Device.execute method called to execute a chunk
+ *
+ * @subsection CPUDevice CPUDevice
+ * When a CPUDevice gets a WorkPackage the Device will get the inputbuffer that is needed to calculate the chunk. Allocation is already done by the ExecutionGroup.
+ * The outputbuffer of the chunk is being created.
+ * The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
+ *
+ * @see ExecutionGroup
+ * @see NodeOperation.executeRegion executes a single chunk of a NodeOperation
+ * @see CPUDevice.execute
+ *
+ * @subsection GPUDevice OpenCLDevice
+ *
+ * To be completed!
+ * @see NodeOperation.executeOpenCLRegion
+ * @see OpenCLDevice.execute
+ *
+ * @section executePixel executing a pixel
+ * Finally the last step, the node functionality :)
+
+ * @page newnode Creating new nodes
+ */
+
+/**
+ * @brief The main method that is used to execute the compositor tree.
+ * It can be executed during editing (blenkernel/node.c) or rendering
+ * (renderer/pipeline.c)
+ *
+ * @param editingtree [struct bNodeTree]
+ * reference to the compositor editing tree
+ *
+ * @param rendering [true false]
+ * This parameter determines whether the function is called from rendering (true) or editing (false).
+ * based on this setting the system will work differently:
+ * - during rendering only Composite & the File output node will be calculated
+ * @see NodeOperation.isOutputProgram(int rendering) of the specific operations
+ *
+ * - during editing all output nodes will be calculated
+ * @see NodeOperation.isOutputProgram(int rendering) of the specific operations
+ *
+ * - another quality setting can be used bNodeTree. The quality is determined by the bNodeTree fields.
+ * quality can be modified by the user from within the node panels.
+ * @see bNodeTree.edit_quality
+ * @see bNodeTree.render_quality
+ *
+ * - output nodes can have different priorities in the WorkScheduler. This is implemented in the COM_execute function.
+ */
+void COM_execute(bNodeTree *editingtree, int rendering);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
new file mode 100644
index 00000000000..df807091cb8
--- /dev/null
+++ b/source/blender/compositor/COM_defines.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_defines_h_
+#define _COM_defines_h_
+
+/**
+ * @brief possible data types for SocketConnection
+ * @ingroup Model
+ */
+typedef enum DataType {
+ /** @brief Unknown data type (or not yet known) */
+ COM_DT_UNKNOWN = 0,
+ /** @brief Value data type */
+ COM_DT_VALUE = 1,
+ /** @brief Vector data type */
+ COM_DT_VECTOR = 2,
+ /** @brief Color data type */
+ COM_DT_COLOR = 4
+} DataType;
+
+/**
+ * @brief Possible quality settings
+ * @see CompositorContext.quality
+ * @ingroup Execution
+ */
+typedef enum CompositorQuality {
+ /** @brief High quality setting */
+ COM_QUALITY_HIGH = 0 ,
+ /** @brief Medium quality setting */
+ COM_QUALITY_MEDIUM = 1,
+ /** @brief Low quality setting */
+ COM_QUALITY_LOW = 2
+} CompositorQuality;
+
+// configurable items
+
+// chunk size determination
+#define COM_PREVIEW_SIZE 140.0f
+#define COM_OPENCL_ENABLED
+#define COM_PREVIEW_ENABLED
+// workscheduler threading models
+/**
+ * COM_TM_QUEUE is a multithreaded model, which uses the BLI_thread_queue pattern. This is the default option.
+ */
+#define COM_TM_QUEUE 1
+
+/**
+ * COM_TM_NOTHREAD is a single threading model, everything is executed in the caller thread. easy for debugging
+ */
+#define COM_TM_NOTHREAD 0
+
+/**
+ * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is currently default.
+ */
+#define COM_CURRENT_THREADING_MODEL COM_TM_QUEUE
+// chunk order
+/**
+ * @brief The order of chunks to be scheduled
+ * @ingroup Execution
+ */
+typedef enum OrderOfChunks {
+ /** @brief order from a distance to centerX/centerY */
+ COM_TO_CENTER_OUT = 0,
+ /** @brief order randomly */
+ COM_TO_RANDOM = 1,
+ /** @brief no ordering */
+ COM_TO_TOP_DOWN = 2,
+ /** @brief experimental ordering with 9 hotspots */
+ COM_TO_RULE_OF_THIRDS = 3
+} OrderOfChunks;
+
+#define COM_RULE_OF_THIRDS_DIVIDER 100.0f
+
+#define COM_NUMBER_OF_CHANNELS 4
+
+#define COM_DEFAULT_RESOLUTION_WIDTH 640
+#define COM_DEFAULT_RESOLUTION_HEIGHT 480
+
+#endif
diff --git a/source/blender/compositor/SConscript b/source/blender/compositor/SConscript
new file mode 100644
index 00000000000..08fe1ea5e19
--- /dev/null
+++ b/source/blender/compositor/SConscript
@@ -0,0 +1,14 @@
+#!/usr/bin/python
+Import ('env')
+defs = ['GLEW_STATIC']
+
+sources = env.Glob('intern/*.cpp') + env.Glob('nodes/*.cpp') + env.Glob('operations/*.cpp')
+
+incs = '. nodes intern operations ../blenlib ../blenkernel ../makesdna ../render/extern/include ../render/intern/include'
+incs += ' ../makesrna ../blenloader ../../../intern/guardedalloc ../imbuf ../windowmanager '
+incs += '../opencl ../nodes ../nodes/intern ../nodes/composite '
+
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
+ incs += ' ' + env['BF_PTHREADS_INC']
+
+env.BlenderLib ( 'bf_composite', sources, Split(incs), defines=defs, libtype=['core','player'], priority = [191,191] )
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
new file mode 100644
index 00000000000..2e74fbf19b3
--- /dev/null
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CPUDevice.h"
+
+void CPUDevice::execute(WorkPackage *work) {
+ const unsigned int chunkNumber = work->getChunkNumber();
+ ExecutionGroup * executionGroup = work->getExecutionGroup();
+ rcti rect;
+
+ executionGroup->determineChunkRect(&rect, chunkNumber);
+ MemoryBuffer ** inputBuffers = executionGroup->getInputBuffers(chunkNumber);
+ MemoryBuffer * outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
+
+ executionGroup->getOutputNodeOperation()->executeRegion(&rect, chunkNumber, inputBuffers);
+
+ executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
+ if (outputBuffer != NULL) {
+ outputBuffer->setCreatedState();
+ }
+}
+
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
new file mode 100644
index 00000000000..f577e2b8926
--- /dev/null
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CPUDevice_h
+#define _COM_CPUDevice_h
+
+#include "COM_Device.h"
+
+/**
+ * @brief class representing a CPU device.
+ * @note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
+ */
+class CPUDevice: public Device {
+public:
+ /**
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
+ void execute(WorkPackage *work);
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_ChannelInfo.cpp b/source/blender/compositor/intern/COM_ChannelInfo.cpp
new file mode 100644
index 00000000000..e945babe9c3
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChannelInfo.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ChannelInfo.h"
+#include "COM_defines.h"
+#include <stdio.h>
+
+/**
+ * @brief create new ChannelInfo instance and sets the defaults.
+ */
+ChannelInfo::ChannelInfo() {
+ this->number = 0;
+ this->premultiplied = true;
+ this->type = COM_CT_UNUSED;
+}
diff --git a/source/blender/compositor/intern/COM_ChannelInfo.h b/source/blender/compositor/intern/COM_ChannelInfo.h
new file mode 100644
index 00000000000..40933bce6f5
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChannelInfo.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ChannelInfo_h
+#define _COM_ChannelInfo_h
+
+#include <vector>
+#include "BKE_text.h"
+#include <string>
+#include "DNA_node_types.h"
+#include "BLI_rect.h"
+
+using namespace std;
+
+/**
+ * @brief List of possible channel types
+ * @ingroup Model
+ */
+typedef enum ChannelType {
+ COM_CT_ColorComponent /** @brief this channel is contains color information. Specific used is determined by channelnumber, and in the future color space */,
+ COM_CT_Alpha /** @brief this channel is contains transparency value */,
+ COM_CT_Value /** @brief this channel is contains a value */,
+ COM_CT_X /** @brief this channel is contains a X value */,
+ COM_CT_Y /** @brief this channel is contains a Y value */,
+ COM_CT_Z /** @brief this channel is contains a Z value */,
+ COM_CT_W /** @brief this channel is contains a W value */,
+ COM_CT_UNUSED /** @brief this channel is unused */
+} ChannelType;
+
+/**
+ * @brief ChannelInfo holds information about a channel.
+ *
+ * Channels are transported from node to node via a SocketConnection.
+ * ChannelInfo holds specific setting of these channels in order that the to-node of the connection
+ * Can handle specific logic per channel setting.
+ *
+ * @note currently this is not used, but a future place to implement color spacing and other things.
+ * @ingroup Model
+ */
+class ChannelInfo {
+private:
+ /**
+ * @brief the channel number, in the connection. [0-3]
+ */
+ int number;
+
+ /**
+ * @brief type of channel
+ */
+ ChannelType type;
+
+ /**
+ * @brieg Is this value in this channel premultiplied with its alpha
+ * @note only valid if type = ColorComponent;
+ */
+ bool premultiplied;
+
+// /**
+// * Color space of this value.
+// * only valid when type = ColorComponent;
+// */
+// string colorspacename;
+
+public:
+ /**
+ * @brief creates a new ChannelInfo and set default values
+ */
+ ChannelInfo();
+
+ /**
+ * @brief set the index of this channel in the SocketConnection
+ */
+ void setNumber(const int number) { this->number = number; }
+
+ /**
+ * @brief get the index of this channel in the SocketConnection
+ */
+ const int getNumber() const {return this->number; }
+
+ /**
+ * @brief set the type of channel
+ */
+ void setType(const ChannelType type) { this->type = type; }
+
+ /**
+ * @brief get the type of channel
+ */
+ const ChannelType getType() const {return this->type; }
+
+ /**
+ * @brief set the premultiplicatioin of this channel
+ */
+ void setPremultiplied(const bool premultiplied) { this->premultiplied = premultiplied; }
+
+ /**
+ * @brief is this channel premultiplied
+ */
+ const bool isPremultiplied() const {return this->premultiplied;}
+};
+
+
+#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
new file mode 100644
index 00000000000..784b848a2f9
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ChunkOrder.h"
+#include "BLI_math.h"
+
+ChunkOrder::ChunkOrder() {
+ this->distance = 0.0;
+ this->number = 0;
+ this->x = 0;
+ this->y = 0;
+}
+
+void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots) {
+ unsigned int index;
+ double distance = MAXFLOAT;
+ for (index = 0 ; index < numberOfHotspots ; index ++) {
+ ChunkOrderHotspot* hotspot = hotspots[index];
+ double ndistance = hotspot->determineDistance(this->x, this->y);
+ if (ndistance < distance) {
+ distance = ndistance;
+ }
+ }
+ this->distance = distance;
+}
+
+bool operator<(const ChunkOrder& a, const ChunkOrder& b) {
+ return a.distance < b.distance;
+}
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
new file mode 100644
index 00000000000..3dbb4ae8080
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ChunkOrder_h_
+#define _COM_ChunkOrder_h_
+
+#include "COM_ChunkOrderHotspot.h"
+class ChunkOrder {
+private:
+ unsigned int number;
+ int x;
+ int y;
+ double distance;
+public:
+ ChunkOrder();
+ void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
+ friend bool operator<(const ChunkOrder& a, const ChunkOrder& b);
+
+ void setChunkNumber(unsigned int chunknumber) {this->number = chunknumber;}
+ void setX(int x) {this->x = x;}
+ void setY(int y) {this->y = y;}
+ unsigned int getChunkNumber() {return this->number;}
+ double getDistance() {return this->distance;}
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
new file mode 100644
index 00000000000..11079878b4f
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ChunkOrderHotspot.h"
+#include <math.h>
+
+ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition) {
+ this->x = x;
+ this->y = y;
+ this->addition = addition;
+}
+
+double ChunkOrderHotspot::determineDistance(int x, int y) {
+ int dx = x-this->x;
+ int dy = y-this->y;
+ double result = sqrt((double)(dx*dx+dy*dy));
+ result += this->addition;
+ return result;
+}
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
new file mode 100644
index 00000000000..ceb5934a7df
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ChunkOrderHotSpot_h_
+#define _COM_ChunkOrderHotSpot_h_
+
+class ChunkOrderHotspot {
+private:
+ int x;
+ int y;
+ float addition;
+
+public:
+ ChunkOrderHotspot(int x, int y, float addition);
+ double determineDistance(int x, int y);
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
new file mode 100644
index 00000000000..dbb05d4f493
--- /dev/null
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CompositorContext.h"
+#include "COM_defines.h"
+#include <stdio.h>
+
+CompositorContext::CompositorContext() {
+ this->scene = NULL;
+ this->quality = COM_QUALITY_HIGH;
+ this->hasActiveOpenCLDevices = false;
+}
+
+const int CompositorContext::getFramenumber() const {
+ if (this->scene) {
+ return this->scene->r.cfra;
+ } else {
+ return -1; /* this should never happen */
+ }
+}
+
+const int CompositorContext::isColorManaged() const {
+ if (this->scene) {
+ return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
+ } else {
+ return 0; /* this should never happen */
+ }
+}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
new file mode 100644
index 00000000000..dc5b248f777
--- /dev/null
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CompositorContext_h
+#define _COM_CompositorContext_h
+
+#include <vector>
+#include "BKE_text.h"
+#include <string>
+#include "DNA_node_types.h"
+#include "BLI_rect.h"
+#include "DNA_scene_types.h"
+#include "COM_defines.h"
+
+/**
+ * @brief Overall context of the compositor
+ */
+class CompositorContext {
+private:
+ /**
+ * @brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
+ bool rendering;
+
+ /**
+ * @brief The quality of the composite.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
+ CompositorQuality quality;
+
+ /**
+ * @brief Reference to the scene that is being composited.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
+ Scene* scene;
+
+ /**
+ * @brief reference to the bNodeTree
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * @see ExecutionSystem
+ */
+ bNodeTree* bnodetree;
+
+ /**
+ * @brief does this system have active opencl devices?
+ */
+ bool hasActiveOpenCLDevices;
+
+public:
+ /**
+ * @brief constructor initializes the context with default values.
+ */
+ CompositorContext();
+
+ /**
+ * @brief set the rendering field of the context
+ */
+ void setRendering(bool rendering) { this->rendering = rendering; }
+
+ /**
+ * @brief get the rendering field of the context
+ */
+ bool isRendering() const {return this->rendering;}
+
+ /**
+ * @brief set the scene of the context
+ */
+ void setScene(Scene* scene) {this->scene = scene;}
+
+ /**
+ * @brief set the bnodetree of the context
+ */
+ void setbNodeTree(bNodeTree* bnodetree) {this->bnodetree = bnodetree;}
+
+ /**
+ * @brief get the bnodetree of the context
+ */
+ const bNodeTree * getbNodeTree() const {return this->bnodetree;}
+
+ /**
+ * @brief get the scene of the context
+ */
+ const Scene* getScene() const {return this->scene;}
+
+ /**
+ * @brief set the quality
+ */
+ void setQuality(CompositorQuality quality) {
+ this->quality = quality;
+ }
+
+ /**
+ * @brief get the quality
+ */
+ const CompositorQuality getQuality() const {
+ return quality;
+ }
+
+ /**
+ * @brief get the current framenumber of the scene in this context
+ */
+ const int getFramenumber() const;
+
+ /**
+ * @brief has this system active openclDevices?
+ */
+ const bool getHasActiveOpenCLDevices() const {
+ return this->hasActiveOpenCLDevices;
+ }
+
+ /**
+ * @brief set has this system active openclDevices?
+ */
+ void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) {
+ this->hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
+ }
+
+ int getChunksize() {return this->getbNodeTree()->chunksize;}
+
+ const int isColorManaged() const;
+};
+
+
+#endif
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
new file mode 100644
index 00000000000..56b1da97df8
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -0,0 +1,492 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Converter.h"
+#include "BKE_node.h"
+#include "COM_CompositorNode.h"
+#include "COM_RenderLayersNode.h"
+#include "COM_ColorToBWNode.h"
+#include "string.h"
+#include "COM_SocketConnection.h"
+#include "COM_ConvertColourToValueProg.h"
+#include "COM_ConvertValueToColourProg.h"
+#include "COM_ConvertColorToVectorOperation.h"
+#include "COM_ConvertValueToVectorOperation.h"
+#include "COM_ConvertVectorToColorOperation.h"
+#include "COM_ConvertVectorToValueOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_MixNode.h"
+#include "COM_MuteNode.h"
+#include "COM_TranslateNode.h"
+#include "COM_RotateNode.h"
+#include "COM_ScaleNode.h"
+#include "COM_FlipNode.h"
+#include "COM_IDMaskNode.h"
+#include "COM_FilterNode.h"
+#include "COM_BrightnessNode.h"
+#include "COM_SeparateRGBANode.h"
+#include "COM_CombineRGBANode.h"
+#include "COM_SeparateHSVANode.h"
+#include "COM_CombineHSVANode.h"
+#include "COM_SeparateYUVANode.h"
+#include "COM_CombineYUVANode.h"
+#include "COM_SeparateYCCANode.h"
+#include "COM_CombineYCCANode.h"
+#include "COM_AlphaOverNode.h"
+#include "COM_ColorBalanceNode.h"
+#include "COM_ViewerNode.h"
+#include "COM_SplitViewerNode.h"
+#include "COM_InvertNode.h"
+#include "COM_GroupNode.h"
+#include "COM_NormalNode.h"
+#include "COM_NormalizeNode.h"
+#include "COM_ImageNode.h"
+#include "COM_BokehImageNode.h"
+#include "COM_ColorCurveNode.h"
+#include "COM_VectorCurveNode.h"
+#include "COM_SetAlphaNode.h"
+#include "COM_ConvertAlphaNode.h"
+#include "COM_MapUVNode.h"
+#include "COM_DisplaceNode.h"
+#include "COM_MathNode.h"
+#include "COM_HueSaturationValueNode.h"
+#include "COM_HueSaturationValueCorrectNode.h"
+#include "COM_ColorCorrectionNode.h"
+#include "COM_BoxMaskNode.h"
+#include "COM_EllipseMaskNode.h"
+#include "COM_GammaNode.h"
+#include "COM_ColorRampNode.h"
+#include "COM_DifferenceMatteNode.h"
+#include "COM_LuminanceMatteNode.h"
+#include "COM_DistanceMatteNode.h"
+#include "COM_ChromaMatteNode.h"
+#include "COM_ColorMatteNode.h"
+#include "COM_ChannelMatteNode.h"
+#include "COM_BlurNode.h"
+#include "COM_BokehBlurNode.h"
+#include "COM_DilateErodeNode.h"
+#include "COM_TranslateOperation.h"
+#include "COM_LensDistortionNode.h"
+#include "COM_TextureNode.h"
+#include "COM_ColorNode.h"
+#include "COM_ValueNode.h"
+#include "COM_TimeNode.h"
+#include "COM_DirectionalBlurNode.h"
+#include "COM_ZCombineNode.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ScaleOperation.h"
+#include "COM_ExecutionSystemHelper.h"
+#include "COM_TonemapNode.h"
+#include "COM_SwitchNode.h"
+#include "COM_GlareNode.h"
+#include "COM_MovieClipNode.h"
+#include "COM_ColorSpillNode.h"
+#include "COM_OutputFileNode.h"
+#include "COM_MapValueNode.h"
+#include "COM_TransformNode.h"
+#include "COM_Stabilize2dNode.h"
+#include "COM_BilateralBlurNode.h"
+#include "COM_VectorBlurNode.h"
+#include "COM_MovieDistortionNode.h"
+#include "COM_ViewLevelsNode.h"
+#include "COM_DefocusNode.h"
+#include "COM_DoubleEdgeMaskNode.h"
+#include "COM_CropNode.h"
+
+Node* Converter::convert(bNode *bNode) {
+ Node * node;
+
+ if (bNode->flag & NODE_MUTED) {
+ node = new MuteNode(bNode);
+ return node;
+ }
+
+ switch (bNode->type) {
+ case CMP_NODE_COMPOSITE:
+ node = new CompositorNode(bNode);
+ break;
+ case CMP_NODE_R_LAYERS:
+ node = new RenderLayersNode(bNode);
+ break;
+ case CMP_NODE_TEXTURE:
+ node = new TextureNode(bNode);
+ break;
+ case CMP_NODE_RGBTOBW:
+ node = new ColourToBWNode(bNode);
+ break;
+ case CMP_NODE_MIX_RGB:
+ node = new MixNode(bNode);
+ break;
+ case CMP_NODE_TRANSLATE:
+ node = new TranslateNode(bNode);
+ break;
+ case CMP_NODE_SCALE:
+ node = new ScaleNode(bNode);
+ break;
+ case CMP_NODE_ROTATE:
+ node = new RotateNode(bNode);
+ break;
+ case CMP_NODE_FLIP:
+ node = new FlipNode(bNode);
+ break;
+ case CMP_NODE_FILTER:
+ node = new FilterNode(bNode);
+ break;
+ case CMP_NODE_ID_MASK:
+ node = new IDMaskNode(bNode);
+ break;
+ case CMP_NODE_BRIGHTCONTRAST:
+ node = new BrightnessNode(bNode);
+ break;
+ case CMP_NODE_SEPRGBA:
+ node = new SeparateRGBANode(bNode);
+ break;
+ case CMP_NODE_COMBRGBA:
+ node = new CombineRGBANode(bNode);
+ break;
+ case CMP_NODE_SEPHSVA:
+ node = new SeparateHSVANode(bNode);
+ break;
+ case CMP_NODE_COMBHSVA:
+ node = new CombineHSVANode(bNode);
+ break;
+ case CMP_NODE_SEPYUVA:
+ node = new SeparateYUVANode(bNode);
+ break;
+ case CMP_NODE_COMBYUVA:
+ node = new CombineYUVANode(bNode);
+ break;
+ case CMP_NODE_SEPYCCA:
+ node = new SeparateYCCANode(bNode);
+ break;
+ case CMP_NODE_COMBYCCA:
+ node = new CombineYCCANode(bNode);
+ break;
+ case CMP_NODE_ALPHAOVER:
+ node = new AlphaOverNode(bNode);
+ break;
+ case CMP_NODE_COLORBALANCE:
+ node = new ColorBalanceNode(bNode);
+ break;
+ case CMP_NODE_VIEWER:
+ node = new ViewerNode(bNode);
+ break;
+ case CMP_NODE_SPLITVIEWER:
+ node = new SplitViewerNode(bNode);
+ break;
+ case CMP_NODE_INVERT:
+ node = new InvertNode(bNode);
+ break;
+ case NODE_GROUP:
+ node = new GroupNode(bNode);
+ break;
+ case CMP_NODE_NORMAL:
+ node = new NormalNode(bNode);
+ break;
+ case CMP_NODE_NORMALIZE:
+ node = new NormalizeNode(bNode);
+ break;
+ case CMP_NODE_IMAGE:
+ node = new ImageNode(bNode);
+ break;
+ case CMP_NODE_SETALPHA:
+ node = new SetAlphaNode(bNode);
+ break;
+ case CMP_NODE_PREMULKEY:
+ node = new ConvertAlphaNode(bNode);
+ break;
+ case CMP_NODE_MATH:
+ node = new MathNode(bNode);
+ break;
+ case CMP_NODE_HUE_SAT:
+ node = new HueSaturationValueNode(bNode);
+ break;
+ case CMP_NODE_COLORCORRECTION:
+ node = new ColorCorrectionNode(bNode);
+ break;
+ case CMP_NODE_MASK_BOX:
+ node = new BoxMaskNode(bNode);
+ break;
+ case CMP_NODE_MASK_ELLIPSE:
+ node = new EllipseMaskNode(bNode);
+ break;
+ case CMP_NODE_GAMMA:
+ node = new GammaNode(bNode);
+ break;
+ case CMP_NODE_CURVE_RGB:
+ node = new ColorCurveNode(bNode);
+ break;
+ case CMP_NODE_CURVE_VEC:
+ node = new VectorCurveNode(bNode);
+ break;
+ case CMP_NODE_HUECORRECT:
+ node = new HueSaturationValueCorrectNode(bNode);
+ break;
+ case CMP_NODE_MAP_UV:
+ node = new MapUVNode(bNode);
+ break;
+ case CMP_NODE_DISPLACE:
+ node = new DisplaceNode(bNode);
+ break;
+ case CMP_NODE_VALTORGB:
+ node = new ColorRampNode(bNode);
+ break;
+ case CMP_NODE_DIFF_MATTE:
+ node = new DifferenceMatteNode(bNode);
+ break;
+ case CMP_NODE_LUMA_MATTE:
+ node = new LuminanceMatteNode(bNode);
+ break;
+ case CMP_NODE_DIST_MATTE:
+ node = new DistanceMatteNode(bNode);
+ break;
+ case CMP_NODE_CHROMA_MATTE:
+ node = new ChromaMatteNode(bNode);
+ break;
+ case CMP_NODE_COLOR_MATTE:
+ node = new ColorMatteNode(bNode);
+ break;
+ case CMP_NODE_CHANNEL_MATTE:
+ node = new ChannelMatteNode(bNode);
+ break;
+ case CMP_NODE_BLUR:
+ node = new BlurNode(bNode);
+ break;
+ case CMP_NODE_BOKEHIMAGE:
+ node = new BokehImageNode(bNode);
+ break;
+ case CMP_NODE_BOKEHBLUR:
+ node = new BokehBlurNode(bNode);
+ break;
+ case CMP_NODE_DILATEERODE:
+ node = new DilateErodeNode(bNode);
+ break;
+ case CMP_NODE_LENSDIST:
+ node = new LensDistortionNode(bNode);
+ break;
+ case CMP_NODE_RGB:
+ node = new ColorNode(bNode);
+ break;
+ case CMP_NODE_VALUE:
+ node = new ValueNode(bNode);
+ break;
+ case CMP_NODE_TIME:
+ node = new TimeNode(bNode);
+ break;
+ case CMP_NODE_DBLUR:
+ node = new DirectionalBlurNode(bNode);
+ break;
+ case CMP_NODE_ZCOMBINE:
+ node = new ZCombineNode(bNode);
+ break;
+ case CMP_NODE_TONEMAP:
+ node = new TonemapNode(bNode);
+ break;
+ case CMP_NODE_SWITCH:
+ node = new SwitchNode(bNode);
+ break;
+ case CMP_NODE_GLARE:
+ node = new GlareNode(bNode);
+ break;
+ case CMP_NODE_MOVIECLIP:
+ node = new MovieClipNode(bNode);
+ break;
+ case CMP_NODE_COLOR_SPILL:
+ node = new ColorSpillNode(bNode);
+ break;
+case CMP_NODE_OUTPUT_FILE:
+ node = new OutputFileNode(bNode);
+ break;
+ case CMP_NODE_MAP_VALUE:
+ node = new MapValueNode(bNode);
+ break;
+ case CMP_NODE_TRANSFORM:
+ node = new TransformNode(bNode);
+ break;
+ case CMP_NODE_STABILIZE2D:
+ node = new Stabilize2dNode(bNode);
+ break;
+ case CMP_NODE_BILATERALBLUR:
+ node = new BilateralBlurNode(bNode);
+ break;
+ case CMP_NODE_VECBLUR:
+ node = new VectorBlurNode(bNode);
+ break;
+ case CMP_NODE_MOVIEDISTORTION:
+ node = new MovieDistortionNode(bNode);
+ break;
+ case CMP_NODE_VIEW_LEVELS:
+ node = new ViewLevelsNode(bNode);
+ break;
+ case CMP_NODE_DEFOCUS:
+ node = new DefocusNode(bNode);
+ break;
+ case CMP_NODE_DOUBLEEDGEMASK:
+ node = new DoubleEdgeMaskNode(bNode);
+ break;
+ case CMP_NODE_CROP:
+ node = new CropNode(bNode);
+ break;
+ /* not inplemented yet */
+ default:
+ node = new MuteNode(bNode);
+ break;
+ }
+ return node;
+}
+void Converter::convertDataType(SocketConnection* connection, ExecutionSystem *system) {
+ OutputSocket* outputSocket = connection->getFromSocket();
+ InputSocket* inputSocket = connection->getToSocket();
+ DataType fromDatatype = outputSocket->getActualDataType();
+ DataType toDatatype = inputSocket->getActualDataType();
+ NodeOperation * converter = NULL;
+ if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
+ converter = new ConvertValueToColourProg();
+ } else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
+ converter = new ConvertValueToVectorOperation();
+ } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
+ converter = new ConvertColourToValueProg();
+ } else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
+ converter = new ConvertColorToVectorOperation();
+ } else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
+ converter = new ConvertVectorToValueOperation();
+ } else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
+ converter = new ConvertVectorToColorOperation();
+ }
+ if (converter != NULL) {
+ inputSocket->relinkConnections(converter->getInputSocket(0));
+ ExecutionSystemHelper::addLink(system->getConnections(), converter->getOutputSocket(), inputSocket);
+ system->addOperation(converter);
+ }
+}
+
+void Converter::convertResolution(SocketConnection *connection, ExecutionSystem *system) {
+ InputSocketResizeMode mode = connection->getToSocket()->getResizeMode();
+
+ NodeOperation * toOperation = (NodeOperation*)connection->getToNode();
+ const float toWidth = toOperation->getWidth();
+ const float toHeight = toOperation->getHeight();
+ NodeOperation * fromOperation = (NodeOperation*)connection->getFromNode();
+ const float fromWidth = fromOperation->getWidth();
+ const float fromHeight = fromOperation->getHeight();
+ bool doCenter = false;
+ bool doScale = false;
+ float addX= (toWidth-fromWidth)/2.0f;
+ float addY = (toHeight-fromHeight)/2.0f;
+ float scaleX=0;
+ float scaleY=0;
+
+ switch (mode) {
+ case COM_SC_NO_RESIZE:
+ break;
+ case COM_SC_CENTER:
+ doCenter = true;
+ break;
+ case COM_SC_FIT_WIDTH:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toWidth/fromWidth;
+ break;
+ case COM_SC_FIT_HEIGHT:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toHeight/fromHeight;
+ break;
+ case COM_SC_FIT:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth/fromWidth;
+ scaleY = toHeight/fromHeight;
+ if (scaleX < scaleY) {
+ scaleX = scaleY;
+ } else {
+ scaleY = scaleX;
+ }
+ break;
+ case COM_SC_STRETCH:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth/fromWidth;
+ scaleY = toHeight/fromHeight;
+ break;
+
+ }
+
+ if (doCenter) {
+ NodeOperation *first = NULL;
+ SocketConnection *c;
+ ScaleOperation * scaleOperation = NULL;
+ if(doScale) {
+ scaleOperation = new ScaleOperation();
+ first = scaleOperation;
+ SetValueOperation * sxop = new SetValueOperation();
+ sxop->setValue(scaleX);
+ c = ExecutionSystemHelper::addLink(system->getConnections(), sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
+ c->setIgnoreResizeCheck(true);
+ SetValueOperation * syop = new SetValueOperation();
+ syop->setValue(scaleY);
+ c = ExecutionSystemHelper::addLink(system->getConnections(), syop->getOutputSocket(), scaleOperation->getInputSocket(2));
+ c->setIgnoreResizeCheck(true);
+ system->addOperation(sxop);
+ system->addOperation(syop);
+
+ unsigned int resolution[2] = {fromWidth, fromHeight};
+ scaleOperation->setResolution(resolution);
+ sxop->setResolution(resolution);
+ syop->setResolution(resolution);
+ system->addOperation(scaleOperation);
+
+ c->setIgnoreResizeCheck(true);
+ }
+
+ TranslateOperation * translateOperation = new TranslateOperation();
+ if (!first) first = translateOperation;
+ SetValueOperation * xop = new SetValueOperation();
+ xop->setValue(addX);
+ c = ExecutionSystemHelper::addLink(system->getConnections(), xop->getOutputSocket(), translateOperation->getInputSocket(1));
+ c->setIgnoreResizeCheck(true);
+ SetValueOperation * yop = new SetValueOperation();
+ yop->setValue(addY);
+ c = ExecutionSystemHelper::addLink(system->getConnections(), yop->getOutputSocket(), translateOperation->getInputSocket(2));
+ c->setIgnoreResizeCheck(true);
+ system->addOperation(xop);
+ system->addOperation(yop);
+
+ unsigned int resolution[2] = {toWidth, toHeight};
+ translateOperation->setResolution(resolution);
+ xop->setResolution(resolution);
+ yop->setResolution(resolution);
+ system->addOperation(translateOperation);
+
+ if (doScale) {
+ c = ExecutionSystemHelper::addLink(system->getConnections(), scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ c->setIgnoreResizeCheck(true);
+ }
+
+ InputSocket * inputSocket = connection->getToSocket();
+ inputSocket->relinkConnections(first->getInputSocket(0));
+ c = ExecutionSystemHelper::addLink(system->getConnections(), translateOperation->getOutputSocket(), inputSocket);
+ c->setIgnoreResizeCheck(true);
+ }
+
+ connection->setIgnoreResizeCheck(true);
+}
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
new file mode 100644
index 00000000000..f5144d1bfed
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_Converter_h
+#define _COM_Converter_h
+
+#include "DNA_node_types.h"
+#include "COM_Node.h"
+
+/**
+ * @brief Conversion methods for the compositor
+ */
+class Converter {
+public:
+ /**
+ * @brief Convert/wraps a bNode in its Node instance.
+ *
+ * For all nodetypes a wrapper class is created.
+ * Muted nodes are wrapped with MuteNode.
+ *
+ * @note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
+ *
+ * @see Node
+ * @see MuteNode
+ */
+ static Node* convert(bNode* bNode);
+
+ /**
+ * @brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
+ *
+ * @note this method is called when conversion is needed.
+ *
+ * @param connection the SocketConnection what needs conversion
+ * @param system the ExecutionSystem to add the conversion to.
+ * @see SocketConnection - a link between two sockets
+ */
+ static void convertDataType(SocketConnection* connection, ExecutionSystem *system);
+
+ /**
+ * @brief This method will add a resolution rule based on the settings of the InputSocket.
+ *
+ * @note Conversion logic is implemented in this method
+ * @see InputSocketResizeMode for the possible conversions.
+
+ * @param connection the SocketConnection what needs conversion
+ * @param system the ExecutionSystem to add the conversion to.
+ * @see SocketConnection - a link between two sockets
+ */
+ static void convertResolution(SocketConnection* connection, ExecutionSystem *system);
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_Device.cpp b/source/blender/compositor/intern/COM_Device.cpp
new file mode 100644
index 00000000000..64172cdd472
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Device.cpp
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Device.h"
+
diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h
new file mode 100644
index 00000000000..74a9400f8f3
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Device.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_Device_h
+#define _COM_Device_h
+
+#include "COM_ExecutionSystem.h"
+#include "COM_WorkPackage.h"
+#include "COM_NodeOperation.h"
+#include "BLI_rect.h"
+#include "COM_MemoryBuffer.h"
+
+/**
+ * @brief Abstract class for device implementations to be used by the Compositor.
+ * devices are queried, initialized and used by the WorkScheduler.
+ * work are packaged as a WorkPackage instance.
+ */
+class Device {
+public:
+ /**
+ * @brief initialize the device
+ */
+ virtual bool initialize() {return true;}
+
+ /**
+ * @brief deinitialize the device
+ */
+ virtual void deinitialize() {}
+
+ /**
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
+ virtual void execute(WorkPackage *work) = 0;
+
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
new file mode 100644
index 00000000000..22d4366a1a8
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -0,0 +1,566 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ExecutionGroup.h"
+#include "COM_InputSocket.h"
+#include "COM_SocketConnection.h"
+#include "COM_defines.h"
+#include "math.h"
+#include "COM_ExecutionSystem.h"
+#include <sstream>
+#include "COM_ReadBufferOperation.h"
+#include "COM_WriteBufferOperation.h"
+#include "COM_ReadBufferOperation.h"
+#include "COM_WorkScheduler.h"
+#include "COM_ViewerOperation.h"
+#include <stdlib.h>
+#include "BLI_math.h"
+#include "COM_MemoryManager.h"
+#include "PIL_time.h"
+#include "COM_ChunkOrder.h"
+#include <algorithm>
+#include "BLI_math.h"
+#include "COM_ExecutionSystemHelper.h"
+
+ExecutionGroup::ExecutionGroup() {
+ this->isOutput = false;
+ this->complex = false;
+ this->chunkExecutionStates = NULL;
+ this->bTree = NULL;
+ this->height = 0;
+ this->width = 0;
+ this->cachedMaxReadBufferOffset = 0;
+ this->numberOfXChunks = 0;
+ this->numberOfYChunks = 0;
+ this->numberOfChunks = 0;
+ this->initialized = false;
+ this->openCL = false;
+ this->chunksFinished = 0;
+}
+
+int ExecutionGroup::getRenderPriotrity() {
+ return this->getOutputNodeOperation()->getRenderPriority();
+}
+
+bool ExecutionGroup::containsOperation(NodeOperation* operation) {
+ for (vector<NodeOperation*>::const_iterator iterator = this->operations.begin() ; iterator != this->operations.end() ; ++iterator) {
+ NodeOperation* inListOperation = *iterator;
+ if (inListOperation == operation) {
+ return true;
+ }
+ }
+ return false;
+}
+
+const bool ExecutionGroup::isComplex() const {
+ return this->complex;
+}
+
+bool ExecutionGroup::canContainOperation(NodeOperation* operation) {
+ if (!this->initialized) {return true;}
+ if (operation->isReadBufferOperation()) {return true;}
+ if (operation->isWriteBufferOperation()) {return false;}
+ if (operation->isSetOperation()) {return true;}
+
+ if (!this->isComplex()) {
+ return (!operation->isComplex());
+ } else {
+ return false;
+ }
+}
+
+void ExecutionGroup::addOperation(ExecutionSystem *system, NodeOperation *operation) {
+ if (containsOperation(operation)) return;
+ if (canContainOperation(operation)) {
+ if (!operation->isBufferOperation()) {
+ this->complex = operation->isComplex();
+ this->openCL = operation->isOpenCL();
+ this->initialized = true;
+ }
+ this->operations.push_back(operation);
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation* readOperation = (ReadBufferOperation*)operation;
+ WriteBufferOperation* writeOperation = readOperation->getMemoryProxy()->getWriteBufferOperation();
+ this->addOperation(system, writeOperation);
+ } else {
+ unsigned int index;
+ for (index = 0 ; index < operation->getNumberOfInputSockets(); index ++) {
+ InputSocket * inputSocket = operation->getInputSocket(index);
+ if (inputSocket->isConnected()) {
+ NodeOperation* node = (NodeOperation*)inputSocket->getConnection()->getFromNode();
+ this->addOperation(system, node);
+ }
+ }
+ }
+ } else {
+ if (operation->isWriteBufferOperation()) {
+ WriteBufferOperation * writeoperation = (WriteBufferOperation*)operation;
+ if (writeoperation->getMemoryProxy()->getExecutor() == NULL) {
+ ExecutionGroup* newGroup = new ExecutionGroup();
+ writeoperation->getMemoryProxy()->setExecutor(newGroup);
+ newGroup->addOperation(system, operation);
+ ExecutionSystemHelper::addExecutionGroup(system->getExecutionGroups(), newGroup);
+ }
+ }
+ }
+}
+
+NodeOperation* ExecutionGroup::getOutputNodeOperation() const{
+ return this->operations[0]; // the first operation of the group is always the output operation.
+}
+
+void ExecutionGroup::initExecution()
+{
+ if (this->chunkExecutionStates != NULL) {
+ delete[] this->chunkExecutionStates;
+ }
+ unsigned int index;
+ determineNumberOfChunks();
+
+ this->chunkExecutionStates = NULL;
+ if (this->numberOfChunks != 0) {
+ this->chunkExecutionStates = new ChunkExecutionState[numberOfChunks];
+ for (index = 0 ; index < numberOfChunks ; index ++) {
+ this->chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED;
+ }
+ }
+
+
+ unsigned int maxNumber = 0;
+
+ for (index = 0 ; index < this->operations.size(); index ++) {
+ NodeOperation* operation = this->operations[index];
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation*)operation;
+ this->cachedReadOperations.push_back(readOperation);
+ maxNumber = max(maxNumber, readOperation->getOffset());
+ }
+ }
+ maxNumber++;
+ this->cachedMaxReadBufferOffset = maxNumber;
+
+}
+
+void ExecutionGroup::deinitExecution() {
+ if (this->chunkExecutionStates != NULL) {
+ delete[] this->chunkExecutionStates;
+ this->chunkExecutionStates = NULL;
+ }
+ this->numberOfChunks = 0;
+ this->numberOfXChunks = 0;
+ this->numberOfYChunks = 0;
+ this->cachedReadOperations.clear();
+ this->bTree = NULL;
+}
+void ExecutionGroup::determineResolution(unsigned int resolution[]) {
+ NodeOperation* operation = this->getOutputNodeOperation();
+ unsigned int preferredResolution[2];
+ preferredResolution[0] = 0;
+ preferredResolution[1] = 0;
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+ this->setResolution(resolution);
+}
+
+void ExecutionGroup::determineNumberOfChunks() {
+ const float chunkSizef = this->chunkSize;
+ this->numberOfXChunks = ceil(this->width / chunkSizef);
+ this->numberOfYChunks = ceil(this->height / chunkSizef);
+ this->numberOfChunks = this->numberOfXChunks * this->numberOfYChunks;
+}
+
+/**
+ * this method is called for the top execution groups. containing the compositor node or the preview node or the viewer node)
+ */
+void ExecutionGroup::execute(ExecutionSystem* graph) {
+ CompositorContext& context = graph->getContext();
+ const bNodeTree* bTree = context.getbNodeTree();
+ if (this->width == 0 || this->height == 0) {return;} /// @note: break out... no pixels to calculate.
+ if (bTree->test_break && bTree->test_break(bTree->tbh)) {return;} /// @note: early break out for blur and preview nodes
+ if (this->numberOfChunks == 0) {return;} /// @note: early break out
+ unsigned int chunkNumber;
+
+ this->chunksFinished = 0;
+ this->bTree = bTree;
+ unsigned int index;
+ unsigned int *chunkOrder = new unsigned int[this->numberOfChunks];
+
+ for (chunkNumber = 0 ; chunkNumber<this->numberOfChunks ; chunkNumber++) {
+ chunkOrder[chunkNumber] = chunkNumber;
+ }
+ NodeOperation *operation = this->getOutputNodeOperation();
+ float centerX = 0.5;
+ float centerY = 0.5;
+ int chunkorder = COM_TO_CENTER_OUT;
+
+ if (operation->isViewerOperation()) {
+ ViewerBaseOperation* viewer = (ViewerBaseOperation*)operation;
+ centerX = viewer->getCenterX();
+ centerY = viewer->getCenterY();
+ chunkorder = viewer->getChunkOrder();
+ }
+
+ switch (chunkorder) {
+ case COM_TO_RANDOM:
+ for (index = 0 ; index < 2* numberOfChunks ; index ++) {
+ int index1 = rand()%numberOfChunks;
+ int index2 = rand()%numberOfChunks;
+ int s = chunkOrder[index1];
+ chunkOrder[index1] = chunkOrder[index2];
+ chunkOrder[index2] = s;
+ }
+ break;
+ case COM_TO_CENTER_OUT:
+ {
+ ChunkOrderHotspot **hotspots = new ChunkOrderHotspot*[1];
+ hotspots[0] = new ChunkOrderHotspot(this->width*centerX, this->height*centerY, 0.0f);
+ rcti rect;
+ ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks];
+ for (index = 0 ; index < this->numberOfChunks; index ++) {
+ determineChunkRect(&rect, index);
+ chunkOrders[index].setChunkNumber(index);
+ chunkOrders[index].setX(rect.xmin);
+ chunkOrders[index].setY(rect.ymin);
+ chunkOrders[index].determineDistance(hotspots, 1);
+ }
+
+ sort(&chunkOrders[0], &chunkOrders[numberOfChunks-1]);
+ for (index = 0 ; index < numberOfChunks; index ++) {
+ chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ }
+
+ delete hotspots[0];
+ delete[] hotspots;
+ delete[] chunkOrders;
+ }
+ break;
+ case COM_TO_RULE_OF_THIRDS:
+ {
+ ChunkOrderHotspot **hotspots = new ChunkOrderHotspot*[9];
+ unsigned int tx = this->width/6;
+ unsigned int ty = this->height/6;
+ unsigned int mx = this->width/2;
+ unsigned int my = this->height/2;
+ unsigned int bx = mx+2*tx;
+ unsigned int by = my+2*ty;
+
+ float addition = numberOfChunks/COM_RULE_OF_THIRDS_DIVIDER;
+ hotspots[0] = new ChunkOrderHotspot(mx, my, addition*0);
+ hotspots[1] = new ChunkOrderHotspot(tx, my, addition*1);
+ hotspots[2] = new ChunkOrderHotspot(bx, my, addition*2);
+ hotspots[3] = new ChunkOrderHotspot(bx, by, addition*3);
+ hotspots[4] = new ChunkOrderHotspot(tx, ty, addition*4);
+ hotspots[5] = new ChunkOrderHotspot(bx, ty, addition*5);
+ hotspots[6] = new ChunkOrderHotspot(tx, by, addition*6);
+ hotspots[7] = new ChunkOrderHotspot(mx, ty, addition*7);
+ hotspots[8] = new ChunkOrderHotspot(mx, by, addition*8);
+ rcti rect;
+ ChunkOrder *chunkOrders = new ChunkOrder[this->numberOfChunks];
+ for (index = 0 ; index < this->numberOfChunks; index ++) {
+ determineChunkRect(&rect, index);
+ chunkOrders[index].setChunkNumber(index);
+ chunkOrders[index].setX(rect.xmin);
+ chunkOrders[index].setY(rect.ymin);
+ chunkOrders[index].determineDistance(hotspots, 9);
+ }
+
+ sort(&chunkOrders[0], &chunkOrders[numberOfChunks]);
+
+ for (index = 0 ; index < numberOfChunks; index ++) {
+ chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ }
+
+ delete hotspots[0];
+ delete hotspots[1];
+ delete hotspots[2];
+ delete hotspots[3];
+ delete hotspots[4];
+ delete hotspots[5];
+ delete hotspots[6];
+ delete hotspots[7];
+ delete hotspots[8];
+ delete[] hotspots;
+ delete[] chunkOrders;
+ }
+ break;
+ case COM_TO_TOP_DOWN:
+ default:
+ break;
+ }
+
+ bool breaked = false;
+ bool finished = false;
+ unsigned int startIndex = 0;
+ const int maxNumberEvaluated = BLI_system_thread_count()*2;
+
+ while (!finished && !breaked) {
+ unsigned int index;
+ bool startEvaluated = false;
+ finished = true;
+ int numberEvaluated = 0;
+
+ for (index = startIndex ; index < numberOfChunks && numberEvaluated < maxNumberEvaluated; index ++) {
+ int chunkNumber = chunkOrder[index];
+ int yChunk = chunkNumber/this->numberOfXChunks;
+ int xChunk = chunkNumber - (yChunk*this->numberOfXChunks);
+ const ChunkExecutionState state = this->chunkExecutionStates[chunkNumber];
+ if (state == COM_ES_NOT_SCHEDULED) {
+ scheduleChunkWhenPossible(graph, xChunk, yChunk);
+ finished=false;
+ startEvaluated = true;
+ numberEvaluated++;
+ } else if (state == COM_ES_SCHEDULED) {
+ finished=false;
+ startEvaluated = true;
+ numberEvaluated++;
+ } else if (state == COM_ES_EXECUTED && !startEvaluated) {
+ startIndex = index+1;
+ }
+ }
+ PIL_sleep_ms(10);
+
+ if (bTree->test_break && bTree->test_break(bTree->tbh)) {
+ breaked = true;
+ }
+ }
+
+ delete[] chunkOrder;
+}
+
+MemoryBuffer** ExecutionGroup::getInputBuffers(int chunkNumber) {
+ rcti rect;
+ vector<MemoryProxy*> memoryproxies;
+ unsigned int index;
+ determineChunkRect(&rect, chunkNumber);
+
+ this->determineDependingMemoryProxies(&memoryproxies);
+ MemoryBuffer **memoryBuffers = new MemoryBuffer*[this->cachedMaxReadBufferOffset];
+ for (index= 0 ; index < this->cachedMaxReadBufferOffset ; index ++) {
+ memoryBuffers[index] = NULL;
+ }
+ rcti output;
+ for (index = 0 ; index < this->cachedReadOperations.size(); index ++) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation*)this->cachedReadOperations[index];
+ MemoryProxy * memoryProxy = readOperation->getMemoryProxy();
+ this->determineDependingAreaOfInterest(&rect, readOperation, &output);
+ MemoryBuffer* memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output);
+ memoryBuffers[readOperation->getOffset()] = memoryBuffer;
+ }
+ return memoryBuffers;
+}
+
+MemoryBuffer* ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect) {
+ // find all chunks inside the rect
+ // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
+ float chunkSizef = this->chunkSize;
+
+ int indexx, indexy;
+
+ const int minxchunk = floor(rect->xmin/chunkSizef);
+ const int maxxchunk = ceil((rect->xmax-1)/chunkSizef);
+ const int minychunk = floor(rect->ymin/chunkSizef);
+ const int maxychunk = ceil((rect->ymax-1)/chunkSizef);
+
+ if (maxxchunk== minxchunk+1 && maxychunk == minychunk+1) {
+ const int chunkNumber = minxchunk+minychunk*numberOfXChunks;
+ MemoryBuffer *result = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber);
+ return result;
+ }
+
+ rcti chunkRect;
+ chunkRect.xmin = minxchunk*this->chunkSize;
+ chunkRect.xmax = maxxchunk*this->chunkSize;
+ chunkRect.ymin = minychunk*this->chunkSize;
+ chunkRect.ymax = maxychunk*this->chunkSize;
+
+ CLAMP(chunkRect.xmin, 0, (int)this->width);
+ CLAMP(chunkRect.xmax, 0, (int)this->width);
+ CLAMP(chunkRect.ymin, 0, (int)this->height);
+ CLAMP(chunkRect.ymax, 0, (int)this->height);
+
+ MemoryBuffer *result = new MemoryBuffer(memoryProxy, &chunkRect);
+
+ for (indexx = max(minxchunk, 0); indexx<min((int)this->numberOfXChunks, maxxchunk) ; indexx++) {
+ for (indexy = max(minychunk, 0); indexy<min((int)this->numberOfYChunks, maxychunk) ; indexy++) {
+ int chunkNumber = indexx+indexy*this->numberOfXChunks;
+ MemoryBuffer *chunkBuffer = MemoryManager::getMemoryBuffer(memoryProxy, chunkNumber);
+ result->copyContentFrom(chunkBuffer);
+ }
+ }
+
+ return result;
+}
+
+void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers) {
+ if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
+ this->chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
+ else
+ throw "Threading inconsistency";
+
+ this->chunksFinished++;
+ if (memoryBuffers) {
+ for (unsigned int index = 0 ; index < this->cachedMaxReadBufferOffset; index ++) {
+ MemoryBuffer * buffer = memoryBuffers[index];
+ if (buffer) {
+ if (buffer->isTemporarily()) {
+ memoryBuffers[index] = NULL;
+ delete buffer;
+ }
+ }
+ }
+ delete[] memoryBuffers;
+ }
+ if (bTree) {
+ // status report is only performed for top level Execution Groups.
+ float progress = chunksFinished;
+ progress/=numberOfChunks;
+ bTree->progress(bTree->prh, progress);
+ }
+}
+
+inline void ExecutionGroup::determineChunkRect(rcti* rect, const unsigned int xChunk, const unsigned int yChunk ) const {
+ const unsigned int minx = xChunk * chunkSize;
+ const unsigned int miny = yChunk * chunkSize;
+ BLI_init_rcti(rect, minx, min(minx + this->chunkSize, this->width), miny, min(miny + this->chunkSize, this->height));
+}
+
+void ExecutionGroup::determineChunkRect(rcti* rect, const unsigned int chunkNumber) const {
+ const unsigned int yChunk = chunkNumber / numberOfXChunks;
+ const unsigned int xChunk = chunkNumber - (yChunk * numberOfXChunks);
+ determineChunkRect(rect, xChunk, yChunk);
+}
+
+MemoryBuffer* ExecutionGroup::allocateOutputBuffer(int chunkNumber, rcti* rect) {
+ MemoryBuffer* outputBuffer = NULL;
+ // output allocation is only valid when our outputoperation is a memorywriter
+ NodeOperation * operation = this->getOutputNodeOperation();
+ if (operation->isWriteBufferOperation()) {
+ WriteBufferOperation* writeOperation = (WriteBufferOperation*)operation;
+ outputBuffer = MemoryManager::allocateMemoryBuffer(writeOperation->getMemoryProxy(), chunkNumber, rect);
+ }
+ return outputBuffer;
+}
+
+
+bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem * graph, rcti *area) {
+ // find all chunks inside the rect
+ // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
+
+ float chunkSizef = this->chunkSize;
+
+ int indexx, indexy;
+ const int minxchunk = floor(area->xmin/chunkSizef);
+ const int maxxchunk = ceil((area->xmax-1)/chunkSizef);
+ const int minychunk = floor(area->ymin/chunkSizef);
+ const int maxychunk = ceil((area->ymax-1)/chunkSizef);
+
+ bool result = true;
+ for (indexx = max(minxchunk, 0); indexx<maxxchunk ; indexx++) {
+ for (indexy = max(minychunk, 0); indexy<maxychunk ; indexy++) {
+ if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
+ result = false;
+ }
+ }
+ }
+
+ return result;
+}
+
+bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber) {
+ if (this->chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) {
+ this->chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED;
+ WorkScheduler::schedule(this, chunkNumber);
+ return true;
+ }
+ return false;
+}
+
+bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk) {
+ if (xChunk < 0 || xChunk >= (int)this->numberOfXChunks) {
+ return true;
+ }
+ if (yChunk < 0 || yChunk >= (int)this->numberOfYChunks) {
+ return true;
+ }
+ int chunkNumber = yChunk*this->numberOfXChunks + xChunk;
+ // chunk is already executed
+ if (this->chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) {
+ return true;
+ }
+
+ // chunk is scheduled, but not executed
+ if (this->chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) {
+ return false;
+ }
+
+ // chunk is nor executed nor scheduled.
+ vector<MemoryProxy*> memoryProxies;
+ this->determineDependingMemoryProxies(&memoryProxies);
+
+ rcti rect;
+ determineChunkRect(&rect, xChunk, yChunk);
+ unsigned int index;
+ bool canBeExecuted = true;
+ rcti area;
+
+ for (index = 0 ; index < cachedReadOperations.size() ; index ++) {
+ ReadBufferOperation * readOperation = (ReadBufferOperation*)cachedReadOperations[index];
+ BLI_init_rcti(&area, 0, 0, 0, 0);
+ MemoryProxy * memoryProxy = memoryProxies[index];
+ determineDependingAreaOfInterest(&rect, readOperation, &area);
+ ExecutionGroup *group = memoryProxy->getExecutor();
+
+ if (group != NULL) {
+ if (!group->scheduleAreaWhenPossible(graph, &area)) {
+ canBeExecuted = false;
+ }
+ } else {
+ throw "ERROR";
+ }
+ }
+
+ if (canBeExecuted) {
+ scheduleChunk(chunkNumber);
+ }
+
+ return false;
+}
+
+void ExecutionGroup::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output) {
+ this->getOutputNodeOperation()->determineDependingAreaOfInterest(input, readOperation, output);
+}
+
+void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies) {
+ unsigned int index;
+ for (index = 0 ; index < this->cachedReadOperations.size() ; index ++) {
+ ReadBufferOperation * readOperation = (ReadBufferOperation*) this->cachedReadOperations[index];
+ memoryProxies->push_back(readOperation->getMemoryProxy());
+ }
+}
+
+bool ExecutionGroup::operator ==(const ExecutionGroup & executionGroup) const {
+ return this->getOutputNodeOperation() == executionGroup.getOutputNodeOperation();
+}
+
+bool ExecutionGroup::isOpenCL() {
+ return this->openCL;
+}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
new file mode 100644
index 00000000000..2d5e0965297
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -0,0 +1,404 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ExecutionGroup_h
+#define _COM_ExecutionGroup_h
+
+#include "COM_Node.h"
+#include "COM_NodeOperation.h"
+#include <vector>
+#include "BLI_rect.h"
+#include "COM_MemoryProxy.h"
+#include "COM_Device.h"
+#include "COM_CompositorContext.h"
+
+
+/**
+ * @brief the execution state of a chunk in an ExecutionGroup
+ * @ingroup Execution
+ */
+typedef enum ChunkExecutionState {
+ /**
+ * @brief chunk is not yet scheduled
+ */
+ COM_ES_NOT_SCHEDULED = 0,
+ /**
+ * @brief chunk is scheduled, but not yet executed
+ */
+ COM_ES_SCHEDULED = 1,
+ /**
+ * @brief chunk is executed.
+ */
+ COM_ES_EXECUTED = 2
+} ChunkExecutionState;
+
+class MemoryProxy;
+class ReadBufferOperation;
+class Device;
+
+/**
+ * @brief Class ExecutionGroup is a group of NodeOperations that are executed as one.
+ * This grouping is used to combine Operations that can be executed as one whole when multi-processing.
+ * @ingroup Execution
+ */
+class ExecutionGroup {
+private:
+ // fields
+ /**
+ * @brief unique identifier of this node.
+ */
+ string id;
+
+ /**
+ * @brief list of operations in this ExecutionGroup
+ */
+ vector<NodeOperation*> operations;
+
+ /**
+ * @brief is this ExecutionGroup an input ExecutionGroup
+ * an input execution group is a group that is at the end of the calculation (the output is important for the user)
+ */
+ int isOutput;
+
+ /**
+ * @brief Width of the output
+ */
+ unsigned int width;
+
+ /**
+ * @brief Height of the output
+ */
+ unsigned int height;
+
+ /**
+ * @brief size of a single chunk, being Width or of height
+ * a chunk is always a square, except at the edges of the MemoryBuffer
+ */
+ unsigned int chunkSize;
+
+ /**
+ * @brief number of chunks in the x-axis
+ */
+ unsigned int numberOfXChunks;
+
+ /**
+ * @brief number of chunks in the y-axis
+ */
+ unsigned int numberOfYChunks;
+
+ /**
+ * @brief total number of chunks
+ */
+ unsigned int numberOfChunks;
+
+ /**
+ * @brief contains this ExecutionGroup a complex NodeOperation.
+ */
+ bool complex;
+
+ /**
+ * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ */
+ bool openCL;
+
+ /**
+ * @brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
+ * @note this is used to construct the MemoryBuffers that will be passed during execution.
+ */
+ unsigned int cachedMaxReadBufferOffset;
+
+ /**
+ * @brief a cached vector of all read operations in the execution group.
+ */
+ vector<NodeOperation*> cachedReadOperations;
+
+ /**
+ * @brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
+ * @note can only be used to call the callbacks for progress, status and break
+ */
+ const bNodeTree * bTree;
+
+ /**
+ * @brief total number of chunks that have been calculated for this ExecutionGroup
+ */
+ unsigned int chunksFinished;
+
+ /**
+ * @brief the chunkExecutionStates holds per chunk the execution state. this state can be
+ * - COM_ES_NOT_SCHEDULED: not scheduled
+ * - COM_ES_SCHEDULED: scheduled
+ * - COM_ES_EXECUTED: executed
+ */
+ ChunkExecutionState *chunkExecutionStates;
+
+ /**
+ * @brief indicator when this ExecutionGroup has valid NodeOperations in its vector for Execution
+ * @note When building the ExecutionGroup NodeOperations are added via recursion. First a WriteBufferOperations is added, then the
+ * @note Operation containing the settings that is important for the ExecutiongGroup is added,
+ * @note When this occurs, these settings are copied over from the node to the ExecutionGroup
+ * @note and the Initialized flag is set to true.
+ * @see complex
+ * @see openCL
+ */
+ bool initialized;
+
+ // methods
+ /**
+ * @brief check whether parameter operation can be added to the execution group
+ * @param operation the operation to be added
+ */
+ bool canContainOperation(NodeOperation* operation);
+
+ /**
+ * @brief get the Render priority of this ExecutionGroup
+ * @see ExecutionSystem.execute
+ */
+ int getRenderPriotrity();
+
+ /**
+ * @brief calculate the actual chunk size of this execution group.
+ * @note A chunk size is an unsigned int that is both the height and width of a chunk.
+ * @note The chunk size will not be stored in the chunkSize field. This needs to be done
+ * @note by the calling method.
+ */
+ unsigned int determineChunkSize();
+
+
+ /**
+ * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
+ * @note Only gives usefull results ater the determination of the chunksize
+ * @see determineChunkSize()
+ */
+ void determineChunkRect(rcti* rect, const unsigned int xChunk, const unsigned int yChunk) const;
+
+ /**
+ * @brief determine the number of chunks, based on the chunkSize, width and height.
+ * @note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
+ */
+ void determineNumberOfChunks();
+
+ /**
+ * @brief try to schedule a specific chunk.
+ * @note scheduling succeeds when all input requirements are met and the chunks hasen't been scheduled yet.
+ * @param graph
+ * @param xChunk
+ * @param yChunk
+ * @return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleChunkWhenPossible(ExecutionSystem * graph, int xChunk, int yChunk);
+
+ /**
+ * @brief try to schedule a specific area.
+ * @note Check if a certain area is available, when not available this are will be checked.
+ * @note This method is called from other ExecutionGroup's.
+ * @param graph
+ * @param rect
+ * @return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleAreaWhenPossible(ExecutionSystem * graph, rcti * rect);
+
+ /**
+ * @brief add a chunk to the WorkScheduler.
+ * @param chunknumber
+ */
+ bool scheduleChunk(unsigned int chunkNumber);
+
+ /**
+ * @brief determine the area of interest of a certain input area
+ * @note This method only evaluates a single ReadBufferOperation
+ * @param input the input area
+ * @param readOperation The ReadBufferOperation where the area needs to be evaluated
+ * @param output the area needed of the ReadBufferOperation. Result
+ */
+ void determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output);
+
+
+public:
+ // constructors
+ ExecutionGroup();
+
+ /**
+ * @brief set the id of this ExecutionGroup
+ * @param id
+ */
+ void setId(string id) {this->id = id;}
+
+ /**
+ * @brief return the id of this ExecutionGroup
+ */
+ const string getId() const {return this->id;}
+
+ // methods
+ /**
+ * @brief check to see if a NodeOperation is already inside this execution group
+ * @param operation the NodeOperation to check
+ * @return [true,false]
+ */
+ bool containsOperation(NodeOperation* operation);
+
+ /**
+ * @brief add an operation to this ExecutionGroup
+ * @note this method will add input of the operations recursivly
+ * @note this method can create multiple ExecutionGroup's
+ * @param system
+ * @param operation
+ */
+ void addOperation(ExecutionSystem* system, NodeOperation *operation);
+
+ /**
+ * @brief is this ExecutionGroup an output ExecutionGroup
+ * @note An OutputExecution group are groups containing a
+ * @note ViewerOperation, CompositeOperation, PreviewOperation.
+ * @see NodeOperation.isOutputOperation
+ */
+ const int isOutputExecutionGroup() const {return this->isOutput;}
+
+ /**
+ * @brief set whether this ExecutionGroup is an output
+ * @param isOutput
+ */
+ void setOutputExecutionGroup(int isOutput) {this->isOutput = isOutput;}
+
+ /**
+ * @brief determine the resolution of this ExecutionGroup
+ * @param resolution
+ */
+ void determineResolution(unsigned int resolution[]);
+
+ /**
+ * @brief set the resolution of this executiongroup
+ * @param resolution
+ */
+ void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];}
+
+ /**
+ * @brief get the width of this execution group
+ */
+ const unsigned int getWidth() {return this->width;}
+
+ /**
+ * @brief get the height of this execution group
+ */
+ const unsigned int getHeight() {return this->height;}
+
+ /**
+ * @brief does this ExecutionGroup contains a complex NodeOperation
+ */
+ const bool isComplex() const;
+
+
+ /**
+ * @brief get the output operation of this ExecutionGroup
+ * @return NodeOperation* output operation
+ */
+ NodeOperation* getOutputNodeOperation() const;
+
+ /**
+ * @brief compose multiple chunks into a single chunk
+ * @return Memorybuffer* consolidated chunk
+ */
+ MemoryBuffer* constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
+
+ /**
+ * @brief initExecution is called just before the execution of the whole graph will be done.
+ * @note The implementation will calculate the chunkSize of this execution group.
+ */
+ void initExecution();
+
+ /**
+ * @brief get all inputbuffers needed to calculate an chunk
+ * @note all inputbuffers must be executed
+ * @param chunkNumber the chunk to be calculated
+ * @return MemoryBuffer** the inputbuffers
+ */
+ MemoryBuffer** getInputBuffers(int chunkNumber);
+
+ /**
+ * @brief allocate the outputbuffer of a chunk
+ * @param chunkNumber the number of the chunk in the ExecutionGroup
+ * @param rect the rect of that chunk
+ * @see determineChunkRect
+ */
+ MemoryBuffer* allocateOutputBuffer(int chunkNumber, rcti *rect);
+
+ /**
+ * @brief after a chunk is executed the needed resources can be freed or unlocked.
+ * @param chunknumber
+ * @param memorybuffers
+ */
+ void finalizeChunkExecution(int chunkNumber, MemoryBuffer** memoryBuffers);
+
+ /**
+ * @brief deinitExecution is called just after execution the whole graph.
+ * @note It will release all needed resources
+ */
+ void deinitExecution();
+
+
+ /**
+ * @brief schedule an ExecutionGroup
+ * @note this method will return when all chunks have been calculated, or the execution has breaked (by user)
+ *
+ * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
+ * - ChunkOrdering
+ * - CenterX
+ * - CenterY
+ *
+ * After determining the order of the chunks the chunks will be scheduled
+ *
+ * @see ViewerOperation
+ * @param system
+ */
+ void execute(ExecutionSystem* system);
+
+ /**
+ * @brief this method determines the MemoryProxy's where this execution group depends on.
+ * @note After this method determineDependingAreaOfInterest can be called to determine
+ * @note the area of the MemoryProxy.creator thas has to be executed.
+ * @param memoryProxies result
+ */
+ void determineDependingMemoryProxies(vector<MemoryProxy*> *memoryProxies);
+
+ /**
+ * @brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
+ * @note Only gives usefull results ater the determination of the chunksize
+ * @see determineChunkSize()
+ */
+ void determineChunkRect(rcti* rect, const unsigned int chunkNumber) const;
+
+
+ bool operator ==(const ExecutionGroup &executionGroup) const;
+
+ /**
+ * @brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ * @see WorkScheduler.schedule
+ */
+ bool isOpenCL();
+
+ void setChunksize(int chunksize) {this->chunkSize = chunksize;}
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
new file mode 100644
index 00000000000..d82d725d234
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ExecutionSystem.h"
+
+#include "PIL_time.h"
+#include "BKE_node.h"
+#include "COM_Converter.h"
+#include <sstream>
+#include "COM_NodeOperation.h"
+#include "COM_ExecutionGroup.h"
+#include "COM_NodeBase.h"
+#include "COM_WorkScheduler.h"
+#include "COM_ReadBufferOperation.h"
+#include "COM_MemoryManager.h"
+#include "stdio.h"
+#include "COM_GroupNode.h"
+#include "COM_WriteBufferOperation.h"
+#include "COM_ReadBufferOperation.h"
+#include "COM_ExecutionSystemHelper.h"
+
+#include "BKE_global.h"
+
+ExecutionSystem::ExecutionSystem(bNodeTree* editingtree, bool rendering) {
+ this->context.setbNodeTree(editingtree);
+
+ /* initialize the CompositorContext */
+ if (rendering) {
+ context.setQuality((CompositorQuality)editingtree->render_quality);
+ } else {
+ context.setQuality((CompositorQuality)editingtree->edit_quality);
+ }
+ context.setRendering(rendering);
+ context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL));
+
+ Node* mainOutputNode=NULL;
+
+ mainOutputNode = ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree);
+
+ if (mainOutputNode) {
+ context.setScene((Scene*)mainOutputNode->getbNode()->id);
+ this->convertToOperations();
+ this->groupOperations(); /* group operations in ExecutionGroups */
+ vector<ExecutionGroup*> executionGroups;
+ this->findOutputExecutionGroup(&executionGroups);
+ unsigned int index;
+ unsigned int resolution[2];
+ for (index = 0 ; index < executionGroups.size(); index ++) {
+ resolution[0]=0;
+ resolution[1]=0;
+ ExecutionGroup* executionGroup = executionGroups[index];
+ executionGroup->determineResolution(resolution);
+ }
+ }
+
+ if (G.f & G_DEBUG) ExecutionSystemHelper::debugDump(this);
+}
+
+ExecutionSystem::~ExecutionSystem() {
+ unsigned int index;
+ for(index = 0; index < this->connections.size(); index++) {
+ SocketConnection* connection = this->connections[index];
+ delete connection;
+ }
+ this->connections.clear();
+ for(index = 0; index < this->nodes.size(); index++) {
+ Node* node = this->nodes[index];
+ delete node;
+ }
+ this->nodes.clear();
+ for(index = 0; index < this->operations.size(); index++) {
+ NodeOperation* operation = this->operations[index];
+ delete operation;
+ }
+ this->operations.clear();
+ for(index = 0; index < this->groups.size(); index++) {
+ ExecutionGroup* group = this->groups[index];
+ delete group;
+ }
+ this->groups.clear();
+}
+
+void ExecutionSystem::execute() {
+ unsigned int order = 0;
+ for( vector<NodeOperation*>::iterator iter = this->operations.begin(); iter != operations.end(); ++iter ) {
+ NodeBase* node = *iter;
+ NodeOperation *operation = (NodeOperation*) node;
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation * readOperation = (ReadBufferOperation*)operation;
+ readOperation->setOffset(order);
+ order ++;
+ }
+ }
+
+ MemoryManager::initialize();
+ unsigned int index;
+
+ for (index = 0 ; index < this->operations.size() ; index ++) {
+ NodeOperation * operation = this->operations[index];
+ operation->initExecution();
+ }
+ for (index = 0 ; index < this->groups.size() ; index ++) {
+ ExecutionGroup * executionGroup = this->groups[index];
+ executionGroup->setChunksize(context.getChunksize());
+ executionGroup->initExecution();
+ }
+
+ WorkScheduler::start(this->context);
+
+
+ vector<ExecutionGroup*> executionGroups;
+ this->findOutputExecutionGroup(&executionGroups);
+
+ /* start execution of the ExecutionGroups based on priority of their output node */
+ for (int priority = 9 ; priority>=0 ; priority--) {
+ for (index = 0 ; index < executionGroups.size(); index ++) {
+ ExecutionGroup* group = executionGroups[index];
+ NodeOperation* output = group->getOutputNodeOperation();
+ if (output->getRenderPriority() == priority) {
+ group->execute(this);
+ }
+ }
+ }
+
+ WorkScheduler::finish();
+ WorkScheduler::stop();
+
+ for (index = 0 ; index < this->operations.size() ; index ++) {
+ NodeOperation * operation = this->operations[index];
+ operation->deinitExecution();
+ }
+ for (index = 0 ; index < this->groups.size() ; index ++) {
+ ExecutionGroup * executionGroup = this->groups[index];
+ executionGroup->deinitExecution();
+ }
+ MemoryManager::clear();
+}
+
+void ExecutionSystem::addOperation(NodeOperation *operation) {
+ ExecutionSystemHelper::addOperation(this->operations, operation);
+}
+
+void ExecutionSystem::addReadWriteBufferOperations(NodeOperation *operation) {
+ // for every input add write and read operation if input is not a read operation
+ // only add read operation to other links when they are attached to buffered operations.
+ unsigned int index;
+ for (index = 0 ; index < operation->getNumberOfInputSockets();index++) {
+ InputSocket* inputsocket = operation->getInputSocket(index);
+ if (inputsocket->isConnected()) {
+ SocketConnection *connection = inputsocket->getConnection();
+ NodeOperation* otherEnd = (NodeOperation*)connection->getFromNode();
+ if (!otherEnd->isReadBufferOperation()) {
+ // check of other end already has write operation
+ OutputSocket *fromsocket = connection->getFromSocket();
+ WriteBufferOperation * writeoperation = fromsocket->findAttachedWriteBufferOperation();
+ if (writeoperation == NULL) {
+ writeoperation = new WriteBufferOperation();
+ writeoperation->setbNodeTree(this->getContext().getbNodeTree());
+ this->addOperation(writeoperation);
+ ExecutionSystemHelper::addLink(this->getConnections(), fromsocket, writeoperation->getInputSocket(0));
+ }
+ ReadBufferOperation *readoperation = new ReadBufferOperation();
+ readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
+ connection->setFromSocket(readoperation->getOutputSocket());
+ readoperation->getOutputSocket()->addConnection(connection);
+ this->addOperation(readoperation);
+ }
+ }
+ }
+ /*
+ link the outputsocket to a write operation
+ link the writeoperation to a read operation
+ link the read operation to the next node.
+ */
+ OutputSocket * outputsocket = operation->getOutputSocket();
+ if (outputsocket->isConnected()) {
+ int index;
+ WriteBufferOperation *writeOperation;
+ writeOperation = new WriteBufferOperation();
+ writeOperation->setbNodeTree(this->getContext().getbNodeTree());
+ this->addOperation(writeOperation);
+ for (index = 0 ; index < outputsocket->getNumberOfConnections();index ++) {
+ SocketConnection * connection = outputsocket->getConnection(index);
+ ReadBufferOperation* readoperation = new ReadBufferOperation();
+ readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
+ connection->setFromSocket(readoperation->getOutputSocket());
+ readoperation->getOutputSocket()->addConnection(connection);
+ this->addOperation(readoperation);
+ }
+ ExecutionSystemHelper::addLink(this->getConnections(), outputsocket, writeOperation->getInputSocket(0));
+ }
+}
+
+void ExecutionSystem::convertToOperations() {
+ unsigned int index;
+ // first determine data types of the nodes, this can be used by the node to convert to a different operation system
+ this->determineActualSocketDataTypes((vector<NodeBase*>&)this->nodes);
+ for(index = 0; index < this->nodes.size(); index++) {
+ Node* node = (Node*)this->nodes[index];
+ node->convertToOperations(this, &this->context);
+ }
+
+ // update the socket types of the operations. this will be used to add conversion operations in the system
+ this->determineActualSocketDataTypes((vector<NodeBase*>&)this->operations);
+ for (index = 0 ; index < this->connections.size(); index ++) {
+ SocketConnection *connection = this->connections[index];
+ if (connection->isValid()) {
+ if (connection->getFromSocket()->getActualDataType() != connection->getToSocket()->getActualDataType()) {
+ Converter::convertDataType(connection, this);
+ }
+ }
+ }
+
+ // determine all resolutions of the operations (Width/Height)
+ for (index = 0 ; index < this->operations.size(); index ++) {
+ NodeOperation* operation= this->operations[index];
+ if (operation->isOutputOperation(context.isRendering())) {
+ unsigned int resolution[2] = {0,0};
+ unsigned int preferredResolution[2] = {0,0};
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+ }
+ }
+
+ // add convert resolution operations when needed.
+ for (index = 0 ; index < this->connections.size(); index ++) {
+ SocketConnection *connection = this->connections[index];
+ if (connection->isValid()) {
+ if (connection->needsResolutionConversion()) {
+ Converter::convertResolution(connection, this);
+ }
+ }
+ }
+
+}
+
+void ExecutionSystem::groupOperations() {
+ vector<NodeOperation*> outputOperations;
+ NodeOperation * operation;
+ unsigned int index;
+ // surround complex operations with ReadBufferOperation and WriteBufferOperation
+ for(index = 0; index < this->operations.size(); index++) {
+ operation = this->operations[index];
+ if (operation->isComplex()) {
+ this->addReadWriteBufferOperations(operation);
+ }
+ }
+ ExecutionSystemHelper::findOutputNodeOperations(&outputOperations, this->getOperations(), this->context.isRendering());
+ for( vector<NodeOperation*>::iterator iter = outputOperations.begin(); iter != outputOperations.end(); ++iter ) {
+ operation = *iter;
+ ExecutionGroup *group = new ExecutionGroup();
+ group->addOperation(this, operation);
+ group->setOutputExecutionGroup(true);
+ ExecutionSystemHelper::addExecutionGroup(this->getExecutionGroups(), group);
+ }
+}
+
+void ExecutionSystem::addSocketConnection(SocketConnection *connection)
+{
+ this->connections.push_back(connection);
+}
+
+
+void ExecutionSystem::determineActualSocketDataTypes(vector<NodeBase*> &nodes) {
+ unsigned int index;
+ /* first do all input nodes */
+ for(index = 0; index < nodes.size(); index++) {
+ NodeBase* node = nodes[index];
+ if (node->isInputNode()) {
+ node->determineActualSocketDataTypes();
+ }
+ }
+
+ /* then all other nodes */
+ for(index = 0; index < nodes.size(); index++) {
+ NodeBase* node = nodes[index];
+ if (!node->isInputNode()) {
+ node->determineActualSocketDataTypes();
+ }
+ }
+}
+
+void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup*> *result) const {
+ unsigned int index;
+ for (index = 0 ; index < this->groups.size() ; index ++) {
+ ExecutionGroup* group = this->groups[index];
+ if (group->isOutputExecutionGroup()) {
+ result->push_back(group);
+ }
+ }
+}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
new file mode 100644
index 00000000000..7d0830491f3
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class ExecutionGroup;
+
+#ifndef _COM_ExecutionSystem_h
+#define _COM_ExecutionSystem_h
+
+#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"
+
+using namespace std;
+
+/**
+ * @page execution Execution model
+ * In order to get to an efficient model for execution, serveral steps are being done. these steps are explained below.
+ *
+ * @section EM_Step1 Step 1: translating blender node system to the new compsitor system
+ * Blenders node structure is based on C structs (DNA). These structs are not efficient in the new architecture. We want to use classes in order to simplify the system.
+ * during this step the blender node_tree is evaluated and converted to a CPP node system.
+ *
+ * @see ExecutionSystem
+ * @see Converter.convert
+ * @see Node
+ *
+ * @section EM_Step2 Step2: translating nodes to operations
+ * Ungrouping the GroupNodes. Group nodes are node_tree's in node_tree's. The new system only supports a single level of node_tree. We will 'flatten' the system in a single level.
+ * @see GroupNode
+ * @see ExecutionSystemHelper.ungroup
+ *
+ * Every node has the ability to convert itself to operations. The node itself is responsible to create a correct NodeOperation setup based on its internal settings.
+ * Most Node only need to convert it to its NodeOperation. Like a ColorToBWNode doesn't check anything, but replaces itself with a ConvertColorToBWOperation.
+ * More complex nodes can use different NodeOperation based on settings; like MixNode. based on the selected Mixtype a different operation will be used.
+ * for more information see the page about creating new Nodes. [@subpage newnode]
+ *
+ * @see ExecutionSystem.convertToOperations
+ * @see Node.convertToOperations
+ * @see NodeOperation base class for all operations in the system
+ *
+ * @section EM_Step3 Step3: add additional conversions to the operation system
+ * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR. The user can connect a Value socket to a color socket. 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 folowing 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
+ * - [@ref InputSocketResizeMode.COM_SC_FIT]: The width, or the height of both images are aligned to make sure that it fits.
+ * - [@ref InputSocketResizeMode.COM_SC_STRETCH]: The width and the height of both images are aligned
+ * - [@ref InputSocketResizeMode.COM_SC_NO_RESIZE]: bottom left of the images are aligned.
+ *
+ * @see Converter.convertDataType Datatype conversions
+ * @see Converter.convertResolution Image size conversions
+ *
+ * @section EM_Step4 Step4: group operations in executions groups
+ * ExecutionGroup are groups of operations that are calculated as being one bigger operation. All operations will be part of an ExecutionGroup.
+ * Complex nodes will be added to separate groups. Between ExecutionGroup's the data will be stored in MemoryBuffers. ReadBufferOperations and WriteBufferOperations are added where needed.
+ *
+ * <pre>
+ *
+ * +------------------------------+ +----------------+
+ * | ExecutionGroup A | |ExecutionGroup B| ExecutionGroup
+ * | +----------+ +----------+| |+----------+ |
+ * /----->| Operation|---->| Operation|-\ /--->| Operation|-\ | NodeOperation
+ * | | | A | | B ||| | || C | | |
+ * | | | cFFA | /->| cFFA ||| | || cFFA | | |
+ * | | +----------+ | +----------+|| | |+----------+ | |
+ * | +---------------|--------------+v | +-------------v--+
+ * +-*----+ +---*--+ +--*-*--+ +--*----+
+ * |inputA| |inputB| |outputA| |outputB| MemoryBuffer
+ * |cFAA | |cFAA | |cFAA | |cFAA |
+ * +------+ +------+ +-------+ +-------+
+ * </pre>
+ * @see ExecutionSystem.groupOperations method doing this step
+ * @see ExecutionSystem.addReadWriteBufferOperations
+ * @see NodeOperation.isComplex
+ * @see ExecutionGroup class representing the ExecutionGroup
+ */
+
+/**
+ * @brief the ExecutionSystem contains the whole compositor tree.
+ */
+class ExecutionSystem {
+private:
+ /**
+ * @brief the context used during execution
+ */
+ CompositorContext context;
+
+ /**
+ * @brief vector of nodes
+ */
+ vector<Node*> nodes;
+
+ /**
+ * @brief vector of operations
+ */
+ vector<NodeOperation*> operations;
+
+ /**
+ * @brief vector of groups
+ */
+ vector<ExecutionGroup*> groups
+
+ /**
+ * @brief vector of connections
+ */;
+ vector<SocketConnection*> connections;
+
+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) const;
+
+public:
+ /**
+ * @brief Create a new ExecutionSystem and initialize it with the
+ * editingtree.
+ *
+ * @param editingtree [bNodeTree*]
+ * @param rendering [true false]
+ */
+ ExecutionSystem(bNodeTree* editingtree, bool rendering);
+
+ /**
+ * Destructor
+ */
+ ~ExecutionSystem();
+
+
+ /**
+ * @brief execute this system
+ * - initialize the NodeOperation's and ExecutionGroup's
+ * - schedule the output ExecutionGroup's based on their priority
+ * - deinitialize the ExecutionGroup's and NodeOperation's
+ */
+ 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);
+
+ /**
+ * @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->context;}
+
+ /**
+ * @brief get the reference to the compositor nodes
+ */
+ vector<Node*>& getNodes() {return this->nodes;}
+
+ /**
+ * @brief get the reference to the compositor connections
+ */
+ vector<SocketConnection*>& getConnections() {return this->connections;}
+
+ /**
+ * @brief get the reference to the list of execution groups
+ */
+ vector<ExecutionGroup*>& getExecutionGroups() {return this->groups;}
+
+ /**
+ * @brief get the reference to the list of operations
+ */
+ vector<NodeOperation*>& getOperations() {return this->operations;}
+
+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);
+
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
new file mode 100644
index 00000000000..d6b03b41105
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
@@ -0,0 +1,310 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ExecutionSystemHelper.h"
+
+#include "PIL_time.h"
+#include "BKE_node.h"
+#include "COM_Converter.h"
+#include <sstream>
+#include "COM_NodeOperation.h"
+#include "COM_ExecutionGroup.h"
+#include "COM_NodeBase.h"
+#include "COM_WorkScheduler.h"
+#include "COM_ReadBufferOperation.h"
+#include "COM_MemoryManager.h"
+#include "stdio.h"
+#include "COM_GroupNode.h"
+#include "COM_WriteBufferOperation.h"
+#include "COM_ReadBufferOperation.h"
+
+Node* ExecutionSystemHelper::addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree *tree) {
+ vector<Node*>& nodes = system.getNodes();
+ vector<SocketConnection*>& links = system.getConnections();
+ Node* mainnode = NULL;
+ /* add all nodes of the tree to the node list */
+ bNode* node = (bNode*)tree->nodes.first;
+ while (node != NULL) {
+ Node* execnode = addNode(nodes, node);
+ if (node->type == CMP_NODE_COMPOSITE) {
+ mainnode = execnode;
+ }
+ node = (bNode*)node->next;
+ }
+
+ NodeRange node_range(nodes.begin()+nodes_start, nodes.end());
+
+ /* add all nodelinks of the tree to the link list */
+ bNodeLink* nodelink = (bNodeLink*)tree->links.first;
+ while (nodelink != NULL) {
+ addNodeLink(node_range, links, nodelink);
+ nodelink = (bNodeLink*)nodelink->next;
+ }
+
+ /* Expand group nodes */
+ for (int i=nodes_start; i < nodes.size(); ++i) {
+ Node *execnode = nodes[i];
+ if (execnode->isGroupNode()) {
+ GroupNode * groupNode = (GroupNode*)execnode;
+ groupNode->ungroup(system);
+ }
+ }
+
+ return mainnode;
+}
+
+void ExecutionSystemHelper::addNode(vector<Node*>& nodes, Node *node) {
+ nodes.push_back(node);
+}
+
+Node* ExecutionSystemHelper::addNode(vector<Node*>& nodes, bNode *bNode) {
+ Converter converter;
+ Node * node;
+ node = converter.convert(bNode);
+ if (node != NULL) {
+ addNode(nodes, node);
+ return node;
+ }
+ return NULL;
+}
+void ExecutionSystemHelper::addOperation(vector<NodeOperation*>& operations, NodeOperation *operation) {
+ operations.push_back(operation);
+}
+
+void ExecutionSystemHelper::addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup) {
+ executionGroups.push_back(executionGroup);
+}
+
+void ExecutionSystemHelper::findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations, bool rendering) {
+ unsigned int index;
+
+ for (index = 0 ; index < operations.size() ; index ++) {
+ NodeOperation* operation = operations[index];
+ if (operation->isOutputOperation(rendering)) {
+ result->push_back(operation);
+ }
+ }
+}
+
+static InputSocket* find_input(NodeRange &node_range, bNode *bnode, bNodeSocket* bsocket) {
+ if (bnode != NULL) {
+ for(NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ Node* node = *it;
+ if (node->getbNode() == bnode)
+ return node->findInputSocketBybNodeSocket(bsocket);
+ }
+ } else {
+ for(NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ Node* node = *it;
+ if (node->isProxyNode()) {
+ InputSocket *proxySocket = node->getInputSocket(0);
+ if (proxySocket->getbNodeSocket()==bsocket)
+ return proxySocket;
+ }
+ }
+ }
+ return NULL;
+}
+static OutputSocket* find_output(NodeRange &node_range, bNode *bnode, bNodeSocket* bsocket) {
+ if (bnode != NULL) {
+ for(NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ Node* node = *it;
+ if (node->getbNode() == bnode)
+ return node->findOutputSocketBybNodeSocket(bsocket);
+ }
+ } else {
+ for(NodeIterator it=node_range.first; it!=node_range.second; ++it) {
+ Node* node = *it;
+ if (node->isProxyNode()) {
+ OutputSocket *proxySocket = node->getOutputSocket(0);
+ if (proxySocket->getbNodeSocket()==bsocket)
+ return proxySocket;
+ }
+ }
+ }
+ return NULL;
+}
+SocketConnection* ExecutionSystemHelper::addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink) {
+ /// @note: cyclic lines will be ignored. This has been copied from node.c
+ if (bNodeLink->tonode != 0 && bNodeLink->fromnode != 0) {
+ if(!(bNodeLink->fromnode->level >= bNodeLink->tonode->level && bNodeLink->tonode->level!=0xFFF)) { // only add non cyclic lines! so execution will procede
+ return NULL;
+ }
+ }
+
+ InputSocket *inputSocket = find_input(node_range, bNodeLink->tonode, bNodeLink->tosock);
+ OutputSocket *outputSocket = find_output(node_range, bNodeLink->fromnode, bNodeLink->fromsock);
+ if (inputSocket == NULL || outputSocket == NULL) {
+ return NULL;
+ }
+ if (inputSocket->isConnected()) {
+ return NULL;
+ }
+ SocketConnection* connection = addLink(links, outputSocket, inputSocket);
+ return connection;
+}
+
+SocketConnection* ExecutionSystemHelper::addLink(vector<SocketConnection*>& links, OutputSocket* fromSocket, InputSocket* toSocket) {
+ SocketConnection * newconnection = new SocketConnection();
+ newconnection->setFromSocket(fromSocket);
+ newconnection->setToSocket(toSocket);
+ fromSocket->addConnection(newconnection);
+ toSocket->setConnection(newconnection);
+ links.push_back(newconnection);
+ return newconnection;
+}
+
+void ExecutionSystemHelper::debugDump(ExecutionSystem* system) {
+ Node* node;
+ NodeOperation* operation;
+ ExecutionGroup* group;
+ SocketConnection* connection;
+ int tot, tot2;
+ printf("-- BEGIN COMPOSITOR DUMP --\r\n");
+ printf("digraph compositorexecution {\r\n");
+ tot = system->getNodes().size();
+ for (int i = 0 ; i < tot ; i ++) {
+ node = system->getNodes()[i];
+ printf("// NODE: %s\r\n", node->getbNode()->typeinfo->name);
+ }
+ tot = system->getOperations().size();
+ for (int i = 0 ; i < tot ; i ++) {
+ operation = system->getOperations()[i];
+ printf("// OPERATION: %p\r\n", operation);
+ printf("\t\"O_%p\"", operation);
+ printf(" [shape=record,label=\"{");
+ tot2 = operation->getNumberOfInputSockets();
+ if (tot2 != 0) {
+ printf("{");
+ for (int j = 0 ; j < tot2 ; j ++) {
+ InputSocket *socket = operation->getInputSocket(j);
+ if (j != 0) {
+ printf("|");
+ }
+ printf("<IN_%p>", socket);
+ switch (socket->getActualDataType()) {
+ case COM_DT_VALUE:
+ printf("Value");
+ break;
+ case COM_DT_VECTOR:
+ printf("Vector");
+ break;
+ case COM_DT_COLOR:
+ printf("Color");
+ break;
+ case COM_DT_UNKNOWN:
+ printf("Unknown");
+ break;
+ }
+ }
+ printf("}");
+ printf("|");
+ }
+ if (operation->isViewerOperation()) {
+ printf("Viewer");
+ } else if (operation->isOutputOperation(system->getContext().isRendering())) {
+ printf("Output");
+ } else if (operation->isSetOperation()) {
+ printf("Set");
+ } else if (operation->isReadBufferOperation()) {
+ printf("ReadBuffer");
+ } else if (operation->isWriteBufferOperation()) {
+ printf("WriteBuffer");
+ } else {
+ printf("O_%p", operation);
+ }
+ tot2 = operation->getNumberOfOutputSockets();
+ if (tot2 != 0) {
+ printf("|");
+ printf("{");
+ for (int j = 0 ; j < tot2 ; j ++) {
+ OutputSocket *socket = operation->getOutputSocket(j);
+ if (j != 0) {
+ printf("|");
+ }
+ printf("<OUT_%p>", socket);
+ switch (socket->getActualDataType()) {
+ case COM_DT_VALUE:
+ printf("Value");
+ break;
+ case COM_DT_VECTOR:
+ printf("Vector");
+ break;
+ case COM_DT_COLOR:
+ printf("Color");
+ break;
+ case COM_DT_UNKNOWN:
+ printf("Unknown");
+ break;
+ }
+ }
+ printf("}");
+ }
+ printf("}\"]");
+ printf("\r\n");
+ }
+ tot = system->getExecutionGroups().size();
+ for (int i = 0 ; i < tot ; i ++) {
+ group = system->getExecutionGroups()[i];
+ printf("// GROUP: %d\r\n", i);
+ printf("subgraph {\r\n");
+ printf("// OUTPUTOPERATION: %p\r\n", group->getOutputNodeOperation());
+ printf(" O_%p\r\n", group->getOutputNodeOperation());
+ printf("}\r\n");
+ }
+ tot = system->getOperations().size();
+ for (int i = 0 ; i < tot ; i ++) {
+ operation = system->getOperations()[i];
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation * read = (ReadBufferOperation*)operation;
+ WriteBufferOperation * write= read->getMemoryProxy()->getWriteBufferOperation();
+ printf("\t\"O_%p\" -> \"O_%p\" [style=dotted]\r\n", write, read);
+ }
+ }
+ tot = system->getConnections().size();
+ for (int i = 0 ; i < tot ; i ++) {
+ connection = system->getConnections()[i];
+ printf("// CONNECTION: %p.%p -> %p.%p\r\n", connection->getFromNode(), connection->getFromSocket(), connection->getToNode(), connection->getToSocket());
+ printf("\t\"O_%p\":\"OUT_%p\" -> \"O_%p\":\"IN_%p\"", connection->getFromNode(), connection->getFromSocket(), connection->getToNode(), connection->getToSocket());
+ if (!connection->isValid()) {
+ printf(" [color=red]");
+ } else {
+ switch (connection->getFromSocket()->getActualDataType()) {
+ case COM_DT_VALUE:
+ printf(" [color=grey]");
+ break;
+ case COM_DT_VECTOR:
+ printf(" [color=blue]");
+ break;
+ case COM_DT_COLOR:
+ printf(" [color=orange]");
+ break;
+ case COM_DT_UNKNOWN:
+ printf(" [color=black]");
+ break;
+ }
+ }
+ printf("\r\n");
+ }
+ printf("}\r\n");
+ printf("-- END COMPOSITOR DUMP --\r\n");
+}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystemHelper.h b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
new file mode 100644
index 00000000000..e6b11c4043f
--- /dev/null
+++ b/source/blender/compositor/intern/COM_ExecutionSystemHelper.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class ExecutionGroup;
+
+#ifndef _COM_ExecutionSystemHelper_h
+#define _COM_ExecutionSystemHelper_h
+
+#include "DNA_node_types.h"
+#include <vector>
+#include "COM_Node.h"
+#include "COM_SocketConnection.h"
+#include "BKE_text.h"
+#include "COM_ExecutionGroup.h"
+
+using namespace std;
+
+/**
+ *
+ */
+class ExecutionSystemHelper {
+
+public:
+
+ /**
+ * @brief add an bNodeTree to the nodes list and connections
+ * @param system Execution system
+ * @param nodes_start Starting index in the system's nodes list for nodes in this tree.
+ * @param tree bNodeTree to add
+ * @return Node representing the "Compositor node" of the maintree. or NULL when a subtree is added
+ */
+ static Node* addbNodeTree(ExecutionSystem &system, int nodes_start, bNodeTree * tree);
+
+ /**
+ * @brief add an editor node to the system.
+ * this node is converted to a Node instance.
+ * and the converted node is returned
+ *
+ * @param bNode node to add
+ * @return Node that represents the bNode or null when not able to convert.
+ */
+ static Node* addNode(vector<Node*>& nodes, bNode* bNode);
+
+ /**
+ * @brief Add a Node to a list
+ *
+ * @param nodes the list where the node needs to be added to
+ * @param node the node to be added
+ */
+ static void addNode(vector<Node*>& nodes, Node* node);
+
+ /**
+ * @brief Add an operation to the operation list
+ *
+ * The id of the operation is updated.
+ *
+ * @param operations the list where the operation need to be added to
+ * @param operation the operation to add
+ */
+ static void addOperation(vector<NodeOperation*> &operations, NodeOperation* operation);
+
+ /**
+ * @brief Add an ExecutionGroup to a list
+ *
+ * The id of the ExecutionGroup is updated.
+ *
+ * @param executionGroups the list where the executionGroup need to be added to
+ * @param executionGroup the ExecutionGroup to add
+ */
+ static void addExecutionGroup(vector<ExecutionGroup*>& executionGroups, ExecutionGroup *executionGroup);
+
+ /**
+ * Find all Node Operations that needs to be executed.
+ * @param rendering
+ * the rendering parameter will tell what type of execution we are doing
+ * FALSE is editing, TRUE is rendering
+ */
+ static void findOutputNodeOperations(vector<NodeOperation*>* result, vector<NodeOperation*>& operations , bool rendering);
+
+ /**
+ * @brief add a bNodeLink to the list of links
+ * the bNodeLink will be wrapped in a SocketConnection
+ *
+ * @note Cyclic links will be ignored
+ *
+ * @param node_range list of possible nodes for lookup.
+ * @param links list of links to add the bNodeLink to
+ * @param bNodeLink the link to be added
+ * @return the created SocketConnection or NULL
+ */
+ static SocketConnection* addNodeLink(NodeRange &node_range, vector<SocketConnection*>& links, bNodeLink *bNodeLink);
+
+ /**
+ * @brief create a new SocketConnection and add to a vector of links
+ * @param links the vector of links
+ * @param fromSocket the startpoint of the connection
+ * @param toSocket the endpoint of the connection
+ * @return the new created SocketConnection
+ */
+ static SocketConnection* addLink(vector<SocketConnection*>& links, OutputSocket* fromSocket, InputSocket* toSocket);
+
+ /**
+ * @brief dumps the content of the execution system to standard out
+ * @param system the execution system to dump
+ */
+ static void debugDump(ExecutionSystem* system);
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_InputSocket.cpp b/source/blender/compositor/intern/COM_InputSocket.cpp
new file mode 100644
index 00000000000..9596d5b73b0
--- /dev/null
+++ b/source/blender/compositor/intern/COM_InputSocket.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Socket.h"
+#include "COM_Node.h"
+#include "COM_SocketConnection.h"
+#include "COM_ExecutionSystem.h"
+
+InputSocket::InputSocket(DataType datatype) :Socket(datatype) {
+ this->connection = NULL;
+ this->resizeMode = COM_SC_CENTER;
+}
+InputSocket::InputSocket(DataType datatype, InputSocketResizeMode resizeMode) :Socket(datatype) {
+ this->connection = NULL;
+ this->resizeMode = resizeMode;
+}
+
+InputSocket::InputSocket(InputSocket* from) :Socket(from->getDataType()) {
+ this->connection = NULL;
+ this->resizeMode = from->getResizeMode();
+}
+
+int InputSocket::isInputSocket() const { return true; }
+const int InputSocket::isConnected() const { return this->connection != NULL; }
+
+void InputSocket::setConnection(SocketConnection *connection) {
+ this->connection = connection;
+}
+SocketConnection* InputSocket::getConnection() {return this->connection;}
+
+void InputSocket::determineResolution(unsigned int resolution[],unsigned int preferredResolution[]) {
+ if (this->isConnected()){
+ this->connection->getFromSocket()->determineResolution(resolution, preferredResolution);
+ } else {
+ return;
+ }
+}
+
+DataType InputSocket::convertToSupportedDataType(DataType datatype) {
+ int supportedDataTypes = getDataType();
+ if (supportedDataTypes&datatype) {
+ return datatype;
+ }
+ bool candoValue = supportedDataTypes&COM_DT_VALUE;
+ bool candoVector = supportedDataTypes&COM_DT_VECTOR;
+ bool candoColor = supportedDataTypes&COM_DT_COLOR;
+
+ if (datatype == COM_DT_VALUE) {
+ if (candoColor) {
+ return COM_DT_COLOR;
+ } else if (candoVector) {
+ return COM_DT_VECTOR;
+ }
+ } else if (datatype == COM_DT_VECTOR) {
+ if (candoColor) {
+ return COM_DT_COLOR;
+ } else if (candoValue) {
+ return COM_DT_VALUE;
+ }
+ } else if (datatype == COM_DT_COLOR) {
+ if (candoVector) {
+ return COM_DT_VECTOR;
+ } else if (candoValue) {
+ return COM_DT_VALUE;
+ }
+ }
+ return this->getDataType();
+}
+
+void InputSocket::determineActualDataType() {
+ /// @note: this method is only called for inputsocket that are not connected.
+ /// @note: passes COM_DT_COLOR, the convertToSupportedDataType converts this to a capable DataType
+ this->setActualDataType(this->convertToSupportedDataType(COM_DT_COLOR));
+ #if 0 // XXX TODO check for proxy node and use output data type?
+ if (this->getGroupOutputSocket()) {
+ if (!this->isInsideOfGroupNode()) {
+ this->getGroupOutputSocket()->determineActualDataType();
+ }
+ }
+ #endif
+}
+
+void InputSocket::notifyActualInputType(DataType datatype) {
+ DataType supportedDataType = convertToSupportedDataType(datatype);
+ this->setActualDataType(supportedDataType);
+ this->fireActualDataTypeSet();
+}
+
+void InputSocket::fireActualDataTypeSet() {
+ this->getNode()->notifyActualDataTypeSet(this, this->getActualDataType());
+}
+void InputSocket::relinkConnections(InputSocket *relinkToSocket) {
+ this->relinkConnections(relinkToSocket, false, -1, NULL);
+}
+
+void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem* graph) {
+ if (!duplicate) {
+ this->relinkConnections(relinkToSocket, autoconnect, editorNodeInputSocketIndex, graph);
+ } else {
+ if (!this->isConnected() && autoconnect) {
+ Node* node = (Node*)this->getNode();
+ switch (this->getActualDataType()) {
+ case COM_DT_UNKNOWN:
+ case COM_DT_COLOR:
+ node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VECTOR:
+ node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VALUE:
+ node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ }
+ return;
+ }
+ SocketConnection * newConnection = new SocketConnection();
+ OutputSocket * fromSocket = this->getConnection()->getFromSocket();
+ newConnection->setToSocket(relinkToSocket);
+ newConnection->setFromSocket(fromSocket);
+ relinkToSocket->setConnection(newConnection);
+ fromSocket->addConnection(newConnection);
+ graph->addSocketConnection(newConnection);
+ }
+}
+
+void InputSocket::relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem* graph) {
+ if (!isConnected()) {
+ if (autoconnect) {
+ Node* node = (Node*)this->getNode();
+ switch (this->getActualDataType()) {
+ case COM_DT_UNKNOWN:
+ case COM_DT_COLOR:
+ node->addSetColorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VECTOR:
+ node->addSetVectorOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ case COM_DT_VALUE:
+ node->addSetValueOperation(graph, relinkToSocket, editorNodeInputSocketIndex);
+ break;
+ }
+ }
+ return;
+ }
+ SocketConnection *connection = this->getConnection();
+ connection->setToSocket(relinkToSocket);
+ relinkToSocket->setConnection(connection);
+ this->setConnection(NULL);
+}
+
+const ChannelInfo* InputSocket::getChannelInfo(const int channelnumber) {
+ if (this->isConnected() && this->connection->getFromSocket()) {
+ return this->connection->getFromSocket()->getChannelInfo(channelnumber);
+ } else {
+ return NULL;
+ }
+}
+
+bool InputSocket::isStatic() {
+ if (isConnected()) {
+ NodeBase* node = this->getConnection()->getFromNode();
+ if (node) {
+ return node->isStatic();
+ }
+ }
+ return true;
+}
+SocketReader* InputSocket::getReader() {
+ return this->getOperation();
+}
+
+NodeOperation* InputSocket::getOperation() const {
+ if (isConnected()) {
+ return (NodeOperation*)this->connection->getFromSocket()->getNode();
+ } else {
+ return NULL;
+ }
+}
+
+float* InputSocket::getStaticValues() {
+ /* XXX only works for socket types with actual float input values.
+ * currently all compositor socket types (value, rgba, vector) support this.
+ */
+ bNodeSocket *b_socket = this->getbNodeSocket();
+ static float default_null = 0.0f;
+
+ switch (this->getDataType()) {
+ case COM_DT_VALUE:
+ return &((bNodeSocketValueFloat*)b_socket->default_value)->value;
+ case COM_DT_COLOR:
+ return ((bNodeSocketValueRGBA*)b_socket->default_value)->value;
+ case COM_DT_VECTOR:
+ return ((bNodeSocketValueVector*)b_socket->default_value)->value;
+ default:
+ /* XXX this should never happen, just added to please the compiler */
+ return &default_null;
+ }
+}
diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h
new file mode 100644
index 00000000000..340cfa98ef6
--- /dev/null
+++ b/source/blender/compositor/intern/COM_InputSocket.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_InputSocket_h
+#define _COM_InputSocket_h
+
+#include <vector>
+#include "COM_Socket.h"
+#include "COM_SocketReader.h"
+
+using namespace std;
+class SocketConnection;
+class Node;
+class ExecutionSystem;
+class OutputSocket;
+class ChannelInfo;
+class NodeOperation;
+
+/**
+ * @brief Resize modes of inputsockets
+ * How are the input and working resolutions matched
+ * @ingroup Model
+ */
+typedef enum InputSocketResizeMode {
+ /** @brief Center the input image to the center of the working area of the node, no resizing occurs */
+ COM_SC_CENTER = NS_CR_CENTER,
+ /** @brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
+ COM_SC_NO_RESIZE = NS_CR_NONE,
+ /** @brief Fit the width of the input image to the width of the working area of the node */
+ COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
+ /** @brief Fit the height of the input image to the height of the working area of the node */
+ COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
+ /** @brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
+ COM_SC_FIT = NS_CR_FIT,
+ /** @brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
+ COM_SC_STRETCH = NS_CR_STRETCH
+} InputSocketResizeMode;
+
+/**
+ * @brief InputSocket are sockets that can receive data/input
+ * @ingroup Model
+ */
+class InputSocket : public Socket {
+private:
+ /**
+ * @brief connection connected to this InputSocket.
+ * An input socket can only have a single connection
+ */
+ SocketConnection* connection;
+
+ /**
+ * @brief resize mode of this socket
+ */
+ InputSocketResizeMode resizeMode;
+
+
+ /**
+ * @brief convert a data type to a by the socket supported data type.
+ *
+ * @param datatype the datatype that needs to be checked
+ * @section data-conversion
+ */
+ DataType convertToSupportedDataType(DataType datatype);
+
+ /**
+ * @brief called when the ActualDataType is set. notifies other parties
+ */
+ void fireActualDataTypeSet();
+
+public:
+ InputSocket(DataType datatype);
+ InputSocket(DataType datatype, InputSocketResizeMode resizeMode);
+ InputSocket(InputSocket* from);
+
+ void setConnection(SocketConnection* connection);
+ SocketConnection* getConnection();
+
+ const int isConnected() const;
+ int isInputSocket() const;
+
+ /**
+ * @brief determine the resolution of this data going through this socket
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[],unsigned int preferredResolution[]);
+
+ void determineActualDataType();
+
+ /**
+ * @brief Notifies the Input of the data type (via a SocketConnection)
+ * @param datatype the datatype to evaluate
+ */
+ void notifyActualInputType(DataType datatype);
+
+ /**
+ * @brief move all connections of this input socket to another socket
+ * only use this method when already checked the availability of a SocketConnection
+ * @param relinkToSocket the socket to move to connections to
+ */
+ void relinkConnections(InputSocket *relinkToSocket);
+
+ /**
+ * @brief move all connections of this input socket to another socket
+ * @param relinkToSocket the socket to move to connections to
+ * @param autoconnect will a set operation be added when no connections exist
+ * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
+ * @param system ExecutionSystem to update to
+ */
+ void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, ExecutionSystem* system);
+
+ /**
+ * @brief move all connections of this input socket to another socket
+ * @param relinkToSocket the socket to move to connections to
+ * @param autoconnect will a set operation be added when no connections exist
+ * @param editorNodeInputSocketIndex index of the socket number of the bNode (used to retrieve the value for autoconnection)
+ * @param duplicate instead of move do a copy of the connection.
+ * @param system ExecutionSystem to update to
+ */
+ void relinkConnections(InputSocket *relinkToSocket, bool autoconnect, int editorNodeInputSocketIndex, bool duplicate, ExecutionSystem* system);
+
+ /**
+ * @brief set the resize mode
+ * @param resizeMode the new resize mode.
+ */
+ void setResizeMode(InputSocketResizeMode resizeMode) {this->resizeMode = resizeMode;}
+
+ /**
+ * @brief get the resize mode of this socket
+ * @return InputSocketResizeMode
+ */
+ InputSocketResizeMode getResizeMode() const {return this->resizeMode;}
+
+ const ChannelInfo* getChannelInfo(const int channelnumber);
+
+ bool isStatic();
+
+ float* getStaticValues();
+ SocketReader* getReader();
+ NodeOperation* getOperation() const;
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
new file mode 100644
index 00000000000..53357b8ec50
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -0,0 +1,338 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MemoryBuffer.h"
+#include "MEM_guardedalloc.h"
+#include "BLI_math.h"
+#include "BKE_global.h"
+
+unsigned int MemoryBuffer::determineBufferSize() {
+ return getWidth() * getHeight();
+}
+
+int MemoryBuffer::getWidth() const {
+ return this->rect.xmax-this->rect.xmin;
+}
+int MemoryBuffer::getHeight() const {
+ return this->rect.ymax-this->rect.ymin;
+}
+
+MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, unsigned int chunkNumber, rcti* rect) {
+ BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->memoryProxy = memoryProxy;
+ this->chunkNumber = chunkNumber;
+ this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
+ this->state = COM_MB_ALLOCATED;
+ this->datatype = COM_DT_COLOR;
+ this->chunkWidth = this->rect.xmax - this->rect.xmin;
+}
+
+MemoryBuffer::MemoryBuffer(MemoryProxy * memoryProxy, rcti* rect) {
+ BLI_init_rcti(&this->rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->memoryProxy = memoryProxy;
+ this->chunkNumber = -1;
+ this->buffer = (float*)MEM_mallocN(sizeof(float)*determineBufferSize()*4, "COM_MemoryBuffer");
+ this->state = COM_MB_TEMPORARILY;
+ this->datatype = COM_DT_COLOR;
+ this->chunkWidth = this->rect.xmax - this->rect.xmin;
+}
+MemoryBuffer* MemoryBuffer::duplicate() {
+ MemoryBuffer *result = new MemoryBuffer(this->memoryProxy, &this->rect);
+ memcpy(result->buffer, this->buffer, this->determineBufferSize()*4*sizeof(float));
+ return result;
+}
+void MemoryBuffer::clear() {
+ memset(this->buffer, 0, this->determineBufferSize()*4*sizeof(float));
+}
+
+float* MemoryBuffer::convertToValueBuffer() {
+ int size = this->determineBufferSize();
+ int i;
+ int offset4;
+ float* result = new float[size];
+ for (i = 0, offset4 = 0 ; i < size ; i ++, offset4 +=4) {
+ result[i] = this->buffer[offset4];
+ }
+
+ return result;
+}
+
+MemoryBuffer::~MemoryBuffer() {
+ if (this->buffer) {
+ MEM_freeN(this->buffer);
+ this->buffer = NULL;
+ }
+}
+
+void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer) {
+ if (!otherBuffer) {
+ return;
+ }
+ unsigned int otherY;
+ unsigned int minX = max(this->rect.xmin, otherBuffer->rect.xmin);
+ unsigned int maxX = min(this->rect.xmax, otherBuffer->rect.xmax);
+ unsigned int minY = max(this->rect.ymin, otherBuffer->rect.ymin);
+ unsigned int maxY = min(this->rect.ymax, otherBuffer->rect.ymax);
+ int offset;
+ int otherOffset;
+
+
+ for (otherY = minY ; otherY<maxY ; otherY ++) {
+ otherOffset = ((otherY-otherBuffer->rect.ymin) * otherBuffer->chunkWidth + minX-otherBuffer->rect.xmin)*4;
+ offset = ((otherY - this->rect.ymin) * this->chunkWidth + minX-this->rect.xmin)*4;
+ memcpy(&this->buffer[offset], &otherBuffer->buffer[otherOffset], (maxX-minX) * 4*sizeof(float));
+ }
+}
+
+void MemoryBuffer::read(float* result, int x, int y) {
+ if (x>=this->rect.xmin && x < this->rect.xmax &&
+ y>=this->rect.ymin && y < this->rect.ymax) {
+ int dx = x-this->rect.xmin;
+ int dy = y-this->rect.ymin;
+ int offset = (this->chunkWidth*dy+dx)*4;
+ result[0] = this->buffer[offset];
+ result[1] = this->buffer[offset+1];
+ result[2] = this->buffer[offset+2];
+ result[3] = this->buffer[offset+3];
+ }
+ else {
+ result[0] = 0.0f;
+ result[1] = 0.0f;
+ result[2] = 0.0f;
+ result[3] = 0.0f;
+ }
+}
+void MemoryBuffer::writePixel(int x, int y, float color[4]) {
+ if (x>=this->rect.xmin && x < this->rect.xmax &&
+ y>=this->rect.ymin && y < this->rect.ymax) {
+ int offset = (this->chunkWidth*y+x)*4;
+ this->buffer[offset] = color[0];
+ this->buffer[offset+1] = color[1];
+ this->buffer[offset+2] = color[2];
+ this->buffer[offset+3] = color[3];
+ }
+}
+
+void MemoryBuffer::readCubic(float* result, float x, float y) {
+ int x1 = floor(x);
+ int x2 = x1 + 1;
+ int y1 = floor(y);
+ int y2 = y1 + 1;
+
+ float valuex = x - x1;
+ float valuey = y - y1;
+ float mvaluex = 1.0 - valuex;
+ float mvaluey = 1.0 - valuey;
+
+ float color1[4];
+ float color2[4];
+ float color3[4];
+ float color4[4];
+
+ read(color1, x1, y1);
+ read(color2, x1, y2);
+ read(color3, x2, y1);
+ read(color4, x2, y2);
+
+ color1[0] = color1[0]*mvaluey + color2[0]*valuey;
+ color1[1] = color1[1]*mvaluey + color2[1]*valuey;
+ color1[2] = color1[2]*mvaluey + color2[2]*valuey;
+ color1[3] = color1[3]*mvaluey + color2[3]*valuey;
+
+ color3[0] = color3[0]*mvaluey + color4[0]*valuey;
+ color3[1] = color3[1]*mvaluey + color4[1]*valuey;
+ color3[2] = color3[2]*mvaluey + color4[2]*valuey;
+ color3[3] = color3[3]*mvaluey + color4[3]*valuey;
+
+ result[0] = color1[0]*mvaluex + color3[0]*valuex;
+ result[1] = color1[1]*mvaluex + color3[1]*valuex;
+ result[2] = color1[2]*mvaluex + color3[2]*valuex;
+ result[3] = color1[3]*mvaluex + color3[3]*valuex;
+}
+
+
+// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
+// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible
+#define EWA_MAXIDX 255
+static float EWA_WTS[EWA_MAXIDX + 1] =
+{ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
+ 0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
+ 0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,
+ 0.794079f, 0.786653f, 0.779284f, 0.771974f, 0.76472f, 0.757523f, 0.750382f, 0.743297f,
+ 0.736267f, 0.729292f, 0.722372f, 0.715505f, 0.708693f, 0.701933f, 0.695227f, 0.688572f,
+ 0.68197f, 0.67542f, 0.66892f, 0.662471f, 0.656073f, 0.649725f, 0.643426f, 0.637176f,
+ 0.630976f, 0.624824f, 0.618719f, 0.612663f, 0.606654f, 0.600691f, 0.594776f, 0.588906f,
+ 0.583083f, 0.577305f, 0.571572f, 0.565883f, 0.56024f, 0.55464f, 0.549084f, 0.543572f,
+ 0.538102f, 0.532676f, 0.527291f, 0.521949f, 0.516649f, 0.511389f, 0.506171f, 0.500994f,
+ 0.495857f, 0.490761f, 0.485704f, 0.480687f, 0.475709f, 0.470769f, 0.465869f, 0.461006f,
+ 0.456182f, 0.451395f, 0.446646f, 0.441934f, 0.437258f, 0.432619f, 0.428017f, 0.42345f,
+ 0.418919f, 0.414424f, 0.409963f, 0.405538f, 0.401147f, 0.39679f, 0.392467f, 0.388178f,
+ 0.383923f, 0.379701f, 0.375511f, 0.371355f, 0.367231f, 0.363139f, 0.359079f, 0.355051f,
+ 0.351055f, 0.347089f, 0.343155f, 0.339251f, 0.335378f, 0.331535f, 0.327722f, 0.323939f,
+ 0.320186f, 0.316461f, 0.312766f, 0.3091f, 0.305462f, 0.301853f, 0.298272f, 0.294719f,
+ 0.291194f, 0.287696f, 0.284226f, 0.280782f, 0.277366f, 0.273976f, 0.270613f, 0.267276f,
+ 0.263965f, 0.26068f, 0.257421f, 0.254187f, 0.250979f, 0.247795f, 0.244636f, 0.241502f,
+ 0.238393f, 0.235308f, 0.232246f, 0.229209f, 0.226196f, 0.223206f, 0.220239f, 0.217296f,
+ 0.214375f, 0.211478f, 0.208603f, 0.20575f, 0.20292f, 0.200112f, 0.197326f, 0.194562f,
+ 0.191819f, 0.189097f, 0.186397f, 0.183718f, 0.18106f, 0.178423f, 0.175806f, 0.17321f,
+ 0.170634f, 0.168078f, 0.165542f, 0.163026f, 0.16053f, 0.158053f, 0.155595f, 0.153157f,
+ 0.150738f, 0.148337f, 0.145955f, 0.143592f, 0.141248f, 0.138921f, 0.136613f, 0.134323f,
+ 0.132051f, 0.129797f, 0.12756f, 0.125341f, 0.123139f, 0.120954f, 0.118786f, 0.116635f,
+ 0.114501f, 0.112384f, 0.110283f, 0.108199f, 0.106131f, 0.104079f, 0.102043f, 0.100023f,
+ 0.0980186f, 0.09603f, 0.094057f, 0.0920994f, 0.0901571f, 0.08823f, 0.0863179f, 0.0844208f,
+ 0.0825384f, 0.0806708f, 0.0788178f, 0.0769792f, 0.0751551f, 0.0733451f, 0.0715493f, 0.0697676f,
+ 0.0679997f, 0.0662457f, 0.0645054f, 0.0627786f, 0.0610654f, 0.0593655f, 0.0576789f, 0.0560055f,
+ 0.0543452f, 0.0526979f, 0.0510634f, 0.0494416f, 0.0478326f, 0.0462361f, 0.0446521f, 0.0430805f,
+ 0.0415211f, 0.039974f, 0.0384389f, 0.0369158f, 0.0354046f, 0.0339052f, 0.0324175f, 0.0309415f,
+ 0.029477f, 0.0280239f, 0.0265822f, 0.0251517f, 0.0237324f, 0.0223242f, 0.020927f, 0.0195408f,
+ 0.0181653f, 0.0168006f, 0.0154466f, 0.0141031f, 0.0127701f, 0.0114476f, 0.0101354f, 0.00883339f,
+ 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
+};
+
+static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F)
+{
+ float ct2 = cosf(th);
+ const float st2 = 1.f - ct2*ct2; // <- sin(th)^2
+ ct2 *= ct2;
+ *A = a2*st2 + b2*ct2;
+ *B = (b2 - a2)*sinf(2.f*th);
+ *C = a2*ct2 + b2*st2;
+ *F = a2*b2;
+}
+
+// all tests here are done to make sure possible overflows are hopefully minimized
+static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc)
+{
+ if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity
+ *a = sqrtf(A > C ? A : C);
+ *b = 0.f;
+ *ecc = 1e10f;
+ *th = 0.5f*(atan2f(B, A - C) + (float)M_PI);
+ }
+ else {
+ const float AmC = A - C, ApC = A + C, F2 = F*2.f;
+ const float r = sqrtf(AmC*AmC + B*B);
+ float d = ApC - r;
+ *a = (d <= 0.f) ? sqrtf(A > C ? A : C) : sqrtf(F2 / d);
+ d = ApC + r;
+ if (d <= 0.f) {
+ *b = 0.f;
+ *ecc = 1e10f;
+ }
+ else {
+ *b = sqrtf(F2 / d);
+ *ecc = *a / *b;
+ }
+ // incr theta by 0.5*pi (angle of major axis)
+ *th = 0.5f*(atan2f(B, AmC) + (float)M_PI);
+ }
+}
+
+float clipuv(float x, float limit){
+ x = (x < 0) ? 0 : ((x >= limit) ? (limit - 1) : x);
+ return x;
+}
+
+void MemoryBuffer::readEWA(float* result, float fx, float fy, float dx, float dy) {
+ int width = this->getWidth(), height = this->getHeight();
+
+ // scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
+ // scaling by aspect ratio alone does the opposite, so try something in between instead...
+ const float ff2 = width, ff = sqrtf(ff2), q = height / ff;
+ const float Ux = dx*ff, Vx = dx*q, Uy = dy*ff, Vy = dy*q;
+ float A = Vx*Vx + Vy*Vy;
+ float B = -2.f*(Ux*Vx + Uy*Vy);
+ float C = Ux*Ux + Uy*Uy;
+ float F = A*C - B*B*0.25f;
+ float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d;
+ int u, v, u1, u2, v1, v2;
+ // The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C,
+ // so the ellipse always covers at least some texels. But since the filter is now always larger,
+ // it also means that everywhere else it's also more blurry then ideally should be the case.
+ // So instead here the ellipse radii are modified instead whenever either is too low.
+ // Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
+ // and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
+ // (minimum values: const float rmin = intpol ? 1.f : 0.5f;)
+ const float rmin = 1.5625f/ff2;
+ imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
+ if ((b2 = b*b) < rmin) {
+ if ((a2 = a*a) < rmin) {
+ B = 0.f;
+ A = C = rmin;
+ F = A*C;
+ }
+ else {
+ b2 = rmin;
+ radangle2imp(a2, b2, th, &A, &B, &C, &F);
+ }
+ }
+
+ ue = ff*sqrtf(C);
+ ve = ff*sqrtf(A);
+ d = (float)(EWA_MAXIDX + 1) / (F*ff2);
+ A *= d;
+ B *= d;
+ C *= d;
+
+ U0 = fx;
+ V0 = fy;
+ u1 = (int)(floorf(U0 - ue));
+ u2 = (int)(ceilf(U0 + ue));
+ v1 = (int)(floorf(V0 - ve));
+ v2 = (int)(ceilf(V0 + ve));
+ U0 -= 0.5f;
+ V0 -= 0.5f;
+ DDQ = 2.f*A;
+ U = u1 - U0;
+ ac1 = A*(2.f*U + 1.f);
+ ac2 = A*U*U;
+ BU = B*U;
+
+ d = result[0] = result[1] = result[2] = result[3] = 0.f;
+ for (v=v1; v<=v2; ++v) {
+ const float V = v - V0;
+ float DQ = ac1 + B*V;
+ float Q = (C*V + BU)*V + ac2;
+ for (u=u1; u<=u2; ++u) {
+ if (Q < (float)(EWA_MAXIDX + 1)) {
+ float tc[4];
+ const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q];
+ read(tc, clipuv(u, width), clipuv(v, height));
+ result[0] += tc[0]*wt;
+ result[1] += tc[1]*wt;
+ result[2] += tc[2]*wt;
+ result[3] += result[3] ? tc[3]*wt : 0.f;
+ d += wt;
+ }
+ Q += DQ;
+ DQ += DDQ;
+ }
+ }
+
+ // d should hopefully never be zero anymore
+ d = 1.f/d;
+ result[0] *= d;
+ result[1] *= d;
+ result[2] *= d;
+ // clipping can be ignored if alpha used, texr->ta already includes filtered edge
+ result[3] = result[3] ? result[3] *d : 1.f;
+}
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
new file mode 100644
index 00000000000..78fb16a7b12
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class MemoryBuffer;
+
+#ifndef _COM_MemoryBuffer_h_
+#define _COM_MemoryBuffer_h_
+
+#include "COM_ExecutionGroup.h"
+#include "BLI_rect.h"
+#include "COM_MemoryProxy.h"
+extern "C" {
+ #include "BLI_threads.h"
+}
+#include <vector>
+
+/**
+ * @brief state of a memory buffer
+ * @ingroup Memory
+ */
+typedef enum MemoryBufferState {
+ /** @brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
+ COM_MB_ALLOCATED = 1,
+ /** @brief memory is available for use, content has been created */
+ COM_MB_AVAILABLE = 2,
+ /** @brief chunk is consolidated from other chunks. special state.*/
+ COM_MB_TEMPORARILY = 6
+} MemoryBufferState;
+
+class MemoryProxy;
+
+/**
+ * @brief a MemoryBuffer contains access to the data of a chunk
+ */
+class MemoryBuffer {
+private:
+ /**
+ * @brief proxy of the memory (same for all chunks in the same buffer)
+ */
+ MemoryProxy * memoryProxy;
+
+ /**
+ * @brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
+ */
+ DataType datatype;
+
+
+ /**
+ * @brief region of this buffer inside reative to the MemoryProxy
+ */
+ rcti rect;
+
+ /**
+ * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
+ * @see memoryProxy
+ */
+ unsigned int chunkNumber;
+
+ /**
+ * @brief width of the chunk
+ */
+ unsigned int chunkWidth;
+
+ /**
+ * @brief state of the buffer
+ */
+ MemoryBufferState state;
+
+ /**
+ * @brief the actual float buffer/data
+ */
+ float* buffer;
+
+public:
+ /**
+ * @brief construct new MemoryBuffer for a chunk
+ */
+ MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti* rect);
+
+ /**
+ * @brief construct new temporarily MemoryBuffer for an area
+ */
+ MemoryBuffer(MemoryProxy *memoryProxy, rcti* rect);
+
+ /**
+ * @brief destructor
+ */
+ ~MemoryBuffer();
+
+ /**
+ * @brief read the ChunkNumber of this MemoryBuffer
+ */
+ unsigned int getChunkNumber() {return this->chunkNumber;}
+
+ /**
+ * @brief get the data of this MemoryBuffer
+ * @note buffer should already be available in memory
+ */
+ float* getBuffer() {return this->buffer;}
+
+ /**
+ * @brief after execution the state will be set to available by calling this method
+ */
+ void setCreatedState() {
+ this->state = COM_MB_AVAILABLE;
+ }
+
+ void read(float* result, int x, int y);
+ void writePixel(int x, int y, float color[4]);
+ void readCubic(float* result, float x, float y);
+ void readEWA(float *result, float fx, float fy, float dx, float dy);
+
+ /**
+ * @brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
+ */
+ inline const bool isTemporarily() const {return this->state == COM_MB_TEMPORARILY;}
+
+ /**
+ * @brief add the content from otherBuffer to this MemoryBuffer
+ * @param otherBuffer source buffer
+ */
+ void copyContentFrom(MemoryBuffer* otherBuffer);
+
+ /**
+ * @brief get the rect of this MemoryBuffer
+ */
+ rcti* getRect() {return &this->rect;}
+
+ /**
+ * @brief get the width of this MemoryBuffer
+ */
+ int getWidth() const;
+
+ /**
+ * @brief get the height of this MemoryBuffer
+ */
+ int getHeight() const;
+
+ /**
+ * @brief clear the buffer. Make all pixels black transparant.
+ */
+ void clear();
+
+ MemoryBuffer* duplicate();
+
+ float* convertToValueBuffer();
+private:
+ unsigned int determineBufferSize();
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_MemoryManager.cpp b/source/blender/compositor/intern/COM_MemoryManager.cpp
new file mode 100644
index 00000000000..fa587e8c7d6
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryManager.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MemoryManager.h"
+#include "BLI_threads.h"
+#include <stdio.h>
+#include "COM_defines.h"
+
+vector<MemoryBuffer*> buffers;
+
+ThreadMutex mutex;
+
+MemoryBuffer* MemoryManager::allocateMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber, rcti *rect) {
+ MemoryBuffer *result = new MemoryBuffer(id, chunkNumber, rect);
+ MemoryManagerState * state = MemoryManager::getState(id);
+ state->addMemoryBuffer(result);
+ BLI_mutex_lock(&mutex);
+ buffers.push_back(result);
+ BLI_mutex_unlock(&mutex);
+ return result;
+}
+
+void MemoryManager::addMemoryProxy(MemoryProxy *memoryProxy) {
+ MemoryManagerState * state = MemoryManager::getState(memoryProxy);
+ if (!state) {
+ state = new MemoryManagerState(memoryProxy);
+ memoryProxy->setState(state);
+ }
+}
+MemoryBuffer* MemoryManager::getMemoryBuffer(MemoryProxy *id, unsigned int chunkNumber){
+ MemoryManagerState * state = MemoryManager::getState(id);
+ if (!state) {
+ return NULL;
+ }
+ MemoryBuffer* buffer = state->getMemoryBuffer(chunkNumber);
+ if (!buffer) return NULL;
+ return buffer;
+}
+
+MemoryManagerState* MemoryManager::getState(MemoryProxy* memoryProxy) {
+ return memoryProxy->getState();
+}
+void MemoryManager::initialize() {
+ BLI_mutex_init(&mutex);
+}
+void MemoryManager::clear() {
+ buffers.clear();
+ BLI_mutex_end(&mutex);
+}
diff --git a/source/blender/compositor/intern/COM_MemoryManager.h b/source/blender/compositor/intern/COM_MemoryManager.h
new file mode 100644
index 00000000000..506bf2a8c24
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryManager.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MemoryManager_h_
+#define _COM_MemoryManager_h_
+
+#include "COM_MemoryBuffer.h"
+#include "COM_MemoryProxy.h"
+#include "COM_ExecutionGroup.h"
+#include "COM_MemoryManagerState.h"
+
+/**
+ * @page memorymanager The Memory Manager
+ * The compositor has its own MemoryManager. The goal of the MemoryManager is to manage the memory allocated by chunks.
+ * During execution new chunks will be created [MemoryManager.allocateMemoryBuffer] When calculation is finished the MemoryBuffer will get the state [MemoryBufferState.COM_MB_AVAILABLE].
+ * From now on other ExecutionGroup and NodeOperations may read from the MemoryBuffer.
+ * The MemoryManager also has the capability to save MemoryBuffer's to disk in order to free some memory.
+ *
+ * @section S_MEM Memory manager
+ * The memory manager synchronize and optimize data across devices.
+ * Only one NodeOperation running on a device is able to write to a MemoryBuffer. This MemoryBuffer is only allocated on the main-device memory (CPU).
+ * The MemoryBuffer.state will be [MemoryBufferState.COM_MB_ALLOCATED]. As soon as the chunk has been executed the state changes to [MemoryBufferState.COM_MB_AVAILABLE]. This MemoryBuffer can now be used as inputBuffer of ExecutionGroup's.
+ * When needed the MemoryBuffer will be stored to a file. This will save memory that can be used by other tiles.
+ * @subsection S_MEM_1 Step one
+ * When a chunk of an ExecutionGroup is being executed by a device, the MemoryBuffer is allocated on the CPU.
+ * <pre>
+ * Allocation of the output MemoryBuffer
+ * +----------------------------------------+
+ * | Main device (CPU) |
+ * | +----------------+ +--------------+ |
+ * | | ExecutionGroup | | MemoryBuffer | |
+ * | | | | Chunk a | |
+ * | +----------------+ +--------------+ |
+ * | |
+ * +----------------------------------------+
+ * </pre>
+ * @see MemoryManager.allocateMemoryBuffer
+ *
+ * @subsection S_MEM_2 Step two
+ * The Device will execute the ExecutionGroup. This differs per type of Device. CPUDevice will call the NodeOperation.executeRegion method of the outputnode of the ExecutionGroup.
+ * The [NodeOperation.executeRegion] writes the result to the allocated MemoryBuffer. When finished the state of the MemoryBuffer will be set to [MemoryBufferState.COM_MB_AVAILABLE].
+ * <pre>
+ * Execute a chunk and store result to the MemoryBuffer
+ * +----------------------------------------+
+ * | Main device (CPU) |
+ * | +----------------+ +--------------+ |
+ * | | ExecutionGroup | | MemoryBuffer | |
+ * | | | | Chunk a | |
+ * | +----------------+ +--------------+ |
+ * | | ^ |
+ * | +----------------+ | |
+ * | | NodeOperation |--------+ |
+ * | | | Write result |
+ * | +----------------+ |
+ * | |
+ * +----------------------------------------+
+ * </pre>
+ * @subsection S_MEM_3 Step 3
+ * Other Chunks that depend on the MemoryBuffer can now use it.
+ * When a MemoryBuffer is being used its number of users are increased. When a 'user' is finished the number of users are decreased, If a MemoryBuffer has no users, the system can decide to store the data to disk and free some memory.
+ * @see MemoryBuffer.numberOfUsers
+ * @see MemoryBuffer.saveToDisk
+ *
+ * @subsection S_MEM_CON Temporarily MemoryBuffers
+ * Nodes like blur nodes can depend on multiple MemoryBuffer of the same MemoryProxy. These multiple buffers will be consolidated temporarily to a new MemoryBuffer.
+ * When execution is finished this temporarily memory buffer is deallicated.
+ * <pre>
+ * Original MemoryBuffer's Temporarily
+ * +-------+ +-------+ MemoryBuffer
+ * | MB A | | MB B | +-------+-------+
+ * +-------+ +-------+ | MB A | MB B |
+ * ==> +-------+-------+
+ * +-------+ +-------+ | MB C | MB D |
+ * | MB C | | MB D | +-------+-------+
+ * +-------+ +-------+
+ * </pre>
+ * @see ExecutionGroup.constructConsolidatedMemoryBuffer constructs the temporarily MemoryBuffer
+ * @see MemoryBuffer.state state is MemoryManagerState.COM_MB_TEMPORARILY
+ * @see ExecutionGroup.finalizeChunkExecution deallocate the temporarily MemoryBuffer
+ * @note this MemoryBuffer is not managed by the MemoryManager
+ */
+
+/**
+ * @brief the memory manager for the compostor
+ * @ingroup Memory
+ */
+class MemoryManager {
+private:
+ /**
+ * @brief retrieve the state of a certain MemoryProxy;
+ * @param memoryProxy the MemoryProxy to retrieve the state from
+ */
+ static MemoryManagerState* getState(MemoryProxy* memoryProxy);
+public:
+ /**
+ * @brief allocate a memory buffer
+ * @param memoryProxy the MemoryProxy to get a chunk from
+ * @param chunkNumber number of the chunk to receive
+ * @param rect size + position of the chunk
+ */
+ static MemoryBuffer* allocateMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti* rect);
+
+ /**
+ * @brief get a memory buffer
+ * @param memoryProxy the MemoryProxy to get a chunk from
+ * @param chunkNumber number of the chunk to receive
+ * @param addUser must we add a user to the chunk.
+ */
+ static MemoryBuffer* getMemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber);
+
+ /**
+ * @brief add a MemoryProxy to the scope of the memory manager
+ * @param memoryProxy the MemoryProxy to add
+ */
+ static void addMemoryProxy(MemoryProxy *memoryProxy);
+
+ /**
+ * @brief clear the memory manager
+ */
+ static void clear();
+
+ /**
+ * @brief initialize the memory manager.
+ */
+ static void initialize();
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_MemoryManagerState.cpp b/source/blender/compositor/intern/COM_MemoryManagerState.cpp
new file mode 100644
index 00000000000..56946c3f0f2
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryManagerState.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MemoryManagerState.h"
+
+MemoryManagerState::MemoryManagerState(MemoryProxy *memoryProxy) {
+ this->memoryProxy = memoryProxy;
+ this->currentSize = 0;
+ this->chunkBuffers = NULL;
+ BLI_mutex_init(&this->mutex);
+}
+
+MemoryProxy * MemoryManagerState::getMemoryProxy() {
+ return this->memoryProxy;
+}
+
+MemoryManagerState::~MemoryManagerState() {
+ this->memoryProxy = NULL;
+ unsigned int index;
+ for (index = 0 ; index < this->currentSize; index ++){
+ MemoryBuffer* buffer = this->chunkBuffers[index];
+ if (buffer) {
+ delete buffer;
+ }
+ }
+ delete this->chunkBuffers;
+ BLI_mutex_end(&this->mutex);
+}
+
+void MemoryManagerState::addMemoryBuffer(MemoryBuffer *buffer) {
+ BLI_mutex_lock(&this->mutex);
+ unsigned int chunkNumber = buffer->getChunkNumber();
+ unsigned int index;
+ while (this->currentSize <= chunkNumber) {
+ unsigned int newSize = this->currentSize + 1000;
+ MemoryBuffer** newbuffer = new MemoryBuffer*[newSize];
+ MemoryBuffer** oldbuffer = this->chunkBuffers;
+
+ for (index = 0 ; index < this->currentSize ; index++) {
+ newbuffer[index] = oldbuffer[index];
+ }
+ for (index = currentSize ; index < newSize; index++) {
+ newbuffer[index] = NULL;
+ }
+
+ this->chunkBuffers = newbuffer;
+ this->currentSize = newSize;
+ if (oldbuffer) delete oldbuffer;
+ }
+
+ if (this->chunkBuffers[chunkNumber] == NULL) {
+ this->chunkBuffers[chunkNumber] = buffer;
+ } else {
+ throw "ALREADY ALLOCATED!";
+ }
+ BLI_mutex_unlock(&this->mutex);
+}
+
+MemoryBuffer* MemoryManagerState::getMemoryBuffer(unsigned int chunkNumber) {
+ MemoryBuffer* result = NULL;
+ if (chunkNumber< this->currentSize){
+ result = this->chunkBuffers[chunkNumber];
+ if (result) {
+ return result;
+ }
+ }
+
+ BLI_mutex_lock(&this->mutex);
+ if (chunkNumber< this->currentSize){
+ result = this->chunkBuffers[chunkNumber];
+ }
+
+ BLI_mutex_unlock(&this->mutex);
+ return result;
+}
diff --git a/source/blender/compositor/intern/COM_MemoryManagerState.h b/source/blender/compositor/intern/COM_MemoryManagerState.h
new file mode 100644
index 00000000000..4b4f0a112a8
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryManagerState.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class MemoryManagerState;
+
+#ifndef _COM_MemoryManagerState_h_
+#define _COM_MemoryManagerState_h_
+
+#include "COM_MemoryProxy.h"
+#include "COM_MemoryBuffer.h"
+#include <vector>
+extern "C" {
+ #include "BLI_threads.h"
+}
+
+/**
+ * @brief State of a MemoryProxy in the MemoryManager.
+ * @ingroup Memory
+ */
+class MemoryManagerState {
+private:
+ /**
+ * @brief reference to the MemoryProxy of this state
+ */
+ MemoryProxy *memoryProxy;
+
+ /**
+ * @brief list of all chunkbuffers
+ */
+ MemoryBuffer** chunkBuffers;
+
+ /**
+ * @brief size of the chunkBuffers
+ */
+ unsigned int currentSize;
+
+ /**
+ * @brief lock to this memory for multithreading
+ */
+ ThreadMutex mutex;
+public:
+ /**
+ * @brief creates a new MemoryManagerState for a certain MemoryProxy.
+ */
+ MemoryManagerState(MemoryProxy * memoryProxy);
+ /**
+ * @brief destructor
+ */
+ ~MemoryManagerState();
+
+ /**
+ * @brief get the reference to the MemoryProxy this state belongs to.
+ */
+ MemoryProxy *getMemoryProxy();
+
+ /**
+ * @brief add a new memorybuffer to the state
+ */
+ void addMemoryBuffer(MemoryBuffer* buffer);
+
+ /**
+ * @brief get the MemoryBuffer assiciated to a chunk.
+ * @param chunkNumber the chunknumber
+ */
+ MemoryBuffer* getMemoryBuffer(unsigned int chunkNumber);
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp
new file mode 100644
index 00000000000..0880af9833c
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MemoryProxy.h"
+
+
+MemoryProxy::MemoryProxy() {
+ this->state = NULL;
+ this->writeBufferOperation = NULL;
+ this->executor = NULL;
+}
+
+MemoryProxy::~MemoryProxy() {
+ if (this->state) {
+ delete this->state;
+ this->state = NULL;
+ }
+}
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
new file mode 100644
index 00000000000..9424ea9a3e5
--- /dev/null
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class MemoryProxy;
+
+
+#ifndef _COM_MemoryProxy_h
+#define _COM_MemoryProxy_h
+#include "COM_ExecutionGroup.h"
+#include "COM_MemoryManagerState.h"
+
+class ExecutionGroup;
+
+/**
+ * @brief A MemoryProxy is a unique identifier for a memory buffer.
+ * A single MemoryProxy is used among all chunks of the same buffer,
+ * the MemoryBuffer only stores the data of a single chunk.
+ * @ingroup Memory
+ */
+class MemoryProxy {
+private:
+ /**
+ * @brief reference to the ouput operation of the executiongroup
+ */
+ WriteBufferOperation *writeBufferOperation;
+
+ /**
+ * @brief reference to the executor. the Execution group that can fill a chunk
+ */
+ ExecutionGroup *executor;
+
+ /**
+ * @brief data of the different chunks.
+ * @note state is part of this class due to optimization in the MemoryManager
+ */
+ MemoryManagerState * state;
+
+ /**
+ * @brief datatype of this MemoryProxy
+ */
+ DataType datatype;
+
+ /**
+ * @brief channel information of this buffer
+ */
+ ChannelInfo channelInfo[COM_NUMBER_OF_CHANNELS];
+public:
+ MemoryProxy();
+ ~MemoryProxy();
+
+ /**
+ * @brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ * @param group the ExecutionGroup to set
+ */
+ void setExecutor(ExecutionGroup *executor) {this->executor = executor;}
+
+ /**
+ * @brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ */
+ ExecutionGroup* getExecutor() {return this->executor;}
+
+ /**
+ * @brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * @param operation
+ */
+ void setWriteBufferOperation(WriteBufferOperation* operation) {this->writeBufferOperation = operation;}
+
+ /**
+ * @brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * @return WriteBufferOperation
+ */
+ WriteBufferOperation* getWriteBufferOperation() {return this->writeBufferOperation;}
+
+ /**
+ * @brief set the memorymanager state of this MemoryProxy, this is set from the MemoryManager
+ * @param state the state to set
+ */
+ void setState(MemoryManagerState *state) {this->state = state;}
+
+ /**
+ * @brief get the state of this MemoryProxy
+ * @return MemoryManagerState reference to the state of this MemoryProxy.
+ */
+ MemoryManagerState* getState() {return this->state;}
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
new file mode 100644
index 00000000000..2587eaa5195
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "string.h"
+
+#include "COM_NodeOperation.h"
+#include "BKE_node.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SocketConnection.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_PreviewOperation.h"
+#include "COM_TranslateOperation.h"
+
+#include "COM_SocketProxyNode.h"
+
+//#include "stdio.h"
+#include "COM_defines.h"
+
+Node::Node(bNode* editorNode, bool create_sockets) {
+ this->editorNode = editorNode;
+
+ if (create_sockets) {
+ bNodeSocket * input = (bNodeSocket*)editorNode->inputs.first;
+ while (input != NULL) {
+ DataType dt = COM_DT_VALUE;
+ if (input->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+
+ this->addInputSocket(dt, (InputSocketResizeMode)input->resizemode, input);
+ input = (bNodeSocket*)input->next;
+ }
+ bNodeSocket *output = (bNodeSocket*)editorNode->outputs.first;
+ while(output != NULL) {
+ DataType dt = COM_DT_VALUE;
+ if (output->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (output->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+
+ this->addOutputSocket(dt, output);
+ output = (bNodeSocket*)output->next;
+ }
+ }
+}
+Node::Node() {
+ this->editorNode = NULL;
+}
+
+bNode* Node::getbNode() {return this->editorNode;}
+
+void Node::addSetValueOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+ bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ SetValueOperation *operation = new SetValueOperation();
+ bNodeSocketValueFloat *val = (bNodeSocketValueFloat*)bSock->default_value;
+ operation->setValue(val->value);
+ this->addLink(graph, operation->getOutputSocket(), inputsocket);
+ graph->addOperation(operation);
+}
+
+void Node::addPreviewOperation(ExecutionSystem *system, OutputSocket *outputSocket, int priority) {
+#ifdef COM_PREVIEW_ENABLED
+ PreviewOperation *operation = new PreviewOperation();
+ system->addOperation(operation);
+ operation->setbNode(this->getbNode());
+ operation->setbNodeTree(system->getContext().getbNodeTree());
+ operation->setPriority(priority);
+ this->addLink(system, outputSocket, operation->getInputSocket(0));
+#endif
+}
+
+void Node::addPreviewOperation(ExecutionSystem *system, InputSocket *inputSocket, int priority) {
+ if (inputSocket->isConnected()) {
+ OutputSocket *outputsocket = inputSocket->getConnection()->getFromSocket();
+ this->addPreviewOperation(system, outputsocket, priority);
+ }
+}
+
+SocketConnection* Node::addLink(ExecutionSystem *graph, OutputSocket* outputSocket, InputSocket* inputsocket) {
+ if (inputsocket->isConnected()) {
+ return NULL;
+ }
+ SocketConnection *connection = new SocketConnection();
+ connection->setFromSocket(outputSocket);
+ outputSocket->addConnection(connection);
+ connection->setToSocket(inputsocket);
+ inputsocket->setConnection(connection);
+ graph->addSocketConnection(connection);
+ return connection;
+}
+
+void Node::addSetColorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+ bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ SetColorOperation *operation = new SetColorOperation();
+ bNodeSocketValueRGBA *val = (bNodeSocketValueRGBA*)bSock->default_value;
+ operation->setChannel1(val->value[0]);
+ operation->setChannel2(val->value[1]);
+ operation->setChannel3(val->value[2]);
+ operation->setChannel4(val->value[3]);
+ this->addLink(graph, operation->getOutputSocket(), inputsocket);
+ graph->addOperation(operation);
+}
+
+void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex) {
+ bNodeSocket *bSock = (bNodeSocket*)this->getEditorInputSocket(editorNodeInputSocketIndex);
+ bNodeSocketValueVector *val = (bNodeSocketValueVector*)bSock->default_value;
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setX(val->value[0]);
+ operation->setY(val->value[1]);
+ operation->setZ(val->value[2]);
+ operation->setW(val->value[3]);
+ this->addLink(graph, operation->getOutputSocket(), inputsocket);
+ graph->addOperation(operation);
+}
+
+bNodeSocket* Node::getEditorInputSocket(int editorNodeInputSocketIndex) {
+ bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->inputs.first;
+ int index = 0;
+ while (bSock != NULL) {
+ if (index == editorNodeInputSocketIndex) {
+ return bSock;
+ }
+ index++;
+ bSock = bSock->next;
+ }
+ return NULL;
+}
+bNodeSocket* Node::getEditorOutputSocket(int editorNodeInputSocketIndex) {
+ bNodeSocket *bSock = (bNodeSocket*)this->getbNode()->outputs.first;
+ int index = 0;
+ while (bSock != NULL) {
+ if (index == editorNodeInputSocketIndex) {
+ return bSock;
+ }
+ index++;
+ bSock = bSock->next;
+ }
+ return NULL;
+}
+
+InputSocket* Node::findInputSocketBybNodeSocket(bNodeSocket* socket) {
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+ unsigned int index;
+ for (index = 0 ; index < inputsockets.size(); index ++) {
+ InputSocket* input = inputsockets[index];
+ if (input->getbNodeSocket() == socket) {
+ return input;
+ }
+ }
+ return NULL;
+}
+
+OutputSocket* Node::findOutputSocketBybNodeSocket(bNodeSocket* socket) {
+ vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+ unsigned int index;
+ for (index = 0 ; index < outputsockets.size(); index ++) {
+ OutputSocket* output = outputsockets[index];
+ if (output->getbNodeSocket() == socket) {
+ return output;
+ }
+ }
+ return NULL;
+}
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
new file mode 100644
index 00000000000..3706592a585
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_Node_h
+#define _COM_Node_h
+
+#include "COM_NodeBase.h"
+#include "COM_InputSocket.h"
+#include "COM_OutputSocket.h"
+#include "COM_CompositorContext.h"
+#include "DNA_node_types.h"
+#include "BKE_text.h"
+#include <vector>
+#include <string>
+
+using namespace std;
+
+class Node;
+class NodeOperation;
+class ExecutionSystem;
+
+typedef vector<Node*> NodeList;
+typedef NodeList::iterator NodeIterator;
+typedef pair<NodeIterator, NodeIterator> NodeRange;
+
+/**
+ * My node documentation.
+ */
+class Node:public NodeBase {
+private:
+ /**
+ * @brief stores the reference to the SDNA bNode struct
+ */
+ bNode* editorNode;
+
+public:
+ Node(bNode* editorNode, bool create_sockets=true);
+
+ /**
+ * @brief get the reference to the SDNA bNode struct
+ */
+ bNode* getbNode();
+
+ /**
+ * @brief convert node to operation
+ *
+ * @todo this must be described furter
+ *
+ * @param system the ExecutionSystem where the operations need to be added
+ * @param context reference to the CompositorContext
+ */
+ virtual void convertToOperations(ExecutionSystem* system, CompositorContext * context) =0;
+
+ /**
+ * this method adds a SetValueOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
+ void addSetValueOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+
+ /**
+ * this method adds a SetColorOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
+ void addSetColorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+
+ /**
+ * this method adds a SetVectorOperation as input of the input socket.
+ * This can only be used from the convertToOperation method. all other usages are not allowed
+ */
+ void addSetVectorOperation(ExecutionSystem *graph, InputSocket* inputsocket, int editorNodeInputSocketIndex);
+
+ /**
+ * Creates a new link between an outputSocket and inputSocket and registrates the link to the graph
+ * @return the new created link
+ */
+ SocketConnection* addLink(ExecutionSystem *graph, OutputSocket* outputSocket, InputSocket* inputsocket);
+
+ /**
+ * is this node a group node.
+ */
+ virtual bool isGroupNode() const { return false; }
+ /**
+ * is this node a proxy node.
+ */
+ virtual bool isProxyNode() const { return false; }
+
+ /**
+ * @brief find the InputSocket by bNodeSocket
+ *
+ * @param socket
+ */
+ InputSocket* findInputSocketBybNodeSocket(bNodeSocket* socket);
+
+ /**
+ * @brief find the OutputSocket by bNodeSocket
+ *
+ * @param socket
+ */
+ OutputSocket* findOutputSocketBybNodeSocket(bNodeSocket* socket);
+protected:
+
+ Node();
+
+ void addPreviewOperation(ExecutionSystem *system, InputSocket* inputSocket, int priority);
+ void addPreviewOperation(ExecutionSystem *system, OutputSocket* inputSocket, int priority);
+
+ bNodeSocket* getEditorInputSocket(int editorNodeInputSocketIndex);
+ bNodeSocket* getEditorOutputSocket(int editorNodeOutputSocketIndex);
+private:
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_NodeBase.cpp b/source/blender/compositor/intern/COM_NodeBase.cpp
new file mode 100644
index 00000000000..6e6be889572
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeBase.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_NodeBase.h"
+#include "string.h"
+#include "COM_NodeOperation.h"
+#include "BKE_node.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SocketConnection.h"
+#include "COM_ExecutionSystem.h"
+
+NodeBase::NodeBase() {
+}
+
+
+NodeBase::~NodeBase(){
+ while (!this->outputsockets.empty()) {
+ delete (this->outputsockets.back());
+ this->outputsockets.pop_back();
+ }
+ while (!this->inputsockets.empty()) {
+ delete (this->inputsockets.back());
+ this->inputsockets.pop_back();
+ }
+}
+
+void NodeBase::addInputSocket(DataType datatype) {
+ this->addInputSocket(datatype, COM_SC_CENTER, NULL);
+}
+
+void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode) {
+ this->addInputSocket(datatype, resizeMode, NULL);
+}
+void NodeBase::addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket* bSocket) {
+ InputSocket *socket = new InputSocket(datatype, resizeMode);
+ socket->setEditorSocket(bSocket);
+ socket->setNode(this);
+ this->inputsockets.push_back(socket);
+}
+
+void NodeBase::addOutputSocket(DataType datatype) {
+ this->addOutputSocket(datatype, NULL);
+
+}
+void NodeBase::addOutputSocket(DataType datatype, bNodeSocket* bSocket) {
+ OutputSocket *socket = new OutputSocket(datatype);
+ socket->setEditorSocket(bSocket);
+ socket->setNode(this);
+ this->outputsockets.push_back(socket);
+}
+const bool NodeBase::isInputNode() const {
+ return this->inputsockets.size() == 0;
+}
+
+OutputSocket* NodeBase::getOutputSocket(int index) {
+ return this->outputsockets[index];
+}
+
+InputSocket* NodeBase::getInputSocket(int index) {
+ return this->inputsockets[index];
+}
+
+
+void NodeBase::determineActualSocketDataTypes() {
+ unsigned int index;
+ for (index = 0 ; index < this->outputsockets.size() ; index ++) {
+ OutputSocket* socket = this->outputsockets[index];
+ if (socket->getActualDataType() ==COM_DT_UNKNOWN && socket->isConnected()) {
+ socket->determineActualDataType();
+ }
+ }
+ for (index = 0 ; index < this->inputsockets.size() ; index ++) {
+ InputSocket* socket = this->inputsockets[index];
+ if (socket->getActualDataType() ==COM_DT_UNKNOWN) {
+ socket->determineActualDataType();
+ }
+ }
+}
+
+DataType NodeBase::determineActualDataType(OutputSocket *outputsocket) {
+ const int inputIndex = outputsocket->getInputSocketDataTypeDeterminatorIndex();
+ if (inputIndex != -1) {
+ return this->getInputSocket(inputIndex)->getActualDataType();
+ } else {
+ return outputsocket->getDataType();
+ }
+}
+
+void NodeBase::notifyActualDataTypeSet(InputSocket *socket, DataType actualType) {
+ unsigned int index;
+ int socketIndex = -1;
+ for (index = 0 ; index < this->inputsockets.size() ; index ++) {
+ if (this->inputsockets[index] == socket) {
+ socketIndex = (int)index;
+ break;
+ }
+ }
+ if (socketIndex == -1) return;
+
+ for (index = 0 ; index < this->outputsockets.size() ; index ++) {
+ OutputSocket* socket = this->outputsockets[index];
+ if (socket->isActualDataTypeDeterminedByInputSocket() &&
+ socket->getInputSocketDataTypeDeterminatorIndex() == socketIndex) {
+ socket->setActualDataType(actualType);
+ socket->fireActualDataType();
+ }
+ }
+}
diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h
new file mode 100644
index 00000000000..10028324d91
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeBase.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_NodeBase_h
+#define _COM_NodeBase_h
+
+#include "COM_InputSocket.h"
+#include "COM_OutputSocket.h"
+#include "DNA_node_types.h"
+#include "BKE_text.h"
+#include <vector>
+#include <string>
+
+using namespace std;
+
+
+class NodeOperation;
+class ExecutionSystem;
+
+/**
+ * @brief The NodeBase class is the super-class of all node related objects like @see Node @see NodeOperation
+ * the reason for the existence of this class is to support graph-nodes when using ExecutionSystem
+ * the NodeBase also contains the reference to InputSocket and OutputSocket.
+ * @ingroup Model
+ */
+class NodeBase {
+private:
+ /**
+ * @brief the list of actual inputsockets @see InputSocket
+ */
+ vector<InputSocket*> inputsockets;
+
+ /**
+ * @brief the list of actual outputsockets @see OutputSocket
+ */
+ vector<OutputSocket*> outputsockets;
+
+protected:
+ /**
+ * @brief get access to the vector of input sockets
+ */
+ inline vector<InputSocket*>& getInputSockets() {return this->inputsockets;}
+
+ /**
+ * @brief get access to the vector of input sockets
+ */
+ inline vector<OutputSocket*>& getOutputSockets() {return this->outputsockets;}
+
+
+public:
+ /**
+ * @brief destructor
+ * clean up memory related to this NodeBase.
+ */
+ virtual ~NodeBase();
+
+ /**
+ * @brief determine the actual socket data types that will go through the system
+ */
+ virtual void determineActualSocketDataTypes();
+
+ /**
+ * @brief determine the actual socket data types of a specific outputsocket
+ *
+ * @param outputsocket
+ * a reference to the actual outputsocket where the datatype must be determined from
+ *
+ * @return
+ * COM_DT_VALUE if it is a value (1 float buffer)
+ * COM_DT_COLOR if it is a value (4 float buffer)
+ * COM_DT_VECTOR if it is a value (3 float buffer)
+ */
+ virtual DataType determineActualDataType(OutputSocket *outputsocket);
+
+ /**
+ * @brief is this node an operation?
+ * This is true when the instance is of the subclass NodeOperation.
+ * @return [true:false]
+ * @see NodeOperation
+ */
+ virtual const int isOperation() const {return false;}
+
+ /**
+ * @brief check if this is an input node
+ * An input node is a node that only has output sockets and no input sockets
+ * @return [false..true]
+ */
+ const bool isInputNode() const;
+
+ /**
+ * @brief Return the number of input sockets of this node.
+ */
+ const unsigned int getNumberOfInputSockets() const {return this->inputsockets.size();}
+
+ /**
+ * @brief Return the number of output sockets of this node.
+ */
+ const unsigned int getNumberOfOutputSockets() const {return this->outputsockets.size();}
+
+ /**
+ * after the data has been determined of an outputsocket that has a connection with an inputsocket this method is called on the
+ * node that contains the inputsocket.
+ * @param socket
+ * the reference of the inputsocket where connected data type is found
+ * @param actualType [COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR]
+ * the actual data type that is coming from the connected output socket
+ */
+ virtual void notifyActualDataTypeSet(InputSocket* socket, const DataType actualType);
+
+ /**
+ * get the reference to a certain outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
+ OutputSocket* getOutputSocket(const int index);
+
+ /**
+ * get the reference to the first outputsocket
+ * @param index
+ * the index of the needed outputsocket
+ */
+ inline OutputSocket* getOutputSocket() {return getOutputSocket(0);}
+
+ /**
+ * get the reference to a certain inputsocket
+ * @param index
+ * the index of the needed inputsocket
+ */
+ InputSocket* getInputSocket(const int index);
+
+
+ virtual bool isStatic() const {return false;}
+ void getStaticValues(float* result) const {}
+protected:
+ NodeBase();
+
+ /**
+ * @brief add an InputSocket to the collection of inputsockets
+ * @note may only be called in an constructor
+ * @param socket the InputSocket to add
+ */
+ void addInputSocket(DataType datatype);
+ void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode);
+ void addInputSocket(DataType datatype, InputSocketResizeMode resizeMode, bNodeSocket* socket);
+
+ /**
+ * @brief add an OutputSocket to the collection of outputsockets
+ * @note may only be called in an constructor
+ * @param socket the OutputSocket to add
+ */
+ void addOutputSocket(DataType datatype);
+ void addOutputSocket(DataType datatype, bNodeSocket* socket);
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
new file mode 100644
index 00000000000..b02bcb6676e
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_NodeOperation.h"
+#include <typeinfo>
+#include "COM_InputSocket.h"
+#include "COM_SocketConnection.h"
+#include "COM_defines.h"
+#include "stdio.h"
+
+NodeOperation::NodeOperation() {
+ this->resolutionInputSocketIndex = 0;
+ this->complex = false;
+ this->width = 0;
+ this->height = 0;
+ this->openCL = false;
+}
+
+void NodeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ unsigned int temp[2];
+ unsigned int temp2[2];
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+
+ for (unsigned int index = 0 ; index < inputsockets.size();index++) {
+ InputSocket* inputSocket = inputsockets[index];
+ if (inputSocket->isConnected()) {
+ if (index == this->resolutionInputSocketIndex) {
+ inputSocket->determineResolution(resolution, preferredResolution);
+ temp2[0] = resolution[0];
+ temp2[1] = resolution[1];
+ break;
+ }
+ }
+ }
+ for (unsigned int index = 0 ; index < inputsockets.size();index++) {
+ InputSocket* inputSocket = inputsockets[index];
+ if (inputSocket->isConnected()) {
+ if (index != resolutionInputSocketIndex) {
+ inputSocket->determineResolution(temp, temp2);
+ }
+ }
+ }
+}
+void NodeOperation::setResolutionInputSocketIndex(unsigned int index) {
+ this->resolutionInputSocketIndex = index;
+}
+void NodeOperation::initExecution() {
+}
+
+void NodeOperation::initMutex() {
+ BLI_mutex_init(&mutex);
+}
+void NodeOperation::deinitMutex() {
+ BLI_mutex_end(&mutex);
+}
+void NodeOperation::deinitExecution() {
+}
+SocketReader* NodeOperation::getInputSocketReader(unsigned int inputSocketIndex) {
+ return this->getInputSocket(inputSocketIndex)->getReader();
+}
+NodeOperation* NodeOperation::getInputOperation(unsigned int inputSocketIndex) {
+ return this->getInputSocket(inputSocketIndex)->getOperation();
+}
+
+void NodeOperation::getConnectedInputSockets(vector<InputSocket*> *sockets) {
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+ for (vector<InputSocket*>::iterator iterator = inputsockets.begin() ; iterator!= inputsockets.end() ; iterator++) {
+ InputSocket *socket = *iterator;
+ if (socket->isConnected()) {
+ sockets->push_back(socket);
+ }
+ }
+}
+
+bool NodeOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti* output) {
+ if (this->isInputNode()) {
+ BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax);
+ return false;
+ } else {
+ unsigned int index;
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+
+ for (index = 0 ; index < inputsockets.size() ; index++) {
+ InputSocket* inputsocket = inputsockets[index];
+ if (inputsocket->isConnected()) {
+ NodeOperation* inputoperation = (NodeOperation*)inputsocket->getConnection()->getFromNode();
+ bool result = inputoperation->determineDependingAreaOfInterest(input, readOperation, output);
+ if (result) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
new file mode 100644
index 00000000000..5dabc4db840
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -0,0 +1,247 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_NodeProgram_h
+#define _COM_NodeProgram_h
+
+class NodeOperation;
+
+#include "COM_Node.h"
+#include <string>
+#include <sstream>
+#include "COM_MemoryBuffer.h"
+#include "COM_MemoryProxy.h"
+#include "COM_SocketReader.h"
+#include "OCL_opencl.h"
+#include "list"
+
+class ReadBufferOperation;
+
+/**
+ * @brief NodeOperation are contains calculation logic
+ *
+ * Subclasses needs to implement the execution method (defined in SocketReader) to implement logic.
+ * @ingroup Model
+ */
+class NodeOperation : public NodeBase, public SocketReader {
+private:
+ /**
+ * @brief the index of the input socket that will be used to determine the resolution
+ */
+ unsigned int resolutionInputSocketIndex;
+
+ /**
+ * @brief is this operation a complex one.
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ bool complex;
+
+ /**
+ * @brief can this operation be scheduled on an OpenCL device.
+ * @note Only applicable if complex is True
+ */
+ bool openCL;
+
+ /**
+ * @brief mutex reference for very special node initializations
+ * @note only use when you really know what you are doing.
+ * this mutex is used to share data among chunks in the same operation
+ * @see TonemapOperation for an example of usage
+ * @see NodeOperation.initMutex initializes this mutex
+ * @see NodeOperation.deinitMutex deinitializes this mutex
+ * @see NodeOperation.getMutex retrieve a pointer to this mutex.
+ */
+ ThreadMutex mutex;
+
+public:
+ /**
+ * @brief is this node an operation?
+ * This is true when the instance is of the subclass NodeOperation.
+ * @return [true:false]
+ * @see NodeBase
+ */
+ const int isOperation() const {return true;}
+
+ /**
+ * @brief determine the resolution of this node
+ * @note this method will not set the resolution, this is the responsibility of the caller
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
+ virtual void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ /**
+ * @brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
+ *
+ * Default behaviour if not overriden, this operation will not be evaluated as being an output of the ExecutionSystem.
+ *
+ * @see ExecutionSystem
+ * @group check
+ * @param rendering [true false]
+ * true: rendering
+ * false: editing
+ *
+ * @return bool the result of this method
+ */
+ virtual bool isOutputOperation(bool rendering) const {return false;}
+
+ /**
+ * isBufferOperation returns if this is an operation that work directly on buffers.
+ *
+ * there are only 2 implementation where this is true:
+ * @see ReadBufferOperation
+ * @see WriteBufferOperation
+ * for all other operations this will result in false.
+ */
+ virtual int isBufferOperation() {return false;}
+
+ virtual void initExecution();
+ void initMutex();
+
+ /**
+ * @brief when a chunk is executed by a CPUDevice, this method is called
+ * @ingroup execution
+ * @param rect the rectangle of the chunk (location and size)
+ * @param chunkNumber the chunkNumber to be calculated
+ * @param memoryBuffers all input MemoryBuffer's needed
+ */
+ virtual void executeRegion(rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers) {}
+
+ /**
+ * @brief when a chunk is executed by an OpenCLDevice, this method is called
+ * @ingroup execution
+ * @note this method is only implemented in WriteBufferOperation
+ * @param context the OpenCL context
+ * @param program the OpenCL program containing all compositor kernels
+ * @param queue the OpenCL command queue of the device the chunk is executed on
+ * @param rect the rectangle of the chunk (location and size)
+ * @param chunkNumber the chunkNumber to be calculated
+ * @param memoryBuffers all input MemoryBuffer's needed
+ */
+ virtual void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers) {}
+
+ /**
+ * @brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
+ * @ingroup execution
+ * @param context the OpenCL context
+ * @param program the OpenCL program containing all compositor kernels
+ * @param queue the OpenCL command queue of the device the chunk is executed on
+ * @param outputMemoryBuffer the allocated memory buffer in main CPU memory
+ * @param clOutputBuffer the allocated memory buffer in OpenCLDevice memory
+ * @param inputMemoryBuffers all input MemoryBuffer's needed
+ * @param clMemToCleanUp all created cl_mem references must be added to this list. Framework will clean this after execution
+ * @param clKernelsToCleanUp all created cl_kernel references must be added to this list. Framework will clean this after execution
+ */
+ virtual void executeOpenCL(cl_context context,cl_program program, cl_command_queue queue, MemoryBuffer* outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer** inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp) {}
+ virtual void deinitExecution();
+ void deinitMutex();
+
+ /**
+ * @brief set the resolution
+ * @param resolution the resolution to set
+ */
+ void setResolution(unsigned int resolution[]) {this->width = resolution[0];this->height = resolution[1];}
+ void getConnectedInputSockets(vector<InputSocket*> *sockets);
+
+ /**
+ * @brief is this operation complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ const bool isComplex() const {return this->complex;}
+ virtual const bool isSetOperation() const {return false;}
+
+ /**
+ * @brief is this operation of type ReadBufferOperation
+ * @return [true:false]
+ * @see ReadBufferOperation
+ */
+ virtual const bool isReadBufferOperation() const {return false;}
+
+ /**
+ * @brief is this operation of type WriteBufferOperation
+ * @return [true:false]
+ * @see WriteBufferOperation
+ */
+ virtual const bool isWriteBufferOperation() const {return false;}
+
+ /**
+ * @brief is this operation the active viewer output
+ * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
+ * @return [true:false]
+ * @see BaseViewerOperation
+ */
+ virtual const bool isActiveViewerOutput() const {return false;}
+
+ virtual bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output);
+
+ /**
+ * @brief set the index of the input socket that will determine the resolution of this operation
+ * @param index the index to set
+ */
+ void setResolutionInputSocketIndex(unsigned int index);
+
+ /**
+ * @brief get the render priority of this node.
+ * @note only applicable for output operations like ViewerOperation
+ * @return [0:9] 9 is highest priority
+ */
+ virtual const int getRenderPriority() const {return 0;}
+
+ /**
+ * @brief can this NodeOperation be scheduled on an OpenCLDevice
+ * @see WorkScheduler.schedule
+ * @see ExecutionGroup.addOperation
+ */
+ bool isOpenCL() { return this->openCL; }
+
+ virtual bool isViewerOperation() {return false;}
+protected:
+ NodeOperation();
+
+ void setWidth(unsigned int width) {this->width = width;}
+ void setHeight(unsigned int height) {this->height= height;}
+ SocketReader* getInputSocketReader(unsigned int inputSocketindex);
+ NodeOperation* getInputOperation(unsigned int inputSocketindex);
+
+ inline ThreadMutex* getMutex() {return &this->mutex;}
+
+ /**
+ * @brief set whether this operation is complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ void setComplex(bool complex) {this->complex = complex;}
+
+ /**
+ * @brief set if this NodeOperation can be scheduled on a OpenCLDevice
+ */
+ void setOpenCL(bool openCL) {this->openCL = openCL;}
+
+
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_NodeProgram.cpp b/source/blender/compositor/intern/COM_NodeProgram.cpp
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeProgram.cpp
diff --git a/source/blender/compositor/intern/COM_NodeProgram.h b/source/blender/compositor/intern/COM_NodeProgram.h
new file mode 100644
index 00000000000..a71fa2b676f
--- /dev/null
+++ b/source/blender/compositor/intern/COM_NodeProgram.h
@@ -0,0 +1,7 @@
+#ifndef _COM_NodeProgram_h
+#define _COM_NodeProgram_h
+
+class NodeProgram{
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
new file mode 100644
index 00000000000..acf3bf3789d
--- /dev/null
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_OpenCLDevice.h"
+#include "COM_WorkScheduler.h"
+
+
+OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program){
+ this->device = device;
+ this->context = context;
+ this->program = program;
+ this->queue = NULL;
+}
+
+bool OpenCLDevice::initialize(){
+ cl_int error;
+ queue = clCreateCommandQueue(context, device, 0, &error);
+ return false;
+}
+
+void OpenCLDevice::deinitialize(){
+ if(queue){
+ clReleaseCommandQueue(queue);
+ }
+}
+
+void OpenCLDevice::execute(WorkPackage *work) {
+ const unsigned int chunkNumber = work->getChunkNumber();
+ ExecutionGroup * executionGroup = work->getExecutionGroup();
+ rcti rect;
+
+ executionGroup->determineChunkRect(&rect, chunkNumber);
+ MemoryBuffer ** inputBuffers = executionGroup->getInputBuffers(chunkNumber);
+ MemoryBuffer * outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
+
+ executionGroup->getOutputNodeOperation()->executeOpenCLRegion(this->context, this->program, this->queue, &rect, chunkNumber, inputBuffers);
+
+ executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
+ if (outputBuffer != NULL) {
+ outputBuffer->setCreatedState();
+ }
+}
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
new file mode 100644
index 00000000000..f61c555558d
--- /dev/null
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class OpenCLDevice;
+
+#ifndef _COM_OpenCLDevice_h
+#define _COM_OpenCLDevice_h
+
+#include "COM_Device.h"
+#include "OCL_opencl.h"
+#include "COM_WorkScheduler.h"
+
+
+/**
+ * @brief device representing an GPU OpenCL device.
+ * an instance of this class represents a single cl_device
+ */
+class OpenCLDevice: public Device {
+private:
+ /**
+ *@brief opencl context
+ */
+ cl_context context;
+
+ /**
+ *@brief opencl device
+ */
+ cl_device_id device;
+
+ /**
+ *@brief opencl program
+ */
+ cl_program program;
+
+ /**
+ *@brief opencl command queue
+ */
+ cl_command_queue queue;
+public:
+ /**
+ *@brief constructor with opencl device
+ *@param context
+ *@param device
+ */
+ OpenCLDevice(cl_context context, cl_device_id device, cl_program program);
+
+
+ /**
+ * @brief initialize the device
+ * During initialization the OpenCL cl_command_queue is created
+ * the command queue is stored in the field queue.
+ * @see queue
+ */
+ bool initialize();
+
+ /**
+ * @brief deinitialize the device
+ * During deintiialization the command queue is cleared
+ */
+ void deinitialize();
+
+ /**
+ * @brief execute a WorkPackage
+ * @param work the WorkPackage to execute
+ */
+ void execute(WorkPackage *work);
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_OutputSocket.cpp b/source/blender/compositor/intern/COM_OutputSocket.cpp
new file mode 100644
index 00000000000..a262ad5f6ea
--- /dev/null
+++ b/source/blender/compositor/intern/COM_OutputSocket.cpp
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Socket.h"
+#include "COM_Node.h"
+#include "COM_SocketConnection.h"
+#include "COM_NodeOperation.h"
+
+OutputSocket::OutputSocket(DataType datatype) :Socket(datatype) {
+ this->inputSocketDataTypeDeterminatorIndex = -1;
+}
+OutputSocket::OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex) :Socket(datatype) {
+ this->inputSocketDataTypeDeterminatorIndex = inputSocketDataTypeDeterminatorIndex;
+}
+
+OutputSocket::OutputSocket(OutputSocket *from): Socket(from->getDataType()) {
+ this->inputSocketDataTypeDeterminatorIndex = from->getInputSocketDataTypeDeterminatorIndex();
+}
+
+int OutputSocket::isOutputSocket() const { return true; }
+const int OutputSocket::isConnected() const { return this->connections.size()!=0; }
+
+void OutputSocket::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ NodeBase* node = this->getNode();
+ if (node->isOperation()) {
+ NodeOperation* operation = (NodeOperation*)node;
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+ }
+}
+
+void OutputSocket::determineActualDataType() {
+ DataType actualDatatype = this->getNode()->determineActualDataType(this);
+
+ /** @todo: set the channel info needs to be moved after integration with OCIO */
+ this->channelinfo[0].setNumber(0);
+ this->channelinfo[1].setNumber(1);
+ this->channelinfo[2].setNumber(2);
+ this->channelinfo[3].setNumber(3);
+ switch (actualDatatype) {
+ case COM_DT_VALUE:
+ this->channelinfo[0].setType(COM_CT_Value);
+ break;
+ case COM_DT_VECTOR:
+ this->channelinfo[0].setType(COM_CT_X);
+ this->channelinfo[1].setType(COM_CT_Y);
+ this->channelinfo[2].setType(COM_CT_Z);
+ break;
+ case COM_DT_COLOR:
+ this->channelinfo[0].setType(COM_CT_ColorComponent);
+ this->channelinfo[1].setType(COM_CT_ColorComponent);
+ this->channelinfo[2].setType(COM_CT_ColorComponent);
+ this->channelinfo[3].setType(COM_CT_Alpha);
+ break;
+ default:
+ break;
+ }
+
+ this->setActualDataType(actualDatatype);
+ this->fireActualDataType();
+}
+
+void OutputSocket::addConnection(SocketConnection *connection) {
+ this->connections.push_back(connection);
+}
+
+void OutputSocket::fireActualDataType() {
+ unsigned int index;
+ for (index = 0 ; index < this->connections.size();index ++) {
+ SocketConnection *connection = this->connections[index];
+ connection->getToSocket()->notifyActualInputType(this->getActualDataType());
+ }
+}
+void OutputSocket::relinkConnections(OutputSocket *relinkToSocket, bool single) {
+ if (isConnected()) {
+ if (single) {
+ SocketConnection *connection = this->connections[0];
+ connection->setFromSocket(relinkToSocket);
+ relinkToSocket->addConnection(connection);
+// relinkToSocket->setActualDataType(this->getActualDataType());
+ this->connections.erase(this->connections.begin());
+ } else {
+ unsigned int index;
+ for (index = 0 ; index < this->connections.size();index ++) {
+ SocketConnection *connection = this->connections[index];
+ connection->setFromSocket(relinkToSocket);
+ relinkToSocket->addConnection(connection);
+ }
+// relinkToSocket->setActualDataType(this->getActualDataType());
+ this->connections.clear();
+ }
+ }
+}
+void OutputSocket::removeFirstConnection() {
+ SocketConnection *connection = this->connections[0];
+ InputSocket* inputSocket = connection->getToSocket();
+ if (inputSocket != NULL) {
+ inputSocket->setConnection(NULL);
+ }
+ this->connections.erase(this->connections.begin());
+}
+
+void OutputSocket::clearConnections() {
+ while (this->isConnected()) {
+ removeFirstConnection();
+ }
+}
+
+WriteBufferOperation* OutputSocket::findAttachedWriteBufferOperation() const {
+ unsigned int index;
+ for (index = 0 ; index < this->connections.size();index++) {
+ SocketConnection* connection = this->connections[index];
+ NodeBase* node = connection->getToNode();
+ if (node->isOperation()) {
+ NodeOperation* operation = (NodeOperation*)node;
+ if (operation->isWriteBufferOperation()) {
+ return (WriteBufferOperation*)operation;
+ }
+ }
+ }
+ return NULL;
+}
+
+ChannelInfo* OutputSocket::getChannelInfo(const int channelnumber) {
+ return &this->channelinfo[channelnumber];
+}
+
diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h
new file mode 100644
index 00000000000..8815f0bb3a8
--- /dev/null
+++ b/source/blender/compositor/intern/COM_OutputSocket.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_OutputSocket_h
+#define _COM_OutputSocket_h
+
+#include <vector>
+#include "COM_Socket.h"
+#include "COM_ChannelInfo.h"
+
+using namespace std;
+class SocketConnection;
+class Node;
+class InputSocket;
+class WriteBufferOperation;
+
+//#define COM_ST_INPUT 0
+//#define COM_ST_OUTPUT 1
+
+/**
+ * @brief OutputSocket are sockets that can send data/input
+ * @ingroup Model
+ */
+class OutputSocket : public Socket {
+private:
+ vector<SocketConnection*> connections;
+
+ /**
+ * @brief index of the inputsocket that determines the datatype of this outputsocket
+ * -1 will not use any inputsocket to determine the datatype, but use the outputsocket
+ * default datatype.
+ */
+ int inputSocketDataTypeDeterminatorIndex;
+
+ ChannelInfo channelinfo[4];
+ void removeFirstConnection();
+public:
+ OutputSocket(DataType datatype);
+ OutputSocket(DataType datatype, int inputSocketDataTypeDeterminatorIndex);
+ OutputSocket(OutputSocket * from);
+ void addConnection(SocketConnection *connection);
+ SocketConnection* getConnection(unsigned int index) {return this->connections[index];}
+ const int isConnected() const;
+ int isOutputSocket() const;
+
+ /**
+ * @brief determine the resolution of this socket
+ * @param resolution the result of this operation
+ * @param preferredResolution the preferrable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ /**
+ * @brief determine the actual data type and channel info.
+ */
+ void determineActualDataType();
+ void relinkConnections(OutputSocket *relinkToSocket) {this->relinkConnections(relinkToSocket, false);};
+ void relinkConnections(OutputSocket *relinkToSocket, bool single);
+ bool isActualDataTypeDeterminedByInputSocket() {
+ return this->inputSocketDataTypeDeterminatorIndex>-1;
+ }
+ const int getNumberOfConnections() {return connections.size();}
+
+ /**
+ * @brief get the index of the inputsocket that determines the datatype of this outputsocket
+ */
+ int getInputSocketDataTypeDeterminatorIndex() {return this->inputSocketDataTypeDeterminatorIndex;}
+ void clearConnections();
+
+ /**
+ * @brief find a connected write buffer operation to this OutputSocket
+ * @return WriteBufferOperation or NULL
+ */
+ WriteBufferOperation* findAttachedWriteBufferOperation() const;
+ ChannelInfo* getChannelInfo(const int channelnumber);
+
+ /**
+ * @brief trigger determine actual data type to all connected sockets
+ * @note will only be triggered just after the actual data type is set.
+ */
+ void fireActualDataType();
+
+private:
+
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_Socket.cpp b/source/blender/compositor/intern/COM_Socket.cpp
new file mode 100644
index 00000000000..cb429c9df4a
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Socket.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Socket.h"
+#include "COM_Node.h"
+#include "COM_SocketConnection.h"
+
+Socket::Socket(DataType datatype) {
+ this->datatype = datatype;
+ this->actualType = COM_DT_UNKNOWN;
+ this->editorSocket = NULL;
+ this->node = NULL;
+}
+
+DataType Socket::getDataType() const {
+ return this->datatype;
+}
+
+int Socket::isInputSocket() const { return false; }
+int Socket::isOutputSocket() const { return false; }
+const int Socket::isConnected() const {return false;}
+void Socket::setNode(NodeBase *node) {this->node = node;}
+NodeBase* Socket::getNode() const {return this->node;}
+
+DataType Socket::getActualDataType() const {return this->actualType;}
+void Socket::setActualDataType(DataType actualType) {
+ this->actualType = actualType;
+}
diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h
new file mode 100644
index 00000000000..3243a371cda
--- /dev/null
+++ b/source/blender/compositor/intern/COM_Socket.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_Socket_h
+#define _COM_Socket_h
+
+#include <vector>
+#include "BKE_text.h"
+#include <string>
+#include "DNA_node_types.h"
+#include "COM_defines.h"
+
+using namespace std;
+class SocketConnection;
+class NodeBase;
+
+/**
+ * @brief Base class for InputSocket and OutputSocket.
+ *
+ * A socket are the points on an node where the user can make a connection between.
+ * Sockets are always part of a node or an operation.
+ *
+ * @see InputSocket
+ * @see OutputSocket
+ * @see SocketConnection - a connection between an InputSocket and an OutputSocket
+ * @ingroup Model
+ */
+class Socket {
+private:
+ /**
+ * Reference to the node where this Socket belongs to
+ */
+ NodeBase* node;
+
+ /**
+ * the datatype of this socket. Is used for automatically data transformation.
+ * @section data-conversion
+ */
+ DataType datatype;
+
+ /**
+ * the actual data type during execution. This can be different than the field datatype, based on the conversion rules of the node
+ * @section data-conversion
+ */
+ DataType actualType;
+
+ bNodeSocket* editorSocket;
+public:
+ Socket(DataType datatype);
+
+ DataType getDataType() const;
+ void setNode(NodeBase* node);
+ NodeBase* getNode() const;
+
+ /**
+ * @brief get the actual data type
+ *
+ * @note The actual data type can differ from the data type this socket expects.
+ * @return actual DataType
+ */
+ DataType getActualDataType() const;
+
+ /**
+ * @brief set the actual data type
+ * @param actualType the new actual type
+ */
+ void setActualDataType(DataType actualType);
+
+ const virtual int isConnected() const;
+ int isInputSocket() const;
+ int isOutputSocket() const;
+ virtual void determineResolution(int resolution[], unsigned int preferredResolution[]) {}
+ virtual void determineActualDataType() {}
+
+ void setEditorSocket(bNodeSocket* editorSocket) {this->editorSocket = editorSocket;}
+ bNodeSocket* getbNodeSocket() const {return this->editorSocket;}
+
+};
+
+
+#endif
diff --git a/source/blender/compositor/intern/COM_SocketConnection.cpp b/source/blender/compositor/intern/COM_SocketConnection.cpp
new file mode 100644
index 00000000000..6c6c673501a
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SocketConnection.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SocketConnection.h"
+#include "COM_NodeOperation.h"
+
+SocketConnection::SocketConnection() {
+ this->fromSocket = NULL;
+ this->toSocket = NULL;
+ this->setIgnoreResizeCheck(false);
+}
+
+void SocketConnection::setFromSocket(OutputSocket* fromsocket){
+ if (fromsocket == NULL) {
+ throw "ERROR";
+ }
+ this->fromSocket = fromsocket;
+}
+
+OutputSocket* SocketConnection::getFromSocket() const {return this->fromSocket;}
+void SocketConnection::setToSocket(InputSocket* tosocket) {
+ if (tosocket == NULL) {
+ throw "ERROR";
+ }
+ this->toSocket = tosocket;
+}
+
+InputSocket* SocketConnection::getToSocket() const {return this->toSocket;}
+
+NodeBase* SocketConnection::getFromNode() const {
+ if (this->getFromSocket() == NULL) {
+ return NULL;
+ } else {
+ return this->getFromSocket()->getNode();
+ }
+}
+NodeBase* SocketConnection::getToNode() const {
+ if (this->getToSocket() == NULL) {
+ return NULL;
+ } else {
+ return this->getToSocket()->getNode();
+ }
+}
+bool SocketConnection::isValid() const {
+ if ((this->getToSocket() != NULL && this->getFromSocket() != NULL)) {
+ if (this->getFromNode()->isOperation() && this->getToNode()->isOperation()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool SocketConnection::needsResolutionConversion() const {
+ if (this->ignoreResizeCheck) {return false;}
+ NodeOperation* fromOperation = (NodeOperation*)this->getFromNode();
+ NodeOperation* toOperation = (NodeOperation*)this->getToNode();
+ if (this->toSocket->getResizeMode() == COM_SC_NO_RESIZE) {return false;}
+ const unsigned int fromWidth = fromOperation->getWidth();
+ const unsigned int fromHeight = fromOperation->getHeight();
+ const unsigned int toWidth = toOperation->getWidth();
+ const unsigned int toHeight = toOperation->getHeight();
+
+ if (fromWidth == toWidth && fromHeight == toHeight) {
+ return false;
+ }
+ return true;
+}
diff --git a/source/blender/compositor/intern/COM_SocketConnection.h b/source/blender/compositor/intern/COM_SocketConnection.h
new file mode 100644
index 00000000000..55811cc6ebe
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SocketConnection.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SocketConnection_h
+#define _COM_SocketConnection_h
+
+#include "DNA_node_types.h"
+#include "COM_Node.h"
+#include "COM_Socket.h"
+#include "COM_ChannelInfo.h"
+
+/**
+ * @brief An SocketConnection is an connection between an InputSocket and an OutputSocket.
+ *
+ * <pre>
+ * +----------+ To InputSocket +----------+
+ * | From | SocketConnection \| To Node |
+ * | Node *====================* |
+ * | |\ | |
+ * | | From OutputSocket +----------+
+ * +----------+
+ * </pre>
+ * @ingroup Model
+ * @see InputSocket
+ * @see OutputSocket
+ */
+class SocketConnection {
+private:
+ /**
+ * @brief Startpoint of the connection
+ */
+ OutputSocket *fromSocket;
+
+ /**
+ * @brief Endpoint of the connection
+ */
+ InputSocket *toSocket;
+
+ /**
+ * @brief has the resize already been done for this connection
+ */
+ bool ignoreResizeCheck;
+public:
+ SocketConnection();
+
+ /**
+ * @brief set the startpoint of the connection
+ * @param fromsocket
+ */
+ void setFromSocket(OutputSocket* fromsocket);
+
+ /**
+ * @brief get the startpoint of the connection
+ * @return from OutputSocket
+ */
+ OutputSocket* getFromSocket() const;
+
+ /**
+ * @brief set the endpoint of the connection
+ * @param tosocket
+ */
+ void setToSocket(InputSocket* tosocket);
+
+ /**
+ * @brief get the endpoint of the connection
+ * @return to InputSocket
+ */
+ InputSocket* getToSocket() const;
+
+ /**
+ * @brief check if this connection is valid
+ */
+ bool isValid() const;
+
+ /**
+ * @brief return the Node where this connection is connected from
+ */
+ NodeBase * getFromNode() const;
+
+ /**
+ * @brief return the Node where this connection is connected to
+ */
+ NodeBase * getToNode() const;
+
+ /**
+ * @brief set, whether the resize has already been done for this SocketConnection
+ */
+ void setIgnoreResizeCheck(bool check) {this->ignoreResizeCheck = check;}
+
+ /**
+ * @brief has the resize already been done for this SocketConnection
+ */
+ bool isIgnoreResizeCheck() const { return this->ignoreResizeCheck;}
+
+ /**
+ * @brief does this SocketConnection need resolution conversion
+ * @note PreviewOperation's will be ignored
+ * @note Already converted SocketConnection's will be ignored
+ * @return needs conversion [true:false]
+ */
+ bool needsResolutionConversion() const;
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_SocketReader.cpp b/source/blender/compositor/intern/COM_SocketReader.cpp
new file mode 100644
index 00000000000..45f3be5a66c
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SocketReader.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SocketReader.h"
+
+
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
new file mode 100644
index 00000000000..fd07726a939
--- /dev/null
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SocketReader_h
+#define _COM_SocketReader_h
+#include "BLI_rect.h"
+#include "COM_defines.h"
+
+typedef enum PixelSampler {
+ COM_PS_NEAREST,
+ COM_PS_BILINEAR,
+ COM_PS_BICUBIC
+} PixelSampler;
+
+class MemoryBuffer;
+/**
+ * @brief Helper class for reading socket data.
+ * Only use this class for dispatching (un-ary and n-ary) executions.
+ * @ingroup Execution
+ */
+class SocketReader {
+private:
+protected:
+ /**
+ * @brief Holds the width of the output of this operation.
+ */
+ unsigned int width;
+
+ /**
+ * @brief Holds the height of the output of this operation.
+ */
+ unsigned int height;
+
+
+ /**
+ * @brief calculate a single pixel
+ * @note this method is called for non-complex
+ * @param result is a float[4] array to store the result
+ * @param x the x-coordinate of the pixel to calculate in image space
+ * @param y the y-coordinate of the pixel to calculate in image space
+ * @param inputBuffers chunks that can be read by their ReadBufferOperation.
+ */
+ virtual void executePixel(float* result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {}
+
+ /**
+ * @brief calculate a single pixel
+ * @note this method is called for complex
+ * @param result is a float[4] array to store the result
+ * @param x the x-coordinate of the pixel to calculate in image space
+ * @param y the y-coordinate of the pixel to calculate in image space
+ * @param inputBuffers chunks that can be read by their ReadBufferOperation.
+ * @param chunkData chunk specific data a during execution time.
+ */
+ virtual void executePixel(float* result, int x, int y, MemoryBuffer *inputBuffers[], void* chunkData) {
+ executePixel(result, x, y, COM_PS_NEAREST, inputBuffers);
+ }
+
+ /**
+ * @brief calculate a single pixel using an EWA filter
+ * @note this method is called for complex
+ * @param result is a float[4] array to store the result
+ * @param x the x-coordinate of the pixel to calculate in image space
+ * @param y the y-coordinate of the pixel to calculate in image space
+ * @param dx
+ * @param dy
+ * @param inputBuffers chunks that can be read by their ReadBufferOperation.
+ */
+ virtual void executePixel(float* result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {}
+
+public:
+ inline void read(float* result, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ executePixel(result, x, y, sampler, inputBuffers);
+ }
+ inline void read(float* result, int x, int y, MemoryBuffer *inputBuffers[], void* chunkData) {
+ executePixel(result, x, y, inputBuffers, chunkData);
+ }
+ inline void read(float* result, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {
+ executePixel(result, x, y, dx, dy, inputBuffers);
+ }
+
+ virtual void* initializeTileData(rcti *rect, MemoryBuffer** memoryBuffers) {
+ return 0;
+ }
+ virtual void deinitializeTileData(rcti *rect, MemoryBuffer** memoryBuffers, void* data) {
+ }
+
+ virtual MemoryBuffer* getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return 0;}
+
+
+ inline const unsigned int getWidth() const {return this->width;}
+ inline const unsigned int getHeight() const {return this->height;}
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp
new file mode 100644
index 00000000000..d606e845b00
--- /dev/null
+++ b/source/blender/compositor/intern/COM_WorkPackage.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_WorkPackage.h"
+
+WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber) {
+ this->executionGroup = group;
+ this->chunkNumber = chunkNumber;
+}
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
new file mode 100644
index 00000000000..3169a9dcc30
--- /dev/null
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+class WorkPackage;
+
+#ifndef _COM_WorkPackage_h_
+#define _COM_WorkPackage_h_
+
+#include "COM_ExecutionGroup.h"
+
+/**
+ * @brief contains data about work that can be scheduled
+ * @see WorkScheduler
+ */
+class WorkPackage {
+private:
+ /**
+ * @brief executionGroup with the operations-setup to be evaluated
+ */
+ ExecutionGroup* executionGroup;
+
+ /**
+ * @brief number of the chunk to be executed
+ */
+ unsigned int chunkNumber;
+public:
+ /**
+ * @constructor
+ * @param group the ExecutionGroup
+ * @param chunkNumber the number of the chunk
+ */
+ WorkPackage(ExecutionGroup* group, unsigned int chunkNumber);
+
+ /**
+ * @brief get the ExecutionGroup
+ */
+ ExecutionGroup* getExecutionGroup() const {return this->executionGroup;}
+
+ /**
+ * @brief get the number of the chunk
+ */
+ unsigned int getChunkNumber() const {return this->chunkNumber;}
+};
+
+#endif
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
new file mode 100644
index 00000000000..e7c1e00dd96
--- /dev/null
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -0,0 +1,313 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include <list>
+#include "COM_WorkScheduler.h"
+#include "PIL_time.h"
+#include "BLI_threads.h"
+#include "COM_CPUDevice.h"
+#include "COM_OpenCLDevice.h"
+#include "OCL_opencl.h"
+#include "stdio.h"
+#include "COM_OpenCLKernels.cl.cpp"
+
+#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
+#warning COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD is activated. Use only for debugging.
+#elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+#else
+#error COM_CURRENT_THREADING_MODEL No threading model selected
+#endif
+
+
+/// @brief global state of the WorkScheduler.
+static WorkSchedulerState state;
+/// @brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
+static vector<CPUDevice*> cpudevices;
+
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+/// @brief list of all thread for every CPUDevice in cpudevices a thread exists
+static ListBase cputhreads;
+/// @brief all scheduled work for the cpu
+static ThreadQueue * cpuqueue;
+static ThreadQueue * gpuqueue;
+#ifdef COM_OPENCL_ENABLED
+static cl_context context;
+static cl_program program;
+/// @brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created
+static vector<OpenCLDevice*> gpudevices;
+/// @brief list of all thread for every GPUDevice in cpudevices a thread exists
+static ListBase gputhreads;
+/// @brief all scheduled work for the gpu
+#ifdef COM_OPENCL_ENABLED
+static bool openclActive = false;
+#endif
+#endif
+#endif
+
+
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+void* WorkScheduler::thread_execute_cpu(void* data) {
+ bool continueLoop = true;
+ Device* device = (Device*)data;
+ while (continueLoop) {
+ WorkPackage* work = (WorkPackage*)BLI_thread_queue_pop(cpuqueue);
+ if (work) {
+ device->execute(work);
+ delete work;
+ }
+ PIL_sleep_ms(10);
+
+ if (WorkScheduler::isStopping()) {
+ continueLoop = false;
+ }
+ }
+ return NULL;
+}
+
+void* WorkScheduler::thread_execute_gpu(void* data) {
+ bool continueLoop = true;
+ Device* device = (Device*)data;
+ while (continueLoop) {
+ WorkPackage* work = (WorkPackage*)BLI_thread_queue_pop(gpuqueue);
+ if (work) {
+ device->execute(work);
+ delete work;
+ }
+ PIL_sleep_ms(10);
+
+ if (WorkScheduler::isStopping()) {
+ continueLoop = false;
+ }
+ }
+ return NULL;
+}
+
+bool WorkScheduler::isStopping() {return state == COM_WSS_STOPPING;}
+#endif
+
+
+
+void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) {
+ WorkPackage* package = new WorkPackage(group, chunkNumber);
+#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
+ CPUDevice device;
+ device.execute(package);
+ delete package;
+#elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+#ifdef COM_OPENCL_ENABLED
+ if (group->isOpenCL() && openclActive){
+ BLI_thread_queue_push(gpuqueue, package);
+ } else{
+ BLI_thread_queue_push(cpuqueue, package);
+ }
+#else
+ BLI_thread_queue_push(cpuqueue, package);
+#endif
+#endif
+}
+
+void WorkScheduler::start(CompositorContext &context) {
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+ unsigned int index;
+ cpuqueue = BLI_thread_queue_init();
+ BLI_thread_queue_nowait(cpuqueue);
+ BLI_init_threads(&cputhreads, thread_execute_cpu, cpudevices.size());
+ for (index = 0 ; index < cpudevices.size() ; index ++) {
+ Device* device = cpudevices[index];
+ BLI_insert_thread(&cputhreads, device);
+ }
+#ifdef COM_OPENCL_ENABLED
+ if (context.getHasActiveOpenCLDevices()) {
+ gpuqueue = BLI_thread_queue_init();
+ BLI_thread_queue_nowait(gpuqueue);
+ BLI_init_threads(&gputhreads, thread_execute_gpu, gpudevices.size());
+ for (index = 0 ; index < gpudevices.size() ; index ++) {
+ Device* device = gpudevices[index];
+ BLI_insert_thread(&gputhreads, device);
+ }
+ openclActive = true;
+ } else {
+ openclActive = false;
+ }
+#endif
+#endif
+ state = COM_WSS_STARTED;
+}
+void WorkScheduler::finish() {
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+#ifdef COM_OPENCL_ENABLED
+ if (openclActive) {
+ while (BLI_thread_queue_size(gpuqueue) + BLI_thread_queue_size(cpuqueue) > 0) {
+ PIL_sleep_ms(10);
+ }
+ } else {
+ while (BLI_thread_queue_size(cpuqueue) > 0) {
+ PIL_sleep_ms(10);
+ }
+ }
+#else
+ while (BLI_thread_queue_size(cpuqueue) > 0) {
+ PIL_sleep_ms(10);
+ }
+#endif
+#endif
+}
+void WorkScheduler::stop() {
+ state = COM_WSS_STOPPING;
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+ BLI_end_threads(&cputhreads);
+ BLI_thread_queue_free(cpuqueue);
+ cpuqueue = NULL;
+#ifdef COM_OPENCL_ENABLED
+ if (openclActive) {
+ BLI_end_threads(&gputhreads);
+ BLI_thread_queue_free(gpuqueue);
+ gpuqueue = NULL;
+ }
+#endif
+#endif
+ state = COM_WSS_STOPPED;
+}
+
+bool WorkScheduler::hasGPUDevices() {
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+#ifdef COM_OPENCL_ENABLED
+ return gpudevices.size()>0;
+#else
+ return 0;
+#endif
+#else
+ return 0;
+#endif
+}
+
+extern void clContextError(const char *errinfo, const void *private_info, size_t cb, void *user_data) {
+ printf("OPENCL error: %s\n", errinfo);
+}
+
+void WorkScheduler::initialize() {
+ state = COM_WSS_UNKNOWN;
+
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+ int numberOfCPUThreads = BLI_system_thread_count();
+
+ for (int index = 0 ; index < numberOfCPUThreads ; index ++) {
+ CPUDevice *device = new CPUDevice();
+ device->initialize();
+ cpudevices.push_back(device);
+ }
+#ifdef COM_OPENCL_ENABLED
+ context = NULL;
+ program = NULL;
+ if (clCreateContextFromType) {
+ cl_uint numberOfPlatforms;
+ cl_int error;
+ error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ printf("%d number of platforms\n", numberOfPlatforms);
+ cl_platform_id *platforms = new cl_platform_id[numberOfPlatforms];
+ error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
+ unsigned int indexPlatform;
+ cl_uint totalNumberOfDevices = 0;
+ for (indexPlatform = 0 ; indexPlatform < numberOfPlatforms ; indexPlatform ++) {
+ cl_platform_id platform = platforms[indexPlatform];
+ cl_uint numberOfDevices;
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
+ totalNumberOfDevices += numberOfDevices;
+ }
+
+ cl_device_id *cldevices = new cl_device_id[totalNumberOfDevices];
+ unsigned int numberOfDevicesReceived = 0;
+ for (indexPlatform = 0 ; indexPlatform < numberOfPlatforms ; indexPlatform ++) {
+ cl_platform_id platform = platforms[indexPlatform];
+ cl_uint numberOfDevices;
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices+numberOfDevicesReceived*sizeof (cl_device_id), 0);
+ numberOfDevicesReceived += numberOfDevices;
+ }
+ context = clCreateContext(NULL, totalNumberOfDevices, cldevices, clContextError, NULL, &error);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ program = clCreateProgramWithSource(context, 1, &sourcecode, 0, &error);
+ error = clBuildProgram(program, totalNumberOfDevices, cldevices, 0, 0, 0);
+ if (error != CL_SUCCESS) {
+ cl_int error2;
+ size_t ret_val_size;
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
+ if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ char* build_log = new char[ret_val_size+1];
+ error2 = clGetProgramBuildInfo(program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
+ if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ build_log[ret_val_size] = '\0';
+ printf("%s", build_log);
+ delete build_log;
+
+ }
+ unsigned int indexDevices;
+ for (indexDevices = 0 ; indexDevices < totalNumberOfDevices ; indexDevices ++) {
+ cl_device_id device = cldevices[indexDevices];
+ OpenCLDevice* clDevice = new OpenCLDevice(context, device, program);
+ clDevice->initialize(),
+ gpudevices.push_back(clDevice);
+ char resultString[32];
+ error = clGetDeviceInfo(device, CL_DEVICE_NAME, 32, resultString, 0);
+ printf("OPENCL_DEVICE: %s, ", resultString);
+ error = clGetDeviceInfo(device, CL_DEVICE_VENDOR, 32, resultString, 0);
+ printf("%s\n", resultString);
+ }
+ delete cldevices;
+ delete platforms;
+ }
+#endif
+#endif
+
+ state = COM_WSS_INITIALIZED;
+}
+
+void WorkScheduler::deinitialize() {
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+ Device* device;
+ while(cpudevices.size()>0) {
+ device = cpudevices.back();
+ cpudevices.pop_back();
+ device->deinitialize();
+ delete device;
+ }
+#ifdef COM_OPENCL_ENABLED
+ while(gpudevices.size()>0) {
+ device = gpudevices.back();
+ gpudevices.pop_back();
+ device->deinitialize();
+ delete device;
+ }
+ if (program) {
+ clReleaseProgram(program);
+ program = NULL;
+ }
+ if (context) {
+ clReleaseContext(context);
+ context = NULL;
+ }
+#endif
+#endif
+ state = COM_WSS_DEINITIALIZED;
+}
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
new file mode 100644
index 00000000000..0befa209e47
--- /dev/null
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_WorkScheduler_h_
+#define _COM_WorkScheduler_h_
+
+#include "COM_ExecutionGroup.h"
+extern "C" {
+ #include "BLI_threads.h"
+}
+#include "COM_WorkPackage.h"
+#include "COM_defines.h"
+#include "COM_Device.h"
+
+// STATES
+/** @brief states of the WorkScheduler
+ * @ingroup execution
+ */
+typedef enum WorkSchedulerState {
+ COM_WSS_UNKNOWN = -1,
+ COM_WSS_INITIALIZED = 0,
+ COM_WSS_STARTED = 1,
+ COM_WSS_STOPPING = 2,
+ COM_WSS_STOPPED = 3,
+ COM_WSS_DEINITIALIZED = 4
+} WorkSchedulerState;
+
+/** @brief the workscheduler
+ * @ingroup execution
+ */
+class WorkScheduler {
+
+#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
+ /**
+ * @brief are we being stopped.
+ */
+ static bool isStopping();
+
+ /**
+ * @brief main thread loop for cpudevices
+ * inside this loop new work is queried and being executed
+ */
+ static void* thread_execute_cpu(void* data);
+
+ /**
+ * @brief main thread loop for gpudevices
+ * inside this loop new work is queried and being executed
+ */
+ static void* thread_execute_gpu(void* data);
+#endif
+public:
+ /**
+ * @brief schedule a chunk of a group to be calculated.
+ * An execution group schedules a chunk in the WorkScheduler
+ * when ExecutionGroup.isOpenCL is set the work will be handled by a OpenCLDevice
+ * otherwide the work is scheduled for an CPUDevice
+ * @see ExecutionGroup.execute
+ * @param group the execution group
+ * @param chunkNumber the number of the chunk in the group to be executed
+ */
+ static void schedule(ExecutionGroup* group, int chunkNumber);
+
+ /**
+ * @brief initialize the WorkScheduler
+ *
+ * during initialization the mutexes are initialized.
+ * there are two mutexes (for every device type one)
+ * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
+ * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
+ * these devices are stored in a separate list (cpudevices & gpudevices)
+ */
+ static void initialize();
+
+ /**
+ * @brief deinitialize the WorkScheduler
+ * free all allocated resources
+ */
+ static void deinitialize();
+
+ /**
+ * @brief Start the execution
+ * this methods will start the WorkScheduler. Inside this method all threads are initialized.
+ * for every device a thread is created.
+ * @see initialize Initialization and query of the number of devices
+ */
+ static void start(CompositorContext &context);
+
+ /**
+ * @brief stop the execution
+ * All created thread by the start method are destroyed.
+ * @see start
+ */
+ static void stop();
+
+ /**
+ * @brief wait for all work to be completed.
+ */
+ static void finish();
+
+ /**
+ * @brief Are there OpenCL capable GPU devices initialized?
+ * the result of this method is stored in the CompositorContext
+ * A node can generate a different operation tree when OpenCLDevices exists.
+ * @see CompositorContext.getHasActiveOpenCLDevices
+ */
+ static bool hasGPUDevices();
+};
+#endif
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
new file mode 100644
index 00000000000..5707fc2c2fe
--- /dev/null
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+
+#include "BKE_node.h"
+extern "C" {
+ #include "BLI_threads.h"
+}
+
+#include "COM_compositor.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_WorkScheduler.h"
+
+static ThreadMutex *compositorMutex;
+void COM_execute(bNodeTree *editingtree, int rendering) {
+ if (compositorMutex == NULL) { /// TODO: move to blender startup phase
+ compositorMutex = new ThreadMutex();
+ BLI_mutex_init(compositorMutex);
+ WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere
+ }
+ BLI_mutex_lock(compositorMutex);
+ if (editingtree->test_break && editingtree->test_break(editingtree->tbh)) {
+ // during editing multiple calls to this method can be triggered.
+ // make sure one the last one will be doing the work.
+ BLI_mutex_unlock(compositorMutex);
+ return;
+
+ }
+
+ /* set progress bar to 0% and status to init compositing*/
+ editingtree->progress(editingtree->prh, 0.0);
+ editingtree->stats_draw(editingtree->sdh, (char*)"Compositing");
+
+ /* initialize execution system */
+ ExecutionSystem* system = new ExecutionSystem(editingtree, rendering);
+ system->execute();
+ delete system;
+
+ BLI_mutex_unlock(compositorMutex);
+}
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
new file mode 100644
index 00000000000..7cd26bc79b7
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_AlphaOverNode.h"
+
+#include "COM_MixBaseOperation.h"
+#include "COM_AlphaOverKeyOperation.h"
+#include "COM_AlphaOverMixedOperation.h"
+#include "COM_AlphaOverPremultiplyOperation.h"
+
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "DNA_material_types.h" // the ramp types
+
+void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *valueSocket = this->getInputSocket(0);
+ InputSocket *color1Socket = this->getInputSocket(1);
+ InputSocket *color2Socket = this->getInputSocket(2);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* editorNode = this->getbNode();
+
+ MixBaseOperation *convertProg;
+ NodeTwoFloats *ntf= (NodeTwoFloats*)editorNode->storage;
+ if (ntf->x!= 0.0f) {
+ AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation();
+ mixOperation->setX(ntf->x);
+ convertProg = mixOperation;
+
+ } else if (editorNode->custom1) {
+ convertProg = new AlphaOverKeyOperation();
+ } else {
+ convertProg = new AlphaOverPremultiplyOperation();
+ }
+
+ convertProg->setUseValueAlphaMultiply(false);
+ if (color1Socket->isConnected()) {
+ convertProg->setResolutionInputSocketIndex(1);
+ } else if (color2Socket->isConnected()) {
+ convertProg->setResolutionInputSocketIndex(2);
+ } else {
+ convertProg->setResolutionInputSocketIndex(0);
+ }
+ valueSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph);
+ color1Socket->relinkConnections(convertProg->getInputSocket(1), true, 1, graph);
+ color2Socket->relinkConnections(convertProg->getInputSocket(2), true, 2, graph);
+ outputSocket->relinkConnections(convertProg->getOutputSocket(0));
+ graph->addOperation(convertProg);
+}
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
new file mode 100644
index 00000000000..b9840f89d3a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_AlphaOverNode_h
+#define _COM_AlphaOverNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief AlphaOverNode
+ * @ingroup Node
+ */
+class AlphaOverNode: public Node {
+public:
+ AlphaOverNode(bNode* editorNode) :Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
new file mode 100644
index 00000000000..5302fb01f1c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BilateralBlurNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_node_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_BilateralBlurOperation.h"
+
+BilateralBlurNode::BilateralBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ NodeBilateralBlurData *data = (NodeBilateralBlurData*)this->getbNode()->storage;
+ BilateralBlurOperation *operation = new BilateralBlurOperation();
+ operation->setQuality(context->getQuality());
+ operation->setData(data);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
new file mode 100644
index 00000000000..d5d9b7367a4
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BilateralBlurNode_h_
+#define _COM_BilateralBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BilateralBlurNode
+ * @ingroup Node
+ */
+class BilateralBlurNode: public Node {
+public:
+ BilateralBlurNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
new file mode 100644
index 00000000000..c278ea877ba
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BlurNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_node_types.h"
+#include "COM_GaussianXBlurOperation.h"
+#include "COM_GaussianYBlurOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_GaussianBokehBlurOperation.h"
+#include "COM_FastGaussianBlurOperation.h"
+
+BlurNode::BlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ bNode* editorNode = this->getbNode();
+ NodeBlurData * data = (NodeBlurData*)editorNode->storage;
+ const bNodeSocket *sock = this->getInputSocket(1)->getbNodeSocket();
+ //const float size = ((const bNodeSocketValueFloat*)sock->default_value)->value;
+
+ CompositorQuality quality = context->getQuality();
+
+ if (data->filtertype == R_FILTER_MITCH || data->filtertype == R_FILTER_CATROM) {
+ quality = COM_QUALITY_HIGH;
+ }
+ if (data->filtertype == R_FILTER_FAST_GAUSS) {
+ FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
+ operationfgb->setData(data);
+ this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0));
+ graph->addOperation(operationfgb);
+ addPreviewOperation(graph, operationfgb->getOutputSocket(), 5);
+ }else if (!data->bokeh) {
+ GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
+ operationx->setData(data);
+ operationx->setQuality(quality);
+ this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), true, 1, graph);
+ graph->addOperation(operationx);
+ GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
+ operationy->setData(data);
+ operationy->setQuality(quality);
+ this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket());
+ graph->addOperation(operationy);
+ addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
+ addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1));
+ addPreviewOperation(graph, operationy->getOutputSocket(), 5);
+ } else {
+ GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
+ operation->setData(data);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ operation->setQuality(quality);
+ graph->addOperation(operation);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ addPreviewOperation(graph, operation->getOutputSocket(), 5);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h
new file mode 100644
index 00000000000..087e2be208f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BlurNode_h_
+#define _COM_BlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BlurNode
+ * @ingroup Node
+ */
+
+class BlurNode: public Node {
+public:
+ BlurNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
new file mode 100644
index 00000000000..c40bcab3ffb
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BokehBlurNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_object_types.h"
+#include "DNA_node_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_BokehBlurOperation.h"
+#include "COM_VariableSizeBokehBlurOperation.h"
+#include "COM_ConvertDepthToRadiusOperation.h"
+
+BokehBlurNode::BokehBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ Object* camob = context->getScene()->camera;
+
+ if (this->getInputSocket(2)->isConnected()) {
+ VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
+ ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
+ converter->setfStop(4.0f);
+ converter->setCameraObject(camob);
+ operation->setMaxBlur(16);
+ operation->setQuality(context->getQuality());
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), true, 2, graph);
+ addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2));
+ graph->addOperation(operation);
+ graph->addOperation(converter);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ } else {
+ BokehBlurOperation *operation = new BokehBlurOperation();
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), true, 3, graph);
+ operation->setSize(((bNodeSocketValueFloat*)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
+ operation->setQuality(context->getQuality());
+ graph->addOperation(operation);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
new file mode 100644
index 00000000000..cb9d117c8ae
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehBlurNode_h_
+#define _COM_BokehBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BokehBlurNode
+ * @ingroup Node
+ */
+
+class BokehBlurNode: public Node {
+public:
+ BokehBlurNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
new file mode 100644
index 00000000000..511727636b5
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BokehImageNode.h"
+#include "DNA_scene_types.h"
+#include "COM_BokehImageOperation.h"
+#include "COM_ExecutionSystem.h"
+
+BokehImageNode::BokehImageNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ BokehImageOperation *operation = new BokehImageOperation();
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ operation->setData((NodeBokehImage*)this->getbNode()->storage);
+ addPreviewOperation(graph, operation->getOutputSocket(0), 9);
+}
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
new file mode 100644
index 00000000000..f3322077c47
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehImageNode_h_
+#define _COM_BokehImageNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BokehImageNode
+ * @ingroup Node
+ */
+class BokehImageNode: public Node {
+public:
+ BokehImageNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
new file mode 100644
index 00000000000..7f904f1acc0
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BoxMaskNode.h"
+#include "DNA_scene_types.h"
+#include "COM_BoxMaskOperation.h"
+#include "COM_ExecutionSystem.h"
+
+BoxMaskNode::BoxMaskNode(bNode *editorNode): Node(editorNode) {
+}
+
+void BoxMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ BoxMaskOperation *operation;
+ operation = new BoxMaskOperation();
+ operation->setData((NodeBoxMask*)this->getbNode()->storage);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ operation->setMaskType(this->getbNode()->custom1);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
new file mode 100644
index 00000000000..c91730fdbb8
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BoxMaskNode_h_
+#define _COM_BoxMaskNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BoxMaskNode
+ * @ingroup Node
+ */
+class BoxMaskNode: public Node {
+public:
+ BoxMaskNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
new file mode 100644
index 00000000000..3ff5538f13e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BrightnessNode.h"
+#include "DNA_scene_types.h"
+#include "COM_BrightnessOperation.h"
+#include "COM_ExecutionSystem.h"
+
+BrightnessNode::BrightnessNode(bNode *editorNode): Node(editorNode) {
+}
+/// @todo: add anti alias when not FSA
+void BrightnessNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ BrightnessOperation *operation = new BrightnessOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2),true, 2, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
new file mode 100644
index 00000000000..8f1c9ccda86
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BrightnessNode_h_
+#define _COM_BrightnessNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief BrightnessNode
+ * @ingroup Node
+ */
+class BrightnessNode: public Node {
+public:
+ BrightnessNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
new file mode 100644
index 00000000000..bf3def05643
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ChannelMatteNode.h"
+#include "BKE_node.h"
+#include "COM_ChannelMatteOperation.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "COM_ConvertRGBToYUVOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+ChannelMatteNode::ChannelMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocketImage = this->getInputSocket(0);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+ NodeOperation *convert=NULL;
+ bNode* node = this->getbNode();
+
+ /* colorspace */
+ switch(node->custom1) {
+ case CMP_NODE_CHANNEL_MATTE_CS_RGB:
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/
+ convert = new ConvertRGBToHSVOperation();
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/
+ convert = new ConvertRGBToYUVOperation();
+ break;
+ case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/
+ convert = new ConvertRGBToYCCOperation();
+ ((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */
+ break;
+ default:
+ break;
+ }
+
+ ChannelMatteOperation *operation = new ChannelMatteOperation();
+ /* pass the ui properties to the operation */
+ operation->setSettings((NodeChroma*)node->storage, node->custom2);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+
+ if (convert) {
+ inputSocketImage->relinkConnections(convert->getInputSocket(0), true, 0, graph);
+ addLink(graph, convert->getOutputSocket(), operation->getInputSocket(0));
+ addLink(graph, convert->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+ graph->addOperation(convert);
+ }
+ else {
+ inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+ }
+
+ if (outputSocketMatte->isConnected()) {
+ outputSocketMatte->relinkConnections(operation->getOutputSocket(0));
+ }
+
+ graph->addOperation(operation);
+ graph->addOperation(operationAlpha);
+
+ addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9);
+
+ if (outputSocketImage->isConnected()) {
+ outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
new file mode 100644
index 00000000000..cb67ac604b2
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef COM_ChannelMatteNODE_H
+#define COM_ChannelMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ChannelMatteNode
+ * @ingroup Node
+ */
+class ChannelMatteNode : public Node
+{
+public:
+ ChannelMatteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ChannelMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
new file mode 100644
index 00000000000..36d315c3a4b
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ChromaMatteNode.h"
+#include "BKE_node.h"
+#include "COM_ChromaMatteOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+ChromaMatteNode::ChromaMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocketImage = this->getInputSocket(0);
+ InputSocket *inputSocketKey = this->getInputSocket(1);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+ ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation();
+ ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation();
+ operationRGBToYCC_Image->setMode(0); /* BLI_YCC_ITU_BT601 */
+ operationRGBToYCC_Key->setMode(0); /* BLI_YCC_ITU_BT601 */
+
+ ChromaMatteOperation *operation = new ChromaMatteOperation();
+ bNode* editorsnode = getbNode();
+ operation->setSettings((NodeChroma*)editorsnode->storage);
+
+ inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), true, 0, graph);
+ inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), true, 0, graph);
+
+ addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
+ addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
+
+ graph->addOperation(operationRGBToYCC_Image);
+ graph->addOperation(operationRGBToYCC_Key);
+ graph->addOperation(operation);
+
+ if (outputSocketMatte->isConnected()) {
+ outputSocketMatte->relinkConnections(operation->getOutputSocket());
+ }
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ addLink(graph, operationRGBToYCC_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+
+ graph->addOperation(operationAlpha);
+ addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9);
+
+ if (outputSocketImage->isConnected()) {
+ outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
new file mode 100644
index 00000000000..6008137b4a7
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef COM_ChromaMatteNODE_H
+#define COM_ChromaMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ChromaMatteNode
+ * @ingroup Node
+ */
+class ChromaMatteNode : public Node
+{
+public:
+ ChromaMatteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ChromaMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
new file mode 100644
index 00000000000..73d10d4b1ca
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorBalanceNode.h"
+#include "COM_ColorBalanceLGGOperation.h"
+#include "COM_ColorBalanceASCCDLOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+#include "COM_MixBlendOperation.h"
+
+ColorBalanceNode::ColorBalanceNode(bNode* editorNode): Node(editorNode)
+{
+}
+void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputImageSocket = this->getInputSocket(1);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+
+ bNode* node = this->getbNode();
+ NodeColorBalance *n= (NodeColorBalance *)node->storage;
+ NodeOperation*operation;
+ if (node->custom1 == 0) {
+ ColorBalanceLGGOperation* operationLGG = new ColorBalanceLGGOperation();
+ {
+ int c;
+
+ for (c = 0; c < 3; c++) {
+ n->lift_lgg[c] = 2.0f - n->lift[c];
+ n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f/n->gamma[c] : 1000000.0f;
+ }
+ }
+
+ operationLGG->setGain(n->gain);
+ operationLGG->setLift(n->lift_lgg);
+ operationLGG->setGammaInv(n->gamma_inv);
+ operation = operationLGG;
+ } else {
+ ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation();
+ operationCDL->setGain(n->gain);
+ operationCDL->setLift(n->lift);
+ operationCDL->setGamma(n->gamma);
+ operation = operationCDL;
+ }
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputImageSocket->relinkConnections(operation->getInputSocket(1), true, 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
new file mode 100644
index 00000000000..6de431a764f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_ColorBalanceNODE_H
+#define COM_ColorBalanceNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorBalanceNode
+ * @ingroup Node
+ */
+class ColorBalanceNode : public Node
+{
+public:
+ ColorBalanceNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif // COM_ColorBalanceNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
new file mode 100644
index 00000000000..ac3e1285e75
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorCorrectionNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ColorCorrectionOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ColorCorrectionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ ColorCorrectionOperation *operation = new ColorCorrectionOperation();
+ bNode* editorNode = getbNode();
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0),true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ operation->setData((NodeColorCorrection*)editorNode->storage);
+ operation->setRedChannelEnabled((editorNode->custom1&1)>0);
+ operation->setGreenChannelEnabled((editorNode->custom1&2)>0);
+ operation->setBlueChannelEnabled((editorNode->custom1&4)>0);
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
new file mode 100644
index 00000000000..e5c35476931
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorCorrectionNode_h_
+#define _COM_ColorCorrectionNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorCorrectionNode
+ * @ingroup Node
+ */
+class ColorCorrectionNode: public Node {
+public:
+ ColorCorrectionNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
new file mode 100644
index 00000000000..55837a35b59
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorCurveNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ColorCurveOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ColorCurveNode::ColorCurveNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ ColorCurveOperation *operation = new ColorCurveOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, graph);
+
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ operation->setCurveMapping((CurveMapping*)this->getbNode()->storage);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
new file mode 100644
index 00000000000..aade20860c2
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorCurveNode_h_
+#define _COM_ColorCurveNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorCurveNode
+ * @ingroup Node
+ */
+class ColorCurveNode: public Node {
+public:
+ ColorCurveNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
new file mode 100644
index 00000000000..fa00c95f50b
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ColorMatteNode.h"
+#include "BKE_node.h"
+#include "COM_ColorMatteOperation.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+ColorMatteNode::ColorMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocketImage = this->getInputSocket(0);
+ InputSocket *inputSocketKey = this->getInputSocket(1);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+ ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
+ ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
+
+ ColorMatteOperation *operation = new ColorMatteOperation();
+ bNode* editorsnode = getbNode();
+ operation->setSettings((NodeChroma*)editorsnode->storage);
+
+ inputSocketImage->relinkConnections(operationRGBToHSV_Image->getInputSocket(0), true, 0, graph);
+ inputSocketKey->relinkConnections(operationRGBToHSV_Key->getInputSocket(0), true, 1, graph);
+
+ addLink(graph, operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
+ addLink(graph, operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
+
+ if (outputSocketMatte->isConnected()) {
+ outputSocketMatte->relinkConnections(operation->getOutputSocket(0));
+ }
+
+ graph->addOperation(operationRGBToHSV_Image);
+ graph->addOperation(operationRGBToHSV_Key);
+ graph->addOperation(operation);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ addLink(graph, operationRGBToHSV_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ graph->addOperation(operationAlpha);
+ addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9);
+
+ if (outputSocketImage->isConnected()) {
+ outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
new file mode 100644
index 00000000000..af64616d054
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef COM_ColorMatteNODE_H
+#define COM_ColorMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorMatteNode
+ * @ingroup Node
+ */
+class ColorMatteNode : public Node
+{
+public:
+ ColorMatteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ColorMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp
new file mode 100644
index 00000000000..0eee305a7e6
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorNode.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorNode.h"
+#include "DNA_scene_types.h"
+#include "COM_SetColorOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ColorNode::ColorNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ColorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ SetColorOperation *operation = new SetColorOperation();
+ bNodeSocket* socket = this->getEditorOutputSocket(0);
+ bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)socket->default_value;
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ operation->setChannels(dval->value);
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
new file mode 100644
index 00000000000..6a9f3062676
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorNode_h_
+#define _COM_ColorNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorNode
+ * @ingroup Node
+ */
+class ColorNode: public Node {
+public:
+ ColorNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
new file mode 100644
index 00000000000..bd1b3b5a35e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorRampNode.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+#include "COM_ColorRampOperation.h"
+#include "COM_SeparateChannelOperation.h"
+#include "DNA_texture_types.h"
+
+ColorRampNode::ColorRampNode(bNode* editorNode): Node(editorNode)
+{}
+
+void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ OutputSocket *outputSocketAlpha = this->getOutputSocket(1);
+ bNode* editorNode = this->getbNode();
+
+ ColorRampOperation * operation = new ColorRampOperation();
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ if (outputSocketAlpha->isConnected()) {
+ SeparateChannelOperation *operation2 = new SeparateChannelOperation();
+ outputSocketAlpha->relinkConnections(operation2->getOutputSocket());
+ addLink(graph, operation->getOutputSocket(), operation2->getInputSocket(0));
+ operation2->setChannel(3);
+ graph->addOperation(operation2);
+ }
+ operation->setColorBand((ColorBand*)editorNode->storage);
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
new file mode 100644
index 00000000000..de0f2a5395e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_ColorRampNODE_H
+#define COM_ColorRampNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorRampNode
+ * @ingroup Node
+ */
+class ColorRampNode : public Node
+{
+public:
+ ColorRampNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif // COM_ColorRampNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
new file mode 100644
index 00000000000..011a2cb12cc
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorSpillNode.h"
+#include "BKE_node.h"
+#include "COM_ColorSpillOperation.h"
+
+ColorSpillNode::ColorSpillNode(bNode *editorNode): Node(editorNode)
+{}
+
+void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocketImage = this->getInputSocket(0);
+ InputSocket *inputSocketFac = this->getInputSocket(1);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+
+ bNode* editorsnode = getbNode();
+
+
+ ColorSpillOperation *operation;
+ if (editorsnode->custom2 == 0) {
+ // Simple color spill
+ operation = new ColorSpillOperation();
+ } else {
+ // Average color spill
+ operation = new ColorSpillAverageOperation();
+ }
+ operation->setSettings((NodeColorspill*)editorsnode->storage);
+ operation->setSpillChannel(editorsnode->custom1-1); // Channel for spilling
+
+
+ inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputSocketFac->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+
+ outputSocketImage->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
new file mode 100644
index 00000000000..ed0e33b0742
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_ColorSpillNODE_H
+#define COM_ColorSpillNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief ColorSpillNode
+ * @ingroup Node
+ */
+class ColorSpillNode : public Node
+{
+public:
+ ColorSpillNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_ColorSpillNODE_H
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
new file mode 100644
index 00000000000..a58c2e9fd19
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorToBWNode.h"
+
+#include "COM_ConvertColorToBWOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ColourToBWNode::ColourToBWNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *colourSocket = this->getInputSocket(0);
+ OutputSocket *valueSocket = this->getOutputSocket(0);
+
+ ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
+ colourSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph);
+ valueSocket->relinkConnections(convertProg->getOutputSocket(0));
+ graph->addOperation(convertProg);
+}
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
new file mode 100644
index 00000000000..e2badd1b104
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColourToBWNode_h
+#define _COM_ColourToBWNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief ColourToBWNode
+ * @ingroup Node
+ */
+class ColourToBWNode : public Node {
+public:
+ ColourToBWNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
new file mode 100644
index 00000000000..bd43f207fc7
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CombineHSVANode.h"
+
+#include "COM_CombineChannelsOperation.h"
+
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ConvertHSVToRGBOperation.h"
+
+CombineHSVANode::CombineHSVANode(bNode *editorNode): CombineRGBANode(editorNode) {
+}
+
+void CombineHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ ConvertHSVToRGBOperation *operation = new ConvertHSVToRGBOperation();
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ if (outputSocket->isConnected()) {
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ addLink(graph, outputSocket, operation->getInputSocket(0));
+ }
+ graph->addOperation(operation);
+ CombineRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h
new file mode 100644
index 00000000000..fabd6f91f7e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineHSVANode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CombineHSVANode_h
+#define _COM_CombineHSVANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_CombineRGBANode.h"
+/**
+ * @brief CombineHSVANode
+ * @ingroup Node
+ */
+class CombineHSVANode : public CombineRGBANode {
+public:
+ CombineHSVANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
new file mode 100644
index 00000000000..8a1a34589a5
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CombineRGBANode.h"
+
+#include "COM_CombineChannelsOperation.h"
+
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "DNA_material_types.h" // the ramp types
+
+
+CombineRGBANode::CombineRGBANode(bNode *editorNode): Node(editorNode) {
+}
+
+
+void CombineRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputRSocket = this->getInputSocket(0);
+ InputSocket *inputGSocket = this->getInputSocket(1);
+ InputSocket *inputBSocket = this->getInputSocket(2);
+ InputSocket *inputASocket = this->getInputSocket(3);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+
+ CombineChannelsOperation *operation = new CombineChannelsOperation();
+ if (inputRSocket->isConnected()) {
+ operation->setResolutionInputSocketIndex(0);
+ } else if (inputGSocket->isConnected()) {
+ operation->setResolutionInputSocketIndex(1);
+ } else if (inputBSocket->isConnected()) {
+ operation->setResolutionInputSocketIndex(2);
+ } else {
+ operation->setResolutionInputSocketIndex(3);
+ }
+ inputRSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputGSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ inputBSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ inputASocket->relinkConnections(operation->getInputSocket(3), true, 3, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/compositor/nodes/COM_CombineRGBANode.h
new file mode 100644
index 00000000000..182bfece6d3
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineRGBANode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CombineRGBANode_h
+#define _COM_CombineRGBANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief CombineRGBANode
+ * @ingroup Node
+ */
+class CombineRGBANode : public Node {
+public:
+ CombineRGBANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
new file mode 100644
index 00000000000..bf31daf5852
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_CombineYCCANode.h"
+#include "COM_ConvertYCCToRGBOperation.h"
+
+CombineYCCANode::CombineYCCANode(bNode *editorNode): CombineRGBANode(editorNode) {
+}
+
+void CombineYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+
+ bNode *node = this->getbNode();
+ operation->setMode(node->custom1);
+
+ if (outputSocket->isConnected()) {
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ addLink(graph, outputSocket, operation->getInputSocket(0));
+ }
+
+ graph->addOperation(operation);
+ CombineRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h
new file mode 100644
index 00000000000..86e2d50e950
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineYCCANode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_CombineYCCANode_h
+#define _COM_CombineYCCANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_CombineRGBANode.h"
+/**
+ * @brief CombineYCCANode
+ * @ingroup Node
+ */
+class CombineYCCANode : public CombineRGBANode {
+public:
+ CombineYCCANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
new file mode 100644
index 00000000000..3348eacc86f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_CombineYUVANode.h"
+#include "COM_ConvertYUVToRGBOperation.h"
+
+CombineYUVANode::CombineYUVANode(bNode *editorNode): CombineRGBANode(editorNode) {
+}
+
+void CombineYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ ConvertYUVToRGBOperation *operation = new ConvertYUVToRGBOperation();
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ if (outputSocket->isConnected()) {
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ addLink(graph, outputSocket, operation->getInputSocket(0));
+ }
+ graph->addOperation(operation);
+ CombineRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h
new file mode 100644
index 00000000000..7d2f9cddf7e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CombineYUVANode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_CombineYUVANode_h
+#define _COM_CombineYUVANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_CombineRGBANode.h"
+/**
+ * @brief CombineYUVANode
+ * @ingroup Node
+ */
+class CombineYUVANode : public CombineRGBANode {
+public:
+ CombineYUVANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
new file mode 100644
index 00000000000..95db41b322c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CompositorNode.h"
+#include "COM_CompositorOperation.h"
+#include "COM_ExecutionSystem.h"
+
+CompositorNode::CompositorNode(bNode *editorNode): Node(editorNode) {
+}
+
+void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *imageSocket = this->getInputSocket(0);
+ InputSocket *alphaSocket = this->getInputSocket(1);
+ if (imageSocket->isConnected()) {
+ CompositorOperation *colourAlphaProg = new CompositorOperation();
+ colourAlphaProg->setScene(context->getScene());
+ colourAlphaProg->setbNodeTree(context->getbNodeTree());
+ imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0));
+ alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1));
+ graph->addOperation(colourAlphaProg);
+ addPreviewOperation(graph, colourAlphaProg->getInputSocket(0), 5);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
new file mode 100644
index 00000000000..e77d1d2f225
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CompositorNode_h
+#define _COM_CompositorNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief CompositorNode
+ * @ingroup Node
+ */
+class CompositorNode : public Node {
+public:
+ CompositorNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
new file mode 100644
index 00000000000..4e20b3a5d3a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertAlphaNode.h"
+#include "COM_ConvertPremulToKeyOperation.h"
+#include "COM_ConvertKeyToPremulOperation.h"
+#include "COM_ExecutionSystem.h"
+
+void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ NodeOperation* operation = NULL;
+ bNode* node = this->getbNode();
+
+ /* value hardcoded in rna_nodetree.c */
+ if (node->custom1 == 1){
+ operation = new ConvertPremulToKeyOperation();
+ }
+ else {
+ operation = new ConvertKeyToPremulOperation();
+ }
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
new file mode 100644
index 00000000000..04834a45c45
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertAlphaNode_h
+#define _COM_ConvertAlphaNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief ConvertAlphaNode
+ * @ingroup Node
+ */
+class ConvertAlphaNode: public Node {
+public:
+ ConvertAlphaNode(bNode* editorNode) :Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
new file mode 100644
index 00000000000..fdbb1529c60
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CropNode.h"
+#include "COM_CropOperation.h"
+
+
+CropNode::CropNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context){
+ bNode* node = getbNode();
+ NodeTwoXYs *cropSettings = (NodeTwoXYs*)node->storage;
+ bool relative = (bool)node->custom2;
+ bool cropImage = (bool)node->custom1;
+ CropBaseOperation *operation;
+ if (cropImage){
+ operation = new CropImageOperation();
+ } else {
+ operation = new CropOperation();
+ }
+ operation->setCropSettings(cropSettings);
+ operation->setRelative(relative);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
new file mode 100644
index 00000000000..a39bd47f22a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CropNode_h_
+#define _COM_CropNode_h_
+
+#include "COM_Node.h"
+
+class CropNode: public Node {
+public:
+ CropNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
+
+
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
new file mode 100644
index 00000000000..7f5c9896bbe
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DefocusNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_camera_types.h"
+#include "DNA_object_types.h"
+#include "DNA_node_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_ConvertDepthToRadiusOperation.h"
+#include "COM_VariableSizeBokehBlurOperation.h"
+#include "COM_BokehImageOperation.h"
+#include "COM_MathBaseOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_GammaCorrectOperation.h"
+
+DefocusNode::DefocusNode(bNode *editorNode): Node(editorNode) {
+}
+
+void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ bNode *node = this->getbNode();
+ Scene *scene= (Scene*)node->id;
+ Object* camob = (scene)? scene->camera: NULL;
+ NodeDefocus *data = (NodeDefocus*)node->storage;
+
+ NodeOperation* radiusOperation;
+ if (data->no_zbuf) {
+ MathMultiplyOperation *multiply = new MathMultiplyOperation();
+ SetValueOperation *multiplier = new SetValueOperation();
+ multiplier->setValue(data->scale);
+ SetValueOperation *maxRadius = new SetValueOperation();
+ maxRadius->setValue(data->maxblur);
+ MathMinimumOperation *minimize = new MathMinimumOperation();
+ this->getInputSocket(1)->relinkConnections(multiply->getInputSocket(0), true, 1, graph);
+ addLink(graph, multiplier->getOutputSocket(), multiply->getInputSocket(1));
+ addLink(graph, maxRadius->getOutputSocket(), minimize->getInputSocket(1));
+ addLink(graph, multiply->getOutputSocket(), minimize->getInputSocket(0));
+
+ graph->addOperation(multiply);
+ graph->addOperation(multiplier);
+ graph->addOperation(maxRadius);
+ graph->addOperation(minimize);
+ radiusOperation = minimize;
+ } else {
+ ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation();
+ converter->setCameraObject(camob);
+ converter->setfStop(data->fstop);
+ converter->setMaxRadius(data->maxblur);
+ this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), true, 1, graph);
+ graph->addOperation(converter);
+ radiusOperation = converter;
+ }
+
+ BokehImageOperation *bokeh = new BokehImageOperation();
+ NodeBokehImage * bokehdata = new NodeBokehImage();
+ bokehdata->angle = data->rotation;
+ bokehdata->rounding = 0.0f;
+ bokehdata->flaps = data->bktype;
+ if (data->bktype<3) {
+ bokehdata->flaps = 5;
+ bokehdata->rounding = 1.0f;
+ }
+ bokehdata->catadioptric = 0.0f;
+ bokehdata->lensshift = 0.0f;
+
+ bokeh->setData(bokehdata);
+ bokeh->deleteDataOnFinish();
+ graph->addOperation(bokeh);
+
+ VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
+ operation->setQuality(context->getQuality());
+ operation->setMaxBlur(data->maxblur);
+ operation->setThreshold(data->bthresh);
+ addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1));
+ addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2));
+ if (data->gamco) {
+ GammaCorrectOperation * correct = new GammaCorrectOperation();
+ GammaUncorrectOperation * inverse = new GammaUncorrectOperation();
+ this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, true, graph);
+ addLink(graph, correct->getOutputSocket(), operation->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), inverse->getInputSocket(0));
+ this->getOutputSocket()->relinkConnections(inverse->getOutputSocket());
+ graph->addOperation(correct);
+ graph->addOperation(inverse);
+ } else {
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, true, graph);
+ this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
+ }
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h
new file mode 100644
index 00000000000..3d2ff7eb4de
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DefocusNode_h_
+#define _COM_DefocusNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief DefocusNode
+ * @ingroup Node
+ */
+
+class DefocusNode: public Node {
+public:
+ DefocusNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
new file mode 100644
index 00000000000..8327813cf05
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DifferenceMatteNode.h"
+#include "BKE_node.h"
+#include "COM_DifferenceMatteOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+DifferenceMatteNode::DifferenceMatteNode(bNode* editorNode): Node(editorNode)
+{}
+
+void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputSocket2 = this->getInputSocket(1);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+ bNode* editorNode = this->getbNode();
+
+ DifferenceMatteOperation * operationSet = new DifferenceMatteOperation();
+ operationSet->setSettings((NodeChroma*)editorNode->storage);
+ inputSocket->relinkConnections(operationSet->getInputSocket(0), true, 0, graph);
+ inputSocket2->relinkConnections(operationSet->getInputSocket(1), true, 1, graph);
+
+ outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0));
+ graph->addOperation(operationSet);
+
+ SetAlphaOperation * operation = new SetAlphaOperation();
+ addLink(graph, operationSet->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
+ addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
+ outputSocketImage->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+ addPreviewOperation(graph, operation->getOutputSocket(), 5);
+}
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
new file mode 100644
index 00000000000..2adce752f49
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_DifferenceMatteNODE_H
+#define COM_DifferenceMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief DifferenceMatteNode
+ * @ingroup Node
+ */
+class DifferenceMatteNode : public Node
+{
+public:
+ DifferenceMatteNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif // COM_DifferenceMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
new file mode 100644
index 00000000000..185eb6475bf
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DilateErodeNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_DilateErodeOperation.h"
+#include "COM_AntiAliasOperation.h"
+#include "BLI_math.h"
+
+DilateErodeNode::DilateErodeNode(bNode *editorNode): Node(editorNode) {
+}
+
+void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ bNode* editorNode = this->getbNode();
+ DilateErodeOperation *operation = new DilateErodeOperation();
+ operation->setDistance(editorNode->custom2);
+ operation->setInset(2.0f);
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+
+ AntiAliasOperation * antiAlias = new AntiAliasOperation();
+ addLink(graph, operation->getOutputSocket(), antiAlias->getInputSocket(0));
+ this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0));
+ graph->addOperation(operation);
+ graph->addOperation(antiAlias);
+}
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
new file mode 100644
index 00000000000..1ebf7e0b4c8
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DilateErodeNode_h_
+#define _COM_DilateErodeNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief DilateErodeNode
+ * @ingroup Node
+ */
+class DilateErodeNode: public Node {
+public:
+ DilateErodeNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
new file mode 100644
index 00000000000..ef3e4918048
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DirectionalBlurNode.h"
+#include "DNA_scene_types.h"
+#include "DNA_node_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_DirectionalBlurOperation.h"
+
+DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ NodeDBlurData *data = (NodeDBlurData*)this->getbNode()->storage;
+ DirectionalBlurOperation *operation = new DirectionalBlurOperation();
+ operation->setQuality(context->getQuality());
+ operation->setData(data);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
new file mode 100644
index 00000000000..842e330d6d0
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DirectionalBlurNode_h_
+#define _COM_DirectionalBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief DirectionalBlurNode
+ * @ingroup Node
+ */
+class DirectionalBlurNode: public Node {
+public:
+ DirectionalBlurNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
new file mode 100644
index 00000000000..ff5dd413468
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_DisplaceNode.h"
+#include "COM_DisplaceOperation.h"
+#include "COM_DisplaceSimpleOperation.h"
+#include "COM_ExecutionSystem.h"
+
+DisplaceNode::DisplaceNode(bNode *editorNode): Node(editorNode) {
+}
+
+void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+{
+ NodeOperation *operation;
+ if (context->getQuality() == COM_QUALITY_LOW)
+ operation = new DisplaceSimpleOperation();
+ else
+ operation = new DisplaceOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h
new file mode 100644
index 00000000000..3451f05dd1f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_DisplaceNode_h
+#define _COM_DisplaceNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief DisplaceNode
+ * @ingroup Node
+ */
+class DisplaceNode : public Node {
+public:
+ DisplaceNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
new file mode 100644
index 00000000000..c55ce803f97
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_DistanceMatteNode.h"
+#include "BKE_node.h"
+#include "COM_DistanceMatteOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+DistanceMatteNode::DistanceMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocketImage = this->getInputSocket(0);
+ InputSocket *inputSocketKey = this->getInputSocket(1);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+ DistanceMatteOperation *operation = new DistanceMatteOperation();
+ bNode* editorsnode = getbNode();
+ operation->setSettings((NodeChroma*)editorsnode->storage);
+
+ inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputSocketKey->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+
+ if (outputSocketMatte->isConnected()) {
+ outputSocketMatte->relinkConnections(operation->getOutputSocket());
+ }
+
+ graph->addOperation(operation);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+
+ graph->addOperation(operationAlpha);
+ addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9);
+
+ if (outputSocketImage->isConnected()) {
+ outputSocketImage->relinkConnections(operationAlpha->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
new file mode 100644
index 00000000000..740eb767a71
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef COM_DistanceMatteNODE_H
+#define COM_DistanceMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief DistanceMatteNode
+ * @ingroup Node
+ */
+class DistanceMatteNode : public Node
+{
+public:
+ DistanceMatteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_DistanceMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
new file mode 100644
index 00000000000..f1ec4ab9b23
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DoubleEdgeMaskNode.h"
+#include "COM_DoubleEdgeMaskOperation.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+
+DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode): Node(editorNode) {
+}
+
+void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ DoubleEdgeMaskOperation *operation;
+ bNode* bnode = this->getbNode();
+
+ operation = new DoubleEdgeMaskOperation();
+ operation->setAdjecentOnly(bnode->custom1);
+ operation->setKeepInside(bnode->custom2);
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ system->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
new file mode 100644
index 00000000000..26d553a1422
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DoubleEdgeMaskNode_h_
+#define _COM_DoubleEdgeMaskNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief DoubleEdgeMaskNode
+ * @ingroup Node
+ */
+class DoubleEdgeMaskNode: public Node {
+public:
+ DoubleEdgeMaskNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
new file mode 100644
index 00000000000..89996f0e590
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_EllipseMaskNode.h"
+#include "DNA_scene_types.h"
+#include "COM_EllipseMaskOperation.h"
+#include "COM_ExecutionSystem.h"
+
+EllipseMaskNode::EllipseMaskNode(bNode *editorNode): Node(editorNode) {
+}
+
+void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ EllipseMaskOperation *operation;
+ operation = new EllipseMaskOperation();
+ operation->setData((NodeEllipseMask*)this->getbNode()->storage);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ operation->setMaskType(this->getbNode()->custom1);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
new file mode 100644
index 00000000000..4fecf6946cc
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_EllipseMaskNode_h_
+#define _COM_EllipseMaskNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief EllipseMaskNode
+ * @ingroup Node
+ */
+class EllipseMaskNode: public Node {
+public:
+ EllipseMaskNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
new file mode 100644
index 00000000000..ce78e451f30
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_FilterNode.h"
+#include "COM_ConvolutionFilterOperation.h"
+#include "COM_ConvolutionEdgeFilterOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+#include "COM_MixBlendOperation.h"
+
+FilterNode::FilterNode(bNode* editorNode): Node(editorNode)
+{
+}
+
+void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputImageSocket = this->getInputSocket(1);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ ConvolutionFilterOperation *operation = NULL;
+
+ switch(this->getbNode()->custom1) {
+ case CMP_FILT_SOFT:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f);
+ break;
+ case CMP_FILT_SHARP:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(-1,-1,-1,-1,9,-1,-1,-1,-1);
+ break;
+ case CMP_FILT_LAPLACE:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f);
+ break;
+ case CMP_FILT_SOBEL:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(1,2,1,0,0,0,-1,-2,-1);
+ break;
+ case CMP_FILT_PREWITT:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(1,1,1,0,0,0,-1,-1,-1);
+ break;
+ case CMP_FILT_KIRSCH:
+ operation = new ConvolutionEdgeFilterOperation();
+ operation->set3x3Filter(5,5,5,-3,-3,-3,-2,-2,-2);
+ break;
+ case CMP_FILT_SHADOW:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(1,2,1,0,1,0,-1,-2,-1);
+ break;
+ default:
+ operation = new ConvolutionFilterOperation();
+ operation->set3x3Filter(0,0,0,0,1,0,0,0,0);
+ break;
+ }
+
+ inputImageSocket->relinkConnections(operation->getInputSocket(0), true, 1, graph);
+ inputSocket->relinkConnections(operation->getInputSocket(1), true, 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ addPreviewOperation(graph, operation->getOutputSocket(0), 5);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
new file mode 100644
index 00000000000..c77846ef2fe
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_FILTERNODE_H
+#define COM_FILTERNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief FilterNode
+ * @ingroup Node
+ */
+class FilterNode : public Node
+{
+public:
+ FilterNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif // COM_FILTERNODE_H
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
new file mode 100644
index 00000000000..7fbb21478ec
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_FlipNode.h"
+
+#include "COM_FlipOperation.h"
+#include "COM_ExecutionSystem.h"
+
+FlipNode::FlipNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ FlipOperation *operation = new FlipOperation();
+ switch (this->getbNode()->custom1) {
+ case 0: /// @TODO: I didn't find any constants in the old implementation, should I introduce them.
+ operation->setFlipX(true);
+ operation->setFlipY(false);
+ break;
+ case 1:
+ operation->setFlipX(false);
+ operation->setFlipY(true);
+ break;
+ case 2:
+ operation->setFlipX(true);
+ operation->setFlipY(true);
+ break;
+ }
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
new file mode 100644
index 00000000000..593fed452af
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_FlipNode_h_
+#define _COM_FlipNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief FlipNode
+ * @ingroup Node
+ */
+class FlipNode: public Node {
+public:
+ FlipNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp
new file mode 100644
index 00000000000..e61f9245f40
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GammaNode.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GammaNode.h"
+#include "DNA_scene_types.h"
+#include "COM_GammaOperation.h"
+#include "COM_ExecutionSystem.h"
+
+GammaNode::GammaNode(bNode *editorNode): Node(editorNode) {
+}
+
+void GammaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ GammaOperation *operation = new GammaOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h
new file mode 100644
index 00000000000..56f2374467d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GammaNode_h_
+#define _COM_GammaNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief GammaNode
+ * @ingroup Node
+ */
+class GammaNode: public Node {
+public:
+ GammaNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
new file mode 100644
index 00000000000..c0fcad1a5b3
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareNode.h"
+#include "DNA_node_types.h"
+#include "COM_FogGlowImageOperation.h"
+#include "COM_BokehBlurOperation.h"
+#include "COM_GlareThresholdOperation.h"
+#include "COM_GlareSimpleStarOperation.h"
+#include "COM_GlareStreaksOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_MixBlendOperation.h"
+
+GlareNode::GlareNode(bNode *editorNode): Node(editorNode) {
+}
+
+void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ bNode* node = this->getbNode();
+ NodeGlare* glare = (NodeGlare*)node->storage;
+
+ switch (glare->type) {
+
+ default:
+ case 2: // streaks
+ {
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ GlareStreaksOperation * glareoperation = new GlareStreaksOperation();
+ SetValueOperation * mixvalueoperation = new SetValueOperation();
+ MixBlendOperation * mixoperation = new MixBlendOperation();
+
+ this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system);
+ addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
+ addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+ this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+
+ thresholdOperation->setThreshold(glare->threshold);
+ glareoperation->setGlareSettings(glare);
+ mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+ mixoperation->setResolutionInputSocketIndex(1);
+
+ system->addOperation(glareoperation);
+ system->addOperation(thresholdOperation);
+ system->addOperation(mixvalueoperation);
+ system->addOperation(mixoperation);
+ }
+ break;
+ case 1: // fog glow
+ {
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ FogGlowImageOperation * kerneloperation = new FogGlowImageOperation();
+ BokehBlurOperation * bluroperation = new BokehBlurOperation();
+ SetValueOperation * valueoperation = new SetValueOperation();
+ SetValueOperation * mixvalueoperation = new SetValueOperation();
+ MixBlendOperation * mixoperation = new MixBlendOperation();
+ mixoperation->setResolutionInputSocketIndex(1);
+ this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system);
+ addLink(system, thresholdOperation->getOutputSocket(), bluroperation->getInputSocket(0));
+ addLink(system, kerneloperation->getOutputSocket(), bluroperation->getInputSocket(1));
+ addLink(system, valueoperation->getOutputSocket(), bluroperation->getInputSocket(2));
+ addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ addLink(system, bluroperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+
+ thresholdOperation->setThreshold(glare->threshold);
+ bluroperation->setSize(0.003f*glare->size);
+ bluroperation->setQuality(context->getQuality());
+ valueoperation->setValue(1.0f);
+ mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+ this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+
+ system->addOperation(bluroperation);
+ system->addOperation(kerneloperation);
+ system->addOperation(thresholdOperation);
+ system->addOperation(mixvalueoperation);
+ system->addOperation(valueoperation);
+ system->addOperation(mixoperation);
+ }
+ break;
+
+ case 0: // simple star
+ {
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ GlareSimpleStarOperation * glareoperation = new GlareSimpleStarOperation();
+ SetValueOperation * mixvalueoperation = new SetValueOperation();
+ MixBlendOperation * mixoperation = new MixBlendOperation();
+
+ this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system);
+ addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0));
+ addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0));
+ addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2));
+ addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1));
+ this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket());
+
+ thresholdOperation->setThreshold(glare->threshold);
+ glareoperation->setGlareSettings(glare);
+ mixvalueoperation->setValue(0.5f+glare->mix*0.5f);
+ mixoperation->setResolutionInputSocketIndex(1);
+
+
+ system->addOperation(glareoperation);
+ system->addOperation(thresholdOperation);
+ system->addOperation(mixvalueoperation);
+ system->addOperation(mixoperation);
+ }
+ break;
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h
new file mode 100644
index 00000000000..b3e965fa72d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareNode_h_
+#define _COM_GlareNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief GlareNode
+ * @ingroup Node
+ */
+class GlareNode: public Node {
+public:
+ GlareNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp
new file mode 100644
index 00000000000..dcb8691524a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GroupNode.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GroupNode.h"
+#include "COM_SocketProxyNode.h"
+#include "COM_ExecutionSystemHelper.h"
+
+GroupNode::GroupNode(bNode *editorNode): Node(editorNode) {
+}
+
+void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+}
+
+void GroupNode::ungroup(ExecutionSystem &system) {
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+ vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+ unsigned int index;
+
+ /* get the node list size _before_ adding proxy nodes, so they are available for linking */
+ int nodes_start = system.getNodes().size();
+
+ for (index = 0 ; index < inputsockets.size();index ++) {
+ InputSocket * inputSocket = inputsockets[index];
+ bNodeSocket *editorInput = inputSocket->getbNodeSocket();
+ if (editorInput->groupsock) {
+ if (inputSocket->isConnected()) {
+ SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
+ inputSocket->relinkConnections(proxy->getInputSocket(0), true, index, &system);
+ ExecutionSystemHelper::addNode(system.getNodes(), proxy);
+ } else {
+ OutputSocketProxyNode * proxy = new OutputSocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock);
+ inputSocket->relinkConnections(proxy->getInputSocket(0), true, index, &system);
+ ExecutionSystemHelper::addNode(system.getNodes(), proxy);
+ }
+ }
+ }
+
+ for (index = 0 ; index < outputsockets.size();index ++) {
+ OutputSocket * outputSocket = outputsockets[index];
+ bNodeSocket *editorOutput = outputSocket->getbNodeSocket();
+ if (outputSocket->isConnected() && editorOutput->groupsock) {
+ SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorOutput->groupsock, editorOutput);
+ outputSocket->relinkConnections(proxy->getOutputSocket(0));
+ ExecutionSystemHelper::addNode(system.getNodes(), proxy);
+ }
+ }
+
+ bNodeTree* subtree = (bNodeTree*)this->getbNode()->id;
+ ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree);
+}
diff --git a/source/blender/compositor/nodes/COM_GroupNode.h b/source/blender/compositor/nodes/COM_GroupNode.h
new file mode 100644
index 00000000000..a3a46ad2c33
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_GroupNode.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GroupNode_h_
+#define _COM_GroupNode_h_
+
+#include "COM_Node.h"
+#include "COM_ExecutionSystem.h"
+
+/**
+ * @brief Represents a group node
+ * @ingroup Node
+ */
+class GroupNode: public Node {
+public:
+ GroupNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+
+ /**
+ * @brief check if this node a group node.
+ * @returns true
+ */
+ bool isGroupNode() const { return true; }
+
+ /**
+ * @brief ungroup this group node.
+ * during ungroup the subtree (internal nodes and links) of the group node
+ * are added to the ExecutionSystem.
+ *
+ * Between the main tree and the subtree proxy nodes will be added
+ * to translate between InputSocket and OutputSocket
+ *
+ * @param system the ExecutionSystem where to add the subtree
+ */
+ void ungroup(ExecutionSystem &system);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
new file mode 100644
index 00000000000..88ba24498bb
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_HueSaturationValueCorrectNode.h"
+
+#include "COM_ConvertColourToValueProg.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "COM_ConvertHSVToRGBOperation.h"
+#include "COM_MixBlendOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ChangeHSVOperation.h"
+#include "DNA_node_types.h"
+#include "COM_HueSaturationValueCorrectOperation.h"
+
+HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode): Node(editorNode) {
+}
+
+void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *valueSocket = this->getInputSocket(0);
+ InputSocket *colourSocket = this->getInputSocket(1);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* editorsnode = getbNode();
+ CurveMapping *storage = (CurveMapping*)editorsnode->storage;
+
+ if (colourSocket->isConnected() && outputSocket->isConnected()) {
+ ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation();
+ ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation();
+ HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation();
+ MixBlendOperation * blend = new MixBlendOperation();
+
+ colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), true, 0, graph);
+ addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
+ addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
+ addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
+ addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1));
+ valueSocket->relinkConnections(blend->getInputSocket(0), true, 0, graph);
+ outputSocket->relinkConnections(blend->getOutputSocket());
+
+ changeHSV->setCurveMapping(storage);
+
+ blend->setResolutionInputSocketIndex(1);
+
+ graph->addOperation(rgbToHSV);
+ graph->addOperation(hsvToRGB);
+ graph->addOperation(changeHSV);
+ graph->addOperation(blend);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
new file mode 100644
index 00000000000..d69990f712c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_HueSaturationValueCorrectNode_h
+#define _COM_HueSaturationValueCorrectNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief HueSaturationValueCorrectNode
+ * @ingroup Node
+ */
+class HueSaturationValueCorrectNode : public Node {
+public:
+ HueSaturationValueCorrectNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
new file mode 100644
index 00000000000..b4b9b55cf8b
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_HueSaturationValueNode.h"
+
+#include "COM_ConvertColourToValueProg.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "COM_ConvertHSVToRGBOperation.h"
+#include "COM_MixBlendOperation.h"
+#include "COM_SetColorOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ChangeHSVOperation.h"
+#include "DNA_node_types.h"
+
+HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode): Node(editorNode) {
+}
+
+void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *valueSocket = this->getInputSocket(0);
+ InputSocket *colourSocket = this->getInputSocket(1);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* editorsnode = getbNode();
+ NodeHueSat *storage = (NodeHueSat*)editorsnode->storage;
+
+ ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation();
+ ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation();
+ ChangeHSVOperation *changeHSV = new ChangeHSVOperation();
+ MixBlendOperation * blend = new MixBlendOperation();
+
+ colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), true, 0, graph);
+ addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0));
+ addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0));
+ addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2));
+ addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1));
+ valueSocket->relinkConnections(blend->getInputSocket(0), true, 0, graph);
+ outputSocket->relinkConnections(blend->getOutputSocket());
+
+ changeHSV->setHue(storage->hue);
+ changeHSV->setSaturation(storage->sat);
+ changeHSV->setValue(storage->val);
+
+ blend->setResolutionInputSocketIndex(1);
+
+ graph->addOperation(rgbToHSV);
+ graph->addOperation(hsvToRGB);
+ graph->addOperation(changeHSV);
+ graph->addOperation(blend);
+}
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
new file mode 100644
index 00000000000..4fa1a4f547c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_HueSaturationValueNode_h
+#define _COM_HueSaturationValueNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief HueSaturationValueNode
+ * @ingroup Node
+ */
+class HueSaturationValueNode : public Node {
+public:
+ HueSaturationValueNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
new file mode 100644
index 00000000000..440468afd46
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_IDMaskNode.h"
+#include "DNA_scene_types.h"
+#include "COM_IDMaskOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_AntiAliasOperation.h"
+
+IDMaskNode::IDMaskNode(bNode *editorNode): Node(editorNode) {
+}
+void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ bNode* bnode = this->getbNode();
+ IDMaskOperation *operation;
+ operation = new IDMaskOperation();
+ operation->setObjectIndex(bnode->custom1);
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+ if (bnode->custom2==0 || context->getScene()->r.scemode & R_FULL_SAMPLE) {
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ } else {
+ AntiAliasOperation * antiAliasOperation = new AntiAliasOperation();
+ addLink(graph, operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
+ this->getOutputSocket(0)->relinkConnections(antiAliasOperation->getOutputSocket(0));
+ graph->addOperation(antiAliasOperation);
+ }
+ graph->addOperation(operation);
+
+}
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
new file mode 100644
index 00000000000..5559044df4e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_IDMaskNode_h_
+#define _COM_IDMaskNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief IDMaskNode
+ * @ingroup Node
+ */
+class IDMaskNode: public Node {
+public:
+ IDMaskNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
new file mode 100644
index 00000000000..20e6069b60a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#include "COM_ImageNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_ImageOperation.h"
+#include "COM_MultilayerImageOperation.h"
+#include "BKE_node.h"
+#include "BLI_utildefines.h"
+
+ImageNode::ImageNode(bNode *editorNode): Node(editorNode) {
+}
+NodeOperation* ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype) {
+ OutputSocket *outputSocket = this->getOutputSocket(outputsocketIndex);
+ MultilayerBaseOperation * operation = NULL;
+ switch (datatype) {
+ case COM_DT_VALUE:
+ operation = new MultilayerValueOperation(pass);
+ break;
+ case COM_DT_VECTOR:
+ operation = new MultilayerVectorOperation(pass);
+ break;
+ case COM_DT_COLOR:
+ operation = new MultilayerColorOperation(pass);
+ break;
+ default:
+ break;
+ }
+ operation->setImage(image);
+ operation->setRenderLayer(rl);
+ operation->setImageUser(user);
+ operation->setFramenumber(framenumber);
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ system->addOperation(operation);
+ return operation;
+}
+
+void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ /// Image output
+ OutputSocket *outputImage = this->getOutputSocket(0);
+ bNode *editorNode = this->getbNode();
+ Image *image = (Image*)editorNode->id;
+ ImageUser *imageuser = (ImageUser*)editorNode->storage;
+ int framenumber = context->getFramenumber();
+ int numberOfOutputs = this->getNumberOfOutputSockets();
+
+ /* force a load, we assume iuser index will be set OK anyway */
+ if(image && image->type==IMA_TYPE_MULTILAYER) {
+ BKE_image_get_ibuf(image, imageuser);
+ if(image->rr) {
+ OutputSocket * socket;
+ int index;
+ for (index = 0 ; index < numberOfOutputs ; index ++) {
+ socket = this->getOutputSocket(index);
+ if (socket->isConnected() || index == 0) {
+ bNodeSocket *bnodeSocket = socket->getbNodeSocket();
+ NodeImageLayer *storage = (NodeImageLayer*)bnodeSocket->storage;
+ int passindex = storage->pass_index;
+ int layerindex = storage->layer_index;
+ RenderLayer *rl= (RenderLayer*)BLI_findlink(&image->rr->layers, layerindex);
+ if (rl) {
+
+ RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex);
+ if (rpass) {
+ NodeOperation * operation = NULL;
+ imageuser->pass = passindex;
+ imageuser->layer = layerindex;
+ switch (rpass->channels) {
+ case 1:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE);
+ break;
+ /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
+ /* XXX any way to detect actual vector images? */
+ case 3:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR);
+ break;
+ case 4:
+ operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR);
+ break;
+
+ default:
+ /* XXX add a dummy operation? */
+ break;
+ }
+ if (index == 0 && operation) {
+ addPreviewOperation(graph, operation->getOutputSocket(), 9);
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (numberOfOutputs > 0) {
+ ImageOperation *operation = new ImageOperation();
+ if (outputImage->isConnected()) {
+ outputImage->relinkConnections(operation->getOutputSocket());
+ }
+ operation->setImage(image);
+ operation->setImageUser(imageuser);
+ operation->setFramenumber(framenumber);
+ graph->addOperation(operation);
+ addPreviewOperation(graph, operation->getOutputSocket(), 9);
+ }
+
+ if (numberOfOutputs > 1) {
+ OutputSocket *alphaImage = this->getOutputSocket(1);
+ if (alphaImage->isConnected()) {
+ ImageAlphaOperation *alphaOperation = new ImageAlphaOperation();
+ alphaOperation->setImage(image);
+ alphaOperation->setImageUser(imageuser);
+ alphaOperation->setFramenumber(framenumber);
+ alphaImage->relinkConnections(alphaOperation->getOutputSocket());
+ graph->addOperation(alphaOperation);
+ }
+ }
+ if (numberOfOutputs > 2) {
+ OutputSocket *depthImage = this->getOutputSocket(2);
+ if (depthImage->isConnected()) {
+ ImageDepthOperation *depthOperation = new ImageDepthOperation();
+ depthOperation->setImage(image);
+ depthOperation->setImageUser(imageuser);
+ depthOperation->setFramenumber(framenumber);
+ depthImage->relinkConnections(depthOperation->getOutputSocket());
+ graph->addOperation(depthOperation);
+ }
+ }
+ }
+}
+
diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h
new file mode 100644
index 00000000000..cfbfbd119f9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#include "COM_defines.h"
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "DNA_image_types.h"
+extern "C" {
+ #include "RE_engine.h"
+}
+
+/**
+ * @brief ImageNode
+ * @ingroup Node
+ */
+class ImageNode : public Node {
+
+private:
+ NodeOperation* doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype);
+public:
+ ImageNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+
+};
diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp
new file mode 100644
index 00000000000..2c47b467537
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_InvertNode.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_InvertNode.h"
+#include "DNA_scene_types.h"
+#include "COM_InvertOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+
+InvertNode::InvertNode(bNode *editorNode): Node(editorNode) {
+}
+
+void InvertNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InvertOperation *operation = new InvertOperation();
+ bNode* node = this->getbNode();
+ operation->setColor(node->custom1 & CMP_CHAN_RGB);
+ operation->setAlpha(node->custom1 & CMP_CHAN_A);
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0),true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h
new file mode 100644
index 00000000000..ec70be3ba31
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_InvertNode_h_
+#define _COM_InvertNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief InvertNode
+ * @ingroup Node
+ */
+class InvertNode: public Node {
+public:
+ InvertNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
new file mode 100644
index 00000000000..edaa0a9009e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_LensDistortionNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_ProjectorLensDistortionOperation.h"
+#include "COM_ScreenLensDistortionOperation.h"
+
+LensDistortionNode::LensDistortionNode(bNode *editorNode): Node(editorNode) {
+}
+
+void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ bNode* editorNode = this->getbNode();
+ NodeLensDist * data = (NodeLensDist*)editorNode->storage;
+ if (data->proj) {
+ ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+
+ operation->setData(data);
+ graph->addOperation(operation);
+
+ } else {
+ ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]);
+ operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+
+ operation->setData(data);
+ graph->addOperation(operation);
+ }
+
+}
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
new file mode 100644
index 00000000000..41b84d4baff
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_LensDistortionNode_h_
+#define _COM_LensDistortionNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief LensDistortionNode
+ * @ingroup Node
+ */
+class LensDistortionNode: public Node {
+public:
+ LensDistortionNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
new file mode 100644
index 00000000000..010688b6c2a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_LuminanceMatteNode.h"
+#include "BKE_node.h"
+#include "COM_LuminanceMatteOperation.h"
+#include "COM_ConvertRGBToYUVOperation.h"
+#include "COM_SetAlphaOperation.h"
+
+LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode): Node(editorNode)
+{}
+
+void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocketImage = this->getOutputSocket(0);
+ OutputSocket *outputSocketMatte = this->getOutputSocket(1);
+
+ ConvertRGBToYUVOperation *rgbToYUV = new ConvertRGBToYUVOperation();
+ LuminanceMatteOperation *operationSet = new LuminanceMatteOperation();
+ bNode* editorsnode = getbNode();
+ operationSet->setSettings((NodeChroma*)editorsnode->storage);
+
+ inputSocket->relinkConnections(rgbToYUV->getInputSocket(0), true, 0, graph);
+ addLink(graph, rgbToYUV->getOutputSocket(), operationSet->getInputSocket(0));
+
+ if (outputSocketMatte->isConnected()) {
+ outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0));
+ }
+
+ graph->addOperation(rgbToYUV);
+ graph->addOperation(operationSet);
+
+ SetAlphaOperation *operation = new SetAlphaOperation();
+ addLink(graph, rgbToYUV->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0));
+ addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1));
+ graph->addOperation(operation);
+ addPreviewOperation(graph, operation->getOutputSocket(), 9);
+
+ if (outputSocketImage->isConnected()) {
+ outputSocketImage->relinkConnections(operation->getOutputSocket());
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
new file mode 100644
index 00000000000..e2dd8b47833
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef COM_LuminanceMatteNODE_H
+#define COM_LuminanceMatteNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief LuminanceMatteNode
+ * @ingroup Node
+ */
+class LuminanceMatteNode : public Node
+{
+public:
+ LuminanceMatteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+
+#endif // COM_LuminanceMatteNODE_H
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp
new file mode 100644
index 00000000000..14129eb7064
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_MapUVNode.h"
+#include "COM_MapUVOperation.h"
+#include "COM_ExecutionSystem.h"
+
+MapUVNode::MapUVNode(bNode *editorNode): Node(editorNode) {
+}
+
+void MapUVNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ MapUVOperation *operation = new MapUVOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ bNode* node = this->getbNode();
+ operation->setAlpha((float)node->custom1);
+ operation->setResolutionInputSocketIndex(1);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h
new file mode 100644
index 00000000000..3092e84990f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MapUVNode.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_MapUVNode_h
+#define _COM_MapUVNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief MapUVNode
+ * @ingroup Node
+ */
+class MapUVNode : public Node {
+public:
+ MapUVNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp
new file mode 100644
index 00000000000..834b74a552d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MapValueNode.h"
+
+#include "COM_MapValueOperation.h"
+#include "COM_ExecutionSystem.h"
+
+MapValueNode::MapValueNode(bNode *editorNode): Node(editorNode) {
+}
+
+void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *colourSocket = this->getInputSocket(0);
+ OutputSocket *valueSocket = this->getOutputSocket(0);
+ TexMapping* storage = (TexMapping*)this->getbNode()->storage;
+ MapValueOperation *convertProg = new MapValueOperation();
+ convertProg->setSettings(storage);
+ colourSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph);
+ valueSocket->relinkConnections(convertProg->getOutputSocket(0));
+ graph->addOperation(convertProg);
+}
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
new file mode 100644
index 00000000000..47a6ea6adce
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MapValueNode_h
+#define _COM_MapValueNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief MapValueNode
+ * @ingroup Node
+ */
+class MapValueNode : public Node {
+public:
+ MapValueNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
new file mode 100644
index 00000000000..075b90c0f2b
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MathNode.h"
+#include "COM_MathBaseOperation.h"
+#include "COM_ExecutionSystem.h"
+
+void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ MathBaseOperation* operation=NULL;
+
+ switch(this->getbNode()->custom1)
+ {
+ case 0: /* Add */
+ operation = new MathAddOperation();
+ break;
+ case 1: /* Subtract */
+ operation = new MathSubtractOperation();
+ break;
+ case 2: /* Multiply */
+ operation = new MathMultiplyOperation();
+ break;
+ case 3: /* Divide */
+ operation = new MathDivideOperation();
+ break;
+ case 4: /* Sine */
+ operation = new MathSineOperation();
+ break;
+ case 5: /* Cosine */
+ operation = new MathCosineOperation();
+ break;
+ case 6: /* Tangent */
+ operation = new MathTangentOperation();
+ break;
+ case 7: /* Arc-Sine */
+ operation = new MathArcSineOperation();
+ break;
+ case 8: /* Arc-Cosine */
+ operation = new MathArcCosineOperation();
+ break;
+ case 9: /* Arc-Tangent */
+ operation = new MathArcTangentOperation();
+ break;
+ case 10: /* Power */
+ operation = new MathPowerOperation();
+ break;
+ case 11: /* Logarithm */
+ operation = new MathLogarithmOperation();
+ break;
+ case 12: /* Minimum */
+ operation = new MathMinimumOperation();
+ break;
+ case 13: /* Maximum */
+ operation = new MathMaximumOperation();
+ break;
+ case 14: /* Round */
+ operation = new MathRoundOperation();
+ break;
+ case 15: /* Less Than */
+ operation = new MathLessThanOperation();
+ break;
+ case 16: /* Greater Than */
+ operation = new MathGreaterThanOperation();
+ break;
+ }
+
+ if (operation != NULL) {
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ graph->addOperation(operation);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
new file mode 100644
index 00000000000..f5e6b5daebe
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MathNode_h
+#define _COM_MathNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief MathNode
+ * @ingroup Node
+ */
+class MathNode: public Node {
+public:
+ MathNode(bNode* editorNode) :Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
new file mode 100644
index 00000000000..1477163d1fc
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixNode.h"
+
+#include "COM_MixBlendOperation.h"
+#include "COM_MixAddOperation.h"
+#include "COM_MixMultiplyOperation.h"
+#include "COM_MixBurnOperation.h"
+#include "COM_MixColorOperation.h"
+#include "COM_MixDarkenOperation.h"
+#include "COM_MixDifferenceOperation.h"
+#include "COM_MixDivideOperation.h"
+#include "COM_MixHueOperation.h"
+#include "COM_MixLightenOperation.h"
+#include "COM_MixLinearLightOperation.h"
+#include "COM_MixOverlayOperation.h"
+#include "COM_MixSaturationOperation.h"
+#include "COM_MixScreenOperation.h"
+#include "COM_MixSoftLightOperation.h"
+#include "COM_MixSubtractOperation.h"
+#include "COM_MixValueOperation.h"
+#include "COM_MixDodgeOperation.h"
+
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "DNA_material_types.h" // the ramp types
+
+
+MixNode::MixNode(bNode *editorNode): Node(editorNode) {
+}
+
+
+void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *valueSocket = this->getInputSocket(0);
+ InputSocket *color1Socket = this->getInputSocket(1);
+ InputSocket *color2Socket = this->getInputSocket(2);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* editorNode = this->getbNode();
+
+ MixBaseOperation *convertProg;
+
+ switch (editorNode->custom1) {
+ case MA_RAMP_ADD:
+ convertProg = new MixAddOperation();
+ break;
+ case MA_RAMP_MULT:
+ convertProg = new MixMultiplyOperation();
+ break;
+ case MA_RAMP_LIGHT:
+ convertProg = new MixLightenOperation();
+ break;
+ case MA_RAMP_BURN:
+ convertProg = new MixBurnOperation();
+ break;
+ case MA_RAMP_HUE:
+ convertProg = new MixHueOperation();
+ break;
+ case MA_RAMP_COLOR:
+ convertProg = new MixColorOperation();
+ break;
+ case MA_RAMP_SOFT:
+ convertProg = new MixSoftLightOperation();
+ break;
+ case MA_RAMP_SCREEN:
+ convertProg = new MixScreenOperation();
+ break;
+ case MA_RAMP_LINEAR:
+ convertProg = new MixLinearLightOperation();
+ break;
+ case MA_RAMP_DIFF:
+ convertProg = new MixDifferenceOperation();
+ break;
+ case MA_RAMP_SAT:
+ convertProg = new MixSaturationOperation();
+ break;
+ case MA_RAMP_DIV:
+ convertProg = new MixDivideOperation();
+ break;
+ case MA_RAMP_SUB:
+ convertProg = new MixSubtractOperation();
+ break;
+ case MA_RAMP_DARK:
+ convertProg = new MixDarkenOperation();
+ break;
+ case MA_RAMP_OVERLAY:
+ convertProg = new MixOverlayOperation();
+ break;
+ case MA_RAMP_VAL:
+ convertProg = new MixValueOperation();
+ break;
+ case MA_RAMP_DODGE:
+ convertProg = new MixDodgeOperation();
+ break;
+
+ case MA_RAMP_BLEND:
+ default:
+ convertProg = new MixBlendOperation();
+ break;
+ }
+ convertProg->setUseValueAlphaMultiply(this->getbNode()->custom2);
+
+ valueSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph);
+ color1Socket->relinkConnections(convertProg->getInputSocket(1), true, 1, graph);
+ color2Socket->relinkConnections(convertProg->getInputSocket(2), true, 2, graph);
+ outputSocket->relinkConnections(convertProg->getOutputSocket(0));
+ addPreviewOperation(graph, convertProg->getOutputSocket(0), 5);
+
+ convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode());
+
+ graph->addOperation(convertProg);
+}
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
new file mode 100644
index 00000000000..4b57bdbc02a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixNode_h
+#define _COM_MixNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief MixNode
+ * @ingroup Node
+ */
+class MixNode : public Node {
+public:
+ MixNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
new file mode 100644
index 00000000000..7d11a06a24d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MovieClipNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_MovieClipOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ConvertColorProfileOperation.h"
+
+extern "C" {
+ #include "DNA_movieclip_types.h"
+ #include "BKE_movieclip.h"
+ #include "BKE_tracking.h"
+}
+
+MovieClipNode::MovieClipNode(bNode *editorNode): Node(editorNode) {
+}
+
+void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ OutputSocket *outputMovieClip = this->getOutputSocket(0);
+ OutputSocket *offsetXMovieClip = this->getOutputSocket(1);
+ OutputSocket *offsetYMovieClip = this->getOutputSocket(2);
+ OutputSocket *scaleMovieClip = this->getOutputSocket(3);
+ OutputSocket *angleMovieClip = this->getOutputSocket(4);
+
+ bNode *editorNode = this->getbNode();
+ MovieClip *movieClip = (MovieClip*)editorNode->id;
+ MovieClipUser *movieClipUser = (MovieClipUser*)editorNode->storage;
+
+ ImBuf * ibuf= NULL;
+ if (movieClip) {
+ ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser);
+ }
+
+ // always connect the output image
+ MovieClipOperation *operation = new MovieClipOperation();
+
+ if (ibuf && context->isColorManaged() && ibuf->profile == IB_PROFILE_NONE) {
+ ConvertColorProfileOperation *converter = new ConvertColorProfileOperation();
+ converter->setFromColorProfile(IB_PROFILE_LINEAR_RGB);
+ converter->setToColorProfile(IB_PROFILE_SRGB);
+ addLink(graph, operation->getOutputSocket(), converter->getInputSocket(0));
+ addPreviewOperation(graph, converter->getOutputSocket(), 9);
+ if (outputMovieClip->isConnected()) {
+ outputMovieClip->relinkConnections(converter->getOutputSocket());
+ }
+ graph->addOperation(converter);
+ if (ibuf) {
+ converter->setPredivided(ibuf->flags & IB_cm_predivide);
+ }
+ } else {
+ addPreviewOperation(graph, operation->getOutputSocket(), 9);
+ if (outputMovieClip->isConnected()) {
+ outputMovieClip->relinkConnections(operation->getOutputSocket());
+ }
+ }
+ operation->setMovieClip(movieClip);
+ operation->setMovieClipUser(movieClipUser);
+ operation->setFramenumber(context->getFramenumber());
+ graph->addOperation(operation);
+
+ MovieTrackingStabilization *stab= &movieClip->tracking.stabilization;
+ float loc[2], scale, angle;
+ loc[0] = 0.0f;
+ loc[1] = 0.0f;
+ scale = 1.0f;
+ angle = 0.0f;
+
+ if (ibuf) {
+ if(stab->flag&TRACKING_2D_STABILIZATION) {
+ BKE_tracking_stabilization_data(&movieClip->tracking, context->getFramenumber(), ibuf->x, ibuf->y, loc, &scale, &angle);
+ }
+ }
+
+ if (offsetXMovieClip->isConnected()) {
+ SetValueOperation * operationSetValue = new SetValueOperation();
+ operationSetValue->setValue(loc[0]);
+ offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket());
+ graph->addOperation(operationSetValue);
+ }
+ if (offsetYMovieClip->isConnected()) {
+ SetValueOperation * operationSetValue = new SetValueOperation();
+ operationSetValue->setValue(loc[1]);
+ offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket());
+ graph->addOperation(operationSetValue);
+ }
+ if (scaleMovieClip->isConnected()) {
+ SetValueOperation * operationSetValue = new SetValueOperation();
+ operationSetValue->setValue(scale);
+ scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
+ graph->addOperation(operationSetValue);
+ }
+ if (angleMovieClip->isConnected()) {
+ SetValueOperation * operationSetValue = new SetValueOperation();
+ operationSetValue->setValue(angle);
+ angleMovieClip->relinkConnections(operationSetValue->getOutputSocket());
+ graph->addOperation(operationSetValue);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
new file mode 100644
index 00000000000..883ebe486f8
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief MovieClipNode
+ * @ingroup Node
+ */
+class MovieClipNode : public Node {
+
+
+public:
+ MovieClipNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+
+};
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
new file mode 100644
index 00000000000..4233f313a87
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MovieDistortionNode.h"
+
+#include "COM_MovieDistortionOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "DNA_movieclip_types.h"
+
+MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void MovieDistortionNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* bnode = this->getbNode();
+ MovieClip * clip = (MovieClip*)bnode->id;
+
+ MovieDistortionOperation * operation = new MovieDistortionOperation(bnode->custom1 == 1);
+ operation->setMovieClip(clip);
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ system->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
new file mode 100644
index 00000000000..28eec5011a2
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MovieDistortionNode_h_
+#define _COM_MovieDistortionNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief MovieDistortionNode
+ * @ingroup Node
+ */
+class MovieDistortionNode: public Node {
+public:
+ MovieDistortionNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp
new file mode 100644
index 00000000000..44accf42f6a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MuteNode.cpp
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MuteNode.h"
+#include "COM_SocketConnection.h"
+#include "stdio.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
+#include "COM_SetColorOperation.h"
+
+MuteNode::MuteNode(bNode *editorNode): Node(editorNode) {
+}
+
+void MuteNode::reconnect(ExecutionSystem * graph, OutputSocket * output) {
+ vector<InputSocket*> &inputsockets = this->getInputSockets();
+ for (unsigned int index = 0; index < inputsockets.size() ; index ++) {
+ InputSocket *input = inputsockets[index];
+ if (input->getDataType() == output->getDataType()) {
+ if (input->isConnected()) {
+ output->relinkConnections(input->getConnection()->getFromSocket(), false);
+ return;
+ }
+ }
+ }
+
+ NodeOperation * operation;
+ switch (output->getDataType()) {
+ case COM_DT_VALUE:
+ {
+ SetValueOperation *valueoperation = new SetValueOperation();
+ valueoperation->setValue(0.0f);
+ operation = valueoperation;
+ break;
+ }
+ case COM_DT_VECTOR:
+ {
+ SetVectorOperation *vectoroperation = new SetVectorOperation();
+ vectoroperation->setX(0.0f);
+ vectoroperation->setY(0.0f);
+ vectoroperation->setW(0.0f);
+ operation = vectoroperation;
+ break;
+ }
+ case COM_DT_COLOR:
+ {
+ SetColorOperation *coloroperation = new SetColorOperation();
+ coloroperation->setChannel1(0.0f);
+ coloroperation->setChannel2(0.0f);
+ coloroperation->setChannel3(0.0f);
+ coloroperation->setChannel4(0.0f);
+ operation = coloroperation;
+ break;
+ }
+ }
+ if (operation) {
+ output->relinkConnections(operation->getOutputSocket(), false);
+ graph->addOperation(operation);
+ }
+
+ output->clearConnections();
+}
+
+void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ vector<OutputSocket*> &outputsockets = this->getOutputSockets();
+
+ for (unsigned int index = 0 ; index < outputsockets.size() ; index ++) {
+ OutputSocket * output = outputsockets[index];
+ if (output->isConnected()) {
+ reconnect(graph, output);
+ }
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_MuteNode.h b/source/blender/compositor/nodes/COM_MuteNode.h
new file mode 100644
index 00000000000..c2d1f283c62
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_MuteNode.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MuteNode_h_
+#define _COM_MuteNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief MuteNode
+ * @ingroup Node
+ */
+class MuteNode: public Node {
+public:
+ MuteNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+private:
+ void reconnect(ExecutionSystem* graph, OutputSocket * output);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp
new file mode 100644
index 00000000000..b54d8b8aab6
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_NormalNode.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_NormalNode.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+#include "COM_DotproductOperation.h"
+#include "COM_SetVectorOperation.h"
+
+NormalNode::NormalNode(bNode* editorNode): Node(editorNode)
+{}
+
+void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ OutputSocket *outputSocketDotproduct = this->getOutputSocket(1);
+ bNode* editorNode = this->getbNode();
+
+ SetVectorOperation * operationSet = new SetVectorOperation();
+ bNodeSocket * insock = (bNodeSocket*)editorNode->outputs.first;
+ bNodeSocketValueVector *dval = (bNodeSocketValueVector*)insock->default_value;
+ operationSet->setX(dval->value[0]);
+ operationSet->setY(dval->value[1]);
+ operationSet->setZ(dval->value[2]);
+ operationSet->setW(0.0f);
+
+ outputSocket->relinkConnections(operationSet->getOutputSocket(0));
+ graph->addOperation(operationSet);
+
+ if (outputSocketDotproduct->isConnected()) {
+ DotproductOperation *operation = new DotproductOperation();
+ outputSocketDotproduct->relinkConnections(operation->getOutputSocket(0));
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ addLink(graph, operationSet->getOutputSocket(0), operation->getInputSocket(1));
+ graph->addOperation(operation);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h
new file mode 100644
index 00000000000..97a2f4bdd06
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef COM_NORMALNODE_H
+#define COM_NORMALNODE_H
+
+#include "COM_Node.h"
+
+/**
+ * @brief NormalNode
+ * @ingroup Node
+ */
+class NormalNode : public Node
+{
+public:
+ NormalNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif // COM_NormalNODE_H
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
new file mode 100644
index 00000000000..dbe8278af0f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_NormalizeNode.h"
+#include "COM_NormalizeOperation.h"
+#include "COM_ExecutionSystem.h"
+
+NormalizeNode::NormalizeNode(bNode *editorNode): Node(editorNode) {
+}
+
+void NormalizeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ NormalizeOperation *operation = new NormalizeOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h
new file mode 100644
index 00000000000..b955b52391e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_NormalizeNode_h_
+#define _COM_NormalizeNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief NormalizeNode
+ * @ingroup Node
+ */
+class NormalizeNode: public Node {
+public:
+ NormalizeNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
new file mode 100644
index 00000000000..d844861cdd5
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#include "COM_OutputFileNode.h"
+#include "COM_OutputFileOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "BLI_path_util.h"
+#include "BKE_utildefines.h"
+
+OutputFileNode::OutputFileNode(bNode *editorNode): Node(editorNode) {
+}
+
+void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ NodeImageMultiFile* storage = (NodeImageMultiFile*)this->getbNode()->storage;
+
+ if (!context->isRendering()) {
+ /* XXX TODO as in previous implementation?
+ * add dummy operations and exit, to prevent file writing on each compo update.
+ */
+ }
+
+ if (storage->format.imtype==R_IMF_IMTYPE_MULTILAYER) {
+ /* single output operation for the multilayer file */
+ OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation(
+ context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
+
+ int num_inputs = getNumberOfInputSockets();
+ bool hasConnections = false;
+ for (int i=0; i < num_inputs; ++i) {
+ InputSocket *input = getInputSocket(i);
+ if (input->isConnected()) {
+ hasConnections = true;
+ NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
+
+ outputOperation->add_layer(sockdata->path, input->getDataType());
+
+ input->relinkConnections(outputOperation->getInputSocket(i));
+ }
+ }
+ if (hasConnections) addPreviewOperation(graph, outputOperation->getInputSocket(0), 5);
+
+ graph->addOperation(outputOperation);
+ }
+ else { /* single layer format */
+ int num_inputs = getNumberOfInputSockets();
+ bool previewAdded = false;
+ for (int i=0; i < num_inputs; ++i) {
+ InputSocket *input = getInputSocket(i);
+ if (input->isConnected()) {
+ NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage;
+ ImageFormatData *format = (sockdata->use_node_format ? &storage->format : &sockdata->format);
+ char path[FILE_MAX];
+
+ /* combine file path for the input */
+ BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
+
+ OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
+ context->getScene(), context->getbNodeTree(), input->getActualDataType(), format, path);
+ input->relinkConnections(outputOperation->getInputSocket(0));
+ graph->addOperation(outputOperation);
+ if (!previewAdded) {
+ addPreviewOperation(graph, outputOperation->getInputSocket(0), 5);
+ previewAdded = true;
+ }
+ }
+ }
+ }
+}
+
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
new file mode 100644
index 00000000000..10cbba7d50f
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#ifndef _COM_OutputFileNode_h
+#define _COM_OutputFileNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief OutputFileNode
+ * @ingroup Node
+ */
+class OutputFileNode : public Node {
+public:
+ OutputFileNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
new file mode 100644
index 00000000000..e22c2fd5910
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_RenderLayersImageProg.h"
+#include "COM_RenderLayersAlphaProg.h"
+#include "COM_RenderLayersDepthProg.h"
+#include "COM_RenderLayersNormalOperation.h"
+#include "COM_RenderLayersSpeedOperation.h"
+#include "COM_RenderLayersColorOperation.h"
+#include "COM_RenderLayersUVOperation.h"
+#include "COM_RenderLayersMistOperation.h"
+#include "COM_RenderLayersObjectIndexOperation.h"
+#include "COM_RenderLayersDiffuseOperation.h"
+#include "COM_RenderLayersSpecularOperation.h"
+#include "COM_RenderLayersShadowOperation.h"
+#include "COM_RenderLayersAOOperation.h"
+#include "COM_RenderLayersEmitOperation.h"
+#include "COM_RenderLayersReflectionOperation.h"
+#include "COM_RenderLayersRefractionOperation.h"
+#include "COM_RenderLayersEnvironmentOperation.h"
+#include "COM_RenderLayersIndirectOperation.h"
+#include "COM_RenderLayersMaterialIndexOperation.h"
+#include "COM_RenderLayersCyclesOperation.h"
+#include "COM_TranslateOperation.h"
+#include "COM_RotateOperation.h"
+#include "COM_ScaleOperation.h"
+#include "COM_SetValueOperation.h"
+
+RenderLayersNode::RenderLayersNode(bNode *editorNode): Node(editorNode) {
+}
+
+void RenderLayersNode::testSocketConnection(ExecutionSystem* system, int outputSocketNumber, RenderLayersBaseProg * operation) {
+ OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
+ Scene* scene = (Scene*)this->getbNode()->id;
+ short layerId = this->getbNode()->custom1;
+
+ if (outputSocket->isConnected()) {
+ operation->setScene(scene);
+ operation->setLayerId(layerId);
+ outputSocket->relinkConnections(operation->getOutputSocket());
+ system->addOperation(operation);
+ if (outputSocketNumber == 0) { // only do for image socket if connected
+ addPreviewOperation(system, operation->getOutputSocket(), 9);
+ }
+ } else {
+ if (outputSocketNumber == 0) {
+ system->addOperation(operation);
+ operation->setScene(scene);
+ operation->setLayerId(layerId);
+ addPreviewOperation(system, operation->getOutputSocket(), 9);
+ } else {
+ delete operation;
+ }
+ }
+}
+
+void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ testSocketConnection(graph, 0, new RenderLayersColourProg());
+ testSocketConnection(graph, 1, new RenderLayersAlphaProg());
+ testSocketConnection(graph, 2, new RenderLayersDepthProg());
+ testSocketConnection(graph, 3, new RenderLayersNormalOperation());
+ testSocketConnection(graph, 4, new RenderLayersUVOperation());
+ testSocketConnection(graph, 5, new RenderLayersSpeedOperation());
+ testSocketConnection(graph, 6, new RenderLayersColorOperation());
+ testSocketConnection(graph, 7, new RenderLayersDiffuseOperation());
+ testSocketConnection(graph, 8, new RenderLayersSpecularOperation());
+ testSocketConnection(graph, 9, new RenderLayersShadowOperation());
+ testSocketConnection(graph, 10, new RenderLayersAOOperation());
+ testSocketConnection(graph, 11, new RenderLayersReflectionOperation());
+ testSocketConnection(graph, 12, new RenderLayersRefractionOperation());
+ testSocketConnection(graph, 13, new RenderLayersIndirectOperation());
+ testSocketConnection(graph, 14, new RenderLayersObjectIndexOperation());
+ testSocketConnection(graph, 15, new RenderLayersMaterialIndexOperation());
+ testSocketConnection(graph, 16, new RenderLayersMistOperation());
+ testSocketConnection(graph, 17, new RenderLayersEmitOperation());
+ testSocketConnection(graph, 18, new RenderLayersEnvironmentOperation());
+
+ // cycles passes
+ testSocketConnection(graph, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
+ testSocketConnection(graph, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
+ testSocketConnection(graph, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
+ testSocketConnection(graph, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
+ testSocketConnection(graph, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
+ testSocketConnection(graph, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
+ testSocketConnection(graph, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
+ testSocketConnection(graph, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
+ testSocketConnection(graph, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
+}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
new file mode 100644
index 00000000000..285b6f6d007
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_RenderLayersBaseProg.h"
+
+/**
+ * @brief RenderLayersNode
+ * @ingroup Node
+ */
+class RenderLayersNode : public Node {
+public:
+ RenderLayersNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+private:
+ void testSocketConnection(ExecutionSystem* graph, int outputSocketNumber, RenderLayersBaseProg * operation);
+};
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp
new file mode 100644
index 00000000000..059a62874bb
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_RotateNode.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RotateNode.h"
+
+#include "COM_RotateOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetSamplerOperation.h"
+
+RotateNode::RotateNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputDegreeSocket = this->getInputSocket(1);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ RotateOperation *operation = new RotateOperation();
+ SetSamplerOperation *sampler = new SetSamplerOperation();
+
+ switch (this->getbNode()->custom1) {
+ case 0:
+ sampler->setSampler(COM_PS_NEAREST);
+ break ;
+ case 1:
+ sampler->setSampler(COM_PS_BILINEAR);
+ break;
+ case 2:
+ sampler->setSampler(COM_PS_BICUBIC);
+ break;
+
+ }
+
+ addLink(system, sampler->getOutputSocket(), operation->getInputSocket(0));
+
+ inputSocket->relinkConnections(sampler->getInputSocket(0), true, 0, system);
+ inputDegreeSocket->relinkConnections(operation->getInputSocket(1), true, 1, system);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ system->addOperation(sampler);
+ system->addOperation(operation);
+
+}
diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h
new file mode 100644
index 00000000000..7e4f7a1a546
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RotateNode_h_
+#define _COM_RotateNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief RotateNode
+ * @ingroup Node
+ */
+class RotateNode: public Node {
+public:
+ RotateNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
new file mode 100644
index 00000000000..b281ed64d79
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ScaleNode.h"
+
+#include "COM_ScaleOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "BKE_node.h"
+#include "COM_SetValueOperation.h"
+
+ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputXSocket = this->getInputSocket(1);
+ InputSocket *inputYSocket = this->getInputSocket(2);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ bNode* bnode = this->getbNode();
+ switch (bnode->custom1) {
+ case CMP_SCALE_RELATIVE: {
+ ScaleOperation *operation = new ScaleOperation();
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ break;
+ case CMP_SCALE_SCENEPERCENT: {
+ SetValueOperation * scaleFactorOperation = new SetValueOperation();
+ scaleFactorOperation->setValue(context->getScene()->r.size/100.0f);
+ ScaleOperation * operation = new ScaleOperation();
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
+ addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2));
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(scaleFactorOperation);
+ graph->addOperation(operation);
+ }
+ break;
+
+ case CMP_SCALE_RENDERPERCENT: {
+ const RenderData* data = &context->getScene()->r;
+ ScaleFixedSizeOperation * operation = new ScaleFixedSizeOperation();
+ operation->setNewWidth(data->xsch*data->size/100.0f);
+ operation->setNewHeight(data->ysch*data->size/100.0f);
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true);
+ graph->addOperation(operation);
+ }
+ break;
+
+ case CMP_SCALE_ABSOLUTE: {
+ ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated....
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ break;
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h
new file mode 100644
index 00000000000..b6a1a56d8c9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ScaleNode_h_
+#define _COM_ScaleNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ScaleNode
+ * @ingroup Node
+ */
+class ScaleNode: public Node {
+public:
+ ScaleNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
new file mode 100644
index 00000000000..922b9c051d5
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SeparateHSVANode.h"
+
+#include "COM_SeparateChannelOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ConvertRGBToHSVOperation.h"
+
+SeparateHSVANode::SeparateHSVANode(bNode *editorNode): SeparateRGBANode(editorNode) {
+}
+
+void SeparateHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ ConvertRGBToHSVOperation *operation = new ConvertRGBToHSVOperation();
+ InputSocket *inputSocket = this->getInputSocket(0);
+ if (inputSocket->isConnected()) {
+ inputSocket->relinkConnections(operation->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), inputSocket);
+ }
+ graph->addOperation(operation);
+ SeparateRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/compositor/nodes/COM_SeparateHSVANode.h
new file mode 100644
index 00000000000..9fbd0212509
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SeparateHSVANode_h
+#define _COM_SeparateHSVANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_SeparateRGBANode.h"
+
+/**
+ * @brief SeparateHSVANode
+ * @ingroup Node
+ */
+class SeparateHSVANode : public SeparateRGBANode {
+public:
+ SeparateHSVANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
new file mode 100644
index 00000000000..08b3c87cbf9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SeparateRGBANode.h"
+
+#include "COM_SeparateChannelOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "DNA_material_types.h" // the ramp types
+
+
+SeparateRGBANode::SeparateRGBANode(bNode *editorNode): Node(editorNode) {
+}
+
+
+void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *imageSocket = this->getInputSocket(0);
+ OutputSocket *outputRSocket = this->getOutputSocket(0);
+ OutputSocket *outputGSocket = this->getOutputSocket(1);
+ OutputSocket *outputBSocket = this->getOutputSocket(2);
+ OutputSocket *outputASocket = this->getOutputSocket(3);
+
+ if (outputRSocket->isConnected()) {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(0);
+ imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph);
+ outputRSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ if (outputGSocket->isConnected()) {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(1);
+ imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph);
+ outputGSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ if (outputBSocket->isConnected()) {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(2);
+ imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph);
+ outputBSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+ if (outputASocket->isConnected()) {
+ SeparateChannelOperation *operation = new SeparateChannelOperation();
+ operation->setChannel(3);
+ imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph);
+ outputASocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/compositor/nodes/COM_SeparateRGBANode.h
new file mode 100644
index 00000000000..5fb00600790
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SeparateRGBANode_h
+#define _COM_SeparateRGBANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief SeparateRGBANode
+ * @ingroup Node
+ */
+class SeparateRGBANode : public Node {
+public:
+ SeparateRGBANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
new file mode 100644
index 00000000000..854f74cda4c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_SeparateYCCANode.h"
+#include "COM_SeparateChannelOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ConvertRGBToYCCOperation.h"
+
+SeparateYCCANode::SeparateYCCANode(bNode *editorNode): SeparateRGBANode(editorNode) {
+}
+
+void SeparateYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
+ InputSocket *inputSocket = this->getInputSocket(0);
+
+ bNode *node = this->getbNode();
+ operation->setMode(node->custom1);
+
+ if (inputSocket->isConnected()) {
+ inputSocket->relinkConnections(operation->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), inputSocket);
+ }
+ graph->addOperation(operation);
+ SeparateRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/compositor/nodes/COM_SeparateYCCANode.h
new file mode 100644
index 00000000000..441eba9bc93
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_SeparateYCCANode_h
+#define _COM_SeparateYCCANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_SeparateRGBANode.h"
+
+/**
+ * @brief SeparateYCCANode
+ * @ingroup Node
+ */
+class SeparateYCCANode : public SeparateRGBANode {
+public:
+ SeparateYCCANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
new file mode 100644
index 00000000000..db8a8bd2697
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_SeparateYUVANode.h"
+#include "COM_SeparateChannelOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ConvertRGBToYUVOperation.h"
+
+SeparateYUVANode::SeparateYUVANode(bNode *editorNode): SeparateRGBANode(editorNode) {
+}
+
+void SeparateYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) {
+ ConvertRGBToYUVOperation *operation = new ConvertRGBToYUVOperation();
+ InputSocket *inputSocket = this->getInputSocket(0);
+ if (inputSocket->isConnected()) {
+ inputSocket->relinkConnections(operation->getInputSocket(0));
+ addLink(graph, operation->getOutputSocket(), inputSocket);
+ }
+ graph->addOperation(operation);
+ SeparateRGBANode::convertToOperations(graph, context);
+}
diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h
new file mode 100644
index 00000000000..136ce1b4f20
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_SeparateYUVANode_h
+#define _COM_SeparateYUVANode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+#include "COM_SeparateRGBANode.h"
+
+/**
+ * @brief SeparateYUVANode
+ * @ingroup Node
+ */
+class SeparateYUVANode : public SeparateRGBANode {
+public:
+ SeparateYUVANode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext *context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
new file mode 100644
index 00000000000..5dd7dea1fa8
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetAlphaNode.h"
+#include "COM_SetAlphaOperation.h"
+#include "COM_ExecutionSystem.h"
+
+void SetAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ SetAlphaOperation* operation = new SetAlphaOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
new file mode 100644
index 00000000000..c9d819d172e
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetAlphaNode_h
+#define _COM_SetAlphaNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief SetAlphaNode
+ * @ingroup Node
+ */
+class SetAlphaNode: public Node {
+public:
+ SetAlphaNode(bNode* editorNode) :Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
new file mode 100644
index 00000000000..0622ed0ea84
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SocketProxyNode.h"
+#include "COM_SocketConnection.h"
+#include "COM_SocketProxyOperation.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetVectorOperation.h"
+#include "COM_SetColorOperation.h"
+
+SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): Node(editorNode, false) {
+ DataType dt;
+
+ dt = COM_DT_VALUE;
+ if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+ this->addInputSocket(dt, (InputSocketResizeMode)editorInput->resizemode, editorInput);
+
+ dt = COM_DT_VALUE;
+ if (editorOutput->type == SOCK_RGBA) dt = COM_DT_COLOR;
+ if (editorOutput->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
+ this->addOutputSocket(dt, editorOutput);
+}
+
+void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ OutputSocket * outputsocket = this->getOutputSocket(0);
+ if (outputsocket->isConnected()) {
+ SocketProxyOperation *operation = new SocketProxyOperation();
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0));
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ }
+}
+
+void OutputSocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ OutputSocket * outputsocket = this->getOutputSocket(0);
+ InputSocket * inputsocket = this->getInputSocket(0);
+ if (outputsocket->isConnected()) {
+ switch (outputsocket->getActualDataType()) {
+ case COM_DT_VALUE:
+ {
+ SetValueOperation *operation = new SetValueOperation();
+ bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)inputsocket->getbNodeSocket()->default_value;
+ operation->setValue(dval->value);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
+ case COM_DT_COLOR:
+ {
+ SetColorOperation *operation = new SetColorOperation();
+ bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)inputsocket->getbNodeSocket()->default_value;
+ operation->setChannels(dval->value);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
+ case COM_DT_VECTOR:
+ {
+ SetVectorOperation *operation = new SetVectorOperation();
+ bNodeSocketValueVector *dval = (bNodeSocketValueVector*)inputsocket->getbNodeSocket()->default_value;
+ operation->setVector(dval->value);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+ break;
+ }
+ }
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
new file mode 100644
index 00000000000..eb14f84c46a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SocketProxyNode_h_
+#define _COM_SocketProxyNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief SocketProxyNode
+ * @ingroup Node
+ */
+class SocketProxyNode: public Node {
+public:
+ SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+
+ virtual bool isProxyNode() const { return true; }
+};
+
+class OutputSocketProxyNode: public SocketProxyNode {
+public:
+ OutputSocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): SocketProxyNode(editorNode, editorInput, editorOutput) {}
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
new file mode 100644
index 00000000000..12204c65112
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SplitViewerNode.h"
+#include "BKE_global.h"
+
+#include "COM_SplitViewerOperation.h"
+#include "COM_ExecutionSystem.h"
+
+SplitViewerNode::SplitViewerNode(bNode *editorNode): Node(editorNode) {
+}
+
+void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *image1Socket = this->getInputSocket(0);
+ InputSocket *image2Socket = this->getInputSocket(1);
+ Image* image = (Image*)this->getbNode()->id;
+ ImageUser * imageUser = (ImageUser*) this->getbNode()->storage;
+ if (image1Socket->isConnected() && image2Socket->isConnected()) {
+ SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
+ splitViewerOperation->setImage(image);
+ splitViewerOperation->setImageUser(imageUser);
+ splitViewerOperation->setActive(this->getbNode()->flag & NODE_DO_OUTPUT);
+ splitViewerOperation->setSplitPercentage(this->getbNode()->custom1);
+ splitViewerOperation->setXSplit(!this->getbNode()->custom2);
+ image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), true, 1, graph);
+ image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), true, 1, graph);
+ addPreviewOperation(graph, splitViewerOperation->getInputSocket(0), 0);
+ graph->addOperation(splitViewerOperation);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
new file mode 100644
index 00000000000..e2d7a8c0dc9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SplitViewerNode_h
+#define _COM_SplitViewerNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief SplitViewerNode
+ * @ingroup Node
+ */
+class SplitViewerNode : public Node {
+public:
+ SplitViewerNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
new file mode 100644
index 00000000000..74fde974784
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Stabilize2dNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_TranslateOperation.h"
+#include "COM_RotateOperation.h"
+#include "COM_ScaleOperation.h"
+#include "COM_MovieClipAttributeOperation.h"
+
+extern "C" {
+ #include "DNA_movieclip_types.h"
+ #include "BKE_tracking.h"
+}
+
+Stabilize2dNode::Stabilize2dNode(bNode *editorNode): Node(editorNode) {
+}
+
+void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *imageInput = this->getInputSocket(0);
+ MovieClip *clip= (MovieClip *)getbNode()->id;
+
+ ScaleOperation * scaleOperation = new ScaleOperation();
+ RotateOperation * rotateOperation = new RotateOperation();
+ TranslateOperation * translateOperation = new TranslateOperation();
+ MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation();
+ MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation();
+ MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation();
+ MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation();
+
+ scaleAttribute->setAttribute(MCA_SCALE);
+ scaleAttribute->setFramenumber(context->getFramenumber());
+ scaleAttribute->setMovieClip(clip);
+
+ angleAttribute->setAttribute(MCA_ANGLE);
+ angleAttribute->setFramenumber(context->getFramenumber());
+ angleAttribute->setMovieClip(clip);
+
+ xAttribute->setAttribute(MCA_X);
+ xAttribute->setFramenumber(context->getFramenumber());
+ xAttribute->setMovieClip(clip);
+
+ yAttribute->setAttribute(MCA_Y);
+ yAttribute->setFramenumber(context->getFramenumber());
+ yAttribute->setMovieClip(clip);
+
+ imageInput->relinkConnections(scaleOperation->getInputSocket(0), true, 0, graph);
+ addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+ addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+
+ addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ addLink(graph, angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
+ rotateOperation->setDoDegree2RadConversion(false);
+
+ addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ addLink(graph, xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+ addLink(graph, yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
+
+ this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket());
+
+ graph->addOperation(scaleAttribute);
+ graph->addOperation(angleAttribute);
+ graph->addOperation(xAttribute);
+ graph->addOperation(yAttribute);
+ graph->addOperation(scaleOperation);
+ graph->addOperation(translateOperation);
+ graph->addOperation(rotateOperation);
+}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
new file mode 100644
index 00000000000..613bb97b994
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief Stabilize2dNode
+ * @ingroup Node
+ */
+class Stabilize2dNode : public Node {
+public:
+ Stabilize2dNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
new file mode 100644
index 00000000000..1b15ae0e890
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SwitchNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_SocketProxyOperation.h"
+
+SwitchNode::SwitchNode(bNode *editorNode): Node(editorNode) {
+}
+
+
+void SwitchNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ SocketProxyOperation * operation = new SocketProxyOperation();
+ int switchFrame = this->getbNode()->custom1;
+
+ if (!switchFrame) {
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ } else {
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(0), true, 1, graph);
+ }
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
new file mode 100644
index 00000000000..da93af42489
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SwitchNode_h
+#define _COM_SwitchNode_h
+
+#include "COM_Node.h"
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+/**
+ * @brief SwitchNode
+ * @ingroup Node
+ */
+class SwitchNode : public Node {
+public:
+ SwitchNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
new file mode 100644
index 00000000000..ac78c1afd7d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TextureNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_TextureOperation.h"
+
+TextureNode::TextureNode(bNode *editorNode): Node(editorNode) {
+}
+
+void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ bNode* editorNode = this->getbNode();
+ Tex* texture = (Tex*)editorNode->id;
+ TextureOperation* operation = new TextureOperation();
+ this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket());
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
+ operation->setTexture(texture);
+ system->addOperation(operation);
+ addPreviewOperation(system, operation->getOutputSocket(), 9);
+
+ if (this->getOutputSocket(0)->isConnected()) {
+ TextureAlphaOperation* alphaOperation = new TextureAlphaOperation();
+ this->getOutputSocket(0)->relinkConnections(alphaOperation->getOutputSocket());
+ addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0));
+ addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
+ alphaOperation->setTexture(texture);
+ system->addOperation(alphaOperation);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h
new file mode 100644
index 00000000000..493c94ddb19
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief TextureNode
+ * @ingroup Node
+ */
+class TextureNode : public Node {
+public:
+ TextureNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
new file mode 100644
index 00000000000..3e2c750d3aa
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TimeNode.h"
+#include "DNA_scene_types.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ExecutionSystem.h"
+extern "C" {
+ #include "BKE_colortools.h"
+}
+#include "BLI_utildefines.h"
+
+TimeNode::TimeNode(bNode *editorNode): Node(editorNode) {
+}
+
+void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ SetValueOperation *operation = new SetValueOperation();
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ bNode* node = this->getbNode();
+
+ /* stack order output: fac */
+ float fac= 0.0f;
+ const int framenumber = context->getFramenumber();
+
+ if (framenumber < node->custom1) {
+ fac = 0.0f;
+ } else if (framenumber > node->custom2) {
+ fac = 1.0f;
+ } else if(node->custom1 < node->custom2) {
+ fac= (context->getFramenumber() - node->custom1)/(float)(node->custom2-node->custom1);
+ }
+
+ fac= curvemapping_evaluateF((CurveMapping*)node->storage, 0, fac);
+ operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
new file mode 100644
index 00000000000..25134db8528
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_TimeNode_h_
+#define _COM_TimeNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief TimeNode
+ * @ingroup Node
+ */
+class TimeNode: public Node {
+public:
+ TimeNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp
new file mode 100644
index 00000000000..a610146a495
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TonemapNode.h"
+#include "DNA_scene_types.h"
+#include "COM_TonemapOperation.h"
+#include "COM_ExecutionSystem.h"
+
+TonemapNode::TonemapNode(bNode *editorNode): Node(editorNode) {
+}
+
+void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ NodeTonemap* data = (NodeTonemap*)this->getbNode()->storage;
+ TonemapOperation *operation = data->type==1?new PhotoreceptorTonemapOperation():new TonemapOperation();
+
+ operation->setData(data);
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
+ system->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
new file mode 100644
index 00000000000..2140d7deb6a
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_TonemapNode_h_
+#define _COM_TonemapNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief TonemapNode
+ * @ingroup Node
+ */
+class TonemapNode: public Node {
+public:
+ TonemapNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp
new file mode 100644
index 00000000000..9b6d5ec35c5
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TransformNode.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TransformNode.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_TranslateOperation.h"
+#include "COM_RotateOperation.h"
+#include "COM_ScaleOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_SetSamplerOperation.h"
+
+TransformNode::TransformNode(bNode *editorNode): Node(editorNode) {
+}
+
+void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *imageInput = this->getInputSocket(0);
+ InputSocket *xInput = this->getInputSocket(1);
+ InputSocket *yInput = this->getInputSocket(2);
+ InputSocket *angleInput = this->getInputSocket(3);
+ InputSocket *scaleInput = this->getInputSocket(4);
+
+ ScaleOperation * scaleOperation = new ScaleOperation();
+ RotateOperation * rotateOperation = new RotateOperation();
+ TranslateOperation * translateOperation = new TranslateOperation();
+ SetSamplerOperation *sampler = new SetSamplerOperation();
+
+ switch (this->getbNode()->custom1) {
+ case 0:
+ sampler->setSampler(COM_PS_NEAREST);
+ break ;
+ case 1:
+ sampler->setSampler(COM_PS_BILINEAR);
+ break;
+ case 2:
+ sampler->setSampler(COM_PS_BICUBIC);
+ break;
+ }
+
+ imageInput->relinkConnections(sampler->getInputSocket(0), true, 0, graph);
+ addLink(graph, sampler->getOutputSocket(), scaleOperation->getInputSocket(0));
+ scaleInput->relinkConnections(scaleOperation->getInputSocket(1), true, 4, graph);
+ addLink(graph, scaleOperation->getInputSocket(1)->getConnection()->getFromSocket(), scaleOperation->getInputSocket(2)); // xscale = yscale
+
+ addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ rotateOperation->setDoDegree2RadConversion(false);
+ angleInput->relinkConnections(rotateOperation->getInputSocket(1), true, 3, graph);
+
+ addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ xInput->relinkConnections(translateOperation->getInputSocket(1), true, 1, graph);
+ yInput->relinkConnections(translateOperation->getInputSocket(2), true, 2, graph);
+
+ this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket());
+
+ graph->addOperation(sampler);
+ graph->addOperation(scaleOperation);
+ graph->addOperation(rotateOperation);
+ graph->addOperation(translateOperation);
+}
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
new file mode 100644
index 00000000000..bcb71ba8e5d
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief TransformNode
+ * @ingroup Node
+ */
+class TransformNode : public Node {
+public:
+ TransformNode(bNode* editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
new file mode 100644
index 00000000000..4dfa901610c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TranslateNode.h"
+
+#include "COM_TranslateOperation.h"
+#include "COM_ExecutionSystem.h"
+
+TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode) {
+}
+
+void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *inputSocket = this->getInputSocket(0);
+ InputSocket *inputXSocket = this->getInputSocket(1);
+ InputSocket *inputYSocket = this->getInputSocket(2);
+ OutputSocket *outputSocket = this->getOutputSocket(0);
+ TranslateOperation *operation = new TranslateOperation();
+
+ inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph);
+ inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph);
+ outputSocket->relinkConnections(operation->getOutputSocket(0));
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h
new file mode 100644
index 00000000000..8f7558ea468
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_TranslateNode_h_
+#define _COM_TranslateNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief TranslateNode
+ * @ingroup Node
+ */
+class TranslateNode: public Node {
+public:
+ TranslateNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp
new file mode 100644
index 00000000000..0b40872bed4
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ValueNode.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ValueNode.h"
+#include "DNA_scene_types.h"
+#include "COM_SetValueOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ValueNode::ValueNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ SetValueOperation *operation = new SetValueOperation();
+ bNodeSocket* socket = this->getEditorOutputSocket(0);
+ bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)socket->default_value;
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ operation->setValue(dval->value);
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
new file mode 100644
index 00000000000..f0322a9704c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ValueNode_h_
+#define _COM_ValueNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ValueNode
+ * @ingroup Node
+ */
+class ValueNode: public Node {
+public:
+ ValueNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
new file mode 100644
index 00000000000..2063f21c785
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_VectorBlurNode.h"
+#include "DNA_node_types.h"
+#include "COM_FogGlowImageOperation.h"
+#include "COM_BokehBlurOperation.h"
+#include "COM_VectorBlurOperation.h"
+#include "COM_SetValueOperation.h"
+#include "COM_MixBlendOperation.h"
+
+VectorBlurNode::VectorBlurNode(bNode *editorNode): Node(editorNode) {
+}
+
+void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) {
+ bNode* node = this->getbNode();
+ NodeBlurData* vectorBlurSettings = (NodeBlurData*)node->storage;
+ VectorBlurOperation *operation = new VectorBlurOperation();
+ operation->setVectorBlurSettings(vectorBlurSettings);
+ operation->setQuality(context->getQuality());
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system);
+ this->getOutputSocket()->relinkConnections(operation->getOutputSocket());
+ system->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
new file mode 100644
index 00000000000..54449bde1d3
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_VectorBlurNode_h_
+#define _COM_VectorBlurNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief VectorBlurNode
+ * @ingroup Node
+ */
+class VectorBlurNode: public Node {
+public:
+ VectorBlurNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
new file mode 100644
index 00000000000..c62906a82a6
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_VectorCurveNode.h"
+#include "DNA_scene_types.h"
+#include "COM_VectorCurveOperation.h"
+#include "COM_ExecutionSystem.h"
+
+VectorCurveNode::VectorCurveNode(bNode *editorNode): Node(editorNode) {
+}
+
+void VectorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ VectorCurveOperation *operation = new VectorCurveOperation();
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+
+ operation->setCurveMapping((CurveMapping*)this->getbNode()->storage);
+
+ graph->addOperation(operation);
+}
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
new file mode 100644
index 00000000000..e18dac54c2c
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_VectorCurveNode_h_
+#define _COM_VectorCurveNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief VectorCurveNode
+ * @ingroup Node
+ */
+class VectorCurveNode: public Node {
+public:
+ VectorCurveNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
new file mode 100644
index 00000000000..b5b15b2ba70
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ViewLevelsNode.h"
+#include "DNA_scene_types.h"
+#include "COM_ExecutionSystem.h"
+#include "COM_CalculateMeanOperation.h"
+#include "COM_CalculateStandardDeviationOperation.h"
+
+ViewLevelsNode::ViewLevelsNode(bNode *editorNode): Node(editorNode) {
+}
+void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket * input = this->getInputSocket(0);
+ bool firstOperationConnected = false;
+ if (input->isConnected()) {
+ OutputSocket* inputSocket= input->getConnection()->getFromSocket();
+ // add preview to inputSocket;
+
+ OutputSocket * socket = this->getOutputSocket(0);
+ if (socket->isConnected()) {
+ // calculate mean operation
+ CalculateMeanOperation * operation = new CalculateMeanOperation();
+ input->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ firstOperationConnected = true;
+ operation->setSetting(this->getbNode()->custom1);
+ socket->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+ }
+
+ socket = this->getOutputSocket(1);
+ if (socket->isConnected()) {
+ // calculate standard deviation operation
+ CalculateStandardDeviationOperation * operation = new CalculateStandardDeviationOperation();
+ if (firstOperationConnected) {
+ addLink(graph, inputSocket, operation->getInputSocket(0));
+ }else{
+ input->relinkConnections(operation->getInputSocket(0), true, 0, graph);
+ }
+ operation->setSetting(this->getbNode()->custom1);
+ socket->relinkConnections(operation->getOutputSocket());
+ graph->addOperation(operation);
+ }
+ }
+}
+
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
new file mode 100644
index 00000000000..9d6b764a2a9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ViewLevelsNode_h_
+#define _COM_ViewLevelsNode_h_
+
+#include "COM_Node.h"
+
+/**
+ * @brief ViewLevelsNode
+ * @ingroup Node
+ */
+class ViewLevelsNode: public Node {
+public:
+ ViewLevelsNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem* graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
new file mode 100644
index 00000000000..0148fac47f9
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ViewerNode.h"
+#include "BKE_global.h"
+
+#include "COM_ViewerOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ViewerNode::ViewerNode(bNode *editorNode): Node(editorNode) {
+}
+
+void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
+ InputSocket *imageSocket = this->getInputSocket(0);
+ InputSocket *alphaSocket = this->getInputSocket(1);
+ Image* image = (Image*)this->getbNode()->id;
+ ImageUser * imageUser = (ImageUser*) this->getbNode()->storage;
+ if (imageSocket->isConnected()) {
+ bNode* editorNode = this->getbNode();
+ ViewerOperation *viewerOperation = new ViewerOperation();
+ viewerOperation->setColorManagement( context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ viewerOperation->setColorPredivide( context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
+ viewerOperation->setbNodeTree(context->getbNodeTree());
+ viewerOperation->setImage(image);
+ viewerOperation->setImageUser(imageUser);
+ viewerOperation->setActive(editorNode->flag & NODE_DO_OUTPUT);
+ viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
+ viewerOperation->setCenterX(editorNode->custom3);
+ viewerOperation->setCenterY(editorNode->custom4);
+ imageSocket->relinkConnections(viewerOperation->getInputSocket(0), true, 0, graph);
+ alphaSocket->relinkConnections(viewerOperation->getInputSocket(1));
+ graph->addOperation(viewerOperation);
+ addPreviewOperation(graph, viewerOperation->getInputSocket(0), 0);
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
new file mode 100644
index 00000000000..59371f04e87
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ViewerNode_h
+#define _COM_ViewerNode_h
+
+#include "COM_Node.h"
+#include "DNA_node_types.h"
+/**
+ * @brief ViewerNode
+ * @ingroup Node
+ */
+class ViewerNode : public Node {
+public:
+ ViewerNode(bNode *editorNode);
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+#endif
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
new file mode 100644
index 00000000000..be7b6ebdc45
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ZCombineNode.h"
+
+#include "COM_ZCombineOperation.h"
+
+#include "COM_ExecutionSystem.h"
+#include "COM_SetValueOperation.h"
+#include "COM_MathBaseOperation.h"
+
+#include "DNA_material_types.h" // the ramp types
+
+void ZCombineNode::convertToOperations(ExecutionSystem* system, CompositorContext * context) {
+ if (this->getOutputSocket(0)->isConnected()) {
+ ZCombineOperation * operation = NULL;
+ if (this->getbNode()->custom1) {
+ operation = new ZCombineAlphaOperation();
+ } else {
+ operation = new ZCombineOperation();
+ }
+
+ this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system);
+ this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, system);
+ this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
+ system->addOperation(operation);
+ if (this->getOutputSocket(1)->isConnected()) {
+ MathMinimumOperation * zoperation = new MathMinimumOperation();
+ addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0));
+ addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1));
+ this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
+ system->addOperation(zoperation);
+ }
+ } else {
+ if (this->getOutputSocket(1)->isConnected()) {
+ MathMinimumOperation * zoperation = new MathMinimumOperation();
+ this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), true, 1, system);
+ this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), true, 3, system);
+ this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket());
+ system->addOperation(zoperation);
+ }
+ }
+}
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
new file mode 100644
index 00000000000..0faf7df8725
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ZCombineNode_h
+#define _COM_ZCombineNode_h
+
+#include "COM_Node.h"
+
+/**
+ * @brief ZCombineNode
+ * @ingroup Node
+ */
+class ZCombineNode: public Node {
+public:
+ ZCombineNode(bNode* editorNode) :Node(editorNode) {}
+ void convertToOperations(ExecutionSystem *graph, CompositorContext * context);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
new file mode 100644
index 00000000000..2dba9572ee8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_AlphaOverKeyOperation.h"
+
+AlphaOverKeyOperation::AlphaOverKeyOperation(): MixBaseOperation() {
+}
+
+void AlphaOverKeyOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
+
+ inputValueOperation->read(value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
+
+ if(inputOverColor[3]<=0.0f) {
+ outputValue[0] = inputColor1[0];
+ outputValue[1] = inputColor1[1];
+ outputValue[2] = inputColor1[2];
+ outputValue[3] = inputColor1[3];
+ }
+ else if(value[0]==1.0f && inputOverColor[3]>=1.0f) {
+ outputValue[0] = inputOverColor[0];
+ outputValue[1] = inputOverColor[1];
+ outputValue[2] = inputOverColor[2];
+ outputValue[3] = inputOverColor[3];
+ }
+ else {
+ float premul= value[0]*inputOverColor[3];
+ float mul= 1.0f - premul;
+
+ outputValue[0]= (mul*inputColor1[0]) + premul*inputOverColor[0];
+ outputValue[1]= (mul*inputColor1[1]) + premul*inputOverColor[1];
+ outputValue[2]= (mul*inputColor1[2]) + premul*inputOverColor[2];
+ outputValue[3]= (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ }
+}
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
new file mode 100644
index 00000000000..5ed99d0dbc6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_AlphaOverKeyOperation_h
+#define _COM_AlphaOverKeyOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class AlphaOverKeyOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ AlphaOverKeyOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
new file mode 100644
index 00000000000..9deb00ae71a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_AlphaOverMixedOperation.h"
+
+AlphaOverMixedOperation::AlphaOverMixedOperation(): MixBaseOperation() {
+ this->x = 0.0f;
+}
+
+void AlphaOverMixedOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
+
+ inputValueOperation->read(value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
+
+ if(inputOverColor[3]<=0.0f) {
+ outputValue[0] = inputColor1[0];
+ outputValue[1] = inputColor1[1];
+ outputValue[2] = inputColor1[2];
+ outputValue[3] = inputColor1[3];
+ }
+ else if(value[0]==1.0f && inputOverColor[3]>=1.0f) {
+ outputValue[0] = inputOverColor[0];
+ outputValue[1] = inputOverColor[1];
+ outputValue[2] = inputOverColor[2];
+ outputValue[3] = inputOverColor[3];
+ }
+ else {
+ float addfac= 1.0f - this->x + inputOverColor[3]*this->x;
+ float premul= value[0]*addfac;
+ float mul= 1.0f - value[0]*inputOverColor[3];
+
+ outputValue[0]= (mul*inputColor1[0]) + premul*inputOverColor[0];
+ outputValue[1]= (mul*inputColor1[1]) + premul*inputOverColor[1];
+ outputValue[2]= (mul*inputColor1[2]) + premul*inputOverColor[2];
+ outputValue[3]= (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
new file mode 100644
index 00000000000..3ee5f243303
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_AlphaOverMixedOperation_h
+#define _COM_AlphaOverMixedOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class AlphaOverMixedOperation : public MixBaseOperation {
+private:
+ float x;
+public:
+ /**
+ * Default constructor
+ */
+ AlphaOverMixedOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void setX(float x) {this->x = x;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
new file mode 100644
index 00000000000..635a6308601
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_AlphaOverPremultiplyOperation.h"
+
+AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation(): MixBaseOperation() {
+}
+
+void AlphaOverPremultiplyOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
+
+ inputValueOperation->read(value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputOverColor, x, y, sampler, inputBuffers);
+
+ /* Zero alpha values should still permit an add of RGB data */
+ if(inputOverColor[3]<0.0f) {
+ outputValue[0] = inputColor1[0];
+ outputValue[1] = inputColor1[1];
+ outputValue[2] = inputColor1[2];
+ outputValue[3] = inputColor1[3];
+ }
+ else if(value[0]==1.0f && inputOverColor[3]>=1.0f) {
+ outputValue[0] = inputOverColor[0];
+ outputValue[1] = inputOverColor[1];
+ outputValue[2] = inputOverColor[2];
+ outputValue[3] = inputOverColor[3];
+ }
+ else {
+ float mul= 1.0f - value[0]*inputOverColor[3];
+
+ outputValue[0]= (mul*inputColor1[0]) + value[0]*inputOverColor[0];
+ outputValue[1]= (mul*inputColor1[1]) + value[0]*inputOverColor[1];
+ outputValue[2]= (mul*inputColor1[2]) + value[0]*inputOverColor[2];
+ outputValue[3]= (mul*inputColor1[3]) + value[0]*inputOverColor[3];
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
new file mode 100644
index 00000000000..4fc3b482942
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_AlphaOverPremultiplyOperation_h
+#define _COM_AlphaOverPremultiplyOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class AlphaOverPremultiplyOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ AlphaOverPremultiplyOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
new file mode 100644
index 00000000000..729d04c182e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_AntiAliasOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+extern "C" {
+ #include "RE_render_ext.h"
+}
+
+
+AntiAliasOperation::AntiAliasOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->valueReader = NULL;
+ this->buffer = NULL;
+ this->setComplex(true);
+}
+void AntiAliasOperation::initExecution() {
+ this->valueReader = this->getInputSocketReader(0);
+ NodeOperation::initMutex();
+}
+
+void AntiAliasOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ if (y < 0 || y >= this->height || x < 0 || x >= this->width) {
+ color[0] = 0.0f;
+ } else {
+ int offset = y*this->width + x;
+ color[0] = buffer[offset]/255.0f;
+ }
+
+}
+
+void AntiAliasOperation::deinitExecution() {
+ this->valueReader = NULL;
+ if (this->buffer) {
+ delete buffer;
+ }
+ NodeOperation::deinitMutex();
+}
+
+bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti imageInput;
+ if (this->buffer) {
+ return false;
+ } else {
+ NodeOperation* operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void* AntiAliasOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ if (this->buffer) {return buffer;}
+ BLI_mutex_lock(getMutex());
+ if (this->buffer == NULL) {
+ MemoryBuffer* tile = (MemoryBuffer*)valueReader->initializeTileData(rect, memoryBuffers);
+ int size = tile->getHeight()*tile->getWidth();
+ float * input = tile->getBuffer();
+ char* valuebuffer = new char[size];
+ for (int i = 0 ; i < size ; i ++) {
+ float in = input[i* COM_NUMBER_OF_CHANNELS];
+ if (in < 0.0f) { in = 0.0f;}
+ if (in > 1.0f) {in = 1.0f;}
+ valuebuffer[i] = in * 255;
+ }
+ antialias_tagbuf(tile->getWidth(), tile->getHeight(), valuebuffer);
+ this->buffer = valuebuffer;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->buffer;
+}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
new file mode 100644
index 00000000000..1b8b4c42ff9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_AntiAliasOperation_h
+#define _COM_AntiAliasOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief AntiAlias operations
+ * it only supports anti aliasing on BW buffers.
+ * @ingroup operation
+ */
+class AntiAliasOperation : public NodeOperation {
+protected:
+ /**
+ * @brief Cached reference to the reader
+ */
+ SocketReader * valueReader;
+ char *buffer;
+public:
+ AntiAliasOperation();
+
+ /**
+ * 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);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
new file mode 100644
index 00000000000..5743b388705
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BilateralBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+BilateralBlurOperation::BilateralBlurOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->inputColorProgram = NULL;
+ this->inputDeterminatorProgram = NULL;
+}
+
+void BilateralBlurOperation::initExecution() {
+ this->inputColorProgram = getInputSocketReader(0);
+ this->inputDeterminatorProgram = getInputSocketReader(1);
+ this->space = this->data->sigma_space + this->data->iter;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+}
+
+void BilateralBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ // read the determinator color at x, y, this will be used as the reference color for the determinator
+ float determinatorReferenceColor[4];
+ float determinator[4];
+ float tempColor[4];
+ float blurColor[4];
+ float blurDivider;
+ float space = this->space;
+ float sigmacolor = this->data->sigma_color;
+ int minx = floor(x - space);
+ int maxx = ceil(x + space);
+ int miny = floor(y - space);
+ int maxy = ceil(y + space);
+ float deltaColor;
+ this->inputDeterminatorProgram->read(determinatorReferenceColor, x, y, inputBuffers, data);
+
+ blurColor[0] = 0.0f;
+ blurColor[1] = 0.0f;
+ blurColor[2] = 0.0f;
+ blurColor[3] = 0.0f;
+ blurDivider = 0.0f;
+ for (int yi = miny ; yi < maxy ; yi+=QualityStepHelper::getStep()) {
+ for (int xi = minx ; xi < maxx ; xi+=QualityStepHelper::getStep()) {
+ // read determinator
+ this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
+ deltaColor = fabsf(determinatorReferenceColor[0] - determinator[0])+
+ fabsf(determinatorReferenceColor[1] - determinator[1])+
+ fabsf(determinatorReferenceColor[2] - determinator[2]); // do not take the alpha channel into account
+ if (deltaColor< sigmacolor) {
+ // add this to the blur
+ this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
+ blurColor[0]+=tempColor[0];
+ blurColor[1]+=tempColor[1];
+ blurColor[2]+=tempColor[2];
+ blurColor[3]+=tempColor[3];
+ blurDivider += 1.0f;
+ }
+ }
+ }
+
+ if (blurDivider > 0.0f) {
+ color[0] = blurColor[0]/blurDivider;
+ color[1] = blurColor[1]/blurDivider;
+ color[2] = blurColor[2]/blurDivider;
+ color[3] = blurColor[3]/blurDivider;
+ } else {
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 1.0f;
+ }
+}
+
+void BilateralBlurOperation::deinitExecution() {
+ this->inputColorProgram = NULL;
+ this->inputDeterminatorProgram = NULL;
+}
+
+bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ int add = ceil(this->space)+1;
+
+ newInput.xmax = input->xmax + (add);
+ newInput.xmin = input->xmin - (add);
+ newInput.ymax = input->ymax + (add);
+ newInput.ymin = input->ymin - (add);
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
new file mode 100644
index 00000000000..295797fb0b8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehBilateralBlurOperation_h
+#define _COM_BilateralBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class BilateralBlurOperation : public NodeOperation, public QualityStepHelper {
+private:
+ SocketReader* inputColorProgram;
+ SocketReader* inputDeterminatorProgram;
+ NodeBilateralBlurData* data;
+ float space;
+
+public:
+ BilateralBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setData(NodeBilateralBlurData *data) {this->data = data;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
new file mode 100644
index 00000000000..b18c0762c1a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BlurBaseOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+BlurBaseOperation::BlurBaseOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->inputProgram = NULL;
+ this->data = NULL;
+ this->size = 1.0f;
+ this->deleteData = false;
+}
+void BlurBaseOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ this->inputSize = this->getInputSocketReader(1);
+ this->data->image_in_width= this->getWidth();
+ this->data->image_in_height= this->getHeight();
+ if(this->data->relative) {
+ switch (this->data->aspect) {
+ case CMP_NODE_BLUR_ASPECT_NONE:
+ this->data->sizex= (int)(this->data->percentx*0.01f*this->data->image_in_width);
+ this->data->sizey= (int)(this->data->percenty*0.01f*this->data->image_in_height);
+ break;
+ case CMP_NODE_BLUR_ASPECT_Y:
+ this->data->sizex= (int)(this->data->percentx*0.01f*this->data->image_in_width);
+ this->data->sizey= (int)(this->data->percenty*0.01f*this->data->image_in_width);
+ break;
+ case CMP_NODE_BLUR_ASPECT_X:
+ this->data->sizex= (int)(this->data->percentx*0.01f*this->data->image_in_height);
+ this->data->sizey= (int)(this->data->percenty*0.01f*this->data->image_in_height);
+ break;
+ }
+ }
+
+ QualityStepHelper::initExecution(COM_QH_MULTIPLY);
+
+}
+
+float* BlurBaseOperation::make_gausstab(int rad)
+{
+ float *gausstab, sum, val;
+ int i, n;
+
+ n = 2 * rad + 1;
+
+ gausstab = new float[n];
+
+ sum = 0.0f;
+ for (i = -rad; i <= rad; i++) {
+ val= RE_filter_value(this->data->filtertype, (float)i/(float)rad);
+ sum += val;
+ gausstab[i+rad] = val;
+ }
+
+ sum= 1.0f/sum;
+ for(i=0; i<n; i++)
+ gausstab[i]*= sum;
+
+ return gausstab;
+}
+
+void BlurBaseOperation::deinitExecution() {
+ this->inputProgram = NULL;
+ this->inputSize = NULL;
+ if (this->deleteData) {
+ delete this->data;
+ }
+ this->data = NULL;
+}
+
+void BlurBaseOperation::updateSize(MemoryBuffer **memoryBuffers){
+ float result[4];
+ this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, memoryBuffers);
+ this->size = result[0];
+}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
new file mode 100644
index 00000000000..3eb36f29865
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BlurBaseOperation_h
+#define _COM_BlurBaseOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class BlurBaseOperation : public NodeOperation, public QualityStepHelper {
+private:
+
+protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputProgram;
+ SocketReader* inputSize;
+ NodeBlurData * data;
+ BlurBaseOperation();
+ float* make_gausstab(int rad);
+ float size;
+ bool deleteData;
+ void updateSize(MemoryBuffer **memoryBuffers);
+public:
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeBlurData* data) {this->data= data;}
+
+ void deleteDataWhenFinished() {this->deleteData = true;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
new file mode 100644
index 00000000000..31345dbaeff
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BokehBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+BokehBlurOperation::BokehBlurOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->size = .01;
+
+ this->inputProgram = NULL;
+ this->inputBokehProgram = NULL;
+ this->inputBoundingBoxReader = NULL;
+}
+
+void* BokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ void* buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void BokehBlurOperation::initExecution() {
+ this->inputProgram = getInputSocketReader(0);
+ this->inputBokehProgram = getInputSocketReader(1);
+ this->inputBoundingBoxReader = getInputSocketReader(2);
+
+ int width = inputBokehProgram->getWidth();
+ int height = inputBokehProgram->getHeight();
+
+ float dimension;
+ if (width<height) {
+ dimension = width;
+ } else {
+ dimension = height;
+ }
+ this->bokehMidX = width/2.0f;
+ this->bokehMidY = height/2.0f;
+ this->bokehDimension = dimension/2.0f;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+}
+
+void BokehBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float tempColor[4];
+ float tempBoundingBox[4];
+ float bokeh[4];
+
+ inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers);
+ if (tempBoundingBox[0] >0.0f) {
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float overallmultiplyerr = 0;
+ float overallmultiplyerg = 0;
+ float overallmultiplyerb = 0;
+ MemoryBuffer* inputBuffer = (MemoryBuffer*)data;
+ float* buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+ int pixelSize = this->size*this->getWidth();
+
+ int miny = y - pixelSize;
+ int maxy = y + pixelSize;
+ int minx = x - pixelSize;
+ int maxx = x + pixelSize;
+ miny = max(miny, inputBuffer->getRect()->ymin);
+ minx = max(minx, inputBuffer->getRect()->xmin);
+ maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax);
+
+ int step = getStep();
+ int offsetadd = getOffsetAdd();
+
+ float m = this->bokehDimension/pixelSize;
+ for (int ny = miny ; ny < maxy ; ny +=step) {
+ int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
+ for (int nx = minx ; nx < maxx ; nx +=step) {
+ float u = this->bokehMidX - (nx-x) *m;
+ float v = this->bokehMidY - (ny-y) *m;
+ inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
+ tempColor[0] += bokeh[0] * buffer[bufferindex];
+ tempColor[1] += bokeh[1] * buffer[bufferindex+1];
+ tempColor[2] += bokeh[2]* buffer[bufferindex+2];
+ overallmultiplyerr += bokeh[0];
+ overallmultiplyerg += bokeh[1];
+ overallmultiplyerb += bokeh[2];
+ bufferindex +=offsetadd;
+ }
+ }
+ color[0] = tempColor[0]*(1.0/overallmultiplyerr);
+ color[1] = tempColor[1]*(1.0/overallmultiplyerg);
+ color[2] = tempColor[2]*(1.0/overallmultiplyerb);
+ color[3] = 1.0f;
+ } else {
+ inputProgram->read(color, x, y, COM_PS_NEAREST, inputBuffers);
+ }
+}
+
+void BokehBlurOperation::deinitExecution() {
+ this->inputProgram = NULL;
+ this->inputBokehProgram = NULL;
+ this->inputBoundingBoxReader = NULL;
+}
+
+bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ rcti bokehInput;
+
+ newInput.xmax = input->xmax + (size*this->getWidth());
+ newInput.xmin = input->xmin - (size*this->getWidth());
+ newInput.ymax = input->ymax + (size*this->getWidth());
+ newInput.ymin = input->ymin - (size*this->getWidth());
+
+ NodeOperation* operation = getInputOperation(1);
+ bokehInput.xmax = operation->getWidth();
+ bokehInput.xmin = 0;
+ bokehInput.ymax = operation->getHeight();
+ bokehInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
+ return true;
+ }
+ operation = getInputOperation(0);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
+ return true;
+ }
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
+ return true;
+ }
+ return false;
+}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
new file mode 100644
index 00000000000..c782c421966
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehBokehBlurOperation_h
+#define _COM_BokehBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class BokehBlurOperation : public NodeOperation, public QualityStepHelper {
+private:
+ SocketReader* inputProgram;
+ SocketReader* inputBokehProgram;
+ SocketReader* inputBoundingBoxReader;
+ float size;
+ float bokehMidX;
+ float bokehMidY;
+ float bokehDimension;
+public:
+ BokehBlurOperation();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setSize(float size) {this->size = size;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
new file mode 100644
index 00000000000..3286217e71d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BokehImageOperation.h"
+#include "BLI_math.h"
+
+BokehImageOperation::BokehImageOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+ this->deleteData = false;
+}
+void BokehImageOperation::initExecution() {
+ this->centerX = getWidth() / 2;
+ this->centerY = getHeight() / 2;
+ this->center[0] = this->centerX;
+ this->center[1] = this->centerY;
+ this->inverseRounding = 1.0-this->data->rounding;
+ this->circularDistance = getWidth()/2;
+ this->flapRad = (M_PI*2)/this->data->flaps;
+ this->flapRadAdd = (this->data->angle/360.0)*M_PI*2;
+ if (this->flapRadAdd>M_PI) {
+ this->flapRadAdd-=M_PI*2;
+ }
+}
+void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance) {
+ r[0] = sin(flapRad*flapNumber + flapRadAdd)*distance+centerX;
+ r[1] = cos(flapRad*flapNumber + flapRadAdd)*distance+centerY;
+}
+float BokehImageOperation::isInsideBokeh(float distance, float x, float y) {
+ float insideBokeh = 0.0;
+ const float deltaX = x - centerX;
+ const float deltaY = y - centerY;
+ float closestPoint[2];
+ float lineP1[2];
+ float lineP2[2];
+ float point[2];
+ point[0] = x;
+ point[1] = y;
+
+ const float distanceToCenter = len_v2v2(point, center);
+ const float bearing = (atan2f(deltaX, deltaY) + (M_PI*2));
+ int flapNumber = (int)((bearing-flapRadAdd)/flapRad);
+
+ detemineStartPointOfFlap(lineP1, flapNumber, distance);
+ detemineStartPointOfFlap(lineP2, flapNumber+1, distance);
+ closest_to_line_v2(closestPoint, point, lineP1, lineP2);
+
+ const float distanceLineToCenter = len_v2v2(center, closestPoint);
+ const float distanceRoundingToCenter = inverseRounding*distanceLineToCenter+this->data->rounding*distance;
+
+ const float catadioptricDistanceToCenter = distanceRoundingToCenter*this->data->catadioptric;
+ if (distanceRoundingToCenter>=distanceToCenter && catadioptricDistanceToCenter<=distanceToCenter) {
+ if (distanceRoundingToCenter-distanceToCenter<1.0) {
+ insideBokeh = (distanceRoundingToCenter-distanceToCenter);
+ } else if (this->data->catadioptric != 0.0 && distanceToCenter-catadioptricDistanceToCenter<1.0) {
+ insideBokeh = (distanceToCenter-catadioptricDistanceToCenter);
+ } else {
+ insideBokeh = 1.0;
+ }
+ }
+ return insideBokeh;
+}
+void BokehImageOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float shift = this->data->lensshift;
+ float shift2 = shift/2.0f;
+ float distance = this->circularDistance;
+ float insideBokehMax = isInsideBokeh(distance, x, y);
+ float insideBokehMed = isInsideBokeh(distance-fabs(shift2*distance), x, y);
+ float insideBokehMin = isInsideBokeh(distance-fabs(shift*distance), x, y);
+ if (shift<0) {
+ color[0] = insideBokehMax;
+ color[1] = insideBokehMed;
+ color[2] = insideBokehMin;
+ } else {
+ color[0] = insideBokehMin;
+ color[1] = insideBokehMed;
+ color[2] = insideBokehMax;
+ }
+ color[3] = 1.0f;
+}
+
+void BokehImageOperation::deinitExecution() {
+ if (deleteData) {
+ if (data) {
+ delete data;
+ data = NULL;
+ }
+ }
+}
+
+void BokehImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = 512;
+ resolution[1] = 512;
+}
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
new file mode 100644
index 00000000000..3089ca6f12e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehImageOperation_h
+#define _COM_BokehImageOperation_h
+#include "COM_NodeOperation.h"
+
+
+class BokehImageOperation : public NodeOperation {
+private:
+ NodeBokehImage *data;
+
+ float center[2];
+ float centerX;
+ float centerY;
+ float inverseRounding;
+ float circularDistance;
+ float flapRad;
+ float flapRadAdd;
+
+ bool deleteData;
+
+ void detemineStartPointOfFlap(float r[2], int flapNumber, float distance);
+ float isInsideBokeh(float distance, float x, float y);
+public:
+ BokehImageOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void setData(NodeBokehImage *data) {this->data = data;}
+ void deleteDataOnFinish() {this->deleteData = true;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
new file mode 100644
index 00000000000..44157051089
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BoxMaskOperation.h"
+#include "BLI_math.h"
+#include "DNA_node_types.h"
+
+BoxMaskOperation::BoxMaskOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputMask = NULL;
+ this->inputValue = NULL;
+ this->cosine = 0.0f;
+ this->sine = 0.0f;
+}
+void BoxMaskOperation::initExecution() {
+ this->inputMask = this->getInputSocketReader(0);
+ this->inputValue = this->getInputSocketReader(1);
+ const double rad = DEG2RAD(this->data->rotation);
+ this->cosine = cos(rad);
+ this->sine = sin(rad);
+ this->aspectRatio = ((float)this->getWidth())/this->getHeight();
+}
+
+void BoxMaskOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputMask[4];
+ float inputValue[4];
+
+ float rx = x/this->getWidth();
+ float ry = y/this->getHeight();
+
+ const float dy = (ry - this->data->y)/this->aspectRatio;
+ const float dx = rx - this->data->x;
+ rx = this->data->x+(this->cosine*dx + this->sine*dy);
+ ry = this->data->y+(-this->sine*dx + this->cosine*dy);
+
+ this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
+ this->inputValue->read(inputValue, x, y, sampler, inputBuffers);
+
+ float halfHeight = (this->data->height)/2.0f;
+ float halfWidth = this->data->width/2.0f;
+ bool inside = rx > this->data->x-halfWidth
+ && rx < this->data->x+halfWidth
+ && ry > this->data->y-halfHeight
+ && ry < this->data->y+halfHeight;
+
+ switch (this->maskType) {
+ case CMP_NODE_MASKTYPE_ADD:
+ if (inside) {
+ color[0] = max(inputMask[0],inputValue[0]);
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_SUBTRACT:
+ if (inside) {
+ color[0] = inputMask[0]-inputValue[0];
+ CLAMP(color[0], 0, 1);
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_MULTIPLY:
+ if (inside) {
+ color[0] = inputMask[0]*inputValue[0];
+ } else {
+ color[0] = 0;
+ }
+ break;
+ case CMP_NODE_MASKTYPE_NOT:
+ if (inside) {
+ if (inputMask[0]>0.0f) {
+ color[0] = 0;
+ } else {
+ color[0] = inputValue[0];
+ }
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ }
+
+
+}
+
+void BoxMaskOperation::deinitExecution() {
+ this->inputMask = NULL;
+ this->inputValue = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
new file mode 100644
index 00000000000..3436eec8b4c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BoxMaskOperation_h
+#define _COM_BoxMaskOperation_h
+#include "COM_NodeOperation.h"
+
+
+class BoxMaskOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputMask;
+ SocketReader * inputValue;
+
+ float sine;
+ float cosine;
+ float aspectRatio;
+ int maskType;
+
+ NodeBoxMask *data;
+public:
+ BoxMaskOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeBoxMask *data) {this->data = data;}
+
+ void setMaskType(int maskType) {this->maskType = maskType;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
new file mode 100644
index 00000000000..bb481f71cc1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_BrightnessOperation.h"
+
+BrightnessOperation::BrightnessOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+}
+void BrightnessOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ this->inputBrightnessProgram = this->getInputSocketReader(1);
+ this->inputContrastProgram = this->getInputSocketReader(2);
+}
+
+void BrightnessOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float a, b;
+ float inputBrightness[4];
+ float inputContrast[4];
+ this->inputProgram->read(inputValue, x, y, sampler, inputBuffers);
+ this->inputBrightnessProgram->read(inputBrightness, x, y, sampler, inputBuffers);
+ this->inputContrastProgram->read(inputContrast, x, y, sampler, inputBuffers);
+ float brightness = inputBrightness[0];
+ float contrast = inputContrast[0];
+ brightness /= 100.0f;
+ float delta = contrast / 200.0f;
+ a = 1.0f - delta * 2.0f;
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+ if( contrast > 0 )
+ {
+ a = 1.0f / a;
+ b = a * (brightness - delta);
+ }
+ else
+ {
+ delta *= -1;
+ b = a * (brightness + delta);
+ }
+
+ color[0] = a*inputValue[0]+b;
+ color[1] = a*inputValue[1]+b;
+ color[2] = a*inputValue[2]+b;
+ color[3] = inputValue[3];
+}
+
+void BrightnessOperation::deinitExecution() {
+ this->inputProgram = NULL;
+ this->inputBrightnessProgram = NULL;
+ this->inputContrastProgram = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
new file mode 100644
index 00000000000..60666098bc1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BrightnessOperation_h
+#define _COM_BrightnessOperation_h
+#include "COM_NodeOperation.h"
+
+
+class BrightnessOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+ SocketReader * inputBrightnessProgram;
+ SocketReader* inputContrastProgram;
+
+public:
+ BrightnessOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
new file mode 100644
index 00000000000..062e7fc69fe
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CalculateMeanOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+
+
+CalculateMeanOperation::CalculateMeanOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->imageReader = NULL;
+ this->iscalculated = false;
+ this->setting = 1;
+ this->setComplex(true);
+}
+void CalculateMeanOperation::initExecution() {
+ this->imageReader = this->getInputSocketReader(0);
+ this->iscalculated = false;
+ NodeOperation::initMutex();
+}
+
+void CalculateMeanOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ color[0] = this->result;
+}
+
+void CalculateMeanOperation::deinitExecution() {
+ this->imageReader = NULL;
+ NodeOperation::deinitMutex();
+}
+
+bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti imageInput;
+ if (iscalculated) {
+ return false;
+ }
+ NodeOperation* operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
+ return true;
+ }
+ return false;
+}
+
+void* CalculateMeanOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ BLI_mutex_lock(getMutex());
+ if (!this->iscalculated) {
+ MemoryBuffer* tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ calculateMean(tile);
+ this->iscalculated = true;
+ }
+ BLI_mutex_unlock(getMutex());
+ return NULL;
+}
+
+void CalculateMeanOperation::calculateMean(MemoryBuffer * tile) {
+ this->result = 0.0f;
+ float* buffer = tile->getBuffer();
+ int size = tile->getWidth()*tile->getHeight();
+ int pixels = 0;
+ float sum;
+ for (int i = 0, offset = 0 ; i < size ; i ++, offset +=4) {
+ if (buffer[offset+3] > 0) {
+ pixels ++;
+
+ switch(this->setting)
+ {
+ case 1:
+ {
+ sum += buffer[offset]*0.35f + buffer[offset+1]*0.45f + buffer[offset+2]*0.2f;
+ break;
+ }
+ case 2:
+ {
+ sum+= buffer[offset];
+ break;
+ }
+ case 3:
+ {
+ sum+= buffer[offset+1];
+ break;
+ }
+ case 4:
+ {
+ sum+= buffer[offset+2];
+ break;
+ }
+ case 5:
+ {
+ float yuv[3];
+ rgb_to_yuv(buffer[offset], buffer[offset+1], buffer[offset+2], &yuv[0], &yuv[1], &yuv[2]);
+ sum+=yuv[0];
+ break;
+ }
+ }
+ }
+ }
+ this->result = sum / pixels;
+}
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
new file mode 100644
index 00000000000..e77b864c5c8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CalculateMeanOperation_h
+#define _COM_CalculateMeanOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief base class of CalculateMean, implementing the simple CalculateMean
+ * @ingroup operation
+ */
+class CalculateMeanOperation : public NodeOperation {
+protected:
+ /**
+ * @brief Cached reference to the reader
+ */
+ SocketReader * imageReader;
+
+ bool iscalculated;
+ float result;
+ int setting;
+
+public:
+ CalculateMeanOperation();
+
+ /**
+ * 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);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void setSetting(int setting) {this->setting = setting;}
+
+protected:
+ void calculateMean(MemoryBuffer* tile);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
new file mode 100644
index 00000000000..4cd990e417e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CalculateStandardDeviationOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+
+
+CalculateStandardDeviationOperation::CalculateStandardDeviationOperation(): CalculateMeanOperation() {
+}
+
+void CalculateStandardDeviationOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ color[0] = this->standardDeviation;
+}
+
+void* CalculateStandardDeviationOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ BLI_mutex_lock(getMutex());
+ if (!this->iscalculated) {
+ MemoryBuffer* tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ CalculateMeanOperation::calculateMean(tile);
+ this->standardDeviation = 0.0f;
+ float* buffer = tile->getBuffer();
+ int size = tile->getWidth()*tile->getHeight();
+ int pixels = 0;
+ float sum;
+ float mean = this->result;
+ for (int i = 0, offset = 0 ; i < size ; i ++, offset +=4) {
+ if (buffer[offset+3] > 0) {
+ pixels ++;
+
+ switch(this->setting)
+ {
+ case 1:
+ {
+ float value = buffer[offset]*0.35f + buffer[offset+1]*0.45f + buffer[offset+2]*0.2f;
+ sum+=(value-mean)*(value-mean);
+ break;
+ }
+ case 2:
+ {
+ float value = buffer[offset];
+ sum+=value;
+ sum+=(value-mean)*(value-mean);
+ break;
+ }
+ case 3:
+ {
+ float value = buffer[offset+1];
+ sum+=value;
+ sum+=(value-mean)*(value-mean);
+ break;
+ }
+ case 4:
+ {
+ float value = buffer[offset+2];
+ sum+=value;
+ sum+=(value-mean)*(value-mean);
+ }
+ case 5:
+ {
+ float yuv[3];
+ rgb_to_yuv(buffer[offset], buffer[offset+1], buffer[offset+2], &yuv[0], &yuv[1], &yuv[2]);
+ sum+=(yuv[0]-mean)*(yuv[0]-mean);
+ break;
+ }
+ }
+ }
+ }
+ this->standardDeviation = sqrt(sum / (float)(pixels-1));
+ this->iscalculated = true;
+ }
+ BLI_mutex_unlock(getMutex());
+ return NULL;
+}
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
new file mode 100644
index 00000000000..9da8823acd1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CalculateStandardDeviationOperation_h
+#define _COM_CalculateStandardDeviationOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_CalculateMeanOperation.h"
+/**
+ * @brief base class of CalculateStandardDeviation, implementing the simple CalculateStandardDeviation
+ * @ingroup operation
+ */
+class CalculateStandardDeviationOperation : public CalculateMeanOperation {
+protected:
+ float standardDeviation;
+
+public:
+ CalculateStandardDeviationOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
new file mode 100644
index 00000000000..fd2bd3991ec
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ChangeHSVOperation.h"
+
+ChangeHSVOperation::ChangeHSVOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ChangeHSVOperation::initExecution() {
+ this->inputOperation = getInputSocketReader(0);
+}
+
+void ChangeHSVOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
+void ChangeHSVOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+
+ inputOperation->read(inputColor1, x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputColor1[0] + (this->hue - 0.5f);
+ if (outputValue[0]>1.0f) outputValue[0]-=1.0; else if(outputValue[0]<0.0) outputValue[0]+= 1.0;
+ outputValue[1] = inputColor1[1] * this->saturation;
+ outputValue[2] = inputColor1[2] * this->value;
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
new file mode 100644
index 00000000000..8adae8e8ce7
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ChangeHSVOperation_h
+#define _COM_ChangeHSVOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ChangeHSVOperation : public NodeOperation {
+private:
+ SocketReader * inputOperation;
+
+ float hue;
+ float saturation;
+ float value;
+
+public:
+ /**
+ * Default constructor
+ */
+ ChangeHSVOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void setHue(float hue) {this->hue = hue;}
+ void setSaturation(float saturation) {this->saturation = saturation;}
+ void setValue(float value) {this->value = value;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
new file mode 100644
index 00000000000..b595aca3c46
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ChannelMatteOperation.h"
+#include "BLI_math.h"
+
+ChannelMatteOperation::ChannelMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImageProgram = NULL;
+}
+
+void ChannelMatteOperation::initExecution() {
+ this->inputImageProgram = this->getInputSocketReader(0);
+
+ this->limit_range = this->limit_max - this->limit_min;
+
+ switch (this->limit_method) {
+ /* SINGLE */
+ case 0: {
+ /* 123 / RGB / HSV / YUV / YCC */
+ const int matte_channel=this->matte_channel-1;
+ const int limit_channel=this->limit_channel-1;
+ this->ids[0] = matte_channel;
+ this->ids[1] = limit_channel;
+ this->ids[2] = limit_channel;
+ break;
+ }
+ /* MAX */
+ case 1: {
+ switch (this->matte_channel) {
+ case 1: {
+ this->ids[0] = 0;
+ this->ids[1] = 1;
+ this->ids[2] = 2;
+ break;
+ }
+ case 2: {
+ this->ids[0] = 1;
+ this->ids[1] = 0;
+ this->ids[2] = 2;
+ break;
+ }
+ case 3: {
+ this->ids[0] = 2;
+ this->ids[1] = 0;
+ this->ids[2] = 1;
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void ChannelMatteOperation::deinitExecution() {
+ this->inputImageProgram= NULL;
+}
+
+void ChannelMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inColor[4];
+ float alpha;
+
+ const float limit_max = this->limit_max;
+ const float limit_min = this->limit_min;
+ const float limit_range = this->limit_range;
+
+ this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers);
+
+ /* matte operation */
+ alpha = inColor[this->ids[0]] - max(inColor[this->ids[1]], inColor[this->ids[2]]);
+
+ /* flip because 0.0 is transparent, not 1.0 */
+ alpha = 1.f - alpha;
+
+ /* test range*/
+ if(alpha > limit_max) {
+ alpha = inColor[3]; /*whatever it was prior */
+ }
+ else if(alpha < limit_min){
+ alpha = 0.f;
+ }
+ else {/*blend */
+ alpha = (alpha - limit_min) / limit_range;
+ }
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /* don't make something that was more transparent less transparent */
+ outputValue[0] = min(alpha, inColor[3]);
+}
+
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
new file mode 100644
index 00000000000..33e502fe565
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ChannelMatteOperation_h
+#define _COM_ChannelMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ChannelMatteOperation : public NodeOperation {
+private:
+ SocketReader *inputImageProgram;
+
+ int color_space; /* node->custom1 */
+ int matte_channel; /* node->custom2 */
+ int limit_method; /* node->algorithm */
+ int limit_channel; /* node->channel */
+ float limit_max; /* node->storage->t1 */
+ float limit_min; /* node->storage->t2 */
+
+ float limit_range;
+
+ /** ids to use for the operations (max and simple)
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ * the simple operation is using:
+ * alpha = in[ids[0]] - in[ids[1]]
+ * but to use the same formula and operation for both we do:
+ * ids[2] = ids[1]
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ */
+ int ids[3];
+public:
+ /**
+ * Default constructor
+ */
+ ChannelMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma, const int custom2)
+ {
+ this->limit_max = nodeChroma->t1;
+ this->limit_min = nodeChroma->t2;
+ this->limit_method = nodeChroma->algorithm;
+ this->limit_channel = nodeChroma->channel;
+ this->matte_channel = custom2;
+ }
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
new file mode 100644
index 00000000000..8e793f08a3b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ChromaMatteOperation.h"
+#include "BLI_math.h"
+
+ChromaMatteOperation::ChromaMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImageProgram = NULL;
+ inputKeyProgram = NULL;
+}
+
+void ChromaMatteOperation::initExecution() {
+ this->inputImageProgram = this->getInputSocketReader(0);
+ this->inputKeyProgram = this->getInputSocketReader(1);
+}
+
+void ChromaMatteOperation::deinitExecution() {
+ this->inputImageProgram= NULL;
+ this->inputKeyProgram= NULL;
+}
+
+void ChromaMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inKey[4];
+ float inImage[4];
+
+ const float acceptance = this->settings->t1; /* in radians */
+ const float cutoff = this->settings->t2; /* in radians */
+ const float gain = this->settings->fstrength;
+
+ float x_angle, z_angle, alpha;
+ float theta, beta;
+ float kfg;
+
+ this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers);
+ this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers);
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /* Algorithm from book "Video Demistified," does not include the spill reduction part */
+ /* find theta, the angle that the color space should be rotated based on key*/
+ theta=atan2(inKey[2], inKey[1]);
+
+ /*rotate the cb and cr into x/z space */
+ x_angle=inImage[1]*cosf(theta)+inImage[2]*sinf(theta);
+ z_angle=inImage[2]*cosf(theta)-inImage[1]*sinf(theta);
+
+ /*if within the acceptance angle */
+ /* if kfg is <0 then the pixel is outside of the key color */
+ kfg= x_angle-(fabsf(z_angle)/tanf(acceptance/2.f));
+
+ if(kfg>0.f) { /* found a pixel that is within key color */
+ alpha=(1.f-kfg)*(gain);
+
+ beta=atan2(z_angle,x_angle);
+
+ /* if beta is within the cutoff angle */
+ if(fabsf(beta) < (cutoff/2.f)) {
+ alpha=0.f;
+ }
+
+ /* don't make something that was more transparent less transparent */
+ if (alpha<inImage[3]) {
+ outputValue[0]=alpha;
+ }
+ else {
+ outputValue[0]=inImage[3];
+ }
+ }
+ else { /*pixel is outside key color */
+ outputValue[0]=inImage[3]; /* make pixel just as transparent as it was before */
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
new file mode 100644
index 00000000000..21f0f4b4fe6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ChromaMatteOperation_h
+#define _COM_ChromaMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ChromaMatteOperation : public NodeOperation {
+private:
+ NodeChroma *settings;
+ SocketReader *inputImageProgram;
+ SocketReader *inputKeyProgram;
+public:
+ /**
+ * Default constructor
+ */
+ ChromaMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma) {this->settings= nodeChroma;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
new file mode 100644
index 00000000000..317d84b0299
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorBalanceASCCDLOperation.h"
+#include "BLI_math.h"
+
+inline float colorbalance_cdl(float in, float offset, float power, float slope)
+{
+ float x = in * slope + offset;
+
+ /* prevent NaN */
+ CLAMP(x, 0.0, 1.0);
+
+ return powf(x, power);
+}
+
+ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputValueOperation = NULL;
+ this->inputColorOperation = NULL;
+ this->setResolutionInputSocketIndex(1);
+}
+
+void ColorBalanceASCCDLOperation::initExecution() {
+ this->inputValueOperation = this->getInputSocketReader(0);
+ this->inputColorOperation = this->getInputSocketReader(1);
+}
+
+void ColorBalanceASCCDLOperation::executePixel(float* outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ float value[4];
+
+ inputValueOperation->read(value, x, y, sampler, inputBuffers);
+ inputColorOperation->read(inputColor, x, y, sampler, inputBuffers);
+
+ float fac = value[0];
+ fac = min(1.0f, fac);
+ const float mfac= 1.0f - fac;
+
+ outputColor[0] = mfac*inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->lift[0], this->gamma[0], this->gain[0]);
+ outputColor[1] = mfac*inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->lift[1], this->gamma[1], this->gain[1]);
+ outputColor[2] = mfac*inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->lift[2], this->gamma[2], this->gain[2]);
+ outputColor[3] = inputColor[3];
+
+}
+
+void ColorBalanceASCCDLOperation::deinitExecution() {
+ this->inputValueOperation = NULL;
+ this->inputColorOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
new file mode 100644
index 00000000000..a7e9680c98d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorBalanceASCCDLOperation_h
+#define _COM_ColorBalanceASCCDLOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ColorBalanceASCCDLOperation : public NodeOperation {
+protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader * inputValueOperation;
+ SocketReader * inputColorOperation;
+
+ float gain[3];
+ float lift[3];
+ float gamma[3];
+
+public:
+ /**
+ * Default constructor
+ */
+ ColorBalanceASCCDLOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setGain(float gain[3]) {
+ this->gain[0] = gain[0];
+ this->gain[1] = gain[1];
+ this->gain[2] = gain[2];
+ }
+ void setLift(float lift[3]) {
+ this->lift[0] = lift[0];
+ this->lift[1] = lift[1];
+ this->lift[2] = lift[2];
+ }
+ void setGamma(float gamma[3]) {
+ this->gamma[0] = gamma[0];
+ this->gamma[1] = gamma[1];
+ this->gamma[2] = gamma[2];
+ }
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
new file mode 100644
index 00000000000..b853c28136f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorBalanceLGGOperation.h"
+#include "BLI_math.h"
+
+
+inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float gain)
+{
+ /* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
+ * but best keep it this way, sice testing for durian shows a similar calculation
+ * without lin/srgb conversions gives bad results (over-saturated shadows) with colors
+ * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+ float x= (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
+
+ /* prevent NaN */
+ if (x < 0.f) x = 0.f;
+
+ return powf(srgb_to_linearrgb(x), gamma_inv);
+}
+
+ColorBalanceLGGOperation::ColorBalanceLGGOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputValueOperation = NULL;
+ this->inputColorOperation = NULL;
+ this->setResolutionInputSocketIndex(1);
+}
+
+void ColorBalanceLGGOperation::initExecution() {
+ this->inputValueOperation = this->getInputSocketReader(0);
+ this->inputColorOperation = this->getInputSocketReader(1);
+}
+
+void ColorBalanceLGGOperation::executePixel(float* outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ float value[4];
+
+ inputValueOperation->read(value, x, y, sampler, inputBuffers);
+ inputColorOperation->read(inputColor, x, y, sampler, inputBuffers);
+
+ float fac = value[0];
+ fac = min(1.0f, fac);
+ const float mfac= 1.0f - fac;
+
+ outputColor[0] = mfac*inputColor[0] + fac * colorbalance_lgg(inputColor[0], this->lift[0], this->gamma_inv[0], this->gain[0]);
+ outputColor[1] = mfac*inputColor[1] + fac * colorbalance_lgg(inputColor[1], this->lift[1], this->gamma_inv[1], this->gain[1]);
+ outputColor[2] = mfac*inputColor[2] + fac * colorbalance_lgg(inputColor[2], this->lift[2], this->gamma_inv[2], this->gain[2]);
+ outputColor[3] = inputColor[3];
+
+}
+
+void ColorBalanceLGGOperation::deinitExecution() {
+ this->inputValueOperation = NULL;
+ this->inputColorOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
new file mode 100644
index 00000000000..ebaabfeb736
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorBalanceLGGOperation_h
+#define _COM_ColorBalanceLGGOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ColorBalanceLGGOperation : public NodeOperation {
+protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader * inputValueOperation;
+ SocketReader * inputColorOperation;
+
+ float gain[3];
+ float lift[3];
+ float gamma_inv[3];
+
+public:
+ /**
+ * Default constructor
+ */
+ ColorBalanceLGGOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setGain(float gain[3]) {
+ this->gain[0] = gain[0];
+ this->gain[1] = gain[1];
+ this->gain[2] = gain[2];
+ }
+ void setLift(float lift[3]) {
+ this->lift[0] = lift[0];
+ this->lift[1] = lift[1];
+ this->lift[2] = lift[2];
+ }
+ void setGammaInv(float gamma_inv[3]) {
+ this->gamma_inv[0] = gamma_inv[0];
+ this->gamma_inv[1] = gamma_inv[1];
+ this->gamma_inv[2] = gamma_inv[2];
+ }
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
new file mode 100644
index 00000000000..fef045481f7
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorCorrectionOperation.h"
+#include "BLI_math.h"
+
+ColorCorrectionOperation::ColorCorrectionOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputImage = NULL;
+ this->inputMask = NULL;
+ this->redChannelEnabled = true;
+ this->greenChannelEnabled = true;
+ this->blueChannelEnabled = true;
+}
+void ColorCorrectionOperation::initExecution() {
+ this->inputImage = this->getInputSocketReader(0);
+ this->inputMask = this->getInputSocketReader(1);
+}
+
+void ColorCorrectionOperation::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputImageColor[4];
+ float inputMask[4];
+ this->inputImage->read(inputImageColor, x, y, sampler, inputBuffers);
+ this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
+
+ float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2])/3.0f;
+ float contrast= this->data->master.contrast;
+ float saturation = this->data->master.saturation;
+ float gamma = this->data->master.gamma;
+ float gain = this->data->master.gain;
+ float lift = this->data->master.lift;
+ float r, g, b;
+
+ float value = inputMask[0];
+ value = min(1.0f, value);
+ const float mvalue= 1.0f - value;
+
+ float levelShadows = 0.0;
+ float levelMidtones = 0.0;
+ float levelHighlights = 0.0;
+#define MARGIN 0.10
+#define MARGIN_DIV (0.5/MARGIN)
+ if ( level < this->data->startmidtones-MARGIN) {
+ levelShadows = 1.0f;
+ } else if (level < this->data->startmidtones+MARGIN) {
+ levelMidtones = ((level-this->data->startmidtones)*MARGIN_DIV)+0.5;
+ levelShadows = 1.0- levelMidtones;
+ } else if (level < this->data->endmidtones-MARGIN) {
+ levelMidtones = 1.0f;
+ } else if (level < this->data->endmidtones+MARGIN) {
+ levelHighlights = ((level-this->data->endmidtones)*MARGIN_DIV)+0.5;
+ levelMidtones = 1.0- levelHighlights;
+ } else {
+ levelHighlights = 1.0f;
+ }
+#undef MARGIN
+#undef MARGIN_DIV
+ contrast *= (levelShadows*this->data->shadows.contrast)+(levelMidtones*this->data->midtones.contrast)+(levelHighlights*this->data->highlights.contrast);
+ saturation *= (levelShadows*this->data->shadows.saturation)+(levelMidtones*this->data->midtones.saturation)+(levelHighlights*this->data->highlights.saturation);
+ gamma *= (levelShadows*this->data->shadows.gamma)+(levelMidtones*this->data->midtones.gamma)+(levelHighlights*this->data->highlights.gamma);
+ gain *= (levelShadows*this->data->shadows.gain)+(levelMidtones*this->data->midtones.gain)+(levelHighlights*this->data->highlights.gain);
+ lift += (levelShadows*this->data->shadows.lift)+(levelMidtones*this->data->midtones.lift)+(levelHighlights*this->data->highlights.lift);
+
+ r = inputImageColor[0];
+ g = inputImageColor[1];
+ b = inputImageColor[2];
+
+ float invgamma = 1.0f/gamma;
+ float luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
+ r = ( luma + saturation * (r - luma));
+ g = ( luma + saturation * (g - luma));
+ b = ( luma + saturation * (b - luma));
+ CLAMP (r, 0.0f, 1.0f);
+ CLAMP (g, 0.0f, 1.0f);
+ CLAMP (b, 0.0f, 1.0f);
+
+ r = 0.5+((r-0.5)*contrast);
+ g = 0.5+((g-0.5)*contrast);
+ b = 0.5+((b-0.5)*contrast);
+
+ r = powf(r*gain+lift, invgamma);
+ g = powf(g*gain+lift, invgamma);
+ b = powf(b*gain+lift, invgamma);
+
+
+ // mix with mask
+ r = mvalue*inputImageColor[0] + value * r;
+ g = mvalue*inputImageColor[1] + value * g;
+ b = mvalue*inputImageColor[2] + value * b;
+
+ if (this->redChannelEnabled) {
+ output[0] = r;
+ } else {
+ output[0] = inputImageColor[0];
+ }
+ if (this->greenChannelEnabled) {
+ output[1] = g;
+ } else {
+ output[1] = inputImageColor[1];
+ }
+ if (this->blueChannelEnabled) {
+ output[2] = b;
+ } else {
+ output[2] = inputImageColor[2];
+ }
+ output[3] = inputImageColor[3];
+}
+
+void ColorCorrectionOperation::deinitExecution() {
+ this->inputImage = NULL;
+ this->inputMask = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
new file mode 100644
index 00000000000..9a3eefe30c6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorCorrectionOperation_h
+#define _COM_ColorCorrectionOperation_h
+#include "COM_NodeOperation.h"
+
+
+class ColorCorrectionOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputImage;
+ SocketReader* inputMask;
+ NodeColorCorrection *data;
+
+ bool redChannelEnabled;
+ bool greenChannelEnabled;
+ bool blueChannelEnabled;
+
+public:
+ ColorCorrectionOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeColorCorrection * data) {this->data = data;}
+ void setRedChannelEnabled(bool enabled) {this->redChannelEnabled = enabled;}
+ void setGreenChannelEnabled(bool enabled) {this->greenChannelEnabled = enabled;}
+ void setBlueChannelEnabled(bool enabled) {this->blueChannelEnabled = enabled;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
new file mode 100644
index 00000000000..cb16b99f06b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorCurveOperation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "BKE_colortools.h"
+#ifdef __cplusplus
+}
+#endif
+
+ColorCurveOperation::ColorCurveOperation(): CurveBaseOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputFacProgram = NULL;
+ this->inputImageProgram = NULL;
+ this->inputBlackProgram = NULL;
+ this->inputWhiteProgram = NULL;
+
+ this->setResolutionInputSocketIndex(1);
+}
+void ColorCurveOperation::initExecution() {
+ CurveBaseOperation::initExecution();
+ this->inputFacProgram = this->getInputSocketReader(0);
+ this->inputImageProgram = this->getInputSocketReader(1);
+ this->inputBlackProgram = this->getInputSocketReader(2);
+ this->inputWhiteProgram = this->getInputSocketReader(3);
+
+ curvemapping_premultiply(this->curveMapping, 0);
+
+}
+
+void ColorCurveOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float black[4];
+ float white[4];
+ float fac[4];
+ float image[4];
+
+ this->inputBlackProgram->read(black, x, y, sampler, inputBuffers);
+ this->inputWhiteProgram->read(white, x, y, sampler, inputBuffers);
+
+ curvemapping_set_black_white(this->curveMapping, black, white);
+
+ this->inputFacProgram->read(fac, x, y, sampler, inputBuffers);
+ this->inputImageProgram->read(image, x, y, sampler, inputBuffers);
+
+ if(fac[0]>=1.0)
+ curvemapping_evaluate_premulRGBF(this->curveMapping, color, image);
+ else if(*fac<=0.0) {
+ color[0]= image[0];
+ color[1]= image[1];
+ color[2]= image[2];
+ }
+ else {
+ float col[4], mfac= 1.0f-*fac;
+ curvemapping_evaluate_premulRGBF(this->curveMapping, col, image);
+ color[0]= mfac*image[0] + *fac*col[0];
+ color[1]= mfac*image[1] + *fac*col[1];
+ color[2]= mfac*image[2] + *fac*col[2];
+ }
+ color[3]= image[3];
+}
+
+void ColorCurveOperation::deinitExecution() {
+ this->inputFacProgram = NULL;
+ this->inputImageProgram = NULL;
+ this->inputBlackProgram = NULL;
+ this->inputWhiteProgram = NULL;
+ curvemapping_premultiply(this->curveMapping, 1);
+}
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
new file mode 100644
index 00000000000..986f6fcfcc2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorCurveOperation_h
+#define _COM_ColorCurveOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_color_types.h"
+#include "COM_CurveBaseOperation.h"
+
+class ColorCurveOperation : public CurveBaseOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputFacProgram;
+ SocketReader * inputImageProgram;
+ SocketReader * inputBlackProgram;
+ SocketReader * inputWhiteProgram;
+public:
+ ColorCurveOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
new file mode 100644
index 00000000000..a80788ddd33
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ColorMatteOperation.h"
+#include "BLI_math.h"
+
+ColorMatteOperation::ColorMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImageProgram = NULL;
+ inputKeyProgram = NULL;
+}
+
+void ColorMatteOperation::initExecution() {
+ this->inputImageProgram = this->getInputSocketReader(0);
+ this->inputKeyProgram = this->getInputSocketReader(1);
+}
+
+void ColorMatteOperation::deinitExecution() {
+ this->inputImageProgram= NULL;
+ this->inputKeyProgram= NULL;
+}
+
+void ColorMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inColor[4];
+ float inKey[4];
+
+ const float hue=this->settings->t1;
+ const float sat=this->settings->t2;
+ const float val=this->settings->t3;
+
+ float h_wrap;
+
+ this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers);
+ this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers);
+
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ if(
+ /* do hue last because it needs to wrap, and does some more checks */
+
+ /* sat */ (fabsf(inColor[1]-inKey[1]) < sat) &&
+ /* val */ (fabsf(inColor[2]-inKey[2]) < val) &&
+
+ /* multiply by 2 because it wraps on both sides of the hue,
+ * otherwise 0.5 would key all hue's */
+
+ /* hue */ ((h_wrap= 2.f * fabsf(inColor[0]-inKey[0])) < hue || (2.f - h_wrap) < hue)
+ ) {
+ outputValue[0]=0.f; /*make transparent*/
+ }
+
+ else { /*pixel is outside key color */
+ outputValue[0]=inColor[3]; /* make pixel just as transparent as it was before */
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
new file mode 100644
index 00000000000..954a5bbb3e8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ColorMatteOperation_h
+#define _COM_ColorMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ColorMatteOperation : public NodeOperation {
+private:
+ NodeChroma *settings;
+ SocketReader *inputImageProgram;
+ SocketReader *inputKeyProgram;
+public:
+ /**
+ * Default constructor
+ */
+ ColorMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma) {this->settings= nodeChroma;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
new file mode 100644
index 00000000000..a7cfb30b439
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorRampOperation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "BKE_texture.h"
+#ifdef __cplusplus
+}
+#endif
+
+ColorRampOperation::ColorRampOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputProgram = NULL;
+ this->colorBand = NULL;
+}
+void ColorRampOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void ColorRampOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float values[4];
+
+ this->inputProgram->read(values, x, y, sampler, inputBuffers);
+ do_colorband(this->colorBand, values[0], color);
+}
+
+void ColorRampOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
new file mode 100644
index 00000000000..08a6c26a8bf
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorRampOperation_h
+#define _COM_ColorRampOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_texture_types.h"
+
+class ColorRampOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+ ColorBand* colorBand;
+public:
+ ColorRampOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setColorBand(ColorBand* colorBand) {this->colorBand = colorBand;}
+
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
new file mode 100644
index 00000000000..9f054540332
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This Reader is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This Reader is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this Reader; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ColorSpillOperation.h"
+#include "BLI_math.h"
+#define avg(a,b) ((a+b)/2)
+
+ColorSpillOperation::ColorSpillOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_VALUE);
+ addOutputSocket(COM_DT_COLOR);
+
+ inputImageReader = NULL;
+ inputFacReader = NULL;
+ this->spillChannel = 1; // GREEN
+}
+
+void ColorSpillOperation::initExecution() {
+ this->inputImageReader = this->getInputSocketReader(0);
+ this->inputFacReader = this->getInputSocketReader(1);
+ if (spillChannel == 0) {
+ rmut = -1.0f;
+ gmut = 1.0f;
+ bmut = 1.0f;
+ this->channel2 = 1;
+ this->channel3 = 2;
+ if (settings->unspill == 0) {
+ settings->uspillr = 1.0f;
+ settings->uspillg = 0.0f;
+ settings->uspillb = 0.0f;
+ }
+ } else if (spillChannel == 1) {
+ rmut = 1.0f;
+ gmut = -1.0f;
+ bmut = 1.0f;
+ this->channel2 = 0;
+ this->channel3 = 2;
+ if (settings->unspill == 0) {
+ settings->uspillr = 0.0f;
+ settings->uspillg = 1.0f;
+ settings->uspillb = 0.0f;
+ }
+ } else {
+ rmut = 1.0f;
+ gmut = 1.0f;
+ bmut = -1.0f;
+
+ this->channel2 = 0;
+ this->channel3 = 1;
+ if (settings->unspill == 0) {
+ settings->uspillr = 0.0f;
+ settings->uspillg = 0.0f;
+ settings->uspillb = 1.0f;
+ }
+ }
+}
+
+void ColorSpillOperation::deinitExecution() {
+ this->inputImageReader= NULL;
+ this->inputFacReader = NULL;
+}
+
+void ColorSpillOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float fac[4];
+ float input[4];
+ float map;
+ this->inputFacReader->read(fac, x, y, sampler, inputBuffers);
+ this->inputImageReader->read(input, x, y, sampler, inputBuffers);
+ float rfac = min(1.0f, fac[0]);
+ map = calculateMapValue(rfac, input);
+ if(map>0) {
+ outputValue[0]=input[0]+rmut*(settings->uspillr*map);
+ outputValue[1]=input[1]+gmut*(settings->uspillg*map);
+ outputValue[2]=input[2]+bmut*(settings->uspillb*map);
+ outputValue[3]=input[3];
+ }
+ else {
+ outputValue[0]=input[0];
+ outputValue[1]=input[1];
+ outputValue[2]=input[2];
+ outputValue[3]=input[3];
+ }
+}
+float ColorSpillOperation::calculateMapValue(float fac, float *input) {
+ return fac * (input[this->spillChannel]-(this->settings->limscale*input[settings->limchan]));
+}
+
+
+float ColorSpillAverageOperation::calculateMapValue(float fac, float *input) {
+ return fac * (input[this->spillChannel]-(this->settings->limscale*avg(input[this->channel2], input[this->channel3])));
+}
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h
new file mode 100644
index 00000000000..963eaae3076
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ColorSpillOperation_h
+#define _COM_ColorSpillOperation_h
+#include "COM_NodeOperation.h"
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ColorSpillOperation : public NodeOperation {
+protected:
+ NodeColorspill *settings;
+ SocketReader *inputImageReader;
+ SocketReader *inputFacReader;
+ int spillChannel;
+ int channel2;
+ int channel3;
+ float rmut, gmut, bmut;
+public:
+ /**
+ * Default constructor
+ */
+ ColorSpillOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeColorspill* nodeColorSpill) {this->settings= nodeColorSpill;}
+ void setSpillChannel(int channel) {this->spillChannel = channel;}
+
+ float calculateMapValue(float fac, float *input);
+};
+
+class ColorSpillAverageOperation: public ColorSpillOperation {
+public:
+ float calculateMapValue(float fac, float *input);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp
new file mode 100644
index 00000000000..efeac9db410
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CombineChannelsOperation.h"
+#include <stdio.h>
+
+CombineChannelsOperation::CombineChannelsOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputChannel1Operation = NULL;
+ this->inputChannel2Operation = NULL;
+ this->inputChannel3Operation = NULL;
+ this->inputChannel4Operation = NULL;
+}
+void CombineChannelsOperation::initExecution() {
+ this->inputChannel1Operation = this->getInputSocketReader(0);
+ this->inputChannel2Operation = this->getInputSocketReader(1);
+ this->inputChannel3Operation = this->getInputSocketReader(2);
+ this->inputChannel4Operation = this->getInputSocketReader(3);
+}
+
+void CombineChannelsOperation::deinitExecution() {
+ this->inputChannel1Operation = NULL;
+ this->inputChannel2Operation = NULL;
+ this->inputChannel3Operation = NULL;
+ this->inputChannel4Operation = NULL;
+}
+
+
+void CombineChannelsOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input[4];
+ /// @todo: remove if statements
+ if (this->inputChannel1Operation) {
+ this->inputChannel1Operation->read(input, x, y, sampler, inputBuffers);
+ color[0] = input[0];
+ }
+ if (this->inputChannel2Operation) {
+ this->inputChannel2Operation->read(input, x, y, sampler, inputBuffers);
+ color[1] = input[0];
+ }
+ if (this->inputChannel3Operation) {
+ this->inputChannel3Operation->read(input, x, y, sampler, inputBuffers);
+ color[2] = input[0];
+ }
+ if (this->inputChannel4Operation) {
+ this->inputChannel4Operation->read(input, x, y, sampler, inputBuffers);
+ color[3] = input[0];
+ }
+}
diff --git a/source/blender/compositor/operations/COM_CombineChannelsOperation.h b/source/blender/compositor/operations/COM_CombineChannelsOperation.h
new file mode 100644
index 00000000000..18dd1fd2ec9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CombineChannelsOperation.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CombineChannelsOperation_h_
+#define _COM_CombineChannelsOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class CombineChannelsOperation: public NodeOperation {
+private:
+ SocketReader *inputChannel1Operation;
+ SocketReader *inputChannel2Operation;
+ SocketReader *inputChannel3Operation;
+ SocketReader *inputChannel4Operation;
+public:
+ CombineChannelsOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
new file mode 100644
index 00000000000..7590b4be299
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CompositorOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+ #include "MEM_guardedalloc.h"
+#include "render_types.h"
+}
+#include "PIL_time.h"
+
+
+CompositorOperation::CompositorOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+
+ this->setScene(NULL);
+ this->outputBuffer = NULL;
+ this->imageInput = NULL;
+ this->alphaInput = NULL;
+}
+
+void CompositorOperation::initExecution() {
+ // When initializing the tree during initial load the width and height can be zero.
+ this->imageInput = getInputSocketReader(0);
+ this->alphaInput = getInputSocketReader(1);
+ if (this->getWidth() * this->getHeight() != 0) {
+ this->outputBuffer=(float*) MEM_callocN(this->getWidth()*this->getHeight()*4*sizeof(float), "CompositorOperation");
+ }
+ const Scene * scene = this->scene;
+ Render* re= RE_GetRender(scene->id.name);
+ RenderResult *rr= RE_AcquireResultWrite(re);
+ if(rr) {
+ if(rr->rectf != NULL) {
+ MEM_freeN(rr->rectf);
+ }
+ rr->rectf= outputBuffer;
+ }
+ if (re) {
+ RE_ReleaseResult(re);
+ re = NULL;
+ }
+
+}
+
+void CompositorOperation::deinitExecution() {
+ this->outputBuffer = NULL;
+ this->imageInput = NULL;
+ this->alphaInput = NULL;
+}
+
+
+void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) {
+ float color[8]; // 7 is enough
+ float* buffer = this->outputBuffer;
+
+ if (!buffer) return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1*this->getWidth() + x1 ) * 4;
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1 ; y < y2 && (!breaked); y++) {
+ for (x = x1 ; x < x2 && (!breaked) ; x++) {
+ imageInput->read(color, x, y, COM_PS_NEAREST, memoryBuffers);
+ if (alphaInput != NULL) {
+ alphaInput->read(&(color[3]), x, y, COM_PS_NEAREST, memoryBuffers);
+ }
+ buffer[offset] = color[0];
+ buffer[offset+1] = color[1];
+ buffer[offset+2] = color[2];
+ buffer[offset+3] = color[3];
+ offset +=4;
+ if (tree->test_break && tree->test_break(tree->tbh)) {
+ breaked = true;
+ }
+ }
+ offset += (this->getWidth()-(x2-x1))*4;
+ }
+}
+
+void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ int width = this->scene->r.xsch*this->scene->r.size/100;
+ int height= this->scene->r.ysch*this->scene->r.size/100;
+ preferredResolution[0] = width;
+ preferredResolution[1] = height;
+
+ NodeOperation::determineResolution(resolution, preferredResolution);
+
+ resolution[0] = width;
+ resolution[1] = height;
+}
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
new file mode 100644
index 00000000000..6f71fdff7b4
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CompositorOperation_h
+#define _COM_CompositorOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "BLI_rect.h"
+
+/**
+ * @brief Compositor output operation
+ */
+class CompositorOperation : public NodeOperation {
+private:
+ /**
+ * @brief local reference to the scene
+ */
+ const Scene* scene;
+
+ /**
+ * @brief local reference to the node tree
+ */
+ const bNodeTree* tree;
+
+ /**
+ * @brief reference to the output float buffer
+ */
+ float *outputBuffer;
+
+ /**
+ * @brief local reference to the input image operation
+ */
+ SocketReader* imageInput;
+
+ /**
+ * @brief local reference to the input alpha operation
+ */
+ SocketReader* alphaInput;
+public:
+ CompositorOperation();
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void setScene(const Scene* scene) {this->scene = scene;}
+ void setbNodeTree(const bNodeTree* tree) {this->tree= tree;}
+ bool isOutputOperation(bool rendering) const {return rendering;}
+ void initExecution();
+ void deinitExecution();
+ const int getRenderPriority() const {return 7;}
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
new file mode 100644
index 00000000000..3267994feea
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertColorProfileOperation.h"
+
+extern "C" {
+ #include "IMB_imbuf.h"
+}
+ConvertColorProfileOperation::ConvertColorProfileOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+ this->predivided = false;
+}
+
+void ConvertColorProfileOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertColorProfileOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float color[4];
+ inputOperation->read(color, x, y, sampler, inputBuffers);
+ IMB_buffer_float_from_float(outputValue, color, 4, this->toProfile, this->fromProfile, this->predivided, 1, 1, 0, 0);
+}
+
+void ConvertColorProfileOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
new file mode 100644
index 00000000000..9781795b952
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertColorProfileOperation_h
+#define _COM_ConvertColorProfileOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertColorProfileOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+
+ /**
+ * @brief color profile where to convert from
+ */
+ int fromProfile;
+
+ /**
+ * @brief color profile where to convert to
+ */
+ int toProfile;
+
+ /**
+ * @brief is color predivided
+ */
+ bool predivided;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertColorProfileOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setFromColorProfile(int colorProfile) {this->fromProfile = colorProfile;}
+ void setToColorProfile(int colorProfile) {this->toProfile = colorProfile;}
+ void setPredivided(bool predivided) {this->predivided = predivided;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
new file mode 100644
index 00000000000..8c48c5c0d14
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertColorToBWOperation.h"
+
+ConvertColorToBWOperation::ConvertColorToBWOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+}
+
+void ConvertColorToBWOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertColorToBWOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
+ outputValue[0] = (inputColor[0]*0.35f + inputColor[1]*0.45f + inputColor[2]*0.2f)*inputColor[3];
+}
+
+void ConvertColorToBWOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h
new file mode 100644
index 00000000000..82d71453e1e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertColorToBWOperation_h
+#define _COM_ConvertColorToBWOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertColorToBWOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertColorToBWOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp
new file mode 100644
index 00000000000..af86f3ea5e8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertColorToVectorOperation.h"
+
+ConvertColorToVectorOperation::ConvertColorToVectorOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VECTOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertColorToVectorOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertColorToVectorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ inputOperation->read(outputValue, x, y, sampler, inputBuffers);
+}
+
+void ConvertColorToVectorOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h
new file mode 100644
index 00000000000..de7315da02f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertColorToVectorOperation_h
+#define _COM_ConvertColorToVectorOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertColorToVectorOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertColorToVectorOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp
new file mode 100644
index 00000000000..caf41419668
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertColourToValueProg.h"
+
+ConvertColourToValueProg::ConvertColourToValueProg(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+}
+
+void ConvertColourToValueProg::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertColourToValueProg::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers);
+ outputValue[0] = ((inputColor[0] + inputColor[1] + inputColor[2])/3.0f)*inputColor[3];
+}
+
+void ConvertColourToValueProg::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h
new file mode 100644
index 00000000000..73e71b5665a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertColourToValueProg.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertColourToValueProg_h
+#define _COM_ConvertColourToValueProg_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertColourToValueProg : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertColourToValueProg();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
new file mode 100644
index 00000000000..345fc37b340
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertDepthToRadiusOperation.h"
+#include "BLI_math.h"
+#include "DNA_camera_types.h"
+
+ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+ this->fStop = 128.0f;
+ this->cameraObject = NULL;
+ this->maxRadius = 32.0f;
+}
+
+float ConvertDepthToRadiusOperation::determineFocalDistance() {
+
+ if (cameraObject == NULL || cameraObject->type != OB_CAMERA) {
+ return 10.0f;
+ } else {
+ Camera *camera= (Camera*)this->cameraObject->data;
+ cam_lens = camera->lens;
+ if (camera->dof_ob) {
+ /* too simple, better to return the distance on the view axis only
+ * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
+ float mat[4][4], imat[4][4], obmat[4][4];
+
+ copy_m4_m4(obmat, cameraObject->obmat);
+ normalize_m4(obmat);
+ invert_m4_m4(imat, obmat);
+ mult_m4_m4m4(mat, imat, camera->dof_ob->obmat);
+ return (float)fabs(mat[3][2]);
+ }
+ return camera->YF_dofdist;
+ }
+}
+
+void ConvertDepthToRadiusOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ float focalDistance = determineFocalDistance();
+ if (focalDistance==0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it be be far away */
+ inverseFocalDistance = 1.f/focalDistance;
+ this->aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight());
+ this->aperture = 0.5f*(this->cam_lens / (this->aspect*32.f)) / this->fStop;
+ float minsz = MIN2(getWidth(), getHeight());
+ this->dof_sp = (float)minsz / (16.f / cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
+}
+
+void ConvertDepthToRadiusOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float z;
+ float radius;
+ inputOperation->read(inputValue, x, y, sampler, inputBuffers);
+ z = inputValue[0];
+ if (z!=0.f) {
+ float iZ = (1.f/z);
+
+ // bug #6656 part 2b, do not rescale
+ /*
+ bcrad = 0.5f*fabs(aperture*(dof_sp*(cam_invfdist - iZ) - 1.f));
+ // scale crad back to original maximum and blend
+ crad->rect[px] = bcrad + wts->rect[px]*(scf*crad->rect[px] - bcrad);
+ */
+ radius = 0.5f*fabsf(this->aperture*(dof_sp*(inverseFocalDistance - iZ) - 1.f));
+ // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
+ if (radius < 0.5f) radius = 0.5f;
+ if (radius > maxRadius) {
+ radius = maxRadius;
+ }
+ outputValue[0] = radius;
+ }
+ else outputValue[0] = 0.0f;
+}
+
+void ConvertDepthToRadiusOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
new file mode 100644
index 00000000000..80a56122565
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertDepthToRadiusOperation_h
+#define _COM_ConvertDepthToRadiusOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_object_types.h"
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertDepthToRadiusOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+ float fStop;
+ float aspect;
+ float maxRadius;
+ float inverseFocalDistance;
+ float aperture;
+ float cam_lens;
+ float dof_sp;
+ Object *cameraObject;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertDepthToRadiusOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setfStop(float fStop) {this->fStop = fStop;}
+ void setMaxRadius(float maxRadius) {this->maxRadius = maxRadius;}
+ void setCameraObject(Object* camera) {this->cameraObject = camera;}
+ float determineFocalDistance();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp
new file mode 100644
index 00000000000..8de98fef28b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertHSVToRGBOperation.h"
+#include "BLI_math_color.h"
+
+ConvertHSVToRGBOperation::ConvertHSVToRGBOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertHSVToRGBOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertHSVToRGBOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+ hsv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]);
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertHSVToRGBOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h
new file mode 100644
index 00000000000..f2f61250aad
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertHSVToRGBOperation_h
+#define _COM_ConvertHSVToRGBOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertHSVToRGBOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertHSVToRGBOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
new file mode 100644
index 00000000000..509093f4d5f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertKeyToPremulOperation.h"
+#include "BLI_math.h"
+
+ConvertKeyToPremulOperation::ConvertKeyToPremulOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputColor = NULL;
+}
+
+void ConvertKeyToPremulOperation::initExecution() {
+ this->inputColor = getInputSocketReader(0);
+}
+
+void ConvertKeyToPremulOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float alpha;
+
+ this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
+ alpha = inputValue[3];
+
+ outputValue[0] = inputValue[0] * alpha;
+ outputValue[1] = inputValue[1] * alpha;
+ outputValue[2] = inputValue[2] * alpha;
+
+ /* never touches the alpha */
+ outputValue[3] = alpha;
+}
+
+void ConvertKeyToPremulOperation::deinitExecution() {
+ this->inputColor = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
new file mode 100644
index 00000000000..15195b37f49
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertKeyToPremulOperation_h
+#define _COM_ConvertKeyToPremulOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertKeyToPremulOperation : public NodeOperation {
+private:
+ SocketReader *inputColor;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertKeyToPremulOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
new file mode 100644
index 00000000000..6f676b1c404
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertPremulToKeyOperation.h"
+#include "BLI_math.h"
+
+ConvertPremulToKeyOperation::ConvertPremulToKeyOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputColor = NULL;
+}
+
+void ConvertPremulToKeyOperation::initExecution() {
+ this->inputColor = getInputSocketReader(0);
+}
+
+void ConvertPremulToKeyOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float alpha;
+
+ this->inputColor->read(inputValue, x, y, sampler, inputBuffers);
+ alpha = inputValue[3];
+
+ if(fabsf(alpha) < 1e-5f) {
+ outputValue[0]= 0.f;
+ outputValue[1]= 0.f;
+ outputValue[2]= 0.f;
+ }
+ else {
+ outputValue[0] = inputValue[0] / alpha;
+ outputValue[1] = inputValue[1] / alpha;
+ outputValue[2] = inputValue[2] / alpha;
+ }
+
+ /* never touches the alpha */
+ outputValue[3] = alpha;
+}
+
+void ConvertPremulToKeyOperation::deinitExecution() {
+ this->inputColor = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h
new file mode 100644
index 00000000000..431dcfe5742
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertPremulToKeyOperation_h
+#define _COM_ConvertPremulToKeyOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertPremulToKeyOperation : public NodeOperation {
+private:
+ SocketReader *inputColor;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertPremulToKeyOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp
new file mode 100644
index 00000000000..b8208a864ff
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertRGBToHSVOperation.h"
+#include "BLI_math_color.h"
+
+ConvertRGBToHSVOperation::ConvertRGBToHSVOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertRGBToHSVOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertRGBToHSVOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+ rgb_to_hsv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]);
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertRGBToHSVOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h
new file mode 100644
index 00000000000..a36092640e8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertRGBToHSVOperation_h
+#define _COM_ConvertRGBToHSVOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertRGBToHSVOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertRGBToHSVOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
new file mode 100644
index 00000000000..623376d532f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertRGBToYCCOperation.h"
+#include "BLI_math_color.h"
+
+ConvertRGBToYCCOperation::ConvertRGBToYCCOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertRGBToYCCOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertRGBToYCCOperation::setMode(int mode) {
+ switch(mode)
+ {
+ case 1:
+ this->mode = BLI_YCC_ITU_BT709;
+ break;
+ case 2:
+ this->mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 0:
+ default:
+ this->mode = BLI_YCC_ITU_BT601;
+ break;
+ }
+}
+
+void ConvertRGBToYCCOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ float color[3];
+
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+ rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->mode);
+
+ /* divided by 255 to normalize for viewing in */
+ outputValue[0] = color[0]/255.f; /* Y */
+ outputValue[1] = color[1]/255.f; /* Cb*/
+ outputValue[2] = color[2]/255.f; /* Cr*/
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertRGBToYCCOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h
new file mode 100644
index 00000000000..76825061c19
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertRGBToYCCOperation_h
+#define _COM_ConvertRGBToYCCOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertRGBToYCCOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+
+ /**
+ * YCbCr mode (Jpeg, ITU601, ITU709)
+ */
+ int mode;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertRGBToYCCOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ /**
+ * Set the YCC mode
+ */
+ void setMode(int mode);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp
new file mode 100644
index 00000000000..c8ab3dd5a4b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.cpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertRGBToYUVOperation.h"
+#include "BLI_math_color.h"
+
+ConvertRGBToYUVOperation::ConvertRGBToYUVOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertRGBToYUVOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertRGBToYUVOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+ rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]);
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertRGBToYUVOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h
new file mode 100644
index 00000000000..aba759b6b97
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertRGBToYUVOperation_h
+#define _COM_ConvertRGBToYUVOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertRGBToYUVOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertRGBToYUVOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp
new file mode 100644
index 00000000000..622163739d6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertValueToColourProg.h"
+
+ConvertValueToColourProg::ConvertValueToColourProg(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+}
+void ConvertValueToColourProg::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void ConvertValueToColourProg::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ this->inputProgram->read(inputValue, x, y, sampler, inputBuffers);
+ color[0] = inputValue[0];
+ color[1] = inputValue[0];
+ color[2] = inputValue[0];
+ color[3] = 1.0f;
+}
+
+void ConvertValueToColourProg::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h
new file mode 100644
index 00000000000..25643a74f35
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertValueToColourProg.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertValueToColourProg_h
+#define _COM_ConvertValueToColourProg_h
+#include "COM_NodeOperation.h"
+
+
+class ConvertValueToColourProg : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputProgram;
+public:
+ ConvertValueToColourProg();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp
new file mode 100644
index 00000000000..c675ea16fdb
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertValueToVectorOperation.h"
+
+ConvertValueToVectorOperation::ConvertValueToVectorOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VECTOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertValueToVectorOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertValueToVectorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input[4];
+ inputOperation->read(input, x, y, sampler, inputBuffers);
+ outputValue[0] = input[0];
+ outputValue[1] = input[0];
+ outputValue[2] = input[0];
+ outputValue[3] = 0.0f;
+}
+
+void ConvertValueToVectorOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h
new file mode 100644
index 00000000000..0824bb0e4fe
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertValueToVectorOperation_h
+#define _COM_ConvertValueToVectorOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertValueToVectorOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertValueToVectorOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp
new file mode 100644
index 00000000000..517fc56e93e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertVectorToColorOperation.h"
+
+ConvertVectorToColorOperation::ConvertVectorToColorOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertVectorToColorOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertVectorToColorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ inputOperation->read(outputValue, x, y, sampler, inputBuffers);
+ outputValue[3] = 1.0f;
+}
+
+void ConvertVectorToColorOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h
new file mode 100644
index 00000000000..4ebaf5b9230
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertVectorToColorOperation_h
+#define _COM_ConvertVectorToColorOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertVectorToColorOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertVectorToColorOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp
new file mode 100644
index 00000000000..a57cd229e1f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvertVectorToValueOperation.h"
+
+ConvertVectorToValueOperation::ConvertVectorToValueOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+}
+
+void ConvertVectorToValueOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertVectorToValueOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input[4];
+ inputOperation->read(input, x, y, sampler, inputBuffers);
+ outputValue[0] = (input[0]+input[1]+input[2])/3.0f;
+}
+
+void ConvertVectorToValueOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h
new file mode 100644
index 00000000000..ede7853f57e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvertVectorToValueOperation_h
+#define _COM_ConvertVectorToValueOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertVectorToValueOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertVectorToValueOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
new file mode 100644
index 00000000000..1d8ee944915
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertYCCToRGBOperation.h"
+#include "BLI_math_color.h"
+
+ConvertYCCToRGBOperation::ConvertYCCToRGBOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertYCCToRGBOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertYCCToRGBOperation::setMode(int mode) {
+ switch(mode)
+ {
+ case 1:
+ this->mode = BLI_YCC_ITU_BT709;
+ break;
+ case 2:
+ this->mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 0:
+ default:
+ this->mode = BLI_YCC_ITU_BT601;
+ break;
+ }
+}
+
+void ConvertYCCToRGBOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+
+ /* need to un-normalize the data */
+ inputColor[0] *= 255.f; /* Y */
+ inputColor[1] *= 255.f; /* Cb*/
+ inputColor[2] *= 255.f; /* Cr*/
+
+ ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2], this->mode);
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertYCCToRGBOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h
new file mode 100644
index 00000000000..c3702de3b48
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertYCCToRGBOperation_h
+#define _COM_ConvertYCCToRGBOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertYCCToRGBOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+
+ /**
+ * YCbCr mode (Jpeg, ITU601, ITU709)
+ */
+ int mode;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertYCCToRGBOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ /**
+ * Set the YCC mode
+ */
+ void setMode(int mode);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp
new file mode 100644
index 00000000000..a807030cb8a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_ConvertYUVToRGBOperation.h"
+#include "BLI_math_color.h"
+
+ConvertYUVToRGBOperation::ConvertYUVToRGBOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void ConvertYUVToRGBOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void ConvertYUVToRGBOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ inputOperation->read(inputColor, x, y, sampler, inputBuffers);
+ yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &outputValue[0], &outputValue[1], &outputValue[2]);
+ outputValue[3] = inputColor[3];
+}
+
+void ConvertYUVToRGBOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h
new file mode 100644
index 00000000000..6d82d36fe5c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_ConvertYUVToRGBOperation_h
+#define _COM_ConvertYUVToRGBOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ConvertYUVToRGBOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+public:
+ /**
+ * Default constructor
+ */
+ ConvertYUVToRGBOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
new file mode 100644
index 00000000000..6505e1be83e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvolutionEdgeFilterOperation.h"
+#include "BLI_math.h"
+
+ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation() {
+}
+inline void addFilter(float* result, float*input, float value) {
+ result[0] += input[0] * value;
+ result[1] += input[1] * value;
+ result[2] += input[2] * value;
+}
+
+void ConvolutionEdgeFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float in1[4],in2[4], res1[4], res2[4];
+
+ float value[4];
+ this->inputValueOperation->read(value, x, y, inputBuffers, NULL);
+ float mval = 1.0f - value[0];
+
+ res1[0] = 0.0f;
+ res1[1] = 0.0f;
+ res1[2] = 0.0f;
+ res1[3] = 0.0f;
+ res2[0] = 0.0f;
+ res2[1] = 0.0f;
+ res2[2] = 0.0f;
+ res2[3] = 0.0f;
+
+ this->inputOperation->read(in1, x-1, y-1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[0]);
+ addFilter(res2, in1, this->filter[0]);
+
+ this->inputOperation->read(in1, x, y-1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[1]);
+ addFilter(res2, in1, this->filter[3]);
+
+ this->inputOperation->read(in1, x+1, y-1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[2]);
+ addFilter(res2, in1, this->filter[6]);
+
+ this->inputOperation->read(in1, x-1, y, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[3]);
+ addFilter(res2, in1, this->filter[1]);
+
+ this->inputOperation->read(in2, x, y, inputBuffers, NULL);
+ addFilter(res1, in2, this->filter[4]);
+ addFilter(res2, in2, this->filter[4]);
+
+ this->inputOperation->read(in1, x+1, y, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[5]);
+ addFilter(res2, in1, this->filter[7]);
+
+ this->inputOperation->read(in1, x-1, y+1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[6]);
+ addFilter(res2, in1, this->filter[2]);
+
+ this->inputOperation->read(in1, x, y+1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[7]);
+ addFilter(res2, in1, this->filter[5]);
+
+ this->inputOperation->read(in1, x+1, y+1, inputBuffers, NULL);
+ addFilter(res1, in1, this->filter[8]);
+ addFilter(res2, in1, this->filter[8]);
+
+ color[0] = sqrt(res1[0]*res1[0]+res2[0]*res2[0]);
+ color[1] = sqrt(res1[1]*res1[1]+res2[1]*res2[1]);
+ color[2] = sqrt(res1[2]*res1[2]+res2[2]*res2[2]);
+
+ color[0] = color[0]*value[0] + in2[0] * mval;
+ color[1] = color[1]*value[0] + in2[1] * mval;
+ color[2] = color[2]*value[0] + in2[2] * mval;
+
+ color[3] = in2[3];
+}
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
new file mode 100644
index 00000000000..64a52d1a925
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvolutionEdgeFilterOperation_h_
+#define _COM_ConvolutionEdgeFilterOperation_h_
+
+#include "COM_ConvolutionFilterOperation.h"
+
+class ConvolutionEdgeFilterOperation: public ConvolutionFilterOperation {
+public:
+ ConvolutionEdgeFilterOperation();
+ void executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void* data);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
new file mode 100644
index 00000000000..1bf53260e23
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ConvolutionFilterOperation.h"
+
+ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->filter = NULL;
+ this->setComplex(true);
+}
+void ConvolutionFilterOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ this->inputValueOperation = this->getInputSocketReader(1);
+}
+
+void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9) {
+ this->filter = new float[9];
+ this->filter[0] = f1;
+ this->filter[1] = f2;
+ this->filter[2] = f3;
+ this->filter[3] = f4;
+ this->filter[4] = f5;
+ this->filter[5] = f6;
+ this->filter[6] = f7;
+ this->filter[7] = f8;
+ this->filter[8] = f9;
+ this->filterHeight = 3;
+ this->filterWidth = 3;
+}
+
+void ConvolutionFilterOperation::deinitExecution() {
+ this->inputOperation = NULL;
+ this->inputValueOperation = NULL;
+ if (this->filter) {
+ delete this->filter;
+ this->filter = NULL;
+ }
+}
+
+
+void ConvolutionFilterOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ color[0] = 0.0;
+ color[1] = 0.0;
+ color[2] = 0.0;
+ color[3] = 0.0;
+ float in1[4];
+ float in2[4];
+ float value[4];
+ this->inputValueOperation->read(value, x, y, inputBuffers, NULL);
+ float mval = 1.0f - value[0];
+
+ this->inputOperation->read(in1, x-1, y-1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[0];
+ color[1] += in1[1] * this->filter[0];
+ color[2] += in1[2] * this->filter[0];
+ color[3] += in1[3] * this->filter[0];
+ this->inputOperation->read(in1, x, y-1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[1];
+ color[1] += in1[1] * this->filter[1];
+ color[2] += in1[2] * this->filter[1];
+ color[3] += in1[3] * this->filter[1];
+ this->inputOperation->read(in1, x+1, y-1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[2];
+ color[1] += in1[1] * this->filter[2];
+ color[2] += in1[2] * this->filter[2];
+ color[3] += in1[3] * this->filter[2];
+ this->inputOperation->read(in1, x-1, y, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[3];
+ color[1] += in1[1] * this->filter[3];
+ color[2] += in1[2] * this->filter[3];
+ color[3] += in1[3] * this->filter[3];
+ this->inputOperation->read(in2, x, y, inputBuffers, NULL);
+ color[0] += in2[0] * this->filter[4];
+ color[1] += in2[1] * this->filter[4];
+ color[2] += in2[2] * this->filter[4];
+ color[3] += in2[3] * this->filter[4];
+ this->inputOperation->read(in1, x+1, y, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[5];
+ color[1] += in1[1] * this->filter[5];
+ color[2] += in1[2] * this->filter[5];
+ color[3] += in1[3] * this->filter[5];
+ this->inputOperation->read(in1, x-1, y+1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[6];
+ color[1] += in1[1] * this->filter[6];
+ color[2] += in1[2] * this->filter[6];
+ color[3] += in1[3] * this->filter[6];
+ this->inputOperation->read(in1, x, y+1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[7];
+ color[1] += in1[1] * this->filter[7];
+ color[2] += in1[2] * this->filter[7];
+ color[3] += in1[3] * this->filter[7];
+ this->inputOperation->read(in1, x+1, y+1, inputBuffers, NULL);
+ color[0] += in1[0] * this->filter[8];
+ color[1] += in1[1] * this->filter[8];
+ color[2] += in1[2] * this->filter[8];
+ color[3] += in1[3] * this->filter[8];
+
+ color[0] = color[0]*value[0] + in2[0] * mval;
+ color[1] = color[1]*value[0] + in2[1] * mval;
+ color[2] = color[2]*value[0] + in2[2] * mval;
+}
+
+bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ int addx = (this->filterWidth-1)/2+1;
+ int addy = (this->filterHeight-1)/2+1;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
new file mode 100644
index 00000000000..732b3d3699e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ConvolutionFilterOperation_h_
+#define _COM_ConvolutionFilterOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class ConvolutionFilterOperation: public NodeOperation {
+private:
+ int filterWidth;
+ int filterHeight;
+
+protected:
+ SocketReader *inputOperation;
+ SocketReader *inputValueOperation;
+ float* filter;
+
+public:
+ ConvolutionFilterOperation();
+ void set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ void initExecution();
+ void deinitExecution();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
new file mode 100644
index 00000000000..a763ded7f52
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CropOperation.h"
+#include "BLI_math.h"
+
+CropBaseOperation::CropBaseOperation() :NodeOperation(){
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+ this->settings = NULL;
+}
+
+void CropBaseOperation::updateArea() {
+ SocketReader * inputReference = this->getInputSocketReader(0);
+ float width = inputReference->getWidth();
+ float height = inputReference->getHeight();
+ if (this->relative){
+ settings->x1= width * settings->fac_x1;
+ settings->x2= width * settings->fac_x2;
+ settings->y1= height * settings->fac_y1;
+ settings->y2= height * settings->fac_y2;
+ }
+ if (width <= settings->x1 + 1)
+ settings->x1 = width - 1;
+ if (height <= settings->y1 + 1)
+ settings->y1 = height - 1;
+ if (width <= settings->x2 + 1)
+ settings->x2 = width - 1;
+ if (height <= settings->y2 + 1)
+ settings->y2 = height - 1;
+
+ this->xmax = MAX2(settings->x1, settings->x2) + 1;
+ this->xmin = MIN2(settings->x1, settings->x2);
+ this->ymax = MAX2(settings->y1, settings->y2) + 1;
+ this->ymin = MIN2(settings->y1, settings->y2);
+}
+
+void CropBaseOperation::initExecution(){
+ this->inputOperation = this->getInputSocketReader(0);
+ updateArea();
+}
+
+void CropBaseOperation::deinitExecution(){
+ this->inputOperation = NULL;
+}
+
+CropOperation::CropOperation() :CropBaseOperation(){
+}
+
+void CropOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]){
+ if ((x < this->xmax && x >= xmin) && (y < ymax && y >= ymin)){
+ inputOperation->read(color, x, y, sampler, inputBuffers);
+ } else {
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+ }
+}
+
+CropImageOperation::CropImageOperation() :CropBaseOperation(){
+}
+
+bool CropImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output){
+ rcti newInput;
+
+ newInput.xmax = input->xmax + this->xmin;
+ newInput.xmin = input->xmin + this->xmin;
+ newInput.ymax = input->ymax + this->ymin;
+ newInput.ymin = input->ymin + this->ymin;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+
+void CropImageOperation::determineResolution(unsigned int resolution[], unsigned int preferedResolution[]){
+ NodeOperation::determineResolution(resolution, preferedResolution);
+ updateArea();
+ resolution[0] = this->xmax - this->xmin;
+ resolution[1] = this->ymax - this->ymin;
+}
+
+void CropImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]){
+ this->inputOperation->read(color, (x + this->xmin), (y + this->ymin), sampler, inputBuffers);
+}
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
new file mode 100644
index 00000000000..a728212d221
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CropOperation_h_
+#define _COM_CropOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class CropBaseOperation: public NodeOperation {
+protected:
+ SocketReader *inputOperation;
+ NodeTwoXYs *settings;
+ bool relative;
+ int xmax;
+ int xmin;
+ int ymax;
+ int ymin;
+
+ void updateArea();
+public:
+ CropBaseOperation();
+ void initExecution();
+ void deinitExecution();
+ void setCropSettings(NodeTwoXYs *settings) {this->settings = settings;}
+ void setRelative(bool rel) {this->relative =rel;}
+};
+
+class CropOperation: public CropBaseOperation {
+private:
+public:
+ CropOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+class CropImageOperation: public CropBaseOperation {
+private:
+public:
+ CropImageOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void determineResolution(unsigned int resolution[], unsigned int preferedResolution[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
new file mode 100644
index 00000000000..ddccff01772
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_CurveBaseOperation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "BKE_colortools.h"
+#ifdef __cplusplus
+}
+#endif
+
+CurveBaseOperation::CurveBaseOperation(): NodeOperation() {
+ this->curveMapping = NULL;
+}
+void CurveBaseOperation::initExecution() {
+ curvemapping_initialize(this->curveMapping);
+}
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h
new file mode 100644
index 00000000000..bd4ee2ef2ed
--- /dev/null
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_CurveBaseOperation_h
+#define _COM_CurveBaseOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_color_types.h"
+
+class CurveBaseOperation : public NodeOperation {
+protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ CurveMapping *curveMapping;
+public:
+ CurveBaseOperation();
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ void setCurveMapping(CurveMapping* mapping) {this->curveMapping = mapping;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
new file mode 100644
index 00000000000..92d9e29dcec
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DifferenceMatteOperation.h"
+#include "BLI_math.h"
+
+DifferenceMatteOperation::DifferenceMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImage1Program = NULL;
+ inputImage2Program = NULL;
+}
+
+void DifferenceMatteOperation::initExecution() {
+ this->inputImage1Program = this->getInputSocketReader(0);
+ this->inputImage2Program = this->getInputSocketReader(1);
+}
+void DifferenceMatteOperation::deinitExecution() {
+ this->inputImage1Program= NULL;
+ this->inputImage2Program= NULL;
+}
+
+void DifferenceMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inColor1[4];
+ float inColor2[4];
+
+ const float tolerence=this->settings->t1;
+ const float falloff=this->settings->t2;
+ float difference;
+ float alpha;
+
+ this->inputImage1Program->read(inColor1, x, y, sampler, inputBuffers);
+ this->inputImage2Program->read(inColor2, x, y, sampler, inputBuffers);
+
+ difference= fabs(inColor2[0]-inColor1[0])+
+ fabs(inColor2[1]-inColor1[1])+
+ fabs(inColor2[2]-inColor1[2]);
+
+ /*average together the distances*/
+ difference=difference/3.0;
+
+ /*make 100% transparent*/
+ if(difference < tolerence) {
+ outputValue[0]=0.0;
+ }
+ /*in the falloff region, make partially transparent */
+ else if(difference < falloff+tolerence) {
+ difference=difference-tolerence;
+ alpha=difference/falloff;
+ /*only change if more transparent than before */
+ if(alpha < inColor1[3]) {
+ outputValue[0]=alpha;
+ }
+ else { /* leave as before */
+ outputValue[0]=inColor1[3];
+ }
+ }
+ else {
+ /*foreground object*/
+ outputValue[0]= inColor1[3];
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
new file mode 100644
index 00000000000..2b63bfd7a15
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DifferenceMatteOperation_h
+#define _COM_DifferenceMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class DifferenceMatteOperation : public NodeOperation {
+private:
+ NodeChroma* settings;
+ SocketReader * inputImage1Program;
+ SocketReader* inputImage2Program;
+public:
+ /**
+ * Default constructor
+ */
+ DifferenceMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma) {this->settings= nodeChroma;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
new file mode 100644
index 00000000000..df3bf996c96
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DilateErodeOperation.h"
+#include "BLI_math.h"
+
+DilateErodeOperation::DilateErodeOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
+ this->inputProgram = NULL;
+ this->inset = 0.0f;
+ this->_switch = 0.5f;
+ this->distance = 0.0f;
+}
+void DilateErodeOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ if (this->distance < 0.0f) {
+ this->scope = - this->distance + this->inset;
+ } else {
+ if (this->inset*2 > this->distance) {
+ this->scope = max(this->inset*2 - this->distance, this->distance);
+ } else {
+ this->scope = distance;
+ }
+ }
+ if (scope < 3) {
+ scope = 3;
+ }
+}
+
+void* DilateErodeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ void* buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void DilateErodeOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float inputValue[4];
+ const float sw = this->_switch;
+ const float distance = this->distance;
+ float pixelvalue;
+ const float rd = scope * scope;
+ const float inset = this->inset;
+ float mindist = rd*2;
+
+ MemoryBuffer* inputBuffer = (MemoryBuffer*)data;
+ float* buffer = inputBuffer->getBuffer();
+ rcti* rect = inputBuffer->getRect();
+ const int minx = max(x - scope, rect->xmin);
+ const int miny = max(y - scope, rect->ymin);
+ const int maxx = min(x + scope, rect->xmax);
+ const int maxy = min(y + scope, rect->ymax);
+ const int bufferWidth = rect->xmax-rect->xmin;
+ int offset;
+
+ this->inputProgram->read(inputValue, x, y, inputBuffers, NULL);
+ if (inputValue[0]>sw) {
+ for (int yi = miny ; yi<maxy;yi++) {
+ offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
+ for (int xi = minx ; xi<maxx;xi++) {
+ if (buffer[offset]<sw) {
+ const float dx = xi-x;
+ const float dy = yi-y;
+ const float dis = dx*dx+dy*dy;
+ mindist = min(mindist, dis);
+ }
+ offset +=4;
+ }
+ }
+ pixelvalue = -sqrtf(mindist);
+ } else {
+ for (int yi = miny ; yi<maxy;yi++) {
+ offset = ((yi-rect->ymin)*bufferWidth+(minx-rect->xmin))*4;
+ for (int xi = minx ; xi<maxx;xi++) {
+ if (buffer[offset]>sw) {
+ const float dx = xi-x;
+ const float dy = yi-y;
+ const float dis = dx*dx+dy*dy;
+ mindist = min(mindist, dis);
+ }
+ offset +=4;
+
+ }
+ }
+ pixelvalue = sqrtf(mindist);
+ }
+
+ if (distance > 0.0f) {
+ const float delta = distance - pixelvalue;
+ if (delta >= 0.0f) {
+ if (delta >= inset) {
+ color[0] = 1.0f;
+ } else {
+ color[0] = delta/inset;
+ }
+ } else {
+ color[0] = 0.0f;
+ }
+ } else {
+ const float delta = -distance+pixelvalue;
+ if (delta < 0.0f) {
+ if (delta < -inset) {
+ color[0] = 1.0f;
+ } else {
+ color[0] = (-delta)/inset;
+ }
+ } else {
+ color[0] = 0.0f;
+ }
+ }
+}
+
+void DilateErodeOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
+bool DilateErodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmax = input->xmax + scope;
+ newInput.xmin = input->xmin - scope;
+ newInput.ymax = input->ymax + scope;
+ newInput.ymin = input->ymin - scope;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h
new file mode 100644
index 00000000000..af554fa0d16
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DilateErodeOperation_h
+#define _COM_DilateErodeOperation_h
+#include "COM_NodeOperation.h"
+
+
+class DilateErodeOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+ float distance;
+ float _switch;
+ float inset;
+
+ /**
+ * determines the area of interest to track pixels
+ * keep this one as small as possible for speed gain.
+ */
+ int scope;
+public:
+ DilateErodeOperation();
+
+ /**
+ * 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);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setDistance(float distance) {this->distance = distance;}
+ void setSwitch(float sw) {this->_switch = sw;}
+ void setInset(float inset) {this->inset = inset;}
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
new file mode 100644
index 00000000000..5b066d8f16e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DirectionalBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->inputProgram = NULL;
+}
+
+void DirectionalBlurOperation::initExecution() {
+ this->inputProgram = getInputSocketReader(0);
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+ const float angle = this->data->angle;
+ const float zoom = this->data->zoom;
+ const float spin = this->data->spin;
+ const float iterations = this->data->iter;
+ const float distance = this->data->distance;
+ const float center_x = this->data->center_x;
+ const float center_y = this->data->center_y;
+ const float width = getWidth();
+ const float height = getHeight();
+
+ const float a= angle;
+ const float itsc= 1.f / pow(2.f, (float)iterations);
+ float D;
+
+ D= distance * sqrtf(width*width + height*height);
+ center_x_pix= center_x * width;
+ center_y_pix= center_y * height;
+
+ tx= itsc * D * cos(a);
+ ty= -itsc * D * sin(a);
+ sc= itsc * zoom;
+ rot= itsc * spin;
+
+}
+
+void DirectionalBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ const int iterations = pow(2.f, this->data->iter);
+ float col[4]= {0,0,0,0};
+ float col2[4]= {0,0,0,0};
+ this->inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers);
+ float ltx = tx;
+ float lty = ty;
+ float lsc = sc;
+ float lrot = rot;
+ /* blur the image */
+ for(int i= 0; i < iterations; ++i) {
+ const float cs= cos(lrot), ss= sin(lrot);
+ const float isc= 1.f / (1.f + lsc);
+
+ const float v= isc * (y - center_y_pix) + lty;
+ const float u= isc * (x - center_x_pix) + ltx;
+
+ this->inputProgram->read(col, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, COM_PS_NEAREST, inputBuffers);
+
+ col2[0] += col[0];
+ col2[1] += col[1];
+ col2[2] += col[2];
+ col2[3] += col[3];
+
+ /* double transformations */
+ ltx += tx;
+ lty += ty;
+ lrot += rot;
+ lsc += sc;
+ }
+ color[0] = col2[0]/iterations;
+ color[1] = col2[1]/iterations;
+ color[2] = col2[2]/iterations;
+ color[3] = col2[3]/iterations;
+}
+
+void DirectionalBlurOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
+bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
new file mode 100644
index 00000000000..e82b451c102
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehDirectionalBlurOperation_h
+#define _COM_DirectionalBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper {
+private:
+ SocketReader* inputProgram;
+ NodeDBlurData* data;
+
+ float center_x_pix, center_y_pix;
+ float tx, ty;
+ float sc, rot;
+
+public:
+ DirectionalBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setData(NodeDBlurData *data) {this->data = data;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
new file mode 100644
index 00000000000..b30ce5ac5b5
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_DisplaceOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+DisplaceOperation::DisplaceOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->inputColorProgram = NULL;
+ this->inputVectorProgram = NULL;
+ this->inputScaleXProgram = NULL;
+ this->inputScaleYProgram = NULL;
+}
+
+void DisplaceOperation::initExecution() {
+ this->inputColorProgram = this->getInputSocketReader(0);
+ this->inputVectorProgram = this->getInputSocketReader(1);
+ this->inputScaleXProgram = this->getInputSocketReader(2);
+ this->inputScaleYProgram = this->getInputSocketReader(3);
+
+ width_x4 = this->getWidth() * 4;
+ height_x4 = this->getHeight() * 4;
+}
+
+
+/* minimum distance (in pixels) a pixel has to be displaced
+ * in order to take effect */
+#define DISPLACE_EPSILON 0.01f
+
+void DisplaceOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data)
+{
+ float inVector[4];
+ float inScale[4];
+
+ float p_dx, p_dy; /* main displacement in pixel space */
+ float d_dx, d_dy;
+ float dxt, dyt;
+ float u, v;
+
+ this->inputScaleXProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers);
+ float xs = inScale[0];
+ this->inputScaleYProgram->read(inScale, x, y, COM_PS_NEAREST, inputBuffers);
+ float ys = inScale[0];
+
+ /* clamp x and y displacement to triple image resolution -
+ * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
+ CLAMP(xs, -width_x4, width_x4);
+ CLAMP(ys, -height_x4, height_x4);
+
+ this->inputVectorProgram->read(inVector, x, y, COM_PS_NEAREST, inputBuffers);
+ p_dx = inVector[0] * xs;
+ p_dy = inVector[1] * ys;
+
+ /* displaced pixel in uv coords, for image sampling */
+ u = x - p_dx + 0.5f;
+ v = y - p_dy + 0.5f;
+
+ /* calc derivatives */
+ this->inputVectorProgram->read(inVector, x+1, y, COM_PS_NEAREST, inputBuffers);
+ d_dx = inVector[0] * xs;
+ this->inputVectorProgram->read(inVector, x, y+1, COM_PS_NEAREST, inputBuffers);
+ d_dy = inVector[0] * ys;
+
+ /* clamp derivatives to minimum displacement distance in UV space */
+ dxt = p_dx - d_dx;
+ dyt = p_dy - d_dy;
+
+ dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/this->getWidth();
+ dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/this->getHeight();
+
+ /* EWA filtering */
+ this->inputColorProgram->read(color, u, v, dxt, dyt, inputBuffers);
+}
+
+void DisplaceOperation::deinitExecution() {
+ this->inputColorProgram = NULL;
+ this->inputVectorProgram = NULL;
+ this->inputScaleXProgram = NULL;
+ this->inputScaleYProgram = NULL;
+}
+
+bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti colorInput;
+ rcti vectorInput;
+ NodeOperation *operation=NULL;
+
+ /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
+ /* image */
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* vector */
+ operation = getInputOperation(1);
+ vectorInput.xmax = input->xmax + 2;
+ vectorInput.xmin = input->xmin;
+ vectorInput.ymax = input->ymax + 2;
+ vectorInput.ymin = input->ymin;
+ if (operation->determineDependingAreaOfInterest(&vectorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* scale x */
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
+ return true;
+ }
+
+ /* scale y */
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h
new file mode 100644
index 00000000000..17f65eea20f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_DisplaceOperation_h
+#define _COM_DisplaceOperation_h
+#include "COM_NodeOperation.h"
+
+
+class DisplaceOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputColorProgram;
+ SocketReader* inputVectorProgram;
+ SocketReader* inputScaleXProgram;
+ SocketReader* inputScaleYProgram;
+
+ float width_x4;
+ float height_x4;
+
+public:
+ DisplaceOperation();
+
+ /**
+ * we need a 2x2 differential filter for Vector Input and full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
new file mode 100644
index 00000000000..99d1eb1cd14
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_DisplaceSimpleOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+DisplaceSimpleOperation::DisplaceSimpleOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputColorProgram = NULL;
+ this->inputVectorProgram = NULL;
+ this->inputScaleXProgram = NULL;
+ this->inputScaleYProgram = NULL;
+}
+
+void DisplaceSimpleOperation::initExecution() {
+ this->inputColorProgram = this->getInputSocketReader(0);
+ this->inputVectorProgram = this->getInputSocketReader(1);
+ this->inputScaleXProgram = this->getInputSocketReader(2);
+ this->inputScaleYProgram = this->getInputSocketReader(3);
+
+ width_x4 = this->getWidth() * 4;
+ height_x4 = this->getHeight() * 4;
+}
+
+
+/* minimum distance (in pixels) a pixel has to be displaced
+ * in order to take effect */
+#define DISPLACE_EPSILON 0.01f
+
+void DisplaceSimpleOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
+ float inVector[4];
+ float inScale[4];
+
+ float p_dx, p_dy; /* main displacement in pixel space */
+ float u, v;
+
+ this->inputScaleXProgram->read(inScale, x, y, sampler, inputBuffers);
+ float xs = inScale[0];
+ this->inputScaleYProgram->read(inScale, x, y, sampler, inputBuffers);
+ float ys = inScale[0];
+
+ /* clamp x and y displacement to triple image resolution -
+ * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
+ CLAMP(xs, -width_x4, width_x4);
+ CLAMP(ys, -height_x4, height_x4);
+
+ this->inputVectorProgram->read(inVector, x, y, sampler, inputBuffers);
+ p_dx = inVector[0] * xs;
+ p_dy = inVector[1] * ys;
+
+ /* displaced pixel in uv coords, for image sampling */
+ /* clamp nodes to avoid glitches */
+ u = x - p_dx + 0.5f;
+ v = y - p_dy + 0.5f;
+ CLAMP(u, 0.f, this->getWidth()-1.f);
+ CLAMP(v, 0.f, this->getHeight()-1.f);
+
+ this->inputColorProgram->read(color, u, v, sampler, inputBuffers);
+}
+
+void DisplaceSimpleOperation::deinitExecution() {
+ this->inputColorProgram = NULL;
+ this->inputVectorProgram = NULL;
+ this->inputScaleXProgram = NULL;
+ this->inputScaleYProgram = NULL;
+}
+
+bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti colorInput;
+ NodeOperation *operation=NULL;
+
+ /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
+ /* image */
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* vector */
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ /* scale x */
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
+ return true;
+ }
+
+ /* scale y */
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
new file mode 100644
index 00000000000..88569954305
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_DisplaceSimpleOperation_h
+#define _COM_DisplaceSimpleOperation_h
+#include "COM_NodeOperation.h"
+
+
+class DisplaceSimpleOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputColorProgram;
+ SocketReader* inputVectorProgram;
+ SocketReader* inputScaleXProgram;
+ SocketReader* inputScaleYProgram;
+
+ float width_x4;
+ float height_x4;
+
+public:
+ DisplaceSimpleOperation();
+
+ /**
+ * we need a full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp
new file mode 100644
index 00000000000..bef470ca9de
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_DistanceMatteOperation.h"
+#include "BLI_math.h"
+
+DistanceMatteOperation::DistanceMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImageProgram = NULL;
+ inputKeyProgram = NULL;
+}
+
+void DistanceMatteOperation::initExecution() {
+ this->inputImageProgram = this->getInputSocketReader(0);
+ this->inputKeyProgram = this->getInputSocketReader(1);
+}
+
+void DistanceMatteOperation::deinitExecution() {
+ this->inputImageProgram= NULL;
+ this->inputKeyProgram= NULL;
+}
+
+void DistanceMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inKey[4];
+ float inImage[4];
+
+ const float tolerence=this->settings->t1;
+ const float falloff=this->settings->t2;
+
+ float distance;
+ float alpha;
+
+ this->inputKeyProgram->read(inKey, x, y, sampler, inputBuffers);
+ this->inputImageProgram->read(inImage, x, y, sampler, inputBuffers);
+
+ distance = sqrt(pow((inKey[0]-inImage[0]),2)+
+ pow((inKey[1]-inImage[1]),2)+
+ pow((inKey[2]-inImage[2]),2));
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /*make 100% transparent */
+ if(distance < tolerence) {
+ outputValue[0]=0.f;
+ }
+ /*in the falloff region, make partially transparent */
+ else if(distance < falloff+tolerence){
+ distance=distance-tolerence;
+ alpha=distance/falloff;
+ /*only change if more transparent than before */
+ if(alpha < inImage[3]) {
+ outputValue[0]=alpha;
+ }
+ else { /* leave as before */
+ outputValue[0]=inImage[3];
+ }
+ }
+ else {
+ /* leave as before */
+ outputValue[0]=inImage[3];
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h
new file mode 100644
index 00000000000..efa735445fa
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_DistanceMatteOperation_h
+#define _COM_DistanceMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class DistanceMatteOperation : public NodeOperation {
+private:
+ NodeChroma *settings;
+ SocketReader *inputImageProgram;
+ SocketReader *inputKeyProgram;
+public:
+ /**
+ * Default constructor
+ */
+ DistanceMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma) {this->settings= nodeChroma;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
new file mode 100644
index 00000000000..284fb0ddca4
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DotproductOperation.h"
+
+DotproductOperation::DotproductOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setResolutionInputSocketIndex(0);
+ this->input1Operation = NULL;
+ this->input2Operation = NULL;
+}
+void DotproductOperation::initExecution() {
+ this->input1Operation = this->getInputSocketReader(0);
+ this->input2Operation = this->getInputSocketReader(1);
+}
+
+void DotproductOperation::deinitExecution() {
+ this->input1Operation = NULL;
+ this->input2Operation = NULL;
+}
+
+/** @todo: current implementation is the inverse of a dotproduct. not 'logically' correct
+ */
+void DotproductOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input1[4];
+ float input2[4];
+ this->input1Operation->read(input1, x, y, sampler, inputBuffers);
+ this->input2Operation->read(input2, x, y, sampler, inputBuffers);
+ color[0] = -(input1[0]*input2[0]+input1[1]*input2[1]+input1[2]*input2[2]);
+}
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h
new file mode 100644
index 00000000000..0244fffa110
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DotproductOperation_h_
+#define _COM_DotproductOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class DotproductOperation: public NodeOperation {
+private:
+ SocketReader *input1Operation;
+ SocketReader *input2Operation;
+public:
+ DotproductOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
new file mode 100644
index 00000000000..cb6b27b9da1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -0,0 +1,1195 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_DoubleEdgeMaskOperation.h"
+#include "BLI_math.h"
+#include "DNA_node_types.h"
+
+// this part has been copied from the double edge mask
+// Contributor(s): Peter Larabell.
+static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize){
+ int x;
+ unsigned int isz=0; // inner edge size
+ unsigned int osz=0; // outer edge size
+ unsigned int gsz=0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x=t-rw+1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel underneath, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+1] && lomask[x+1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* upper right corner */
+ x=t;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel underneath, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x-1] && lomask[x-1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* lower left corner */
+ x=0;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel above, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x+rw] && lomask[x+rw]) || (!limask[x+1] && lomask[x+1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* lower right corner */
+ x=rw-1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel above, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x+rw] && lomask[x+rw]) || (!limask[x-1] && lomask[x-1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+
+ /* Test the TOP row of pixels in buffer, except corners */
+ for(x= t-1; x>=(t-rw)+2; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel to the right, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for(x= rw-2; x; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel to the right, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for(x= t-(rw<<1)+1; x>=rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for(x= t-rw; x>rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ rsize[0]=isz; // fill in our return sizes for edges + fill
+ rsize[1]=osz;
+ rsize[2]=gsz;
+}
+
+static void do_adjacentBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize){
+ int x;
+ unsigned int isz=0; // inner edge size
+ unsigned int osz=0; // outer edge size
+ unsigned int gsz=0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x=t-rw+1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel underneath, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+1] && lomask[x+1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* upper right corner */
+ x=t;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel underneath, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x-1] && lomask[x-1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x-1]) { // test if outer mask is empty underneath or to the left
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* lower left corner */
+ x=0;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel above, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x+rw] && lomask[x+rw]) || (!limask[x+1] && lomask[x+1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x+rw] || !lomask[x+1]) { // test if outer mask is empty above or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* lower right corner */
+ x=rw-1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if pixel above, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x+rw] && lomask[x+rw]) || (!limask[x-1] && lomask[x-1])){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x+rw] || !lomask[x-1]) { // test if outer mask is empty above or to the left
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for(x= t-1; x>=(t-rw)+2; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel to the left, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for(x= rw-2; x; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel to the left, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-1] && lomask[x-1]) || (!limask[x+1] && lomask[x+1])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for(x= t-(rw<<1)+1; x>=rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for(x= t-rw; x>rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if((!limask[x-rw] && lomask[x-rw]) || (!limask[x+rw] && lomask[x+rw])) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ rsize[0]=isz; // fill in our return sizes for edges + fill
+ rsize[1]=osz;
+ rsize[2]=gsz;
+}
+
+static void do_allKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize){
+ int x;
+ unsigned int isz=0; // inner edge size
+ unsigned int osz=0; // outer edge size
+ unsigned int gsz=0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x=t-rw+1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if the inner mask is empty underneath or to the right
+ if(!limask[x-rw] || !limask[x+1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* upper right corner */
+ x=t;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if the inner mask is empty underneath or to the left
+ if(!limask[x-rw] || !limask[x-1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* lower left corner */
+ x=0;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if inner mask is empty above or to the right
+ if(!limask[x+rw] || !limask[x+1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ /* lower right corner */
+ x=rw-1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if inner mask is empty above or to the left
+ if(!limask[x+rw] || !limask[x-1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+
+ /* Test the TOP row of pixels in buffer, except corners */
+ for(x= t-1; x>=(t-rw)+2; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if(!limask[x-1] || !limask[x+1]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for(x= rw-2; x; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if(!limask[x-1] || !limask[x+1]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for(x= t-(rw<<1)+1; x>=rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty underneath or above
+ if(!limask[x-rw] || !limask[x+rw]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for(x= t-rw; x>rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty underneath or above
+ if(!limask[x-rw] || !limask[x+rw]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ }
+ }
+
+ rsize[0]=isz; // fill in our return sizes for edges + fill
+ rsize[1]=osz;
+ rsize[2]=gsz;
+}
+
+static void do_allBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize){
+ int x;
+ unsigned int isz=0; // inner edge size
+ unsigned int osz=0; // outer edge size
+ unsigned int gsz=0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x=t-rw+1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if the inner mask is empty underneath or to the right
+ if(!limask[x-rw] || !limask[x+1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* upper right corner */
+ x=t;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if the inner mask is empty underneath or to the left
+ if(!limask[x-rw] || !limask[x-1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x-1]) { // test if outer mask is empty above or to the left
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* lower left corner */
+ x=0;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if inner mask is empty above or to the right
+ if(!limask[x+rw] || !limask[x+1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x+rw] || !lomask[x+1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* lower right corner */
+ x=rw-1;
+ // test if inner mask is filled
+ if(limask[x]){
+ // test if inner mask is empty above or to the left
+ if(!limask[x+rw] || !limask[x-1]){
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]){ // inner mask was empty, test if outer mask is filled
+ if(!lomask[x+rw] || !lomask[x-1]) { // test if outer mask is empty underneath or to the left
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for(x= t-1; x>=(t-rw)+2; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if(!limask[x-1] || !limask[x+1]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for(x= rw-2; x; x--) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if(!limask[x-1] || !limask[x+1]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-1] || !lomask[x+1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for(x= t-(rw<<1)+1; x>=rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty underneath or above
+ if(!limask[x-rw] || !limask[x+rw]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for(x= t-rw; x>rw; x-=rw) {
+ // test if inner mask is filled
+ if(limask[x]) {
+ // test if inner mask is empty underneath or above
+ if(!limask[x-rw] || !limask[x+rw]) {
+ isz++; // increment inner edge size
+ lres[x]=4; // flag pixel as inner edge
+ } else {
+ res[x]=1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ } else if(lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if(!lomask[x-rw] || !lomask[x+rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x]=3; // flag pixel as outer edge
+ } else {
+ gsz++; // increment the gradient pixel count
+ lres[x]=2; // flag pixel as gradient
+ }
+ }
+ }
+
+ rsize[0]=isz; // fill in our return sizes for edges + fill
+ rsize[1]=osz;
+ rsize[2]=gsz;
+}
+
+static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz){
+ int x; // x = pixel loop counter
+ int a; // a = pixel loop counter
+ int dx; // dx = delta x
+ int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
+ int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
+ int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
+ int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
+ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
+ for(x= (t-rw)+1, dx=x-(rw-2); dx>rw; x-=rw,dx-=rw) {
+ a=x-2;
+ pix_prevRow=a+rw;
+ pix_nextRow=a-rw;
+ pix_prevCol=a+1;
+ pix_nextCol=a-1;
+ while(a>dx-2) {
+ if(!limask[a]) { // if the inner mask is empty
+ if(lomask[a]) { // if the outer mask is full
+ /*
+ Next we test all 4 directions around the current pixel: next/prev/up/down
+ The test ensures that the outer mask is empty and that the inner mask
+ is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ then the current pixel is counted as being a true outer edge pixel.
+ */
+ if((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
+ (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
+ (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
+ (!lomask[pix_prevRow] && !limask[pix_prevRow]))
+ {
+ in_osz++; // increment the outer boundary pixel count
+ lres[a]=3; // flag pixel as part of outer edge
+ } else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a]=2; // flag pixel as gradient
+ }
+ }
+
+ } else {
+ if(!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] || !limask[pix_prevRow]) {
+ in_isz++; // increment the inner boundary pixel count
+ lres[a]=4; // flag pixel as part of inner edge
+ } else {
+ res[a]=1.0f; // pixel is part of inner mask, but not at an edge
+ }
+ }
+ a--;
+ pix_prevRow--;
+ pix_nextRow--;
+ pix_prevCol--;
+ pix_nextCol--;
+ }
+ }
+
+ rsize[0]=in_isz; // fill in our return sizes for edges + fill
+ rsize[1]=in_osz;
+ rsize[2]=in_gsz;
+}
+
+static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz){
+ int x; // x = pixel loop counter
+ int a; // a = pixel loop counter
+ int dx; // dx = delta x
+ int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
+ int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
+ int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
+ int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
+ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
+ for(x= (t-rw)+1, dx=x-(rw-2); dx>rw; x-=rw,dx-=rw) {
+ a=x-2;
+ pix_prevRow=a+rw;
+ pix_nextRow=a-rw;
+ pix_prevCol=a+1;
+ pix_nextCol=a-1;
+ while(a>dx-2) {
+ if(!limask[a]) { // if the inner mask is empty
+ if(lomask[a]) { // if the outer mask is full
+ /*
+ Next we test all 4 directions around the current pixel: next/prev/up/down
+ The test ensures that the outer mask is empty and that the inner mask
+ is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ then the current pixel is counted as being a true outer edge pixel.
+ */
+ if((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
+ (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
+ (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
+ (!lomask[pix_prevRow] && !limask[pix_prevRow]))
+ {
+ in_osz++; // increment the outer boundary pixel count
+ lres[a]=3; // flag pixel as part of outer edge
+ } else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a]=2; // flag pixel as gradient
+ }
+ }
+
+ } else {
+ if((!limask[pix_nextCol] && lomask[pix_nextCol]) ||
+ (!limask[pix_prevCol] && lomask[pix_prevCol]) ||
+ (!limask[pix_nextRow] && lomask[pix_nextRow]) ||
+ (!limask[pix_prevRow] && lomask[pix_prevRow]))
+ {
+ in_isz++; // increment the inner boundary pixel count
+ lres[a]=4; // flag pixel as part of inner edge
+ } else {
+ res[a]=1.0f; // pixel is part of inner mask, but not at an edge
+ }
+ }
+ a--;
+ pix_prevRow--; // advance all four "surrounding" pixel pointers
+ pix_nextRow--;
+ pix_prevCol--;
+ pix_nextCol--;
+ }
+ }
+
+ rsize[0]=in_isz; // fill in our return sizes for edges + fill
+ rsize[1]=in_osz;
+ rsize[2]=in_gsz;
+}
+
+static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigned int *lres, float *res, unsigned short *gbuf, unsigned int *innerEdgeOffset, unsigned int *outerEdgeOffset, unsigned int isz, unsigned int gsz){
+ int x; // x = pixel loop counter
+ int a; // a = temporary pixel index buffer loop counter
+ unsigned int ud; // ud = unscaled edge distance
+ unsigned int dmin; // dmin = minimun edge distance
+
+ unsigned int rsl; // long used for finding fast 1.0/sqrt
+ unsigned int gradientFillOffset;
+ unsigned int innerAccum=0; // for looping inner edge pixel indexes, represents current position from offset
+ unsigned int outerAccum=0; // for looping outer edge pixel indexes, represents current position from offset
+ unsigned int gradientAccum=0; // for looping gradient pixel indexes, represents current position from offset
+ /*
+ Here we compute the size of buffer needed to hold (row,col) coordinates
+ for each pixel previously determined to be either gradient, inner edge,
+ or outer edge.
+
+ Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even
+ though gbuf[] is declared as unsigned short* (2 bytes) because we don't
+ store the pixel indexes, we only store x,y location of pixel in buffer.
+
+ This does make the assumption that x and y can fit in 16 unsigned bits
+ so if Blender starts doing renders greater than 65536 in either direction
+ this will need to allocate gbuf[] as unsigned int* and allocate 8 bytes
+ per flagged pixel.
+
+ In general, the buffer on-screen:
+
+ Example: 9 by 9 pixel block
+
+ . = pixel non-white in both outer and inner mask
+ o = pixel white in outer, but not inner mask, adjacent to "." pixel
+ g = pixel white in outer, but not inner mask, not adjacent to "." pixel
+ i = pixel white in inner mask, adjacent to "g" or "." pixel
+ F = pixel white in inner mask, only adjacent to other pixels white in the inner mask
+
+
+ ......... <----- pixel #80
+ ..oooo...
+ .oggggo..
+ .oggiggo.
+ .ogiFigo.
+ .oggiggo.
+ .oggggo..
+ ..oooo...
+ pixel #00 -----> .........
+
+ gsz = 18 (18 "g" pixels above)
+ isz = 4 (4 "i" pixels above)
+ osz = 18 (18 "o" pixels above)
+
+
+ The memory in gbuf[] after filling will look like this:
+
+ gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels)
+ / / /
+ / / /
+ |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y)
+ +--------------------------------> <----------------> <------------------------> <----------------+
+ |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes
+ +--------------------------------> <----------------> <------------------------> <----------------+
+ |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel
+ / / /
+ / / /
+ / / /
+ +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+
+
+
+ Ultimately we do need the pixel's memory buffer index to set the output
+ pixel color, but it's faster to reconstruct the memory buffer location
+ each iteration of the final gradient calculation than it is to deconstruct
+ a memory location into x,y pairs each round.
+*/
+
+
+ gradientFillOffset=0; // since there are likely "more" of these, put it first. :)
+ *innerEdgeOffset=gradientFillOffset+gsz; // set start of inner edge indexes
+ *outerEdgeOffset=(*innerEdgeOffset)+isz; // set start of outer edge indexes
+ /* set the accumulators to correct positions */ // set up some accumulator variables for loops
+ gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
+ innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
+ outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
+ //uses dmin=row, rsl=col
+ for(x=0,dmin=0; x<t; x+=rw,dmin++) {
+ for(rsl=0; rsl<rw; rsl++) {
+ a=x+rsl;
+ if(lres[a]==2) { // it is a gradient pixel flagged by 2
+ ud=gradientAccum<<1; // double the index to reach correct unsigned short location
+ gbuf[ud]=dmin; // insert pixel's row into gradient pixel location buffer
+ gbuf[ud+1]=rsl; // insert pixel's column into gradient pixel location buffer
+ gradientAccum++; // increment gradient index buffer pointer
+ } else if(lres[a]==3) { // it is an outer edge pixel flagged by 3
+ ud=outerAccum<<1; // double the index to reach correct unsigned short location
+ gbuf[ud]=dmin; // insert pixel's row into outer edge pixel location buffer
+ gbuf[ud+1]=rsl; // insert pixel's column into outer edge pixel location buffer
+ outerAccum++; // increment outer edge index buffer pointer
+ res[a]=0.0f; // set output pixel intensity now since it won't change later
+ } else if(lres[a]==4) { // it is an inner edge pixel flagged by 4
+ ud=innerAccum<<1; // double int index to reach correct unsigned short location
+ gbuf[ud]=dmin; // insert pixel's row into inner edge pixel location buffer
+ gbuf[ud+1]=rsl; // insert pixel's column into inner edge pixel location buffer
+ innerAccum++; // increment inner edge index buffer pointer
+ res[a]=1.0f; // set output pixel intensity now since it won't change later
+ }
+ }
+ }
+
+}
+
+static void do_fillGradientBuffer(unsigned int rw, float *res, unsigned short *gbuf, unsigned int isz, unsigned int osz, unsigned int gsz, unsigned int innerEdgeOffset, unsigned int outerEdgeOffset){
+ int x; // x = pixel loop counter
+ int a; // a = temporary pixel index buffer loop counter
+ int fsz; // size of the frame
+ unsigned int rsl; // long used for finding fast 1.0/sqrt
+ float rsf; // float used for finding fast 1.0/sqrt
+ const float rsopf = 1.5f; // constant float used for finding fast 1.0/sqrt
+
+ unsigned int gradientFillOffset;
+ unsigned int t;
+ unsigned int ud; // ud = unscaled edge distance
+ unsigned int dmin; // dmin = minimun edge distance
+ float odist; // odist = current outer edge distance
+ float idist; // idist = current inner edge distance
+ int dx; // dx = X-delta (used for distance proportion calculation)
+ int dy; // dy = Y-delta (used for distance proportion calculation)
+
+ /*
+ The general algorithm used to color each gradient pixel is:
+
+ 1.) Loop through all gradient pixels.
+ A.) For each gradient pixel:
+ a.) Loop though all outside edge pixels, looking for closest one
+ to the gradient pixel we are in.
+ b.) Loop through all inside edge pixels, looking for closest one
+ to the gradient pixel we are in.
+ c.) Find proportion of distance from gradient pixel to inside edge
+ pixel compared to sum of distance to inside edge and distance to
+ outside edge.
+
+ In an image where:
+ . = blank (black) pixels, not covered by inner mask or outer mask
+ + = desired gradient pixels, covered only by outer mask
+ * = white full mask pixels, covered by at least inner mask
+
+ ...............................
+ ...............+++++++++++.....
+ ...+O++++++..++++++++++++++....
+ ..+++\++++++++++++++++++++.....
+ .+++++G+++++++++*******+++.....
+ .+++++|+++++++*********+++.....
+ .++***I****************+++.....
+ .++*******************+++......
+ .+++*****************+++.......
+ ..+++***************+++........
+ ....+++**********+++...........
+ ......++++++++++++.............
+ ...............................
+
+ O = outside edge pixel
+ \
+ G = gradient pixel
+ |
+ I = inside edge pixel
+
+ __
+ *note that IO does not need to be a straight line, in fact
+ many cases can arise where straight lines do not work
+ correctly.
+
+ __ __ __
+ d.) Pixel color is assigned as |GO| / ( |GI| + |GO| )
+
+ The implementation does not compute distance, but the reciprocal of the
+ distance. This is done to avoid having to compute a square root, as a
+ reciprocal square root can be computed faster. Therefore, the code computes
+ pixel color as |GI| / (|GI| + |GO|). Since these are reciprocals, GI serves the
+ purpose of GO for the proportion calculation.
+
+ For the purposes of the minimun distance comparisons, we only check
+ the sums-of-squares against eachother, since they are in the same
+ mathematical sort-order as if we did go ahead and take square roots
+
+ Loop through all gradient pixels.
+ */
+
+ for(x= gsz-1; x>=0; x--) {
+ gradientFillOffset=x<<1;
+ t=gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x]
+ fsz=gbuf[gradientFillOffset+1]; // calculate row of pixel indexed by gbuf[x]
+ dmin=0xffffffff; // reset min distance to edge pixel
+ for(a=outerEdgeOffset+osz-1; a>=outerEdgeOffset; a--) { // loop through all outer edge buffer pixels
+ ud=a<<1;
+ dy=t-gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row
+ dx=fsz-gbuf[ud+1]; // set dy to gradient pixel row - outer edge pixel column
+ ud=dx*dx+dy*dy; // compute sum of squares
+ if(ud<dmin) { // if our new sum of squares is less than the current minimum
+ dmin=ud; // set a new minimum equal to the new lower value
+ }
+ }
+ odist=(float)(dmin); // cast outer min to a float
+ rsf=odist*0.5f; //
+ rsl=*(unsigned int*)&odist; // use some peculiar properties of the way bits are stored
+ rsl=0x5f3759df-(rsl>>1); // in floats vs. unsigned ints to compute an approximate
+ odist=*(float*)&rsl; // reciprocal square root
+ odist=odist*(rsopf-(rsf*odist*odist)); // -- ** this line can be iterated for more accuracy ** --
+ dmin=0xffffffff; // reset min distance to edge pixel
+ for(a= innerEdgeOffset+isz-1; a>=innerEdgeOffset; a--) { // loop through all inside edge pixels
+ ud=a<<1;
+ dy=t-gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel
+ dx=fsz-gbuf[ud+1]; // compute delta in X from gradient pixel to inside edge pixel
+ ud=dx*dx+dy*dy; // compute sum of squares
+ if(ud<dmin) { // if our new sum of squares is less than the current minimum we've found
+ dmin=ud; // set a new minimum equal to the new lower value
+ }
+ }
+ idist=(float)(dmin); // cast inner min to a float
+ rsf=idist*0.5f; //
+ rsl=*(unsigned int*)&idist; //
+ rsl=0x5f3759df-(rsl>>1); // see notes above
+ idist=*(float*)&rsl; //
+ idist=idist*(rsopf-(rsf*idist*idist)); //
+ /*
+ Note once again that since we are using reciprocals of distance values our
+ proportion is already the correct intensity, and does not need to be
+ subracted from 1.0 like it would have if we used real distances.
+ */
+
+ /*
+ Here we reconstruct the pixel's memory location in the CompBuf by
+ Pixel Index = Pixel Column + ( Pixel Row * Row Width )
+ */
+ res[gbuf[gradientFillOffset+1]+(gbuf[gradientFillOffset]*rw)]=(idist/(idist+odist)); //set intensity
+ }
+
+}
+
+// end of copy
+
+void DoubleEdgeMaskOperation::doDoubleEdgeMask(float* imask, float *omask, float *res) {
+
+ unsigned int *lres; // lres = unsigned int pointer to output pixel buffer (for bit operations)
+ unsigned int *limask; // limask = unsigned int pointer to inner mask (for bit operations)
+ unsigned int *lomask; // lomask = unsigned int pointer to outer mask (for bit operations)
+
+ int rw; // rw = pixel row width
+ int t; // t = total number of pixels in buffer - 1 (used for loop starts)
+ int fsz; // size of the frame
+
+ unsigned int isz=0; // size (in pixels) of inside edge pixel index buffer
+ unsigned int osz=0; // size (in pixels) of outside edge pixel index buffer
+ unsigned int gsz=0; // size (in pixels) of gradient pixel index buffer
+ unsigned int rsize[3]; // size storage to pass to helper functions
+ unsigned int innerEdgeOffset=0; // offset into final buffer where inner edge pixel indexes start
+ unsigned int outerEdgeOffset=0; // offset into final buffer where outer edge pixel indexes start
+
+ unsigned short *gbuf; // gradient/inner/outer pixel location index buffer
+
+ if(true) { // if both input sockets have some data coming in...
+
+ t=(this->getWidth()*this->getHeight())-1; // determine size of the frame
+
+ lres= (unsigned int*)res; // unsigned int pointer to output buffer (for bit level ops)
+ limask=(unsigned int*)imask; // unsigned int pointer to input mask (for bit level ops)
+ lomask=(unsigned int*)omask; // unsigned int pointer to output mask (for bit level ops)
+ rw= this->getWidth(); // width of a row of pixels
+
+
+ /*
+ The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the
+ LEFT and RIGHT edges (excluding the corner pixels), and all OTHER rows.
+ This allows for quick computation of outer edge pixels where
+ a screen edge pixel is marked to be gradient.
+
+ The pixel type (gradient vs inner-edge vs outer-edge) tests change
+ depending on the user selected "Inner Edge Mode" and the user selected
+ "Buffer Edge Mode" on the node's GUI. There are 4 sets of basically the
+ same algorithm:
+
+ 1.) Inner Edge -> Adjacent Only
+ Buffer Edge -> Keep Inside
+
+ 2.) Inner Edge -> Adjacent Only
+ Buffer Edge -> Bleed Out
+
+ 3.) Inner Edge -> All
+ Buffer Edge -> Keep Inside
+
+ 4.) Inner Edge -> All
+ Buffer Edge -> Bleed Out
+
+ Each version has slightly different criteria for detecting an edge pixel.
+ */
+ if(this->adjecentOnly) { // if "adjacent only" inner edge mode is turned on
+ if(this->keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_adjacentKeepBorders(t,rw,limask,lomask,lres,res,rsize);
+ }else{ // "bleed out" buffer edge mode is turned on
+ do_adjacentBleedBorders(t,rw,limask,lomask,lres,res,rsize);
+ }
+ isz=rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ osz=rsize[1];
+ gsz=rsize[2];
+ // detect edges in all non-border pixels in the buffer
+ do_adjacentEdgeDetection(t,rw,limask,lomask,lres,res,rsize,isz,osz,gsz);
+ }else{ // "all" inner edge mode is turned on
+ if(this->keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_allKeepBorders(t,rw,limask,lomask,lres,res,rsize);
+ }else{ // "bleed out" buffer edge mode is turned on
+ do_allBleedBorders(t,rw,limask,lomask,lres,res,rsize);
+ }
+ isz=rsize[0]; // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ osz=rsize[1];
+ gsz=rsize[2];
+ // detect edges in all non-border pixels in the buffer
+ do_allEdgeDetection(t,rw,limask,lomask,lres,res,rsize,isz,osz,gsz);
+ }
+
+ isz=rsize[0]; // set edge and gradient buffer sizes once again...
+ osz=rsize[1]; // the sizes in rsize[] may have been modified
+ gsz=rsize[2]; // by the do_*EdgeDetection() function.
+
+ fsz=gsz+isz+osz; // calculate size of pixel index buffer needed
+ gbuf= new unsigned short[fsz*2]; // allocate edge/gradient pixel index buffer
+
+ do_createEdgeLocationBuffer(t,rw,lres,res,gbuf,&innerEdgeOffset,&outerEdgeOffset,isz,gsz);
+ do_fillGradientBuffer(rw,res,gbuf,isz,osz,gsz,innerEdgeOffset,outerEdgeOffset);
+
+ delete gbuf; // free the gradient index buffer
+ }
+}
+
+DoubleEdgeMaskOperation::DoubleEdgeMaskOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputInnerMask = NULL;
+ this->inputOuterMask = NULL;
+ this->adjecentOnly = false;
+ this->keepInside = false;
+ this->setComplex(true);
+}
+
+bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ if (this->cachedInstance == NULL) {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ } else {
+ return false;
+ }
+}
+
+void DoubleEdgeMaskOperation::initExecution() {
+ this->inputInnerMask = this->getInputSocketReader(0);
+ this->inputOuterMask = this->getInputSocketReader(1);
+ initMutex();
+ this->cachedInstance = NULL;
+}
+
+void* DoubleEdgeMaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ if (this->cachedInstance) return this->cachedInstance;
+
+ BLI_mutex_lock(getMutex());
+ if (this->cachedInstance == NULL) {
+ MemoryBuffer* innerMask = (MemoryBuffer*)inputInnerMask->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer* outerMask= (MemoryBuffer*)inputOuterMask->initializeTileData(rect, memoryBuffers);
+ float* data = new float[this->getWidth()*this->getHeight()];
+ float* imask = innerMask->convertToValueBuffer();
+ float* omask = outerMask->convertToValueBuffer();
+ doDoubleEdgeMask(imask, omask, data);
+ delete imask;
+ delete omask;
+ this->cachedInstance = data;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->cachedInstance;
+}
+void DoubleEdgeMaskOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float* buffer = (float*) data;
+ int index = (y*this->getWidth() + x);
+ color[0] = buffer[index];
+ color[1] = buffer[index+1];
+ color[2] = buffer[index+2];
+ color[3] = buffer[index+3];
+}
+
+void DoubleEdgeMaskOperation::deinitExecution() {
+ this->inputInnerMask = NULL;
+ this->inputOuterMask = NULL;
+ deinitMutex();
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ this->cachedInstance = NULL;
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
new file mode 100644
index 00000000000..f233570800a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_DoubleEdgeMaskOperation_h
+#define _COM_DoubleEdgeMaskOperation_h
+#include "COM_NodeOperation.h"
+
+
+class DoubleEdgeMaskOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOuterMask;
+ SocketReader * inputInnerMask;
+ bool adjecentOnly;
+ bool keepInside;
+ float* cachedInstance;
+public:
+ DoubleEdgeMaskOperation();
+
+ void doDoubleEdgeMask(float* inner, float *outer, float *res);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setAdjecentOnly(bool adjecentOnly) {this->adjecentOnly = adjecentOnly;}
+ void setKeepInside(bool keepInside) {this->keepInside = keepInside;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
new file mode 100644
index 00000000000..033cb4da84d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_EllipseMaskOperation.h"
+#include "BLI_math.h"
+#include "DNA_node_types.h"
+
+EllipseMaskOperation::EllipseMaskOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputMask = NULL;
+ this->inputValue = NULL;
+ this->cosine = 0.0f;
+ this->sine = 0.0f;
+}
+void EllipseMaskOperation::initExecution() {
+ this->inputMask = this->getInputSocketReader(0);
+ this->inputValue = this->getInputSocketReader(1);
+ const double rad = DEG2RAD(this->data->rotation);
+ this->cosine = cos(rad);
+ this->sine = sin(rad);
+ this->aspectRatio = ((float)this->getWidth())/this->getHeight();
+}
+
+void EllipseMaskOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputMask[4];
+ float inputValue[4];
+
+ float rx = x/this->getWidth();
+ float ry = y/this->getHeight();
+
+ const float dy = (ry - this->data->y)/this->aspectRatio;
+ const float dx = rx - this->data->x;
+ rx = this->data->x+(this->cosine*dx + this->sine*dy);
+ ry = this->data->y+(-this->sine*dx + this->cosine*dy);
+
+ this->inputMask->read(inputMask, x, y, sampler, inputBuffers);
+ this->inputValue->read(inputValue, x, y, sampler, inputBuffers);
+
+ const float halfHeight = (this->data->height)/2.0f;
+ const float halfWidth = this->data->width/2.0f;
+ float sx = rx-this->data->x;
+ sx *= sx;
+ const float tx = halfWidth * halfWidth;
+ float sy = ry-this->data->y;
+ sy *= sy;
+ const float ty = halfHeight * halfHeight;
+
+ bool inside = ((sx/tx)+(sy/ty))<1.0f;
+
+ switch (this->maskType) {
+ case CMP_NODE_MASKTYPE_ADD:
+ if (inside) {
+ color[0] = max(inputMask[0],inputValue[0]);
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_SUBTRACT:
+ if (inside) {
+ color[0] = inputMask[0]-inputValue[0];
+ CLAMP(color[0], 0, 1);
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_MULTIPLY:
+ if (inside) {
+ color[0] = inputMask[0]*inputValue[0];
+ } else {
+ color[0] = 0;
+ }
+ break;
+ case CMP_NODE_MASKTYPE_NOT:
+ if (inside) {
+ if (inputMask[0]>0.0f) {
+ color[0] = 0;
+ } else {
+ color[0] = inputValue[0];
+ }
+ } else {
+ color[0] = inputMask[0];
+ }
+ break;
+ }
+
+
+}
+
+void EllipseMaskOperation::deinitExecution() {
+ this->inputMask = NULL;
+ this->inputValue = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
new file mode 100644
index 00000000000..969013782e6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_EllipseMaskOperation_h
+#define _COM_EllipseMaskOperation_h
+#include "COM_NodeOperation.h"
+
+
+class EllipseMaskOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputMask;
+ SocketReader * inputValue;
+
+ float sine;
+ float cosine;
+ float aspectRatio;
+ int maskType;
+
+ NodeEllipseMask *data;
+public:
+ EllipseMaskOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeEllipseMask *data) {this->data = data;}
+
+ void setMaskType(int maskType) {this->maskType = maskType;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
new file mode 100644
index 00000000000..aae39694220
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_FastGaussianBlurOperation.h"
+#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
+FastGaussianBlurOperation::FastGaussianBlurOperation(): BlurBaseOperation(){
+ this->iirgaus = false;
+}
+
+void FastGaussianBlurOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data) {
+ MemoryBuffer *newData = (MemoryBuffer*)data;
+
+ newData->read(color, x, y);
+}
+
+bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output){
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation * operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }else {
+ if(this->iirgaus){
+ newInput.xmax = input->xmax + (sx);
+ newInput.xmin = input->xmin - (sx);
+ newInput.ymax = input->ymax + (sy);
+ newInput.ymin = input->ymin - (sy);
+ }else {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+}
+
+void* FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers){
+ MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *copy = newBuf->duplicate();
+ updateSize(memoryBuffers);
+
+ int c;
+ sx = data->sizex * this->size/2.0f;
+ sy = data->sizey * this->size/2.0f;
+ this->iirgaus = true;
+
+ if ((sx == sy) && (sx > 0.f)) {
+ for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(copy, sx, c, 3);
+ }
+ else {
+ if (sx > 0.f) {
+ for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(copy, sx, c, 1);
+ }
+ if (sy > 0.f) {
+ for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ IIR_gauss(copy, sy, c, 2);
+ }
+ }
+ return copy;
+}
+
+void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data){
+ MemoryBuffer *newData = (MemoryBuffer*)data;
+ delete newData;
+}
+
+void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int chan, int xy) {
+ double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3];
+ double *X, *Y, *W;
+ int i, x, y, sz;
+ float *buffer = src->getBuffer();
+
+ // <0.5 not valid, though can have a possibly useful sort of sharpening effect
+ if (sigma < 0.5f) return;
+
+ if ((xy < 1) || (xy > 3)) xy = 3;
+
+ // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
+ // so just skiping blur along faulty direction if src's def is below that limit!
+ if (src->getWidth() < 3) xy &= ~(int) 1;
+ if (src->getHeight() < 3) xy &= ~(int) 2;
+ if (xy < 1) return;
+
+ // see "Recursive Gabor Filtering" by Young/VanVliet
+ // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
+ if (sigma >= 3.556f)
+ q = 0.9804f*(sigma - 3.556f) + 2.5091f;
+ else // sigma >= 0.5
+ q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f;
+ q2 = q*q;
+ sc = (1.1668 + q)*(3.203729649 + (2.21566 + q)*q);
+ // no gabor filtering here, so no complex multiplies, just the regular coefs.
+ // all negated here, so as not to have to recalc Triggs/Sdika matrix
+ cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc;
+ cf[2] = -q2*(3.38246 + 3.0*q)/sc;
+ // 0 & 3 unchanged
+ cf[3] = q2*q/sc;
+ cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
+
+ // Triggs/Sdika border corrections,
+ // it seems to work, not entirely sure if it is actually totally correct,
+ // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
+ // found one other implementation by Cristoph Lampert,
+ // but neither seem to be quite the same, result seems to be ok so far anyway.
+ // Extra scale factor here to not have to do it in filter,
+ // though maybe this had something to with the precision errors
+ sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));
+ tsM[0] = sc*(-cf[3]*cf[1] + 1.0 - cf[3]*cf[3] - cf[2]);
+ tsM[1] = sc*((cf[3] + cf[1])*(cf[2] + cf[3]*cf[1]));
+ tsM[2] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
+ tsM[3] = sc*(cf[1] + cf[3]*cf[2]);
+ tsM[4] = sc*(-(cf[2] - 1.0)*(cf[2] + cf[3]*cf[1]));
+ tsM[5] = sc*(-(cf[3]*cf[1] + cf[3]*cf[3] + cf[2] - 1.0)*cf[3]);
+ tsM[6] = sc*(cf[3]*cf[1] + cf[2] + cf[1]*cf[1] - cf[2]*cf[2]);
+ tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]);
+ tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
+
+#define YVV(L) \
+{ \
+W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0]; \
+W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0]; \
+W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0]; \
+for (i=3; i<L; i++) \
+W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3]; \
+tsu[0] = W[L-1] - X[L-1]; \
+tsu[1] = W[L-2] - X[L-1]; \
+tsu[2] = W[L-3] - X[L-1]; \
+tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1]; \
+tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1]; \
+tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1]; \
+Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2]; \
+Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1]; \
+Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0]; \
+for (i=L-4; i>=0; i--) \
+Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3]; \
+}
+
+ // intermediate buffers
+ sz = MAX2(src->getWidth(), src->getHeight());
+ X = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss X buf");
+ Y = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss Y buf");
+ W = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss W buf");
+ if (xy & 1) { // H
+ for (y=0; y<src->getHeight(); ++y) {
+ const int yx = y*src->getWidth();
+ for (x=0; x<src->getWidth(); ++x)
+ X[x] = buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan];
+ YVV(src->getWidth());
+ for (x=0; x<src->getWidth(); ++x)
+ buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan] = Y[x];
+ }
+ }
+ if (xy & 2) { // V
+ for (x=0; x<src->getWidth(); ++x) {
+ for (y=0; y<src->getHeight(); ++y)
+ X[y] = buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan];
+ YVV(src->getHeight());
+ for (y=0; y<src->getHeight(); ++y)
+ buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan] = Y[y];
+ }
+ }
+
+ MEM_freeN(X);
+ MEM_freeN(W);
+ MEM_freeN(Y);
+#undef YVV
+
+}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
new file mode 100644
index 00000000000..3e1d5416ca7
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_FastGaussianBlurOperation_h
+#define _COM_FastGaussianBlurOperation_h
+
+#include "COM_BlurBaseOperation.h"
+#include "DNA_node_types.h"
+
+class FastGaussianBlurOperation: public BlurBaseOperation {
+private:
+ float sx;
+ float sy;
+ bool iirgaus;
+public:
+ FastGaussianBlurOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
+
+};
+#endif
+
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
new file mode 100644
index 00000000000..afe3173ab0f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_FlipOperation.h"
+
+FlipOperation::FlipOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->flipX = true;
+ this->flipY = false;
+}
+void FlipOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void FlipOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
+
+void FlipOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float nx = this->flipX?this->getWidth()-1-x:x;
+ float ny = this->flipY?this->getHeight()-1-y:y;
+
+ this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
+}
+
+bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ if (this->flipX) {
+ newInput.xmax = (this->getWidth()- 1 - input->xmin)+1;
+ newInput.xmin = (this->getWidth()- 1 - input->xmax)-1;
+ } else {
+ newInput.xmin = input->xmin;
+ newInput.xmax = input->xmax;
+ }
+ if (this->flipY) {
+ newInput.ymax = (this->getHeight()- 1 - input->ymin)+1;
+ newInput.ymin = (this->getHeight()- 1 - input->ymax)-1;
+ } else {
+ newInput.ymin = input->ymin;
+ newInput.ymax = input->ymax;
+ }
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
new file mode 100644
index 00000000000..9774cfd7bcd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_FlipOperation_h_
+#define _COM_FlipOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class FlipOperation: public NodeOperation {
+private:
+ SocketReader *inputOperation;
+ bool flipX;
+ bool flipY;
+public:
+ FlipOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+ void setFlipX(bool flipX) {this->flipX = flipX;}
+ void setFlipY(bool flipY) {this->flipY = flipY;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp b/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
new file mode 100644
index 00000000000..a81597322a0
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FogGlowImageOperation.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_FogGlowImageOperation.h"
+#include "BLI_math.h"
+
+FogGlowImageOperation::FogGlowImageOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+void FogGlowImageOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
+
+ float u, v, w, d, r;
+
+ v = 2.f*(y / (float)512) - 1.f;
+ u = 2.f*(x / (float)512) - 1.f;
+ r = (u*u + v*v)*256;
+ d = -sqrtf(sqrtf(sqrtf(r)));
+ w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
+ color[0] = expf(d*cs_r) * w;
+ color[1] = expf(d*cs_g) * w;
+ color[2] = expf(d*cs_b) * w;
+ color[3] = 1.0f;
+}
+
+void FogGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = 512;
+ resolution[1] = 512;
+}
diff --git a/source/blender/compositor/operations/COM_FogGlowImageOperation.h b/source/blender/compositor/operations/COM_FogGlowImageOperation.h
new file mode 100644
index 00000000000..f68346eeb8d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_FogGlowImageOperation.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_FogGlowOperation_h
+#define _COM_FogGlowOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_lamp_types.h"
+
+class FogGlowImageOperation : public NodeOperation {
+public:
+ FogGlowImageOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
new file mode 100644
index 00000000000..c83c5d0ecb6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GammaCorrectOperation.h"
+#include "BLI_math.h"
+
+GammaCorrectOperation::GammaCorrectOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+}
+void GammaCorrectOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void GammaCorrectOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ this->inputProgram->read(inputColor, x, y, sampler, inputBuffers);
+ if (inputColor[3] > 0.0f) {
+ inputColor[0] /= inputColor[3];
+ inputColor[1] /= inputColor[3];
+ inputColor[2] /= inputColor[3];
+ }
+
+ /* check for negative to avoid nan's */
+ color[0] = inputColor[0]>0.0f?inputColor[0]*inputColor[0] :0.0f;
+ color[1] = inputColor[1]>0.0f?inputColor[1]*inputColor[1] :0.0f;
+ color[2] = inputColor[2]>0.0f?inputColor[2]*inputColor[2] :0.0f;
+
+ inputColor[0] *= inputColor[3];
+ inputColor[1] *= inputColor[3];
+ inputColor[2] *= inputColor[3];
+
+ color[0] = inputColor[0];
+ color[1] = inputColor[1];
+ color[2] = inputColor[2];
+ color[3] = inputColor[3];
+}
+
+void GammaCorrectOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
+GammaUncorrectOperation::GammaUncorrectOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+}
+void GammaUncorrectOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void GammaUncorrectOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor[4];
+ this->inputProgram->read(inputColor, x, y, sampler, inputBuffers);
+
+ if (inputColor[3] > 0.0f) {
+ inputColor[0] /= inputColor[3];
+ inputColor[1] /= inputColor[3];
+ inputColor[2] /= inputColor[3];
+ }
+
+ color[0] = inputColor[0]>0.0f?sqrtf(inputColor[0]) :0.0f;
+ color[1] = inputColor[1]>0.0f?sqrtf(inputColor[1]) :0.0f;
+ color[2] = inputColor[2]>0.0f?sqrtf(inputColor[2]) :0.0f;
+
+ inputColor[0] *= inputColor[3];
+ inputColor[1] *= inputColor[3];
+ inputColor[2] *= inputColor[3];
+
+ color[0] = inputColor[0];
+ color[1] = inputColor[1];
+ color[2] = inputColor[2];
+ color[3] = inputColor[3];
+}
+
+void GammaUncorrectOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
new file mode 100644
index 00000000000..bcf78f4508a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GammaCorrectOperation_h
+#define _COM_GammaCorrectOperation_h
+#include "COM_NodeOperation.h"
+
+
+class GammaCorrectOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+public:
+ GammaCorrectOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+
+class GammaUncorrectOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+public:
+ GammaUncorrectOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
new file mode 100644
index 00000000000..eaa56c2f31a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GammaOperation.h"
+#include "BLI_math.h"
+
+GammaOperation::GammaOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+ this->inputGammaProgram = NULL;
+}
+void GammaOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ this->inputGammaProgram = this->getInputSocketReader(1);
+}
+
+void GammaOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float inputGamma[4];
+
+ this->inputProgram->read(inputValue, x, y, sampler, inputBuffers);
+ this->inputGammaProgram->read(inputGamma, x, y, sampler, inputBuffers);
+ const float gamma = inputGamma[0];
+ /* check for negative to avoid nan's */
+ color[0] = inputValue[0]>0.0f?pow(inputValue[0], gamma):inputValue[0];
+ color[1] = inputValue[1]>0.0f?pow(inputValue[1], gamma):inputValue[1];
+ color[2] = inputValue[2]>0.0f?pow(inputValue[2], gamma):inputValue[2];
+
+ color[3] = inputValue[3];
+}
+
+void GammaOperation::deinitExecution() {
+ this->inputProgram = NULL;
+ this->inputGammaProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
new file mode 100644
index 00000000000..0fbbf58bad6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GammaOperation_h
+#define _COM_GammaOperation_h
+#include "COM_NodeOperation.h"
+
+
+class GammaOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+ SocketReader* inputGammaProgram;
+
+public:
+ GammaOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
new file mode 100644
index 00000000000..9b7df61143e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GaussianBokehBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+GaussianBokehBlurOperation::GaussianBokehBlurOperation(): BlurBaseOperation() {
+ this->gausstab = NULL;
+}
+
+void* GaussianBokehBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ updateGauss(memoryBuffers);
+ void* buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) {
+ if (this->gausstab == NULL) {
+ float radxf;
+ float radyf;
+ int n;
+ float* dgauss;
+ float* ddgauss;
+ float val;
+ int j, i;
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ updateSize(memoryBuffers);
+
+ radxf = size*(float)this->data->sizex;
+ if(radxf>width/2.0f)
+ radxf= width/2.0f;
+ else if(radxf<1.0f)
+ radxf= 1.0f;
+
+ /* vertical */
+ radyf = size*(float)this->data->sizey;
+ if(radyf>height/2.0f)
+ radyf= height/2.0f;
+ else if(radyf<1.0f)
+ radyf= 1.0f;
+
+ radx= ceil(radxf);
+ rady= ceil(radyf);
+
+ n = (2*radx+1)*(2*rady+1);
+
+ /* create a full filter image */
+ ddgauss= new float[n];
+ dgauss= ddgauss;
+ val= 0.0f;
+ for(j=-rady; j<=rady; j++) {
+ for(i=-radx; i<=radx; i++, dgauss++) {
+ float fj= (float)j/radyf;
+ float fi= (float)i/radxf;
+ float dist= sqrt(fj*fj + fi*fi);
+ *dgauss= RE_filter_value(this->data->filtertype, dist);
+
+ val+= *dgauss;
+ }
+ }
+ if(val!=0.0f) {
+ val= 1.0f/val;
+ for(j= n -1; j>=0; j--)
+ ddgauss[j]*= val;
+ }
+ else ddgauss[4]= 1.0f;
+
+ gausstab = ddgauss;
+ }
+}
+
+void GaussianBokehBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float tempColor[4];
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float overallmultiplyer = 0;
+ MemoryBuffer* inputBuffer = (MemoryBuffer*)data;
+ float* buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ int miny = y - this->rady;
+ int maxy = y + this->rady;
+ int minx = x - this->radx;
+ int maxx = x + this->radx;
+ miny = max(miny, inputBuffer->getRect()->ymin);
+ minx = max(minx, inputBuffer->getRect()->xmin);
+ maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax);
+
+ int index = 0;
+ int step = QualityStepHelper::getStep();
+ int offsetadd = QualityStepHelper::getOffsetAdd();
+ for (int ny = miny ; ny < maxy ; ny +=step) {
+ int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
+ for (int nx = minx ; nx < maxx ; nx +=step) {
+ float multiplyer = gausstab[index];
+ tempColor[0] += multiplyer * buffer[bufferindex];
+ tempColor[1] += multiplyer * buffer[bufferindex+1];
+ tempColor[2] += multiplyer * buffer[bufferindex+2];
+ tempColor[3] += multiplyer * buffer[bufferindex+3];
+ overallmultiplyer += multiplyer;
+ index += step;
+ bufferindex +=offsetadd;
+ }
+ }
+ float divider = 1.0/overallmultiplyer;
+ color[0] = tempColor[0]*divider;
+ color[1] = tempColor[1]*divider;
+ color[2] = tempColor[2]*divider;
+ color[3] = tempColor[3]*divider;
+}
+
+void GaussianBokehBlurOperation::deinitExecution() {
+ BlurBaseOperation::deinitExecution();
+ delete this->gausstab;
+ this->gausstab = NULL;
+}
+
+bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation * operation = this->getInputOperation(1);
+
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ } else {
+ if (this->gausstab) {
+ int addx = radx;
+ int addy = rady;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+ } else {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
+ return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+}
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
new file mode 100644
index 00000000000..806f77fd375
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehGaussianBokehBlurOperation_h
+#define _COM_GaussianBokehBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_BlurBaseOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class GaussianBokehBlurOperation : public BlurBaseOperation {
+private:
+ float* gausstab;
+ int radx, rady;
+ void updateGauss(MemoryBuffer **memoryBuffers);
+
+public:
+ GaussianBokehBlurOperation();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
new file mode 100644
index 00000000000..a93c0e44d18
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GaussianXBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+GaussianXBlurOperation::GaussianXBlurOperation(): BlurBaseOperation() {
+ this->gausstab = NULL;
+ this->rad = 0;
+
+}
+
+void* GaussianXBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ updateGauss(memoryBuffers);
+ void* buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) {
+ if (this->gausstab == NULL) {
+ updateSize(memoryBuffers);
+ float rad = size*this->data->sizex;
+ if(rad<1)
+ rad= 1;
+
+ this->rad = rad;
+ this->gausstab = BlurBaseOperation::make_gausstab(rad);
+ }
+}
+
+void GaussianXBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void *data) {
+
+ float tempColor[4];
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float overallmultiplyer = 0;
+ MemoryBuffer* inputBuffer = (MemoryBuffer*)data;
+ float* buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ int miny = y;
+ int maxy = y;
+ int minx = x - this->rad;
+ int maxx = x + this->rad;
+ miny = max(miny, inputBuffer->getRect()->ymin);
+ minx = max(minx, inputBuffer->getRect()->xmin);
+ maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax);
+
+ int index = 0;
+ int step = getStep();
+ int offsetadd = getOffsetAdd();
+ int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth);
+ for (int nx = minx ; nx < maxx ; nx +=step) {
+ float multiplyer = gausstab[index++];
+ tempColor[0] += multiplyer * buffer[bufferindex];
+ tempColor[1] += multiplyer * buffer[bufferindex+1];
+ tempColor[2] += multiplyer * buffer[bufferindex+2];
+ tempColor[3] += multiplyer * buffer[bufferindex+3];
+ overallmultiplyer += multiplyer;
+ bufferindex +=offsetadd;
+ }
+ float divider = 1.0/overallmultiplyer;
+ color[0] = tempColor[0]*divider;
+ color[1] = tempColor[1]*divider;
+ color[2] = tempColor[2]*divider;
+ color[3] = tempColor[3]*divider;
+}
+
+void GaussianXBlurOperation::deinitExecution() {
+ BlurBaseOperation::deinitExecution();
+ delete this->gausstab;
+ this->gausstab = NULL;
+}
+
+bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation * operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }else {
+ if (this->gausstab == NULL) {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }else{
+ newInput.xmax = input->xmax + rad;
+ newInput.xmin = input->xmin - rad;
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+}
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
new file mode 100644
index 00000000000..6b6eb4d80f9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GaussianXBlurOperation_h
+#define _COM_GaussianXBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_BlurBaseOperation.h"
+
+class GaussianXBlurOperation : public BlurBaseOperation {
+private:
+ float* gausstab;
+ int rad;
+ void updateGauss(MemoryBuffer **memoryBuffers);
+public:
+ GaussianXBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
new file mode 100644
index 00000000000..86f9dbf5c40
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GaussianYBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+GaussianYBlurOperation::GaussianYBlurOperation(): BlurBaseOperation() {
+ this->gausstab = NULL;
+ this->rad = 0;
+}
+
+void* GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ updateGauss(memoryBuffers);
+ void* buffer = getInputOperation(0)->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers) {
+ if (this->gausstab == NULL) {
+ updateSize(memoryBuffers);
+ float rad = size*this->data->sizey;
+ if(rad<1)
+ rad= 1;
+
+ this->rad = rad;
+ this->gausstab = BlurBaseOperation::make_gausstab(rad);
+ }
+}
+
+void GaussianYBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void *data) {
+
+ float tempColor[4];
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float overallmultiplyer = 0;
+ MemoryBuffer* inputBuffer = (MemoryBuffer*)data;
+ float* buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ int miny = y - this->rad;
+ int maxy = y + this->rad;
+ int minx = x;
+ int maxx = x;
+ miny = max(miny, inputBuffer->getRect()->ymin);
+ minx = max(minx, inputBuffer->getRect()->xmin);
+ maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax);
+
+ int step = getStep();
+ int index = 0;
+ for (int ny = miny ; ny < maxy ; ny +=step) {
+ int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
+ float multiplyer = gausstab[index++];
+ tempColor[0] += multiplyer * buffer[bufferindex];
+ tempColor[1] += multiplyer * buffer[bufferindex+1];
+ tempColor[2] += multiplyer * buffer[bufferindex+2];
+ tempColor[3] += multiplyer * buffer[bufferindex+3];
+ overallmultiplyer += multiplyer;
+ }
+ float divider = 1.0/overallmultiplyer;
+ color[0] = tempColor[0]*divider;
+ color[1] = tempColor[1]*divider;
+ color[2] = tempColor[2]*divider;
+ color[3] = tempColor[3]*divider;
+}
+
+void GaussianYBlurOperation::deinitExecution() {
+ BlurBaseOperation::deinitExecution();
+ delete this->gausstab;
+ this->gausstab = NULL;
+}
+
+bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation * operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }else {
+ if (this->gausstab == NULL) {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ } else {
+ newInput.xmax = input->xmax;
+ newInput.xmin = input->xmin;
+ newInput.ymax = input->ymax + rad;
+ newInput.ymin = input->ymin - rad;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+}
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
new file mode 100644
index 00000000000..5c116e80a71
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GaussianYBlurOperation_h
+#define _COM_GaussianYBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_BlurBaseOperation.h"
+
+class GaussianYBlurOperation : public BlurBaseOperation {
+private:
+ float* gausstab;
+ int rad;
+ void updateGauss(MemoryBuffer **memoryBuffers);
+public:
+ GaussianYBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
new file mode 100644
index 00000000000..b86c61ea9da
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareBaseOperation.h"
+#include "BLI_math.h"
+
+GlareBaseOperation::GlareBaseOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->settings = NULL;
+ this->cachedInstance = NULL;
+ setComplex(true);
+}
+void GlareBaseOperation::initExecution() {
+ initMutex();
+ this->inputProgram = getInputSocketReader(0);
+ this->cachedInstance = NULL;
+}
+
+void GlareBaseOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float* buffer = (float*) data;
+ int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
+ color[0] = buffer[index];
+ color[1] = buffer[index+1];
+ color[2] = buffer[index+2];
+ color[3] = buffer[index+3];
+}
+
+void GlareBaseOperation::deinitExecution() {
+ deinitMutex();
+ this->inputProgram = NULL;
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ this->cachedInstance = NULL;
+ }
+}
+void* GlareBaseOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ BLI_mutex_lock(getMutex());
+ if (this->cachedInstance == NULL) {
+ MemoryBuffer* tile = (MemoryBuffer*)inputProgram->initializeTileData(rect, memoryBuffers);
+ float* data = new float[this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS];
+ this->generateGlare(data, tile, this->settings);
+ this->cachedInstance = data;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->cachedInstance;
+}
+
+bool GlareBaseOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
new file mode 100644
index 00000000000..4233e6150a2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareBaseOperation_h
+#define _COM_GlareBaseOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+class GlareBaseOperation : public NodeOperation {
+private:
+ /**
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+ /**
+ * @brief settings of the glare node.
+ */
+ NodeGlare * settings;
+
+ float* cachedInstance;
+
+public:
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void setGlareSettings(NodeGlare * settings) {this->settings = settings;}
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+protected:
+ GlareBaseOperation();
+
+ virtual void generateGlare(float* data, MemoryBuffer* inputTile, NodeGlare* settings) = 0;
+
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
new file mode 100644
index 00000000000..ce3fd82acf0
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareSimpleStarOperation.h"
+
+void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) {
+ int i, x, y, ym, yp, xm, xp;
+ float c[4] = {0,0,0,0}, tc[4] = {0,0,0,0};
+ const float f1 = 1.f - settings->fade, f2 = (1.f - f1)*0.5f;
+
+
+ MemoryBuffer* tbuf1 = inputTile->duplicate();
+ MemoryBuffer* tbuf2 = inputTile->duplicate();
+
+ for (i=0; i<settings->iter; i++) {
+// // (x || x-1, y-1) to (x || x+1, y+1)
+// // F
+ for (y=0; y<this->getHeight(); y++) {
+ ym = y - i;
+ yp = y + i;
+ for (x=0; x<this->getWidth(); x++) {
+ xm = x - i;
+ xp = x + i;
+ tbuf1->read(c, x, y);
+ c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ tbuf1->read(tc, (settings->angle ? xm : x), ym);
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ tbuf1->read(tc, (settings->angle ? xp : x), yp);
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ c[3] = 1.0f;
+ tbuf1->writePixel(x, y, c);
+
+ tbuf2->read(c, x, y);
+ c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ tbuf2->read(tc, xm, (settings->angle ? yp : y));
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ tbuf2->read(tc, xp, (settings->angle ? ym : y));
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ c[3] = 1.0f;
+ tbuf2->writePixel(x, y, c);
+
+ }
+ }
+// // B
+ for (y=tbuf1->getHeight()-1; y>=0; y--) {
+ ym = y - i;
+ yp = y + i;
+ for (x=tbuf1->getWidth()-1; x>=0; x--) {
+ xm = x - i;
+ xp = x + i;
+ tbuf1->read(c, x, y);
+ c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ tbuf1->read(tc, (settings->angle ? xm : x), ym);
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ tbuf1->read(tc, (settings->angle ? xp : x), yp);
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ c[3] = 1.0f;
+ tbuf1->writePixel(x, y, c);
+
+ tbuf2->read(c, x, y);
+ c[0]*=f1; c[1]*=f1 ; c[2] *=f1;
+ tbuf2->read(tc, xm, (settings->angle ? yp : y));
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ tbuf2->read(tc, xp, (settings->angle ? ym : y));
+ c[0]+=tc[0]*f2;
+ c[1]+=tc[1]*f2;
+ c[2]+=tc[2]*f2;
+ c[3] = 1.0f;
+ tbuf2->writePixel(x, y, c);
+ }
+ }
+ }
+
+ for (i = 0 ; i < this->getWidth()*this->getHeight()*4 ; i++) {
+ data[i] = tbuf1->getBuffer()[i] + tbuf2->getBuffer()[i];
+ }
+
+ delete tbuf1;
+ delete tbuf2;
+}
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
new file mode 100644
index 00000000000..22040da9bc5
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareSimpleStarOperation_h
+#define _COM_GlareSimpleStarOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_GlareBaseOperation.h"
+
+class GlareSimpleStarOperation : public GlareBaseOperation {
+public:
+ GlareSimpleStarOperation() : GlareBaseOperation() {}
+protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
new file mode 100644
index 00000000000..177bb6e0730
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareStreaksOperation.h"
+#include "BLI_math.h"
+
+void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) {
+ int x, y, n;
+ unsigned int nump=0;
+ float c1[4], c2[4], c3[4], c4[4];
+ float a, ang = DEG2RADF(360.0f)/(float)settings->angle;
+
+ int size = inputTile->getWidth()*inputTile->getHeight();
+ int size4 = size*4;
+
+
+ MemoryBuffer* tsrc = inputTile->duplicate();
+ MemoryBuffer* tdst = new MemoryBuffer(NULL, inputTile->getRect());
+ tdst->clear();
+ memset(data, 0, size4*sizeof(float));
+
+ for (a=0.f; a<DEG2RADF(360.0f); a+=ang) {
+ const float an = a + settings->angle_ofs;
+ const float vx = cos((double)an), vy = sin((double)an);
+ for (n=0; n<settings->iter; ++n) {
+ const float p4 = pow(4.0, (double)n);
+ const float vxp = vx*p4, vyp = vy*p4;
+ const float wt = pow((double)settings->fade, (double)p4);
+ const float cmo = 1.f - (float)pow((double)settings->colmod, (double)n+1); // colormodulation amount relative to current pass
+ float* tdstcol = tdst->getBuffer();
+ for (y=0; y<tsrc->getHeight(); ++y) {
+ for (x=0; x<tsrc->getWidth(); ++x, tdstcol+=4) {
+ // first pass no offset, always same for every pass, exact copy,
+ // otherwise results in uneven brightness, only need once
+ if (n==0) tsrc->read(c1, x, y); else c1[0]=c1[1]=c1[2]=0;
+ tsrc->readCubic(c2, x + vxp, y + vyp);
+ tsrc->readCubic(c3, x + vxp*2.f, y + vyp*2.f);
+ tsrc->readCubic(c4, x + vxp*3.f, y + vyp*3.f);
+ // modulate color to look vaguely similar to a color spectrum
+ c2[1] *= cmo;
+ c2[2] *= cmo;
+
+ c3[0] *= cmo;
+ c3[1] *= cmo;
+
+ c4[0] *= cmo;
+ c4[2] *= cmo;
+
+ tdstcol[0] = 0.5f*(tdstcol[0] + c1[0] + wt*(c2[0] + wt*(c3[0] + wt*c4[0])));
+ tdstcol[1] = 0.5f*(tdstcol[1] + c1[1] + wt*(c2[1] + wt*(c3[1] + wt*c4[1])));
+ tdstcol[2] = 0.5f*(tdstcol[2] + c1[2] + wt*(c2[2] + wt*(c3[2] + wt*c4[2])));
+ tdstcol[3] = 1.0f;
+ }
+ }
+ memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float)*size4);
+ }
+
+// addImage(sbuf, tsrc, 1.f/(float)(6 - ndg->iter)); // add result to data @todo
+ float* sourcebuffer = tsrc->getBuffer();
+ float factor = 1.f/(float)(6 - settings->iter);
+ for (int i = 0 ; i < size4; i ++) {
+ data[i] += sourcebuffer[i] * factor;
+ }
+ for (int i = 0 ; i < size; i ++) {
+ data[i*4+3] = 1.0f;
+ }
+
+ tdst->clear();
+ memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float)*size4);
+ nump++;
+ }
+
+ delete tsrc;
+ delete tdst;
+}
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
new file mode 100644
index 00000000000..07155a4713a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareStreaksOperation_h
+#define _COM_GlareStreaksOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_GlareBaseOperation.h"
+
+class GlareStreaksOperation : public GlareBaseOperation {
+public:
+ GlareStreaksOperation() : GlareBaseOperation() {}
+protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
new file mode 100644
index 00000000000..cc8bda2730e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_GlareThresholdOperation.h"
+#include "BLI_math.h"
+
+GlareThresholdOperation::GlareThresholdOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+}
+void GlareThresholdOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void GlareThresholdOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ this->inputProgram->read(color, x, y, sampler, inputBuffers);
+ if ((0.212671f*color[0] + 0.71516f*color[1] + 0.072169f*color[2]) >= threshold) {
+ color[0] -= threshold, color[1] -= threshold, color[2] -= threshold;
+ color[0] = MAX2(color[0], 0.f);
+ color[1] = MAX2(color[1], 0.f);
+ color[2] = MAX2(color[2], 0.f);
+ }
+ else color[0] = color[1] = color[2] = 0.f;
+}
+
+void GlareThresholdOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
new file mode 100644
index 00000000000..3d68181ae47
--- /dev/null
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_GlareScaleOperation_h
+#define _COM_GlareScaleOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_lamp_types.h"
+
+class GlareThresholdOperation : public NodeOperation {
+private:
+ /**
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+ float threshold;
+
+public:
+ GlareThresholdOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setThreshold(float threshold) {this->threshold = threshold;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
new file mode 100644
index 00000000000..d5d577e91a9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_HueSaturationValueCorrectOperation.h"
+
+#include "BLI_math.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "BKE_colortools.h"
+#ifdef __cplusplus
+}
+#endif
+
+HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation(): CurveBaseOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputProgram = NULL;
+}
+void HueSaturationValueCorrectOperation::initExecution() {
+ CurveBaseOperation::initExecution();
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void HueSaturationValueCorrectOperation::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float hsv[4], f;
+
+ this->inputProgram->read(hsv, x, y, sampler, inputBuffers);
+
+ /* adjust hue, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->curveMapping, 0, hsv[0]);
+ hsv[0] += f-0.5f;
+
+ /* adjust saturation, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->curveMapping, 1, hsv[0]);
+ hsv[1] *= (f * 2.f);
+
+ /* adjust value, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->curveMapping, 2, hsv[0]);
+ hsv[2] *= (f * 2.f);
+
+ hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */
+ CLAMP(hsv[1], 0.f, 1.f);
+
+ output[0]= hsv[0];
+ output[1]= hsv[1];
+ output[2]= hsv[2];
+ output[3]= hsv[3];
+}
+
+void HueSaturationValueCorrectOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
new file mode 100644
index 00000000000..472a85f5531
--- /dev/null
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_HueSaturationValueCorrectOperation_h
+#define _COM_HueSaturationValueCorrectOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_CurveBaseOperation.h"
+
+class HueSaturationValueCorrectOperation : public CurveBaseOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+public:
+ HueSaturationValueCorrectOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* Vector, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
new file mode 100644
index 00000000000..198248e35a3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_IDMaskOperation.h"
+
+IDMaskOperation::IDMaskOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputProgram = NULL;
+}
+void IDMaskOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void IDMaskOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+
+ this->inputProgram->read(inputValue, x, y, sampler, inputBuffers);
+ const float a = (inputValue[0] == this->objectIndex)?1.0f:0.0f;
+ color[0] = a;
+}
+
+void IDMaskOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
new file mode 100644
index 00000000000..3b22be16d8a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_IDMaskOperation_h
+#define _COM_IDMaskOperation_h
+#include "COM_NodeOperation.h"
+
+
+class IDMaskOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputProgram;
+
+ float objectIndex;
+public:
+ IDMaskOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setObjectIndex(float objectIndex) {this->objectIndex = objectIndex;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
new file mode 100644
index 00000000000..52c2e44f7d4
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ImageOperation.h"
+
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "DNA_image_types.h"
+#include "BKE_image.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+BaseImageOperation::BaseImageOperation(): NodeOperation() {
+ this->image = NULL;
+ this->buffer = NULL;
+ this->imageBuffer = NULL;
+ this->imageUser = NULL;
+ this->imagewidth = 0;
+ this->imageheight = 0;
+ this->framenumber = 0;
+ this->depthBuffer = NULL;
+ this->numberOfChannels = 0;
+}
+ImageOperation::ImageOperation(): BaseImageOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+ImageAlphaOperation::ImageAlphaOperation(): BaseImageOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+ImageDepthOperation::ImageDepthOperation(): BaseImageOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+
+ImBuf* BaseImageOperation::getImBuf() {
+ ImBuf *ibuf;
+
+ ibuf= BKE_image_get_ibuf(this->image, this->imageUser);
+ if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) {
+ return NULL;
+ }
+
+ if (ibuf->rect_float == NULL) {
+ IMB_float_from_rect(ibuf);
+ }
+ return ibuf;
+}
+
+
+void BaseImageOperation::initExecution() {
+ ImBuf *stackbuf= getImBuf();
+ this->buffer = stackbuf;
+ if (stackbuf) {
+ this->imageBuffer = stackbuf->rect_float;
+ this->depthBuffer = stackbuf->zbuf_float;
+ this->imagewidth = stackbuf->x;
+ this->imageheight = stackbuf->y;
+ this->numberOfChannels = stackbuf->channels;
+ }
+}
+
+void BaseImageOperation::deinitExecution() {
+ this->imageBuffer= NULL;
+}
+
+void BaseImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ ImBuf *stackbuf= getImBuf();
+ if (stackbuf) {
+ resolution[0] = stackbuf->x;
+ resolution[1] = stackbuf->y;
+ }
+}
+
+void ImageOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+ } else {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ }
+ }
+}
+
+void ImageAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float tempcolor[4];
+
+ if (this->imageBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+ color[0] = 0.0f;
+ } else {
+ tempcolor[3] = 1.0f;
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, tempcolor, x, y);
+ break;
+ }
+ color[0] = tempcolor[3];
+ }
+}
+
+void ImageDepthOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ if (this->depthBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+ color[0] = 0.0f;
+ } else {
+ int offset = y * width + x;
+ color[0] = this->depthBuffer[offset];
+ }
+}
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
new file mode 100644
index 00000000000..a5e2c753b59
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+
+#ifndef _COM_ImageOperation_h
+#define _COM_ImageOperation_h
+
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "BLI_listbase.h"
+#include "BKE_image.h"
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+ #include "MEM_guardedalloc.h"
+}
+
+/**
+ * @brief Base class for all image operations
+ */
+class BaseImageOperation : public NodeOperation {
+protected:
+ ImBuf* buffer;
+ Image* image;
+ ImageUser* imageUser;
+ float *imageBuffer;
+ float *depthBuffer;
+ int imageheight;
+ int imagewidth;
+ int framenumber;
+ int numberOfChannels;
+
+ BaseImageOperation();
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ virtual ImBuf* getImBuf();
+
+public:
+
+ void initExecution();
+ void deinitExecution();
+ void setImage(Image* image) {this->image = image;}
+ void setImageUser(ImageUser* imageuser) {this->imageUser = imageuser;}
+
+ void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+};
+class ImageOperation: public BaseImageOperation {
+public:
+ /**
+ * Constructor
+ */
+ ImageOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class ImageAlphaOperation: public BaseImageOperation {
+public:
+ /**
+ * Constructor
+ */
+ ImageAlphaOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class ImageDepthOperation: public BaseImageOperation {
+public:
+ /**
+ * Constructor
+ */
+ ImageDepthOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
new file mode 100644
index 00000000000..a90c7b6b8d2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_InvertOperation.h"
+
+InvertOperation::InvertOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputValueProgram = NULL;
+ this->inputColorProgram = NULL;
+ this->color = true;
+ this->alpha = false;
+ setResolutionInputSocketIndex(1);
+}
+void InvertOperation::initExecution() {
+ this->inputValueProgram = this->getInputSocketReader(0);
+ this->inputColorProgram = this->getInputSocketReader(1);
+}
+
+void InvertOperation::executePixel(float* out, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue[4];
+ float inputColor[4];
+ this->inputValueProgram->read(inputValue, x, y, sampler, inputBuffers);
+ this->inputColorProgram->read(inputColor, x, y, sampler, inputBuffers);
+
+ const float value = inputValue[0];
+ const float invertedValue = 1.0f - value;
+
+ if(color) {
+ out[0] = (1.0f - inputColor[0])*value + inputColor[0]*invertedValue;
+ out[1] = (1.0f - inputColor[1])*value + inputColor[1]*invertedValue;
+ out[2] = (1.0f - inputColor[2])*value + inputColor[2]*invertedValue;
+ } else {
+ out[0] = inputColor[0];
+ out[1] = inputColor[1];
+ out[2] = inputColor[2];
+ }
+
+ if(alpha)
+ out[3] = (1.0f - inputColor[3])*value + inputColor[3]*invertedValue;
+ else
+ out[3] = inputColor[3];
+
+}
+
+void InvertOperation::deinitExecution() {
+ this->inputValueProgram = NULL;
+ this->inputColorProgram = NULL;
+}
+
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
new file mode 100644
index 00000000000..6baa10a3d62
--- /dev/null
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_InvertOperation_h
+#define _COM_InvertOperation_h
+#include "COM_NodeOperation.h"
+
+
+class InvertOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputValueProgram;
+ SocketReader * inputColorProgram;
+
+ bool alpha;
+ bool color;
+
+public:
+ InvertOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setColor(bool color) {this->color = color;}
+ void setAlpha(bool alpha) {this->alpha = alpha;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_LensGhostOperation.cpp b/source/blender/compositor/operations/COM_LensGhostOperation.cpp
new file mode 100644
index 00000000000..eb957ca4756
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGhostOperation.cpp
@@ -0,0 +1,792 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_LensGhostOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#define MAX_STEP 256
+class Ray {
+public:
+ float position[3];
+ float direction[3];
+ float uv[2];
+ double wavelength;
+ float intensity;
+ bool valid;
+ void copyFrom(Ray* other) {
+ copy_v3_v3(position, other->position);
+ copy_v3_v3(direction, other->direction);
+ copy_v2_v2(uv, other->uv);
+ wavelength = other->wavelength;
+ intensity = other->intensity;
+ this->valid = other->valid;
+ }
+};
+
+class Intersection {
+public:
+ float position[3];
+ float normal[3];
+ double theta;
+ bool hit;
+ bool inverted;
+};
+
+class LensInterface {
+public:
+ float position[3];
+ float radius;
+ float nominalRadius;
+ double refraction1;
+ double refraction2;
+ double refraction3;
+ float thicknessCoathing;
+ virtual bool isFlat() = 0;
+ virtual void intersect(Intersection* result, Ray* ray) = 0;
+};
+
+class FlatInterface: public LensInterface {
+public:
+ bool isFlat() {return true;}
+ FlatInterface(float positionX, float positionY, float positionZ, float radius) {
+ this->position[0] = positionX;
+ this->position[1] = positionY;
+ this->position[2] = positionZ;
+ this->radius = radius;
+ this->nominalRadius = radius;
+ this->refraction1 = 1.0f;
+ this->refraction2 = 1.0f;
+ this->refraction3 = 1.0f;
+ this->thicknessCoathing = 0.0f;
+
+ }
+ void intersect(Intersection* result, Ray* ray) {
+ const float dz = this->position[2]-ray->position[2];
+ result->position[0] = ray->position[0] + ray->direction[0]*(dz)/ray->direction[2];
+ result->position[1] = ray->position[1] + ray->direction[1]*(dz)/ray->direction[2];
+ result->position[2] = ray->position[2] + ray->direction[2]*(dz)/ray->direction[2];
+ result->normal[0] = 0.0f;
+ result->normal[1] = 0.0f;
+ result->normal[2] = ray->direction[2]>0?-1.0f:1.0f;
+ result->theta = 0.0f;
+// result->hit = this->nominalRadius>maxf(fabs(result->position[0]), fabs(result->position[1]));
+ result->hit = true;
+ result->inverted = false;
+ }
+};
+
+class SphereInterface: public LensInterface {
+public:
+ SphereInterface(float positionX, float positionY, float positionZ, float radius, float nominalRadius, float n0, float n2, float coatingPhase) {
+ this->position[0] = positionX;
+ this->position[1] = positionY;
+ this->position[2] = positionZ;
+ this->radius = radius;
+ this->nominalRadius = nominalRadius;
+ this->refraction1 = n0;
+ this->refraction3 = n2;
+ this->refraction2 = maxf(sqrtf(n0*n2), 1.38);
+
+ this->thicknessCoathing = coatingPhase/4/this->refraction2;
+ }
+ bool isFlat() {return false;}
+ void intersect(Intersection* result, Ray* ray) {
+ float delta[3] ={ray->position[0] - this->position[0],
+ ray->position[1] - this->position[1],
+ ray->position[2] - this->position[2]};
+ float b = dot_v3v3(delta, ray->direction);
+ float c = dot_v3v3(delta, delta) - this->radius*this->radius;
+ float b2c = b*b-c;
+ if (b2c < 0) {
+ result->hit = false;
+ } else {
+ float sgn = (this->radius*ray->direction[2])>0?1.0f:-1.0f;
+ float t = sqrtf(b2c)*sgn-b;
+ result->position[0] = ray->direction[0]*t+ray->position[0];
+ result->position[1] = ray->direction[1]*t+ray->position[1];
+ result->position[2] = ray->direction[2]*t+ray->position[2];
+
+ float p[3] = {
+ result->position[0] - this->position[0],
+ result->position[1] - this->position[1],
+ result->position[2] - this->position[2]
+ };
+ normalize_v3(p);
+
+ if (dot_v3v3(p, ray->direction)> 0) {
+ result->normal[0] = -p[0];
+ result->normal[1] = -p[1];
+ result->normal[2] = -p[2];
+ } else {
+ result->normal[0] = p[0];
+ result->normal[1] = p[1];
+ result->normal[2] = p[2];
+ }
+
+ float inverse[3] ={
+ -ray->direction[0],
+ -ray->direction[1],
+ -ray->direction[2]};
+
+ result->theta = acosf(dot_v3v3(inverse, result->normal));
+ result->hit = this->nominalRadius>sqrt(result->position[0]*result->position[0]+result->position[1]*result->position[1]);
+// result->hit = this->nominalRadius>maxf(fabs(result->position[0]), fabs(result->position[1]));
+// result->hit = true;
+ result->inverted = t < 0;
+ }
+ }
+};
+class RayResult {
+public:
+ float x;
+ float y;
+ float intensity[3];
+ float u;
+ float v;
+ float screenX;
+ float screenY;
+ bool valid;
+ bool hasIntensity;
+};
+class Bounce{
+public:
+ LensInterface *interface1;
+ LensInterface *interface2;
+ RayResult *raster;
+ int length; // number of interfaces to travel
+ int rasterLength;
+ Bounce(LensInterface *interface1, LensInterface *interface2, int length, int rasterStep) {
+ this->interface1 = interface1;
+ this->interface2 = interface2;
+ this->length = length;
+ this->rasterLength = rasterStep;
+ this->raster = new RayResult[rasterLength*rasterLength];
+ for (int i = 0 ; i < rasterLength*rasterLength ; i++) {
+ RayResult * res = &this->raster[i];
+ res->intensity[0] = 0.0f;
+ res->intensity[1] = 0.0f;
+ res->intensity[2] = 0.0f;
+ res->x = 0.0f;
+ res->y = 0.0f;
+ res->u = 0.0f;
+ res->v = 0.0f;
+ res->valid = false;
+ }
+ }
+ ~Bounce() {
+ delete raster;
+
+ }
+
+ RayResult* getRayResult(int x, int y) {
+ return &(raster[x+y*rasterLength]);
+ }
+};
+class LensSystem {
+public:
+ vector<LensInterface*> interfaces;
+ vector<Bounce*> bounces;
+ int bokehIndex;
+ int lensIndex;
+
+ ~LensSystem() {
+ for (int index = 0 ; index <bounces.size();index++) {delete bounces[index];}
+ for (int index = 0 ; index <interfaces.size();index++) {delete interfaces[index];}
+ }
+
+ void updateBounces(int step) {
+ for (int i = 0; i < interfaces.size()-1 ; i ++) {
+ if (!interfaces[i]->isFlat()) {
+ for (int j = i+1; j < interfaces.size()-1 ; j ++) {
+ if (!interfaces[j]->isFlat()) {
+ int length = interfaces.size()+2*(j-i);
+ Bounce* bounce = new Bounce(interfaces[j], interfaces[i], length, step);
+ bounces.push_back(bounce);
+ }
+ }
+ }
+ }
+
+ }
+
+ void addInterface(LensInterface* interface) {
+ this->interfaces.push_back(interface);
+ this->lensIndex = this->interfaces.size()-1;
+ }
+
+ static int refraction(float *refract, float *n, float *view, double index)
+ {
+
+ return 1;
+
+// float dot, fac;
+
+// VECCOPY(refract, view);
+
+// dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2];
+
+// if(dot>0.0f) {
+// index = 1.0f/index;
+// fac= 1.0f - (1.0f - dot*dot)*index*index;
+// if(fac<= 0.0f) return 0;
+// fac= -dot*index + sqrt(fac);
+// }
+// else {
+// fac= 1.0f - (1.0f - dot*dot)*index*index;
+// if(fac<= 0.0f) return 0;
+// fac= -dot*index - sqrt(fac);
+// }
+
+// refract[0]= index*view[0] + fac*n[0];
+// refract[1]= index*view[1] + fac*n[1];
+// refract[2]= index*view[2] + fac*n[2];
+
+// normalize_v3(refract);
+// return 1;
+ //---
+// const double cosI = dot_v3v3(n, view);
+// const double sinT2 = index * index * (1.0 - cosI * cosI);
+// if (sinT2 >= 1.0f)
+// {
+// return 0;
+// }
+// refract[0] = index*view[0] - (index + sqrt(1.0-sinT2))*n[0];
+// refract[1] = index*view[1] - (index + sqrt(1.0-sinT2))*n[1];
+// refract[2] = index*view[2] - (index + sqrt(1.0-sinT2))*n[2];
+// normalize_v3(refract);
+// return 1;
+ //---
+
+// double ni = -dot_v3v3(view, n);
+// double test = 1.0f - index*index*(1.0f-ni*ni);
+// if (test < 0) {
+// return 0;
+// } else {
+// double mul = index*ni + sqrt(test);
+// refract[0] = index * view[0] - mul*n[0];
+// refract[1] = index * view[1] - mul*n[1];
+// refract[2] = index * view[2] - mul*n[2];
+// normalize_v3(refract);
+// return 1;
+// }
+ }
+
+ /* orn = original face normal */
+ static void reflection(float *ref, float *n, float *view)
+ {
+ float f1;
+
+ f1= -2.0f*dot_v3v3(n, view);
+
+ ref[0]= (view[0]+f1*n[0]);
+ ref[1]= (view[1]+f1*n[1]);
+ ref[2]= (view[2]+f1*n[2]);
+ normalize_v3(ref);
+ }
+
+ static float fresnelAR(float theta0, float lambda, float d1, float n0, float n1, float n2) {
+ // refractionangles in coating and the 2nd medium
+ float theta1 = asin(sin(theta0)*n0/n1);
+ float theta2 = asin(sin(theta0)*n0/n2);
+
+ float rs01 = -sin(theta0-theta1)/sin(theta0+theta1);
+ float rp01 = tan( theta0-theta1)/tan(theta0+theta1);
+ float ts01 = 2 * sin ( theta1 ) * cos ( theta0 ) / sin ( theta0+theta1 ) ;
+ float tp01 = ts01*cos(theta0-theta1);
+ // amplitude for inner reflection
+ float rs12 = -sin ( theta1-theta2 ) / sin ( theta1+theta2 ) ;
+ float rp12 = +tan ( theta1-theta2 ) / tan ( theta1+theta2 ) ;
+ // after passing through first surface twice :
+ // 2 transmissions and 1 reflection
+ float ris = ts01 * ts01 * rs12 ;
+ float rip = tp01 * tp01 * rp12 ;
+ // phase difference between outer and inner reflections
+ float dy = d1 * n1 ;
+ float dx = tan ( theta1 ) * dy ;
+ float delay = sqrt ( dx * dx+dy * dy ) ;
+ float relPhase = 4 * M_PI / lambda * ( delay-dx * sin ( theta0 ) ) ;
+ // Add up sines of different phase and amplitude
+ float out_s2 = rs01 * rs01 + ris * ris + 2 * rs01 * ris * cos ( relPhase ) ;
+ float out_p2 = rp01 * rp01 + rip * rip + 2 * rp01 * rip * cos ( relPhase ) ;
+ return ( out_s2+out_p2 ) / 2 ;
+ }
+
+ void detectHit(Ray* result, Ray* inputRay, Bounce *bounce) {
+ int phase = 0;
+ int delta = 1;
+ int t = 1;
+ int k;
+ result->copyFrom(inputRay);
+ result->valid = false;
+ LensInterface* next = bounce->interface1;
+ LensInterface* f = NULL;
+ Intersection intersection;
+ for (k = 0 ; k < bounce->length-1;k++, t+=delta) {
+ f = this->interfaces[t];
+ bool breflect = next == f;
+ if (breflect) {
+ delta = -delta;
+ if (phase == 0) {
+ next = bounce->interface2;
+ } else {
+ next = NULL;
+ }
+ phase ++;
+ }
+
+ f->intersect(&intersection, result);
+ if (!intersection.hit) {
+ break;
+ }
+ if (f->isFlat()) {
+ if (t == this->bokehIndex) {
+ result->uv[0] = intersection.position[0]/f->nominalRadius;
+ result->uv[1] = intersection.position[1]/f->nominalRadius;
+ }
+ }
+
+ float p[3] = {
+ intersection.position[0]-result->position[0],
+ intersection.position[1]-result->position[1],
+ intersection.position[2]-result->position[2]
+ };
+
+ float nfac = sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
+
+ if (intersection.inverted) {
+ nfac *= -1;
+ }
+
+ result->direction[0] = p[0]/nfac;
+ result->direction[1] = p[1]/nfac;
+ result->direction[2] = p[2]/nfac;
+ result->position[0] = intersection.position[0];
+ result->position[1] = intersection.position[1];
+ result->position[2] = intersection.position[2];
+
+ if (!f->isFlat()) {
+ // do refraction and reflection
+ double n0 = result->direction[2]<0?f->refraction1:f->refraction3;
+ double n1 = f->refraction2;
+ double n2 = result->direction[2]<0?f->refraction3:f->refraction1;
+ if (!breflect) {
+ float view[3] ={
+ result->direction[0],
+ result->direction[1],
+ result->direction[2]
+ };
+ int ref = this->refraction(result->direction, intersection.normal, view, n0/n1);
+ if (ref == 0) {
+ break;
+ }
+ } else {
+ this->reflection(result->direction, intersection.normal, result->direction);
+ float fresnelMultiplyer = fresnelAR(intersection.theta, result->wavelength, f->thicknessCoathing, n0, n1, n2);
+ if (isnan(fresnelMultiplyer)) {
+ fresnelMultiplyer = 0.0f;
+ }
+ result->intensity *= fresnelMultiplyer;
+ }
+ }
+
+ }
+ if (k < bounce->length-1) {
+ result->intensity = 0;
+ } else {
+ result->valid = true;
+ }
+ }
+};
+
+typedef struct LensFace {
+ RayResult* v1;
+ RayResult* v2;
+ RayResult* v3;
+} LensFace;
+
+LensGhostProjectionOperation::LensGhostProjectionOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->lampObject = NULL;
+ this->cameraObject = NULL;
+ this->system = NULL;
+ this->quality = COM_QUALITY_HIGH;
+ this->setComplex(false);
+}
+
+LensGhostOperation::LensGhostOperation(): LensGhostProjectionOperation() {
+ this->setComplex(true);
+
+}
+
+void LensGhostProjectionOperation::initExecution() {
+ if (this->cameraObject != NULL && this->lampObject != NULL) {
+ if (lampObject == NULL || cameraObject == NULL) {
+ visualLampPosition[0] = 0;
+ visualLampPosition[1] = 0;
+ visualLampPosition[2] = 0;
+ } else {
+ /* too simple, better to return the distance on the view axis only
+ * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */
+ float matt[4][4], imat[4][4], obmat[4][4];
+
+ copy_m4_m4(obmat, cameraObject->obmat);
+ normalize_m4(obmat);
+ invert_m4_m4(imat, obmat);
+ mult_m4_m4m4(matt, imat, lampObject->obmat);
+
+ visualLampPosition[0] = (float)(matt[3][0]);
+ visualLampPosition[1] = (float)(matt[3][1]);
+ visualLampPosition[2] = (float)fabs(matt[3][2]);
+ }
+ }
+ this->lamp = (Lamp*)lampObject->data;
+
+ this->step = this->quality==COM_QUALITY_LOW?64:this->quality==COM_QUALITY_MEDIUM?128:256;
+ this->bokehReader = this->getInputSocketReader(1);
+
+#define MM *0.001f
+#define CM *0.01f
+#define NM *0.000000001
+#define RED 650 NM
+#define GREEN 510 NM
+#define BLUE 475 NM
+#define AIR 1.000293f
+#define GLASS 1.5200f
+#define TEST 0.000002f
+ // determine interfaces
+ LensSystem *system = new LensSystem();
+ system->addInterface(new FlatInterface(0.0f,0.0f, 6.5 CM, 30 MM)); //ENTRANCE
+ system->addInterface(new SphereInterface(0.0f,0.0f, -3 CM, 8 CM, 3 CM, AIR, GLASS , 0.f));
+ system->addInterface(new SphereInterface(0.0f,0.0f, -4 CM, 8 CM, 3 CM, GLASS, AIR, GREEN));
+ system->addInterface(new FlatInterface(0.0f,0.0f, 3.0 CM, 15 MM)); // BOKEH
+ system->addInterface(new SphereInterface(0.0f,0.0f, 6 CM, 3 CM, 2 CM, AIR, GLASS, 0.0f));
+ system->addInterface(new SphereInterface(0.0f,0.0f, 5.5 CM, 3 CM, 2 CM, GLASS, AIR, 0.f));
+ system->addInterface(new FlatInterface(0.0f,0.0f,0 CM, 30 MM)); // SENSOR
+ system->bokehIndex =3;
+
+ // determine interfaces
+// LensSystem *system = new LensSystem();
+// system->addInterface(new FlatInterface(0.0f,0.0f, 6.5 CM, 30 MM)); //ENTRANCE
+// system->addInterface(new SphereInterface(0.0f,0.0f, 14 CM, 8 CM, 6 CM, AIR, GLASS , 0.0f));
+// system->addInterface(new SphereInterface(0.0f,0.0f, 12 CM, 8 CM, 6 CM, GLASS, AIR, GREEN));
+// system->addInterface(new FlatInterface(0.0f,0.0f, 3.0 CM, 30 MM)); // BOKEH
+// system->addInterface(new SphereInterface(0.0f,0.0f, 1 CM, 3 CM, 2 CM, AIR, GLASS, GREEN));
+// system->addInterface(new SphereInterface(0.0f,0.0f, -2 CM, 3 CM, 2 CM, GLASS, AIR, RED));
+// system->addInterface(new FlatInterface(0.0f,0.0f,0 CM, 20 MM)); // SENSOR
+// system->bokehIndex = 3;
+#undef CM
+#undef MM
+ // determine bounces
+ system->updateBounces(step);
+ this->system = system;
+}
+
+void LensGhostOperation::initExecution() {
+ LensGhostProjectionOperation::initExecution();
+ LensSystem *system = (LensSystem*)this->system;
+ LensInterface *interface1 = system->interfaces[0];
+
+ // for every herz
+ float HERZ[3]={650 NM,510 NM,475 NM}; /// @todo use 7 for high quality?
+ for (int iw = 0 ; iw < 3 ; iw ++) {
+ float wavelength = HERZ[iw];
+ // for every bounce
+ for (int ib = 0 ; ib < system->bounces.size() ; ib++) {
+ Bounce* bounce = system->bounces[ib];
+ // based on quality setting the number of iteration will be different (128^2, 64^2, 32^2)
+ for (int xi = 0 ; xi < step ; xi ++) {
+ float x = -interface1->radius+xi*(interface1->radius*2/step);
+ for (int yi = 0 ; yi < step ; yi ++) {
+ float y = -interface1->radius+yi*(interface1->radius*2/step);
+ Ray r;
+ Ray result;
+ r.wavelength = wavelength;
+ r.intensity = this->lamp->energy;
+ r.uv[0] = 0.0f;
+ r.uv[1] = 0.0f;
+ r.position[0] = visualLampPosition[0];
+ r.position[1] = visualLampPosition[1];
+ r.position[2] = visualLampPosition[2];
+ r.direction[0] = interface1->position[0]+x - r.position[0];
+ r.direction[1] = interface1->position[1]+y - r.position[1];
+ r.direction[2] = interface1->position[2] - r.position[2];
+ normalize_v3(r.direction);
+ system->detectHit(&result, &r, bounce);
+ RayResult *res = bounce->getRayResult(xi, yi);
+ if (iw == 0) {
+ res->x = result.position[0];
+ res->y = result.position[1];
+ res->u = result.uv[0];
+ res->v = result.uv[1];
+ }
+ res->intensity[iw] = result.intensity;
+ if (result.valid) {
+ res->valid = true;
+ }
+ }
+ }
+ }
+ }
+#undef NM
+ const int width = this->getWidth();
+ const int height = this->getHeight();
+ const float width2 = width/2.0f;
+ const float height2 = height/2.0f;
+ float *data = new float[width*height*4];
+ for (int i = 0 ; i < width*height ; i ++) {
+ data[i*4+0] = 0.0f;
+ data[i*4+1] = 0.0f;
+ data[i*4+2] = 0.0f;
+ data[i*4+3] = 1.0f;
+ }
+ /// @todo every bounce creates own image. these images are added together at the end
+// LensSystem *system = (LensSystem*)this->system;
+ LensInterface * lens = system->interfaces[system->lensIndex];
+ for (int i = 0 ; i < system->bounces.size() ; i ++) {
+ Bounce* bounce = system->bounces[i];
+ for (int r = 0 ; r < bounce->rasterLength*bounce->rasterLength ; r ++) {
+ RayResult *result = &bounce->raster[r];
+// if (result->valid) {
+ float ru= result->x/lens->nominalRadius*width2+width2;
+ float rv = result->y/lens->nominalRadius*height2+height2;
+ result->screenX = ru;
+ result->screenY = rv;
+ result->hasIntensity = result->intensity[0]>0.0f &&result->intensity[1]>0.0f&& result->intensity[2]>0.0f;
+// }
+ }
+ }
+}
+
+void* LensGhostOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ vector<LensFace*>* result = new vector<LensFace*>();
+ LensSystem *system = (LensSystem*)this->system;
+ const float minx = rect->xmin;
+ const float miny = rect->ymin;
+ const float maxx = rect->xmax;
+ const float maxy = rect->ymax;
+ for (int i = 0 ; i < system->bounces.size() ; i ++) {
+ Bounce* bounce = system->bounces[i];
+ int faceX, faceY;
+ for (faceX = 0 ; faceX < bounce->rasterLength-1 ; faceX++) {
+ for (faceY = 0 ; faceY < bounce->rasterLength-1 ; faceY++) {
+ RayResult* vertex1 = bounce->getRayResult(faceX, faceY);
+ RayResult* vertex2 = bounce->getRayResult(faceX+1, faceY);
+ RayResult* vertex3 = bounce->getRayResult(faceX+1, faceY+1);
+ RayResult* vertex4 = bounce->getRayResult(faceX, faceY+1);
+ // early hit test
+ if (!((vertex1->screenX < minx && vertex2->screenX < minx && vertex3->screenX < minx && vertex4->screenX < minx) ||
+ (vertex1->screenX > maxx && vertex2->screenX > maxx && vertex3->screenX > maxx && vertex4->screenX > maxx) ||
+ (vertex1->screenY < miny && vertex2->screenY < miny && vertex3->screenY < miny && vertex4->screenY < miny) ||
+ (vertex1->screenY > maxy && vertex2->screenY > maxy && vertex3->screenY > maxy && vertex4->screenY > maxy))) {
+ int number = vertex1->hasIntensity +vertex2->hasIntensity +vertex3->hasIntensity +vertex4->hasIntensity;
+ if (number == 4) {
+ LensFace* face = new LensFace();
+ face->v1 = vertex1;
+ face->v2 = vertex2;
+ face->v3 = vertex3;
+ result->push_back(face);
+ face = new LensFace();
+ face->v1 = vertex3;
+ face->v2 = vertex4;
+ face->v3 = vertex1;
+ result->push_back(face);
+ } else if (number == 3) {
+ LensFace *face = new LensFace();
+ if (!vertex1->hasIntensity) {
+ face->v1 = vertex2;
+ face->v2 = vertex3;
+ face->v3 = vertex4;
+ } else if (!vertex2->hasIntensity) {
+ face->v1 = vertex1;
+ face->v2 = vertex3;
+ face->v3 = vertex4;
+ } else if (!vertex3->hasIntensity) {
+ face->v1 = vertex1;
+ face->v2 = vertex2;
+ face->v3 = vertex4;
+ } else {
+ face->v1 = vertex1;
+ face->v2 = vertex2;
+ face->v3 = vertex3;
+ }
+ result->push_back(face);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
+void LensGhostOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) {
+ if (data) {
+ vector<LensFace*>* faces = (vector<LensFace*>*)data;
+ while (faces->size() != 0) {
+ LensFace *face = faces->back();
+ faces->pop_back();
+ delete face;
+ }
+ delete faces;
+ }
+}
+
+
+void LensGhostProjectionOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float bokeh[4];
+ LensSystem *system = (LensSystem*)this->system;
+ LensInterface *interface1 = system->interfaces[0];
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ const float size = min(height, width);
+ const float width2 = width/2;
+ const float height2 = height/2;
+ const float size2 = size/2;
+
+#define NM *0.000000001
+ float HERZ[3]={650 NM,510 NM,475 NM}; /// @todo use 7 for high quality?
+ float rx = ((x-width2)/size2) * interface1->radius;
+ float ry = ((y-height2)/size2) * interface1->radius;
+
+ for (int iw = 0 ; iw < 3 ; iw ++) {
+ float intensity = 0.0f;
+ float wavelength = HERZ[iw];
+ float colorcomponent = 0.0f;
+ if (iw ==0 ) colorcomponent = lamp->r;
+ if (iw ==1 ) colorcomponent = lamp->g;
+ if (iw ==2 ) colorcomponent = lamp->b;
+
+
+ // for every bounce
+ for (int ib = 0 ; ib < system->bounces.size() ; ib++) {
+ Bounce* bounce = system->bounces[ib];
+ // based on quality setting the number of iteration will be different (128^2, 64^2, 32^2)
+
+ Ray r;
+ Ray result;
+ r.wavelength = wavelength;
+ r.intensity = this->lamp->energy;
+ r.uv[0] = 0.0f;
+ r.uv[1] = 0.0f;
+ r.position[0] = visualLampPosition[0];
+ r.position[1] = visualLampPosition[1];
+ r.position[2] = visualLampPosition[2];
+ r.direction[0] = interface1->position[0]+rx - r.position[0];
+ r.direction[1] = interface1->position[1]+ry - r.position[1];
+ r.direction[2] = interface1->position[2] - r.position[2];
+ normalize_v3(r.direction);
+ system->detectHit(&result, &r, bounce);
+ if (result.valid) {
+ float u = ((result.uv[0]+1.0f)/2)*bokehReader->getWidth();
+ float v = ((result.uv[1]+1.0f)/2)*bokehReader->getHeight();
+
+ bokehReader->read(bokeh, u, v, sampler, inputBuffers);
+
+ intensity += result.intensity *bokeh[iw];
+ }
+ }
+ intensity = maxf(0.0f, intensity);
+ color[iw] = intensity*colorcomponent;
+ }
+ color[3] = 1.0f;
+#undef NM
+
+}
+
+
+
+void LensGhostOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ vector<LensFace*>* faces = (vector<LensFace*>*)data;
+ const float bokehWidth = bokehReader->getWidth();
+ const float bokehHeight = bokehReader->getHeight();
+ float bokeh[4];
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 1.0f;
+
+ unsigned int index;
+ for (index = 0 ; index < faces->size() ; index ++) {
+ LensFace * face = faces->operator [](index);
+ RayResult* vertex1 = face->v1;
+ RayResult* vertex2 = face->v2;
+ RayResult* vertex3 = face->v3;
+ if (!((vertex1->screenX < x && vertex2->screenX < x && vertex3->screenX < x) ||
+ (vertex1->screenX > x && vertex2->screenX > x && vertex3->screenX > x) ||
+ (vertex1->screenY < y && vertex2->screenY < y && vertex3->screenY < y) ||
+ (vertex1->screenY > y && vertex2->screenY > y && vertex3->screenY > y))) {
+
+ const float v1[2] = {vertex1->screenX, vertex1->screenY};
+ const float v2[2] = {vertex2->screenX, vertex2->screenY};
+ const float v3[2] = {vertex3->screenX, vertex3->screenY};
+ const float co[2] = {x, y};
+ float weights[3];
+
+ barycentric_weights_v2(v1, v2, v3, co, weights);
+ if (weights[0]>=0.0f && weights[0]<=1.0f &&
+ weights[1]>=0.0f && weights[1]<=1.0f &&
+ weights[2]>=0.0f && weights[2]<=1.0f) {
+// const float u = (vertex1->u*weights[0]+vertex2->u*weights[1]+vertex3->u*weights[2]);
+// const float v = (vertex1->v*weights[0]+vertex2->v*weights[1]+vertex3->v*weights[2]);
+// const float tu = ((u+1.0f)/2.0f)*bokehWidth;
+// const float tv = ((v+1.0f)/2.0f)*bokehHeight;
+// bokehReader->read(bokeh, tu, tv, inputBuffers);
+
+// color[0] = max(color[0], bokeh[0]*(vertex1->intensity[0]*weights[0]+vertex2->intensity[0]*weights[1]+vertex3->intensity[0]*weights[2]));
+// color[1] = max(color[1], bokeh[1]*(vertex1->intensity[1]*weights[0]+vertex2->intensity[1]*weights[1]+vertex3->intensity[1]*weights[2]));
+// color[2] = max(color[2], bokeh[2]*(vertex1->intensity[2]*weights[0]+vertex2->intensity[2]*weights[1]+vertex3->intensity[2]*weights[2]));
+ color[0] = max(color[0], (vertex1->intensity[0]*weights[0]+vertex2->intensity[0]*weights[1]+vertex3->intensity[0]*weights[2]));
+ color[1] = max(color[1], (vertex1->intensity[1]*weights[0]+vertex2->intensity[1]*weights[1]+vertex3->intensity[1]*weights[2]));
+ color[2] = max(color[2], (vertex1->intensity[2]*weights[0]+vertex2->intensity[2]*weights[1]+vertex3->intensity[2]*weights[2]));
+ }
+ }
+ }
+}
+
+
+void LensGhostProjectionOperation::deinitExecution() {
+ if (this->system) delete (LensSystem*)this->system;
+ this->system = NULL;
+ this->bokehReader = NULL;
+}
+
+bool LensGhostProjectionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti bokehInput;
+
+ NodeOperation *operation = this->getInputOperation(1);
+ bokehInput.xmax = operation->getWidth();
+ bokehInput.xmin = 0;
+ bokehInput.ymax = operation->getHeight();
+ bokehInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
+ return true;
+ }
+
+ return NodeOperation::determineDependingAreaOfInterest(input, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_LensGhostOperation.h b/source/blender/compositor/operations/COM_LensGhostOperation.h
new file mode 100644
index 00000000000..396f681e797
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGhostOperation.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_LensGhostOperation_h
+#define _COM_LensGhostOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_lamp_types.h"
+#include "DNA_object_types.h"
+#include "DNA_camera_types.h"
+
+class LensGhostProjectionOperation : public NodeOperation {
+protected:
+ Object* lampObject;
+ Lamp* lamp;
+ Object* cameraObject;
+
+ void* system;
+ float visualLampPosition[3];
+ CompositorQuality quality;
+ int step;
+ SocketReader * bokehReader;
+
+public:
+ LensGhostProjectionOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setLampObject(Object* lampObject) {this->lampObject = lampObject;}
+ void setCameraObject(Object* cameraObject) {this->cameraObject = cameraObject;}
+
+ void setQuality(CompositorQuality quality) {this->quality = quality;}
+};
+
+class LensGhostOperation : public LensGhostProjectionOperation {
+public:
+ LensGhostOperation();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp b/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp
new file mode 100644
index 00000000000..935844a84f1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGlowImageOperation.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_LensGlowImageOperation.h"
+#include "BLI_math.h"
+
+LensGlowImageOperation::LensGlowImageOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+void LensGlowImageOperation::initExecution() {
+ this->scale = 1/20000.0f;
+}
+void LensGlowImageOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ const float cs_r = 1.f, cs_g = 1.f, cs_b = 1.f;
+ const float v = 2.f*(y / (float)512.0f) - 1.f;
+ const float u = 2.f*(x / (float)512.0f) - 1.f;
+ const float r = (u*u + v*v)*scale;
+ const float d = -sqrtf(sqrtf(sqrtf(r)))*9.f;
+ const float w = (0.5f + 0.5f*cos((double)u*M_PI))*(0.5f + 0.5f*cos((double)v*M_PI));
+ color[0] = expf(d*cs_r) * w;
+ color[1] = expf(d*cs_g) * w;
+ color[2] = expf(d*cs_b) * w;
+ color[3] = 1.0f;
+}
+
+void LensGlowImageOperation::deinitExecution() {
+}
+
+void LensGlowImageOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = 512;
+ resolution[1] = 512;
+}
diff --git a/source/blender/compositor/operations/COM_LensGlowImageOperation.h b/source/blender/compositor/operations/COM_LensGlowImageOperation.h
new file mode 100644
index 00000000000..2943f8957a6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGlowImageOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_LensGlowImageOperation_h
+#define _COM_LensGlowImageOperation_h
+#include "COM_NodeOperation.h"
+
+
+class LensGlowImageOperation : public NodeOperation {
+private:
+ float scale;
+
+public:
+ LensGlowImageOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_LensGlowOperation.cpp b/source/blender/compositor/operations/COM_LensGlowOperation.cpp
new file mode 100644
index 00000000000..ecaef52d8e1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGlowOperation.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_LensGlowOperation.h"
+#include "BLI_math.h"
+
+LensGlowOperation::LensGlowOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputProgram = NULL;
+ this->lamp = NULL;
+}
+void LensGlowOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void LensGlowOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+// const float emit100 = this->lamp->energy*100;
+// const float emit200 = emit100*2;
+// const float deltaX = 160-x;
+// const float deltaY = 100-y;
+// const float distance = deltaX * deltaX + deltaY*deltaY;
+
+// float glow = (emit100-(distance))/(emit200);
+// if (glow<0) glow=0;
+
+// color[0] = glow*lamp->r;
+// color[1] = glow*lamp->g;
+// color[2] = glow*lamp->b;
+// color[3] = 1.0f;
+}
+
+void LensGlowOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_LensGlowOperation.h b/source/blender/compositor/operations/COM_LensGlowOperation.h
new file mode 100644
index 00000000000..9a18f605cda
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LensGlowOperation.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_LensGlowOperation_h
+#define _COM_LensGlowOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_lamp_types.h"
+
+class LensGlowOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+ Lamp* lamp;
+
+public:
+ LensGlowOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setLamp(Lamp* lamp) {this->lamp = lamp;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
new file mode 100644
index 00000000000..7850a631212
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_LuminanceMatteOperation.h"
+#include "BLI_math.h"
+
+LuminanceMatteOperation::LuminanceMatteOperation(): NodeOperation() {
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
+
+ inputImageProgram = NULL;
+}
+
+void LuminanceMatteOperation::initExecution() {
+ this->inputImageProgram = this->getInputSocketReader(0);
+}
+
+void LuminanceMatteOperation::deinitExecution() {
+ this->inputImageProgram= NULL;
+}
+
+void LuminanceMatteOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inColor[4];
+
+ const float high=this->settings->t1;
+ const float low=this->settings->t2;
+
+ float alpha;
+
+ this->inputImageProgram->read(inColor, x, y, sampler, inputBuffers);
+
+ /* one line thread-friend algorithm:
+ outputValue[0] = max(inputValue[3], min(high, max(low, ((inColor[0]-low)/(high-low))))
+ */
+
+ /* test range*/
+ if(inColor[0] > high) {
+ alpha=1.f;
+ }
+ else if(inColor[0] < low){
+ alpha=0.f;
+ }
+ else {/*blend */
+ alpha=(inColor[0]-low)/(high-low);
+ }
+
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /* don't make something that was more transparent less transparent */
+ if (alpha<inColor[3]) {
+ outputValue[0]=alpha;
+ }
+ else {
+ /* leave now it was before */
+ outputValue[0]=inColor[3];
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
new file mode 100644
index 00000000000..3c33cee71e9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_LuminanceMatteOperation_h
+#define _COM_LuminanceMatteOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class LuminanceMatteOperation : public NodeOperation {
+private:
+ NodeChroma *settings;
+ SocketReader *inputImageProgram;
+public:
+ /**
+ * Default constructor
+ */
+ LuminanceMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma* nodeChroma) {this->settings= nodeChroma;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
new file mode 100644
index 00000000000..ef0c9004a7d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_MapUVOperation.h"
+#include "BLI_math.h"
+
+MapUVOperation::MapUVOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->alpha = 0.f;
+ this->setComplex(true);
+
+ this->inputUVProgram = NULL;
+ this->inputColorProgram = NULL;
+}
+
+void MapUVOperation::initExecution() {
+ this->inputColorProgram = this->getInputSocketReader(0);
+ this->inputUVProgram = this->getInputSocketReader(1);
+}
+
+void MapUVOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputUV[4];
+ float uv_a[4], uv_b[4];
+ float u,v;
+
+ float dx, dy;
+ float uv_l, uv_r;
+ float uv_u, uv_d;
+
+ this->inputUVProgram->read(inputUV, x, y, sampler, inputBuffers);
+ if (inputUV[2] == 0.f) {
+ color[0] = 0.f;
+ color[1] = 0.f;
+ color[2] = 0.f;
+ color[3] = 0.f;
+ return;
+ }
+ /* adaptive sampling, red (U) channel */
+ this->inputUVProgram->read(uv_a, x-1, y, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x+1, y, COM_PS_NEAREST, inputBuffers);
+ uv_l= uv_a[2]!=0.f? fabs(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r= uv_b[2]!=0.f? fabs(inputUV[0] - uv_b[0]) : 0.f;
+
+ dx= 0.5f * (uv_l + uv_r);
+
+ /* adaptive sampling, green (V) channel */
+ this->inputUVProgram->read(uv_a, x, y-1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x, y+1, COM_PS_NEAREST, inputBuffers);
+ uv_u= uv_a[2]!=0.f? fabs(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d= uv_b[2]!=0.f? fabs(inputUV[1] - uv_b[1]) : 0.f;
+
+ dy= 0.5f * (uv_u + uv_d);
+
+ /* more adaptive sampling, red and green (UV) channels */
+ this->inputUVProgram->read(uv_a, x-1, y-1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x-1, y+1, COM_PS_NEAREST, inputBuffers);
+ uv_l= uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r= uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u= uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d= uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+
+ dx+= 0.25f * (uv_l + uv_r);
+ dy+= 0.25f * (uv_u + uv_d);
+
+ this->inputUVProgram->read(uv_a, x+1, y-1, COM_PS_NEAREST, inputBuffers);
+ this->inputUVProgram->read(uv_b, x+1, y+1, COM_PS_NEAREST, inputBuffers);
+ uv_l= uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r= uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u= uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d= uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+
+ dx+= 0.25f * (uv_l + uv_r);
+ dy+= 0.25f * (uv_u + uv_d);
+
+ /* UV to alpha threshold */
+ const float threshold = this->alpha * 0.05f;
+ float alpha = 1.0f - threshold * (dx + dy);
+ if (alpha < 0.f) alpha= 0.f;
+ else alpha *= inputUV[2];
+
+ /* should use mipmap */
+ dx= min(dx, 0.2f);
+ dy= min(dy, 0.2f);
+
+
+ /* EWA filtering */
+ u = inputUV[0] * inputColorProgram->getWidth();
+ v = inputUV[1] * inputColorProgram->getHeight();
+
+ this->inputColorProgram->read(color, u, v, dx, dy, inputBuffers);
+
+ /* "premul" */
+ if(alpha < 1.0f) {
+ color[0]*= alpha;
+ color[1]*= alpha;
+ color[2]*= alpha;
+ color[3]*= alpha;
+ }
+}
+
+void MapUVOperation::deinitExecution() {
+ this->inputUVProgram = NULL;
+ this->inputColorProgram = NULL;
+}
+
+bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti colorInput;
+ rcti uvInput;
+ NodeOperation *operation=NULL;
+
+ /* the uv buffer only needs a 3x3 buffer. The image needs whole buffer */
+
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ operation = getInputOperation(1);
+ uvInput.xmax = input->xmax + 1;
+ uvInput.xmin = input->xmin - 1;
+ uvInput.ymax = input->ymax + 1;
+ uvInput.ymin = input->ymin - 1;
+ if (operation->determineDependingAreaOfInterest(&uvInput, readOperation, output)) {
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
new file mode 100644
index 00000000000..58c962eb17c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_MapUVOperation_h
+#define _COM_MapUVOperation_h
+#include "COM_NodeOperation.h"
+
+
+class MapUVOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputUVProgram;
+ SocketReader* inputColorProgram;
+
+ float alpha;
+
+public:
+ MapUVOperation();
+
+ /**
+ * we need a 3x3 differential filter for UV Input and full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setAlpha(float alpha){this->alpha = alpha;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
new file mode 100644
index 00000000000..33d38b8475d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MapValueOperation.h"
+
+MapValueOperation::MapValueOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+}
+
+void MapValueOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void MapValueOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float src[4];
+ inputOperation->read(src, x, y, sampler, inputBuffers);
+ TexMapping *texmap= this->settings;
+ float value = (src[0] + texmap->loc[0])*texmap->size[0];
+ if(texmap->flag & TEXMAP_CLIP_MIN)
+ if(value<texmap->min[0])
+ value= texmap->min[0];
+ if(texmap->flag & TEXMAP_CLIP_MAX)
+ if(value>texmap->max[0])
+ value= texmap->max[0];
+
+ outputValue[0] = value;
+}
+
+void MapValueOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
new file mode 100644
index 00000000000..93274a12493
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MapValueOperation_h
+#define _COM_MapValueOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_texture_types.h"
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MapValueOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputOperation;
+ TexMapping * settings;
+public:
+ /**
+ * Default constructor
+ */
+ MapValueOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ /**
+ * @brief set the TexMapping settings
+ */
+ void setSettings(TexMapping* settings) {this->settings = settings;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
new file mode 100644
index 00000000000..55880566bf2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MathBaseOperation.h"
+extern "C" {
+#include "BLI_math.h"
+}
+
+MathBaseOperation::MathBaseOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputValue1Operation = NULL;
+ this->inputValue2Operation = NULL;
+}
+
+void MathBaseOperation::initExecution() {
+ this->inputValue1Operation = this->getInputSocketReader(0);
+ this->inputValue2Operation = this->getInputSocketReader(1);
+}
+
+
+void MathBaseOperation::deinitExecution() {
+ this->inputValue1Operation = NULL;
+ this->inputValue2Operation = NULL;
+}
+
+void MathAddOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputValue1[0] + inputValue2[0];
+}
+
+void MathSubtractOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputValue1[0] - inputValue2[0];
+}
+
+void MathMultiplyOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputValue1[0] * inputValue2[0];
+}
+
+void MathDivideOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ if(inputValue2[0]==0) /* We don't want to divide by zero. */
+ outputValue[0]= 0.0;
+ else
+ outputValue[0]= inputValue1[0] / inputValue2[0];
+}
+
+void MathSineOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = sin(inputValue1[0]);
+}
+
+void MathCosineOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = cos(inputValue1[0]);
+}
+
+void MathTangentOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = tan(inputValue1[0]);
+}
+
+void MathArcSineOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ if(inputValue1[0] <= 1 && inputValue1[0] >= -1 )
+ outputValue[0]= asin(inputValue1[0]);
+ else
+ outputValue[0]= 0.0;
+}
+
+void MathArcCosineOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ if(inputValue1[0] <= 1 && inputValue1[0] >= -1 )
+ outputValue[0]= acos(inputValue1[0]);
+ else
+ outputValue[0]= 0.0;
+}
+
+void MathArcTangentOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = atan(inputValue1[0]);
+}
+
+void MathPowerOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ if( inputValue1[0] >= 0 ) {
+ outputValue[0]= pow(inputValue1[0], inputValue2[0]);
+ } else {
+ float y_mod_1 = fmod(inputValue2[0], 1);
+ /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ if (y_mod_1 > 0.999 || y_mod_1 < 0.001) {
+ outputValue[0]= pow(inputValue1[0], (float)floor(inputValue2[0] + 0.5));
+ } else {
+ outputValue[0] = 0.0;
+ }
+ }
+}
+
+void MathLogarithmOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ if( inputValue1[0] > 0 && inputValue2[0] > 0 )
+ outputValue[0]= log(inputValue1[0]) / log(inputValue2[0]);
+ else
+ outputValue[0]= 0.0;
+}
+
+void MathMinimumOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = min(inputValue1[0], inputValue2[0]);
+}
+
+void MathMaximumOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = max(inputValue1[0], inputValue2[0]);
+}
+
+void MathRoundOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = round(inputValue1[0]);
+}
+
+void MathLessThanOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputValue1[0]<inputValue2[0]?1.0f:0.0f;
+}
+
+void MathGreaterThanOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputValue1[4];
+ float inputValue2[4];
+
+ inputValue1Operation->read(&inputValue1[0], x, y, sampler, inputBuffers);
+ inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
+
+ outputValue[0] = inputValue1[0]>inputValue2[0]?1.0f:0.0f;
+}
+
+
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
new file mode 100644
index 00000000000..728d989e1e9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MathBaseOperation_h
+#define _COM_MathBaseOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MathBaseOperation : public NodeOperation {
+protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader * inputValue1Operation;
+ SocketReader * inputValue2Operation;
+
+protected:
+ /**
+ * Default constructor
+ */
+ MathBaseOperation();
+public:
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) = 0;
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+};
+
+class MathAddOperation: public MathBaseOperation {
+public:
+ MathAddOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathSubtractOperation: public MathBaseOperation {
+public:
+ MathSubtractOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathMultiplyOperation: public MathBaseOperation {
+public:
+ MathMultiplyOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathDivideOperation: public MathBaseOperation {
+public:
+ MathDivideOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathSineOperation: public MathBaseOperation {
+public:
+ MathSineOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathCosineOperation: public MathBaseOperation {
+public:
+ MathCosineOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathTangentOperation: public MathBaseOperation {
+public:
+ MathTangentOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+class MathArcSineOperation: public MathBaseOperation {
+public:
+ MathArcSineOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathArcCosineOperation: public MathBaseOperation {
+public:
+ MathArcCosineOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathArcTangentOperation: public MathBaseOperation {
+public:
+ MathArcTangentOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathPowerOperation: public MathBaseOperation {
+public:
+ MathPowerOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathLogarithmOperation: public MathBaseOperation {
+public:
+ MathLogarithmOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathMinimumOperation: public MathBaseOperation {
+public:
+ MathMinimumOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathMaximumOperation: public MathBaseOperation {
+public:
+ MathMaximumOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathRoundOperation: public MathBaseOperation {
+public:
+ MathRoundOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathLessThanOperation: public MathBaseOperation {
+public:
+ MathLessThanOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+class MathGreaterThanOperation: public MathBaseOperation {
+public:
+ MathGreaterThanOperation() : MathBaseOperation() {}
+ void executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_MixAddOperation.cpp b/source/blender/compositor/operations/COM_MixAddOperation.cpp
new file mode 100644
index 00000000000..d428ca52b49
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixAddOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixAddOperation.h"
+
+MixAddOperation::MixAddOperation(): MixBaseOperation() {
+}
+
+void MixAddOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+
+ inputValueOperation->read(inputValue, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers);
+
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ outputValue[0] = inputColor1[0]+value*inputColor2[0];
+ outputValue[1] = inputColor1[1]+value*inputColor2[1];
+ outputValue[2] = inputColor1[2]+value*inputColor2[2];
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h
new file mode 100644
index 00000000000..0a76083be73
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixAddOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixAddOperation_h
+#define _COM_MixAddOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixAddOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixAddOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.cpp b/source/blender/compositor/operations/COM_MixBaseOperation.cpp
new file mode 100644
index 00000000000..9f8378defe9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBaseOperation.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixBaseOperation.h"
+
+MixBaseOperation::MixBaseOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputValueOperation = NULL;
+ this->inputColor1Operation = NULL;
+ this->inputColor2Operation = NULL;
+ this->setUseValueAlphaMultiply(false);
+}
+
+void MixBaseOperation::initExecution() {
+ this->inputValueOperation = this->getInputSocketReader(0);
+ this->inputColor1Operation = this->getInputSocketReader(1);
+ this->inputColor2Operation = this->getInputSocketReader(2);
+}
+
+void MixBaseOperation::executePixel(float* outputColor, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+ outputColor[0] = valuem*(inputColor1[0])+value*(inputColor2[0]);
+ outputColor[1] = valuem*(inputColor1[1])+value*(inputColor2[1]);
+ outputColor[2] = valuem*(inputColor1[2])+value*(inputColor2[2]);
+ outputColor[3] = inputColor1[3];
+}
+
+void MixBaseOperation::deinitExecution() {
+ this->inputValueOperation = NULL;
+ this->inputColor1Operation = NULL;
+ this->inputColor2Operation = NULL;
+}
+
+void MixBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]){
+ InputSocket* socket;
+ unsigned int tempPreferredResolution[] = {0,0};
+ unsigned int tempResolution[2];
+
+ socket = this->getInputSocket(1);
+ socket->determineResolution(tempResolution, tempPreferredResolution);
+ if((tempResolution[0] != 0) && (tempResolution[1] != 0)){
+ this->setResolutionInputSocketIndex(1);
+ }else {
+ socket = this->getInputSocket(2);
+ tempPreferredResolution[0] = 0;
+ tempPreferredResolution[1] = 0;
+ socket->determineResolution(tempResolution, tempPreferredResolution);
+ if((tempResolution[0] != 0) && (tempResolution[1] != 0)){
+ this->setResolutionInputSocketIndex(2);
+ }else {
+ this->setResolutionInputSocketIndex(0);
+ }
+ }
+ NodeOperation::determineResolution(resolution, preferredResolution);
+}
+
diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h
new file mode 100644
index 00000000000..171cde080eb
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBaseOperation.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixBaseOperation_h
+#define _COM_MixBaseOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixBaseOperation : public NodeOperation {
+protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader * inputValueOperation;
+ SocketReader* inputColor1Operation;
+ SocketReader* inputColor2Operation;
+ bool valueAlphaMultiply;
+public:
+ /**
+ * Default constructor
+ */
+ MixBaseOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void setUseValueAlphaMultiply(const bool value) {this->valueAlphaMultiply = value;}
+ bool useValueAlphaMultiply() {return this->valueAlphaMultiply;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.cpp b/source/blender/compositor/operations/COM_MixBlendOperation.cpp
new file mode 100644
index 00000000000..7b12393bb20
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBlendOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixBlendOperation.h"
+
+MixBlendOperation::MixBlendOperation(): MixBaseOperation() {
+}
+
+void MixBlendOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float value;
+
+ inputValueOperation->read(inputValue, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers);
+ value = inputValue[0];
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+ outputValue[0] = valuem*(inputColor1[0])+value*(inputColor2[0]);
+ outputValue[1] = valuem*(inputColor1[1])+value*(inputColor2[1]);
+ outputValue[2] = valuem*(inputColor1[2])+value*(inputColor2[2]);
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h
new file mode 100644
index 00000000000..5cf31ee9151
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBlendOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixBlendOperation_h
+#define _COM_MixBlendOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixBlendOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixBlendOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.cpp b/source/blender/compositor/operations/COM_MixBurnOperation.cpp
new file mode 100644
index 00000000000..28b86be5e1e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBurnOperation.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixBurnOperation.h"
+
+MixBurnOperation::MixBurnOperation(): MixBaseOperation() {
+}
+
+void MixBurnOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+ float tmp;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ tmp = valuem + value*inputColor2[0];
+ if (tmp <= 0.0f)
+ outputValue[0] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[0]) / tmp;
+ if (tmp < 0.0f)
+ outputValue[0] = 0.0f;
+ else if (tmp > 1.0f)
+ outputValue[0] = 1.0f;
+ else
+ outputValue[0] = tmp;
+ }
+
+ tmp = valuem + value*inputColor2[1];
+ if (tmp <= 0.0f)
+ outputValue[1] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[1]) / tmp;
+ if (tmp < 0.0f)
+ outputValue[1] = 0.0f;
+ else if (tmp > 1.0f)
+ outputValue[1] = 1.0f;
+ else
+ outputValue[1] = tmp;
+ }
+
+ tmp = valuem + value*inputColor2[2];
+ if (tmp <= 0.0f)
+ outputValue[2] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[2]) / tmp;
+ if (tmp < 0.0f)
+ outputValue[2] = 0.0f;
+ else if (tmp > 1.0f)
+ outputValue[2] = 1.0f;
+ else
+ outputValue[2] = tmp;
+ }
+
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h
new file mode 100644
index 00000000000..132db3d25e7
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixBurnOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixBurnOperation_h
+#define _COM_MixBurnOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixBurnOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixBurnOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixColorOperation.cpp b/source/blender/compositor/operations/COM_MixColorOperation.cpp
new file mode 100644
index 00000000000..ebcb7056570
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixColorOperation.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixColorOperation.h"
+
+extern "C" {
+ #include "BLI_math.h"
+}
+
+MixColorOperation::MixColorOperation(): MixBaseOperation() {
+}
+
+void MixColorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ float colH,colS,colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ if(colS!=0.0f){
+ float rH,rS,rV;
+ float tmpr,tmpg,tmpb;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ hsv_to_rgb(colH , colS, rV, &tmpr, &tmpg, &tmpb);
+ outputValue[0] = valuem*(inputColor1[0]) + value*tmpr;
+ outputValue[1] = valuem*(inputColor1[1]) + value*tmpg;
+ outputValue[2] = valuem*(inputColor1[2]) + value*tmpb;
+ }
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h
new file mode 100644
index 00000000000..dfbdcfc0368
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixColorOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixColorOperation_h
+#define _COM_MixColorOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixColorOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixColorOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.cpp b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
new file mode 100644
index 00000000000..773a51e92cb
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixDarkenOperation.h"
+
+MixDarkenOperation::MixDarkenOperation(): MixBaseOperation() {
+}
+
+void MixDarkenOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f-value;
+ float tmp;
+ tmp=inputColor2[0]+((1.0f-inputColor2[0])*valuem);
+ if(tmp < inputColor1[0]) outputValue[0]= tmp;
+ else outputValue[0] = inputColor1[0];
+ tmp=inputColor2[1]+((1.0f-inputColor2[1])*valuem);
+ if(tmp < inputColor1[1]) outputValue[1]= tmp;
+ else outputValue[1] = inputColor1[1];
+ tmp=inputColor2[2]+((1.0f-inputColor2[2])*valuem);
+ if(tmp < inputColor1[2]) outputValue[2]= tmp;
+ else outputValue[2] = inputColor1[2];
+
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h
new file mode 100644
index 00000000000..7ead435212d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixDarkenOperation_h
+#define _COM_MixDarkenOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixDarkenOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixDarkenOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
new file mode 100644
index 00000000000..4ea1428b387
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixDifferenceOperation.h"
+#include "BLI_math.h"
+
+MixDifferenceOperation::MixDifferenceOperation(): MixBaseOperation() {
+}
+
+void MixDifferenceOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+ outputValue[0] = valuem*inputColor1[0] + value*fabsf(inputColor1[0]-inputColor2[0]);
+ outputValue[1] = valuem*inputColor1[1] + value*fabsf(inputColor1[1]-inputColor2[1]);
+ outputValue[2] = valuem*inputColor1[2] + value*fabsf(inputColor1[2]-inputColor2[2]);
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h
new file mode 100644
index 00000000000..9b95d5a91ad
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixDifferenceOperation_h
+#define _COM_MixDifferenceOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixDifferenceOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixDifferenceOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.cpp b/source/blender/compositor/operations/COM_MixDivideOperation.cpp
new file mode 100644
index 00000000000..c2579c6a89c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDivideOperation.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixDivideOperation.h"
+
+MixDivideOperation::MixDivideOperation(): MixBaseOperation() {
+}
+
+void MixDivideOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ if(inputColor2[0]!=0.0f)
+ outputValue[0] = valuem*(inputColor1[0]) + value*(inputColor1[0])/inputColor2[0];
+ else
+ outputValue[0] = 0.0f;
+ if(inputColor2[1]!=0.0f)
+ outputValue[1] = valuem*(inputColor1[1]) + value*(inputColor1[1])/inputColor2[1];
+ else
+ outputValue[1] = 0.0f;
+ if(inputColor2[2]!=0.0f)
+ outputValue[2] = valuem*(inputColor1[2]) + value*(inputColor1[2])/inputColor2[2];
+ else
+ outputValue[2] = 0.0f;
+
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h
new file mode 100644
index 00000000000..d43ddb49c91
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDivideOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixDivideOperation_h
+#define _COM_MixDivideOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixDivideOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixDivideOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.cpp b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
new file mode 100644
index 00000000000..7e6ddeee5e6
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixDodgeOperation.h"
+
+MixDodgeOperation::MixDodgeOperation(): MixBaseOperation() {
+}
+
+void MixDodgeOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+ float tmp;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+
+ if (inputColor1[0] != 0.0f) {
+ tmp = 1.0f - value*inputColor2[0];
+ if (tmp <= 0.0f)
+ outputValue[0] = 1.0f;
+ else {
+ tmp = inputColor1[0] / tmp;
+ if (tmp > 1.0f)
+ outputValue[0] = 1.0f;
+ else
+ outputValue[0] = tmp;
+ }
+ }
+ else
+ outputValue[0] = 0.0f;
+
+ if (inputColor1[1] != 0.0f) {
+ tmp = 1.0f - value*inputColor2[1];
+ if (tmp <= 0.0f)
+ outputValue[1] = 1.0f;
+ else {
+ tmp = inputColor1[1] / tmp;
+ if (tmp > 1.0f)
+ outputValue[1] = 1.0f;
+ else
+ outputValue[1] = tmp;
+ }
+ }
+ else
+ outputValue[1] = 0.0f;
+
+ if (inputColor1[2] != 0.0f) {
+ tmp = 1.0f - value*inputColor2[2];
+ if (tmp <= 0.0f)
+ outputValue[2] = 1.0f;
+ else {
+ tmp = inputColor1[2] / tmp;
+ if (tmp > 1.0f)
+ outputValue[2] = 1.0f;
+ else
+ outputValue[2] = tmp;
+ }
+ }
+ else
+ outputValue[2] = 0.0f;
+
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h
new file mode 100644
index 00000000000..0a910c167ba
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixDodgeOperation_h
+#define _COM_MixDodgeOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixDodgeOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixDodgeOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixHueOperation.cpp b/source/blender/compositor/operations/COM_MixHueOperation.cpp
new file mode 100644
index 00000000000..386bd02ba2a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixHueOperation.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixHueOperation.h"
+
+extern "C" {
+ #include "BLI_math.h"
+}
+
+MixHueOperation::MixHueOperation(): MixBaseOperation() {
+}
+
+void MixHueOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ float colH,colS,colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ if(colS!=0.0f){
+ float rH,rS,rV;
+ float tmpr,tmpg,tmpb;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ hsv_to_rgb(colH , rS, rV, &tmpr, &tmpg, &tmpb);
+ outputValue[0] = valuem*(inputColor1[0]) + value*tmpr;
+ outputValue[1] = valuem*(inputColor1[1]) + value*tmpg;
+ outputValue[2] = valuem*(inputColor1[2]) + value*tmpb;
+ }
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h
new file mode 100644
index 00000000000..5e46b625385
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixHueOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixHueOperation_h
+#define _COM_MixHueOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixHueOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixHueOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.cpp b/source/blender/compositor/operations/COM_MixLightenOperation.cpp
new file mode 100644
index 00000000000..32d28b785b7
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixLightenOperation.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixLightenOperation.h"
+
+MixLightenOperation::MixLightenOperation(): MixBaseOperation() {
+}
+
+void MixLightenOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float tmp;
+ tmp=value * inputColor2[0];
+ if(tmp > inputColor1[0]) outputValue[0]= tmp;
+ else outputValue[0] = inputColor1[0];
+ tmp=value * inputColor2[1];
+ if(tmp > inputColor1[1]) outputValue[1]= tmp;
+ else outputValue[1] = inputColor1[1];
+ tmp=value * inputColor2[2];
+ if(tmp > inputColor1[2]) outputValue[2]= tmp;
+ else outputValue[2] = inputColor1[2];
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h
new file mode 100644
index 00000000000..64b1bf9bbc9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixLightenOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixLightenOperation_h
+#define _COM_MixLightenOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixLightenOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixLightenOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
new file mode 100644
index 00000000000..413b09d7242
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixLinearLightOperation.h"
+
+MixLinearLightOperation::MixLinearLightOperation(): MixBaseOperation() {
+}
+
+void MixLinearLightOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ if (inputColor2[0] > 0.5f)
+ outputValue[0] = inputColor1[0] + value*(2.0f*(inputColor2[0]-0.5f));
+ else
+ outputValue[0] = inputColor1[0] + value*(2.0f*(inputColor2[0]) - 1.0f);
+ if (inputColor2[1] > 0.5f)
+ outputValue[1] = inputColor1[1] + value*(2.0f*(inputColor2[1]-0.5f));
+ else
+ outputValue[1] = inputColor1[1] + value*(2.0f*(inputColor2[1]) - 1.0f);
+ if (inputColor2[2] > 0.5f)
+ outputValue[2] = inputColor1[2] + value*(2.0f*(inputColor2[2]-0.5f));
+ else
+ outputValue[2] = inputColor1[2] + value*(2.0f*(inputColor2[2]) - 1.0f);
+
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h
new file mode 100644
index 00000000000..9fb2a433104
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixLinearLightOperation_h
+#define _COM_MixLinearLightOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixLinearLightOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixLinearLightOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
new file mode 100644
index 00000000000..82c6c2e9c1f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixMultiplyOperation.h"
+
+MixMultiplyOperation::MixMultiplyOperation(): MixBaseOperation() {
+}
+
+void MixMultiplyOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+
+ inputValueOperation->read(inputValue, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(inputColor1, x, y, sampler, inputBuffers);
+ inputColor2Operation->read(inputColor2, x, y, sampler, inputBuffers);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+ outputValue[0] = inputColor1[0] *(valuem+value*inputColor2[0]);
+ outputValue[1] = inputColor1[1] *(valuem+value*inputColor2[1]);
+ outputValue[2] = inputColor1[2] *(valuem+value*inputColor2[2]);
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h
new file mode 100644
index 00000000000..c35e4bbf64b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixMultiplyOperation_h
+#define _COM_MixMultiplyOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixMultiplyOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixMultiplyOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.cpp b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
new file mode 100644
index 00000000000..8254701adad
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixOverlayOperation.h"
+
+MixOverlayOperation::MixOverlayOperation(): MixBaseOperation() {
+}
+
+void MixOverlayOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+
+ float valuem= 1.0f-value;
+
+ if(inputColor1[0] < 0.5f) {
+ outputValue[0] = inputColor1[0] * (valuem + 2.0f*value*inputColor2[0]);
+ } else {
+ outputValue[0] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
+ }
+ if(inputColor1[1] < 0.5f) {
+ outputValue[1] = inputColor1[1] * (valuem + 2.0f*value*inputColor2[1]);
+ } else {
+ outputValue[1] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
+ }
+ if(inputColor1[2] < 0.5f) {
+ outputValue[2] = inputColor1[2] * (valuem + 2.0f*value*inputColor2[2]);
+ } else {
+ outputValue[2] = 1.0f - (valuem + 2.0f*value*(1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
+ }
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h
new file mode 100644
index 00000000000..1a0e865b0e8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixOverlayOperation_h
+#define _COM_MixOverlayOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixOverlayOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixOverlayOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.cpp b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
new file mode 100644
index 00000000000..18ff6f46c46
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixSaturationOperation.h"
+
+extern "C" {
+ #include "BLI_math.h"
+}
+
+MixSaturationOperation::MixSaturationOperation(): MixBaseOperation() {
+}
+
+void MixSaturationOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ float rH,rS,rV;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ if(rS!=0.0f){
+ float colH,colS,colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ hsv_to_rgb(rH , (valuem*rS+value*colS), rV, &outputValue[0], &outputValue[1], &outputValue[2]);
+ }
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h
new file mode 100644
index 00000000000..cea2c886a06
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixSaturationOperation_h
+#define _COM_MixSaturationOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixSaturationOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixSaturationOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.cpp b/source/blender/compositor/operations/COM_MixScreenOperation.cpp
new file mode 100644
index 00000000000..25004ca7257
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixScreenOperation.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixScreenOperation.h"
+
+MixScreenOperation::MixScreenOperation(): MixBaseOperation() {
+}
+
+void MixScreenOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float valuev[4];
+
+ inputValueOperation->read(valuev, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ float value = valuev[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ outputValue[0] = 1.0f - (valuem + value*(1.0f-inputColor2[0])) *(1.0f-inputColor1[0]);
+ outputValue[1] = 1.0f - (valuem + value*(1.0f-inputColor2[1])) *(1.0f-inputColor1[1]);
+ outputValue[2] = 1.0f - (valuem + value*(1.0f-inputColor2[2])) *(1.0f-inputColor1[2]);
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h
new file mode 100644
index 00000000000..5fb99c7582f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixScreenOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixScreenOperation_h
+#define _COM_MixScreenOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixScreenOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixScreenOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
new file mode 100644
index 00000000000..3195b3440ec
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixSoftLightOperation.h"
+
+MixSoftLightOperation::MixSoftLightOperation(): MixBaseOperation() {
+}
+
+void MixSoftLightOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f-value;
+ float scr, scg, scb;
+
+ /* first calculate non-fac based Screen mix */
+ scr = 1.0f - (1.0f - inputColor2[0]) * (1.0f - inputColor1[0]);
+ scg = 1.0f - (1.0f - inputColor2[1]) * (1.0f - inputColor1[1]);
+ scb = 1.0f - (1.0f - inputColor2[2]) * (1.0f - inputColor1[2]);
+
+ outputValue[0] = valuem*(inputColor1[0]) + value*(((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) + (inputColor1[0] * scr));
+ outputValue[1] = valuem*(inputColor1[1]) + value*(((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg));
+ outputValue[2] = valuem*(inputColor1[2]) + value*(((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb));
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h
new file mode 100644
index 00000000000..1f5e9a24f07
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixSoftLightOperation_h
+#define _COM_MixSoftLightOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixSoftLightOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixSoftLightOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.cpp b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
new file mode 100644
index 00000000000..49792c99c27
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixSubtractOperation.h"
+
+MixSubtractOperation::MixSubtractOperation(): MixBaseOperation() {
+}
+
+void MixSubtractOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ outputValue[0] = inputColor1[0]-value*(inputColor2[0]);
+ outputValue[1] = inputColor1[1]-value*(inputColor2[1]);
+ outputValue[2] = inputColor1[2]-value*(inputColor2[2]);
+ outputValue[3] = inputColor1[3];
+}
+
diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h
new file mode 100644
index 00000000000..119d614081f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixSubtractOperation_h
+#define _COM_MixSubtractOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixSubtractOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixSubtractOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MixValueOperation.cpp b/source/blender/compositor/operations/COM_MixValueOperation.cpp
new file mode 100644
index 00000000000..93bb7b59b5f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixValueOperation.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MixValueOperation.h"
+
+extern "C" {
+ #include "BLI_math.h"
+}
+
+MixValueOperation::MixValueOperation(): MixBaseOperation() {
+}
+
+void MixValueOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float inputColor1[4];
+ float inputColor2[4];
+ float value;
+
+ inputValueOperation->read(&value, x, y, sampler, inputBuffers);
+ inputColor1Operation->read(&inputColor1[0], x, y, sampler, inputBuffers);
+ inputColor2Operation->read(&inputColor2[0], x, y, sampler, inputBuffers);
+
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem= 1.0f-value;
+
+ float rH,rS,rV;
+ float colH,colS,colV;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ hsv_to_rgb(rH , rS, (valuem*rV+value*colV), &outputValue[0], &outputValue[1], &outputValue[2]);
+ outputValue[3] = inputColor1[3];
+}
diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h
new file mode 100644
index 00000000000..ce358ebb506
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MixValueOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MixValueOperation_h
+#define _COM_MixValueOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MixValueOperation : public MixBaseOperation {
+public:
+ /**
+ * Default constructor
+ */
+ MixValueOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
new file mode 100644
index 00000000000..5d0e7e4a4fe
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MovieClipAttributeOperation.h"
+extern "C" {
+ #include "BKE_tracking.h"
+}
+MovieClipAttributeOperation::MovieClipAttributeOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+ this->valueSet = false;
+ this->framenumber = 0;
+ this->attribute = MCA_X;
+}
+
+void MovieClipAttributeOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ if (!valueSet) {
+ float loc[2], scale, angle;
+ loc[0] = 0.0f;
+ loc[1] = 0.0f;
+ scale = 1.0f;
+ angle = 0.0f;
+ if (clip) {
+ BKE_tracking_stabilization_data(&clip->tracking, framenumber, getWidth(), getHeight(), loc, &scale, &angle);
+ }
+ switch (this->attribute) {
+ case MCA_SCALE:
+ this->value = scale;
+ break;
+ case MCA_ANGLE:
+ this->value = angle;
+ break;
+ case MCA_X:
+ this->value = loc[0];
+ break;
+ case MCA_Y:
+ this->value = loc[1];
+ break;
+ }
+ valueSet = true;
+ }
+ outputValue[0] = this->value;
+}
+
+void MovieClipAttributeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+}
+
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
new file mode 100644
index 00000000000..960d837dd7e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MovieClipAttributeOperation_h
+#define _COM_MovieClipAttributeOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_movieclip_types.h"
+
+typedef enum MovieClipAttribute {
+ MCA_SCALE,
+ MCA_X,
+ MCA_Y,
+ MCA_ANGLE
+} MovieClipAttribute;
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class MovieClipAttributeOperation : public NodeOperation {
+private:
+ MovieClip * clip;
+ float value;
+ bool valueSet;
+ int framenumber;
+ MovieClipAttribute attribute;
+public:
+ /**
+ * Default constructor
+ */
+ MovieClipAttributeOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void setMovieClip(MovieClip* clip) {this->clip = clip;}
+ void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+ void setAttribute(MovieClipAttribute attribute) {this->attribute = attribute;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
new file mode 100644
index 00000000000..74179293c6c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MovieClipOperation.h"
+
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BLI_math.h"
+extern "C" {
+ #include "BKE_movieclip.h"
+ #include "IMB_imbuf.h"
+}
+#include "BKE_image.h"
+
+MovieClipOperation::MovieClipOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+ this->movieClip = NULL;
+ this->movieClipBuffer = NULL;
+ this->movieClipUser = NULL;
+ this->movieClipwidth = 0;
+ this->movieClipheight = 0;
+ this->framenumber = 0;
+}
+
+
+void MovieClipOperation::initExecution() {
+ if (this->movieClip) {
+ BKE_movieclip_user_set_frame(this->movieClipUser, this->framenumber);
+ ImBuf *ibuf;
+ ibuf= BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser);
+ if (ibuf) {
+ this->movieClipBuffer = ibuf;
+ if (ibuf->rect_float == NULL || ibuf->userflags&IB_RECT_INVALID) {
+ IMB_float_from_rect(ibuf);
+ ibuf->userflags&= ~IB_RECT_INVALID;
+ }
+ }
+ }
+}
+
+void MovieClipOperation::deinitExecution() {
+ this->movieClipBuffer = NULL;
+}
+
+void MovieClipOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ ImBuf *ibuf;
+ if (this->movieClip) {
+ ibuf= BKE_movieclip_get_ibuf(this->movieClip, this->movieClipUser);
+ if (ibuf) {
+ resolution[0] = ibuf->x;
+ resolution[1] = ibuf->y;
+ }
+ }
+}
+
+void MovieClipOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ if (this->movieClipBuffer == NULL || x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight() ) {
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+ } else {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->movieClipBuffer, NULL, color, x, y);
+ break;
+ }
+ }
+}
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
new file mode 100644
index 00000000000..c861115dee8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+
+#ifndef _COM_ImageOperation_h
+#define _COM_ImageOperation_h
+
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "DNA_movieclip_types.h"
+#include "BLI_listbase.h"
+#include "IMB_imbuf_types.h"
+
+/**
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
+class MovieClipOperation : public NodeOperation {
+protected:
+ MovieClip* movieClip;
+ MovieClipUser* movieClipUser;
+ ImBuf *movieClipBuffer;
+ int movieClipheight;
+ int movieClipwidth;
+ int framenumber;
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+public:
+ MovieClipOperation();
+
+ void initExecution();
+ void deinitExecution();
+ void setMovieClip(MovieClip* image) {this->movieClip = image;}
+ void setMovieClipUser(MovieClipUser* imageuser) {this->movieClipUser = imageuser;}
+
+ void setFramenumber(int framenumber) {this->framenumber = framenumber;}
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
new file mode 100644
index 00000000000..360719aa59f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_MovieDistortionOperation.h"
+
+extern "C" {
+ #include "BKE_tracking.h"
+
+#include "BLI_linklist.h"
+}
+
+
+vector<DistortionCache*> s_cache;
+
+
+MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->movieClip = NULL;
+ this->cache = NULL;
+ this->distortion = distortion;
+}
+void MovieDistortionOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ if (this->movieClip) {
+ for (int i = 0 ; i < s_cache.size() ; i ++) {
+ DistortionCache* c = (DistortionCache*)s_cache[i];
+ if (c->isCacheFor(this->movieClip, this->width, this->height, this->distortion)) {
+ this->cache = c;
+ return;
+ }
+ }
+ DistortionCache* newC = new DistortionCache(this->movieClip, this->width, this->height, this->distortion);
+ s_cache.push_back(newC);
+ this->cache = newC;
+ } else {
+ this->cache = NULL;
+ }
+}
+
+void MovieDistortionOperation::deinitExecution() {
+ this->inputOperation = NULL;
+ this->movieClip = NULL;
+}
+
+
+void MovieDistortionOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+
+ if (this->cache != NULL) {
+ float u, v;
+ this->cache->getUV(&this->movieClip->tracking, x, y, &u, &v);
+ this->inputOperation->read(color, u, v, sampler, inputBuffers);
+ }
+ else {
+ this->inputOperation->read(color, x, y, sampler, inputBuffers);
+ }
+}
+
+bool MovieDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmax = input->xmax + 100;
+ newInput.xmin = input->xmin - 100;
+ newInput.ymax = input->ymax + 100;
+ newInput.ymin = input->ymin - 100;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
new file mode 100644
index 00000000000..21aa955075d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_MovieDistortionOperation_h_
+#define _COM_MovieDistortionOperation_h_
+
+#include "COM_NodeOperation.h"
+#include "DNA_movieclip_types.h"
+extern "C" {
+ #include "BKE_tracking.h"
+}
+
+class DistortionCache {
+private:
+ float k1;
+ float k2;
+ float k3;
+ int width;
+ int height;
+ bool inverted;
+ float *buffer;
+ int *bufferCalculated;
+public:
+ DistortionCache(MovieClip* movieclip, int width, int height, bool inverted) {
+ this->k1 = movieclip->tracking.camera.k1;
+ this->k2 = movieclip->tracking.camera.k2;
+ this->k3 = movieclip->tracking.camera.k3;
+ this->width = width;
+ this->height = height;
+ this->inverted = inverted;
+ this->bufferCalculated = new int[this->width*this->height];
+ this->buffer = new float[this->width*this->height*2];
+ for (int i = 0 ; i < this->width*this->height ; i ++) {
+ this->bufferCalculated[i] = 0;
+ }
+ }
+ bool isCacheFor(MovieClip* movieclip, int width, int height, bool inverted) {
+ return this->k1 == movieclip->tracking.camera.k1 &&
+ this->k2 == movieclip->tracking.camera.k2 &&
+ this->k3 == movieclip->tracking.camera.k3 &&
+ this->inverted == inverted &&
+ this->width == width &&
+ this->height == height;
+ }
+
+ void getUV(MovieTracking* trackingData, int x, int y, float *u, float*v) {
+ if (x<0 || x >= this->width || y <0 || y >= this->height) {
+ *u = x;
+ *v = y;
+ } else {
+ int offset = y * this->width + x;
+ int offset2 = offset*2;
+ if (!bufferCalculated[offset]) {
+ float in[2];
+ float out[2];
+ in[0] = x;
+ in[1] = y;
+ if (inverted) {
+ BKE_tracking_invert_intrinsics(trackingData, in, out);
+ } else {
+ BKE_tracking_apply_intrinsics(trackingData, in, out);
+ }
+ buffer[offset2] = out[0];
+ buffer[offset2+1] = out[1];
+ bufferCalculated[offset] = 1;
+ }
+ *u = buffer[offset2];
+ *v = buffer[offset2+1];
+ }
+ }
+};
+
+class MovieDistortionOperation: public NodeOperation {
+private:
+ DistortionCache *cache;
+ SocketReader *inputOperation;
+ MovieClip * movieClip;
+
+protected:
+ bool distortion;
+
+public:
+ MovieDistortionOperation(bool distortion);
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setMovieClip(MovieClip* clip) {this->movieClip = clip;}
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
new file mode 100644
index 00000000000..53b71ed528e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#include "COM_MultilayerImageOperation.h"
+extern "C" {
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+MultilayerBaseOperation::MultilayerBaseOperation(int pass): BaseImageOperation() {
+ this->passId = pass;
+}
+ImBuf* MultilayerBaseOperation::getImBuf() {
+ RenderPass *rpass;
+ rpass = (RenderPass *)BLI_findlink(&this->renderlayer->passes, this->passId);
+ if(rpass) {
+ this->imageUser->pass= this->passId;
+ BKE_image_multilayer_index(image->rr, this->imageUser);
+ return BaseImageOperation::getImBuf();
+ }
+ return NULL;
+}
+
+void MultilayerColorOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ int yi = y;
+ int xi = x;
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+ } else {
+ if (this->numberOfChannels == 4) {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ neareast_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->buffer, NULL, color, x, y);
+ break;
+ }
+ } else {
+ int offset = (yi*this->getWidth()+xi)*3;
+ color[0] = this->imageBuffer[offset];
+ color[1] = this->imageBuffer[offset+1];
+ color[2] = this->imageBuffer[offset+2];
+ }
+ }
+}
+
+void MultilayerValueOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ int yi = y;
+ int xi = x;
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ color[0] = 0.0f;
+ } else {
+ float result = this->imageBuffer[yi*this->getWidth()+xi];
+ color[0] = result;
+ }
+}
+
+void MultilayerVectorOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ int yi = y;
+ int xi = x;
+ if (this->imageBuffer == NULL || xi < 0 || yi < 0 || xi >= this->getWidth() || yi >= this->getHeight() ) {
+ color[0] = 0.0f;
+ } else {
+ int offset = (yi*this->getWidth()+xi)*3;
+ color[0] = this->imageBuffer[offset];
+ color[1] = this->imageBuffer[offset+1];
+ color[2] = this->imageBuffer[offset+2];
+ }
+}
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
new file mode 100644
index 00000000000..37e8020d56c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+
+#ifndef _COM_MultilayerImageOperation_h
+#define _COM_MultilayerImageOperation_h
+
+#include "COM_ImageOperation.h"
+
+class MultilayerBaseOperation: public BaseImageOperation {
+private:
+ int passId;
+ RenderLayer* renderlayer;
+protected:
+ ImBuf* getImBuf();
+public:
+ /**
+ * Constructor
+ */
+ MultilayerBaseOperation(int pass);
+ void setRenderLayer(RenderLayer *renderlayer) {this->renderlayer = renderlayer;}
+};
+
+class MultilayerColorOperation: public MultilayerBaseOperation {
+public:
+ MultilayerColorOperation(int pass): MultilayerBaseOperation(pass) {
+ this->addOutputSocket(COM_DT_COLOR);
+ }
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+class MultilayerValueOperation: public MultilayerBaseOperation {
+public:
+ MultilayerValueOperation(int pass): MultilayerBaseOperation(pass) {
+ this->addOutputSocket(COM_DT_VALUE);
+ }
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+class MultilayerVectorOperation: public MultilayerBaseOperation {
+public:
+ MultilayerVectorOperation(int pass): MultilayerBaseOperation(pass) {
+ this->addOutputSocket(COM_DT_VECTOR);
+ }
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
new file mode 100644
index 00000000000..ade2fde8d07
--- /dev/null
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#include "COM_NormalizeOperation.h"
+
+NormalizeOperation::NormalizeOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->imageReader = NULL;
+ this->cachedInstance = NULL;
+ this->setComplex(true);
+}
+void NormalizeOperation::initExecution() {
+ this->imageReader = this->getInputSocketReader(0);
+ NodeOperation::initMutex();
+}
+
+void NormalizeOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ /* using generic two floats struct to store x: min y: mult */
+ NodeTwoFloats *minmult = (NodeTwoFloats *)data;
+
+ float output[4];
+ this->imageReader->read(output, x, y, inputBuffers, NULL);
+
+ color[0] = (output[0] - minmult->x) * minmult->y;
+}
+
+void NormalizeOperation::deinitExecution() {
+ this->imageReader = NULL;
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ }
+ NodeOperation::deinitMutex();
+}
+
+bool NormalizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti imageInput;
+
+ NodeOperation* operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
+ return true;
+ }
+ return false;
+}
+
+/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
+#define BLENDER_ZMAX 10000.0f
+
+void* NormalizeOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+
+ BLI_mutex_lock(getMutex());
+
+ if (this->cachedInstance == NULL) {
+ MemoryBuffer* tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ /* using generic two floats struct to store x: min y: mult */
+ NodeTwoFloats *minmult = new NodeTwoFloats();
+
+ float *buffer = tile->getBuffer();
+ int p = tile->getWidth() * tile->getHeight();
+ float *bc = buffer;
+
+ float minv = 1.0f+BLENDER_ZMAX;
+ float maxv = -1.0f-BLENDER_ZMAX;
+
+ float value;
+ while (p--) {
+ value=bc[0];
+ maxv = max(value, maxv);
+ minv = min(value, minv);
+ bc+=4;
+ }
+
+ minmult->x = minv;
+ /* The rare case of flat buffer would cause a divide by 0 */
+ minmult->y = ((maxv!=minv)? 1.0f/(maxv-minv):0.f);
+
+ this->cachedInstance = minmult;
+ }
+
+ BLI_mutex_unlock(getMutex());
+ return this->cachedInstance;
+}
+
+void NormalizeOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) {
+}
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h
new file mode 100644
index 00000000000..9475cd3852a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2012, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Dalai Felinto
+ */
+
+#ifndef _COM_NormalizeOperation_h
+#define _COM_NormalizeOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief base class of normalize, implementing the simple normalize
+ * @ingroup operation
+ */
+class NormalizeOperation : public NodeOperation {
+protected:
+ /**
+ * @brief Cached reference to the reader
+ */
+ SocketReader * imageReader;
+
+ /**
+ * @brief temporarily cache of the execution storage
+ * it stores x->min and y->mult
+ */
+ NodeTwoFloats * cachedInstance;
+
+public:
+ NormalizeOperation();
+
+ /**
+ * 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);
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl
new file mode 100644
index 00000000000..d462f5d8250
--- /dev/null
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl
@@ -0,0 +1,9 @@
+/// This file contains all opencl kernels for node-operation implementations
+
+__kernel void testKernel(__global __write_only image2d_t output){
+ int x = get_global_id(0);
+ int y = get_global_id(1);
+ int2 coords = {x, y};
+ float4 color = {0.0f, 1.0f, 0.0f, 1.0f};
+ write_imagef(output, coords, color);
+}
diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl.cpp b/source/blender/compositor/operations/COM_OpenCLKernels.cl.cpp
new file mode 100644
index 00000000000..4cf50823c00
--- /dev/null
+++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl.cpp
@@ -0,0 +1,14 @@
+/// @todo: this source needs to be generated from COM_OpenCLKernels.cl.
+/// not implemented yet. new data to h
+
+const char* sourcecode = "/// This file contains all opencl kernels for node-operation implementations \n" \
+"\n" \
+"__kernel void testKernel(__global __write_only image2d_t output){\n" \
+" int x = get_global_id(0);\n" \
+" int y = get_global_id(1);\n" \
+" int2 coords = {x, y}; \n" \
+" float4 color = {0.0f, 1.0f, 0.0f, 1.0f};\n" \
+" write_imagef(output, coords, color);\n" \
+"}\n" \
+"\0\n";
+
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
new file mode 100644
index 00000000000..e410dd966c8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#include "COM_OutputFileOperation.h"
+#include "COM_SocketConnection.h"
+#include <string.h>
+#include "BLI_listbase.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+static int get_datatype_size(DataType datatype)
+{
+ switch (datatype) {
+ case COM_DT_VALUE: return 1;
+ case COM_DT_VECTOR: return 3;
+ case COM_DT_COLOR: return 4;
+ default: return 0;
+ }
+}
+
+static float *init_buffer(unsigned int width, unsigned int height, DataType datatype) {
+ // When initializing the tree during initial load the width and height can be zero.
+ if (width != 0 && height != 0) {
+ int size = get_datatype_size(datatype);
+ return (float *)MEM_callocN(width*height*size*sizeof(float), "OutputFile buffer");
+ }
+ else
+ return NULL;
+}
+
+static void write_buffer_rect(rcti *rect, MemoryBuffer** memoryBuffers, const bNodeTree *tree,
+ SocketReader *reader, float* buffer, unsigned int width, DataType datatype)
+{
+ float color[4];
+ int i, size = get_datatype_size(datatype);
+
+ if (!buffer) return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1*width + x1 ) * size;
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1 ; y < y2 && (!breaked); y++) {
+ for (x = x1 ; x < x2 && (!breaked) ; x++) {
+ reader->read(color, x, y, COM_PS_NEAREST, memoryBuffers);
+
+ for (i=0; i < size; ++i)
+ buffer[offset+i] = color[i];
+ offset += size;
+
+ if (tree->test_break && tree->test_break(tree->tbh))
+ breaked = true;
+ }
+ offset += (width-(x2-x1)) * size;
+ }
+}
+
+
+OutputSingleLayerOperation::OutputSingleLayerOperation(
+ const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
+{
+ this->scene = scene;
+ this->tree = tree;
+
+ this->addInputSocket(datatype);
+
+ this->outputBuffer = NULL;
+ this->datatype = datatype;
+ this->imageInput = NULL;
+
+ this->format = format;
+ BLI_strncpy(this->path, path, sizeof(this->path));
+}
+
+void OutputSingleLayerOperation::initExecution() {
+ this->imageInput = getInputSocketReader(0);
+ this->outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->datatype);
+}
+
+void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) {
+ write_buffer_rect(rect, memoryBuffers, this->tree, imageInput, this->outputBuffer, this->getWidth(), this->datatype);
+}
+
+void OutputSingleLayerOperation::deinitExecution()
+{
+ if (this->getWidth() * this->getHeight() != 0) {
+
+ int size = get_datatype_size(this->datatype);
+ ImBuf *ibuf= IMB_allocImBuf(this->getWidth(), this->getHeight(), size*8, 0);
+ Main *bmain= G.main; /* TODO, have this passed along */
+ char filename[FILE_MAX];
+
+ ibuf->channels = size;
+ ibuf->rect_float= this->outputBuffer;
+ ibuf->mall |= IB_rectfloat;
+ ibuf->dither= scene->r.dither_intensity;
+
+ if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+ ibuf->profile = IB_PROFILE_LINEAR_RGB;
+
+ BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, this->format->imtype,
+ (this->scene->r.scemode & R_EXTENSION), true);
+
+ if (0 == BKE_imbuf_write(ibuf, filename, this->format))
+ printf("Cannot save Node File Output to %s\n", filename);
+ else
+ printf("Saved: %s\n", filename);
+
+ IMB_freeImBuf(ibuf);
+ }
+ this->outputBuffer = NULL;
+ this->imageInput = NULL;
+}
+
+
+OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype)
+{
+ BLI_strncpy(this->name, name, sizeof(this->name));
+ this->datatype = datatype;
+ /* these are created in initExecution */
+ this->outputBuffer = 0;
+ this->imageInput = 0;
+}
+
+OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(
+ const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec)
+{
+ this->scene = scene;
+ this->tree = tree;
+
+ BLI_strncpy(this->path, path, sizeof(this->path));
+ this->exr_codec = exr_codec;
+}
+
+void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype)
+{
+ this->addInputSocket(datatype);
+ layers.push_back(OutputOpenExrLayer(name, datatype));
+}
+
+void OutputOpenExrMultiLayerOperation::initExecution()
+{
+ for (int i=0; i < layers.size(); ++i) {
+ layers[i].imageInput = getInputSocketReader(i);
+ layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), layers[i].datatype);
+ }
+}
+
+void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers)
+{
+ for (int i=0; i < layers.size(); ++i) {
+ write_buffer_rect(rect, memoryBuffers, this->tree, layers[i].imageInput, layers[i].outputBuffer, this->getWidth(), layers[i].datatype);
+ }
+}
+
+void OutputOpenExrMultiLayerOperation::deinitExecution()
+{
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
+ if (width != 0 && height != 0) {
+ Main *bmain= G.main; /* TODO, have this passed along */
+ char filename[FILE_MAX];
+ void *exrhandle= IMB_exr_get_handle();
+
+ BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, R_IMF_IMTYPE_MULTILAYER,
+ (this->scene->r.scemode & R_EXTENSION), true);
+ BLI_make_existing_file(filename);
+
+ for (int i=0; i < layers.size(); ++i) {
+ char channelname[EXR_TOT_MAXNAME];
+ BLI_strncpy(channelname, layers[i].name, sizeof(channelname)-2);
+ char *channelname_ext = channelname + strlen(channelname);
+
+ float *buf = layers[i].outputBuffer;
+
+ /* create channels */
+ switch (layers[i].datatype) {
+ case COM_DT_VALUE:
+ strcpy(channelname_ext, ".V");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 1, width, buf);
+ break;
+ case COM_DT_VECTOR:
+ strcpy(channelname_ext, ".X");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf);
+ strcpy(channelname_ext, ".Y");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf+1);
+ strcpy(channelname_ext, ".Z");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 3, 3*width, buf+2);
+ break;
+ case COM_DT_COLOR:
+ strcpy(channelname_ext, ".R");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf);
+ strcpy(channelname_ext, ".G");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+1);
+ strcpy(channelname_ext, ".B");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+2);
+ strcpy(channelname_ext, ".A");
+ IMB_exr_add_channel(exrhandle, 0, channelname, 4, 4*width, buf+3);
+ break;
+ default:
+ break;
+ }
+
+ }
+
+ /* when the filename has no permissions, this can fail */
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->exr_codec)) {
+ IMB_exr_write_channels(exrhandle);
+ }
+ else {
+ /* TODO, get the error from openexr's exception */
+ /* XXX nice way to do report? */
+ printf("Error Writing Render Result, see console\n");
+ }
+
+ IMB_exr_close(exrhandle);
+ for (int i=0; i < layers.size(); ++i) {
+ if (layers[i].outputBuffer) {
+ MEM_freeN(layers[i].outputBuffer);
+ layers[i].outputBuffer = NULL;
+ }
+
+ layers[i].imageInput = NULL;
+ }
+ }
+}
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
new file mode 100644
index 00000000000..0fbe874e9e0
--- /dev/null
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ * Lukas Tönne
+ */
+
+#ifndef _COM_OutputFileOperation_h
+#define _COM_OutputFileOperation_h
+#include "COM_NodeOperation.h"
+#include "BLI_rect.h"
+#include "BKE_utildefines.h"
+
+#include "intern/openexr/openexr_multi.h"
+
+/* Writes the image to a single-layer file. */
+class OutputSingleLayerOperation : public NodeOperation {
+private:
+ const Scene *scene;
+ const bNodeTree* tree;
+
+ ImageFormatData *format;
+ char path[FILE_MAX];
+
+ float *outputBuffer;
+ DataType datatype;
+ SocketReader* imageInput;
+
+public:
+ OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
+
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ bool isOutputOperation(bool rendering) const {return true;}
+ void initExecution();
+ void deinitExecution();
+ const int getRenderPriority() const {return 7;}
+};
+
+/* extra info for OpenEXR layers */
+struct OutputOpenExrLayer {
+ OutputOpenExrLayer(const char *name, DataType datatype);
+
+ char name[EXR_TOT_MAXNAME-2];
+ float *outputBuffer;
+ DataType datatype;
+ SocketReader* imageInput;
+};
+
+/* Writes inputs into OpenEXR multilayer channels. */
+class OutputOpenExrMultiLayerOperation : public NodeOperation {
+private:
+ typedef std::vector<OutputOpenExrLayer> LayerList;
+
+ const Scene *scene;
+ const bNodeTree* tree;
+
+ char path[FILE_MAX];
+ char exr_codec;
+ LayerList layers;
+
+public:
+ OutputOpenExrMultiLayerOperation(const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec);
+
+ void add_layer(const char *name, DataType datatype);
+
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ bool isOutputOperation(bool rendering) const {return true;}
+ void initExecution();
+ void deinitExecution();
+ const int getRenderPriority() const {return 7;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
new file mode 100644
index 00000000000..5191c940f70
--- /dev/null
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_PreviewOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+#include "WM_api.h"
+#include "WM_types.h"
+#include "PIL_time.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_color.h"
+#include "COM_defines.h"
+#include "BLI_math.h"
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+
+PreviewOperation::PreviewOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->outputBuffer = NULL;
+ this->input = NULL;
+ this->divider = 1.0f;
+ this->node = NULL;
+ this->priority = 0;
+}
+
+void PreviewOperation::initExecution() {
+ this->input = getInputSocketReader(0);
+ if (!this->node->preview) {
+ this->node->preview = (bNodePreview*)MEM_callocN(sizeof(bNodePreview), "node preview");
+ } else {
+ if (this->getWidth() == (unsigned int)this->node->preview->xsize && this->getHeight() == (unsigned int)this->node->preview->ysize) {
+ this->outputBuffer = this->node->preview->rect;
+ }
+ }
+
+ if (this->outputBuffer == NULL) {
+ this->outputBuffer = (unsigned char*)MEM_callocN(sizeof(unsigned char)*4*getWidth()*getHeight(), "PreviewOperation");
+ if(this->node->preview->rect) {
+ MEM_freeN(this->node->preview->rect);
+ }
+ this->node->preview->xsize= getWidth();
+ this->node->preview->ysize= getHeight();
+ this->node->preview->rect= outputBuffer;
+ }
+}
+
+void PreviewOperation::deinitExecution() {
+ this->outputBuffer = NULL;
+ this->input = NULL;
+}
+
+void PreviewOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers) {
+ int offset;
+ float color[4];
+ for (int y = rect->ymin ; y < rect->ymax ; y++) {
+ offset = (y * getWidth() + rect->xmin)*4;
+ for (int x = rect->xmin ; x < rect->xmax ; x++) {
+ float rx = floor(x/divider);
+ float ry = floor(y/divider);
+
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 1.0f;
+ input->read(color, rx, ry, COM_PS_NEAREST, memoryBuffers);
+ /// @todo: linear conversion only when scene color management is selected, also check predivide.
+ linearrgb_to_srgb_v4(color, color);
+ F4TOCHAR4(color, outputBuffer+offset);
+ offset +=4;
+ }
+ }
+}
+bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmin = input->xmin/divider;
+ newInput.xmax = input->xmax/divider;
+ newInput.ymin = input->ymin/divider;
+ newInput.ymax = input->ymax/divider;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+void PreviewOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ int width = resolution[0];
+ int height = resolution[1];
+ this->divider = 0.0f;
+ if (width > height) {
+ divider = COM_PREVIEW_SIZE / (width-1);
+ } else {
+ divider = COM_PREVIEW_SIZE / (height-1);
+ }
+ width = width * divider;
+ height = height * divider;
+
+ resolution[0] = width;
+ resolution[1] = height;
+}
+
+const int PreviewOperation::getRenderPriority() const {
+ return this->priority;
+}
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
new file mode 100644
index 00000000000..c36c85ad746
--- /dev/null
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_PreviewOperation_h
+#define _COM_PreviewOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_image_types.h"
+#include "BLI_rect.h"
+
+class PreviewOperation : public NodeOperation {
+protected:
+ unsigned char *outputBuffer;
+
+ /**
+ * @brief holds reference to the SDNA bNode, where this nodes will render the preview image for
+ */
+ bNode* node;
+ const bNodeTree* tree;
+ SocketReader* input;
+ float divider;
+ int priority;
+
+public:
+ PreviewOperation();
+ bool isOutputOperation(bool rendering) const {return true;}
+ void initExecution();
+ void deinitExecution();
+ const int getRenderPriority() const;
+
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+ void setbNode(bNode* node) { this->node = node;}
+ void setbNodeTree(const bNodeTree* tree) { this->tree = tree;}
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void setPriority(int priority) { this->priority = priority; }
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
new file mode 100644
index 00000000000..adb72f9abb3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ProjectorLensDistortionOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+ProjectorLensDistortionOperation::ProjectorLensDistortionOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->inputProgram = NULL;
+}
+void ProjectorLensDistortionOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ kr = 0.25f*MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr2 = kr * 20;
+}
+
+void* ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ void* buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void ProjectorLensDistortionOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float inputValue[4];
+ const float height = this->getHeight();
+ const float width = this->getWidth();
+ const float v = (y + 0.5f)/height;
+ const float u = (x + 0.5f)/width;
+ MemoryBuffer * inputBuffer = (MemoryBuffer*)data;
+ inputBuffer->readCubic(inputValue, (u*width + kr2) - 0.5f, v*height - 0.5f);
+ color[0] = inputValue[0];
+ inputBuffer->read(inputValue, x, y);
+ color[1] = inputValue[1];
+ inputBuffer->readCubic(inputValue, (u*width - kr2) - 0.5f, v*height - 0.5f);
+ color[2] = inputValue[2];
+ color[3] = 1.0f;
+}
+
+void ProjectorLensDistortionOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
+bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ newInput.xmin = input->xmin-kr2-2;
+ newInput.xmax = input->xmax+kr2+2;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
new file mode 100644
index 00000000000..6b05dbfcd41
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ProjectorLensDistortionOperation_h
+#define _COM_ProjectorLensDistortionOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+class ProjectorLensDistortionOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+
+ NodeLensDist * data;
+
+ float dispersion;
+ float kr, kr2;
+public:
+ ProjectorLensDistortionOperation();
+
+ /**
+ * 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);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeLensDist* data) {this->data = data;}
+ void setDispertion(float dispersion) {this->dispersion = dispersion;}
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
new file mode 100644
index 00000000000..c21163e03ac
--- /dev/null
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_QualityStepHelper.h"
+
+QualityStepHelper::QualityStepHelper() {
+ this->quality = COM_QUALITY_HIGH;
+ this->step = 1;
+ this->offsetadd = 4;
+}
+
+void QualityStepHelper::initExecution(QualityHelper helper) {
+ switch (helper) {
+ case COM_QH_INCREASE:
+ switch (this->quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->step = 1;
+ this->offsetadd = 4;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->step = 2;
+ this->offsetadd = 8;
+ break;
+ case COM_QUALITY_LOW:
+ this->step = 3;
+ this->offsetadd = 12;
+ break;
+ }
+ break;
+ case COM_QH_MULTIPLY:
+ switch (this->quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->step = 1;
+ this->offsetadd = 4;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->step = 2;
+ this->offsetadd = 8;
+ break;
+ case COM_QUALITY_LOW:
+ this->step = 4;
+ this->offsetadd = 16;
+ break;
+ }
+ break;
+ }
+}
+
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h
new file mode 100644
index 00000000000..ff4870f03bd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_QualityStepHelper_h
+#define _COM_QualityStepHelper_h
+#include "COM_defines.h"
+
+typedef enum QualityHelper {
+ COM_QH_INCREASE,
+ COM_QH_MULTIPLY
+} QualityHelper;
+
+class QualityStepHelper {
+private:
+ CompositorQuality quality;
+ int step;
+ int offsetadd;
+
+protected:
+ /**
+ * Initialize the execution
+ */
+ void initExecution(QualityHelper helper);
+
+ inline int getStep() const {return this->step;}
+ inline int getOffsetAdd() const {return this->offsetadd;}
+
+public:
+ QualityStepHelper();
+
+
+ void setQuality(CompositorQuality quality) {this->quality = quality;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
new file mode 100644
index 00000000000..483a75a69d2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ReadBufferOperation.h"
+#include "COM_WriteBufferOperation.h"
+#include "COM_defines.h"
+
+ReadBufferOperation::ReadBufferOperation():NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+ this->offset = 0;
+}
+
+void* ReadBufferOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ return getInputMemoryBuffer(memoryBuffers);
+}
+
+void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ if (this->memoryProxy != NULL) {
+ WriteBufferOperation * operation = memoryProxy->getWriteBufferOperation();
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
+
+ /// @todo: may not occur!, but does with blur node
+ if (memoryProxy->getExecutor()) memoryProxy->getExecutor()->setResolution(resolution);
+ }
+}
+void ReadBufferOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ MemoryBuffer *inputBuffer = inputBuffers[this->offset];
+ if (inputBuffer) {
+ if (sampler == COM_PS_NEAREST) {
+ inputBuffer->read(color, x, y);
+ } else {
+ inputBuffer->readCubic(color, x, y);
+ }
+ }
+}
+
+void ReadBufferOperation::executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]) {
+ MemoryBuffer *inputBuffer = inputBuffers[this->offset];
+ if (inputBuffer) {
+ inputBuffer->readEWA(color, x, y, dx, dy);
+ }
+}
+
+bool ReadBufferOperation::determineDependingAreaOfInterest(rcti * input, ReadBufferOperation* readOperation, rcti* output) {
+ if (this==readOperation) {
+ BLI_init_rcti(output, input->xmin, input->xmax, input->ymin, input->ymax);
+ return true;
+ }
+ return false;
+}
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
new file mode 100644
index 00000000000..807f615f2e1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ReadBufferOperation_h
+#define _COM_ReadBufferOperation_h
+
+#include "COM_NodeOperation.h"
+#include "COM_MemoryProxy.h"
+
+class ReadBufferOperation: public NodeOperation {
+private:
+ MemoryProxy *memoryProxy;
+ unsigned int offset;
+public:
+ ReadBufferOperation();
+ int isBufferOperation() {return true;}
+ void setMemoryProxy(MemoryProxy* memoryProxy) {this->memoryProxy = memoryProxy;}
+ MemoryProxy* getMemoryProxy() {return this->memoryProxy;}
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void executePixel(float *color, float x, float y, float dx, float dy, MemoryBuffer *inputBuffers[]);
+ const bool isReadBufferOperation() const {return true;}
+ void setOffset(unsigned int offset) {this->offset = offset;}
+ unsigned int getOffset() {return this->offset;}
+ bool determineDependingAreaOfInterest(rcti * input, ReadBufferOperation *readOperation, rcti* output);
+ MemoryBuffer* getInputMemoryBuffer(MemoryBuffer** memoryBuffers) {return memoryBuffers[offset];}
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp
new file mode 100644
index 00000000000..a73f29c3615
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersAOOperation.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersAOOperation.h"
+
+RenderLayersAOOperation::RenderLayersAOOperation() :RenderLayersBaseProg(SCE_PASS_AO, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+
diff --git a/source/blender/compositor/operations/COM_RenderLayersAOOperation.h b/source/blender/compositor/operations/COM_RenderLayersAOOperation.h
new file mode 100644
index 00000000000..71b0b885e81
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersAOOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersAOOperation_h
+#define _COM_RenderLayersAOOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersAOOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersAOOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp
new file mode 100644
index 00000000000..d85d54489ac
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersAlphaProg.h"
+
+RenderLayersAlphaProg::RenderLayersAlphaProg() :RenderLayersBaseProg(SCE_PASS_COMBINED, 4) {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+
+void RenderLayersAlphaProg::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ int ix = x;
+ int iy = y;
+ float * inputBuffer = this->getInputBuffer();
+
+ if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) {
+ output[0] = 0.0f;
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 0.0f;
+ } else {
+ unsigned int offset = (iy*this->getWidth()+ix) * 4;
+ output[0] = inputBuffer[offset+3];
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 0.0f;
+ }
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h
new file mode 100644
index 00000000000..6386915230c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersAlphaProg.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersAlphaProg_h
+#define _COM_RenderLayersAlphaProg_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersAlphaProg : public RenderLayersBaseProg {
+public:
+ RenderLayersAlphaProg();
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
new file mode 100644
index 00000000000..e63fcd5df4d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.cpp
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersBaseProg.h"
+
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+}
+
+RenderLayersBaseProg::RenderLayersBaseProg(int renderpass, int elementsize): NodeOperation() {
+ this->renderpass = renderpass;
+ this->setScene(NULL);
+ this->inputBuffer = NULL;
+ this->elementsize = elementsize;
+}
+
+
+void RenderLayersBaseProg::initExecution() {
+ Scene * scene = this->getScene();
+ Render *re= (scene)? RE_GetRender(scene->id.name): NULL;
+ RenderResult *rr= NULL;
+
+ if(re)
+ rr= RE_AcquireResultRead(re);
+
+ if(rr) {
+ SceneRenderLayer *srl= (SceneRenderLayer*)BLI_findlink(&scene->r.layers, getLayerId());
+ if(srl) {
+
+ RenderLayer *rl= RE_GetRenderLayer(rr, srl->name);
+ if(rl && rl->rectf) {
+ this->inputBuffer = RE_RenderLayerGetPass(rl, renderpass);
+
+ if (this->inputBuffer == NULL || renderpass == SCE_PASS_COMBINED) {
+ this->inputBuffer = rl->rectf;
+ }
+ }
+ }
+ }
+ if (re) {
+ RE_ReleaseResult(re);
+ re = NULL;
+ }
+}
+
+void RenderLayersBaseProg::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ int ix = x;
+ int iy = y;
+
+ if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) {
+ output[0] = 0.0f;
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 0.0f;
+ } else {
+ unsigned int offset = (iy*this->getWidth()+ix) * elementsize;
+ if (elementsize == 1) {
+ output[0] = inputBuffer[offset];
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 0.0f;
+ } else if (elementsize == 3){
+ output[0] = inputBuffer[offset];
+ output[1] = inputBuffer[offset+1];
+ output[2] = inputBuffer[offset+2];
+ output[3] = 1.0f;
+ } else {
+ output[0] = inputBuffer[offset];
+ output[1] = inputBuffer[offset+1];
+ output[2] = inputBuffer[offset+2];
+ output[3] = inputBuffer[offset+3];
+ }
+ }
+}
+
+void RenderLayersBaseProg::deinitExecution() {
+ this->inputBuffer = NULL;
+}
+
+void RenderLayersBaseProg::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ Scene *sce= this->getScene();
+ Render *re= (sce)? RE_GetRender(sce->id.name): NULL;
+ RenderResult *rr= NULL;
+
+ resolution[0] = 0;
+ resolution[1] = 0;
+
+ if(re)
+ rr= RE_AcquireResultRead(re);
+
+ if(rr) {
+ SceneRenderLayer *srl= (SceneRenderLayer*)BLI_findlink(&sce->r.layers, getLayerId());
+ if(srl) {
+ RenderLayer *rl= RE_GetRenderLayer(rr, srl->name);
+ if(rl && rl->rectf) {
+ resolution[0]=rl->rectx;
+ resolution[1]=rl->recty;
+ }
+ }
+ }
+
+ if(re)
+ RE_ReleaseResult(re);
+
+}
+
diff --git a/source/blender/compositor/operations/COM_RenderLayersBaseProg.h b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
new file mode 100644
index 00000000000..a1802d1db65
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersBaseProg.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+
+#ifndef _COM_RenderLayersBaseProg_h
+#define _COM_RenderLayersBaseProg_h
+
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "BLI_listbase.h"
+#include "BKE_image.h"
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+ #include "MEM_guardedalloc.h"
+}
+
+/**
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
+class RenderLayersBaseProg : public NodeOperation {
+private:
+ /**
+ * Reference to the scene object.
+ */
+ Scene* scene;
+
+ /**
+ * layerId of the layer where this operation needs to get its data from
+ */
+ short layerId;
+
+ /**
+ * cached instance to the float buffer inside the layer
+ */
+ float* inputBuffer;
+
+ /**
+ * renderpass where this operation needs to get its data from
+ */
+ int renderpass;
+
+ int elementsize;
+
+protected:
+ /**
+ * Constructor
+ */
+ RenderLayersBaseProg(int renderpass, int elementsize);
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ /**
+ * retrieve the reference to the float buffer of the renderer.
+ */
+ inline float* getInputBuffer() {return this->inputBuffer;}
+
+public:
+ /**
+ * setter for the scene field. Will be called from
+ * @see RenderLayerNode to set the actual scene where
+ * the data will be retrieved from.
+ */
+ void setScene(Scene* scene) {this->scene = scene;}
+ Scene* getScene() {return this->scene;}
+ void setLayerId(short layerId) {this->layerId = layerId;}
+ short getLayerId() {return this->layerId;}
+ void initExecution();
+ void deinitExecution();
+ void executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp
new file mode 100644
index 00000000000..71461ac0e3f
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersColorOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersColorOperation.h"
+
+RenderLayersColorOperation::RenderLayersColorOperation() :RenderLayersBaseProg(SCE_PASS_RGBA, 4) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersColorOperation.h b/source/blender/compositor/operations/COM_RenderLayersColorOperation.h
new file mode 100644
index 00000000000..4f4dfbfb6f3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersColorOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersColorOperation_h
+#define _COM_RenderLayersColorOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersColorOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersColorOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp
new file mode 100644
index 00000000000..17e2c6683d9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersCyclesOperation.h"
+
+RenderLayersCyclesOperation::RenderLayersCyclesOperation(int pass) :RenderLayersBaseProg(pass, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.h b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.h
new file mode 100644
index 00000000000..baa53c7388b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersCyclesOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersCyclesOperation_h
+#define _COM_RenderLayersCyclesOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersCyclesOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersCyclesOperation(int pass);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp b/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp
new file mode 100644
index 00000000000..badb9189206
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersDepthProg.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersDepthProg.h"
+
+RenderLayersDepthProg::RenderLayersDepthProg() :RenderLayersBaseProg(SCE_PASS_Z, 1) {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+
diff --git a/source/blender/compositor/operations/COM_RenderLayersDepthProg.h b/source/blender/compositor/operations/COM_RenderLayersDepthProg.h
new file mode 100644
index 00000000000..fdbe25c818e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersDepthProg.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersDepthProg_h
+#define _COM_RenderLayersDepthProg_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersDepthProg : public RenderLayersBaseProg {
+public:
+ RenderLayersDepthProg();
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp
new file mode 100644
index 00000000000..6c3359ed063
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersDiffuseOperation.h"
+
+RenderLayersDiffuseOperation::RenderLayersDiffuseOperation() :RenderLayersBaseProg(SCE_PASS_DIFFUSE, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.h b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.h
new file mode 100644
index 00000000000..8c20d6f497d
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersDiffuseOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersDiffuseOperation_h
+#define _COM_RenderLayersDiffuseOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersDiffuseOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersDiffuseOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp
new file mode 100644
index 00000000000..936b1f0c59a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersEmitOperation.h"
+
+RenderLayersEmitOperation::RenderLayersEmitOperation() :RenderLayersBaseProg(SCE_PASS_EMIT, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersEmitOperation.h b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.h
new file mode 100644
index 00000000000..c003cb2f87b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersEmitOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersEmitOperation_h
+#define _COM_RenderLayersEmitOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersEmitOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersEmitOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp
new file mode 100644
index 00000000000..642f07d7e16
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersEnvironmentOperation.h"
+
+RenderLayersEnvironmentOperation::RenderLayersEnvironmentOperation() :RenderLayersBaseProg(SCE_PASS_ENVIRONMENT, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.h b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.h
new file mode 100644
index 00000000000..b9310a1778b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersEnvironmentOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersEnvironmentOperation_h
+#define _COM_RenderLayersEnvironmentOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersEnvironmentOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersEnvironmentOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp
new file mode 100644
index 00000000000..a58f16b10a1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersImageProg.h"
+
+RenderLayersColourProg::RenderLayersColourProg() :RenderLayersBaseProg(SCE_PASS_COMBINED, 4) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.h b/source/blender/compositor/operations/COM_RenderLayersImageProg.h
new file mode 100644
index 00000000000..b6ddac425cb
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersColourProg_h
+#define _COM_RenderLayersColourProg_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+/// @TODO rename to image operation
+class RenderLayersColourProg : public RenderLayersBaseProg {
+public:
+ RenderLayersColourProg();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp
new file mode 100644
index 00000000000..db61c237c61
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersIndirectOperation.h"
+
+RenderLayersIndirectOperation::RenderLayersIndirectOperation() :RenderLayersBaseProg(SCE_PASS_INDIRECT, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.h b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.h
new file mode 100644
index 00000000000..d64207a4355
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersIndirectOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersIndirectOperation_h
+#define _COM_RenderLayersIndirectOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersIndirectOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersIndirectOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp
new file mode 100644
index 00000000000..96bab2569dd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersMaterialIndexOperation.h"
+
+RenderLayersMaterialIndexOperation::RenderLayersMaterialIndexOperation() :RenderLayersBaseProg(SCE_PASS_INDEXMA, 1) {
+ this->addOutputSocket(COM_DT_VALUE);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.h b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.h
new file mode 100644
index 00000000000..d06568f5a10
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersMaterialIndexOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersMaterialIndexOperation_h
+#define _COM_RenderLayersMaterialIndexOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersMaterialIndexOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersMaterialIndexOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp
new file mode 100644
index 00000000000..d3be993b3f9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersMistOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersMistOperation.h"
+
+RenderLayersMistOperation::RenderLayersMistOperation() :RenderLayersBaseProg(SCE_PASS_MIST, 1) {
+ this->addOutputSocket(COM_DT_VALUE);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersMistOperation.h b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h
new file mode 100644
index 00000000000..8c0ee9bfcab
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersMistOperation.h
@@ -0,0 +1,11 @@
+#ifndef _COM_RenderLayersMistOperation_h
+#define _COM_RenderLayersMistOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersMistOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersMistOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp
new file mode 100644
index 00000000000..dba40e3cc7a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersNormalOperation.h"
+
+RenderLayersNormalOperation::RenderLayersNormalOperation() :RenderLayersBaseProg(SCE_PASS_NORMAL, 3) {
+ this->addOutputSocket(COM_DT_VECTOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersNormalOperation.h b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.h
new file mode 100644
index 00000000000..39b2040863a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersNormalOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersNormalOperation_h
+#define _COM_RenderLayersNormalOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersNormalOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersNormalOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp
new file mode 100644
index 00000000000..d4d14de6d98
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersObjectIndexOperation.h"
+
+RenderLayersObjectIndexOperation::RenderLayersObjectIndexOperation() :RenderLayersBaseProg(SCE_PASS_INDEXOB, 1) {
+ this->addOutputSocket(COM_DT_VALUE);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.h b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.h
new file mode 100644
index 00000000000..e8a1602cbfc
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersObjectIndexOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersObjectIndexOperation_h
+#define _COM_RenderLayersObjectIndexOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersObjectIndexOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersObjectIndexOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp
new file mode 100644
index 00000000000..0417a6fade2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersReflectionOperation.h"
+
+RenderLayersReflectionOperation::RenderLayersReflectionOperation() :RenderLayersBaseProg(SCE_PASS_REFLECT, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.h b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.h
new file mode 100644
index 00000000000..3dc7148930b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersReflectionOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersReflectionOperation_h
+#define _COM_RenderLayersReflectionOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersReflectionOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersReflectionOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp
new file mode 100644
index 00000000000..74042f46f78
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersRefractionOperation.h"
+
+RenderLayersRefractionOperation::RenderLayersRefractionOperation() :RenderLayersBaseProg(SCE_PASS_REFRACT, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.h b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.h
new file mode 100644
index 00000000000..02ac7aa14f4
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersRefractionOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersRefractionOperation_h
+#define _COM_RenderLayersRefractionOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersRefractionOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersRefractionOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp
new file mode 100644
index 00000000000..87155607d82
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersShadowOperation.h"
+
+RenderLayersShadowOperation::RenderLayersShadowOperation() :RenderLayersBaseProg(SCE_PASS_SHADOW, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersShadowOperation.h b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.h
new file mode 100644
index 00000000000..af35915c2ee
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersShadowOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersShadowOperation_h
+#define _COM_RenderLayersShadowOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersShadowOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersShadowOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp
new file mode 100644
index 00000000000..ed6a0853436
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersSpecularOperation.h"
+
+RenderLayersSpecularOperation::RenderLayersSpecularOperation() :RenderLayersBaseProg(SCE_PASS_SPEC, 3) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.h b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.h
new file mode 100644
index 00000000000..fc7d77976a3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersSpecularOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersSpecularOperation_h
+#define _COM_RenderLayersSpecularOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersSpecularOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersSpecularOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
new file mode 100644
index 00000000000..0a76d04959e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersSpeedOperation.h"
+
+RenderLayersSpeedOperation::RenderLayersSpeedOperation() :RenderLayersBaseProg(SCE_PASS_VECTOR, 4) {
+ this->addOutputSocket(COM_DT_COLOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.h b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.h
new file mode 100644
index 00000000000..d341aa43950
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersSpeedOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersSpeedOperation_h
+#define _COM_RenderLayersSpeedOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersSpeedOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersSpeedOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp b/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp
new file mode 100644
index 00000000000..b15bbb0f3dd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersUVOperation.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RenderLayersUVOperation.h"
+
+RenderLayersUVOperation::RenderLayersUVOperation() :RenderLayersBaseProg(SCE_PASS_UV, 3) {
+ this->addOutputSocket(COM_DT_VECTOR);
+}
diff --git a/source/blender/compositor/operations/COM_RenderLayersUVOperation.h b/source/blender/compositor/operations/COM_RenderLayersUVOperation.h
new file mode 100644
index 00000000000..3068372a66c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RenderLayersUVOperation.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RenderLayersUVOperation_h
+#define _COM_RenderLayersUVOperation_h
+
+#include "COM_RenderLayersBaseProg.h"
+
+class RenderLayersUVOperation : public RenderLayersBaseProg {
+public:
+ RenderLayersUVOperation();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
new file mode 100644
index 00000000000..ef6c5bee90a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_RotateOperation.h"
+#include "BLI_math.h"
+
+RotateOperation::RotateOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->imageSocket = NULL;
+ this->degreeSocket = NULL;
+ this->doDegree2RadConversion = false;
+}
+void RotateOperation::initExecution() {
+ this->imageSocket = this->getInputSocketReader(0);
+ this->degreeSocket = this->getInputSocketReader(1);
+ this->centerX = this->getWidth()/2.0;
+ this->centerY = this->getHeight()/2.0;
+ float degree[4];
+ this->degreeSocket->read(degree, 0, 0, COM_PS_NEAREST, NULL);
+ double rad;
+ if (this->doDegree2RadConversion) {
+ rad = DEG2RAD(degree[0]);
+ } else {
+ rad = degree[0];
+ }
+ this->cosine = cos(rad);
+ this->sine = sin(rad);
+}
+
+void RotateOperation::deinitExecution() {
+ this->imageSocket = NULL;
+ this->degreeSocket = NULL;
+}
+
+
+void RotateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ const float dy = y - this->centerY;
+ const float dx = x - this->centerX;
+ const float nx = this->centerX+(this->cosine*dx + this->sine*dy);
+ const float ny = this->centerY+(-this->sine*dx + this->cosine*dy);
+ this->imageSocket->read(color, nx, ny, sampler, inputBuffers);
+}
+
+bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ const float dxmin = input->xmin - this->centerX;
+ const float dymin = input->ymin - this->centerY;
+ const float dxmax = input->xmax - this->centerX;
+ const float dymax = input->ymax - this->centerY;
+
+ const float x1 = this->centerX+(this->cosine*dxmin + this->sine*dymin);
+ const float x2 = this->centerX+(this->cosine*dxmax + this->sine*dymin);
+ const float x3 = this->centerX+(this->cosine*dxmin + this->sine*dymax);
+ const float x4 = this->centerX+(this->cosine*dxmax + this->sine*dymax);
+ const float y1 = this->centerY+(-this->sine*dxmin + this->cosine*dymin);
+ const float y2 = this->centerY+(-this->sine*dxmax + this->cosine*dymin);
+ const float y3 = this->centerY+(-this->sine*dxmin + this->cosine*dymax);
+ const float y4 = this->centerY+(-this->sine*dxmax + this->cosine*dymax);
+ const float minx = min(x1, min(x2, min(x3, x4)));
+ const float maxx = max(x1, max(x2, max(x3, x4)));
+ const float miny = min(y1, min(y2, min(y3, y4)));
+ const float maxy = max(y1, max(y2, max(y3, y4)));
+
+ newInput.xmax = ceil(maxx)+1;
+ newInput.xmin = floor(minx)-1;
+ newInput.ymax = ceil(maxy)+1;
+ newInput.ymin = floor(miny)-1;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
new file mode 100644
index 00000000000..9965d1021da
--- /dev/null
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_RotateOperation_h_
+#define _COM_RotateOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class RotateOperation: public NodeOperation {
+private:
+ SocketReader *imageSocket;
+ SocketReader *degreeSocket;
+ float centerX;
+ float centerY;
+ float cosine;
+ float sine;
+ bool doDegree2RadConversion;
+public:
+ RotateOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void initExecution();
+ void deinitExecution();
+ void setDoDegree2RadConversion(bool abool) {this->doDegree2RadConversion = abool;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
new file mode 100644
index 00000000000..ef3d8250bab
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ScaleOperation.h"
+
+ScaleOperation::ScaleOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->inputXOperation = NULL;
+ this->inputYOperation = NULL;
+}
+void ScaleOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ this->inputXOperation = this->getInputSocketReader(1);
+ this->inputYOperation = this->getInputSocketReader(2);
+ this->centerX = this->getWidth()/2.0;
+ this->centerY = this->getHeight()/2.0;
+}
+
+void ScaleOperation::deinitExecution() {
+ this->inputOperation = NULL;
+ this->inputXOperation = NULL;
+ this->inputYOperation = NULL;
+}
+
+
+void ScaleOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float scaleX[4];
+ float scaleY[4];
+
+ this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers);
+ this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+
+ float nx = this->centerX+ (x - this->centerX) / scx;
+ float ny = this->centerY+ (y - this->centerY) / scy;
+ this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
+}
+
+bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ float scaleX[4];
+ float scaleY[4];
+
+ this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL);
+ this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+
+ newInput.xmax = this->centerX+ (input->xmax - this->centerX) / scx;
+ newInput.xmin = this->centerX+ (input->xmin - this->centerX) / scx;
+ newInput.ymax = this->centerY+ (input->ymax - this->centerY) / scy;
+ newInput.ymin = this->centerY+ (input->ymin - this->centerY) / scy;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+
+
+// SCALE ABSOLUTE
+ScaleAbsoluteOperation::ScaleAbsoluteOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->inputXOperation= NULL;
+ this->inputYOperation = NULL;
+}
+void ScaleAbsoluteOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ this->inputXOperation = this->getInputSocketReader(1);
+ this->inputYOperation = this->getInputSocketReader(2);
+ this->centerX = this->getWidth()/2.0;
+ this->centerY = this->getHeight()/2.0;
+}
+
+void ScaleAbsoluteOperation::deinitExecution() {
+ this->inputOperation = NULL;
+ this->inputXOperation = NULL;
+ this->inputYOperation = NULL;
+}
+
+
+void ScaleAbsoluteOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float scaleX[4];
+ float scaleY[4];
+
+ this->inputXOperation->read(scaleX, x, y, sampler, inputBuffers);
+ this->inputYOperation->read(scaleY, x, y, sampler, inputBuffers);
+
+ const float scx = scaleX[0]; // target absolute scale
+ const float scy = scaleY[0]; // target absolute scale
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ //div
+ float relativeXScale = scx/width;
+ float relativeYScale = scy/height;
+
+ float nx = this->centerX+ (x - this->centerX) / relativeXScale;
+ float ny = this->centerY+ (y - this->centerY) / relativeYScale;
+ this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
+}
+
+bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ float scaleX[4];
+ float scaleY[4];
+
+ this->inputXOperation->read(scaleX, 0, 0, COM_PS_NEAREST, NULL);
+ this->inputYOperation->read(scaleY, 0, 0, COM_PS_NEAREST, NULL);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ //div
+ float relateveXScale = scx/width;
+ float relateveYScale = scy/height;
+
+ newInput.xmax = this->centerX+ (input->xmax - this->centerX) / relateveXScale;
+ newInput.xmin = this->centerX+ (input->xmin - this->centerX) / relateveXScale;
+ newInput.ymax = this->centerY+ (input->ymax - this->centerY) / relateveYScale;
+ newInput.ymin = this->centerY+ (input->ymin - this->centerY) / relateveYScale;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+
+
+// Absolute fixed siez
+ScaleFixedSizeOperation::ScaleFixedSizeOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+}
+void ScaleFixedSizeOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ this->relX = inputOperation->getWidth() / (float)this->newWidth;
+ this->relY = inputOperation->getHeight() / (float)this->newHeight;
+}
+
+void ScaleFixedSizeOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
+
+void ScaleFixedSizeOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ this->inputOperation->read(color, x*relX, y*relY, sampler, inputBuffers);
+}
+
+bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmax = input->xmax *relX;
+ newInput.xmin = input->xmin *relX;
+ newInput.ymax = input->ymax *relY;
+ newInput.ymin = input->ymin *relY;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
+
+void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ unsigned int nr[2];
+ nr[0] = newWidth;
+ nr[1] = newHeight;
+ NodeOperation::determineResolution(resolution, nr);
+ resolution[0] = newWidth;
+ resolution[1] = newHeight;
+}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
new file mode 100644
index 00000000000..3e075249fa1
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ScaleOperation_h_
+#define _COM_ScaleOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class ScaleOperation: public NodeOperation {
+private:
+ SocketReader *inputOperation;
+ SocketReader *inputXOperation;
+ SocketReader *inputYOperation;
+ float centerX;
+ float centerY;
+public:
+ ScaleOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+
+class ScaleAbsoluteOperation: public NodeOperation {
+ SocketReader *inputOperation;
+ SocketReader *inputXOperation;
+ SocketReader *inputYOperation;
+ float centerX;
+ float centerY;
+public:
+ ScaleAbsoluteOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+
+class ScaleFixedSizeOperation: public NodeOperation {
+ SocketReader *inputOperation;
+ int newWidth;
+ int newHeight;
+ float relX;
+ float relY;
+public:
+ ScaleFixedSizeOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+ void setNewWidth(int width) {this->newWidth = width;}
+ void setNewHeight(int height) {this->newHeight = height;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
new file mode 100644
index 00000000000..4a4ac6c6833
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ScreenLensDistortionOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+extern "C" {
+ #include "BLI_rand.h"
+}
+
+ScreenLensDistortionOperation::ScreenLensDistortionOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->inputProgram = NULL;
+}
+void ScreenLensDistortionOperation::initExecution() {
+ this->inputProgram = this->getInputSocketReader(0);
+ kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
+ // smaller dispersion range for somewhat more control
+ const float d = 0.25f*MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr = MAX2(MIN2((kg+d), 1.f), -0.999f);
+ kb = MAX2(MIN2((kg-d), 1.f), -0.999f);
+ maxk = MAX3(kr, kg, kb);
+ sc = (this->data->fit && (maxk > 0.f)) ? (1.f/(1.f + 2.f*maxk)) : (1.f/(1.f + maxk));
+ drg = 4.f*(kg - kr);
+ dgb = 4.f*(kb - kg);
+
+ kr4 = kr*4;
+ kg4 = kg*4.f;
+ kb4 *= kb*4.f;
+ cx = 0.5f*(float)getWidth();
+ cy = 0.5f*(float)getHeight();
+
+}
+
+void* ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ void* buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
+ return buffer;
+}
+
+void ScreenLensDistortionOperation::executePixel(float* outputColor, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ const float height = this->getHeight();
+ const float width = this->getWidth();
+ MemoryBuffer* buffer = (MemoryBuffer*)data;
+
+ int dr = 0, dg = 0, db = 0;
+ float d, t, ln[6] = {0, 0, 0, 0, 0, 0};
+ float tc[4] = {0, 0, 0, 0};
+ const float v = sc*((y + 0.5f) - cy)/cy;
+ const float u = sc*((x + 0.5f) - cx)/cx;
+ int sta = 0, mid = 0, end = 0;
+
+ if ((t = 1.f - kr4*(u*u + v*v)) >= 0.f) {
+ d = 1.f/(1.f + sqrtf(t));
+ ln[0] = (u*d + 0.5f)*width - 0.5f, ln[1] = (v*d + 0.5f)*height - 0.5f;
+ sta = 1;
+ }
+ if ((t = 1.f - kg4*(u*u + v*v)) >= 0.f) {
+ d = 1.f/(1.f + sqrtf(t));
+ ln[2] = (u*d + 0.5f)*width - 0.5f, ln[3] = (v*d + 0.5f)*height - 0.5f;
+ mid = 1;
+ }
+ if ((t = 1.f - kb4*(u*u + v*v)) >= 0.f) {
+ d = 1.f/(1.f + sqrtf(t));
+ ln[4] = (u*d + 0.5f)*width - 0.5f, ln[5] = (v*d + 0.5f)*height - 0.5f;
+ end = 1;
+ }
+
+ if (sta && mid && end) {
+ float jit = this->data->jit;
+ float z;
+ float color[4];
+ {
+ // RG
+ const int dx = ln[2] - ln[0], dy = ln[3] - ln[1];
+ const float dsf = sqrtf(dx*dx + dy*dy) + 1.f;
+ const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
+ const float sd = 1.f/(float)ds;
+
+ for (z=0; z<ds; ++z) {
+ const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd;
+ t = 1.f - (kr4 + tz*drg)*(u*u + v*v);
+ d = 1.f / (1.f + sqrtf(t));
+ const float nx = (u*d + 0.5f)*getWidth() - 0.5f;
+ const float ny = (v*d + 0.5f)*getHeight() - 0.5f;
+ buffer->readCubic(color, nx, ny);
+ tc[0] += (1.f-tz)*color[0], tc[1] += tz*color[1];
+ dr++, dg++;
+ }
+ }
+ {
+ // GB
+ const int dx = ln[4] - ln[2], dy = ln[5] - ln[3];
+ const float dsf = sqrtf(dx*dx + dy*dy) + 1.f;
+ const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf);
+ const float sd = 1.f/(float)ds;
+
+ for (z=0; z<ds; ++z) {
+ const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd;
+ t = 1.f - (kg4 + tz*dgb)*(u*u + v*v);
+ d = 1.f / (1.f + sqrtf(t));
+ const float nx = (u*d + 0.5f)*getWidth() - 0.5f;
+ const float ny = (v*d + 0.5f)*getHeight() - 0.5f;
+ buffer->readCubic(color, nx, ny);
+ tc[1] += (1.f-tz)*color[1], tc[2] += tz*color[2];
+ dg++, db++;
+ }
+
+ }
+ if (dr) outputColor[0] = 2.f*tc[0] / (float)dr;
+ if (dg) outputColor[1] = 2.f*tc[1] / (float)dg;
+ if (db) outputColor[2] = 2.f*tc[2] / (float)db;
+
+ /* set alpha */
+ outputColor[3]= 1.0f;
+ } else {
+ outputColor[0]= 0.0f;
+ outputColor[1]= 0.0f;
+ outputColor[2]= 0.0f;
+ outputColor[3]= 0.0f;
+ }
+}
+
+void ScreenLensDistortionOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
+
+void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const {
+ const float v = sc*((y + 0.5f) - cy)/cy;
+ const float u = sc*((x + 0.5f) - cx)/cx;
+ const float t = ABS(MIN3(kr, kg, kb)*4);
+ float d = 1.f/(1.f + sqrtf(t));
+ result[0] = (u*d + 0.5f)*getWidth() - 0.5f;
+ result[1] = (v*d + 0.5f)*getHeight() - 0.5f;
+}
+
+bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.ymax = inputProgram->getHeight();
+ newInput.xmax = inputProgram->getWidth();
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
new file mode 100644
index 00000000000..65262cfd3dd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ScreenLensDistortionOperation_h
+#define _COM_ScreenLensDistortionOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+class ScreenLensDistortionOperation : public NodeOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader* inputProgram;
+
+ NodeLensDist * data;
+
+ float dispersion;
+ float distortion;
+ float kr, kg, kb;
+ float kr4, kg4, kb4;
+ float maxk;
+ float drg;
+ float dgb;
+ float sc, cx, cy;
+public:
+ ScreenLensDistortionOperation();
+
+ /**
+ * 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);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeLensDist* data) {this->data = data;}
+ void setDispertion(float dispersion) {this->dispersion = dispersion;}
+ void setDistortion(float distortion) {this->distortion = distortion;}
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+private:
+ void determineUV(float* result, float x, float y) const;
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp
new file mode 100644
index 00000000000..4e0ad1580cd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SeparateChannelOperation.h"
+
+SeparateChannelOperation::SeparateChannelOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->inputOperation = NULL;
+}
+void SeparateChannelOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void SeparateChannelOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
+
+void SeparateChannelOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input[4];
+ this->inputOperation->read(input, x, y, sampler, inputBuffers);
+ color[0] = input[this->channel];
+}
diff --git a/source/blender/compositor/operations/COM_SeparateChannelOperation.h b/source/blender/compositor/operations/COM_SeparateChannelOperation.h
new file mode 100644
index 00000000000..3c1eed4bdd9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SeparateChannelOperation.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SeparateChannelOperation_h_
+#define _COM_SeparateChannelOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class SeparateChannelOperation: public NodeOperation {
+private:
+ SocketReader *inputOperation;
+ int channel;
+public:
+ SeparateChannelOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setChannel(int channel) {this->channel = channel;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
new file mode 100644
index 00000000000..b6545912a80
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetAlphaOperation.h"
+
+SetAlphaOperation::SetAlphaOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->inputColor = NULL;
+ this->inputAlpha = NULL;
+}
+
+void SetAlphaOperation::initExecution() {
+ this->inputColor = getInputSocketReader(0);
+ this->inputAlpha = getInputSocketReader(1);
+}
+
+void SetAlphaOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float alphaInput[4];
+
+ this->inputColor->read(outputValue, x, y, sampler, inputBuffers);
+ this->inputAlpha->read(alphaInput, x, y, sampler, inputBuffers);
+
+ outputValue[3] = alphaInput[0];
+}
+
+void SetAlphaOperation::deinitExecution() {
+ this->inputColor = NULL;
+ this->inputAlpha = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
new file mode 100644
index 00000000000..2cb42bf8cf3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetAlphaOperation_h
+#define _COM_SetAlphaOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class SetAlphaOperation : public NodeOperation {
+private:
+ SocketReader *inputColor;
+ SocketReader *inputAlpha;
+
+public:
+ /**
+ * Default constructor
+ */
+ SetAlphaOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp
new file mode 100644
index 00000000000..729a8073d7a
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetColorOperation.h"
+
+SetColorOperation::SetColorOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+
+void SetColorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ outputValue[0] = this->channel1;
+ outputValue[1] = this->channel2;
+ outputValue[2] = this->channel3;
+ outputValue[3] = this->channel4;
+}
+
+void SetColorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+}
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
new file mode 100644
index 00000000000..13d4bc21392
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetColorOperation_h
+#define _COM_SetColorOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class SetColorOperation : public NodeOperation {
+private:
+ float channel1;
+ float channel2;
+ float channel3;
+ float channel4;
+
+public:
+ /**
+ * Default constructor
+ */
+ SetColorOperation();
+
+ const float getChannel1() {return this->channel1;}
+ void setChannel1(float value) {this->channel1 = value;}
+ const float getChannel2() {return this->channel2;}
+ void setChannel2(float value) {this->channel2 = value;}
+ const float getChannel3() {return this->channel3;}
+ void setChannel3(float value) {this->channel3 = value;}
+ const float getChannel4() {return this->channel4;}
+ void setChannel4(float value) {this->channel4 = value;}
+ void setChannels(float value[4]) {this->channel1 = value[0];this->channel2 = value[1];this->channel3 = value[2];this->channel4 = value[3];}
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+ const bool isSetOperation() const {return true;}
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
new file mode 100644
index 00000000000..d5fda4a8827
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetSamplerOperation.h"
+
+SetSamplerOperation::SetSamplerOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+}
+
+void SetSamplerOperation::initExecution() {
+ this->reader = this->getInputSocketReader(0);
+}
+void SetSamplerOperation::deinitExecution() {
+ this->reader = NULL;
+}
+
+void SetSamplerOperation::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ reader->read(output, x, y, this->sampler, inputBuffers);
+}
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
new file mode 100644
index 00000000000..f7b850fcfe9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetSamplerOperation_h
+#define _COM_SetSamplerOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output Sampler.
+ * it assumes we are in sRGB colour space.
+ */
+class SetSamplerOperation : public NodeOperation {
+private:
+ PixelSampler sampler;
+ SocketReader *reader;
+public:
+ /**
+ * Default constructor
+ */
+ SetSamplerOperation();
+
+ void setSampler(PixelSampler sampler) {this->sampler = sampler;}
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void initExecution();
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
new file mode 100644
index 00000000000..a8a681a6659
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetValueOperation.h"
+
+SetValueOperation::SetValueOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+
+void SetValueOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ outputValue[0] = this->value;
+}
+
+void SetValueOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+}
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
new file mode 100644
index 00000000000..30a8de16dc4
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetValueOperation_h
+#define _COM_SetValueOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class SetValueOperation : public NodeOperation {
+private:
+ float value;
+
+public:
+ /**
+ * Default constructor
+ */
+ SetValueOperation();
+
+ const float getValue() {return this->value;}
+ void setValue(float value) {this->value = value;}
+
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ const bool isSetOperation() const {return true;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
new file mode 100644
index 00000000000..b9c8f4bc369
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SetVectorOperation.h"
+#include "COM_defines.h"
+
+SetVectorOperation::SetVectorOperation(): NodeOperation() {
+ this->addOutputSocket(COM_DT_VECTOR);
+}
+
+void SetVectorOperation::executePixel(float* outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ outputValue[0] = this->x;
+ outputValue[1] = this->y;
+ outputValue[2] = this->z;
+ outputValue[3] = this->w;
+}
+
+void SetVectorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ if (preferredResolution[0] == 0 ||preferredResolution[1]==0) {
+ resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH;
+ resolution[1] = COM_DEFAULT_RESOLUTION_HEIGHT;
+ } else {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+ }
+}
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
new file mode 100644
index 00000000000..c1f3c679b5b
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SetVectorOperation_h
+#define _COM_SetVectorOperation_h
+#include "COM_NodeOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class SetVectorOperation : public NodeOperation {
+private:
+ float x;
+ float y;
+ float z;
+ float w;
+
+public:
+ /**
+ * Default constructor
+ */
+ SetVectorOperation();
+
+ const float getX() {return this->x;}
+ void setX(float value) {this->x = value;}
+ const float getY() {return this->y;}
+ void setY(float value) {this->y = value;}
+ const float getZ() {return this->z;}
+ void setZ(float value) {this->z = value;}
+ const float getW() {return this->w;}
+ void setW(float value) {this->w = value;}
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+ const bool isSetOperation() const {return true;}
+
+ void setVector(float vector[3]) {
+ setX(vector[0]);
+ setY(vector[1]);
+ setZ(vector[2]);
+ }
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
new file mode 100644
index 00000000000..161bdb3e295
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SocketProxyOperation.h"
+
+SocketProxyOperation::SocketProxyOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR/*|COM_DT_VECTOR|COM_DT_VALUE*/);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->inputOperation = NULL;
+}
+
+void SocketProxyOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+}
+
+void SocketProxyOperation::deinitExecution() {
+ this->inputOperation = NULL;
+}
+
+void SocketProxyOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ this->inputOperation->read(color, x, y, sampler, inputBuffers);
+}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
new file mode 100644
index 00000000000..a86134c1ea9
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SocketProxyOperation_h_
+#define _COM_SocketProxyOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class SocketProxyOperation: public NodeOperation {
+private:
+ SocketReader *inputOperation;
+public:
+ SocketProxyOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.cpp b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
new file mode 100644
index 00000000000..f9000cc63da
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_SplitViewerOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+
+SplitViewerOperation::SplitViewerOperation() : ViewerBaseOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->image1Input = NULL;
+ this->image2Input = NULL;
+}
+
+void SplitViewerOperation::initExecution() {
+ // When initializing the tree during initial load the width and height can be zero.
+ this->image1Input = getInputSocketReader(0);
+ this->image2Input = getInputSocketReader(1);
+ ViewerBaseOperation::initExecution();
+}
+
+void SplitViewerOperation::deinitExecution() {
+ this->image1Input = NULL;
+ this->image2Input = NULL;
+ ViewerBaseOperation::deinitExecution();
+}
+
+
+void SplitViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) {
+ float* buffer = this->outputBuffer;
+ unsigned char* bufferDisplay = this->outputBufferDisplay;
+
+ if (!buffer) return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1*this->getWidth() + x1 ) * 4;
+ int x;
+ int y;
+ int perc = xSplit?this->splitPercentage*getWidth()/100.0f:this->splitPercentage*getHeight()/100.0f;
+ for (y = y1 ; y < y2 ; y++) {
+ for (x = x1 ; x < x2 ; x++) {
+ bool image1;
+ float srgb[4];
+ image1 = xSplit?x>perc:y>perc;
+ if (image1) {
+ image1Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers);
+ } else {
+ image2Input->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers);
+ }
+ /// @todo: linear conversion only when scene color management is selected, also check predivide.
+ if (this->doColorManagement) {
+ if(this->doColorPredivide) {
+ linearrgb_to_srgb_predivide_v4(srgb, buffer+offset);
+ } else {
+ linearrgb_to_srgb_v4(srgb, buffer+offset);
+ }
+ } else {
+ copy_v4_v4(srgb, buffer+offset);
+ }
+
+ F4TOCHAR4(srgb, bufferDisplay+offset);
+
+ offset +=4;
+ }
+ offset += (this->getWidth()-(x2-x1))*4;
+ }
+ updateImage(rect);
+}
+
diff --git a/source/blender/compositor/operations/COM_SplitViewerOperation.h b/source/blender/compositor/operations/COM_SplitViewerOperation.h
new file mode 100644
index 00000000000..61e4b027cec
--- /dev/null
+++ b/source/blender/compositor/operations/COM_SplitViewerOperation.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_SplitViewerOperation_h
+#define _COM_SplitViewerOperation_h
+#include "COM_ViewerBaseOperation.h"
+#include "DNA_image_types.h"
+#include "BLI_rect.h"
+
+class SplitViewerOperation : public ViewerBaseOperation {
+private:
+ SocketReader* image1Input;
+ SocketReader* image2Input;
+
+ float splitPercentage;
+ bool xSplit;
+public:
+ SplitViewerOperation();
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void initExecution();
+ void deinitExecution();
+ void setSplitPercentage(float splitPercentage) {this->splitPercentage = splitPercentage;}
+ void setXSplit(bool xsplit) {this->xSplit = xsplit;}
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
new file mode 100644
index 00000000000..1ca986f8893
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TextureOperation.h"
+
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+
+TextureBaseOperation::TextureBaseOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_VECTOR);//offset
+ this->addInputSocket(COM_DT_VECTOR);//size
+ this->texture = NULL;
+ this->inputSize = NULL;
+ this->inputOffset = NULL;
+}
+TextureOperation::TextureOperation() : TextureBaseOperation() {
+ this->addOutputSocket(COM_DT_COLOR);
+}
+TextureAlphaOperation::TextureAlphaOperation() : TextureBaseOperation() {
+ this->addOutputSocket(COM_DT_VALUE);
+}
+
+void TextureBaseOperation::initExecution() {
+ this->inputOffset = getInputSocketReader(0);
+ this->inputSize = getInputSocketReader(1);
+}
+void TextureBaseOperation::deinitExecution() {
+ this->inputSize = NULL;
+ this->inputOffset = NULL;
+}
+
+void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) {
+ if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
+ resolution[0] = COM_DEFAULT_RESOLUTION_WIDTH;
+ resolution[1] = COM_DEFAULT_RESOLUTION_HEIGHT;
+ } else {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+ }
+}
+
+void TextureAlphaOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ TextureBaseOperation::executePixel(color, x, y, sampler, inputBuffers);
+ color[0] = color[3];
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 0.0f;
+}
+
+void TextureBaseOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+ float textureSize[4];
+ float textureOffset[4];
+ float vec[3];
+ int retval;
+ const float cx = this->getWidth()/2;
+ const float cy = this->getHeight()/2;
+ const float u = (cx-x)/this->getWidth()*2;
+ const float v = (cy-y)/this->getHeight()*2;
+
+ this->inputSize->read(textureSize, x, y, sampler, inputBuffers);
+ this->inputOffset->read(textureOffset, x, y, sampler, inputBuffers);
+
+ vec[0]= textureSize[0]*(u + textureOffset[0]);
+ vec[1]= textureSize[1]*(v + textureOffset[1]);
+ vec[2]= textureSize[2]*textureOffset[2];
+
+ retval= multitex_ext(this->texture, vec, NULL, NULL, 0, &texres);
+
+ if(texres.talpha)
+ color[3]= texres.ta;
+ else
+ color[3]= texres.tin;
+
+ if((retval & TEX_RGB)) {
+ color[0]= texres.tr;
+ color[1]= texres.tg;
+ color[2]= texres.tb;
+ }
+ else color[0]= color[1]= color[2]= color[3];
+}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
new file mode 100644
index 00000000000..a545a5eea97
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+
+#ifndef _COM_TextureOperation_h
+#define _COM_TextureOperation_h
+
+#include "COM_NodeOperation.h"
+#include "DNA_scene_types.h"
+#include "DNA_texture_types.h"
+#include "BLI_listbase.h"
+extern "C" {
+ #include "RE_pipeline.h"
+ #include "RE_shader_ext.h"
+ #include "RE_render_ext.h"
+ #include "MEM_guardedalloc.h"
+}
+
+/**
+ * Base class for all renderlayeroperations
+ *
+ * @todo: rename to operation.
+ */
+class TextureBaseOperation : public NodeOperation {
+private:
+ Tex* texture;
+ SocketReader *inputSize;
+ SocketReader *inputOffset;
+
+protected:
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ /**
+ * Constructor
+ */
+ TextureBaseOperation();
+
+public:
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void setTexture(Tex* texture) {this->texture = texture;}
+ void initExecution();
+ void deinitExecution();
+};
+
+class TextureOperation:public TextureBaseOperation {
+public:
+ TextureOperation();
+
+};
+class TextureAlphaOperation:public TextureBaseOperation {
+public:
+ TextureAlphaOperation();
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
new file mode 100644
index 00000000000..84e893d0b2e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TonemapOperation.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+
+
+TonemapOperation::TonemapOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->imageReader = NULL;
+ this->data = NULL;
+ this->cachedInstance = NULL;
+ this->setComplex(true);
+}
+void TonemapOperation::initExecution() {
+ this->imageReader = this->getInputSocketReader(0);
+ NodeOperation::initMutex();
+}
+
+void TonemapOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ AvgLogLum * avg = (AvgLogLum*)data;
+
+ float output[4];
+ this->imageReader->read(output, x, y, inputBuffers, NULL);
+ output[0] *= avg->al;
+ output[1] *= avg->al;
+ output[2] *= avg->al;
+ float dr = output[0] + this->data->offset;
+ float dg = output[1] + this->data->offset;
+ float db = output[2] + this->data->offset;
+ output[0] /= ((dr == 0.f) ? 1.f : dr);
+ output[1] /= ((dg == 0.f) ? 1.f : dg);
+ output[2] /= ((db == 0.f) ? 1.f : db);
+ const float igm = avg->igm;
+ if (igm != 0.f) {
+ output[0] = pow((double)MAX2(output[0], 0.), (double)igm);
+ output[1] = pow((double)MAX2(output[1], 0.), (double)igm);
+ output[2] = pow((double)MAX2(output[2], 0.), (double)igm);
+ }
+
+ color[0] = output[0];
+ color[1] = output[1];
+ color[2] = output[2];
+ color[3] = output[3];
+}
+void PhotoreceptorTonemapOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data) {
+ AvgLogLum * avg = (AvgLogLum*)data;
+ NodeTonemap *ntm = this->data;
+
+ const float f = exp((double)-this->data->f);
+ const float m = (ntm->m > 0.f) ? ntm->m : (0.3f + 0.7f*pow((double)avg->auto_key, 1.4));
+ const float ic = 1.f - ntm->c, ia = 1.f - ntm->a;
+
+ float output[4];
+ this->imageReader->read(output, x, y, inputBuffers, NULL);
+
+ const float L = 0.212671f*output[0] + 0.71516f*output[1] + 0.072169f*output[2];
+ float I_l = output[0] + ic*(L - output[0]);
+ float I_g = avg->cav[0] + ic*(avg->lav - avg->cav[0]);
+ float I_a = I_l + ia*(I_g - I_l);
+ output[0] /= (output[0] + pow((double)f*I_a, (double)m));
+ I_l = output[1] + ic*(L - output[1]);
+ I_g = avg->cav[1] + ic*(avg->lav - avg->cav[1]);
+ I_a = I_l + ia*(I_g - I_l);
+ output[1] /= (output[1] + pow((double)f*I_a,(double)m));
+ I_l = output[2] + ic*(L - output[2]);
+ I_g = avg->cav[2] + ic*(avg->lav - avg->cav[2]);
+ I_a = I_l + ia*(I_g - I_l);
+ output[2] /= (output[2] + pow((double)f*I_a, (double)m));
+
+ color[0] = output[0];
+ color[1] = output[1];
+ color[2] = output[2];
+ color[3] = output[3];
+}
+
+void TonemapOperation::deinitExecution() {
+ this->imageReader = NULL;
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ }
+ NodeOperation::deinitMutex();
+}
+
+bool TonemapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti imageInput;
+
+ NodeOperation* operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
+ return true;
+ }
+ return false;
+}
+
+void* TonemapOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ BLI_mutex_lock(getMutex());
+ if (this->cachedInstance == NULL) {
+ MemoryBuffer* tile = (MemoryBuffer*)imageReader->initializeTileData(rect, memoryBuffers);
+ AvgLogLum *data = new AvgLogLum();
+
+ float * buffer = tile->getBuffer();
+
+ float lsum = 0;
+ int p = tile->getWidth() * tile->getHeight();
+ float* bc = buffer;
+ float avl, maxl = -1e10f, minl = 1e10f;
+ const float sc = 1.f/(p);
+ float Lav = 0.f;
+ float cav[4] = {0.0f,0.0f,0.0f,0.0f};
+ while (p--) {
+ float L = 0.212671f*bc[0] + 0.71516f*bc[1] + 0.072169f*bc[2];
+ Lav += L;
+ cav[0] += bc[0];
+ cav[1] += bc[1];
+ cav[2] += bc[2];
+ lsum += (float)log((double)MAX2(L, 0.0) + 1e-5);
+ maxl = (L > maxl) ? L : maxl;
+ minl = (L < minl) ? L : minl;
+ bc+=4;
+ }
+ data->lav = Lav * sc;
+ data->cav[0] = cav[0]*sc;
+ data->cav[1] = cav[1]*sc;
+ data->cav[2] = cav[2]*sc;
+ maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5f); avl = lsum*sc;
+ data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.f;
+ float al = exp((double)avl);
+ data->al = (al == 0.f) ? 0.f : (this->data->key / al);
+ data->igm = (this->data->gamma==0.f) ? 1 : (1.f / this->data->gamma);
+ this->cachedInstance = data;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->cachedInstance;
+}
+
+void TonemapOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) {
+}
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h
new file mode 100644
index 00000000000..c895fdcba77
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TonemapOperation.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_TonemapOperation_h
+#define _COM_TonemapOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+
+/**
+ * @brief temporarily storage during execution of Tonemap
+ * @ingroup operation
+ */
+typedef struct AvgLogLum {
+ float al;
+ float auto_key;
+ float lav;
+ float cav[4];
+ float igm;
+} AvgLogLum;
+
+/**
+ * @brief base class of tonemap, implementing the simple tonemap
+ * @ingroup operation
+ */
+class TonemapOperation : public NodeOperation {
+protected:
+ /**
+ * @brief Cached reference to the reader
+ */
+ SocketReader * imageReader;
+
+ /**
+ * @brief settings of the Tonemap
+ */
+ NodeTonemap * data;
+
+ /**
+ * @brief temporarily cache of the execution storage
+ */
+ AvgLogLum * cachedInstance;
+
+public:
+ TonemapOperation();
+
+ /**
+ * 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();
+
+ void setData(NodeTonemap* data) {this->data = data;}
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+
+};
+
+/**
+ * @brief class of tonemap, implementing the photoreceptor tonemap
+ * most parts have already been done in TonemapOperation
+ * @ingroup operation
+ */
+
+class PhotoreceptorTonemapOperation : public TonemapOperation {
+public:
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void * data);
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
new file mode 100644
index 00000000000..48774833e14
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_TranslateOperation.h"
+
+TranslateOperation::TranslateOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->inputOperation = NULL;
+ this->inputXOperation = NULL;
+ this->inputYOperation = NULL;
+}
+void TranslateOperation::initExecution() {
+ this->inputOperation = this->getInputSocketReader(0);
+ this->inputXOperation = this->getInputSocketReader(1);
+ this->inputYOperation = this->getInputSocketReader(2);
+
+ float tempDelta[4];
+ this->inputXOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
+ this->deltaX = tempDelta[0];
+ this->inputYOperation->read(tempDelta, 0, 0, COM_PS_NEAREST, NULL);
+ this->deltaY = tempDelta[0];
+}
+
+void TranslateOperation::deinitExecution() {
+ this->inputOperation = NULL;
+ this->inputXOperation = NULL;
+ this->inputYOperation = NULL;
+}
+
+
+void TranslateOperation::executePixel(float *color,float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ this->inputOperation->read(color, x-this->getDeltaX(), y-this->getDeltaY(), sampler, inputBuffers);
+}
+
+bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+
+ newInput.xmax = input->xmax - this->getDeltaX();
+ newInput.xmin = input->xmin - this->getDeltaX();
+ newInput.ymax = input->ymax - this->getDeltaY();
+ newInput.ymin = input->ymin - this->getDeltaY();
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+}
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
new file mode 100644
index 00000000000..eab3391041e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_TranslateOperation_h_
+#define _COM_TranslateOperation_h_
+
+#include "COM_NodeOperation.h"
+
+class TranslateOperation: public NodeOperation {
+private:
+ SocketReader *inputOperation;
+ SocketReader*inputXOperation;
+ SocketReader*inputYOperation;
+ float deltaX;
+ float deltaY;
+public:
+ TranslateOperation();
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ void initExecution();
+ void deinitExecution();
+
+ float getDeltaX() {return this->deltaX;}
+ float getDeltaY() {return this->deltaY;}
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
new file mode 100644
index 00000000000..e97b1155e22
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_VariableSizeBokehBlurOperation.h"
+#include "BLI_math.h"
+
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->inputProgram = NULL;
+ this->inputBokehProgram = NULL;
+ this->inputSizeProgram = NULL;
+ this->maxBlur = 32.0f;
+ this->threshold = 0.0f;
+}
+
+
+void VariableSizeBokehBlurOperation::initExecution() {
+ this->inputProgram = getInputSocketReader(0);
+ this->inputBokehProgram = getInputSocketReader(1);
+ this->inputSizeProgram = getInputSocketReader(2);
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+}
+
+void VariableSizeBokehBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float tempColor[4];
+ float readColor[4];
+ float bokeh[4];
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float tempSize[4];
+ float overallmultiplyerr = 0;
+ float overallmultiplyerg = 0;
+ float overallmultiplyerb = 0;
+
+ int miny = y - maxBlur;
+ int maxy = y + maxBlur;
+ int minx = x - maxBlur;
+ int maxx = x + maxBlur;
+ {
+ inputProgram->read(readColor, x, y, COM_PS_NEAREST, inputBuffers);
+ tempColor[0] += readColor[0];
+ tempColor[1] += readColor[1];
+ tempColor[2] += readColor[2];
+ overallmultiplyerr += 1;
+ overallmultiplyerg += 1;
+ overallmultiplyerb += 1;
+
+ for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
+ for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
+ if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
+ inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
+ float size = tempSize[0];
+ size += this->threshold;
+ float dx = nx - x;
+ float dy = ny - y;
+ if (nx == x && ny == y) {
+ } else if (size>= fabs(dx) && size >= fabs(dy)) {
+ float u = 256+ dx*256/size;
+ float v = 256+ dy*256/size;
+ inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
+ inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
+ tempColor[0] += bokeh[0] * readColor[0];
+ tempColor[1] += bokeh[1] * readColor[1];
+ tempColor[2] += bokeh[2]* readColor[2];
+ overallmultiplyerr += bokeh[0];
+ overallmultiplyerg += bokeh[1];
+ overallmultiplyerb += bokeh[2];
+ }
+ }
+ }
+ }
+ color[0] = tempColor[0]*(1.0/overallmultiplyerr);
+ color[1] = tempColor[1]*(1.0/overallmultiplyerg);
+ color[2] = tempColor[2]*(1.0/overallmultiplyerb);
+ color[3] = 1.0f;
+ }
+
+}
+
+void VariableSizeBokehBlurOperation::deinitExecution() {
+ this->inputProgram = NULL;
+ this->inputBokehProgram = NULL;
+ this->inputSizeProgram = NULL;
+}
+
+bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ rcti newInput;
+ rcti bokehInput;
+
+ newInput.xmax = input->xmax + maxBlur+2;
+ newInput.xmin = input->xmin - maxBlur+2;
+ newInput.ymax = input->ymax + maxBlur-2;
+ newInput.ymin = input->ymin - maxBlur-2;
+ bokehInput.xmax = 512;
+ bokehInput.xmin = 0;
+ bokehInput.ymax = 512;
+ bokehInput.ymin = 0;
+
+ NodeOperation* operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
+ return true;
+ }
+ operation = getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
+ return true;
+ }
+ operation = getInputOperation(0);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
+ return true;
+ }
+ return false;
+}
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
new file mode 100644
index 00000000000..6c3159a8092
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_BokehVariableSizeBokehBlurOperation_h
+#define _COM_VariableSizeBokehBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_QualityStepHelper.h"
+
+class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper {
+private:
+ int maxBlur;
+ float threshold;
+ SocketReader* inputProgram;
+ SocketReader* inputBokehProgram;
+ SocketReader* inputSizeProgram;
+
+public:
+ VariableSizeBokehBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+
+ void setMaxBlur(int maxRadius) {this->maxBlur = maxRadius;}
+
+ void setThreshold(float threshold) {this->threshold = threshold;}
+
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
new file mode 100644
index 00000000000..7d660177fbb
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_VectorBlurOperation.h"
+#include "BLI_math.h"
+
+// use the implementation of blender internal renderer to calculate the vector blur.
+extern "C" {
+ #include "RE_pipeline.h"
+}
+
+VectorBlurOperation::VectorBlurOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE); // ZBUF
+ this->addInputSocket(COM_DT_COLOR); //SPEED
+ this->addOutputSocket(COM_DT_COLOR);
+ this->settings = NULL;
+ this->cachedInstance = NULL;
+ this->inputImageProgram = NULL;
+ this->inputSpeedProgram = NULL;
+ this->inputZProgram = NULL;
+ setComplex(true);
+}
+void VectorBlurOperation::initExecution() {
+ initMutex();
+ this->inputImageProgram = getInputSocketReader(0);
+ this->inputZProgram = getInputSocketReader(1);
+ this->inputSpeedProgram = getInputSocketReader(2);
+ this->cachedInstance = NULL;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+
+}
+
+void VectorBlurOperation::executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data) {
+ float* buffer = (float*) data;
+ int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
+ color[0] = buffer[index];
+ color[1] = buffer[index+1];
+ color[2] = buffer[index+2];
+ color[3] = buffer[index+3];
+}
+
+void VectorBlurOperation::deinitExecution() {
+ deinitMutex();
+ this->inputImageProgram = NULL;
+ this->inputSpeedProgram = NULL;
+ this->inputZProgram = NULL;
+ if (this->cachedInstance) {
+ delete cachedInstance;
+ this->cachedInstance = NULL;
+ }
+}
+void* VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) {
+ if (this->cachedInstance) return this->cachedInstance;
+
+ BLI_mutex_lock(getMutex());
+ if (this->cachedInstance == NULL) {
+ MemoryBuffer* tile = (MemoryBuffer*)inputImageProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer* speed= (MemoryBuffer*)inputSpeedProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer* z = (MemoryBuffer*)inputZProgram->initializeTileData(rect, memoryBuffers);
+ float* data = new float[this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS];
+ memcpy(data, tile->getBuffer(),this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ this->generateVectorBlur(data, tile, speed, z);
+ this->cachedInstance = data;
+ }
+ BLI_mutex_unlock(getMutex());
+ return this->cachedInstance;
+}
+
+bool VectorBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+ if (this->cachedInstance == NULL) {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ } else {
+ return false;
+ }
+}
+
+void VectorBlurOperation::generateVectorBlur(float* data, MemoryBuffer* inputImage, MemoryBuffer* inputSpeed, MemoryBuffer* inputZ) {
+ float *zbuf = inputZ->convertToValueBuffer();
+ NodeBlurData blurdata;
+ blurdata.samples = this->settings->samples/QualityStepHelper::getStep();
+ blurdata.maxspeed = this->settings->maxspeed;
+ blurdata.minspeed = this->settings->minspeed;
+ blurdata.curved = this->settings->curved;
+ blurdata.fac = this->settings->fac;
+ RE_zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), zbuf);
+ delete zbuf;
+ return;
+}
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h
new file mode 100644
index 00000000000..e3275f1bc15
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_VectorBlurOperation_h
+#define _COM_VectorBlurOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_node_types.h"
+#include "COM_QualityStepHelper.h"
+
+class VectorBlurOperation : public NodeOperation, public QualityStepHelper {
+private:
+ /**
+ * @brief Cached reference to the inputProgram
+ */
+ SocketReader * inputImageProgram;
+ SocketReader * inputSpeedProgram;
+ SocketReader * inputZProgram;
+
+ /**
+ * @brief settings of the glare node.
+ */
+ NodeBlurData * settings;
+
+ float* cachedInstance;
+
+public:
+ VectorBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, int x, int y, MemoryBuffer *inputBuffers[], void* data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
+
+ void setVectorBlurSettings(NodeBlurData * settings) {this->settings = settings;}
+ bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+protected:
+
+ void generateVectorBlur(float* data, MemoryBuffer* inputImage, MemoryBuffer* inputSpeed, MemoryBuffer* inputZ);
+
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
new file mode 100644
index 00000000000..697d082c33e
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_VectorCurveOperation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ #include "BKE_colortools.h"
+#ifdef __cplusplus
+}
+#endif
+
+VectorCurveOperation::VectorCurveOperation(): CurveBaseOperation() {
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VECTOR);
+
+ this->inputProgram = NULL;
+}
+void VectorCurveOperation::initExecution() {
+ CurveBaseOperation::initExecution();
+ this->inputProgram = this->getInputSocketReader(0);
+}
+
+void VectorCurveOperation::executePixel(float* output, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float input[4];
+
+
+ this->inputProgram->read(input, x, y, sampler, inputBuffers);
+
+ curvemapping_evaluate_premulRGBF(this->curveMapping, output, input);
+ output[3]= input[3];
+}
+
+void VectorCurveOperation::deinitExecution() {
+ this->inputProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
new file mode 100644
index 00000000000..d3097345ae5
--- /dev/null
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_VectorCurveOperation_h
+#define _COM_VectorCurveOperation_h
+#include "COM_NodeOperation.h"
+#include "COM_CurveBaseOperation.h"
+
+class VectorCurveOperation : public CurveBaseOperation {
+private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader * inputProgram;
+public:
+ VectorCurveOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* Vector, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
new file mode 100644
index 00000000000..16143af7165
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ViewerBaseOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+#include "WM_api.h"
+#include "WM_types.h"
+#include "PIL_time.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_color.h"
+
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+
+ViewerBaseOperation::ViewerBaseOperation() : NodeOperation() {
+ this->setImage(NULL);
+ this->setImageUser(NULL);
+ this->outputBuffer = NULL;
+ this->outputBufferDisplay = NULL;
+ this->active = false;
+ this->doColorManagement = true;
+}
+
+void ViewerBaseOperation::initExecution() {
+ // When initializing the tree during initial load the width and height can be zero.
+ initImage();
+}
+
+void ViewerBaseOperation::initImage() {
+ Image* anImage = this->image;
+ ImBuf *ibuf= BKE_image_acquire_ibuf(anImage, this->imageUser, &this->lock);
+
+ if (!ibuf) return;
+ if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
+ imb_freerectImBuf(ibuf);
+ imb_freerectfloatImBuf(ibuf);
+ IMB_freezbuffloatImBuf(ibuf);
+ ibuf->x= getWidth();
+ ibuf->y= getHeight();
+ imb_addrectImBuf(ibuf);
+ imb_addrectfloatImBuf(ibuf);
+ anImage->ok= IMA_OK_LOADED;
+ }
+
+ /* now we combine the input with ibuf */
+ this->outputBuffer = ibuf->rect_float;
+ this->outputBufferDisplay = (unsigned char*)ibuf->rect;
+
+ BKE_image_release_ibuf(this->image, this->lock);
+}
+void ViewerBaseOperation:: updateImage(rcti *rect) {
+ /// @todo: introduce new event to update smaller area
+ WM_main_add_notifier(NC_WINDOW|ND_DRAW, NULL);
+}
+
+void ViewerBaseOperation::deinitExecution() {
+ this->outputBuffer = NULL;
+}
+
+const int ViewerBaseOperation::getRenderPriority() const {
+ if (this->isActiveViewerOutput()) {
+ return 8;
+ } else {
+ return 0;
+ }
+}
diff --git a/source/blender/compositor/operations/COM_ViewerBaseOperation.h b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
new file mode 100644
index 00000000000..e94d2644e36
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ViewerBaseOperation.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ViewerBaseOperation_h
+#define _COM_ViewerBaseOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_image_types.h"
+#include "BLI_rect.h"
+
+class ViewerBaseOperation : public NodeOperation {
+protected:
+ float *outputBuffer;
+ unsigned char *outputBufferDisplay;
+ Image * image;
+ ImageUser * imageUser;
+ void *lock;
+ bool active;
+ const bNodeTree* tree;
+ float centerX;
+ float centerY;
+ OrderOfChunks chunkOrder;
+ bool doColorManagement;
+ bool doColorPredivide;
+
+public:
+ bool isOutputOperation(bool rendering) const {return true;}
+ void initExecution();
+ void deinitExecution();
+ void setImage(Image* image) {this->image = image;}
+ void setImageUser(ImageUser* imageUser) {this->imageUser = imageUser;}
+ const bool isActiveViewerOutput() const {return active;}
+ void setActive(bool active) {this->active = active;}
+ void setbNodeTree(const bNodeTree* tree) {this->tree = tree;}
+ void setCenterX(float centerX) {this->centerX = centerX;}
+ void setCenterY(float centerY) {this->centerY = centerY;}
+ void setChunkOrder(OrderOfChunks tileOrder) {this->chunkOrder = tileOrder;}
+ float getCenterX() { return this->centerX; }
+ float getCenterY() { return this->centerY; }
+ OrderOfChunks getChunkOrder() { return this->chunkOrder; }
+ const int getRenderPriority() const;
+ void setColorManagement(bool doColorManagement) {this->doColorManagement = doColorManagement;}
+ void setColorPredivide(bool doColorPredivide) {this->doColorPredivide = doColorPredivide;}
+ bool isViewerOperation() {return true;}
+
+protected:
+ ViewerBaseOperation();
+ void updateImage(rcti*rect);
+
+private:
+ void initImage();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
new file mode 100644
index 00000000000..b0d443f1cbd
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ViewerOperation.h"
+#include "COM_SocketConnection.h"
+#include "BLI_listbase.h"
+#include "DNA_scene_types.h"
+#include "BKE_image.h"
+#include "WM_api.h"
+#include "WM_types.h"
+#include "PIL_time.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_color.h"
+#include "BLI_math_vector.h"
+
+extern "C" {
+ #include "MEM_guardedalloc.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+}
+
+
+ViewerOperation::ViewerOperation() : ViewerBaseOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+
+ this->imageInput = NULL;
+ this->alphaInput = NULL;
+}
+
+void ViewerOperation::initExecution() {
+ // When initializing the tree during initial load the width and height can be zero.
+ this->imageInput = getInputSocketReader(0);
+ this->alphaInput = getInputSocketReader(1);
+ ViewerBaseOperation::initExecution();
+}
+
+void ViewerOperation::deinitExecution() {
+ this->imageInput = NULL;
+ this->alphaInput = NULL;
+ ViewerBaseOperation::deinitExecution();
+}
+
+
+void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) {
+ float* buffer = this->outputBuffer;
+ unsigned char* bufferDisplay = this->outputBufferDisplay;
+ if (!buffer) return;
+ const int x1 = rect->xmin;
+ const int y1 = rect->ymin;
+ const int x2 = rect->xmax;
+ const int y2 = rect->ymax;
+ const int offsetadd = (this->getWidth()-(x2-x1))*4;
+ int offset = (y1*this->getWidth() + x1 ) * 4;
+ float alpha[4], srgb[4];
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1 ; y < y2 && (!breaked) ; y++) {
+ for (x = x1 ; x < x2; x++) {
+ imageInput->read(&(buffer[offset]), x, y, COM_PS_NEAREST, memoryBuffers);
+ if (alphaInput != NULL) {
+ alphaInput->read(alpha, x, y, COM_PS_NEAREST, memoryBuffers);
+ buffer[offset+3] = alpha[0];
+ }
+ /// @todo: linear conversion only when scene color management is selected, also check predivide.
+ if (this->doColorManagement) {
+ if(this->doColorPredivide) {
+ linearrgb_to_srgb_predivide_v4(srgb, buffer+offset);
+ } else {
+ linearrgb_to_srgb_v4(srgb, buffer+offset);
+ }
+ } else {
+ copy_v4_v4(srgb, buffer+offset);
+ }
+
+ F4TOCHAR4(srgb, bufferDisplay+offset);
+
+ offset +=4;
+ }
+ if (tree->test_break && tree->test_break(tree->tbh)) {
+ breaked = true;
+ }
+
+ offset += offsetadd;
+ }
+ updateImage(rect);
+}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
new file mode 100644
index 00000000000..951e9ff6fc3
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ViewerOperation_h
+#define _COM_ViewerOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_image_types.h"
+#include "BLI_rect.h"
+#include "COM_ViewerBaseOperation.h"
+
+class ViewerOperation : public ViewerBaseOperation {
+private:
+ SocketReader* imageInput;
+ SocketReader* alphaInput;
+
+public:
+ ViewerOperation();
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void initExecution();
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
new file mode 100644
index 00000000000..44a769ee947
--- /dev/null
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_WriteBufferOperation.h"
+#include "COM_defines.h"
+#include "COM_MemoryManager.h"
+#include <stdio.h>
+
+/// @TODO: writebuffers don't have an actual data type set.
+WriteBufferOperation::WriteBufferOperation() :NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->memoryProxy = new MemoryProxy();
+ this->memoryProxy->setWriteBufferOperation(this);
+ this->memoryProxy->setExecutor(NULL);
+ this->tree = NULL;
+}
+WriteBufferOperation::~WriteBufferOperation() {
+ if (this->memoryProxy) {
+ delete this->memoryProxy;
+ this->memoryProxy = NULL;
+ }
+}
+
+void WriteBufferOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ input->read(color, x, y, sampler, inputBuffers);
+}
+void WriteBufferOperation::initExecution() {
+ this->input = this->getInputOperation(0);
+ MemoryManager::addMemoryProxy(this->memoryProxy);
+}
+void WriteBufferOperation::deinitExecution() {
+ this->input = NULL;
+}
+
+
+void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers) {
+ MemoryBuffer* memoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), tileNumber);
+ float* buffer = memoryBuffer->getBuffer();
+ if (this->input->isComplex()) {
+ void* data = this->input->initializeTileData(rect, memoryBuffers);
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset4 = 0;
+ int x;
+ int y;
+ bool breaked = false;
+ for (y = y1 ; y < y2 && (!breaked) ; y++) {
+ for (x = x1 ; x < x2; x++) {
+ input->read(&(buffer[offset4]), x, y, memoryBuffers, data);
+ offset4 +=4;
+
+ }
+ if (tree->test_break && tree->test_break(tree->tbh)) {
+ breaked = true;
+ }
+
+ }
+ if (data) {
+ this->input->deinitializeTileData(rect, memoryBuffers, data);
+ data = NULL;
+ }
+ } else {
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset4 = 0;
+ int x;
+ int y;
+ bool breaked = false;
+ for (y = y1 ; y < y2 && (!breaked) ; y++) {
+ for (x = x1 ; x < x2 ; x++) {
+ input->read(&(buffer[offset4]), x, y, COM_PS_NEAREST, memoryBuffers);
+ offset4 +=4;
+ }
+ if (tree->test_break && tree->test_break(tree->tbh)) {
+ breaked = true;
+ }
+ }
+ }
+ memoryBuffer->setCreatedState();
+}
+
+void WriteBufferOperation::executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** inputMemoryBuffers) {
+ MemoryBuffer* outputMemoryBuffer = MemoryManager::getMemoryBuffer(this->getMemoryProxy(), chunkNumber);
+ float* outputFloatBuffer = outputMemoryBuffer->getBuffer();
+ cl_int error;
+ /*
+ 1. create cl_mem from outputbuffer
+ 2. call NodeOperation (input) executeOpenCLChunk(.....)
+ 3. schedule readback from opencl to main device (outputbuffer)
+ 4. schedule native callback
+
+ note: list of cl_mem will be filled by 2, and needs to be cleaned up by 4
+ */
+ // STEP 1
+ const unsigned int outputBufferWidth = outputMemoryBuffer->getWidth();
+ const unsigned int outputBufferHeight = outputMemoryBuffer->getHeight();
+
+ const cl_image_format imageFormat = {
+ CL_RGBA,
+ CL_FLOAT
+ };
+
+ cl_mem clOutputBuffer = clCreateImage2D(context, CL_MEM_WRITE_ONLY|CL_MEM_USE_HOST_PTR, &imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+
+ // STEP 2
+ list<cl_mem> * clMemToCleanUp = new list<cl_mem>();
+ clMemToCleanUp->push_back(clOutputBuffer);
+ list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
+
+ this->input->executeOpenCL(context, program, queue, outputMemoryBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
+
+ // STEP 3
+
+ size_t origin[3] = {0,0,0};
+ size_t region[3] = {outputBufferWidth,outputBufferHeight,1};
+
+ error = clEnqueueBarrier(queue);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ error = clEnqueueReadImage(queue, clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ // STEP 4
+
+ while (clMemToCleanUp->size()>0) {
+ cl_mem mem = clMemToCleanUp->front();
+ error = clReleaseMemObject(mem);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ clMemToCleanUp->pop_front();
+ }
+
+ while (clKernelsToCleanUp->size()>0) {
+ cl_kernel kernel = clKernelsToCleanUp->front();
+ error = clReleaseKernel(kernel);
+ if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ clKernelsToCleanUp->pop_front();
+ }
+ delete clKernelsToCleanUp;
+}
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
new file mode 100644
index 00000000000..3b28ffd4f63
--- /dev/null
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_WriteBufferOperation_h_
+#define _COM_WriteBufferOperation_h_
+
+#include "COM_NodeOperation.h"
+#include "COM_MemoryProxy.h"
+#include "COM_SocketReader.h"
+/**
+ * @brief Operation to write to a tile
+ * @ingroup Operation
+ */
+class WriteBufferOperation: public NodeOperation {
+ MemoryProxy *memoryProxy;
+ NodeOperation *input;
+ const bNodeTree * tree;
+public:
+ WriteBufferOperation();
+ ~WriteBufferOperation();
+ int isBufferOperation() {return true;}
+ MemoryProxy* getMemoryProxy() {return this->memoryProxy;}
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+ const bool isWriteBufferOperation() const {return true;}
+
+ void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer** memoryBuffers);
+ void initExecution();
+ void deinitExecution();
+ void setbNodeTree(const bNodeTree* tree) {this->tree = tree;}
+ void executeOpenCLRegion(cl_context context, cl_program program, cl_command_queue queue, rcti *rect, unsigned int chunkNumber, MemoryBuffer** memoryBuffers);
+
+};
+#endif
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
new file mode 100644
index 00000000000..9aa06df1ead
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "COM_ZCombineOperation.h"
+#include "BLI_utildefines.h"
+
+ZCombineOperation::ZCombineOperation(): NodeOperation() {
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->image1Reader = NULL;
+ this->depth1Reader = NULL;
+ this->image2Reader = NULL;
+ this->depth2Reader = NULL;
+
+}
+
+void ZCombineOperation::initExecution() {
+ this->image1Reader = this->getInputSocketReader(0);
+ this->depth1Reader = this->getInputSocketReader(1);
+ this->image2Reader = this->getInputSocketReader(2);
+ this->depth2Reader = this->getInputSocketReader(3);
+}
+
+void ZCombineOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float depth1[4];
+ float depth2[4];
+
+ this->depth1Reader->read(depth1, x, y, sampler, inputBuffers);
+ this->depth2Reader->read(depth2, x, y, sampler, inputBuffers);
+ if (depth1[0]<depth2[0]) {
+ this->image1Reader->read(color, x, y, sampler, inputBuffers);
+ } else {
+ this->image2Reader->read(color, x, y, sampler, inputBuffers);
+ }
+}
+void ZCombineAlphaOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+ float depth1[4];
+ float depth2[4];
+ float color1[4];
+ float color2[4];
+
+ this->depth1Reader->read(depth1, x, y, sampler, inputBuffers);
+ this->depth2Reader->read(depth2, x, y, sampler, inputBuffers);
+ if (depth1[0]<depth2[0]) {
+ this->image1Reader->read(color1, x, y, sampler, inputBuffers);
+ this->image2Reader->read(color2, x, y, sampler, inputBuffers);
+ } else {
+ this->image1Reader->read(color2, x, y, sampler, inputBuffers);
+ this->image2Reader->read(color1, x, y, sampler, inputBuffers);
+ }
+ float fac = color1[3];
+ float ifac = 1.0f-fac;
+ color[0] = color1[0]+ifac*color2[0];
+ color[1] = color1[1]+ifac*color2[1];
+ color[2] = color1[2]+ifac*color2[2];
+ color[3] = MAX2(color1[3], color2[3]);
+}
+
+void ZCombineOperation::deinitExecution() {
+ this->image1Reader = NULL;
+ this->depth1Reader = NULL;
+ this->image2Reader = NULL;
+ this->depth2Reader = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
new file mode 100644
index 00000000000..d5a3f02fea2
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef _COM_ZCombineOperation_h
+#define _COM_ZCombineOperation_h
+#include "COM_MixBaseOperation.h"
+
+
+/**
+ * this program converts an input colour to an output value.
+ * it assumes we are in sRGB colour space.
+ */
+class ZCombineOperation : public NodeOperation {
+protected:
+ SocketReader* image1Reader;
+ SocketReader* depth1Reader;
+ SocketReader* image2Reader;
+ SocketReader* depth2Reader;
+public:
+ /**
+ * Default constructor
+ */
+ ZCombineOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+class ZCombineAlphaOperation: public ZCombineOperation {
+ void executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
+};
+
+#endif
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 58fbceb999d..e2ab5ea64e4 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2210,7 +2210,7 @@ static int image_record_composite_apply(bContext *C, wmOperator *op)
BKE_image_all_free_anim_ibufs(scene->r.cfra);
ntreeCompositTagAnimated(scene->nodetree);
- ntreeCompositExecTree(scene->nodetree, &scene->r, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
+ ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra); /* 1 is no previews */
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 205202a0658..0a64c102150 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -1967,6 +1967,256 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po
uiItemR(layout, ptr, "distortion_type", 0, "", 0);
}
+static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *row;
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Saturation", 0);
+ uiItemL(row, "Contrast", 0);
+ uiItemL(row, "Gamma", 0);
+ uiItemL(row, "Gain", 0);
+ uiItemL(row, "Lift", 0);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+}
+static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) {
+ uiLayout *row;
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
+ row = layout;
+ uiItemL(row, "Saturation", 0);
+ uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemL(row, "Contrast", 0);
+ uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemL(row, "Gamma", 0);
+ uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemL(row, "Gain", 0);
+ uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemL(row, "Lift", 0);
+ uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE);
+}
+
+static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
+}
+
+static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *row;
+
+ row= uiLayoutRow(layout, 1);
+ uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
+
+ row= uiLayoutRow(layout, 1);
+ uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
+}
+
+static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "flaps", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "rounding", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "catadioptric", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "shift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+}
+
+void node_composit_backdrop_viewer(SpaceNode* snode, ImBuf* backdrop, bNode* node, int x, int y)
+{
+// node_composit_backdrop_canvas(snode, backdrop, node, x, y);
+ if (node->custom1 == 0) { /// @todo: why did we need this one?
+ const float backdropWidth = backdrop->x;
+ const float backdropHeight = backdrop->y;
+ const float cx = x+snode->zoom*backdropWidth*node->custom3;
+ const float cy = y+snode->zoom*backdropHeight*node->custom4;
+
+ glColor3f(1.0, 1.0, 1.0);
+
+ glBegin(GL_LINES);
+ glVertex2f(cx-25, cy-25);
+ glVertex2f(cx+25, cy+25);
+ glVertex2f(cx+25, cy-25);
+ glVertex2f(cx-25, cy+25);
+ glEnd();
+ }
+}
+
+void node_composit_backdrop_boxmask(SpaceNode* snode, ImBuf* backdrop, bNode* node, int x, int y)
+{
+ NodeBoxMask * boxmask = node->storage;
+ const float backdropWidth = backdrop->x;
+ const float backdropHeight = backdrop->y;
+ const float aspect = backdropWidth/backdropHeight;
+ const float rad = DEG2RAD(-boxmask->rotation);
+ const float cosine = cos(rad);
+ const float sine = sin(rad);
+ const float halveBoxWidth = backdropWidth*(boxmask->width/2.0f);
+ const float halveBoxHeight = backdropHeight*(boxmask->height/2.0f)*aspect;
+
+ float cx, cy, x1, x2, x3, x4;
+ float y1, y2, y3, y4;
+
+
+ /* keep this, saves us from a version patch */
+ if(snode->zoom==0.0f) snode->zoom= 1.0f;
+
+ glColor3f(1.0, 1.0, 1.0);
+
+ cx = x+snode->zoom*backdropWidth*boxmask->x;
+ cy = y+snode->zoom*backdropHeight*boxmask->y;
+
+ x1 = cx - (cosine*halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x2 = cx - (cosine*-halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x3 = cx - (cosine*-halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ x4 = cx - (cosine*halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ y1 = cy - (-sine*halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y2 = cy - (-sine*-halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y3 = cy - (-sine*-halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+ y4 = cy - (-sine*halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glVertex2f(x3, y3);
+ glVertex2f(x4, y4);
+ glEnd();
+}
+
+void node_composit_backdrop_ellipsemask(SpaceNode* snode, ImBuf* backdrop, bNode* node, int x, int y)
+{
+ NodeEllipseMask * ellipsemask = node->storage;
+ const float backdropWidth = backdrop->x;
+ const float backdropHeight = backdrop->y;
+ const float aspect = backdropWidth/backdropHeight;
+ const float rad = DEG2RAD(-ellipsemask->rotation);
+ const float cosine = cos(rad);
+ const float sine = sin(rad);
+ const float halveBoxWidth = backdropWidth*(ellipsemask->width/2.0f);
+ const float halveBoxHeight = backdropHeight*(ellipsemask->height/2.0f)*aspect;
+
+ float cx, cy, x1, x2, x3, x4;
+ float y1, y2, y3, y4;
+
+
+ /* keep this, saves us from a version patch */
+ if(snode->zoom==0.0f) snode->zoom= 1.0f;
+
+ glColor3f(1.0, 1.0, 1.0);
+
+ cx = x+snode->zoom*backdropWidth*ellipsemask->x;
+ cy = y+snode->zoom*backdropHeight*ellipsemask->y;
+
+ x1 = cx - (cosine*halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x2 = cx - (cosine*-halveBoxWidth+sine*halveBoxHeight)*snode->zoom;
+ x3 = cx - (cosine*-halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ x4 = cx - (cosine*halveBoxWidth+sine*-halveBoxHeight)*snode->zoom;
+ y1 = cy - (-sine*halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y2 = cy - (-sine*-halveBoxWidth + cosine*halveBoxHeight)*snode->zoom;
+ y3 = cy - (-sine*-halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+ y4 = cy - (-sine*halveBoxWidth + cosine*-halveBoxHeight)*snode->zoom;
+
+ glBegin(GL_LINE_LOOP);
+
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glVertex2f(x3, y3);
+ glVertex2f(x4, y4);
+ glEnd();
+}
+
+static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *row;
+ row= uiLayoutRow(layout, 1);
+ uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
+ uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
+ row= uiLayoutRow(layout, 1);
+ uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+ uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
+
+ uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
+}
+
+static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col;
+
+ uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
+ if (RNA_enum_get(ptr, "tile_order")==0) {
+ col= uiLayoutColumn(layout, 1);
+ uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
+ }
+}
+
/* only once called */
static void node_composit_set_butfunc(bNodeType *ntype)
{
@@ -2134,6 +2384,30 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_MOVIEDISTORTION:
ntype->uifunc= node_composit_buts_moviedistortion;
break;
+ case CMP_NODE_COLORCORRECTION:
+ ntype->uifunc=node_composit_buts_colorcorrection;
+ ntype->uifuncbut=node_composit_buts_colorcorrection_but;
+ break;
+ case CMP_NODE_SWITCH:
+ ntype->uifunc= node_composit_buts_switch;
+ break;
+ case CMP_NODE_MASK_BOX:
+ ntype->uifunc= node_composit_buts_boxmask;
+ ntype->uibackdropfunc = node_composit_backdrop_boxmask;
+ break;
+ case CMP_NODE_MASK_ELLIPSE:
+ ntype->uifunc= node_composit_buts_ellipsemask;
+ ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
+ break;
+ case CMP_NODE_BOKEHIMAGE:
+ ntype->uifunc= node_composit_buts_bokehimage;
+ break;
+ case CMP_NODE_VIEWER:
+ ntype->uifunc = NULL;
+ ntype->uifuncbut= node_composit_buts_viewer_but;
+ ntype->uibackdropfunc = node_composit_backdrop_viewer;
+ break;
+
default:
ntype->uifunc= NULL;
}
@@ -2432,6 +2706,19 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
glPixelZoom(1.0f, 1.0f);
}
}
+
+ /// @note draw selected info on backdrop
+ if (snode->edittree) {
+ bNode *node = snode->edittree->nodes.first;
+ while (node) {
+ if (node->flag & NODE_SELECT) {
+ if (node->typeinfo->uibackdropfunc) {
+ node->typeinfo->uibackdropfunc(snode, ibuf, node, x, y);
+ }
+ }
+ node = node->next;
+ }
+ }
glMatrixMode(GL_PROJECTION);
glPopMatrix();
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index c23f6c76650..f71ce3f960c 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -185,8 +185,8 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
// XXX BIF_store_spare();
- ntreeCompositExecTree(ntree, &cj->scene->r, 1); /* 1 is do_previews */
-
+ ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1); /* 1 is do_previews */
+
ntree->test_break= NULL;
ntree->stats_draw= NULL;
ntree->progress= NULL;
@@ -405,6 +405,10 @@ void ED_node_composit_default(Scene *sce)
}
sce->nodetree= ntreeAddTree("Compositing Nodetree", NTREE_COMPOSIT, 0);
+
+ sce->nodetree->chunksize = 256;
+ sce->nodetree->edit_quality = NTREE_QUALITY_HIGH;
+ sce->nodetree->render_quality = NTREE_QUALITY_HIGH;
ntemp.type = CMP_NODE_COMPOSITE;
out= nodeAddNode(sce->nodetree, &ntemp);
diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h
index 6fbaf1723bc..077c4011f4f 100644
--- a/source/blender/makesdna/DNA_node_types.h
+++ b/source/blender/makesdna/DNA_node_types.h
@@ -68,6 +68,14 @@ typedef struct bNodeStack {
#define NS_OSA_VECTORS 1
#define NS_OSA_VALUES 2
+/* node socket/node socket type -b conversion rules */
+#define NS_CR_CENTER 0
+#define NS_CR_NONE 1
+#define NS_CR_FIT_WIDTH 2
+#define NS_CR_FIT_HEIGHT 3
+#define NS_CR_FIT 4
+#define NS_CR_STRETCH 5
+
typedef struct bNodeSocket {
struct bNodeSocket *next, *prev, *new_sock;
@@ -87,7 +95,7 @@ typedef struct bNodeSocket {
short stack_index; /* local stack index */
/* XXX deprecated, kept for forward compatibility */
short stack_type DNA_DEPRECATED;
- int pad2;
+ int resizemode; /* compositor resize mode of the socket */
void *cache; /* cached data from execution */
/* internal data to retrieve relations and groups */
@@ -223,6 +231,11 @@ typedef struct bNodeLink {
#define NODE_LINKFLAG_HILITE 1 /* link has been successfully validated */
#define NODE_LINK_VALID 2
+/* tree->edit_quality/tree->render_quality */
+#define NTREE_QUALITY_HIGH 0
+#define NTREE_QUALITY_MEDIUM 1
+#define NTREE_QUALITY_LOW 2
+
/* the basis for a Node tree, all links and nodes reside internal here */
/* only re-usable node trees are in the library though, materials and textures allocate own tree struct */
typedef struct bNodeTree {
@@ -240,6 +253,10 @@ typedef struct bNodeTree {
int update; /* update flags */
int nodetype; /* specific node type this tree is used for */
+
+ short edit_quality; /* Quality setting when editing */
+ short render_quality; /* Quality setting when rendering */
+ int chunksize; /* tile size for compositor engine */
ListBase inputs, outputs; /* external sockets for group nodes */
@@ -271,6 +288,7 @@ typedef struct bNodeTree {
/* ntree->flag */
#define NTREE_DS_EXPAND 1 /* for animation editors */
+#define NTREE_COM_OPENCL 2 /* use opencl */
/* XXX not nice, but needed as a temporary flags
* for group updates after library linking.
*/
@@ -317,6 +335,16 @@ typedef struct bNodeSocketValueRGBA {
/* data structs, for node->storage */
+#define CMP_NODE_MASKTYPE_ADD 0
+#define CMP_NODE_MASKTYPE_SUBTRACT 1
+#define CMP_NODE_MASKTYPE_MULTIPLY 2
+#define CMP_NODE_MASKTYPE_NOT 3
+
+#define CMP_NODE_LENSFLARE_GHOST 1
+#define CMP_NODE_LENSFLARE_GLOW 2
+#define CMP_NODE_LENSFLARE_CIRCLE 4
+#define CMP_NODE_LENSFLARE_STREAKS 8
+
/* this one has been replaced with ImageUser, keep it for do_versions() */
typedef struct NodeImageAnim {
int frames, sfra, nr;
@@ -324,6 +352,50 @@ typedef struct NodeImageAnim {
short pad;
} NodeImageAnim;
+typedef struct ColorCorrectionData {
+ float saturation;
+ float contrast;
+ float gamma;
+ float gain;
+ float lift;
+ int pad;
+} ColorCorrectionData;
+
+typedef struct NodeColorCorrection {
+ ColorCorrectionData master;
+ ColorCorrectionData shadows;
+ ColorCorrectionData midtones;
+ ColorCorrectionData highlights;
+ float startmidtones;
+ float endmidtones;
+} NodeColorCorrection;
+
+typedef struct NodeBokehImage {
+ float angle;
+ int flaps;
+ float rounding;
+ float catadioptric;
+ float lensshift;
+} NodeBokehImage;
+
+typedef struct NodeBoxMask {
+ float x;
+ float y;
+ float rotation;
+ float height;
+ float width;
+ int pad;
+} NodeBoxMask;
+
+typedef struct NodeEllipseMask {
+ float x;
+ float y;
+ float rotation;
+ float height;
+ float width;
+ int pad;
+} NodeEllipseMask;
+
/* layer info for image node outputs */
typedef struct NodeImageLayer {
/* index in the Image->layers and Image->layers->passes lists */
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index f3ae30eb2aa..6c8293f8dae 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -64,6 +64,11 @@ EnumPropertyItem nodetree_type_items[] = {
{0, NULL, 0, NULL, NULL}
};
+EnumPropertyItem node_quality_items[] = {
+ {NTREE_QUALITY_HIGH, "HIGH", 0, "High", "High quality"},
+ {NTREE_QUALITY_MEDIUM, "MEDIUM", 0, "Medium", "Medium quality"},
+ {NTREE_QUALITY_LOW, "LOW", 0, "Low", "Low quality"},
+ {0, NULL, 0, NULL, NULL}};
EnumPropertyItem node_socket_type_items[] = {
{SOCK_FLOAT, "VALUE", 0, "Value", ""},
@@ -2931,6 +2936,373 @@ static void dev_cmd_transform(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
+/* -- Compositor Nodes ------------------------------------------------------ */
+
+EnumPropertyItem node_masktype_items[] = {
+{0, "ADD", 0, "Add", ""},
+{1, "SUBTRACT", 0, "Subtract", ""},
+{2, "MULTIPLY", 0, "Multiply", ""},
+{3, "NOT", 0, "Not", ""},
+{0, NULL, 0, NULL, NULL}};
+
+static void def_cmp_boxmask(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "mask_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, node_masktype_items);
+ RNA_def_property_ui_text(prop, "Mask type", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "NodeBoxMask", "storage");
+
+ prop = RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "x");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, -1.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "X position", "X position of the middle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "y");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, -1.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Y position", "Y position of the middle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "width");
+ RNA_def_property_float_default(prop, 0.3f);
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Width of the box", "Width of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "height");
+ RNA_def_property_float_default(prop, 0.2f);
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Height of the box", "Height of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1000.0f, 1000.0f);
+ RNA_def_property_ui_text(prop, "Rotation", "Rotationangle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+static void def_cmp_ellipsemask(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ prop = RNA_def_property(srna, "mask_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, node_masktype_items);
+ RNA_def_property_ui_text(prop, "Mask type", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "NodeEllipseMask", "storage");
+
+ prop = RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "x");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, -1.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "X position", "X position of the middle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "y");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, -1.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Y position", "Y position of the middle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "width");
+ RNA_def_property_float_default(prop, 0.3f);
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Width of the box", "Width of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "height");
+ RNA_def_property_float_default(prop, 0.2f);
+ RNA_def_property_range(prop, 0.0f, 2.0f);
+ RNA_def_property_ui_text(prop, "Height of the box", "Height of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rotation");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1000.0f, 1000.0f);
+ RNA_def_property_ui_text(prop, "Rotation", "Rotationangle of the box");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+static void def_cmp_bokehimage(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ RNA_def_struct_sdna_from(srna, "NodeBokehImage", "storage");
+
+ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "angle");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -0.0f, 360.0f);
+ RNA_def_property_ui_text(prop, "Angle", "Angle of the bokeh");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "flaps", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "flaps");
+ RNA_def_property_int_default(prop, 5);
+ RNA_def_property_range(prop, 3, 24);
+ RNA_def_property_ui_text(prop, "Flaps", "Number of flaps");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "rounding", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "rounding");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Rounding", "Level of rounding of the bokeh");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "catadioptric", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "catadioptric");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Catadioptric", "Level of catadioptric of the bokeh");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "shift", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "lensshift");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Lens shift", "Shift of the lens.");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+}
+
+static void def_cmp_switch(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "check", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0);
+ RNA_def_property_ui_text(prop, "Switch", "Off: first socket, On: second socket");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+static void def_cmp_colorcorrection(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ prop = RNA_def_property(srna, "red", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1);
+ RNA_def_property_boolean_default(prop, TRUE);
+ RNA_def_property_ui_text(prop, "Red", "Red channel active");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "green", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 2);
+ RNA_def_property_boolean_default(prop, TRUE);
+ RNA_def_property_ui_text(prop, "Green", "Green channel active");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "blue", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 4);
+ RNA_def_property_boolean_default(prop, TRUE);
+ RNA_def_property_ui_text(prop, "Blue", "Blue channel active");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ RNA_def_struct_sdna_from(srna, "NodeColorCorrection", "storage");
+
+ prop = RNA_def_property(srna, "midtones_start", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "startmidtones");
+ RNA_def_property_float_default(prop, 0.2f);
+ RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_text(prop, "Start of midtones", "Start of midtones");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "midtones_end", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "endmidtones");
+ RNA_def_property_float_default(prop, 0.7f);
+ RNA_def_property_range(prop, 0, 1);
+ RNA_def_property_ui_text(prop, "End of midtones", "end of midtones");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "master_saturation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "master.saturation");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Master saturation", "Master saturation");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "master_contrast", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "master.contrast");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Master contrast", "Master contrast");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "master_gamma", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "master.gamma");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Master gamma", "Master gamma");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "master_gain", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "master.gain");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Master gain", "Master gain");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "master_lift", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "master.lift");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1, 1);
+ RNA_def_property_ui_text(prop, "Master lift", "Master lift");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+//
+ prop = RNA_def_property(srna, "shadows_saturation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shadows.saturation");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Shadows saturation", "Shadows saturation");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "shadows_contrast", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shadows.contrast");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Shadows contrast", "Shadows contrast");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "shadows_gamma", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shadows.gamma");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Shadows gamma", "Shadows gamma");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "shadows_gain", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shadows.gain");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Shadows gain", "Shadows gain");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "shadows_lift", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shadows.lift");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1, 1);
+ RNA_def_property_ui_text(prop, "Shadows lift", "Shadows lift");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+//
+ prop = RNA_def_property(srna, "midtones_saturation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "midtones.saturation");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Midtones saturation", "Midtones saturation");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "midtones_contrast", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "midtones.contrast");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Midtones contrast", "Midtones contrast");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "midtones_gamma", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "midtones.gamma");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Midtones gamma", "Midtones gamma");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "midtones_gain", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "midtones.gain");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Midtones gain", "Midtones gain");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "midtones_lift", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "midtones.lift");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1, 1);
+ RNA_def_property_ui_text(prop, "Midtones lift", "Midtones lift");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+//
+ prop = RNA_def_property(srna, "highlights_saturation", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "highlights.saturation");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Highlights saturation", "Highlights saturation");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "highlights_contrast", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "highlights.contrast");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Highlights contrast", "Highlights contrast");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "highlights_gamma", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "highlights.gamma");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Highlights gamma", "Highlights gamma");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "highlights_gain", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "highlights.gain");
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_range(prop, 0, 4);
+ RNA_def_property_ui_text(prop, "Highlights gain", "Highlights gain");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "highlights_lift", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "highlights.lift");
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_range(prop, -1, 1);
+ RNA_def_property_ui_text(prop, "Highlights lift", "Highlights lift");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
+static void def_cmp_viewer(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ static EnumPropertyItem tileorder_items[] = {
+ {0, "CENTEROUT", 0, "Center", "Expand from center"},
+ {1, "RANDOM", 0, "Random", "Random tiles"},
+ {2, "BOTTOMUP", 0, "Bottom up", "Expand from bottom"},
+ {3, "RULE_OF_THIRDS", 0, "Rule of thirds", "Expand from 9 places"},
+ {0, NULL, 0, NULL, NULL}};
+
+ prop = RNA_def_property(srna, "tile_order", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "custom1");
+ RNA_def_property_enum_items(prop, tileorder_items);
+ RNA_def_property_ui_text(prop, "Tile order", "tile order");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "center_x", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "custom3");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "X", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+
+ prop = RNA_def_property(srna, "center_y", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "custom4");
+ RNA_def_property_float_default(prop, 0.5f);
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Y", "");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
/* -- Texture Nodes --------------------------------------------------------- */
@@ -3488,6 +3860,25 @@ static void rna_def_composite_nodetree(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Node");
RNA_def_property_ui_text(prop, "Nodes", "");
+ prop= RNA_def_property(srna, "render_quality", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "render_quality");
+ RNA_def_property_enum_items(prop, node_quality_items);
+ RNA_def_property_ui_text(prop, "Render quality", "Quality when rendering");
+
+ prop= RNA_def_property(srna, "edit_quality", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "edit_quality");
+ RNA_def_property_enum_items(prop, node_quality_items);
+ RNA_def_property_ui_text(prop, "Edit quality", "Quality when editing");
+
+ prop= RNA_def_property(srna, "chunksize", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "chunksize");
+ RNA_def_property_ui_text(prop, "Chunksize", "Max size of a chunk during calculation");
+ RNA_def_property_range(prop, 32, 1024);
+
+ prop= RNA_def_property(srna, "use_opencl", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", NTREE_COM_OPENCL);
+ RNA_def_property_ui_text(prop, "OpenCL", "Enable GPU calculations");
+
rna_def_composite_nodetree_api(brna, prop);
}
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index d7e55ae27df..2da06d5dea7 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -91,7 +91,7 @@ DefNode( ShaderNode, SH_NODE_TEX_VORONOI, def_sh_tex_voronoi, "TE
DefNode( ShaderNode, SH_NODE_TEX_CHECKER, def_sh_tex_checker, "TEX_CHECKER", TexChecker, "Checker Texture", "" )
DefNode( ShaderNode, SH_NODE_TEX_COORD, 0, "TEX_COORD", TexCoord, "Texture Coordinate","")
-DefNode( CompositorNode, CMP_NODE_VIEWER, 0, "VIEWER", Viewer, "Viewer", "" )
+DefNode( CompositorNode, CMP_NODE_VIEWER, def_cmp_viewer, "VIEWER", Viewer, "Viewer", "" )
DefNode( CompositorNode, CMP_NODE_RGB, 0, "RGB", RGB, "RGB", "" )
DefNode( CompositorNode, CMP_NODE_VALUE, 0, "VALUE", Value, "Value", "" )
DefNode( CompositorNode, CMP_NODE_MIX_RGB, def_mix_rgb, "MIX_RGB", MixRGB, "Mix RGB", "" )
@@ -159,6 +159,11 @@ DefNode( CompositorNode, CMP_NODE_MOVIECLIP, def_cmp_movieclip, "MOVIE
DefNode( CompositorNode, CMP_NODE_TRANSFORM, dev_cmd_transform, "TRANSFORM", Transform, "Transform", "" )
DefNode( CompositorNode, CMP_NODE_STABILIZE2D, def_cmp_stabilize2d, "STABILIZE2D", Stabilize, "Stabilize 2D", "" )
DefNode( CompositorNode, CMP_NODE_MOVIEDISTORTION,def_cmp_moviedistortion,"MOVIEDISTORTION",MovieDistortion, "Movie Distortion", "" )
+DefNode( CompositorNode, CMP_NODE_MASK_BOX, def_cmp_boxmask, "BOXMASK" ,BoxMask, "Box mask", "" )
+DefNode( CompositorNode, CMP_NODE_MASK_ELLIPSE, def_cmp_ellipsemask, "ELLIPSEMASK" ,EllipseMask, "Ellipse mask", "" )
+DefNode( CompositorNode, CMP_NODE_BOKEHIMAGE, def_cmp_bokehimage, "BOKEHIMAGE" ,BokehImage, "Bokeh image", "" )
+DefNode( CompositorNode, CMP_NODE_SWITCH, def_cmp_switch, "SWITCH" ,Switch, "Switch", "" )
+DefNode( CompositorNode, CMP_NODE_COLORCORRECTION,def_cmp_colorcorrection,"COLORCORRECTION",ColorCorrection, "ColorCorrection", "" )
DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index be9dd10b71d..772ce376cb8 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -35,6 +35,7 @@ set(INC
../makesrna
../render/extern/include
../../../intern/guardedalloc
+ ../compositor
)
set(INC_SYS
@@ -107,6 +108,13 @@ set(SRC
composite/nodes/node_composite_vecBlur.c
composite/nodes/node_composite_viewer.c
composite/nodes/node_composite_zcombine.c
+ composite/nodes/node_composite_bokehblur.c
+ composite/nodes/node_composite_bokehimage.c
+ composite/nodes/node_composite_boxmask.c
+ composite/nodes/node_composite_ellipsemask.c
+ composite/nodes/node_composite_switch.c
+ composite/nodes/node_composite_colorcorrection.c
+
composite/node_composite_tree.c
composite/node_composite_util.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index 284b89bc095..ca925c82afd 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -120,4 +120,12 @@ void register_node_type_cmp_glare(struct bNodeTreeType *ttype);
void register_node_type_cmp_tonemap(struct bNodeTreeType *ttype);
void register_node_type_cmp_lensdist(struct bNodeTreeType *ttype);
+
+void register_node_type_cmp_colorcorrection(struct bNodeTreeType *ttype);
+void register_node_type_cmp_boxmask(struct bNodeTreeType *ttype);
+void register_node_type_cmp_ellipsemask(struct bNodeTreeType *ttype);
+void register_node_type_cmp_bokehimage(struct bNodeTreeType *ttype);
+void register_node_type_cmp_bokehblur(struct bNodeTreeType *ttype);
+void register_node_type_cmp_switch(struct bNodeTreeType *ttype);
+
#endif
diff --git a/source/blender/nodes/SConscript b/source/blender/nodes/SConscript
index c8b13e24533..86178b31688 100644
--- a/source/blender/nodes/SConscript
+++ b/source/blender/nodes/SConscript
@@ -13,6 +13,7 @@ incs += ' ../imbuf ../avi '
incs += ' ../blenloader'
incs += ' ../blenfont ../blenkernel ../renderconverter '
incs += ' ../gpu #/extern/glew/include '
+incs += ' ../compositor '
incs += ' ' + env['BF_OPENGL_INC']
incs += ' ' + env['BF_ZLIB_INC']
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 41b1204fba4..b266af15060 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -59,6 +59,7 @@
#include "NOD_composite.h"
#include "node_composite_util.h"
+#include "COM_compositor.h"
static void foreach_nodetree(Main *main, void *calldata, bNodeTreeCallback func)
{
@@ -136,7 +137,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree)
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->id) {
if (node->flag & NODE_DO_OUTPUT)
- node->new_node->id= (ID *)BKE_image_copy((Image *)node->id);
+ node->new_node->id= (ID *)node->id;
else
node->new_node->id= NULL;
}
@@ -575,20 +576,19 @@ static void ntree_composite_texnode(bNodeTree *ntree, int init)
}
/* optimized tree execute test for compositing */
-void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
+/* optimized tree execute test for compositing */
+static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_preview)
{
bNodeExec *nodeexec;
bNode *node;
ListBase threads;
ThreadData thdata;
int totnode, curnode, rendering= 1, n;
- bNodeTreeExec *exec;
-
- if (ntree==NULL) return;
-
- exec = ntree->execdata;
-
- if (do_preview)
+ bNodeTreeExec *exec= ntree->execdata;
+
+ if(ntree==NULL) return;
+
+ if(do_preview)
ntreeInitPreview(ntree, 0, 0);
if (!ntree->execdata) {
@@ -598,7 +598,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
ntree_composite_texnode(ntree, 1);
/* prevent unlucky accidents */
- if (G.background)
+ if(G.background)
rd->scemode &= ~R_COMP_CROP;
/* setup callerdata for thread callback */
@@ -613,15 +613,15 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
BLI_init_threads(&threads, exec_composite_node, rd->threads);
- while (rendering) {
+ while(rendering) {
- if (BLI_available_threads(&threads)) {
+ if(BLI_available_threads(&threads)) {
nodeexec= getExecutableNode(exec);
- if (nodeexec) {
+ if(nodeexec) {
node = nodeexec->node;
- if (ntree->progress && totnode)
+ if(ntree->progress && totnode)
ntree->progress(ntree->prh, (1.0f - curnode/(float)totnode));
- if (ntree->stats_draw) {
+ if(ntree->stats_draw) {
char str[128];
BLI_snprintf(str, sizeof(str), "Compositing %d %s", curnode, node->name);
ntree->stats_draw(ntree->sdh, str);
@@ -640,21 +640,21 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
rendering= 0;
/* test for ESC */
- if (ntree->test_break && ntree->test_break(ntree->tbh)) {
- for (node= ntree->nodes.first; node; node= node->next)
+ if(ntree->test_break && ntree->test_break(ntree->tbh)) {
+ for(node= ntree->nodes.first; node; node= node->next)
node->exec |= NODE_READY;
}
/* check for ready ones, and if we need to continue */
- for (n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
+ for(n=0, nodeexec=exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
node = nodeexec->node;
- if (node->exec & NODE_READY) {
- if ((node->exec & NODE_FINISHED)==0) {
+ if(node->exec & NODE_READY) {
+ if((node->exec & NODE_FINISHED)==0) {
BLI_remove_thread(&threads, nodeexec); /* this waits for running thread to finish btw */
node->exec |= NODE_FINISHED;
/* freeing unused buffers */
- if (rd->scemode & R_COMP_FREE)
+ if(rd->scemode & R_COMP_FREE)
freeExecutableNode(exec);
}
}
@@ -668,6 +668,14 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
ntreeCompositEndExecTree(exec, 1);
}
+void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int rendering, int do_preview)
+{
+ if(G.rt == 200)
+ ntreeCompositExecTreeOld(ntree, rd, do_preview);
+ else
+ COM_execute(ntree, rendering);
+}
+
/* *********************************************** */
/* clumsy checking... should do dynamic outputs once */
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
new file mode 100644
index 00000000000..f239267a128
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Campbell Barton, Alfredo de Greef, David Millan Escriva,
+ * Juho Vepsäläinen
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/intern/CMP_nodes/CMP_blur.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "../node_composite_util.h"
+
+/* **************** BLUR ******************** */
+static bNodeSocketTemplate cmp_node_bokehblur_in[]= {
+ { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, "Bokeh", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Size", 0.01f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f},
+ { SOCK_FLOAT, 1, "Bounding box", 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_bokehblur_out[]= {
+ { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+void register_node_type_cmp_bokehblur(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_bokehblur_in, cmp_node_bokehblur_out);
+ node_type_size(&ntype, 120, 80, 200);
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
new file mode 100644
index 00000000000..15dba89d12b
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c
@@ -0,0 +1,66 @@
+/*
+* $Id$
+*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2006 Blender Foundation.
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): none yet.
+*
+* ***** END GPL LICENSE BLOCK *****
+
+*/
+
+/** \file blender/nodes/intern/CMP_nodes/CMP_gamma.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "../node_composite_util.h"
+
+/* **************** Bokeh image Tools ******************** */
+
+static bNodeSocketTemplate cmp_node_bokehimage_out[]= {
+ { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeBokehImage * data = MEM_callocN(sizeof(NodeBokehImage), "NodeBokehImage");
+ data->angle = 0.0f;
+ data->flaps = 5;
+ data->rounding = 0.0f;
+ data->catadioptric = 0.0f;
+ data->lensshift = 0.0f;
+ node->storage = data;
+}
+
+void register_node_type_cmp_bokehimage(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_BOKEHIMAGE, "Bokeh Image", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS);
+ node_type_socket_templates(&ntype, NULL, cmp_node_bokehimage_out);
+ node_type_size(&ntype, 140, 100, 320);
+ node_type_init(&ntype, node_composit_init_bokehimage);
+ node_type_storage(&ntype, "NodeBokehImage", node_free_standard_storage, node_copy_standard_storage);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
new file mode 100644
index 00000000000..be5d25f60c3
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c
@@ -0,0 +1,75 @@
+/*
+ * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/intern/CMP_nodes/CMP_math.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "../node_composite_util.h"
+
+/* **************** SCALAR MATH ******************** */
+static bNodeSocketTemplate cmp_node_boxmask_in[]= {
+ { SOCK_FLOAT, 1, "Mask", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Value", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_boxmask_out[]= {
+ { SOCK_FLOAT, 0, "Mask", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeBoxMask *data = MEM_callocN(sizeof(NodeBoxMask), "NodeBoxMask");
+ data->x = 0.5;
+ data->y = 0.5;
+ data->width = 0.2;
+ data->height = 0.1;
+ data->rotation = 0.0;
+ node->storage = data;
+}
+
+void register_node_type_cmp_boxmask(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_MASK_BOX, "Box Mask", NODE_CLASS_MATTE, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_boxmask_in, cmp_node_boxmask_out);
+ node_type_size(&ntype, 120, 110, 160);
+ node_type_init(&ntype, node_composit_init_boxmask);
+ node_type_storage(&ntype, "NodeBoxMask", node_free_standard_storage, node_copy_standard_storage);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
+
+
+
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
new file mode 100644
index 00000000000..af085418c0e
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c
@@ -0,0 +1,89 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Jeroen Bakker.
+ * Monique Dewanchand
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/composite/nodes/node_composite_colorcorrection.c
+ * \ingroup cmpnodes
+ */
+
+
+
+#include "node_composite_util.h"
+
+
+/* ******************* Color Balance ********************************* */
+static bNodeSocketTemplate cmp_node_colorcorrection_in[]={
+ { SOCK_RGBA,1,"Image", 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Mask", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1,0,""}
+};
+
+static bNodeSocketTemplate cmp_node_colorcorrection_out[]={
+ { SOCK_RGBA,0,"Image"},
+ { -1,0,""}
+};
+
+static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeColorCorrection *n= node->storage= MEM_callocN(sizeof(NodeColorCorrection), "node colorcorrection");
+ n->startmidtones = 0.2f;
+ n->endmidtones = 0.7f;
+ n->master.contrast = 1.0f;
+ n->master.gain = 1.0f;
+ n->master.gamma = 1.0f;
+ n->master.lift= 0.0f;
+ n->master.saturation= 1.0f;
+ n->midtones.contrast = 1.0f;
+ n->midtones.gain = 1.0f;
+ n->midtones.gamma = 1.0f;
+ n->midtones.lift= 0.0f;
+ n->midtones.saturation= 1.0f;
+ n->shadows.contrast = 1.0f;
+ n->shadows.gain = 1.0f;
+ n->shadows.gamma = 1.0f;
+ n->shadows.lift= 0.0f;
+ n->shadows.saturation= 1.0f;
+ n->highlights.contrast = 1.0f;
+ n->highlights.gain = 1.0f;
+ n->highlights.gamma = 1.0f;
+ n->highlights.lift= 0.0f;
+ n->highlights.saturation= 1.0f;
+ node->custom1 = 7; // red + green + blue enabled
+}
+
+void register_node_type_cmp_colorcorrection(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_COLORCORRECTION, "Color Correction", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_colorcorrection_in, cmp_node_colorcorrection_out);
+ node_type_size(&ntype, 400, 200, 400);
+ node_type_init(&ntype, node_composit_init_colorcorrection);
+ node_type_storage(&ntype, "NodeColorCorrection", node_free_standard_storage, node_copy_standard_storage);
+
+ nodeRegisterType(ttype, &ntype);
+}
diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
new file mode 100644
index 00000000000..556ad1ab6c6
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c
@@ -0,0 +1,75 @@
+/*
+ * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/intern/CMP_nodes/CMP_math.c
+ * \ingroup cmpnodes
+ */
+
+
+#include "../node_composite_util.h"
+
+/* **************** SCALAR MATH ******************** */
+static bNodeSocketTemplate cmp_node_ellipsemask_in[]= {
+ { SOCK_FLOAT, 1, "Mask", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, "Value", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_ellipsemask_out[]= {
+ { SOCK_FLOAT, 0, "Mask", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+{
+ NodeEllipseMask *data = MEM_callocN(sizeof(NodeEllipseMask), "NodeEllipseMask");
+ data->x = 0.5;
+ data->y = 0.5;
+ data->width = 0.2;
+ data->height = 0.1;
+ data->rotation = 0.0;
+ node->storage = data;
+}
+
+void register_node_type_cmp_ellipsemask(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_MASK_ELLIPSE, "Ellipse Mask", NODE_CLASS_MATTE, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_ellipsemask_in, cmp_node_ellipsemask_out);
+ node_type_size(&ntype, 120, 110, 160);
+ node_type_init(&ntype, node_composit_init_ellipsemask);
+ node_type_storage(&ntype, "NodeEllipseMask", node_free_standard_storage, node_copy_standard_storage);
+
+ nodeRegisterType(ttype, &ntype);
+}
+
+
+
+
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 4467fb1f193..ad1264a7b6b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -715,7 +715,6 @@ static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNU
RE_ReleaseResult(re);
}
-
void register_node_type_cmp_rlayers(bNodeTreeType *ttype)
{
static bNodeType ntype;
diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.c b/source/blender/nodes/composite/nodes/node_composite_switch.c
new file mode 100644
index 00000000000..f7b1f9e09e4
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_switch.c
@@ -0,0 +1,58 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/nodes/intern/CMP_nodes/CMP_switch.c
+ * \ingroup cmpnodes
+ */
+
+#include "../node_composite_util.h"
+
+/* **************** MIX RGB ******************** */
+static bNodeSocketTemplate cmp_node_switch_in[]= {
+ { SOCK_RGBA, 1, "Off", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, "On", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketTemplate cmp_node_switch_out[]= {
+ { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+/* custom1 = mix type */
+void register_node_type_cmp_switch(bNodeTreeType *ttype)
+{
+ static bNodeType ntype;
+
+ node_type_base(ttype, &ntype, CMP_NODE_SWITCH, "Switch", NODE_CLASS_OP_COLOR, NODE_OPTIONS);
+ node_type_socket_templates(&ntype, cmp_node_switch_in, cmp_node_switch_out);
+ node_type_size(&ntype, 110, 60, 120);
+ nodeRegisterType(ttype, &ntype);
+}
+
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c
index 3fdedbb2e42..4a0726e473b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.c
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c
@@ -129,6 +129,8 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode* node, bNo
iuser->sfra= 1;
iuser->fie_ima= 2;
iuser->ok= 1;
+ node->custom3 = 0.5f;
+ node->custom4 = 0.5f;
}
void register_node_type_cmp_viewer(bNodeTreeType *ttype)
diff --git a/source/blender/opencl/CMakeLists.txt b/source/blender/opencl/CMakeLists.txt
new file mode 100644
index 00000000000..9c8ce830316
--- /dev/null
+++ b/source/blender/opencl/CMakeLists.txt
@@ -0,0 +1,39 @@
+# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2006, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ .
+)
+
+set(SRC
+ OCL_opencl.h
+ intern/clew.h
+ intern/clew.c
+ intern/OCL_opencl.c
+)
+
+
+blender_add_lib(bf_opencl "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/opencl/OCL_opencl.h b/source/blender/opencl/OCL_opencl.h
new file mode 100644
index 00000000000..4ee167b2fb4
--- /dev/null
+++ b/source/blender/opencl/OCL_opencl.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#ifndef OCL_OPENCL_H
+#define OCL_OPENCL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "intern/clew.h"
+void OCL_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/source/blender/opencl/SConscript b/source/blender/opencl/SConscript
new file mode 100644
index 00000000000..e91a99d5075
--- /dev/null
+++ b/source/blender/opencl/SConscript
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+Import ('env')
+
+sources = env.Glob('intern/*.c')
+
+incs = '.'
+
+env.BlenderLib ( 'bf_opencl', sources, Split(incs), libtype=['core','player'], priority = [192,192] )
diff --git a/source/blender/opencl/intern/OCL_opencl.c b/source/blender/opencl/intern/OCL_opencl.c
new file mode 100644
index 00000000000..fa22acbc1a2
--- /dev/null
+++ b/source/blender/opencl/intern/OCL_opencl.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor:
+ * Jeroen Bakker
+ * Monique Dewanchand
+ */
+
+#include "OCL_opencl.h"
+
+void OCL_init()
+{
+#ifdef _WIN32
+ const char *path = "OpenCL.dll";
+#elif defined(__APPLE__)
+ const char *path = "/Library/Frameworks/OpenCL.framework/OpenCL";
+#else
+ const char *path = "libOpenCL.so";
+#endif
+
+ clewInit(path);
+}
+
diff --git a/source/blender/opencl/intern/clew.c b/source/blender/opencl/intern/clew.c
new file mode 100644
index 00000000000..d68eb17288f
--- /dev/null
+++ b/source/blender/opencl/intern/clew.c
@@ -0,0 +1,311 @@
+//////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2009 Organic Vectory B.V.
+// Written by George van Venrooij
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file license.txt)
+//////////////////////////////////////////////////////////////////////////
+
+#include "clew.h"
+
+//! \file clew.c
+//! \brief OpenCL run-time loader source
+
+#ifndef CLCC_GENERATE_DOCUMENTATION
+#ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #define VC_EXTRALEAN
+ #include <windows.h>
+
+ typedef HMODULE CLCC_DYNLIB_HANDLE;
+
+ #define CLCC_DYNLIB_OPEN LoadLibrary
+ #define CLCC_DYNLIB_CLOSE FreeLibrary
+ #define CLCC_DYNLIB_IMPORT GetProcAddress
+#else
+ #include <dlfcn.h>
+
+ typedef void* CLCC_DYNLIB_HANDLE;
+
+ #define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
+ #define CLCC_DYNLIB_CLOSE dlclose
+ #define CLCC_DYNLIB_IMPORT dlsym
+#endif
+#else
+ //typedef implementation_defined CLCC_DYNLIB_HANDLE;
+ //#define CLCC_DYNLIB_OPEN(path) implementation_defined
+ //#define CLCC_DYNLIB_CLOSE implementation_defined
+ //#define CLCC_DYNLIB_IMPORT implementation_defined
+#endif
+
+#include <stdlib.h>
+
+//! \brief module handle
+static CLCC_DYNLIB_HANDLE module = NULL;
+
+// Variables holding function entry points
+#ifndef CLCC_GENERATE_DOCUMENTATION
+PFNCLGETPLATFORMIDS __oclGetPlatformIDs = NULL;
+PFNCLGETPLATFORMINFO __oclGetPlatformInfo = NULL;
+PFNCLGETDEVICEIDS __oclGetDeviceIDs = NULL;
+PFNCLGETDEVICEINFO __oclGetDeviceInfo = NULL;
+PFNCLCREATECONTEXT __oclCreateContext = NULL;
+PFNCLCREATECONTEXTFROMTYPE __oclCreateContextFromType = NULL;
+PFNCLRETAINCONTEXT __oclRetainContext = NULL;
+PFNCLRELEASECONTEXT __oclReleaseContext = NULL;
+PFNCLGETCONTEXTINFO __oclGetContextInfo = NULL;
+PFNCLCREATECOMMANDQUEUE __oclCreateCommandQueue = NULL;
+PFNCLRETAINCOMMANDQUEUE __oclRetainCommandQueue = NULL;
+PFNCLRELEASECOMMANDQUEUE __oclReleaseCommandQueue = NULL;
+PFNCLGETCOMMANDQUEUEINFO __oclGetCommandQueueInfo = NULL;
+PFNCLSETCOMMANDQUEUEPROPERTY __oclSetCommandQueueProperty = NULL;
+PFNCLCREATEBUFFER __oclCreateBuffer = NULL;
+PFNCLCREATEIMAGE2D __oclCreateImage2D = NULL;
+PFNCLCREATEIMAGE3D __oclCreateImage3D = NULL;
+PFNCLRETAINMEMOBJECT __oclRetainMemObject = NULL;
+PFNCLRELEASEMEMOBJECT __oclReleaseMemObject = NULL;
+PFNCLGETSUPPORTEDIMAGEFORMATS __oclGetSupportedImageFormats = NULL;
+PFNCLGETMEMOBJECTINFO __oclGetMemObjectInfo = NULL;
+PFNCLGETIMAGEINFO __oclGetImageInfo = NULL;
+PFNCLCREATESAMPLER __oclCreateSampler = NULL;
+PFNCLRETAINSAMPLER __oclRetainSampler = NULL;
+PFNCLRELEASESAMPLER __oclReleaseSampler = NULL;
+PFNCLGETSAMPLERINFO __oclGetSamplerInfo = NULL;
+PFNCLCREATEPROGRAMWITHSOURCE __oclCreateProgramWithSource = NULL;
+PFNCLCREATEPROGRAMWITHBINARY __oclCreateProgramWithBinary = NULL;
+PFNCLRETAINPROGRAM __oclRetainProgram = NULL;
+PFNCLRELEASEPROGRAM __oclReleaseProgram = NULL;
+PFNCLBUILDPROGRAM __oclBuildProgram = NULL;
+PFNCLUNLOADCOMPILER __oclUnloadCompiler = NULL;
+PFNCLGETPROGRAMINFO __oclGetProgramInfo = NULL;
+PFNCLGETPROGRAMBUILDINFO __oclGetProgramBuildInfo = NULL;
+PFNCLCREATEKERNEL __oclCreateKernel = NULL;
+PFNCLCREATEKERNELSINPROGRAM __oclCreateKernelsInProgram = NULL;
+PFNCLRETAINKERNEL __oclRetainKernel = NULL;
+PFNCLRELEASEKERNEL __oclReleaseKernel = NULL;
+PFNCLSETKERNELARG __oclSetKernelArg = NULL;
+PFNCLGETKERNELINFO __oclGetKernelInfo = NULL;
+PFNCLGETKERNELWORKGROUPINFO __oclGetKernelWorkGroupInfo = NULL;
+PFNCLWAITFOREVENTS __oclWaitForEvents = NULL;
+PFNCLGETEVENTINFO __oclGetEventInfo = NULL;
+PFNCLRETAINEVENT __oclRetainEvent = NULL;
+PFNCLRELEASEEVENT __oclReleaseEvent = NULL;
+PFNCLGETEVENTPROFILINGINFO __oclGetEventProfilingInfo = NULL;
+PFNCLFLUSH __oclFlush = NULL;
+PFNCLFINISH __oclFinish = NULL;
+PFNCLENQUEUEREADBUFFER __oclEnqueueReadBuffer = NULL;
+PFNCLENQUEUEWRITEBUFFER __oclEnqueueWriteBuffer = NULL;
+PFNCLENQUEUECOPYBUFFER __oclEnqueueCopyBuffer = NULL;
+PFNCLENQUEUEREADIMAGE __oclEnqueueReadImage = NULL;
+PFNCLENQUEUEWRITEIMAGE __oclEnqueueWriteImage = NULL;
+PFNCLENQUEUECOPYIMAGE __oclEnqueueCopyImage = NULL;
+PFNCLENQUEUECOPYIMAGETOBUFFER __oclEnqueueCopyImageToBuffer = NULL;
+PFNCLENQUEUECOPYBUFFERTOIMAGE __oclEnqueueCopyBufferToImage = NULL;
+PFNCLENQUEUEMAPBUFFER __oclEnqueueMapBuffer = NULL;
+PFNCLENQUEUEMAPIMAGE __oclEnqueueMapImage = NULL;
+PFNCLENQUEUEUNMAPMEMOBJECT __oclEnqueueUnmapMemObject = NULL;
+PFNCLENQUEUENDRANGEKERNEL __oclEnqueueNDRangeKernel = NULL;
+PFNCLENQUEUETASK __oclEnqueueTask = NULL;
+PFNCLENQUEUENATIVEKERNEL __oclEnqueueNativeKernel = NULL;
+PFNCLENQUEUEMARKER __oclEnqueueMarker = NULL;
+PFNCLENQUEUEWAITFOREVENTS __oclEnqueueWaitForEvents = NULL;
+PFNCLENQUEUEBARRIER __oclEnqueueBarrier = NULL;
+PFNCLGETEXTENSIONFUNCTIONADDRESS __oclGetExtensionFunctionAddress = NULL;
+#endif // CLCC_GENERATE_DOCUMENTATION
+
+
+//! \brief Unloads OpenCL dynamic library, should not be called directly
+static void clewExit(void)
+{
+ if (module != NULL)
+ {
+ // Ignore errors
+ CLCC_DYNLIB_CLOSE(module);
+ module = NULL;
+ }
+}
+
+//! \param path path to dynamic library to load
+//! \return CLEW_ERROR_OPEN_FAILED if the library could not be opened
+//! CLEW_ERROR_ATEXIT_FAILED if atexit(clewExit) failed
+//! CLEW_SUCCESS when the library was succesfully loaded
+int clewInit(const char* path)
+{
+ int error = 0;
+
+ // Check if already initialized
+ if (module != NULL)
+ {
+ return CLEW_SUCCESS;
+ }
+
+ // Load library
+ module = CLCC_DYNLIB_OPEN(path);
+
+ // Check for errors
+ if (module == NULL)
+ {
+ return CLEW_ERROR_OPEN_FAILED;
+ }
+
+ // Set unloading
+ error = atexit(clewExit);
+
+ if (error)
+ {
+ // Failure queing atexit, shutdown with error
+ CLCC_DYNLIB_CLOSE(module);
+ module = NULL;
+
+ return CLEW_ERROR_ATEXIT_FAILED;
+ }
+
+ // Determine function entry-points
+ __oclGetPlatformIDs = (PFNCLGETPLATFORMIDS )CLCC_DYNLIB_IMPORT(module, "clGetPlatformIDs");
+ __oclGetPlatformInfo = (PFNCLGETPLATFORMINFO )CLCC_DYNLIB_IMPORT(module, "clGetPlatformInfo");
+ __oclGetDeviceIDs = (PFNCLGETDEVICEIDS )CLCC_DYNLIB_IMPORT(module, "clGetDeviceIDs");
+ __oclGetDeviceInfo = (PFNCLGETDEVICEINFO )CLCC_DYNLIB_IMPORT(module, "clGetDeviceInfo");
+ __oclCreateContext = (PFNCLCREATECONTEXT )CLCC_DYNLIB_IMPORT(module, "clCreateContext");
+ __oclCreateContextFromType = (PFNCLCREATECONTEXTFROMTYPE )CLCC_DYNLIB_IMPORT(module, "clCreateContextFromType");
+ __oclRetainContext = (PFNCLRETAINCONTEXT )CLCC_DYNLIB_IMPORT(module, "clRetainContext");
+ __oclReleaseContext = (PFNCLRELEASECONTEXT )CLCC_DYNLIB_IMPORT(module, "clReleaseContext");
+ __oclGetContextInfo = (PFNCLGETCONTEXTINFO )CLCC_DYNLIB_IMPORT(module, "clGetContextInfo");
+ __oclCreateCommandQueue = (PFNCLCREATECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clCreateCommandQueue");
+ __oclRetainCommandQueue = (PFNCLRETAINCOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clRetainCommandQueue");
+ __oclReleaseCommandQueue = (PFNCLRELEASECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clReleaseCommandQueue");
+ __oclGetCommandQueueInfo = (PFNCLGETCOMMANDQUEUEINFO )CLCC_DYNLIB_IMPORT(module, "clGetCommandQueueInfo");
+ __oclSetCommandQueueProperty = (PFNCLSETCOMMANDQUEUEPROPERTY )CLCC_DYNLIB_IMPORT(module, "clSetCommandQueueProperty");
+ __oclCreateBuffer = (PFNCLCREATEBUFFER )CLCC_DYNLIB_IMPORT(module, "clCreateBuffer");
+ __oclCreateImage2D = (PFNCLCREATEIMAGE2D )CLCC_DYNLIB_IMPORT(module, "clCreateImage2D");
+ __oclCreateImage3D = (PFNCLCREATEIMAGE3D )CLCC_DYNLIB_IMPORT(module, "clCreateImage3D");
+ __oclRetainMemObject = (PFNCLRETAINMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clRetainMemObject");
+ __oclReleaseMemObject = (PFNCLRELEASEMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clReleaseMemObject");
+ __oclGetSupportedImageFormats = (PFNCLGETSUPPORTEDIMAGEFORMATS )CLCC_DYNLIB_IMPORT(module, "clGetSupportedImageFormats");
+ __oclGetMemObjectInfo = (PFNCLGETMEMOBJECTINFO )CLCC_DYNLIB_IMPORT(module, "clGetMemObjectInfo");
+ __oclGetImageInfo = (PFNCLGETIMAGEINFO )CLCC_DYNLIB_IMPORT(module, "clGetImageInfo");
+ __oclCreateSampler = (PFNCLCREATESAMPLER )CLCC_DYNLIB_IMPORT(module, "clCreateSampler");
+ __oclRetainSampler = (PFNCLRETAINSAMPLER )CLCC_DYNLIB_IMPORT(module, "clRetainSampler");
+ __oclReleaseSampler = (PFNCLRELEASESAMPLER )CLCC_DYNLIB_IMPORT(module, "clReleaseSampler");
+ __oclGetSamplerInfo = (PFNCLGETSAMPLERINFO )CLCC_DYNLIB_IMPORT(module, "clGetSamplerInfo");
+ __oclCreateProgramWithSource = (PFNCLCREATEPROGRAMWITHSOURCE )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithSource");
+ __oclCreateProgramWithBinary = (PFNCLCREATEPROGRAMWITHBINARY )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithBinary");
+ __oclRetainProgram = (PFNCLRETAINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clRetainProgram");
+ __oclReleaseProgram = (PFNCLRELEASEPROGRAM )CLCC_DYNLIB_IMPORT(module, "clReleaseProgram");
+ __oclBuildProgram = (PFNCLBUILDPROGRAM )CLCC_DYNLIB_IMPORT(module, "clBuildProgram");
+ __oclUnloadCompiler = (PFNCLUNLOADCOMPILER )CLCC_DYNLIB_IMPORT(module, "clUnloadCompiler");
+ __oclGetProgramInfo = (PFNCLGETPROGRAMINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramInfo");
+ __oclGetProgramBuildInfo = (PFNCLGETPROGRAMBUILDINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramBuildInfo");
+ __oclCreateKernel = (PFNCLCREATEKERNEL )CLCC_DYNLIB_IMPORT(module, "clCreateKernel");
+ __oclCreateKernelsInProgram = (PFNCLCREATEKERNELSINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clCreateKernelsInProgram");
+ __oclRetainKernel = (PFNCLRETAINKERNEL )CLCC_DYNLIB_IMPORT(module, "clRetainKernel");
+ __oclReleaseKernel = (PFNCLRELEASEKERNEL )CLCC_DYNLIB_IMPORT(module, "clReleaseKernel");
+ __oclSetKernelArg = (PFNCLSETKERNELARG )CLCC_DYNLIB_IMPORT(module, "clSetKernelArg");
+ __oclGetKernelInfo = (PFNCLGETKERNELINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelInfo");
+ __oclGetKernelWorkGroupInfo = (PFNCLGETKERNELWORKGROUPINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelWorkGroupInfo");
+ __oclWaitForEvents = (PFNCLWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clWaitForEvents");
+ __oclGetEventInfo = (PFNCLGETEVENTINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventInfo");
+ __oclRetainEvent = (PFNCLRETAINEVENT )CLCC_DYNLIB_IMPORT(module, "clRetainEvent");
+ __oclReleaseEvent = (PFNCLRELEASEEVENT )CLCC_DYNLIB_IMPORT(module, "clReleaseEvent");
+ __oclGetEventProfilingInfo = (PFNCLGETEVENTPROFILINGINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventProfilingInfo");
+ __oclFlush = (PFNCLFLUSH )CLCC_DYNLIB_IMPORT(module, "clFlush");
+ __oclFinish = (PFNCLFINISH )CLCC_DYNLIB_IMPORT(module, "clFinish");
+ __oclEnqueueReadBuffer = (PFNCLENQUEUEREADBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadBuffer");
+ __oclEnqueueWriteBuffer = (PFNCLENQUEUEWRITEBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteBuffer");
+ __oclEnqueueCopyBuffer = (PFNCLENQUEUECOPYBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBuffer");
+ __oclEnqueueReadImage = (PFNCLENQUEUEREADIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadImage");
+ __oclEnqueueWriteImage = (PFNCLENQUEUEWRITEIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteImage");
+ __oclEnqueueCopyImage = (PFNCLENQUEUECOPYIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImage");
+ __oclEnqueueCopyImageToBuffer = (PFNCLENQUEUECOPYIMAGETOBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImageToBuffer");
+ __oclEnqueueCopyBufferToImage = (PFNCLENQUEUECOPYBUFFERTOIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBufferToImage");
+ __oclEnqueueMapBuffer = (PFNCLENQUEUEMAPBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapBuffer");
+ __oclEnqueueMapImage = (PFNCLENQUEUEMAPIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapImage");
+ __oclEnqueueUnmapMemObject = (PFNCLENQUEUEUNMAPMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clEnqueueUnmapMemObject");
+ __oclEnqueueNDRangeKernel = (PFNCLENQUEUENDRANGEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNDRangeKernel");
+ __oclEnqueueTask = (PFNCLENQUEUETASK )CLCC_DYNLIB_IMPORT(module, "clEnqueueTask");
+ __oclEnqueueNativeKernel = (PFNCLENQUEUENATIVEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNativeKernel");
+ __oclEnqueueMarker = (PFNCLENQUEUEMARKER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMarker");
+ __oclEnqueueWaitForEvents = (PFNCLENQUEUEWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents");
+ __oclEnqueueBarrier = (PFNCLENQUEUEBARRIER )CLCC_DYNLIB_IMPORT(module, "clEnqueueBarrier");
+ __oclGetExtensionFunctionAddress = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLCC_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress");
+
+ return CLEW_SUCCESS;
+}
+
+//! \param error CL error code
+//! \return a string representation of the error code
+const char* clewErrorString(cl_int error)
+{
+ static const char* strings[] =
+ {
+ // Error Codes
+ "CL_SUCCESS" // 0
+ , "CL_DEVICE_NOT_FOUND" // -1
+ , "CL_DEVICE_NOT_AVAILABLE" // -2
+ , "CL_COMPILER_NOT_AVAILABLE" // -3
+ , "CL_MEM_OBJECT_ALLOCATION_FAILURE" // -4
+ , "CL_OUT_OF_RESOURCES" // -5
+ , "CL_OUT_OF_HOST_MEMORY" // -6
+ , "CL_PROFILING_INFO_NOT_AVAILABLE" // -7
+ , "CL_MEM_COPY_OVERLAP" // -8
+ , "CL_IMAGE_FORMAT_MISMATCH" // -9
+ , "CL_IMAGE_FORMAT_NOT_SUPPORTED" // -10
+ , "CL_BUILD_PROGRAM_FAILURE" // -11
+ , "CL_MAP_FAILURE" // -12
+
+ , "" // -13
+ , "" // -14
+ , "" // -15
+ , "" // -16
+ , "" // -17
+ , "" // -18
+ , "" // -19
+
+ , "" // -20
+ , "" // -21
+ , "" // -22
+ , "" // -23
+ , "" // -24
+ , "" // -25
+ , "" // -26
+ , "" // -27
+ , "" // -28
+ , "" // -29
+
+ , "CL_INVALID_VALUE" // -30
+ , "CL_INVALID_DEVICE_TYPE" // -31
+ , "CL_INVALID_PLATFORM" // -32
+ , "CL_INVALID_DEVICE" // -33
+ , "CL_INVALID_CONTEXT" // -34
+ , "CL_INVALID_QUEUE_PROPERTIES" // -35
+ , "CL_INVALID_COMMAND_QUEUE" // -36
+ , "CL_INVALID_HOST_PTR" // -37
+ , "CL_INVALID_MEM_OBJECT" // -38
+ , "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" // -39
+ , "CL_INVALID_IMAGE_SIZE" // -40
+ , "CL_INVALID_SAMPLER" // -41
+ , "CL_INVALID_BINARY" // -42
+ , "CL_INVALID_BUILD_OPTIONS" // -43
+ , "CL_INVALID_PROGRAM" // -44
+ , "CL_INVALID_PROGRAM_EXECUTABLE" // -45
+ , "CL_INVALID_KERNEL_NAME" // -46
+ , "CL_INVALID_KERNEL_DEFINITION" // -47
+ , "CL_INVALID_KERNEL" // -48
+ , "CL_INVALID_ARG_INDEX" // -49
+ , "CL_INVALID_ARG_VALUE" // -50
+ , "CL_INVALID_ARG_SIZE" // -51
+ , "CL_INVALID_KERNEL_ARGS" // -52
+ , "CL_INVALID_WORK_DIMENSION" // -53
+ , "CL_INVALID_WORK_GROUP_SIZE" // -54
+ , "CL_INVALID_WORK_ITEM_SIZE" // -55
+ , "CL_INVALID_GLOBAL_OFFSET" // -56
+ , "CL_INVALID_EVENT_WAIT_LIST" // -57
+ , "CL_INVALID_EVENT" // -58
+ , "CL_INVALID_OPERATION" // -59
+ , "CL_INVALID_GL_OBJECT" // -60
+ , "CL_INVALID_BUFFER_SIZE" // -61
+ , "CL_INVALID_MIP_LEVEL" // -62
+ , "CL_INVALID_GLOBAL_WORK_SIZE" // -63
+ };
+
+ return strings[-error];
+}
diff --git a/source/blender/opencl/intern/clew.h b/source/blender/opencl/intern/clew.h
new file mode 100644
index 00000000000..bb7e0134dcf
--- /dev/null
+++ b/source/blender/opencl/intern/clew.h
@@ -0,0 +1,1317 @@
+#ifndef CLCC_CLEW_HPP_INCLUDED
+#define CLCC_CLEW_HPP_INCLUDED
+
+//////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2009 Organic Vectory B.V.
+// Written by George van Venrooij
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file license.txt)
+//////////////////////////////////////////////////////////////////////////
+
+//! \file clew.h
+//! \brief OpenCL run-time loader header
+//!
+//! This file contains a copy of the contents of CL.H and CL_PLATFORM.H from the
+//! official OpenCL spec. The purpose of this code is to load the OpenCL dynamic
+//! library at run-time and thus allow the executable to function on many
+//! platforms regardless of the vendor of the OpenCL driver actually installed.
+//! Some of the techniques used here were inspired by work done in the GLEW
+//! library (http://glew.sourceforge.net/)
+
+// Run-time dynamic linking functionality based on concepts used in GLEW
+#ifdef __OPENCL_CL_H
+#error cl.h included before clew.h
+#endif
+
+#ifdef __OPENCL_CL_PLATFORM_H
+#error cl_platform.h included before clew.h
+#endif
+
+#ifndef CLCC_GENERATE_DOCUMENTATION
+// Prevent cl.h inclusion
+#define __OPENCL_CL_H
+// Prevent cl_platform.h inclusion
+#define __CL_PLATFORM_H
+#endif // CLCC_GENERATE_DOCUMENTATION
+
+/*******************************************************************************
+* Copyright (c) 2008-2009 The Khronos Group Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+******************************************************************************/
+#ifdef __APPLE__
+/* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
+#include <AvailabilityMacros.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CLCC_GENERATE_DOCUMENTATION
+
+#if defined(_WIN32)
+#define CL_API_ENTRY
+#define CL_API_CALL __stdcall
+#else
+#define CL_API_ENTRY
+#define CL_API_CALL
+#endif
+
+#if defined(__APPLE__)
+//JBKK removed for compatibility with blender trunk #define CL_API_SUFFIX__VERSION_1_0 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+#define CL_API_SUFFIX__VERSION_1_0
+#define CL_EXTENSION_WEAK_LINK __attribute__((weak_import))
+#else
+#define CL_API_SUFFIX__VERSION_1_0
+#define CL_EXTENSION_WEAK_LINK
+#endif
+
+#if defined(_WIN32) && defined(_MSC_VER)
+
+/* scalar types */
+typedef signed __int8 cl_char;
+typedef unsigned __int8 cl_uchar;
+typedef signed __int16 cl_short;
+typedef unsigned __int16 cl_ushort;
+typedef signed __int32 cl_int;
+typedef unsigned __int32 cl_uint;
+typedef signed __int64 cl_long;
+typedef unsigned __int64 cl_ulong;
+
+typedef unsigned __int16 cl_half;
+typedef float cl_float;
+typedef double cl_double;
+
+
+/*
+* Vector types
+*
+* Note: OpenCL requires that all types be naturally aligned.
+* This means that vector types must be naturally aligned.
+* For example, a vector of four floats must be aligned to
+* a 16 byte boundary (calculated as 4 * the natural 4-byte
+* alignment of the float). The alignment qualifiers here
+* will only function properly if your compiler supports them
+* and if you don't actively work to defeat them. For example,
+* in order for a cl_float4 to be 16 byte aligned in a struct,
+* the start of the struct must itself be 16-byte aligned.
+*
+* Maintaining proper alignment is the user's responsibility.
+*/
+typedef signed __int8 cl_char2[2];
+typedef signed __int8 cl_char4[4];
+typedef signed __int8 cl_char8[8];
+typedef signed __int8 cl_char16[16];
+typedef unsigned __int8 cl_uchar2[2];
+typedef unsigned __int8 cl_uchar4[4];
+typedef unsigned __int8 cl_uchar8[8];
+typedef unsigned __int8 cl_uchar16[16];
+
+typedef signed __int16 cl_short2[2];
+typedef signed __int16 cl_short4[4];
+typedef signed __int16 cl_short8[8];
+typedef signed __int16 cl_short16[16];
+typedef unsigned __int16 cl_ushort2[2];
+typedef unsigned __int16 cl_ushort4[4];
+typedef unsigned __int16 cl_ushort8[8];
+typedef unsigned __int16 cl_ushort16[16];
+
+typedef signed __int32 cl_int2[2];
+typedef signed __int32 cl_int4[4];
+typedef signed __int32 cl_int8[8];
+typedef signed __int32 cl_int16[16];
+typedef unsigned __int32 cl_uint2[2];
+typedef unsigned __int32 cl_uint4[4];
+typedef unsigned __int32 cl_uint8[8];
+typedef unsigned __int32 cl_uint16[16];
+
+typedef signed __int64 cl_long2[2];
+typedef signed __int64 cl_long4[4];
+typedef signed __int64 cl_long8[8];
+typedef signed __int64 cl_long16[16];
+typedef unsigned __int64 cl_ulong2[2];
+typedef unsigned __int64 cl_ulong4[4];
+typedef unsigned __int64 cl_ulong8[8];
+typedef unsigned __int64 cl_ulong16[16];
+
+typedef float cl_float2[2];
+typedef float cl_float4[4];
+typedef float cl_float8[8];
+typedef float cl_float16[16];
+
+typedef double cl_double2[2];
+typedef double cl_double4[4];
+typedef double cl_double8[8];
+typedef double cl_double16[16];
+/* There are no vector types for half */
+
+#else
+
+#include <stdint.h>
+
+/* scalar types */
+typedef int8_t cl_char;
+typedef uint8_t cl_uchar;
+typedef int16_t cl_short __attribute__((aligned(2)));
+typedef uint16_t cl_ushort __attribute__((aligned(2)));
+typedef int32_t cl_int __attribute__((aligned(4)));
+typedef uint32_t cl_uint __attribute__((aligned(4)));
+typedef int64_t cl_long __attribute__((aligned(8)));
+typedef uint64_t cl_ulong __attribute__((aligned(8)));
+
+typedef uint16_t cl_half __attribute__((aligned(2)));
+typedef float cl_float __attribute__((aligned(4)));
+typedef double cl_double __attribute__((aligned(8)));
+
+/*
+* Vector types
+*
+* Note: OpenCL requires that all types be naturally aligned.
+* This means that vector types must be naturally aligned.
+* For example, a vector of four floats must be aligned to
+* a 16 byte boundary (calculated as 4 * the natural 4-byte
+* alignment of the float). The alignment qualifiers here
+* will only function properly if your compiler supports them
+* and if you don't actively work to defeat them. For example,
+* in order for a cl_float4 to be 16 byte aligned in a struct,
+* the start of the struct must itself be 16-byte aligned.
+*
+* Maintaining proper alignment is the user's responsibility.
+*/
+typedef int8_t cl_char2[2] __attribute__((aligned(2)));
+typedef int8_t cl_char4[4] __attribute__((aligned(4)));
+typedef int8_t cl_char8[8] __attribute__((aligned(8)));
+typedef int8_t cl_char16[16] __attribute__((aligned(16)));
+typedef uint8_t cl_uchar2[2] __attribute__((aligned(2)));
+typedef uint8_t cl_uchar4[4] __attribute__((aligned(4)));
+typedef uint8_t cl_uchar8[8] __attribute__((aligned(8)));
+typedef uint8_t cl_uchar16[16] __attribute__((aligned(16)));
+
+typedef int16_t cl_short2[2] __attribute__((aligned(4)));
+typedef int16_t cl_short4[4] __attribute__((aligned(8)));
+typedef int16_t cl_short8[8] __attribute__((aligned(16)));
+typedef int16_t cl_short16[16] __attribute__((aligned(32)));
+typedef uint16_t cl_ushort2[2] __attribute__((aligned(4)));
+typedef uint16_t cl_ushort4[4] __attribute__((aligned(8)));
+typedef uint16_t cl_ushort8[8] __attribute__((aligned(16)));
+typedef uint16_t cl_ushort16[16] __attribute__((aligned(32)));
+
+typedef int32_t cl_int2[2] __attribute__((aligned(8)));
+typedef int32_t cl_int4[4] __attribute__((aligned(16)));
+typedef int32_t cl_int8[8] __attribute__((aligned(32)));
+typedef int32_t cl_int16[16] __attribute__((aligned(64)));
+typedef uint32_t cl_uint2[2] __attribute__((aligned(8)));
+typedef uint32_t cl_uint4[4] __attribute__((aligned(16)));
+typedef uint32_t cl_uint8[8] __attribute__((aligned(32)));
+typedef uint32_t cl_uint16[16] __attribute__((aligned(64)));
+
+typedef int64_t cl_long2[2] __attribute__((aligned(16)));
+typedef int64_t cl_long4[4] __attribute__((aligned(32)));
+typedef int64_t cl_long8[8] __attribute__((aligned(64)));
+typedef int64_t cl_long16[16] __attribute__((aligned(128)));
+typedef uint64_t cl_ulong2[2] __attribute__((aligned(16)));
+typedef uint64_t cl_ulong4[4] __attribute__((aligned(32)));
+typedef uint64_t cl_ulong8[8] __attribute__((aligned(64)));
+typedef uint64_t cl_ulong16[16] __attribute__((aligned(128)));
+
+typedef float cl_float2[2] __attribute__((aligned(8)));
+typedef float cl_float4[4] __attribute__((aligned(16)));
+typedef float cl_float8[8] __attribute__((aligned(32)));
+typedef float cl_float16[16] __attribute__((aligned(64)));
+
+typedef double cl_double2[2] __attribute__((aligned(16)));
+typedef double cl_double4[4] __attribute__((aligned(32)));
+typedef double cl_double8[8] __attribute__((aligned(64)));
+typedef double cl_double16[16] __attribute__((aligned(128)));
+
+/* There are no vector types for half */
+
+#endif
+
+/******************************************************************************/
+
+// Macro names and corresponding values defined by OpenCL
+
+#define CL_CHAR_BIT 8
+#define CL_SCHAR_MAX 127
+#define CL_SCHAR_MIN (-127-1)
+#define CL_CHAR_MAX CL_SCHAR_MAX
+#define CL_CHAR_MIN CL_SCHAR_MIN
+#define CL_UCHAR_MAX 255
+#define CL_SHRT_MAX 32767
+#define CL_SHRT_MIN (-32767-1)
+#define CL_USHRT_MAX 65535
+#define CL_INT_MAX 2147483647
+#define CL_INT_MIN (-2147483647-1)
+#define CL_UINT_MAX 0xffffffffU
+#define CL_LONG_MAX ((cl_long) 0x7FFFFFFFFFFFFFFFLL)
+#define CL_LONG_MIN ((cl_long) -0x7FFFFFFFFFFFFFFFLL - 1LL)
+#define CL_ULONG_MAX ((cl_ulong) 0xFFFFFFFFFFFFFFFFULL)
+
+#define CL_FLT_DIG 6
+#define CL_FLT_MANT_DIG 24
+#define CL_FLT_MAX_10_EXP +38
+#define CL_FLT_MAX_EXP +128
+#define CL_FLT_MIN_10_EXP -37
+#define CL_FLT_MIN_EXP -125
+#define CL_FLT_RADIX 2
+#if defined(_MSC_VER)
+// MSVC doesn't understand hex floats
+#define CL_FLT_MAX 3.402823466e+38F
+#define CL_FLT_MIN 1.175494351e-38F
+#define CL_FLT_EPSILON 1.192092896e-07F
+#else
+#define CL_FLT_MAX 0x1.fffffep127f
+#define CL_FLT_MIN 0x1.0p-126f
+#define CL_FLT_EPSILON 0x1.0p-23f
+#endif
+
+#define CL_DBL_DIG 15
+#define CL_DBL_MANT_DIG 53
+#define CL_DBL_MAX_10_EXP +308
+#define CL_DBL_MAX_EXP +1024
+#define CL_DBL_MIN_10_EXP -307
+#define CL_DBL_MIN_EXP -1021
+#define CL_DBL_RADIX 2
+#if defined(_MSC_VER)
+// MSVC doesn't understand hex floats
+#define CL_DBL_MAX 1.7976931348623158e+308
+#define CL_DBL_MIN 2.2250738585072014e-308
+#define CL_DBL_EPSILON 2.2204460492503131e-016
+#else
+#define CL_DBL_MAX 0x1.fffffffffffffp1023
+#define CL_DBL_MIN 0x1.0p-1022
+#define CL_DBL_EPSILON 0x1.0p-52
+#endif
+
+#include <stddef.h>
+
+
+// CL.h contents
+/******************************************************************************/
+
+typedef struct _cl_platform_id * cl_platform_id;
+typedef struct _cl_device_id * cl_device_id;
+typedef struct _cl_context * cl_context;
+typedef struct _cl_command_queue * cl_command_queue;
+typedef struct _cl_mem * cl_mem;
+typedef struct _cl_program * cl_program;
+typedef struct _cl_kernel * cl_kernel;
+typedef struct _cl_event * cl_event;
+typedef struct _cl_sampler * cl_sampler;
+
+typedef cl_uint cl_bool; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
+typedef cl_ulong cl_bitfield;
+typedef cl_bitfield cl_device_type;
+typedef cl_uint cl_platform_info;
+typedef cl_uint cl_device_info;
+typedef cl_bitfield cl_device_address_info;
+typedef cl_bitfield cl_device_fp_config;
+typedef cl_uint cl_device_mem_cache_type;
+typedef cl_uint cl_device_local_mem_type;
+typedef cl_bitfield cl_device_exec_capabilities;
+typedef cl_bitfield cl_command_queue_properties;
+
+typedef intptr_t cl_context_properties;
+typedef cl_uint cl_context_info;
+typedef cl_uint cl_command_queue_info;
+typedef cl_uint cl_channel_order;
+typedef cl_uint cl_channel_type;
+typedef cl_bitfield cl_mem_flags;
+typedef cl_uint cl_mem_object_type;
+typedef cl_uint cl_mem_info;
+typedef cl_uint cl_image_info;
+typedef cl_uint cl_addressing_mode;
+typedef cl_uint cl_filter_mode;
+typedef cl_uint cl_sampler_info;
+typedef cl_bitfield cl_map_flags;
+typedef cl_uint cl_program_info;
+typedef cl_uint cl_program_build_info;
+typedef cl_int cl_build_status;
+typedef cl_uint cl_kernel_info;
+typedef cl_uint cl_kernel_work_group_info;
+typedef cl_uint cl_event_info;
+typedef cl_uint cl_command_type;
+typedef cl_uint cl_profiling_info;
+
+typedef struct _cl_image_format {
+ cl_channel_order image_channel_order;
+ cl_channel_type image_channel_data_type;
+} cl_image_format;
+
+
+
+/******************************************************************************/
+
+// Error Codes
+#define CL_SUCCESS 0
+#define CL_DEVICE_NOT_FOUND -1
+#define CL_DEVICE_NOT_AVAILABLE -2
+#define CL_COMPILER_NOT_AVAILABLE -3
+#define CL_MEM_OBJECT_ALLOCATION_FAILURE -4
+#define CL_OUT_OF_RESOURCES -5
+#define CL_OUT_OF_HOST_MEMORY -6
+#define CL_PROFILING_INFO_NOT_AVAILABLE -7
+#define CL_MEM_COPY_OVERLAP -8
+#define CL_IMAGE_FORMAT_MISMATCH -9
+#define CL_IMAGE_FORMAT_NOT_SUPPORTED -10
+#define CL_BUILD_PROGRAM_FAILURE -11
+#define CL_MAP_FAILURE -12
+
+#define CL_INVALID_VALUE -30
+#define CL_INVALID_DEVICE_TYPE -31
+#define CL_INVALID_PLATFORM -32
+#define CL_INVALID_DEVICE -33
+#define CL_INVALID_CONTEXT -34
+#define CL_INVALID_QUEUE_PROPERTIES -35
+#define CL_INVALID_COMMAND_QUEUE -36
+#define CL_INVALID_HOST_PTR -37
+#define CL_INVALID_MEM_OBJECT -38
+#define CL_INVALID_IMAGE_FORMAT_DESCRIPTOR -39
+#define CL_INVALID_IMAGE_SIZE -40
+#define CL_INVALID_SAMPLER -41
+#define CL_INVALID_BINARY -42
+#define CL_INVALID_BUILD_OPTIONS -43
+#define CL_INVALID_PROGRAM -44
+#define CL_INVALID_PROGRAM_EXECUTABLE -45
+#define CL_INVALID_KERNEL_NAME -46
+#define CL_INVALID_KERNEL_DEFINITION -47
+#define CL_INVALID_KERNEL -48
+#define CL_INVALID_ARG_INDEX -49
+#define CL_INVALID_ARG_VALUE -50
+#define CL_INVALID_ARG_SIZE -51
+#define CL_INVALID_KERNEL_ARGS -52
+#define CL_INVALID_WORK_DIMENSION -53
+#define CL_INVALID_WORK_GROUP_SIZE -54
+#define CL_INVALID_WORK_ITEM_SIZE -55
+#define CL_INVALID_GLOBAL_OFFSET -56
+#define CL_INVALID_EVENT_WAIT_LIST -57
+#define CL_INVALID_EVENT -58
+#define CL_INVALID_OPERATION -59
+#define CL_INVALID_GL_OBJECT -60
+#define CL_INVALID_BUFFER_SIZE -61
+#define CL_INVALID_MIP_LEVEL -62
+#define CL_INVALID_GLOBAL_WORK_SIZE -63
+
+// OpenCL Version
+#define CL_VERSION_1_0 1
+
+// cl_bool
+#define CL_FALSE 0
+#define CL_TRUE 1
+
+// cl_platform_info
+#define CL_PLATFORM_PROFILE 0x0900
+#define CL_PLATFORM_VERSION 0x0901
+#define CL_PLATFORM_NAME 0x0902
+#define CL_PLATFORM_VENDOR 0x0903
+#define CL_PLATFORM_EXTENSIONS 0x0904
+
+// cl_device_type - bitfield
+#define CL_DEVICE_TYPE_DEFAULT (1 << 0)
+#define CL_DEVICE_TYPE_CPU (1 << 1)
+#define CL_DEVICE_TYPE_GPU (1 << 2)
+#define CL_DEVICE_TYPE_ACCELERATOR (1 << 3)
+#define CL_DEVICE_TYPE_ALL 0xFFFFFFFF
+
+// cl_device_info
+#define CL_DEVICE_TYPE 0x1000
+#define CL_DEVICE_VENDOR_ID 0x1001
+#define CL_DEVICE_MAX_COMPUTE_UNITS 0x1002
+#define CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS 0x1003
+#define CL_DEVICE_MAX_WORK_GROUP_SIZE 0x1004
+#define CL_DEVICE_MAX_WORK_ITEM_SIZES 0x1005
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR 0x1006
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT 0x1007
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT 0x1008
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG 0x1009
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT 0x100A
+#define CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE 0x100B
+#define CL_DEVICE_MAX_CLOCK_FREQUENCY 0x100C
+#define CL_DEVICE_ADDRESS_BITS 0x100D
+#define CL_DEVICE_MAX_READ_IMAGE_ARGS 0x100E
+#define CL_DEVICE_MAX_WRITE_IMAGE_ARGS 0x100F
+#define CL_DEVICE_MAX_MEM_ALLOC_SIZE 0x1010
+#define CL_DEVICE_IMAGE2D_MAX_WIDTH 0x1011
+#define CL_DEVICE_IMAGE2D_MAX_HEIGHT 0x1012
+#define CL_DEVICE_IMAGE3D_MAX_WIDTH 0x1013
+#define CL_DEVICE_IMAGE3D_MAX_HEIGHT 0x1014
+#define CL_DEVICE_IMAGE3D_MAX_DEPTH 0x1015
+#define CL_DEVICE_IMAGE_SUPPORT 0x1016
+#define CL_DEVICE_MAX_PARAMETER_SIZE 0x1017
+#define CL_DEVICE_MAX_SAMPLERS 0x1018
+#define CL_DEVICE_MEM_BASE_ADDR_ALIGN 0x1019
+#define CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE 0x101A
+#define CL_DEVICE_SINGLE_FP_CONFIG 0x101B
+#define CL_DEVICE_GLOBAL_MEM_CACHE_TYPE 0x101C
+#define CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE 0x101D
+#define CL_DEVICE_GLOBAL_MEM_CACHE_SIZE 0x101E
+#define CL_DEVICE_GLOBAL_MEM_SIZE 0x101F
+#define CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE 0x1020
+#define CL_DEVICE_MAX_CONSTANT_ARGS 0x1021
+#define CL_DEVICE_LOCAL_MEM_TYPE 0x1022
+#define CL_DEVICE_LOCAL_MEM_SIZE 0x1023
+#define CL_DEVICE_ERROR_CORRECTION_SUPPORT 0x1024
+#define CL_DEVICE_PROFILING_TIMER_RESOLUTION 0x1025
+#define CL_DEVICE_ENDIAN_LITTLE 0x1026
+#define CL_DEVICE_AVAILABLE 0x1027
+#define CL_DEVICE_COMPILER_AVAILABLE 0x1028
+#define CL_DEVICE_EXECUTION_CAPABILITIES 0x1029
+#define CL_DEVICE_QUEUE_PROPERTIES 0x102A
+#define CL_DEVICE_NAME 0x102B
+#define CL_DEVICE_VENDOR 0x102C
+#define CL_DRIVER_VERSION 0x102D
+#define CL_DEVICE_PROFILE 0x102E
+#define CL_DEVICE_VERSION 0x102F
+#define CL_DEVICE_EXTENSIONS 0x1030
+#define CL_DEVICE_PLATFORM 0x1031
+
+// cl_device_fp_config - bitfield
+#define CL_FP_DENORM (1 << 0)
+#define CL_FP_INF_NAN (1 << 1)
+#define CL_FP_ROUND_TO_NEAREST (1 << 2)
+#define CL_FP_ROUND_TO_ZERO (1 << 3)
+#define CL_FP_ROUND_TO_INF (1 << 4)
+#define CL_FP_FMA (1 << 5)
+
+// cl_device_mem_cache_type
+#define CL_NONE 0x0
+#define CL_READ_ONLY_CACHE 0x1
+#define CL_READ_WRITE_CACHE 0x2
+
+// cl_device_local_mem_type
+#define CL_LOCAL 0x1
+#define CL_GLOBAL 0x2
+
+// cl_device_exec_capabilities - bitfield
+#define CL_EXEC_KERNEL (1 << 0)
+#define CL_EXEC_NATIVE_KERNEL (1 << 1)
+
+// cl_command_queue_properties - bitfield
+#define CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE (1 << 0)
+#define CL_QUEUE_PROFILING_ENABLE (1 << 1)
+
+// cl_context_info
+#define CL_CONTEXT_REFERENCE_COUNT 0x1080
+#define CL_CONTEXT_DEVICES 0x1081
+#define CL_CONTEXT_PROPERTIES 0x1082
+
+// cl_context_properties
+#define CL_CONTEXT_PLATFORM 0x1084
+
+// cl_command_queue_info
+#define CL_QUEUE_CONTEXT 0x1090
+#define CL_QUEUE_DEVICE 0x1091
+#define CL_QUEUE_REFERENCE_COUNT 0x1092
+#define CL_QUEUE_PROPERTIES 0x1093
+
+// cl_mem_flags - bitfield
+#define CL_MEM_READ_WRITE (1 << 0)
+#define CL_MEM_WRITE_ONLY (1 << 1)
+#define CL_MEM_READ_ONLY (1 << 2)
+#define CL_MEM_USE_HOST_PTR (1 << 3)
+#define CL_MEM_ALLOC_HOST_PTR (1 << 4)
+#define CL_MEM_COPY_HOST_PTR (1 << 5)
+
+// cl_channel_order
+#define CL_R 0x10B0
+#define CL_A 0x10B1
+#define CL_RG 0x10B2
+#define CL_RA 0x10B3
+#define CL_RGB 0x10B4
+#define CL_RGBA 0x10B5
+#define CL_BGRA 0x10B6
+#define CL_ARGB 0x10B7
+#define CL_INTENSITY 0x10B8
+#define CL_LUMINANCE 0x10B9
+
+// cl_channel_type
+#define CL_SNORM_INT8 0x10D0
+#define CL_SNORM_INT16 0x10D1
+#define CL_UNORM_INT8 0x10D2
+#define CL_UNORM_INT16 0x10D3
+#define CL_UNORM_SHORT_565 0x10D4
+#define CL_UNORM_SHORT_555 0x10D5
+#define CL_UNORM_INT_101010 0x10D6
+#define CL_SIGNED_INT8 0x10D7
+#define CL_SIGNED_INT16 0x10D8
+#define CL_SIGNED_INT32 0x10D9
+#define CL_UNSIGNED_INT8 0x10DA
+#define CL_UNSIGNED_INT16 0x10DB
+#define CL_UNSIGNED_INT32 0x10DC
+#define CL_HALF_FLOAT 0x10DD
+#define CL_FLOAT 0x10DE
+
+// cl_mem_object_type
+#define CL_MEM_OBJECT_BUFFER 0x10F0
+#define CL_MEM_OBJECT_IMAGE2D 0x10F1
+#define CL_MEM_OBJECT_IMAGE3D 0x10F2
+
+// cl_mem_info
+#define CL_MEM_TYPE 0x1100
+#define CL_MEM_FLAGS 0x1101
+#define CL_MEM_SIZE 0x1102
+#define CL_MEM_HOST_PTR 0x1103
+#define CL_MEM_MAP_COUNT 0x1104
+#define CL_MEM_REFERENCE_COUNT 0x1105
+#define CL_MEM_CONTEXT 0x1106
+
+// cl_image_info
+#define CL_IMAGE_FORMAT 0x1110
+#define CL_IMAGE_ELEMENT_SIZE 0x1111
+#define CL_IMAGE_ROW_PITCH 0x1112
+#define CL_IMAGE_SLICE_PITCH 0x1113
+#define CL_IMAGE_WIDTH 0x1114
+#define CL_IMAGE_HEIGHT 0x1115
+#define CL_IMAGE_DEPTH 0x1116
+
+// cl_addressing_mode
+#define CL_ADDRESS_NONE 0x1130
+#define CL_ADDRESS_CLAMP_TO_EDGE 0x1131
+#define CL_ADDRESS_CLAMP 0x1132
+#define CL_ADDRESS_REPEAT 0x1133
+
+// cl_filter_mode
+#define CL_FILTER_NEAREST 0x1140
+#define CL_FILTER_LINEAR 0x1141
+
+// cl_sampler_info
+#define CL_SAMPLER_REFERENCE_COUNT 0x1150
+#define CL_SAMPLER_CONTEXT 0x1151
+#define CL_SAMPLER_NORMALIZED_COORDS 0x1152
+#define CL_SAMPLER_ADDRESSING_MODE 0x1153
+#define CL_SAMPLER_FILTER_MODE 0x1154
+
+// cl_map_flags - bitfield
+#define CL_MAP_READ (1 << 0)
+#define CL_MAP_WRITE (1 << 1)
+
+// cl_program_info
+#define CL_PROGRAM_REFERENCE_COUNT 0x1160
+#define CL_PROGRAM_CONTEXT 0x1161
+#define CL_PROGRAM_NUM_DEVICES 0x1162
+#define CL_PROGRAM_DEVICES 0x1163
+#define CL_PROGRAM_SOURCE 0x1164
+#define CL_PROGRAM_BINARY_SIZES 0x1165
+#define CL_PROGRAM_BINARIES 0x1166
+
+// cl_program_build_info
+#define CL_PROGRAM_BUILD_STATUS 0x1181
+#define CL_PROGRAM_BUILD_OPTIONS 0x1182
+#define CL_PROGRAM_BUILD_LOG 0x1183
+
+// cl_build_status
+#define CL_BUILD_SUCCESS 0
+#define CL_BUILD_NONE -1
+#define CL_BUILD_ERROR -2
+#define CL_BUILD_IN_PROGRESS -3
+
+// cl_kernel_info
+#define CL_KERNEL_FUNCTION_NAME 0x1190
+#define CL_KERNEL_NUM_ARGS 0x1191
+#define CL_KERNEL_REFERENCE_COUNT 0x1192
+#define CL_KERNEL_CONTEXT 0x1193
+#define CL_KERNEL_PROGRAM 0x1194
+
+// cl_kernel_work_group_info
+#define CL_KERNEL_WORK_GROUP_SIZE 0x11B0
+#define CL_KERNEL_COMPILE_WORK_GROUP_SIZE 0x11B1
+#define CL_KERNEL_LOCAL_MEM_SIZE 0x11B2
+
+// cl_event_info
+#define CL_EVENT_COMMAND_QUEUE 0x11D0
+#define CL_EVENT_COMMAND_TYPE 0x11D1
+#define CL_EVENT_REFERENCE_COUNT 0x11D2
+#define CL_EVENT_COMMAND_EXECUTION_STATUS 0x11D3
+
+// cl_command_type
+#define CL_COMMAND_NDRANGE_KERNEL 0x11F0
+#define CL_COMMAND_TASK 0x11F1
+#define CL_COMMAND_NATIVE_KERNEL 0x11F2
+#define CL_COMMAND_READ_BUFFER 0x11F3
+#define CL_COMMAND_WRITE_BUFFER 0x11F4
+#define CL_COMMAND_COPY_BUFFER 0x11F5
+#define CL_COMMAND_READ_IMAGE 0x11F6
+#define CL_COMMAND_WRITE_IMAGE 0x11F7
+#define CL_COMMAND_COPY_IMAGE 0x11F8
+#define CL_COMMAND_COPY_IMAGE_TO_BUFFER 0x11F9
+#define CL_COMMAND_COPY_BUFFER_TO_IMAGE 0x11FA
+#define CL_COMMAND_MAP_BUFFER 0x11FB
+#define CL_COMMAND_MAP_IMAGE 0x11FC
+#define CL_COMMAND_UNMAP_MEM_OBJECT 0x11FD
+#define CL_COMMAND_MARKER 0x11FE
+#define CL_COMMAND_ACQUIRE_GL_OBJECTS 0x11FF
+#define CL_COMMAND_RELEASE_GL_OBJECTS 0x1200
+
+// command execution status
+#define CL_COMPLETE 0x0
+#define CL_RUNNING 0x1
+#define CL_SUBMITTED 0x2
+#define CL_QUEUED 0x3
+
+// cl_profiling_info
+#define CL_PROFILING_COMMAND_QUEUED 0x1280
+#define CL_PROFILING_COMMAND_SUBMIT 0x1281
+#define CL_PROFILING_COMMAND_START 0x1282
+#define CL_PROFILING_COMMAND_END 0x1283
+
+/********************************************************************************************************/
+
+/********************************************************************************************************/
+
+// Function signature typedef's
+
+// Platform API
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETPLATFORMIDS)(cl_uint /* num_entries */,
+ cl_platform_id * /* platforms */,
+ cl_uint * /* num_platforms */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETPLATFORMINFO)(cl_platform_id /* platform */,
+ cl_platform_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Device APIs
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETDEVICEIDS)(cl_platform_id /* platform */,
+ cl_device_type /* device_type */,
+ cl_uint /* num_entries */,
+ cl_device_id * /* devices */,
+ cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETDEVICEINFO)(cl_device_id /* device */,
+ cl_device_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Context APIs
+typedef CL_API_ENTRY cl_context (CL_API_CALL *
+PFNCLCREATECONTEXT)(const cl_context_properties * /* properties */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* devices */,
+ void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */,
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_context (CL_API_CALL *
+PFNCLCREATECONTEXTFROMTYPE)(const cl_context_properties * /* properties */,
+ cl_device_type /* device_type */,
+ void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */,
+ void * /* user_data */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINCONTEXT)(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASECONTEXT)(cl_context /* context */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETCONTEXTINFO)(cl_context /* context */,
+ cl_context_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Command Queue APIs
+typedef CL_API_ENTRY cl_command_queue (CL_API_CALL *
+PFNCLCREATECOMMANDQUEUE)(cl_context /* context */,
+ cl_device_id /* device */,
+ cl_command_queue_properties /* properties */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINCOMMANDQUEUE)(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASECOMMANDQUEUE)(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETCOMMANDQUEUEINFO)(cl_command_queue /* command_queue */,
+ cl_command_queue_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLSETCOMMANDQUEUEPROPERTY)(cl_command_queue /* command_queue */,
+ cl_command_queue_properties /* properties */,
+ cl_bool /* enable */,
+ cl_command_queue_properties * /* old_properties */) CL_API_SUFFIX__VERSION_1_0;
+
+// Memory Object APIs
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *
+PFNCLCREATEBUFFER)(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ size_t /* size */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *
+PFNCLCREATEIMAGE2D)(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_row_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_mem (CL_API_CALL *
+PFNCLCREATEIMAGE3D)(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ const cl_image_format * /* image_format */,
+ size_t /* image_width */,
+ size_t /* image_height */,
+ size_t /* image_depth */,
+ size_t /* image_row_pitch */,
+ size_t /* image_slice_pitch */,
+ void * /* host_ptr */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINMEMOBJECT)(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASEMEMOBJECT)(cl_mem /* memobj */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETSUPPORTEDIMAGEFORMATS)(cl_context /* context */,
+ cl_mem_flags /* flags */,
+ cl_mem_object_type /* image_type */,
+ cl_uint /* num_entries */,
+ cl_image_format * /* image_formats */,
+ cl_uint * /* num_image_formats */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETMEMOBJECTINFO)(cl_mem /* memobj */,
+ cl_mem_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETIMAGEINFO)(cl_mem /* image */,
+ cl_image_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Sampler APIs
+typedef CL_API_ENTRY cl_sampler (CL_API_CALL *
+PFNCLCREATESAMPLER)(cl_context /* context */,
+ cl_bool /* normalized_coords */,
+ cl_addressing_mode /* addressing_mode */,
+ cl_filter_mode /* filter_mode */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINSAMPLER)(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASESAMPLER)(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETSAMPLERINFO)(cl_sampler /* sampler */,
+ cl_sampler_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Program Object APIs
+typedef CL_API_ENTRY cl_program (CL_API_CALL *
+PFNCLCREATEPROGRAMWITHSOURCE)(cl_context /* context */,
+ cl_uint /* count */,
+ const char ** /* strings */,
+ const size_t * /* lengths */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_program (CL_API_CALL *
+PFNCLCREATEPROGRAMWITHBINARY)(cl_context /* context */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const size_t * /* lengths */,
+ const unsigned char ** /* binaries */,
+ cl_int * /* binary_status */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINPROGRAM)(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASEPROGRAM)(cl_program /* program */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLBUILDPROGRAM)(cl_program /* program */,
+ cl_uint /* num_devices */,
+ const cl_device_id * /* device_list */,
+ const char * /* options */,
+ void (*pfn_notify)(cl_program /* program */, void * /* user_data */),
+ void * /* user_data */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLUNLOADCOMPILER)(void) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETPROGRAMINFO)(cl_program /* program */,
+ cl_program_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETPROGRAMBUILDINFO)(cl_program /* program */,
+ cl_device_id /* device */,
+ cl_program_build_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Kernel Object APIs
+typedef CL_API_ENTRY cl_kernel (CL_API_CALL *
+PFNCLCREATEKERNEL)(cl_program /* program */,
+ const char * /* kernel_name */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLCREATEKERNELSINPROGRAM)(cl_program /* program */,
+ cl_uint /* num_kernels */,
+ cl_kernel * /* kernels */,
+ cl_uint * /* num_kernels_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINKERNEL)(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASEKERNEL)(cl_kernel /* kernel */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLSETKERNELARG)(cl_kernel /* kernel */,
+ cl_uint /* arg_index */,
+ size_t /* arg_size */,
+ const void * /* arg_value */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETKERNELINFO)(cl_kernel /* kernel */,
+ cl_kernel_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETKERNELWORKGROUPINFO)(cl_kernel /* kernel */,
+ cl_device_id /* device */,
+ cl_kernel_work_group_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Event Object APIs
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLWAITFOREVENTS)(cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETEVENTINFO)(cl_event /* event */,
+ cl_event_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRETAINEVENT)(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLRELEASEEVENT)(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+// Profiling APIs
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLGETEVENTPROFILINGINFO)(cl_event /* event */,
+ cl_profiling_info /* param_name */,
+ size_t /* param_value_size */,
+ void * /* param_value */,
+ size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+// Flush and Finish APIs
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLFLUSH)(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLFINISH)(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+// Enqueued Commands APIs
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEREADBUFFER)(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_read */,
+ size_t /* offset */,
+ size_t /* cb */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEWRITEBUFFER)(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_write */,
+ size_t /* offset */,
+ size_t /* cb */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUECOPYBUFFER)(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_buffer */,
+ size_t /* src_offset */,
+ size_t /* dst_offset */,
+ size_t /* cb */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEREADIMAGE)(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_read */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* row_pitch */,
+ size_t /* slice_pitch */,
+ void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEWRITEIMAGE)(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_write */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* input_row_pitch */,
+ size_t /* input_slice_pitch */,
+ const void * /* ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUECOPYIMAGE)(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_image */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUECOPYIMAGETOBUFFER)(cl_command_queue /* command_queue */,
+ cl_mem /* src_image */,
+ cl_mem /* dst_buffer */,
+ const size_t * /* src_origin[3] */,
+ const size_t * /* region[3] */,
+ size_t /* dst_offset */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUECOPYBUFFERTOIMAGE)(cl_command_queue /* command_queue */,
+ cl_mem /* src_buffer */,
+ cl_mem /* dst_image */,
+ size_t /* src_offset */,
+ const size_t * /* dst_origin[3] */,
+ const size_t * /* region[3] */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY void * (CL_API_CALL *
+PFNCLENQUEUEMAPBUFFER)(cl_command_queue /* command_queue */,
+ cl_mem /* buffer */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ size_t /* offset */,
+ size_t /* cb */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY void * (CL_API_CALL *
+PFNCLENQUEUEMAPIMAGE)(cl_command_queue /* command_queue */,
+ cl_mem /* image */,
+ cl_bool /* blocking_map */,
+ cl_map_flags /* map_flags */,
+ const size_t * /* origin[3] */,
+ const size_t * /* region[3] */,
+ size_t * /* image_row_pitch */,
+ size_t * /* image_slice_pitch */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */,
+ cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEUNMAPMEMOBJECT)(cl_command_queue /* command_queue */,
+ cl_mem /* memobj */,
+ void * /* mapped_ptr */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUENDRANGEKERNEL)(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* work_dim */,
+ const size_t * /* global_work_offset */,
+ const size_t * /* global_work_size */,
+ const size_t * /* local_work_size */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUETASK)(cl_command_queue /* command_queue */,
+ cl_kernel /* kernel */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUENATIVEKERNEL)(cl_command_queue /* command_queue */,
+ void (*user_func)(void *),
+ void * /* args */,
+ size_t /* cb_args */,
+ cl_uint /* num_mem_objects */,
+ const cl_mem * /* mem_list */,
+ const void ** /* args_mem_loc */,
+ cl_uint /* num_events_in_wait_list */,
+ const cl_event * /* event_wait_list */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEMARKER)(cl_command_queue /* command_queue */,
+ cl_event * /* event */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEWAITFOREVENTS)(cl_command_queue /* command_queue */,
+ cl_uint /* num_events */,
+ const cl_event * /* event_list */) CL_API_SUFFIX__VERSION_1_0;
+
+typedef CL_API_ENTRY cl_int (CL_API_CALL *
+PFNCLENQUEUEBARRIER)(cl_command_queue /* command_queue */) CL_API_SUFFIX__VERSION_1_0;
+
+// Extension function access
+//
+// Returns the extension function address for the given function name,
+// or NULL if a valid function can not be found. The client must
+// check to make sure the address is not NULL, before using or
+// calling the returned function address.
+//
+typedef CL_API_ENTRY void * (CL_API_CALL * PFNCLGETEXTENSIONFUNCTIONADDRESS)(const char * /* func_name */) CL_API_SUFFIX__VERSION_1_0;
+
+
+#define CLEW_STATIC
+
+#ifdef CLEW_STATIC
+# define CLEWAPI extern
+#else
+# ifdef CLEW_BUILD
+# define CLEWAPI extern __declspec(dllexport)
+# else
+# define CLEWAPI extern __declspec(dllimport)
+# endif
+#endif
+
+#if defined(_WIN32)
+#define CLEW_FUN_EXPORT extern
+#else
+#define CLEW_FUN_EXPORT CLEWAPI
+#endif
+
+#define CLEW_GET_FUN(x) x
+
+
+// Variables holding function entry points
+CLEW_FUN_EXPORT PFNCLGETPLATFORMIDS __oclGetPlatformIDs ;
+CLEW_FUN_EXPORT PFNCLGETPLATFORMINFO __oclGetPlatformInfo ;
+CLEW_FUN_EXPORT PFNCLGETDEVICEIDS __oclGetDeviceIDs ;
+CLEW_FUN_EXPORT PFNCLGETDEVICEINFO __oclGetDeviceInfo ;
+CLEW_FUN_EXPORT PFNCLCREATECONTEXT __oclCreateContext ;
+CLEW_FUN_EXPORT PFNCLCREATECONTEXTFROMTYPE __oclCreateContextFromType ;
+CLEW_FUN_EXPORT PFNCLRETAINCONTEXT __oclRetainContext ;
+CLEW_FUN_EXPORT PFNCLRELEASECONTEXT __oclReleaseContext ;
+CLEW_FUN_EXPORT PFNCLGETCONTEXTINFO __oclGetContextInfo ;
+CLEW_FUN_EXPORT PFNCLCREATECOMMANDQUEUE __oclCreateCommandQueue ;
+CLEW_FUN_EXPORT PFNCLRETAINCOMMANDQUEUE __oclRetainCommandQueue ;
+CLEW_FUN_EXPORT PFNCLRELEASECOMMANDQUEUE __oclReleaseCommandQueue ;
+CLEW_FUN_EXPORT PFNCLGETCOMMANDQUEUEINFO __oclGetCommandQueueInfo ;
+CLEW_FUN_EXPORT PFNCLSETCOMMANDQUEUEPROPERTY __oclSetCommandQueueProperty ;
+CLEW_FUN_EXPORT PFNCLCREATEBUFFER __oclCreateBuffer ;
+CLEW_FUN_EXPORT PFNCLCREATEIMAGE2D __oclCreateImage2D ;
+CLEW_FUN_EXPORT PFNCLCREATEIMAGE3D __oclCreateImage3D ;
+CLEW_FUN_EXPORT PFNCLRETAINMEMOBJECT __oclRetainMemObject ;
+CLEW_FUN_EXPORT PFNCLRELEASEMEMOBJECT __oclReleaseMemObject ;
+CLEW_FUN_EXPORT PFNCLGETSUPPORTEDIMAGEFORMATS __oclGetSupportedImageFormats ;
+CLEW_FUN_EXPORT PFNCLGETMEMOBJECTINFO __oclGetMemObjectInfo ;
+CLEW_FUN_EXPORT PFNCLGETIMAGEINFO __oclGetImageInfo ;
+CLEW_FUN_EXPORT PFNCLCREATESAMPLER __oclCreateSampler ;
+CLEW_FUN_EXPORT PFNCLRETAINSAMPLER __oclRetainSampler ;
+CLEW_FUN_EXPORT PFNCLRELEASESAMPLER __oclReleaseSampler ;
+CLEW_FUN_EXPORT PFNCLGETSAMPLERINFO __oclGetSamplerInfo ;
+CLEW_FUN_EXPORT PFNCLCREATEPROGRAMWITHSOURCE __oclCreateProgramWithSource ;
+CLEW_FUN_EXPORT PFNCLCREATEPROGRAMWITHBINARY __oclCreateProgramWithBinary ;
+CLEW_FUN_EXPORT PFNCLRETAINPROGRAM __oclRetainProgram ;
+CLEW_FUN_EXPORT PFNCLRELEASEPROGRAM __oclReleaseProgram ;
+CLEW_FUN_EXPORT PFNCLBUILDPROGRAM __oclBuildProgram ;
+CLEW_FUN_EXPORT PFNCLUNLOADCOMPILER __oclUnloadCompiler ;
+CLEW_FUN_EXPORT PFNCLGETPROGRAMINFO __oclGetProgramInfo ;
+CLEW_FUN_EXPORT PFNCLGETPROGRAMBUILDINFO __oclGetProgramBuildInfo ;
+CLEW_FUN_EXPORT PFNCLCREATEKERNEL __oclCreateKernel ;
+CLEW_FUN_EXPORT PFNCLCREATEKERNELSINPROGRAM __oclCreateKernelsInProgram ;
+CLEW_FUN_EXPORT PFNCLRETAINKERNEL __oclRetainKernel ;
+CLEW_FUN_EXPORT PFNCLRELEASEKERNEL __oclReleaseKernel ;
+CLEW_FUN_EXPORT PFNCLSETKERNELARG __oclSetKernelArg ;
+CLEW_FUN_EXPORT PFNCLGETKERNELINFO __oclGetKernelInfo ;
+CLEW_FUN_EXPORT PFNCLGETKERNELWORKGROUPINFO __oclGetKernelWorkGroupInfo ;
+CLEW_FUN_EXPORT PFNCLWAITFOREVENTS __oclWaitForEvents ;
+CLEW_FUN_EXPORT PFNCLGETEVENTINFO __oclGetEventInfo ;
+CLEW_FUN_EXPORT PFNCLRETAINEVENT __oclRetainEvent ;
+CLEW_FUN_EXPORT PFNCLRELEASEEVENT __oclReleaseEvent ;
+CLEW_FUN_EXPORT PFNCLGETEVENTPROFILINGINFO __oclGetEventProfilingInfo ;
+CLEW_FUN_EXPORT PFNCLFLUSH __oclFlush ;
+CLEW_FUN_EXPORT PFNCLFINISH __oclFinish ;
+CLEW_FUN_EXPORT PFNCLENQUEUEREADBUFFER __oclEnqueueReadBuffer ;
+CLEW_FUN_EXPORT PFNCLENQUEUEWRITEBUFFER __oclEnqueueWriteBuffer ;
+CLEW_FUN_EXPORT PFNCLENQUEUECOPYBUFFER __oclEnqueueCopyBuffer ;
+CLEW_FUN_EXPORT PFNCLENQUEUEREADIMAGE __oclEnqueueReadImage ;
+CLEW_FUN_EXPORT PFNCLENQUEUEWRITEIMAGE __oclEnqueueWriteImage ;
+CLEW_FUN_EXPORT PFNCLENQUEUECOPYIMAGE __oclEnqueueCopyImage ;
+CLEW_FUN_EXPORT PFNCLENQUEUECOPYIMAGETOBUFFER __oclEnqueueCopyImageToBuffer ;
+CLEW_FUN_EXPORT PFNCLENQUEUECOPYBUFFERTOIMAGE __oclEnqueueCopyBufferToImage ;
+CLEW_FUN_EXPORT PFNCLENQUEUEMAPBUFFER __oclEnqueueMapBuffer ;
+CLEW_FUN_EXPORT PFNCLENQUEUEMAPIMAGE __oclEnqueueMapImage ;
+CLEW_FUN_EXPORT PFNCLENQUEUEUNMAPMEMOBJECT __oclEnqueueUnmapMemObject ;
+CLEW_FUN_EXPORT PFNCLENQUEUENDRANGEKERNEL __oclEnqueueNDRangeKernel ;
+CLEW_FUN_EXPORT PFNCLENQUEUETASK __oclEnqueueTask ;
+CLEW_FUN_EXPORT PFNCLENQUEUENATIVEKERNEL __oclEnqueueNativeKernel ;
+CLEW_FUN_EXPORT PFNCLENQUEUEMARKER __oclEnqueueMarker ;
+CLEW_FUN_EXPORT PFNCLENQUEUEWAITFOREVENTS __oclEnqueueWaitForEvents ;
+CLEW_FUN_EXPORT PFNCLENQUEUEBARRIER __oclEnqueueBarrier ;
+CLEW_FUN_EXPORT PFNCLGETEXTENSIONFUNCTIONADDRESS __oclGetExtensionFunctionAddress ;
+
+
+#define clGetPlatformIDs CLEW_GET_FUN(__oclGetPlatformIDs )
+#define clGetPlatformInfo CLEW_GET_FUN(__oclGetPlatformInfo )
+#define clGetDeviceIDs CLEW_GET_FUN(__oclGetDeviceIDs )
+#define clGetDeviceInfo CLEW_GET_FUN(__oclGetDeviceInfo )
+#define clCreateContext CLEW_GET_FUN(__oclCreateContext )
+#define clCreateContextFromType CLEW_GET_FUN(__oclCreateContextFromType )
+#define clRetainContext CLEW_GET_FUN(__oclRetainContext )
+#define clReleaseContext CLEW_GET_FUN(__oclReleaseContext )
+#define clGetContextInfo CLEW_GET_FUN(__oclGetContextInfo )
+#define clCreateCommandQueue CLEW_GET_FUN(__oclCreateCommandQueue )
+#define clRetainCommandQueue CLEW_GET_FUN(__oclRetainCommandQueue )
+#define clReleaseCommandQueue CLEW_GET_FUN(__oclReleaseCommandQueue )
+#define clGetCommandQueueInfo CLEW_GET_FUN(__oclGetCommandQueueInfo )
+#define clSetCommandQueueProperty CLEW_GET_FUN(__oclSetCommandQueueProperty )
+#define clCreateBuffer CLEW_GET_FUN(__oclCreateBuffer )
+#define clCreateImage2D CLEW_GET_FUN(__oclCreateImage2D )
+#define clCreateImage3D CLEW_GET_FUN(__oclCreateImage3D )
+#define clRetainMemObject CLEW_GET_FUN(__oclRetainMemObject )
+#define clReleaseMemObject CLEW_GET_FUN(__oclReleaseMemObject )
+#define clGetSupportedImageFormats CLEW_GET_FUN(__oclGetSupportedImageFormats )
+#define clGetMemObjectInfo CLEW_GET_FUN(__oclGetMemObjectInfo )
+#define clGetImageInfo CLEW_GET_FUN(__oclGetImageInfo )
+#define clCreateSampler CLEW_GET_FUN(__oclCreateSampler )
+#define clRetainSampler CLEW_GET_FUN(__oclRetainSampler )
+#define clReleaseSampler CLEW_GET_FUN(__oclReleaseSampler )
+#define clGetSamplerInfo CLEW_GET_FUN(__oclGetSamplerInfo )
+#define clCreateProgramWithSource CLEW_GET_FUN(__oclCreateProgramWithSource )
+#define clCreateProgramWithBinary CLEW_GET_FUN(__oclCreateProgramWithBinary )
+#define clRetainProgram CLEW_GET_FUN(__oclRetainProgram )
+#define clReleaseProgram CLEW_GET_FUN(__oclReleaseProgram )
+#define clBuildProgram CLEW_GET_FUN(__oclBuildProgram )
+#define clUnloadCompiler CLEW_GET_FUN(__oclUnloadCompiler )
+#define clGetProgramInfo CLEW_GET_FUN(__oclGetProgramInfo )
+#define clGetProgramBuildInfo CLEW_GET_FUN(__oclGetProgramBuildInfo )
+#define clCreateKernel CLEW_GET_FUN(__oclCreateKernel )
+#define clCreateKernelsInProgram CLEW_GET_FUN(__oclCreateKernelsInProgram )
+#define clRetainKernel CLEW_GET_FUN(__oclRetainKernel )
+#define clReleaseKernel CLEW_GET_FUN(__oclReleaseKernel )
+#define clSetKernelArg CLEW_GET_FUN(__oclSetKernelArg )
+#define clGetKernelInfo CLEW_GET_FUN(__oclGetKernelInfo )
+#define clGetKernelWorkGroupInfo CLEW_GET_FUN(__oclGetKernelWorkGroupInfo )
+#define clWaitForEvents CLEW_GET_FUN(__oclWaitForEvents )
+#define clGetEventInfo CLEW_GET_FUN(__oclGetEventInfo )
+#define clRetainEvent CLEW_GET_FUN(__oclRetainEvent )
+#define clReleaseEvent CLEW_GET_FUN(__oclReleaseEvent )
+#define clGetEventProfilingInfo CLEW_GET_FUN(__oclGetEventProfilingInfo )
+#define clFlush CLEW_GET_FUN(__oclFlush )
+#define clFinish CLEW_GET_FUN(__oclFinish )
+#define clEnqueueReadBuffer CLEW_GET_FUN(__oclEnqueueReadBuffer )
+#define clEnqueueWriteBuffer CLEW_GET_FUN(__oclEnqueueWriteBuffer )
+#define clEnqueueCopyBuffer CLEW_GET_FUN(__oclEnqueueCopyBuffer )
+#define clEnqueueReadImage CLEW_GET_FUN(__oclEnqueueReadImage )
+#define clEnqueueWriteImage CLEW_GET_FUN(__oclEnqueueWriteImage )
+#define clEnqueueCopyImage CLEW_GET_FUN(__oclEnqueueCopyImage )
+#define clEnqueueCopyImageToBuffer CLEW_GET_FUN(__oclEnqueueCopyImageToBuffer )
+#define clEnqueueCopyBufferToImage CLEW_GET_FUN(__oclEnqueueCopyBufferToImage )
+#define clEnqueueMapBuffer CLEW_GET_FUN(__oclEnqueueMapBuffer )
+#define clEnqueueMapImage CLEW_GET_FUN(__oclEnqueueMapImage )
+#define clEnqueueUnmapMemObject CLEW_GET_FUN(__oclEnqueueUnmapMemObject )
+#define clEnqueueNDRangeKernel CLEW_GET_FUN(__oclEnqueueNDRangeKernel )
+#define clEnqueueTask CLEW_GET_FUN(__oclEnqueueTask )
+#define clEnqueueNativeKernel CLEW_GET_FUN(__oclEnqueueNativeKernel )
+#define clEnqueueMarker CLEW_GET_FUN(__oclEnqueueMarker )
+#define clEnqueueWaitForEvents CLEW_GET_FUN(__oclEnqueueWaitForEvents )
+#define clEnqueueBarrier CLEW_GET_FUN(__oclEnqueueBarrier )
+#define clGetExtensionFunctionAddress CLEW_GET_FUN(__oclGetExtensionFunctionAddress )
+
+#endif // CLCC_GENERATE_DOCUMENTATION
+
+#define CLEW_SUCCESS 0 //!< Success error code
+#define CLEW_ERROR_OPEN_FAILED -1 //!< Error code for failing to open the dynamic library
+#define CLEW_ERROR_ATEXIT_FAILED -2 //!< Error code for failing to queue the closing of the dynamic library to atexit()
+
+//! \brief Load OpenCL dynamic library and set function entry points
+int clewInit (const char*);
+//! \brief Convert an OpenCL error code to its string equivalent
+const char* clewErrorString (cl_int error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // CLCC_CLEW_HPP_INCLUDED
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index d7b06a78322..79f94c77dde 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1432,7 +1432,7 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
ntreeCompositTagRender(re->scene);
ntreeCompositTagAnimated(ntree);
- ntreeCompositExecTree(ntree, &re->r, G.background==0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background==0);
}
/* ensure we get either composited result or the active layer */
@@ -1596,7 +1596,7 @@ static void do_render_composite_fields_blur_3d(Render *re)
if (re->r.scemode & R_FULL_SAMPLE)
do_merge_fullsample(re, ntree);
else {
- ntreeCompositExecTree(ntree, &re->r, G.background==0);
+ ntreeCompositExecTree(ntree, &re->r, 1, G.background==0);
}
ntree->stats_draw= NULL;