From 1775ea74c152ba7cf27a8bc1f071b40992c89013 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 8 Mar 2021 13:41:52 +0100 Subject: Cleanup: Change extension .cpp to .cc --- .../blender/compositor/nodes/COM_AlphaOverNode.cc | 66 ++++ .../blender/compositor/nodes/COM_AlphaOverNode.cpp | 66 ---- .../compositor/nodes/COM_BilateralBlurNode.cc | 41 +++ .../compositor/nodes/COM_BilateralBlurNode.cpp | 41 --- source/blender/compositor/nodes/COM_BlurNode.cc | 170 ++++++++++ source/blender/compositor/nodes/COM_BlurNode.cpp | 170 ---------- .../blender/compositor/nodes/COM_BokehBlurNode.cc | 77 +++++ .../blender/compositor/nodes/COM_BokehBlurNode.cpp | 77 ----- .../blender/compositor/nodes/COM_BokehImageNode.cc | 38 +++ .../compositor/nodes/COM_BokehImageNode.cpp | 38 --- source/blender/compositor/nodes/COM_BoxMaskNode.cc | 72 +++++ .../blender/compositor/nodes/COM_BoxMaskNode.cpp | 72 ----- .../blender/compositor/nodes/COM_BrightnessNode.cc | 40 +++ .../compositor/nodes/COM_BrightnessNode.cpp | 40 --- .../compositor/nodes/COM_ChannelMatteNode.cc | 95 ++++++ .../compositor/nodes/COM_ChannelMatteNode.cpp | 95 ------ .../compositor/nodes/COM_ChromaMatteNode.cc | 65 ++++ .../compositor/nodes/COM_ChromaMatteNode.cpp | 65 ---- .../compositor/nodes/COM_ColorBalanceNode.cc | 73 +++++ .../compositor/nodes/COM_ColorBalanceNode.cpp | 73 ----- .../compositor/nodes/COM_ColorCorrectionNode.cc | 43 +++ .../compositor/nodes/COM_ColorCorrectionNode.cpp | 43 --- .../blender/compositor/nodes/COM_ColorCurveNode.cc | 57 ++++ .../compositor/nodes/COM_ColorCurveNode.cpp | 57 ---- .../compositor/nodes/COM_ColorExposureNode.cc | 37 +++ .../compositor/nodes/COM_ColorExposureNode.cpp | 37 --- .../blender/compositor/nodes/COM_ColorMatteNode.cc | 63 ++++ .../compositor/nodes/COM_ColorMatteNode.cpp | 63 ---- source/blender/compositor/nodes/COM_ColorNode.cc | 39 +++ source/blender/compositor/nodes/COM_ColorNode.cpp | 39 --- .../blender/compositor/nodes/COM_ColorRampNode.cc | 52 +++ .../blender/compositor/nodes/COM_ColorRampNode.cpp | 52 --- .../blender/compositor/nodes/COM_ColorSpillNode.cc | 47 +++ .../compositor/nodes/COM_ColorSpillNode.cpp | 47 --- .../blender/compositor/nodes/COM_ColorToBWNode.cc | 40 +++ .../blender/compositor/nodes/COM_ColorToBWNode.cpp | 40 --- .../compositor/nodes/COM_CombineColorNode.cc | 89 ++++++ .../compositor/nodes/COM_CombineColorNode.cpp | 89 ------ .../blender/compositor/nodes/COM_CompositorNode.cc | 61 ++++ .../compositor/nodes/COM_CompositorNode.cpp | 61 ---- .../compositor/nodes/COM_ConvertAlphaNode.cc | 41 +++ .../compositor/nodes/COM_ConvertAlphaNode.cpp | 41 --- .../blender/compositor/nodes/COM_CornerPinNode.cc | 55 ++++ .../blender/compositor/nodes/COM_CornerPinNode.cpp | 55 ---- source/blender/compositor/nodes/COM_CropNode.cc | 47 +++ source/blender/compositor/nodes/COM_CropNode.cpp | 47 --- .../compositor/nodes/COM_CryptomatteNode.cc | 80 +++++ .../compositor/nodes/COM_CryptomatteNode.cpp | 80 ----- source/blender/compositor/nodes/COM_DefocusNode.cc | 143 +++++++++ .../blender/compositor/nodes/COM_DefocusNode.cpp | 143 --------- source/blender/compositor/nodes/COM_DenoiseNode.cc | 43 +++ .../blender/compositor/nodes/COM_DenoiseNode.cpp | 43 --- .../blender/compositor/nodes/COM_DespeckleNode.cc | 48 +++ .../blender/compositor/nodes/COM_DespeckleNode.cpp | 48 --- .../compositor/nodes/COM_DifferenceMatteNode.cc | 54 ++++ .../compositor/nodes/COM_DifferenceMatteNode.cpp | 54 ---- .../compositor/nodes/COM_DilateErodeNode.cc | 149 +++++++++ .../compositor/nodes/COM_DilateErodeNode.cpp | 149 --------- .../compositor/nodes/COM_DirectionalBlurNode.cc | 40 +++ .../compositor/nodes/COM_DirectionalBlurNode.cpp | 40 --- .../blender/compositor/nodes/COM_DisplaceNode.cc | 46 +++ .../blender/compositor/nodes/COM_DisplaceNode.cpp | 46 --- .../compositor/nodes/COM_DistanceMatteNode.cc | 98 ++++++ .../compositor/nodes/COM_DistanceMatteNode.cpp | 98 ------ .../compositor/nodes/COM_DoubleEdgeMaskNode.cc | 42 +++ .../compositor/nodes/COM_DoubleEdgeMaskNode.cpp | 42 --- .../compositor/nodes/COM_EllipseMaskNode.cc | 72 +++++ .../compositor/nodes/COM_EllipseMaskNode.cpp | 72 ----- source/blender/compositor/nodes/COM_FilterNode.cc | 96 ++++++ source/blender/compositor/nodes/COM_FilterNode.cpp | 96 ------ source/blender/compositor/nodes/COM_FlipNode.cc | 54 ++++ source/blender/compositor/nodes/COM_FlipNode.cpp | 54 ---- source/blender/compositor/nodes/COM_GammaNode.cc | 37 +++ source/blender/compositor/nodes/COM_GammaNode.cpp | 37 --- source/blender/compositor/nodes/COM_GlareNode.cc | 82 +++++ source/blender/compositor/nodes/COM_GlareNode.cpp | 82 ----- .../nodes/COM_HueSaturationValueCorrectNode.cc | 64 ++++ .../nodes/COM_HueSaturationValueCorrectNode.cpp | 64 ---- .../compositor/nodes/COM_HueSaturationValueNode.cc | 67 ++++ .../nodes/COM_HueSaturationValueNode.cpp | 67 ---- source/blender/compositor/nodes/COM_IDMaskNode.cc | 49 +++ source/blender/compositor/nodes/COM_IDMaskNode.cpp | 49 --- source/blender/compositor/nodes/COM_ImageNode.cc | 299 ++++++++++++++++++ source/blender/compositor/nodes/COM_ImageNode.cpp | 299 ------------------ source/blender/compositor/nodes/COM_InpaintNode.cc | 45 +++ .../blender/compositor/nodes/COM_InpaintNode.cpp | 45 --- source/blender/compositor/nodes/COM_InvertNode.cc | 41 +++ source/blender/compositor/nodes/COM_InvertNode.cpp | 41 --- source/blender/compositor/nodes/COM_KeyingNode.cc | 350 +++++++++++++++++++++ source/blender/compositor/nodes/COM_KeyingNode.cpp | 350 --------------------- .../compositor/nodes/COM_KeyingScreenNode.cc | 47 +++ .../compositor/nodes/COM_KeyingScreenNode.cpp | 47 --- .../compositor/nodes/COM_LensDistortionNode.cc | 61 ++++ .../compositor/nodes/COM_LensDistortionNode.cpp | 61 ---- .../compositor/nodes/COM_LuminanceMatteNode.cc | 53 ++++ .../compositor/nodes/COM_LuminanceMatteNode.cpp | 53 ---- .../blender/compositor/nodes/COM_MapRangeNode.cc | 49 +++ .../blender/compositor/nodes/COM_MapRangeNode.cpp | 49 --- source/blender/compositor/nodes/COM_MapUVNode.cc | 41 +++ source/blender/compositor/nodes/COM_MapUVNode.cpp | 41 --- .../blender/compositor/nodes/COM_MapValueNode.cc | 43 +++ .../blender/compositor/nodes/COM_MapValueNode.cpp | 43 --- source/blender/compositor/nodes/COM_MaskNode.cc | 70 +++++ source/blender/compositor/nodes/COM_MaskNode.cpp | 70 ----- source/blender/compositor/nodes/COM_MathNode.cc | 161 ++++++++++ source/blender/compositor/nodes/COM_MathNode.cpp | 161 ---------- source/blender/compositor/nodes/COM_MixNode.cc | 112 +++++++ source/blender/compositor/nodes/COM_MixNode.cpp | 112 ------- .../blender/compositor/nodes/COM_MovieClipNode.cc | 108 +++++++ .../blender/compositor/nodes/COM_MovieClipNode.cpp | 108 ------- .../compositor/nodes/COM_MovieDistortionNode.cc | 46 +++ .../compositor/nodes/COM_MovieDistortionNode.cpp | 46 --- source/blender/compositor/nodes/COM_NormalNode.cc | 56 ++++ source/blender/compositor/nodes/COM_NormalNode.cpp | 56 ---- .../blender/compositor/nodes/COM_NormalizeNode.cc | 36 +++ .../blender/compositor/nodes/COM_NormalizeNode.cpp | 36 --- .../blender/compositor/nodes/COM_OutputFileNode.cc | 153 +++++++++ .../compositor/nodes/COM_OutputFileNode.cpp | 153 --------- .../blender/compositor/nodes/COM_PixelateNode.cc | 46 +++ .../blender/compositor/nodes/COM_PixelateNode.cpp | 46 --- .../compositor/nodes/COM_PlaneTrackDeformNode.cc | 72 +++++ .../compositor/nodes/COM_PlaneTrackDeformNode.cpp | 72 ----- .../compositor/nodes/COM_RenderLayersNode.cc | 176 +++++++++++ .../compositor/nodes/COM_RenderLayersNode.cpp | 176 ----------- source/blender/compositor/nodes/COM_RotateNode.cc | 47 +++ source/blender/compositor/nodes/COM_RotateNode.cpp | 47 --- source/blender/compositor/nodes/COM_ScaleNode.cc | 107 +++++++ source/blender/compositor/nodes/COM_ScaleNode.cpp | 107 ------- .../compositor/nodes/COM_SeparateColorNode.cc | 121 +++++++ .../compositor/nodes/COM_SeparateColorNode.cpp | 121 ------- .../blender/compositor/nodes/COM_SetAlphaNode.cc | 48 +++ .../blender/compositor/nodes/COM_SetAlphaNode.cpp | 48 --- .../compositor/nodes/COM_SocketProxyNode.cc | 103 ++++++ .../compositor/nodes/COM_SocketProxyNode.cpp | 103 ------ .../compositor/nodes/COM_SplitViewerNode.cc | 75 +++++ .../compositor/nodes/COM_SplitViewerNode.cpp | 75 ----- .../compositor/nodes/COM_Stabilize2dNode.cc | 113 +++++++ .../compositor/nodes/COM_Stabilize2dNode.cpp | 113 ------- .../blender/compositor/nodes/COM_SunBeamsNode.cc | 39 +++ .../blender/compositor/nodes/COM_SunBeamsNode.cpp | 39 --- source/blender/compositor/nodes/COM_SwitchNode.cc | 40 +++ source/blender/compositor/nodes/COM_SwitchNode.cpp | 40 --- .../blender/compositor/nodes/COM_SwitchViewNode.cc | 40 +++ .../compositor/nodes/COM_SwitchViewNode.cpp | 40 --- source/blender/compositor/nodes/COM_TextureNode.cc | 56 ++++ .../blender/compositor/nodes/COM_TextureNode.cpp | 56 ---- source/blender/compositor/nodes/COM_TimeNode.cc | 58 ++++ source/blender/compositor/nodes/COM_TimeNode.cpp | 58 ---- source/blender/compositor/nodes/COM_TonemapNode.cc | 40 +++ .../blender/compositor/nodes/COM_TonemapNode.cpp | 40 --- .../compositor/nodes/COM_TrackPositionNode.cc | 111 +++++++ .../compositor/nodes/COM_TrackPositionNode.cpp | 111 ------- .../blender/compositor/nodes/COM_TransformNode.cc | 68 ++++ .../blender/compositor/nodes/COM_TransformNode.cpp | 68 ---- .../blender/compositor/nodes/COM_TranslateNode.cc | 71 +++++ .../blender/compositor/nodes/COM_TranslateNode.cpp | 71 ----- source/blender/compositor/nodes/COM_ValueNode.cc | 37 +++ source/blender/compositor/nodes/COM_ValueNode.cpp | 37 --- .../blender/compositor/nodes/COM_VectorBlurNode.cc | 43 +++ .../compositor/nodes/COM_VectorBlurNode.cpp | 43 --- .../compositor/nodes/COM_VectorCurveNode.cc | 37 +++ .../compositor/nodes/COM_VectorCurveNode.cpp | 37 --- .../blender/compositor/nodes/COM_ViewLevelsNode.cc | 61 ++++ .../compositor/nodes/COM_ViewLevelsNode.cpp | 61 ---- source/blender/compositor/nodes/COM_ViewerNode.cc | 84 +++++ source/blender/compositor/nodes/COM_ViewerNode.cpp | 84 ----- .../blender/compositor/nodes/COM_ZCombineNode.cc | 101 ++++++ .../blender/compositor/nodes/COM_ZCombineNode.cpp | 101 ------ 168 files changed, 6237 insertions(+), 6237 deletions(-) create mode 100644 source/blender/compositor/nodes/COM_AlphaOverNode.cc delete mode 100644 source/blender/compositor/nodes/COM_AlphaOverNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BilateralBlurNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BilateralBlurNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BlurNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BlurNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BokehBlurNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BokehBlurNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BokehImageNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BokehImageNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BoxMaskNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BoxMaskNode.cpp create mode 100644 source/blender/compositor/nodes/COM_BrightnessNode.cc delete mode 100644 source/blender/compositor/nodes/COM_BrightnessNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ChannelMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ChannelMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ChromaMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ChromaMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorBalanceNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorBalanceNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorCorrectionNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorCurveNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorCurveNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorExposureNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorExposureNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorRampNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorRampNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorSpillNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorSpillNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ColorToBWNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ColorToBWNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CombineColorNode.cc delete mode 100644 source/blender/compositor/nodes/COM_CombineColorNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CompositorNode.cc delete mode 100644 source/blender/compositor/nodes/COM_CompositorNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ConvertAlphaNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CornerPinNode.cc delete mode 100644 source/blender/compositor/nodes/COM_CornerPinNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CropNode.cc delete mode 100644 source/blender/compositor/nodes/COM_CropNode.cpp create mode 100644 source/blender/compositor/nodes/COM_CryptomatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_CryptomatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DefocusNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DefocusNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DenoiseNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DenoiseNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DespeckleNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DespeckleNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DifferenceMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DilateErodeNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DilateErodeNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DirectionalBlurNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DisplaceNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DisplaceNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DistanceMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DistanceMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cc delete mode 100644 source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp create mode 100644 source/blender/compositor/nodes/COM_EllipseMaskNode.cc delete mode 100644 source/blender/compositor/nodes/COM_EllipseMaskNode.cpp create mode 100644 source/blender/compositor/nodes/COM_FilterNode.cc delete mode 100644 source/blender/compositor/nodes/COM_FilterNode.cpp create mode 100644 source/blender/compositor/nodes/COM_FlipNode.cc delete mode 100644 source/blender/compositor/nodes/COM_FlipNode.cpp create mode 100644 source/blender/compositor/nodes/COM_GammaNode.cc delete mode 100644 source/blender/compositor/nodes/COM_GammaNode.cpp create mode 100644 source/blender/compositor/nodes/COM_GlareNode.cc delete mode 100644 source/blender/compositor/nodes/COM_GlareNode.cpp create mode 100644 source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc delete mode 100644 source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp create mode 100644 source/blender/compositor/nodes/COM_HueSaturationValueNode.cc delete mode 100644 source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp create mode 100644 source/blender/compositor/nodes/COM_IDMaskNode.cc delete mode 100644 source/blender/compositor/nodes/COM_IDMaskNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ImageNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ImageNode.cpp create mode 100644 source/blender/compositor/nodes/COM_InpaintNode.cc delete mode 100644 source/blender/compositor/nodes/COM_InpaintNode.cpp create mode 100644 source/blender/compositor/nodes/COM_InvertNode.cc delete mode 100644 source/blender/compositor/nodes/COM_InvertNode.cpp create mode 100644 source/blender/compositor/nodes/COM_KeyingNode.cc delete mode 100644 source/blender/compositor/nodes/COM_KeyingNode.cpp create mode 100644 source/blender/compositor/nodes/COM_KeyingScreenNode.cc delete mode 100644 source/blender/compositor/nodes/COM_KeyingScreenNode.cpp create mode 100644 source/blender/compositor/nodes/COM_LensDistortionNode.cc delete mode 100644 source/blender/compositor/nodes/COM_LensDistortionNode.cpp create mode 100644 source/blender/compositor/nodes/COM_LuminanceMatteNode.cc delete mode 100644 source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MapRangeNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MapRangeNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MapUVNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MapUVNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MapValueNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MapValueNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MaskNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MaskNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MathNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MathNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MixNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MixNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MovieClipNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MovieClipNode.cpp create mode 100644 source/blender/compositor/nodes/COM_MovieDistortionNode.cc delete mode 100644 source/blender/compositor/nodes/COM_MovieDistortionNode.cpp create mode 100644 source/blender/compositor/nodes/COM_NormalNode.cc delete mode 100644 source/blender/compositor/nodes/COM_NormalNode.cpp create mode 100644 source/blender/compositor/nodes/COM_NormalizeNode.cc delete mode 100644 source/blender/compositor/nodes/COM_NormalizeNode.cpp create mode 100644 source/blender/compositor/nodes/COM_OutputFileNode.cc delete mode 100644 source/blender/compositor/nodes/COM_OutputFileNode.cpp create mode 100644 source/blender/compositor/nodes/COM_PixelateNode.cc delete mode 100644 source/blender/compositor/nodes/COM_PixelateNode.cpp create mode 100644 source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cc delete mode 100644 source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp create mode 100644 source/blender/compositor/nodes/COM_RenderLayersNode.cc delete mode 100644 source/blender/compositor/nodes/COM_RenderLayersNode.cpp create mode 100644 source/blender/compositor/nodes/COM_RotateNode.cc delete mode 100644 source/blender/compositor/nodes/COM_RotateNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ScaleNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ScaleNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SeparateColorNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SeparateColorNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SetAlphaNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SetAlphaNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SocketProxyNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SocketProxyNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SplitViewerNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SplitViewerNode.cpp create mode 100644 source/blender/compositor/nodes/COM_Stabilize2dNode.cc delete mode 100644 source/blender/compositor/nodes/COM_Stabilize2dNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SunBeamsNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SunBeamsNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SwitchNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SwitchNode.cpp create mode 100644 source/blender/compositor/nodes/COM_SwitchViewNode.cc delete mode 100644 source/blender/compositor/nodes/COM_SwitchViewNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TextureNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TextureNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TimeNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TimeNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TonemapNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TonemapNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TrackPositionNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TrackPositionNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TransformNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TransformNode.cpp create mode 100644 source/blender/compositor/nodes/COM_TranslateNode.cc delete mode 100644 source/blender/compositor/nodes/COM_TranslateNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ValueNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ValueNode.cpp create mode 100644 source/blender/compositor/nodes/COM_VectorBlurNode.cc delete mode 100644 source/blender/compositor/nodes/COM_VectorBlurNode.cpp create mode 100644 source/blender/compositor/nodes/COM_VectorCurveNode.cc delete mode 100644 source/blender/compositor/nodes/COM_VectorCurveNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ViewLevelsNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ViewLevelsNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ViewerNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ViewerNode.cpp create mode 100644 source/blender/compositor/nodes/COM_ZCombineNode.cc delete mode 100644 source/blender/compositor/nodes/COM_ZCombineNode.cpp (limited to 'source/blender/compositor/nodes') diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cc b/source/blender/compositor/nodes/COM_AlphaOverNode.cc new file mode 100644 index 00000000000..640fbf49808 --- /dev/null +++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cc @@ -0,0 +1,66 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_AlphaOverNode.h" + +#include "COM_AlphaOverKeyOperation.h" +#include "COM_AlphaOverMixedOperation.h" +#include "COM_AlphaOverPremultiplyOperation.h" +#include "COM_MixOperation.h" + +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" /* the ramp types */ + +void AlphaOverNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *color1Socket = this->getInputSocket(1); + NodeInput *color2Socket = this->getInputSocket(2); + 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->isLinked()) { + convertProg->setResolutionInputSocketIndex(1); + } + else if (color2Socket->isLinked()) { + convertProg->setResolutionInputSocketIndex(2); + } + else { + convertProg->setResolutionInputSocketIndex(0); + } + + converter.addOperation(convertProg); + converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp deleted file mode 100644 index 640fbf49808..00000000000 --- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_AlphaOverNode.h" - -#include "COM_AlphaOverKeyOperation.h" -#include "COM_AlphaOverMixedOperation.h" -#include "COM_AlphaOverPremultiplyOperation.h" -#include "COM_MixOperation.h" - -#include "COM_SetValueOperation.h" -#include "DNA_material_types.h" /* the ramp types */ - -void AlphaOverNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *color1Socket = this->getInputSocket(1); - NodeInput *color2Socket = this->getInputSocket(2); - 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->isLinked()) { - convertProg->setResolutionInputSocketIndex(1); - } - else if (color2Socket->isLinked()) { - convertProg->setResolutionInputSocketIndex(2); - } - else { - convertProg->setResolutionInputSocketIndex(0); - } - - converter.addOperation(convertProg); - converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cc b/source/blender/compositor/nodes/COM_BilateralBlurNode.cc new file mode 100644 index 00000000000..e8037f923f2 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cc @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BilateralBlurNode.h" +#include "COM_BilateralBlurOperation.h" +#include "COM_ExecutionSystem.h" +#include "DNA_node_types.h" + +BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BilateralBlurNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage; + BilateralBlurOperation *operation = new BilateralBlurOperation(); + operation->setQuality(context.getQuality()); + operation->setData(data); + + converter.addOperation(operation); + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp deleted file mode 100644 index e8037f923f2..00000000000 --- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BilateralBlurNode.h" -#include "COM_BilateralBlurOperation.h" -#include "COM_ExecutionSystem.h" -#include "DNA_node_types.h" - -BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BilateralBlurNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage; - BilateralBlurOperation *operation = new BilateralBlurOperation(); - operation->setQuality(context.getQuality()); - operation->setData(data); - - converter.addOperation(operation); - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_BlurNode.cc b/source/blender/compositor/nodes/COM_BlurNode.cc new file mode 100644 index 00000000000..b82bede8443 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BlurNode.cc @@ -0,0 +1,170 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BlurNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_FastGaussianBlurOperation.h" +#include "COM_GammaCorrectOperation.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" +#include "COM_GaussianBokehBlurOperation.h" +#include "COM_GaussianXBlurOperation.h" +#include "COM_GaussianYBlurOperation.h" +#include "COM_MathBaseOperation.h" +#include "COM_SetValueOperation.h" +#include "DNA_node_types.h" + +BlurNode::BlurNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BlurNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + NodeBlurData *data = (NodeBlurData *)editorNode->storage; + NodeInput *inputSizeSocket = this->getInputSocket(1); + bool connectedSizeSocket = inputSizeSocket->isLinked(); + + const float size = this->getInputSocket(1)->getEditorValueFloat(); + const bool extend_bounds = (editorNode->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; + + CompositorQuality quality = context.getQuality(); + NodeOperation *input_operation = nullptr, *output_operation = nullptr; + + if (data->filtertype == R_FILTER_FAST_GAUSS) { + FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); + operationfgb->setData(data); + operationfgb->setExtendBounds(extend_bounds); + converter.addOperation(operationfgb); + + converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1)); + + input_operation = operationfgb; + output_operation = operationfgb; + } + else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) { + MathAddOperation *clamp = new MathAddOperation(); + SetValueOperation *zero = new SetValueOperation(); + zero->setValue(0.0f); + clamp->setUseClamp(true); + + converter.addOperation(clamp); + converter.addOperation(zero); + converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0)); + converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1)); + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + operationx->setSize(1.0f); + operationx->setFalloff(PROP_SMOOTH); + operationx->setSubtract(false); + operationx->setExtendBounds(extend_bounds); + + converter.addOperation(operationx); + converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0)); + + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + operationy->setSize(1.0f); + operationy->setFalloff(PROP_SMOOTH); + operationy->setSubtract(false); + operationy->setExtendBounds(extend_bounds); + + converter.addOperation(operationy); + converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); + + GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation(); + operation->setData(data); + operation->setQuality(quality); + operation->setExtendBounds(extend_bounds); + + converter.addOperation(operation); + converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1)); + + output_operation = operation; + input_operation = operation; + } + else if (!data->bokeh) { + GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + operationx->checkOpenCL(); + operationx->setExtendBounds(extend_bounds); + + converter.addOperation(operationx); + converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); + + GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + operationy->checkOpenCL(); + operationy->setExtendBounds(extend_bounds); + + converter.addOperation(operationy); + converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); + converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); + + if (!connectedSizeSocket) { + operationx->setSize(size); + operationy->setSize(size); + } + + input_operation = operationx; + output_operation = operationy; + } + else { + GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); + operation->setData(data); + operation->setQuality(quality); + operation->setExtendBounds(extend_bounds); + + converter.addOperation(operation); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + + if (!connectedSizeSocket) { + operation->setSize(size); + } + + input_operation = operation; + output_operation = operation; + } + + if (data->gamma) { + GammaCorrectOperation *correct = new GammaCorrectOperation(); + GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); + converter.addOperation(correct); + converter.addOperation(inverse); + + converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0)); + converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0)); + converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket()); + + converter.addPreview(inverse->getOutputSocket()); + } + else { + converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket()); + + converter.addPreview(output_operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp deleted file mode 100644 index b82bede8443..00000000000 --- a/source/blender/compositor/nodes/COM_BlurNode.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BlurNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_FastGaussianBlurOperation.h" -#include "COM_GammaCorrectOperation.h" -#include "COM_GaussianAlphaXBlurOperation.h" -#include "COM_GaussianAlphaYBlurOperation.h" -#include "COM_GaussianBokehBlurOperation.h" -#include "COM_GaussianXBlurOperation.h" -#include "COM_GaussianYBlurOperation.h" -#include "COM_MathBaseOperation.h" -#include "COM_SetValueOperation.h" -#include "DNA_node_types.h" - -BlurNode::BlurNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BlurNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - NodeBlurData *data = (NodeBlurData *)editorNode->storage; - NodeInput *inputSizeSocket = this->getInputSocket(1); - bool connectedSizeSocket = inputSizeSocket->isLinked(); - - const float size = this->getInputSocket(1)->getEditorValueFloat(); - const bool extend_bounds = (editorNode->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; - - CompositorQuality quality = context.getQuality(); - NodeOperation *input_operation = nullptr, *output_operation = nullptr; - - if (data->filtertype == R_FILTER_FAST_GAUSS) { - FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); - operationfgb->setData(data); - operationfgb->setExtendBounds(extend_bounds); - converter.addOperation(operationfgb); - - converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1)); - - input_operation = operationfgb; - output_operation = operationfgb; - } - else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) { - MathAddOperation *clamp = new MathAddOperation(); - SetValueOperation *zero = new SetValueOperation(); - zero->setValue(0.0f); - clamp->setUseClamp(true); - - converter.addOperation(clamp); - converter.addOperation(zero); - converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0)); - converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1)); - - GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); - operationx->setData(data); - operationx->setQuality(quality); - operationx->setSize(1.0f); - operationx->setFalloff(PROP_SMOOTH); - operationx->setSubtract(false); - operationx->setExtendBounds(extend_bounds); - - converter.addOperation(operationx); - converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0)); - - GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); - operationy->setData(data); - operationy->setQuality(quality); - operationy->setSize(1.0f); - operationy->setFalloff(PROP_SMOOTH); - operationy->setSubtract(false); - operationy->setExtendBounds(extend_bounds); - - converter.addOperation(operationy); - converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); - - GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation(); - operation->setData(data); - operation->setQuality(quality); - operation->setExtendBounds(extend_bounds); - - converter.addOperation(operation); - converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1)); - - output_operation = operation; - input_operation = operation; - } - else if (!data->bokeh) { - GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); - operationx->setData(data); - operationx->setQuality(quality); - operationx->checkOpenCL(); - operationx->setExtendBounds(extend_bounds); - - converter.addOperation(operationx); - converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); - - GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); - operationy->setData(data); - operationy->setQuality(quality); - operationy->checkOpenCL(); - operationy->setExtendBounds(extend_bounds); - - converter.addOperation(operationy); - converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); - converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); - - if (!connectedSizeSocket) { - operationx->setSize(size); - operationy->setSize(size); - } - - input_operation = operationx; - output_operation = operationy; - } - else { - GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); - operation->setData(data); - operation->setQuality(quality); - operation->setExtendBounds(extend_bounds); - - converter.addOperation(operation); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - - if (!connectedSizeSocket) { - operation->setSize(size); - } - - input_operation = operation; - output_operation = operation; - } - - if (data->gamma) { - GammaCorrectOperation *correct = new GammaCorrectOperation(); - GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); - converter.addOperation(correct); - converter.addOperation(inverse); - - converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0)); - converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0)); - converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket()); - - converter.addPreview(inverse->getOutputSocket()); - } - else { - converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket()); - - converter.addPreview(output_operation->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cc b/source/blender/compositor/nodes/COM_BokehBlurNode.cc new file mode 100644 index 00000000000..5096dbef608 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cc @@ -0,0 +1,77 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BokehBlurNode.h" +#include "COM_BokehBlurOperation.h" +#include "COM_ConvertDepthToRadiusOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_VariableSizeBokehBlurOperation.h" +#include "DNA_camera_types.h" +#include "DNA_node_types.h" +#include "DNA_object_types.h" + +BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BokehBlurNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *b_node = this->getbNode(); + + NodeInput *inputSizeSocket = this->getInputSocket(2); + + bool connectedSizeSocket = inputSizeSocket->isLinked(); + const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; + + if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) { + VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); + operation->setQuality(context.getQuality()); + operation->setThreshold(0.0f); + operation->setMaxBlur(b_node->custom4); + operation->setDoScaleSize(true); + + converter.addOperation(operation); + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + } + else { + BokehBlurOperation *operation = new BokehBlurOperation(); + operation->setQuality(context.getQuality()); + operation->setExtendBounds(extend_bounds); + + converter.addOperation(operation); + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + + // NOTE: on the bokeh blur operation the sockets are switched. + // for this reason the next two lines are correct. + // Fix for T43771 + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(3)); + converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(2)); + + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + + if (!connectedSizeSocket) { + operation->setSize(this->getInputSocket(2)->getEditorValueFloat()); + } + } +} diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp deleted file mode 100644 index 5096dbef608..00000000000 --- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BokehBlurNode.h" -#include "COM_BokehBlurOperation.h" -#include "COM_ConvertDepthToRadiusOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_VariableSizeBokehBlurOperation.h" -#include "DNA_camera_types.h" -#include "DNA_node_types.h" -#include "DNA_object_types.h" - -BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BokehBlurNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *b_node = this->getbNode(); - - NodeInput *inputSizeSocket = this->getInputSocket(2); - - bool connectedSizeSocket = inputSizeSocket->isLinked(); - const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0; - - if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) { - VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - operation->setQuality(context.getQuality()); - operation->setThreshold(0.0f); - operation->setMaxBlur(b_node->custom4); - operation->setDoScaleSize(true); - - converter.addOperation(operation); - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - } - else { - BokehBlurOperation *operation = new BokehBlurOperation(); - operation->setQuality(context.getQuality()); - operation->setExtendBounds(extend_bounds); - - converter.addOperation(operation); - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - - // NOTE: on the bokeh blur operation the sockets are switched. - // for this reason the next two lines are correct. - // Fix for T43771 - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(3)); - converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(2)); - - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - - if (!connectedSizeSocket) { - operation->setSize(this->getInputSocket(2)->getEditorValueFloat()); - } - } -} diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cc b/source/blender/compositor/nodes/COM_BokehImageNode.cc new file mode 100644 index 00000000000..87fe4979c1d --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehImageNode.cc @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BokehImageNode.h" +#include "COM_BokehImageOperation.h" +#include "COM_ExecutionSystem.h" + +BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BokehImageNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + BokehImageOperation *operation = new BokehImageOperation(); + operation->setData((NodeBokehImage *)this->getbNode()->storage); + + converter.addOperation(operation); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + + converter.addPreview(operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp deleted file mode 100644 index 87fe4979c1d..00000000000 --- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BokehImageNode.h" -#include "COM_BokehImageOperation.h" -#include "COM_ExecutionSystem.h" - -BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BokehImageNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - BokehImageOperation *operation = new BokehImageOperation(); - operation->setData((NodeBokehImage *)this->getbNode()->storage); - - converter.addOperation(operation); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - - converter.addPreview(operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cc b/source/blender/compositor/nodes/COM_BoxMaskNode.cc new file mode 100644 index 00000000000..fe59bd32939 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cc @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BoxMaskNode.h" +#include "COM_BoxMaskOperation.h" +#include "COM_ExecutionSystem.h" + +#include "COM_ScaleOperation.h" +#include "COM_SetValueOperation.h" + +BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BoxMaskNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + + BoxMaskOperation *operation; + operation = new BoxMaskOperation(); + operation->setData((NodeBoxMask *)this->getbNode()->storage); + operation->setMaskType(this->getbNode()->custom1); + converter.addOperation(operation); + + if (inputSocket->isLinked()) { + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + } + else { + /* Value operation to produce original transparent image */ + SetValueOperation *valueOperation = new SetValueOperation(); + valueOperation->setValue(0.0f); + converter.addOperation(valueOperation); + + /* Scale that image up to render resolution */ + const RenderData *rd = context.getRenderData(); + const float render_size_factor = context.getRenderPercentageAsFactor(); + ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); + + scaleOperation->setIsAspect(false); + scaleOperation->setIsCrop(false); + scaleOperation->setOffset(0.0f, 0.0f); + scaleOperation->setNewWidth(rd->xsch * render_size_factor); + scaleOperation->setNewHeight(rd->ysch * render_size_factor); + scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); + converter.addOperation(scaleOperation); + + converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); + converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + } + + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); +} diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp deleted file mode 100644 index fe59bd32939..00000000000 --- a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BoxMaskNode.h" -#include "COM_BoxMaskOperation.h" -#include "COM_ExecutionSystem.h" - -#include "COM_ScaleOperation.h" -#include "COM_SetValueOperation.h" - -BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BoxMaskNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - - BoxMaskOperation *operation; - operation = new BoxMaskOperation(); - operation->setData((NodeBoxMask *)this->getbNode()->storage); - operation->setMaskType(this->getbNode()->custom1); - converter.addOperation(operation); - - if (inputSocket->isLinked()) { - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - } - else { - /* Value operation to produce original transparent image */ - SetValueOperation *valueOperation = new SetValueOperation(); - valueOperation->setValue(0.0f); - converter.addOperation(valueOperation); - - /* Scale that image up to render resolution */ - const RenderData *rd = context.getRenderData(); - const float render_size_factor = context.getRenderPercentageAsFactor(); - ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); - - scaleOperation->setIsAspect(false); - scaleOperation->setIsCrop(false); - scaleOperation->setOffset(0.0f, 0.0f); - scaleOperation->setNewWidth(rd->xsch * render_size_factor); - scaleOperation->setNewHeight(rd->ysch * render_size_factor); - scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); - converter.addOperation(scaleOperation); - - converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); - converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - } - - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); -} diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cc b/source/blender/compositor/nodes/COM_BrightnessNode.cc new file mode 100644 index 00000000000..fcd2a6de1f4 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BrightnessNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_BrightnessNode.h" +#include "COM_BrightnessOperation.h" +#include "COM_ExecutionSystem.h" + +BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void BrightnessNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *bnode = this->getbNode(); + BrightnessOperation *operation = new BrightnessOperation(); + operation->setUsePremultiply((bnode->custom1 & 1) != 0); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp deleted file mode 100644 index fcd2a6de1f4..00000000000 --- a/source/blender/compositor/nodes/COM_BrightnessNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_BrightnessNode.h" -#include "COM_BrightnessOperation.h" -#include "COM_ExecutionSystem.h" - -BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void BrightnessNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *bnode = this->getbNode(); - BrightnessOperation *operation = new BrightnessOperation(); - operation->setUsePremultiply((bnode->custom1 & 1) != 0); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cc b/source/blender/compositor/nodes/COM_ChannelMatteNode.cc new file mode 100644 index 00000000000..598cd7b7745 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cc @@ -0,0 +1,95 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_ChannelMatteNode.h" +#include "BKE_node.h" +#include "COM_ChannelMatteOperation.h" +#include "COM_ConvertOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ChannelMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *node = this->getbNode(); + + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + + NodeOperation *convert = nullptr, *inv_convert = nullptr; + /* colorspace */ + switch (node->custom1) { + case CMP_NODE_CHANNEL_MATTE_CS_RGB: + break; + case CMP_NODE_CHANNEL_MATTE_CS_HSV: /* HSV */ + convert = new ConvertRGBToHSVOperation(); + inv_convert = new ConvertHSVToRGBOperation(); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YUV: /* YUV */ + convert = new ConvertRGBToYUVOperation(); + inv_convert = new ConvertYUVToRGBOperation(); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */ + convert = new ConvertRGBToYCCOperation(); + ((ConvertRGBToYCCOperation *)convert)->setMode(BLI_YCC_ITU_BT709); + inv_convert = new ConvertYCCToRGBOperation(); + ((ConvertYCCToRGBOperation *)inv_convert)->setMode(BLI_YCC_ITU_BT709); + break; + default: + break; + } + + ChannelMatteOperation *operation = new ChannelMatteOperation(); + /* pass the ui properties to the operation */ + operation->setSettings((NodeChroma *)node->storage, node->custom2); + converter.addOperation(operation); + + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); + converter.addOperation(operationAlpha); + + if (convert != nullptr) { + converter.addOperation(convert); + + converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0)); + converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0)); + converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0)); + } + else { + converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + } + + converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); + converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + + if (inv_convert != nullptr) { + converter.addOperation(inv_convert); + converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); + converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); + converter.addPreview(inv_convert->getOutputSocket()); + } + else { + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); + converter.addPreview(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp deleted file mode 100644 index 598cd7b7745..00000000000 --- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_ChannelMatteNode.h" -#include "BKE_node.h" -#include "COM_ChannelMatteOperation.h" -#include "COM_ConvertOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ChannelMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *node = this->getbNode(); - - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - - NodeOperation *convert = nullptr, *inv_convert = nullptr; - /* colorspace */ - switch (node->custom1) { - case CMP_NODE_CHANNEL_MATTE_CS_RGB: - break; - case CMP_NODE_CHANNEL_MATTE_CS_HSV: /* HSV */ - convert = new ConvertRGBToHSVOperation(); - inv_convert = new ConvertHSVToRGBOperation(); - break; - case CMP_NODE_CHANNEL_MATTE_CS_YUV: /* YUV */ - convert = new ConvertRGBToYUVOperation(); - inv_convert = new ConvertYUVToRGBOperation(); - break; - case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */ - convert = new ConvertRGBToYCCOperation(); - ((ConvertRGBToYCCOperation *)convert)->setMode(BLI_YCC_ITU_BT709); - inv_convert = new ConvertYCCToRGBOperation(); - ((ConvertYCCToRGBOperation *)inv_convert)->setMode(BLI_YCC_ITU_BT709); - break; - default: - break; - } - - ChannelMatteOperation *operation = new ChannelMatteOperation(); - /* pass the ui properties to the operation */ - operation->setSettings((NodeChroma *)node->storage, node->custom2); - converter.addOperation(operation); - - SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); - converter.addOperation(operationAlpha); - - if (convert != nullptr) { - converter.addOperation(convert); - - converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0)); - converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0)); - converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0)); - } - else { - converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); - converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); - } - - converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); - converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); - - if (inv_convert != nullptr) { - converter.addOperation(inv_convert); - converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); - converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); - converter.addPreview(inv_convert->getOutputSocket()); - } - else { - converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); - converter.addPreview(operationAlpha->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cc b/source/blender/compositor/nodes/COM_ChromaMatteNode.cc new file mode 100644 index 00000000000..83e88b35f92 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cc @@ -0,0 +1,65 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ChromaMatteNode.h" +#include "BKE_node.h" +#include "COM_ChromaMatteOperation.h" +#include "COM_ConvertOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ChromaMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorsnode = getbNode(); + + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeInput *inputSocketKey = this->getInputSocket(1); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + + ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation(); + ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation(); + operationRGBToYCC_Image->setMode(BLI_YCC_ITU_BT709); + operationRGBToYCC_Key->setMode(BLI_YCC_ITU_BT709); + converter.addOperation(operationRGBToYCC_Image); + converter.addOperation(operationRGBToYCC_Key); + + ChromaMatteOperation *operation = new ChromaMatteOperation(); + operation->setSettings((NodeChroma *)editorsnode->storage); + converter.addOperation(operation); + + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); + converter.addOperation(operationAlpha); + + converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0)); + converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0)); + converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0)); + converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket()); + + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); + + converter.addPreview(operationAlpha->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp deleted file mode 100644 index 83e88b35f92..00000000000 --- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ChromaMatteNode.h" -#include "BKE_node.h" -#include "COM_ChromaMatteOperation.h" -#include "COM_ConvertOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ChromaMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorsnode = getbNode(); - - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeInput *inputSocketKey = this->getInputSocket(1); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - - ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation(); - ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation(); - operationRGBToYCC_Image->setMode(BLI_YCC_ITU_BT709); - operationRGBToYCC_Key->setMode(BLI_YCC_ITU_BT709); - converter.addOperation(operationRGBToYCC_Image); - converter.addOperation(operationRGBToYCC_Key); - - ChromaMatteOperation *operation = new ChromaMatteOperation(); - operation->setSettings((NodeChroma *)editorsnode->storage); - converter.addOperation(operation); - - SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); - converter.addOperation(operationAlpha); - - converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0)); - converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0)); - converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0)); - converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket()); - - converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); - converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); - converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); - - converter.addPreview(operationAlpha->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cc b/source/blender/compositor/nodes/COM_ColorBalanceNode.cc new file mode 100644 index 00000000000..596d9631297 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cc @@ -0,0 +1,73 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorBalanceNode.h" +#include "BKE_node.h" +#include "COM_ColorBalanceASCCDLOperation.h" +#include "COM_ColorBalanceLGGOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_MixOperation.h" + +ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorBalanceNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *node = this->getbNode(); + NodeColorBalance *n = (NodeColorBalance *)node->storage; + + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputImageSocket = this->getInputSocket(1); + NodeOutput *outputSocket = this->getOutputSocket(0); + + NodeOperation *operation; + if (node->custom1 == 0) { + ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation(); + + float lift_lgg[3], gamma_inv[3]; + for (int c = 0; c < 3; c++) { + lift_lgg[c] = 2.0f - n->lift[c]; + gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; + } + + operationLGG->setGain(n->gain); + operationLGG->setLift(lift_lgg); + operationLGG->setGammaInv(gamma_inv); + operation = operationLGG; + } + else { + ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); + + float offset[3]; + copy_v3_fl(offset, n->offset_basis); + add_v3_v3(offset, n->offset); + + operationCDL->setOffset(offset); + operationCDL->setPower(n->power); + operationCDL->setSlope(n->slope); + operation = operationCDL; + } + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp deleted file mode 100644 index 596d9631297..00000000000 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorBalanceNode.h" -#include "BKE_node.h" -#include "COM_ColorBalanceASCCDLOperation.h" -#include "COM_ColorBalanceLGGOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_MixOperation.h" - -ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorBalanceNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *node = this->getbNode(); - NodeColorBalance *n = (NodeColorBalance *)node->storage; - - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputImageSocket = this->getInputSocket(1); - NodeOutput *outputSocket = this->getOutputSocket(0); - - NodeOperation *operation; - if (node->custom1 == 0) { - ColorBalanceLGGOperation *operationLGG = new ColorBalanceLGGOperation(); - - float lift_lgg[3], gamma_inv[3]; - for (int c = 0; c < 3; c++) { - lift_lgg[c] = 2.0f - n->lift[c]; - gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f; - } - - operationLGG->setGain(n->gain); - operationLGG->setLift(lift_lgg); - operationLGG->setGammaInv(gamma_inv); - operation = operationLGG; - } - else { - ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); - - float offset[3]; - copy_v3_fl(offset, n->offset_basis); - add_v3_v3(offset, n->offset); - - operationCDL->setOffset(offset); - operationCDL->setPower(n->power); - operationCDL->setSlope(n->slope); - operation = operationCDL; - } - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cc b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cc new file mode 100644 index 00000000000..92b334fddb9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cc @@ -0,0 +1,43 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorCorrectionNode.h" +#include "COM_ColorCorrectionOperation.h" +#include "COM_ExecutionSystem.h" + +ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorCorrectionNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorNode = getbNode(); + + ColorCorrectionOperation *operation = new ColorCorrectionOperation(); + operation->setData((NodeColorCorrection *)editorNode->storage); + operation->setRedChannelEnabled((editorNode->custom1 & 1) != 0); + operation->setGreenChannelEnabled((editorNode->custom1 & 2) != 0); + operation->setBlueChannelEnabled((editorNode->custom1 & 4) != 0); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp deleted file mode 100644 index 92b334fddb9..00000000000 --- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorCorrectionNode.h" -#include "COM_ColorCorrectionOperation.h" -#include "COM_ExecutionSystem.h" - -ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorCorrectionNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorNode = getbNode(); - - ColorCorrectionOperation *operation = new ColorCorrectionOperation(); - operation->setData((NodeColorCorrection *)editorNode->storage); - operation->setRedChannelEnabled((editorNode->custom1 & 1) != 0); - operation->setGreenChannelEnabled((editorNode->custom1 & 2) != 0); - operation->setBlueChannelEnabled((editorNode->custom1 & 4) != 0); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cc b/source/blender/compositor/nodes/COM_ColorCurveNode.cc new file mode 100644 index 00000000000..e1888f3f0bc --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cc @@ -0,0 +1,57 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorCurveNode.h" +#include "COM_ColorCurveOperation.h" +#include "COM_ExecutionSystem.h" + +ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorCurveNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + if (this->getInputSocket(2)->isLinked() || this->getInputSocket(3)->isLinked()) { + ColorCurveOperation *operation = new ColorCurveOperation(); + operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); + + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + } + else { + ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation(); + float col[4]; + this->getInputSocket(2)->getEditorValueColor(col); + operation->setBlackLevel(col); + this->getInputSocket(3)->getEditorValueColor(col); + operation->setWhiteLevel(col); + operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp deleted file mode 100644 index e1888f3f0bc..00000000000 --- a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorCurveNode.h" -#include "COM_ColorCurveOperation.h" -#include "COM_ExecutionSystem.h" - -ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorCurveNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - if (this->getInputSocket(2)->isLinked() || this->getInputSocket(3)->isLinked()) { - ColorCurveOperation *operation = new ColorCurveOperation(); - operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); - - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - } - else { - ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation(); - float col[4]; - this->getInputSocket(2)->getEditorValueColor(col); - operation->setBlackLevel(col); - this->getInputSocket(3)->getEditorValueColor(col); - operation->setWhiteLevel(col); - operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_ColorExposureNode.cc b/source/blender/compositor/nodes/COM_ColorExposureNode.cc new file mode 100644 index 00000000000..cd0285ac373 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorExposureNode.cc @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2020, Blender Foundation. + */ + +#include "COM_ColorExposureNode.h" +#include "COM_ColorExposureOperation.h" +#include "COM_ExecutionSystem.h" + +ExposureNode::ExposureNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ExposureNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + ExposureOperation *operation = new ExposureOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_ColorExposureNode.cpp b/source/blender/compositor/nodes/COM_ColorExposureNode.cpp deleted file mode 100644 index cd0285ac373..00000000000 --- a/source/blender/compositor/nodes/COM_ColorExposureNode.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2020, Blender Foundation. - */ - -#include "COM_ColorExposureNode.h" -#include "COM_ColorExposureOperation.h" -#include "COM_ExecutionSystem.h" - -ExposureNode::ExposureNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ExposureNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - ExposureOperation *operation = new ExposureOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cc b/source/blender/compositor/nodes/COM_ColorMatteNode.cc new file mode 100644 index 00000000000..865eee5427f --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cc @@ -0,0 +1,63 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorMatteNode.h" +#include "BKE_node.h" +#include "COM_ColorMatteOperation.h" +#include "COM_ConvertOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorsnode = getbNode(); + + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeInput *inputSocketKey = this->getInputSocket(1); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + + ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation(); + ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation(); + converter.addOperation(operationRGBToHSV_Image); + converter.addOperation(operationRGBToHSV_Key); + + ColorMatteOperation *operation = new ColorMatteOperation(); + operation->setSettings((NodeChroma *)editorsnode->storage); + converter.addOperation(operation); + + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); + converter.addOperation(operationAlpha); + + converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0)); + converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0)); + converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0)); + converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); + + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); + + converter.addPreview(operationAlpha->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp deleted file mode 100644 index 865eee5427f..00000000000 --- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorMatteNode.h" -#include "BKE_node.h" -#include "COM_ColorMatteOperation.h" -#include "COM_ConvertOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorsnode = getbNode(); - - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeInput *inputSocketKey = this->getInputSocket(1); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - - ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation(); - ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation(); - converter.addOperation(operationRGBToHSV_Image); - converter.addOperation(operationRGBToHSV_Key); - - ColorMatteOperation *operation = new ColorMatteOperation(); - operation->setSettings((NodeChroma *)editorsnode->storage); - converter.addOperation(operation); - - SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); - converter.addOperation(operationAlpha); - - converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0)); - converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0)); - converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0)); - converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); - - converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); - converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); - converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); - - converter.addPreview(operationAlpha->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ColorNode.cc b/source/blender/compositor/nodes/COM_ColorNode.cc new file mode 100644 index 00000000000..e6f8bfa01fe --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorNode.cc @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetColorOperation.h" + +ColorNode::ColorNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + SetColorOperation *operation = new SetColorOperation(); + NodeOutput *output = this->getOutputSocket(0); + float col[4]; + output->getEditorValueColor(col); + operation->setChannels(col); + converter.addOperation(operation); + + converter.mapOutputSocket(output, operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp deleted file mode 100644 index e6f8bfa01fe..00000000000 --- a/source/blender/compositor/nodes/COM_ColorNode.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetColorOperation.h" - -ColorNode::ColorNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - SetColorOperation *operation = new SetColorOperation(); - NodeOutput *output = this->getOutputSocket(0); - float col[4]; - output->getEditorValueColor(col); - operation->setChannels(col); - converter.addOperation(operation); - - converter.mapOutputSocket(output, operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cc b/source/blender/compositor/nodes/COM_ColorRampNode.cc new file mode 100644 index 00000000000..1504a76cee7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorRampNode.cc @@ -0,0 +1,52 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorRampNode.h" +#include "BKE_node.h" +#include "COM_ColorRampOperation.h" +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "DNA_texture_types.h" + +ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorRampNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + NodeOutput *outputSocketAlpha = this->getOutputSocket(1); + bNode *editorNode = this->getbNode(); + + ColorRampOperation *operation = new ColorRampOperation(); + operation->setColorBand((ColorBand *)editorNode->storage); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + SeparateChannelOperation *operation2 = new SeparateChannelOperation(); + operation2->setChannel(3); + converter.addOperation(operation2); + + converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0)); + converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp deleted file mode 100644 index 1504a76cee7..00000000000 --- a/source/blender/compositor/nodes/COM_ColorRampNode.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorRampNode.h" -#include "BKE_node.h" -#include "COM_ColorRampOperation.h" -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" -#include "DNA_texture_types.h" - -ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorRampNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - NodeOutput *outputSocketAlpha = this->getOutputSocket(1); - bNode *editorNode = this->getbNode(); - - ColorRampOperation *operation = new ColorRampOperation(); - operation->setColorBand((ColorBand *)editorNode->storage); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - SeparateChannelOperation *operation2 = new SeparateChannelOperation(); - operation2->setChannel(3); - converter.addOperation(operation2); - - converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0)); - converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cc b/source/blender/compositor/nodes/COM_ColorSpillNode.cc new file mode 100644 index 00000000000..d1a3099e998 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cc @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorSpillNode.h" +#include "BKE_node.h" +#include "COM_ColorSpillOperation.h" + +ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorSpillNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorsnode = getbNode(); + + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeInput *inputSocketFac = this->getInputSocket(1); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + + ColorSpillOperation *operation; + operation = new ColorSpillOperation(); + operation->setSettings((NodeColorspill *)editorsnode->storage); + operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling + operation->setSpillMethod(editorsnode->custom2); // Channel method + converter.addOperation(operation); + + converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); + converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp deleted file mode 100644 index d1a3099e998..00000000000 --- a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorSpillNode.h" -#include "BKE_node.h" -#include "COM_ColorSpillOperation.h" - -ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorSpillNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorsnode = getbNode(); - - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeInput *inputSocketFac = this->getInputSocket(1); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - - ColorSpillOperation *operation; - operation = new ColorSpillOperation(); - operation->setSettings((NodeColorspill *)editorsnode->storage); - operation->setSpillChannel(editorsnode->custom1 - 1); // Channel for spilling - operation->setSpillMethod(editorsnode->custom2); // Channel method - converter.addOperation(operation); - - converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0)); - converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cc b/source/blender/compositor/nodes/COM_ColorToBWNode.cc new file mode 100644 index 00000000000..4115bad5d3f --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ColorToBWNode.h" + +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" + +ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ColorToBWNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *colorSocket = this->getInputSocket(0); + NodeOutput *valueSocket = this->getOutputSocket(0); + + ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); + converter.addOperation(convertProg); + + converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0)); + converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp deleted file mode 100644 index 4115bad5d3f..00000000000 --- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ColorToBWNode.h" - -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" - -ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ColorToBWNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *colorSocket = this->getInputSocket(0); - NodeOutput *valueSocket = this->getOutputSocket(0); - - ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); - converter.addOperation(convertProg); - - converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0)); - converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cc b/source/blender/compositor/nodes/COM_CombineColorNode.cc new file mode 100644 index 00000000000..12968f06a10 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineColorNode.cc @@ -0,0 +1,89 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_CombineColorNode.h" + +#include "COM_ConvertOperation.h" + +CombineColorNode::CombineColorNode(bNode *editorNode) : Node(editorNode) +{ +} + +void CombineColorNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeInput *inputRSocket = this->getInputSocket(0); + NodeInput *inputGSocket = this->getInputSocket(1); + NodeInput *inputBSocket = this->getInputSocket(2); + NodeInput *inputASocket = this->getInputSocket(3); + NodeOutput *outputSocket = this->getOutputSocket(0); + + CombineChannelsOperation *operation = new CombineChannelsOperation(); + if (inputRSocket->isLinked()) { + operation->setResolutionInputSocketIndex(0); + } + else if (inputGSocket->isLinked()) { + operation->setResolutionInputSocketIndex(1); + } + else if (inputBSocket->isLinked()) { + operation->setResolutionInputSocketIndex(2); + } + else { + operation->setResolutionInputSocketIndex(3); + } + converter.addOperation(operation); + + converter.mapInputSocket(inputRSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputGSocket, operation->getInputSocket(1)); + converter.mapInputSocket(inputBSocket, operation->getInputSocket(2)); + converter.mapInputSocket(inputASocket, operation->getInputSocket(3)); + + NodeOperation *color_conv = getColorConverter(context); + if (color_conv) { + converter.addOperation(color_conv); + + converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket()); + } + else { + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + } +} + +NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return nullptr; /* no conversion needed */ +} + +NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return new ConvertHSVToRGBOperation(); +} + +NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext & /*context*/) const +{ + ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation(); + bNode *editorNode = this->getbNode(); + operation->setMode(editorNode->custom1); + return operation; +} + +NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return new ConvertYUVToRGBOperation(); +} diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cpp b/source/blender/compositor/nodes/COM_CombineColorNode.cpp deleted file mode 100644 index 12968f06a10..00000000000 --- a/source/blender/compositor/nodes/COM_CombineColorNode.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_CombineColorNode.h" - -#include "COM_ConvertOperation.h" - -CombineColorNode::CombineColorNode(bNode *editorNode) : Node(editorNode) -{ -} - -void CombineColorNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeInput *inputRSocket = this->getInputSocket(0); - NodeInput *inputGSocket = this->getInputSocket(1); - NodeInput *inputBSocket = this->getInputSocket(2); - NodeInput *inputASocket = this->getInputSocket(3); - NodeOutput *outputSocket = this->getOutputSocket(0); - - CombineChannelsOperation *operation = new CombineChannelsOperation(); - if (inputRSocket->isLinked()) { - operation->setResolutionInputSocketIndex(0); - } - else if (inputGSocket->isLinked()) { - operation->setResolutionInputSocketIndex(1); - } - else if (inputBSocket->isLinked()) { - operation->setResolutionInputSocketIndex(2); - } - else { - operation->setResolutionInputSocketIndex(3); - } - converter.addOperation(operation); - - converter.mapInputSocket(inputRSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputGSocket, operation->getInputSocket(1)); - converter.mapInputSocket(inputBSocket, operation->getInputSocket(2)); - converter.mapInputSocket(inputASocket, operation->getInputSocket(3)); - - NodeOperation *color_conv = getColorConverter(context); - if (color_conv) { - converter.addOperation(color_conv); - - converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket()); - } - else { - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - } -} - -NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return nullptr; /* no conversion needed */ -} - -NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return new ConvertHSVToRGBOperation(); -} - -NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext & /*context*/) const -{ - ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation(); - bNode *editorNode = this->getbNode(); - operation->setMode(editorNode->custom1); - return operation; -} - -NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return new ConvertYUVToRGBOperation(); -} diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cc b/source/blender/compositor/nodes/COM_CompositorNode.cc new file mode 100644 index 00000000000..32ac1fccec9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CompositorNode.cc @@ -0,0 +1,61 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_CompositorNode.h" +#include "COM_CompositorOperation.h" +#include "COM_ExecutionSystem.h" + +CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void CompositorNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering(); + bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; + + NodeInput *imageSocket = this->getInputSocket(0); + NodeInput *alphaSocket = this->getInputSocket(1); + NodeInput *depthSocket = this->getInputSocket(2); + + CompositorOperation *compositorOperation = new CompositorOperation(); + compositorOperation->setScene(context.getScene()); + compositorOperation->setSceneName(context.getScene()->id.name); + compositorOperation->setRenderData(context.getRenderData()); + compositorOperation->setViewName(context.getViewName()); + compositorOperation->setbNodeTree(context.getbNodeTree()); + /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ + compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); + compositorOperation->setActive(is_active); + + converter.addOperation(compositorOperation); + converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0)); + /* only use alpha link if "use alpha" is enabled */ + if (ignore_alpha) { + converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f); + } + else { + converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1)); + } + converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2)); + + converter.addNodeInputPreview(imageSocket); +} diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp deleted file mode 100644 index 32ac1fccec9..00000000000 --- a/source/blender/compositor/nodes/COM_CompositorNode.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_CompositorNode.h" -#include "COM_CompositorOperation.h" -#include "COM_ExecutionSystem.h" - -CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void CompositorNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering(); - bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; - - NodeInput *imageSocket = this->getInputSocket(0); - NodeInput *alphaSocket = this->getInputSocket(1); - NodeInput *depthSocket = this->getInputSocket(2); - - CompositorOperation *compositorOperation = new CompositorOperation(); - compositorOperation->setScene(context.getScene()); - compositorOperation->setSceneName(context.getScene()->id.name); - compositorOperation->setRenderData(context.getRenderData()); - compositorOperation->setViewName(context.getViewName()); - compositorOperation->setbNodeTree(context.getbNodeTree()); - /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ - compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); - compositorOperation->setActive(is_active); - - converter.addOperation(compositorOperation); - converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0)); - /* only use alpha link if "use alpha" is enabled */ - if (ignore_alpha) { - converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f); - } - else { - converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1)); - } - converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2)); - - converter.addNodeInputPreview(imageSocket); -} diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cc b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cc new file mode 100644 index 00000000000..2921b44c95b --- /dev/null +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cc @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_ConvertAlphaNode.h" +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" + +void ConvertAlphaNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeOperation *operation = nullptr; + bNode *node = this->getbNode(); + + /* value hardcoded in rna_nodetree.c */ + if (node->custom1 == 1) { + operation = new ConvertPremulToStraightOperation(); + } + else { + operation = new ConvertStraightToPremulOperation(); + } + + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp deleted file mode 100644 index 2921b44c95b..00000000000 --- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_ConvertAlphaNode.h" -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" - -void ConvertAlphaNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeOperation *operation = nullptr; - bNode *node = this->getbNode(); - - /* value hardcoded in rna_nodetree.c */ - if (node->custom1 == 1) { - operation = new ConvertPremulToStraightOperation(); - } - else { - operation = new ConvertStraightToPremulOperation(); - } - - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.cc b/source/blender/compositor/nodes/COM_CornerPinNode.cc new file mode 100644 index 00000000000..efe847bbfbf --- /dev/null +++ b/source/blender/compositor/nodes/COM_CornerPinNode.cc @@ -0,0 +1,55 @@ +/* This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2014, Blender Foundation. + */ + +#include "COM_CornerPinNode.h" +#include "COM_ExecutionSystem.h" + +#include "COM_PlaneCornerPinOperation.h" + +CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode) +{ +} + +void CornerPinNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *input_image = this->getInputSocket(0); + /* note: socket order differs between UI node and operations: + * bNode uses intuitive order following top-down layout: + * upper-left, upper-right, lower-left, lower-right + * Operations use same order as the tracking blenkernel functions expect: + * lower-left, lower-right, upper-right, upper-left + */ + const int node_corner_index[4] = {3, 4, 2, 1}; + + NodeOutput *output_warped_image = this->getOutputSocket(0); + NodeOutput *output_plane = this->getOutputSocket(1); + + PlaneCornerPinWarpImageOperation *warp_image_operation = new PlaneCornerPinWarpImageOperation(); + converter.addOperation(warp_image_operation); + PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation(); + converter.addOperation(plane_mask_operation); + + converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0)); + for (int i = 0; i < 4; i++) { + NodeInput *corner_input = getInputSocket(node_corner_index[i]); + converter.mapInputSocket(corner_input, warp_image_operation->getInputSocket(i + 1)); + converter.mapInputSocket(corner_input, plane_mask_operation->getInputSocket(i)); + } + converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket()); + converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.cpp b/source/blender/compositor/nodes/COM_CornerPinNode.cpp deleted file mode 100644 index efe847bbfbf..00000000000 --- a/source/blender/compositor/nodes/COM_CornerPinNode.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2014, Blender Foundation. - */ - -#include "COM_CornerPinNode.h" -#include "COM_ExecutionSystem.h" - -#include "COM_PlaneCornerPinOperation.h" - -CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode) -{ -} - -void CornerPinNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *input_image = this->getInputSocket(0); - /* note: socket order differs between UI node and operations: - * bNode uses intuitive order following top-down layout: - * upper-left, upper-right, lower-left, lower-right - * Operations use same order as the tracking blenkernel functions expect: - * lower-left, lower-right, upper-right, upper-left - */ - const int node_corner_index[4] = {3, 4, 2, 1}; - - NodeOutput *output_warped_image = this->getOutputSocket(0); - NodeOutput *output_plane = this->getOutputSocket(1); - - PlaneCornerPinWarpImageOperation *warp_image_operation = new PlaneCornerPinWarpImageOperation(); - converter.addOperation(warp_image_operation); - PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation(); - converter.addOperation(plane_mask_operation); - - converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0)); - for (int i = 0; i < 4; i++) { - NodeInput *corner_input = getInputSocket(node_corner_index[i]); - converter.mapInputSocket(corner_input, warp_image_operation->getInputSocket(i + 1)); - converter.mapInputSocket(corner_input, plane_mask_operation->getInputSocket(i)); - } - converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket()); - converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_CropNode.cc b/source/blender/compositor/nodes/COM_CropNode.cc new file mode 100644 index 00000000000..0f0883b0151 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CropNode.cc @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_CropNode.h" +#include "COM_CropOperation.h" + +CropNode::CropNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void CropNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + 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); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp deleted file mode 100644 index 0f0883b0151..00000000000 --- a/source/blender/compositor/nodes/COM_CropNode.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_CropNode.h" -#include "COM_CropOperation.h" - -CropNode::CropNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void CropNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - 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); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cc b/source/blender/compositor/nodes/COM_CryptomatteNode.cc new file mode 100644 index 00000000000..27ef98af8f3 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cc @@ -0,0 +1,80 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2018, Blender Foundation. + */ + +#include "COM_CryptomatteNode.h" +#include "COM_ConvertOperation.h" +#include "COM_CryptomatteOperation.h" + +#include "BLI_assert.h" +#include "BLI_hash_mm3.h" +#include "BLI_listbase.h" +#include "BLI_string.h" + +#include "COM_SetAlphaMultiplyOperation.h" +#include + +CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void CryptomatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + NodeOutput *outputSocketPick = this->getOutputSocket(2); + + bNode *node = this->getbNode(); + NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage; + + CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1); + if (cryptoMatteSettings) { + LISTBASE_FOREACH (CryptomatteEntry *, cryptomatte_entry, &cryptoMatteSettings->entries) { + operation->addObjectIndex(cryptomatte_entry->encoded_hash); + } + } + + converter.addOperation(operation); + + for (int i = 0; i < getNumberOfInputSockets() - 1; i++) { + converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); + } + + SeparateChannelOperation *separateOperation = new SeparateChannelOperation; + separateOperation->setChannel(3); + converter.addOperation(separateOperation); + + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); + converter.addOperation(operationAlpha); + + converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); + converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); + + SetAlphaMultiplyOperation *clearAlphaOperation = new SetAlphaMultiplyOperation(); + converter.addOperation(clearAlphaOperation); + converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); + + converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0)); + + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); + converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp deleted file mode 100644 index 27ef98af8f3..00000000000 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2018, Blender Foundation. - */ - -#include "COM_CryptomatteNode.h" -#include "COM_ConvertOperation.h" -#include "COM_CryptomatteOperation.h" - -#include "BLI_assert.h" -#include "BLI_hash_mm3.h" -#include "BLI_listbase.h" -#include "BLI_string.h" - -#include "COM_SetAlphaMultiplyOperation.h" -#include - -CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void CryptomatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - NodeOutput *outputSocketPick = this->getOutputSocket(2); - - bNode *node = this->getbNode(); - NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage; - - CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1); - if (cryptoMatteSettings) { - LISTBASE_FOREACH (CryptomatteEntry *, cryptomatte_entry, &cryptoMatteSettings->entries) { - operation->addObjectIndex(cryptomatte_entry->encoded_hash); - } - } - - converter.addOperation(operation); - - for (int i = 0; i < getNumberOfInputSockets() - 1; i++) { - converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); - } - - SeparateChannelOperation *separateOperation = new SeparateChannelOperation; - separateOperation->setChannel(3); - converter.addOperation(separateOperation); - - SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); - converter.addOperation(operationAlpha); - - converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); - converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); - - SetAlphaMultiplyOperation *clearAlphaOperation = new SetAlphaMultiplyOperation(); - converter.addOperation(clearAlphaOperation); - converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); - - converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0)); - - converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); - converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); - converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); - converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cc b/source/blender/compositor/nodes/COM_DefocusNode.cc new file mode 100644 index 00000000000..393b1f2dabb --- /dev/null +++ b/source/blender/compositor/nodes/COM_DefocusNode.cc @@ -0,0 +1,143 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DefocusNode.h" +#include "COM_BokehImageOperation.h" +#include "COM_ConvertDepthToRadiusOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_FastGaussianBlurOperation.h" +#include "COM_GammaCorrectOperation.h" +#include "COM_MathBaseOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_VariableSizeBokehBlurOperation.h" +#include "DNA_camera_types.h" +#include "DNA_node_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DefocusNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *node = this->getbNode(); + NodeDefocus *data = (NodeDefocus *)node->storage; + Scene *scene = node->id ? (Scene *)node->id : context.getScene(); + Object *camob = scene ? scene->camera : nullptr; + + 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(); + + converter.addOperation(multiply); + converter.addOperation(multiplier); + converter.addOperation(maxRadius); + converter.addOperation(minimize); + + converter.mapInputSocket(getInputSocket(1), multiply->getInputSocket(0)); + converter.addLink(multiplier->getOutputSocket(), multiply->getInputSocket(1)); + converter.addLink(multiply->getOutputSocket(), minimize->getInputSocket(0)); + converter.addLink(maxRadius->getOutputSocket(), minimize->getInputSocket(1)); + + radiusOperation = minimize; + } + else { + ConvertDepthToRadiusOperation *radius_op = new ConvertDepthToRadiusOperation(); + radius_op->setCameraObject(camob); + radius_op->setfStop(data->fstop); + radius_op->setMaxRadius(data->maxblur); + converter.addOperation(radius_op); + + converter.mapInputSocket(getInputSocket(1), radius_op->getInputSocket(0)); + + FastGaussianBlurValueOperation *blur = new FastGaussianBlurValueOperation(); + /* maintain close pixels so far Z values don't bleed into the foreground */ + blur->setOverlay(FAST_GAUSS_OVERLAY_MIN); + converter.addOperation(blur); + + converter.addLink(radius_op->getOutputSocket(0), blur->getInputSocket(0)); + radius_op->setPostBlur(blur); + + radiusOperation = blur; + } + + 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; + + BokehImageOperation *bokeh = new BokehImageOperation(); + bokeh->setData(bokehdata); + bokeh->deleteDataOnFinish(); + converter.addOperation(bokeh); + +#ifdef COM_DEFOCUS_SEARCH + InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation(); + search->setMaxBlur(data->maxblur); + converter.addOperation(search); + + converter.addLink(radiusOperation->getOutputSocket(0), search->getInputSocket(0)); +#endif + + VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); + if (data->preview) { + operation->setQuality(COM_QUALITY_LOW); + } + else { + operation->setQuality(context.getQuality()); + } + operation->setMaxBlur(data->maxblur); + operation->setThreshold(data->bthresh); + converter.addOperation(operation); + + converter.addLink(bokeh->getOutputSocket(), operation->getInputSocket(1)); + converter.addLink(radiusOperation->getOutputSocket(), operation->getInputSocket(2)); +#ifdef COM_DEFOCUS_SEARCH + converter.addLink(search->getOutputSocket(), operation->getInputSocket(3)); +#endif + + if (data->gamco) { + GammaCorrectOperation *correct = new GammaCorrectOperation(); + converter.addOperation(correct); + GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); + converter.addOperation(inverse); + + converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0)); + converter.addLink(correct->getOutputSocket(), operation->getInputSocket(0)); + converter.addLink(operation->getOutputSocket(), inverse->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket()); + } + else { + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp deleted file mode 100644 index 393b1f2dabb..00000000000 --- a/source/blender/compositor/nodes/COM_DefocusNode.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DefocusNode.h" -#include "COM_BokehImageOperation.h" -#include "COM_ConvertDepthToRadiusOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_FastGaussianBlurOperation.h" -#include "COM_GammaCorrectOperation.h" -#include "COM_MathBaseOperation.h" -#include "COM_SetValueOperation.h" -#include "COM_VariableSizeBokehBlurOperation.h" -#include "DNA_camera_types.h" -#include "DNA_node_types.h" -#include "DNA_object_types.h" -#include "DNA_scene_types.h" - -DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DefocusNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *node = this->getbNode(); - NodeDefocus *data = (NodeDefocus *)node->storage; - Scene *scene = node->id ? (Scene *)node->id : context.getScene(); - Object *camob = scene ? scene->camera : nullptr; - - 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(); - - converter.addOperation(multiply); - converter.addOperation(multiplier); - converter.addOperation(maxRadius); - converter.addOperation(minimize); - - converter.mapInputSocket(getInputSocket(1), multiply->getInputSocket(0)); - converter.addLink(multiplier->getOutputSocket(), multiply->getInputSocket(1)); - converter.addLink(multiply->getOutputSocket(), minimize->getInputSocket(0)); - converter.addLink(maxRadius->getOutputSocket(), minimize->getInputSocket(1)); - - radiusOperation = minimize; - } - else { - ConvertDepthToRadiusOperation *radius_op = new ConvertDepthToRadiusOperation(); - radius_op->setCameraObject(camob); - radius_op->setfStop(data->fstop); - radius_op->setMaxRadius(data->maxblur); - converter.addOperation(radius_op); - - converter.mapInputSocket(getInputSocket(1), radius_op->getInputSocket(0)); - - FastGaussianBlurValueOperation *blur = new FastGaussianBlurValueOperation(); - /* maintain close pixels so far Z values don't bleed into the foreground */ - blur->setOverlay(FAST_GAUSS_OVERLAY_MIN); - converter.addOperation(blur); - - converter.addLink(radius_op->getOutputSocket(0), blur->getInputSocket(0)); - radius_op->setPostBlur(blur); - - radiusOperation = blur; - } - - 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; - - BokehImageOperation *bokeh = new BokehImageOperation(); - bokeh->setData(bokehdata); - bokeh->deleteDataOnFinish(); - converter.addOperation(bokeh); - -#ifdef COM_DEFOCUS_SEARCH - InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation(); - search->setMaxBlur(data->maxblur); - converter.addOperation(search); - - converter.addLink(radiusOperation->getOutputSocket(0), search->getInputSocket(0)); -#endif - - VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); - if (data->preview) { - operation->setQuality(COM_QUALITY_LOW); - } - else { - operation->setQuality(context.getQuality()); - } - operation->setMaxBlur(data->maxblur); - operation->setThreshold(data->bthresh); - converter.addOperation(operation); - - converter.addLink(bokeh->getOutputSocket(), operation->getInputSocket(1)); - converter.addLink(radiusOperation->getOutputSocket(), operation->getInputSocket(2)); -#ifdef COM_DEFOCUS_SEARCH - converter.addLink(search->getOutputSocket(), operation->getInputSocket(3)); -#endif - - if (data->gamco) { - GammaCorrectOperation *correct = new GammaCorrectOperation(); - converter.addOperation(correct); - GammaUncorrectOperation *inverse = new GammaUncorrectOperation(); - converter.addOperation(inverse); - - converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0)); - converter.addLink(correct->getOutputSocket(), operation->getInputSocket(0)); - converter.addLink(operation->getOutputSocket(), inverse->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket()); - } - else { - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_DenoiseNode.cc b/source/blender/compositor/nodes/COM_DenoiseNode.cc new file mode 100644 index 00000000000..1aae81e1e7b --- /dev/null +++ b/source/blender/compositor/nodes/COM_DenoiseNode.cc @@ -0,0 +1,43 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2019, Blender Foundation. + */ +#include "COM_DenoiseNode.h" +#include "COM_DenoiseOperation.h" +#include "COM_MixOperation.h" +#include "COM_SetValueOperation.h" +#include "DNA_node_types.h" + +DenoiseNode::DenoiseNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DenoiseNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *node = this->getbNode(); + NodeDenoise *denoise = (NodeDenoise *)node->storage; + + DenoiseOperation *operation = new DenoiseOperation(); + converter.addOperation(operation); + operation->setDenoiseSettings(denoise); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_DenoiseNode.cpp b/source/blender/compositor/nodes/COM_DenoiseNode.cpp deleted file mode 100644 index 1aae81e1e7b..00000000000 --- a/source/blender/compositor/nodes/COM_DenoiseNode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2019, Blender Foundation. - */ -#include "COM_DenoiseNode.h" -#include "COM_DenoiseOperation.h" -#include "COM_MixOperation.h" -#include "COM_SetValueOperation.h" -#include "DNA_node_types.h" - -DenoiseNode::DenoiseNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DenoiseNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *node = this->getbNode(); - NodeDenoise *denoise = (NodeDenoise *)node->storage; - - DenoiseOperation *operation = new DenoiseOperation(); - converter.addOperation(operation); - operation->setDenoiseSettings(denoise); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cc b/source/blender/compositor/nodes/COM_DespeckleNode.cc new file mode 100644 index 00000000000..58734917831 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DespeckleNode.cc @@ -0,0 +1,48 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DespeckleNode.h" +#include "BLI_math.h" +#include "COM_DespeckleOperation.h" +#include "COM_ExecutionSystem.h" +#include "DNA_scene_types.h" + +DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DespeckleNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorNode = this->getbNode(); + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputImageSocket = this->getInputSocket(1); + NodeOutput *outputSocket = this->getOutputSocket(0); + + DespeckleOperation *operation = new DespeckleOperation(); + operation->setThreshold(editorNode->custom3); + operation->setThresholdNeighbor(editorNode->custom4); + converter.addOperation(operation); + + converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputSocket, operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + + converter.addPreview(operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp deleted file mode 100644 index 58734917831..00000000000 --- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DespeckleNode.h" -#include "BLI_math.h" -#include "COM_DespeckleOperation.h" -#include "COM_ExecutionSystem.h" -#include "DNA_scene_types.h" - -DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DespeckleNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorNode = this->getbNode(); - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputImageSocket = this->getInputSocket(1); - NodeOutput *outputSocket = this->getOutputSocket(0); - - DespeckleOperation *operation = new DespeckleOperation(); - operation->setThreshold(editorNode->custom3); - operation->setThresholdNeighbor(editorNode->custom4); - converter.addOperation(operation); - - converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputSocket, operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - - converter.addPreview(operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cc b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cc new file mode 100644 index 00000000000..3d538e9b4a0 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cc @@ -0,0 +1,54 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DifferenceMatteNode.h" +#include "BKE_node.h" +#include "COM_DifferenceMatteOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DifferenceMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputSocket2 = this->getInputSocket(1); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + bNode *editorNode = this->getbNode(); + + DifferenceMatteOperation *operationSet = new DifferenceMatteOperation(); + operationSet->setSettings((NodeChroma *)editorNode->storage); + converter.addOperation(operationSet); + + converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); + converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1)); + converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); + + SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); + + converter.addPreview(operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp deleted file mode 100644 index 3d538e9b4a0..00000000000 --- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DifferenceMatteNode.h" -#include "BKE_node.h" -#include "COM_DifferenceMatteOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DifferenceMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputSocket2 = this->getInputSocket(1); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - bNode *editorNode = this->getbNode(); - - DifferenceMatteOperation *operationSet = new DifferenceMatteOperation(); - operationSet->setSettings((NodeChroma *)editorNode->storage); - converter.addOperation(operationSet); - - converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); - converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1)); - converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); - - SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); - - converter.addPreview(operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cc b/source/blender/compositor/nodes/COM_DilateErodeNode.cc new file mode 100644 index 00000000000..e90707618e5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cc @@ -0,0 +1,149 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DilateErodeNode.h" +#include "BLI_math.h" +#include "COM_AntiAliasOperation.h" +#include "COM_DilateErodeOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" + +DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode) +{ + /* initialize node data */ + NodeBlurData *data = &m_alpha_blur; + memset(data, 0, sizeof(NodeBlurData)); + data->filtertype = R_FILTER_GAUSS; + + if (editorNode->custom2 > 0) { + data->sizex = data->sizey = editorNode->custom2; + } + else { + data->sizex = data->sizey = -editorNode->custom2; + } +} + +void DilateErodeNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + + bNode *editorNode = this->getbNode(); + if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { + DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation(); + operation->setDistance(editorNode->custom2); + operation->setInset(editorNode->custom3); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + + if (editorNode->custom3 < 2.0f) { + AntiAliasOperation *antiAlias = new AntiAliasOperation(); + converter.addOperation(antiAlias); + + converter.addLink(operation->getOutputSocket(), antiAlias->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), antiAlias->getOutputSocket(0)); + } + else { + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + } + else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) { + if (editorNode->custom2 > 0) { + DilateDistanceOperation *operation = new DilateDistanceOperation(); + operation->setDistance(editorNode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + else { + ErodeDistanceOperation *operation = new ErodeDistanceOperation(); + operation->setDistance(-editorNode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + } + else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) { + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context.getQuality(); + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(&m_alpha_blur); + operationx->setQuality(quality); + operationx->setFalloff(PROP_SMOOTH); + converter.addOperation(operationx); + + converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0)); + // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input + // yet + + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(&m_alpha_blur); + operationy->setQuality(quality); + operationy->setFalloff(PROP_SMOOTH); + converter.addOperation(operationy); + + converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); + // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input + // yet + converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket()); + + converter.addPreview(operationy->getOutputSocket()); + + /* TODO? */ + /* see gaussian blue node for original usage */ +#if 0 + if (!connectedSizeSocket) { + operationx->setSize(size); + operationy->setSize(size); + } +#else + operationx->setSize(1.0f); + operationy->setSize(1.0f); +#endif + operationx->setSubtract(editorNode->custom2 < 0); + operationy->setSubtract(editorNode->custom2 < 0); + + if (editorNode->storage) { + NodeDilateErode *data_storage = (NodeDilateErode *)editorNode->storage; + operationx->setFalloff(data_storage->falloff); + operationy->setFalloff(data_storage->falloff); + } + } + else { + if (editorNode->custom2 > 0) { + DilateStepOperation *operation = new DilateStepOperation(); + operation->setIterations(editorNode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + else { + ErodeStepOperation *operation = new ErodeStepOperation(); + operation->setIterations(-editorNode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + } +} diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp deleted file mode 100644 index e90707618e5..00000000000 --- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DilateErodeNode.h" -#include "BLI_math.h" -#include "COM_AntiAliasOperation.h" -#include "COM_DilateErodeOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_GaussianAlphaXBlurOperation.h" -#include "COM_GaussianAlphaYBlurOperation.h" - -DilateErodeNode::DilateErodeNode(bNode *editorNode) : Node(editorNode) -{ - /* initialize node data */ - NodeBlurData *data = &m_alpha_blur; - memset(data, 0, sizeof(NodeBlurData)); - data->filtertype = R_FILTER_GAUSS; - - if (editorNode->custom2 > 0) { - data->sizex = data->sizey = editorNode->custom2; - } - else { - data->sizex = data->sizey = -editorNode->custom2; - } -} - -void DilateErodeNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - - bNode *editorNode = this->getbNode(); - if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_THRESH) { - DilateErodeThresholdOperation *operation = new DilateErodeThresholdOperation(); - operation->setDistance(editorNode->custom2); - operation->setInset(editorNode->custom3); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - - if (editorNode->custom3 < 2.0f) { - AntiAliasOperation *antiAlias = new AntiAliasOperation(); - converter.addOperation(antiAlias); - - converter.addLink(operation->getOutputSocket(), antiAlias->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), antiAlias->getOutputSocket(0)); - } - else { - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - } - else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE) { - if (editorNode->custom2 > 0) { - DilateDistanceOperation *operation = new DilateDistanceOperation(); - operation->setDistance(editorNode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - else { - ErodeDistanceOperation *operation = new ErodeDistanceOperation(); - operation->setDistance(-editorNode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - } - else if (editorNode->custom1 == CMP_NODE_DILATEERODE_DISTANCE_FEATHER) { - /* this uses a modified gaussian blur function otherwise its far too slow */ - CompositorQuality quality = context.getQuality(); - - GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); - operationx->setData(&m_alpha_blur); - operationx->setQuality(quality); - operationx->setFalloff(PROP_SMOOTH); - converter.addOperation(operationx); - - converter.mapInputSocket(getInputSocket(0), operationx->getInputSocket(0)); - // converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1)); // no size input - // yet - - GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); - operationy->setData(&m_alpha_blur); - operationy->setQuality(quality); - operationy->setFalloff(PROP_SMOOTH); - converter.addOperation(operationy); - - converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); - // converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1)); // no size input - // yet - converter.mapOutputSocket(getOutputSocket(0), operationy->getOutputSocket()); - - converter.addPreview(operationy->getOutputSocket()); - - /* TODO? */ - /* see gaussian blue node for original usage */ -#if 0 - if (!connectedSizeSocket) { - operationx->setSize(size); - operationy->setSize(size); - } -#else - operationx->setSize(1.0f); - operationy->setSize(1.0f); -#endif - operationx->setSubtract(editorNode->custom2 < 0); - operationy->setSubtract(editorNode->custom2 < 0); - - if (editorNode->storage) { - NodeDilateErode *data_storage = (NodeDilateErode *)editorNode->storage; - operationx->setFalloff(data_storage->falloff); - operationy->setFalloff(data_storage->falloff); - } - } - else { - if (editorNode->custom2 > 0) { - DilateStepOperation *operation = new DilateStepOperation(); - operation->setIterations(editorNode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - else { - ErodeStepOperation *operation = new ErodeStepOperation(); - operation->setIterations(-editorNode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - } -} diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cc b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cc new file mode 100644 index 00000000000..f8d0eaf4675 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DirectionalBlurNode.h" +#include "COM_DirectionalBlurOperation.h" +#include "COM_ExecutionSystem.h" +#include "DNA_node_types.h" + +DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DirectionalBlurNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeDBlurData *data = (NodeDBlurData *)this->getbNode()->storage; + DirectionalBlurOperation *operation = new DirectionalBlurOperation(); + operation->setQuality(context.getQuality()); + operation->setData(data); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp deleted file mode 100644 index f8d0eaf4675..00000000000 --- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DirectionalBlurNode.h" -#include "COM_DirectionalBlurOperation.h" -#include "COM_ExecutionSystem.h" -#include "DNA_node_types.h" - -DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DirectionalBlurNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeDBlurData *data = (NodeDBlurData *)this->getbNode()->storage; - DirectionalBlurOperation *operation = new DirectionalBlurOperation(); - operation->setQuality(context.getQuality()); - operation->setData(data); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cc b/source/blender/compositor/nodes/COM_DisplaceNode.cc new file mode 100644 index 00000000000..0c0c3aad646 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DisplaceNode.cc @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DisplaceNode.h" +#include "COM_DisplaceOperation.h" +#include "COM_DisplaceSimpleOperation.h" +#include "COM_ExecutionSystem.h" + +DisplaceNode::DisplaceNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DisplaceNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeOperation *operation; + if (context.getQuality() == COM_QUALITY_LOW) { + operation = new DisplaceSimpleOperation(); + } + else { + operation = new DisplaceOperation(); + } + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp deleted file mode 100644 index 0c0c3aad646..00000000000 --- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DisplaceNode.h" -#include "COM_DisplaceOperation.h" -#include "COM_DisplaceSimpleOperation.h" -#include "COM_ExecutionSystem.h" - -DisplaceNode::DisplaceNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DisplaceNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeOperation *operation; - if (context.getQuality() == COM_QUALITY_LOW) { - operation = new DisplaceSimpleOperation(); - } - else { - operation = new DisplaceOperation(); - } - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cc b/source/blender/compositor/nodes/COM_DistanceMatteNode.cc new file mode 100644 index 00000000000..37aeb5c8504 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cc @@ -0,0 +1,98 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DistanceMatteNode.h" +#include "BKE_node.h" +#include "COM_ConvertOperation.h" +#include "COM_DistanceRGBMatteOperation.h" +#include "COM_DistanceYCCMatteOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DistanceMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorsnode = getbNode(); + NodeChroma *storage = (NodeChroma *)editorsnode->storage; + + NodeInput *inputSocketImage = this->getInputSocket(0); + NodeInput *inputSocketKey = this->getInputSocket(1); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); + converter.addOperation(operationAlpha); + + /* work in RGB color space */ + NodeOperation *operation; + if (storage->channel == 1) { + DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation(); + matte->setSettings(storage); + converter.addOperation(matte); + + converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0)); + converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); + + converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1)); + + operation = matte; + } + /* work in YCbCr color space */ + else { + DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation(); + matte->setSettings(storage); + converter.addOperation(matte); + + ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); + ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); + operationYCCImage->setMode(BLI_YCC_ITU_BT709); + operationYCCMatte->setMode(BLI_YCC_ITU_BT709); + converter.addOperation(operationYCCImage); + converter.addOperation(operationYCCMatte); + + converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0)); + converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0)); + converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0)); + + converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0)); + converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1)); + + operation = matte; + } + + converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); + converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + + if (storage->channel != 1) { + ConvertYCCToRGBOperation *inv_convert = new ConvertYCCToRGBOperation(); + inv_convert->setMode(BLI_YCC_ITU_BT709); + + converter.addOperation(inv_convert); + converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); + converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); + converter.addPreview(inv_convert->getOutputSocket()); + } + else { + converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); + converter.addPreview(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp deleted file mode 100644 index 37aeb5c8504..00000000000 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DistanceMatteNode.h" -#include "BKE_node.h" -#include "COM_ConvertOperation.h" -#include "COM_DistanceRGBMatteOperation.h" -#include "COM_DistanceYCCMatteOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DistanceMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorsnode = getbNode(); - NodeChroma *storage = (NodeChroma *)editorsnode->storage; - - NodeInput *inputSocketImage = this->getInputSocket(0); - NodeInput *inputSocketKey = this->getInputSocket(1); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - - SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); - converter.addOperation(operationAlpha); - - /* work in RGB color space */ - NodeOperation *operation; - if (storage->channel == 1) { - DistanceRGBMatteOperation *matte = new DistanceRGBMatteOperation(); - matte->setSettings(storage); - converter.addOperation(matte); - - converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0)); - converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); - - converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1)); - - operation = matte; - } - /* work in YCbCr color space */ - else { - DistanceYCCMatteOperation *matte = new DistanceYCCMatteOperation(); - matte->setSettings(storage); - converter.addOperation(matte); - - ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation(); - ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation(); - operationYCCImage->setMode(BLI_YCC_ITU_BT709); - operationYCCMatte->setMode(BLI_YCC_ITU_BT709); - converter.addOperation(operationYCCImage); - converter.addOperation(operationYCCMatte); - - converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0)); - converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0)); - converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0)); - - converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0)); - converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1)); - - operation = matte; - } - - converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0)); - converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1)); - - if (storage->channel != 1) { - ConvertYCCToRGBOperation *inv_convert = new ConvertYCCToRGBOperation(); - inv_convert->setMode(BLI_YCC_ITU_BT709); - - converter.addOperation(inv_convert); - converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0)); - converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket()); - converter.addPreview(inv_convert->getOutputSocket()); - } - else { - converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket()); - converter.addPreview(operationAlpha->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cc b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cc new file mode 100644 index 00000000000..907a9f49353 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cc @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_DoubleEdgeMaskNode.h" +#include "COM_DoubleEdgeMaskOperation.h" +#include "COM_ExecutionSystem.h" + +DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + DoubleEdgeMaskOperation *operation; + bNode *bnode = this->getbNode(); + + operation = new DoubleEdgeMaskOperation(); + operation->setAdjecentOnly(bnode->custom1); + operation->setKeepInside(bnode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp deleted file mode 100644 index 907a9f49353..00000000000 --- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_DoubleEdgeMaskNode.h" -#include "COM_DoubleEdgeMaskOperation.h" -#include "COM_ExecutionSystem.h" - -DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - DoubleEdgeMaskOperation *operation; - bNode *bnode = this->getbNode(); - - operation = new DoubleEdgeMaskOperation(); - operation->setAdjecentOnly(bnode->custom1); - operation->setKeepInside(bnode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cc b/source/blender/compositor/nodes/COM_EllipseMaskNode.cc new file mode 100644 index 00000000000..1ae855c0f1d --- /dev/null +++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cc @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_EllipseMaskNode.h" +#include "COM_EllipseMaskOperation.h" +#include "COM_ExecutionSystem.h" + +#include "COM_ScaleOperation.h" +#include "COM_SetValueOperation.h" + +EllipseMaskNode::EllipseMaskNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void EllipseMaskNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + + EllipseMaskOperation *operation; + operation = new EllipseMaskOperation(); + operation->setData((NodeEllipseMask *)this->getbNode()->storage); + operation->setMaskType(this->getbNode()->custom1); + converter.addOperation(operation); + + if (inputSocket->isLinked()) { + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + } + else { + /* Value operation to produce original transparent image */ + SetValueOperation *valueOperation = new SetValueOperation(); + valueOperation->setValue(0.0f); + converter.addOperation(valueOperation); + + /* Scale that image up to render resolution */ + const RenderData *rd = context.getRenderData(); + const float render_size_factor = context.getRenderPercentageAsFactor(); + ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); + + scaleOperation->setIsAspect(false); + scaleOperation->setIsCrop(false); + scaleOperation->setOffset(0.0f, 0.0f); + scaleOperation->setNewWidth(rd->xsch * render_size_factor); + scaleOperation->setNewHeight(rd->ysch * render_size_factor); + scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); + converter.addOperation(scaleOperation); + + converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); + converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + } + + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); +} diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp deleted file mode 100644 index 1ae855c0f1d..00000000000 --- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_EllipseMaskNode.h" -#include "COM_EllipseMaskOperation.h" -#include "COM_ExecutionSystem.h" - -#include "COM_ScaleOperation.h" -#include "COM_SetValueOperation.h" - -EllipseMaskNode::EllipseMaskNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void EllipseMaskNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - - EllipseMaskOperation *operation; - operation = new EllipseMaskOperation(); - operation->setData((NodeEllipseMask *)this->getbNode()->storage); - operation->setMaskType(this->getbNode()->custom1); - converter.addOperation(operation); - - if (inputSocket->isLinked()) { - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - } - else { - /* Value operation to produce original transparent image */ - SetValueOperation *valueOperation = new SetValueOperation(); - valueOperation->setValue(0.0f); - converter.addOperation(valueOperation); - - /* Scale that image up to render resolution */ - const RenderData *rd = context.getRenderData(); - const float render_size_factor = context.getRenderPercentageAsFactor(); - ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation(); - - scaleOperation->setIsAspect(false); - scaleOperation->setIsCrop(false); - scaleOperation->setOffset(0.0f, 0.0f); - scaleOperation->setNewWidth(rd->xsch * render_size_factor); - scaleOperation->setNewHeight(rd->ysch * render_size_factor); - scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); - converter.addOperation(scaleOperation); - - converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0)); - converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - } - - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); -} diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc b/source/blender/compositor/nodes/COM_FilterNode.cc new file mode 100644 index 00000000000..1147c11794f --- /dev/null +++ b/source/blender/compositor/nodes/COM_FilterNode.cc @@ -0,0 +1,96 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_FilterNode.h" +#include "BKE_node.h" +#include "COM_ConvolutionEdgeFilterOperation.h" +#include "COM_ConvolutionFilterOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_MixOperation.h" + +FilterNode::FilterNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void FilterNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputImageSocket = this->getInputSocket(1); + NodeOutput *outputSocket = this->getOutputSocket(0); + ConvolutionFilterOperation *operation = nullptr; + + 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 ConvolutionEdgeFilterOperation(); + 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; + } + converter.addOperation(operation); + + converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputSocket, operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + + converter.addPreview(operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp deleted file mode 100644 index 1147c11794f..00000000000 --- a/source/blender/compositor/nodes/COM_FilterNode.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_FilterNode.h" -#include "BKE_node.h" -#include "COM_ConvolutionEdgeFilterOperation.h" -#include "COM_ConvolutionFilterOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_MixOperation.h" - -FilterNode::FilterNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void FilterNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputImageSocket = this->getInputSocket(1); - NodeOutput *outputSocket = this->getOutputSocket(0); - ConvolutionFilterOperation *operation = nullptr; - - 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 ConvolutionEdgeFilterOperation(); - 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; - } - converter.addOperation(operation); - - converter.mapInputSocket(inputImageSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputSocket, operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - - converter.addPreview(operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_FlipNode.cc b/source/blender/compositor/nodes/COM_FlipNode.cc new file mode 100644 index 00000000000..d89e6b7b844 --- /dev/null +++ b/source/blender/compositor/nodes/COM_FlipNode.cc @@ -0,0 +1,54 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_FlipNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_FlipOperation.h" + +FlipNode::FlipNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void FlipNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *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; + } + + converter.addOperation(operation); + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp deleted file mode 100644 index d89e6b7b844..00000000000 --- a/source/blender/compositor/nodes/COM_FlipNode.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_FlipNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_FlipOperation.h" - -FlipNode::FlipNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void FlipNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *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; - } - - converter.addOperation(operation); - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_GammaNode.cc b/source/blender/compositor/nodes/COM_GammaNode.cc new file mode 100644 index 00000000000..1ce17faa0dc --- /dev/null +++ b/source/blender/compositor/nodes/COM_GammaNode.cc @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_GammaNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_GammaOperation.h" + +GammaNode::GammaNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void GammaNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + GammaOperation *operation = new GammaOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp deleted file mode 100644 index 1ce17faa0dc..00000000000 --- a/source/blender/compositor/nodes/COM_GammaNode.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_GammaNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_GammaOperation.h" - -GammaNode::GammaNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void GammaNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - GammaOperation *operation = new GammaOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_GlareNode.cc b/source/blender/compositor/nodes/COM_GlareNode.cc new file mode 100644 index 00000000000..ef088e42205 --- /dev/null +++ b/source/blender/compositor/nodes/COM_GlareNode.cc @@ -0,0 +1,82 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_GlareNode.h" +#include "COM_FastGaussianBlurOperation.h" +#include "COM_GlareFogGlowOperation.h" +#include "COM_GlareGhostOperation.h" +#include "COM_GlareSimpleStarOperation.h" +#include "COM_GlareStreaksOperation.h" +#include "COM_GlareThresholdOperation.h" +#include "COM_MixOperation.h" +#include "COM_SetValueOperation.h" +#include "DNA_node_types.h" + +GlareNode::GlareNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void GlareNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *node = this->getbNode(); + NodeGlare *glare = (NodeGlare *)node->storage; + + GlareBaseOperation *glareoperation = nullptr; + switch (glare->type) { + default: + case 3: + glareoperation = new GlareGhostOperation(); + break; + case 2: // streaks + glareoperation = new GlareStreaksOperation(); + break; + case 1: // fog glow + glareoperation = new GlareFogGlowOperation(); + break; + case 0: // simple star + glareoperation = new GlareSimpleStarOperation(); + break; + } + BLI_assert(glareoperation); + glareoperation->setGlareSettings(glare); + + GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); + thresholdOperation->setGlareSettings(glare); + + SetValueOperation *mixvalueoperation = new SetValueOperation(); + mixvalueoperation->setValue(0.5f + glare->mix * 0.5f); + + MixGlareOperation *mixoperation = new MixGlareOperation(); + mixoperation->setResolutionInputSocketIndex(1); + mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT); + + converter.addOperation(glareoperation); + converter.addOperation(thresholdOperation); + converter.addOperation(mixvalueoperation); + converter.addOperation(mixoperation); + + converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0)); + converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); + + converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1)); + converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(), mixoperation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp deleted file mode 100644 index ef088e42205..00000000000 --- a/source/blender/compositor/nodes/COM_GlareNode.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_GlareNode.h" -#include "COM_FastGaussianBlurOperation.h" -#include "COM_GlareFogGlowOperation.h" -#include "COM_GlareGhostOperation.h" -#include "COM_GlareSimpleStarOperation.h" -#include "COM_GlareStreaksOperation.h" -#include "COM_GlareThresholdOperation.h" -#include "COM_MixOperation.h" -#include "COM_SetValueOperation.h" -#include "DNA_node_types.h" - -GlareNode::GlareNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void GlareNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *node = this->getbNode(); - NodeGlare *glare = (NodeGlare *)node->storage; - - GlareBaseOperation *glareoperation = nullptr; - switch (glare->type) { - default: - case 3: - glareoperation = new GlareGhostOperation(); - break; - case 2: // streaks - glareoperation = new GlareStreaksOperation(); - break; - case 1: // fog glow - glareoperation = new GlareFogGlowOperation(); - break; - case 0: // simple star - glareoperation = new GlareSimpleStarOperation(); - break; - } - BLI_assert(glareoperation); - glareoperation->setGlareSettings(glare); - - GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); - thresholdOperation->setGlareSettings(glare); - - SetValueOperation *mixvalueoperation = new SetValueOperation(); - mixvalueoperation->setValue(0.5f + glare->mix * 0.5f); - - MixGlareOperation *mixoperation = new MixGlareOperation(); - mixoperation->setResolutionInputSocketIndex(1); - mixoperation->getInputSocket(2)->setResizeMode(COM_SC_FIT); - - converter.addOperation(glareoperation); - converter.addOperation(thresholdOperation); - converter.addOperation(mixvalueoperation); - converter.addOperation(mixoperation); - - converter.mapInputSocket(getInputSocket(0), thresholdOperation->getInputSocket(0)); - converter.addLink(thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); - - converter.addLink(mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(0), mixoperation->getInputSocket(1)); - converter.addLink(glareoperation->getOutputSocket(), mixoperation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(), mixoperation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc new file mode 100644 index 00000000000..00125ba2ea5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cc @@ -0,0 +1,64 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_HueSaturationValueCorrectNode.h" + +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_HueSaturationValueCorrectOperation.h" +#include "COM_MixOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "DNA_node_types.h" + +HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void HueSaturationValueCorrectNode::convertToOperations( + NodeConverter &converter, const CompositorContext & /*context*/) const +{ + NodeInput *valueSocket = this->getInputSocket(0); + NodeInput *colorSocket = this->getInputSocket(1); + NodeOutput *outputSocket = this->getOutputSocket(0); + bNode *editorsnode = getbNode(); + CurveMapping *storage = (CurveMapping *)editorsnode->storage; + + ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); + converter.addOperation(rgbToHSV); + + ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); + converter.addOperation(hsvToRGB); + + HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); + changeHSV->setCurveMapping(storage); + converter.addOperation(changeHSV); + + MixBlendOperation *blend = new MixBlendOperation(); + blend->setResolutionInputSocketIndex(1); + converter.addOperation(blend); + + converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0)); + converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + converter.mapInputSocket(colorSocket, blend->getInputSocket(1)); + converter.mapInputSocket(valueSocket, blend->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, blend->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp deleted file mode 100644 index 00125ba2ea5..00000000000 --- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_HueSaturationValueCorrectNode.h" - -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_HueSaturationValueCorrectOperation.h" -#include "COM_MixOperation.h" -#include "COM_SetColorOperation.h" -#include "COM_SetValueOperation.h" -#include "DNA_node_types.h" - -HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void HueSaturationValueCorrectNode::convertToOperations( - NodeConverter &converter, const CompositorContext & /*context*/) const -{ - NodeInput *valueSocket = this->getInputSocket(0); - NodeInput *colorSocket = this->getInputSocket(1); - NodeOutput *outputSocket = this->getOutputSocket(0); - bNode *editorsnode = getbNode(); - CurveMapping *storage = (CurveMapping *)editorsnode->storage; - - ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); - converter.addOperation(rgbToHSV); - - ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); - converter.addOperation(hsvToRGB); - - HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); - changeHSV->setCurveMapping(storage); - converter.addOperation(changeHSV); - - MixBlendOperation *blend = new MixBlendOperation(); - blend->setResolutionInputSocketIndex(1); - converter.addOperation(blend); - - converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0)); - converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); - converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); - converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); - converter.mapInputSocket(colorSocket, blend->getInputSocket(1)); - converter.mapInputSocket(valueSocket, blend->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, blend->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc new file mode 100644 index 00000000000..dc2e5187e8f --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cc @@ -0,0 +1,67 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_HueSaturationValueNode.h" + +#include "COM_ChangeHSVOperation.h" +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_MixOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "DNA_node_types.h" + +HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void HueSaturationValueNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *colorSocket = this->getInputSocket(0); + NodeInput *hueSocket = this->getInputSocket(1); + NodeInput *saturationSocket = this->getInputSocket(2); + NodeInput *valueSocket = this->getInputSocket(3); + NodeInput *facSocket = this->getInputSocket(4); + NodeOutput *outputSocket = this->getOutputSocket(0); + + ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); + converter.addOperation(rgbToHSV); + + ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); + converter.addOperation(hsvToRGB); + + ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); + converter.mapInputSocket(hueSocket, changeHSV->getInputSocket(1)); + converter.mapInputSocket(saturationSocket, changeHSV->getInputSocket(2)); + converter.mapInputSocket(valueSocket, changeHSV->getInputSocket(3)); + converter.addOperation(changeHSV); + + MixBlendOperation *blend = new MixBlendOperation(); + blend->setResolutionInputSocketIndex(1); + converter.addOperation(blend); + + converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0)); + converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + converter.mapInputSocket(colorSocket, blend->getInputSocket(1)); + converter.mapInputSocket(facSocket, blend->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, blend->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp deleted file mode 100644 index dc2e5187e8f..00000000000 --- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_HueSaturationValueNode.h" - -#include "COM_ChangeHSVOperation.h" -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_MixOperation.h" -#include "COM_SetColorOperation.h" -#include "COM_SetValueOperation.h" -#include "DNA_node_types.h" - -HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void HueSaturationValueNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *colorSocket = this->getInputSocket(0); - NodeInput *hueSocket = this->getInputSocket(1); - NodeInput *saturationSocket = this->getInputSocket(2); - NodeInput *valueSocket = this->getInputSocket(3); - NodeInput *facSocket = this->getInputSocket(4); - NodeOutput *outputSocket = this->getOutputSocket(0); - - ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation(); - converter.addOperation(rgbToHSV); - - ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation(); - converter.addOperation(hsvToRGB); - - ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); - converter.mapInputSocket(hueSocket, changeHSV->getInputSocket(1)); - converter.mapInputSocket(saturationSocket, changeHSV->getInputSocket(2)); - converter.mapInputSocket(valueSocket, changeHSV->getInputSocket(3)); - converter.addOperation(changeHSV); - - MixBlendOperation *blend = new MixBlendOperation(); - blend->setResolutionInputSocketIndex(1); - converter.addOperation(blend); - - converter.mapInputSocket(colorSocket, rgbToHSV->getInputSocket(0)); - converter.addLink(rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); - converter.addLink(changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); - converter.addLink(hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); - converter.mapInputSocket(colorSocket, blend->getInputSocket(1)); - converter.mapInputSocket(facSocket, blend->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, blend->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cc b/source/blender/compositor/nodes/COM_IDMaskNode.cc new file mode 100644 index 00000000000..5ba54d75bcd --- /dev/null +++ b/source/blender/compositor/nodes/COM_IDMaskNode.cc @@ -0,0 +1,49 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_IDMaskNode.h" +#include "COM_AntiAliasOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_IDMaskOperation.h" + +IDMaskNode::IDMaskNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} +void IDMaskNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *bnode = this->getbNode(); + + IDMaskOperation *operation; + operation = new IDMaskOperation(); + operation->setObjectIndex(bnode->custom1); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + if (bnode->custom2 == 0 || context.getRenderData()->scemode & R_FULL_SAMPLE) { + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + else { + AntiAliasOperation *antiAliasOperation = new AntiAliasOperation(); + converter.addOperation(antiAliasOperation); + + converter.addLink(operation->getOutputSocket(), antiAliasOperation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), antiAliasOperation->getOutputSocket(0)); + } +} diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp deleted file mode 100644 index 5ba54d75bcd..00000000000 --- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_IDMaskNode.h" -#include "COM_AntiAliasOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_IDMaskOperation.h" - -IDMaskNode::IDMaskNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} -void IDMaskNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *bnode = this->getbNode(); - - IDMaskOperation *operation; - operation = new IDMaskOperation(); - operation->setObjectIndex(bnode->custom1); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - if (bnode->custom2 == 0 || context.getRenderData()->scemode & R_FULL_SAMPLE) { - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - else { - AntiAliasOperation *antiAliasOperation = new AntiAliasOperation(); - converter.addOperation(antiAliasOperation); - - converter.addLink(operation->getOutputSocket(), antiAliasOperation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), antiAliasOperation->getOutputSocket(0)); - } -} diff --git a/source/blender/compositor/nodes/COM_ImageNode.cc b/source/blender/compositor/nodes/COM_ImageNode.cc new file mode 100644 index 00000000000..69729e018d7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ImageNode.cc @@ -0,0 +1,299 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ImageNode.h" +#include "BKE_node.h" +#include "BLI_utildefines.h" +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_ImageOperation.h" +#include "COM_MultilayerImageOperation.h" + +#include "COM_SeparateColorNode.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_SetVectorOperation.h" + +ImageNode::ImageNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} +NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, + RenderLayer *render_layer, + RenderPass *render_pass, + Image *image, + ImageUser *user, + int framenumber, + int outputsocketIndex, + int view, + DataType datatype) const +{ + NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex); + MultilayerBaseOperation *operation = nullptr; + switch (datatype) { + case COM_DT_VALUE: + operation = new MultilayerValueOperation(render_layer, render_pass, view); + break; + case COM_DT_VECTOR: + operation = new MultilayerVectorOperation(render_layer, render_pass, view); + break; + case COM_DT_COLOR: + operation = new MultilayerColorOperation(render_layer, render_pass, view); + break; + default: + break; + } + operation->setImage(image); + operation->setImageUser(user); + operation->setFramenumber(framenumber); + + converter.addOperation(operation); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); + + return operation; +} + +void ImageNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + /** Image output */ + NodeOutput *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(); + bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0; + BKE_image_user_frame_calc(image, imageuser, context.getFramenumber()); + /* force a load, we assume iuser index will be set OK anyway */ + if (image && image->type == IMA_TYPE_MULTILAYER) { + bool is_multilayer_ok = false; + ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, nullptr); + if (image->rr) { + RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); + if (rl) { + NodeOutput *socket; + int index; + + is_multilayer_ok = true; + + for (index = 0; index < numberOfOutputs; index++) { + NodeOperation *operation = nullptr; + socket = this->getOutputSocket(index); + bNodeSocket *bnodeSocket = socket->getbNodeSocket(); + NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage; + RenderPass *rpass = (RenderPass *)BLI_findstring( + &rl->passes, storage->pass_name, offsetof(RenderPass, name)); + int view = 0; + + if (STREQ(storage->pass_name, RE_PASSNAME_COMBINED) && + STREQ(bnodeSocket->name, "Alpha")) { + /* Alpha output is already handled with the associated combined output. */ + continue; + } + + /* returns the image view to use for the current active view */ + if (BLI_listbase_count_at_most(&image->rr->views, 2) > 1) { + const int view_image = imageuser->view; + const bool is_allview = (view_image == 0); /* if view selected == All (0) */ + + if (is_allview) { + /* heuristic to match image name with scene names + * check if the view name exists in the image */ + view = BLI_findstringindex( + &image->rr->views, context.getViewName(), offsetof(RenderView, name)); + if (view == -1) { + view = 0; + } + } + else { + view = view_image - 1; + } + } + + if (rpass) { + switch (rpass->channels) { + case 1: + operation = doMultilayerCheck(converter, + rl, + rpass, + image, + imageuser, + framenumber, + index, + view, + 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(converter, + rl, + rpass, + image, + imageuser, + framenumber, + index, + view, + COM_DT_VECTOR); + break; + case 4: + operation = doMultilayerCheck(converter, + rl, + rpass, + image, + imageuser, + framenumber, + index, + view, + COM_DT_COLOR); + break; + default: + /* dummy operation is added below */ + break; + } + if (index == 0 && operation) { + converter.addPreview(operation->getOutputSocket()); + } + if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) { + for (int alphaIndex = 0; alphaIndex < numberOfOutputs; alphaIndex++) { + NodeOutput *alphaSocket = this->getOutputSocket(alphaIndex); + bNodeSocket *bnodeAlphaSocket = alphaSocket->getbNodeSocket(); + if (!STREQ(bnodeAlphaSocket->name, "Alpha")) { + continue; + } + NodeImageLayer *alphaStorage = (NodeImageLayer *)bnodeSocket->storage; + if (!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) { + continue; + } + SeparateChannelOperation *separate_operation; + separate_operation = new SeparateChannelOperation(); + separate_operation->setChannel(3); + converter.addOperation(separate_operation); + converter.addLink(operation->getOutputSocket(), + separate_operation->getInputSocket(0)); + converter.mapOutputSocket(alphaSocket, separate_operation->getOutputSocket()); + break; + } + } + } + + /* In case we can't load the layer. */ + if (operation == nullptr) { + converter.setInvalidOutput(getOutputSocket(index)); + } + } + } + } + BKE_image_release_ibuf(image, ibuf, nullptr); + + /* without this, multilayer that fail to load will crash blender T32490. */ + if (is_multilayer_ok == false) { + for (int i = 0; i < getNumberOfOutputSockets(); i++) { + converter.setInvalidOutput(getOutputSocket(i)); + } + } + } + else { + if (numberOfOutputs > 0) { + ImageOperation *operation = new ImageOperation(); + operation->setImage(image); + operation->setImageUser(imageuser); + operation->setFramenumber(framenumber); + operation->setRenderData(context.getRenderData()); + operation->setViewName(context.getViewName()); + converter.addOperation(operation); + + if (outputStraightAlpha) { + NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation(); + + converter.addOperation(alphaConvertOperation); + converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket()); + converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0)); + } + else { + converter.mapOutputSocket(outputImage, operation->getOutputSocket()); + } + + converter.addPreview(operation->getOutputSocket()); + } + + if (numberOfOutputs > 1) { + NodeOutput *alphaImage = this->getOutputSocket(1); + ImageAlphaOperation *alphaOperation = new ImageAlphaOperation(); + alphaOperation->setImage(image); + alphaOperation->setImageUser(imageuser); + alphaOperation->setFramenumber(framenumber); + alphaOperation->setRenderData(context.getRenderData()); + alphaOperation->setViewName(context.getViewName()); + converter.addOperation(alphaOperation); + + converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket()); + } + if (numberOfOutputs > 2) { + NodeOutput *depthImage = this->getOutputSocket(2); + ImageDepthOperation *depthOperation = new ImageDepthOperation(); + depthOperation->setImage(image); + depthOperation->setImageUser(imageuser); + depthOperation->setFramenumber(framenumber); + depthOperation->setRenderData(context.getRenderData()); + depthOperation->setViewName(context.getViewName()); + converter.addOperation(depthOperation); + + converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket()); + } + if (numberOfOutputs > 3) { + /* happens when unlinking image datablock from multilayer node */ + for (int i = 3; i < numberOfOutputs; i++) { + NodeOutput *output = this->getOutputSocket(i); + NodeOperation *operation = nullptr; + 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) { + /* not supporting multiview for this generic case */ + converter.addOperation(operation); + converter.mapOutputSocket(output, operation->getOutputSocket()); + } + } + } + } +} diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp deleted file mode 100644 index 69729e018d7..00000000000 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ImageNode.h" -#include "BKE_node.h" -#include "BLI_utildefines.h" -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_ImageOperation.h" -#include "COM_MultilayerImageOperation.h" - -#include "COM_SeparateColorNode.h" -#include "COM_SetColorOperation.h" -#include "COM_SetValueOperation.h" -#include "COM_SetVectorOperation.h" - -ImageNode::ImageNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} -NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, - RenderLayer *render_layer, - RenderPass *render_pass, - Image *image, - ImageUser *user, - int framenumber, - int outputsocketIndex, - int view, - DataType datatype) const -{ - NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex); - MultilayerBaseOperation *operation = nullptr; - switch (datatype) { - case COM_DT_VALUE: - operation = new MultilayerValueOperation(render_layer, render_pass, view); - break; - case COM_DT_VECTOR: - operation = new MultilayerVectorOperation(render_layer, render_pass, view); - break; - case COM_DT_COLOR: - operation = new MultilayerColorOperation(render_layer, render_pass, view); - break; - default: - break; - } - operation->setImage(image); - operation->setImageUser(user); - operation->setFramenumber(framenumber); - - converter.addOperation(operation); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket()); - - return operation; -} - -void ImageNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - /** Image output */ - NodeOutput *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(); - bool outputStraightAlpha = (editorNode->custom1 & CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT) != 0; - BKE_image_user_frame_calc(image, imageuser, context.getFramenumber()); - /* force a load, we assume iuser index will be set OK anyway */ - if (image && image->type == IMA_TYPE_MULTILAYER) { - bool is_multilayer_ok = false; - ImBuf *ibuf = BKE_image_acquire_ibuf(image, imageuser, nullptr); - if (image->rr) { - RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); - if (rl) { - NodeOutput *socket; - int index; - - is_multilayer_ok = true; - - for (index = 0; index < numberOfOutputs; index++) { - NodeOperation *operation = nullptr; - socket = this->getOutputSocket(index); - bNodeSocket *bnodeSocket = socket->getbNodeSocket(); - NodeImageLayer *storage = (NodeImageLayer *)bnodeSocket->storage; - RenderPass *rpass = (RenderPass *)BLI_findstring( - &rl->passes, storage->pass_name, offsetof(RenderPass, name)); - int view = 0; - - if (STREQ(storage->pass_name, RE_PASSNAME_COMBINED) && - STREQ(bnodeSocket->name, "Alpha")) { - /* Alpha output is already handled with the associated combined output. */ - continue; - } - - /* returns the image view to use for the current active view */ - if (BLI_listbase_count_at_most(&image->rr->views, 2) > 1) { - const int view_image = imageuser->view; - const bool is_allview = (view_image == 0); /* if view selected == All (0) */ - - if (is_allview) { - /* heuristic to match image name with scene names - * check if the view name exists in the image */ - view = BLI_findstringindex( - &image->rr->views, context.getViewName(), offsetof(RenderView, name)); - if (view == -1) { - view = 0; - } - } - else { - view = view_image - 1; - } - } - - if (rpass) { - switch (rpass->channels) { - case 1: - operation = doMultilayerCheck(converter, - rl, - rpass, - image, - imageuser, - framenumber, - index, - view, - 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(converter, - rl, - rpass, - image, - imageuser, - framenumber, - index, - view, - COM_DT_VECTOR); - break; - case 4: - operation = doMultilayerCheck(converter, - rl, - rpass, - image, - imageuser, - framenumber, - index, - view, - COM_DT_COLOR); - break; - default: - /* dummy operation is added below */ - break; - } - if (index == 0 && operation) { - converter.addPreview(operation->getOutputSocket()); - } - if (STREQ(rpass->name, RE_PASSNAME_COMBINED)) { - for (int alphaIndex = 0; alphaIndex < numberOfOutputs; alphaIndex++) { - NodeOutput *alphaSocket = this->getOutputSocket(alphaIndex); - bNodeSocket *bnodeAlphaSocket = alphaSocket->getbNodeSocket(); - if (!STREQ(bnodeAlphaSocket->name, "Alpha")) { - continue; - } - NodeImageLayer *alphaStorage = (NodeImageLayer *)bnodeSocket->storage; - if (!STREQ(alphaStorage->pass_name, RE_PASSNAME_COMBINED)) { - continue; - } - SeparateChannelOperation *separate_operation; - separate_operation = new SeparateChannelOperation(); - separate_operation->setChannel(3); - converter.addOperation(separate_operation); - converter.addLink(operation->getOutputSocket(), - separate_operation->getInputSocket(0)); - converter.mapOutputSocket(alphaSocket, separate_operation->getOutputSocket()); - break; - } - } - } - - /* In case we can't load the layer. */ - if (operation == nullptr) { - converter.setInvalidOutput(getOutputSocket(index)); - } - } - } - } - BKE_image_release_ibuf(image, ibuf, nullptr); - - /* without this, multilayer that fail to load will crash blender T32490. */ - if (is_multilayer_ok == false) { - for (int i = 0; i < getNumberOfOutputSockets(); i++) { - converter.setInvalidOutput(getOutputSocket(i)); - } - } - } - else { - if (numberOfOutputs > 0) { - ImageOperation *operation = new ImageOperation(); - operation->setImage(image); - operation->setImageUser(imageuser); - operation->setFramenumber(framenumber); - operation->setRenderData(context.getRenderData()); - operation->setViewName(context.getViewName()); - converter.addOperation(operation); - - if (outputStraightAlpha) { - NodeOperation *alphaConvertOperation = new ConvertPremulToStraightOperation(); - - converter.addOperation(alphaConvertOperation); - converter.mapOutputSocket(outputImage, alphaConvertOperation->getOutputSocket()); - converter.addLink(operation->getOutputSocket(0), alphaConvertOperation->getInputSocket(0)); - } - else { - converter.mapOutputSocket(outputImage, operation->getOutputSocket()); - } - - converter.addPreview(operation->getOutputSocket()); - } - - if (numberOfOutputs > 1) { - NodeOutput *alphaImage = this->getOutputSocket(1); - ImageAlphaOperation *alphaOperation = new ImageAlphaOperation(); - alphaOperation->setImage(image); - alphaOperation->setImageUser(imageuser); - alphaOperation->setFramenumber(framenumber); - alphaOperation->setRenderData(context.getRenderData()); - alphaOperation->setViewName(context.getViewName()); - converter.addOperation(alphaOperation); - - converter.mapOutputSocket(alphaImage, alphaOperation->getOutputSocket()); - } - if (numberOfOutputs > 2) { - NodeOutput *depthImage = this->getOutputSocket(2); - ImageDepthOperation *depthOperation = new ImageDepthOperation(); - depthOperation->setImage(image); - depthOperation->setImageUser(imageuser); - depthOperation->setFramenumber(framenumber); - depthOperation->setRenderData(context.getRenderData()); - depthOperation->setViewName(context.getViewName()); - converter.addOperation(depthOperation); - - converter.mapOutputSocket(depthImage, depthOperation->getOutputSocket()); - } - if (numberOfOutputs > 3) { - /* happens when unlinking image datablock from multilayer node */ - for (int i = 3; i < numberOfOutputs; i++) { - NodeOutput *output = this->getOutputSocket(i); - NodeOperation *operation = nullptr; - 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) { - /* not supporting multiview for this generic case */ - converter.addOperation(operation); - converter.mapOutputSocket(output, operation->getOutputSocket()); - } - } - } - } -} diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cc b/source/blender/compositor/nodes/COM_InpaintNode.cc new file mode 100644 index 00000000000..40fe63ec9f3 --- /dev/null +++ b/source/blender/compositor/nodes/COM_InpaintNode.cc @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_InpaintNode.h" +#include "BLI_math.h" +#include "COM_ExecutionSystem.h" +#include "COM_InpaintOperation.h" +#include "DNA_scene_types.h" + +InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void InpaintNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + + bNode *editorNode = this->getbNode(); + + /* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */ + if (true) { + InpaintSimpleOperation *operation = new InpaintSimpleOperation(); + operation->setIterations(editorNode->custom2); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } +} diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cpp b/source/blender/compositor/nodes/COM_InpaintNode.cpp deleted file mode 100644 index 40fe63ec9f3..00000000000 --- a/source/blender/compositor/nodes/COM_InpaintNode.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_InpaintNode.h" -#include "BLI_math.h" -#include "COM_ExecutionSystem.h" -#include "COM_InpaintOperation.h" -#include "DNA_scene_types.h" - -InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void InpaintNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - - bNode *editorNode = this->getbNode(); - - /* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */ - if (true) { - InpaintSimpleOperation *operation = new InpaintSimpleOperation(); - operation->setIterations(editorNode->custom2); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } -} diff --git a/source/blender/compositor/nodes/COM_InvertNode.cc b/source/blender/compositor/nodes/COM_InvertNode.cc new file mode 100644 index 00000000000..913452c42c8 --- /dev/null +++ b/source/blender/compositor/nodes/COM_InvertNode.cc @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_InvertNode.h" +#include "BKE_node.h" +#include "COM_ExecutionSystem.h" +#include "COM_InvertOperation.h" + +InvertNode::InvertNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void InvertNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + InvertOperation *operation = new InvertOperation(); + bNode *node = this->getbNode(); + operation->setColor(node->custom1 & CMP_CHAN_RGB); + operation->setAlpha(node->custom1 & CMP_CHAN_A); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp deleted file mode 100644 index 913452c42c8..00000000000 --- a/source/blender/compositor/nodes/COM_InvertNode.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_InvertNode.h" -#include "BKE_node.h" -#include "COM_ExecutionSystem.h" -#include "COM_InvertOperation.h" - -InvertNode::InvertNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void InvertNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - InvertOperation *operation = new InvertOperation(); - bNode *node = this->getbNode(); - operation->setColor(node->custom1 & CMP_CHAN_RGB); - operation->setAlpha(node->custom1 & CMP_CHAN_A); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cc b/source/blender/compositor/nodes/COM_KeyingNode.cc new file mode 100644 index 00000000000..9b493d3f332 --- /dev/null +++ b/source/blender/compositor/nodes/COM_KeyingNode.cc @@ -0,0 +1,350 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_KeyingNode.h" + +#include "COM_ExecutionSystem.h" + +#include "COM_KeyingBlurOperation.h" +#include "COM_KeyingClipOperation.h" +#include "COM_KeyingDespillOperation.h" +#include "COM_KeyingOperation.h" + +#include "COM_MathBaseOperation.h" + +#include "COM_ConvertOperation.h" +#include "COM_SetValueOperation.h" + +#include "COM_DilateErodeOperation.h" + +#include "COM_SetAlphaMultiplyOperation.h" + +#include "COM_GaussianAlphaXBlurOperation.h" +#include "COM_GaussianAlphaYBlurOperation.h" + +KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +NodeOperationOutput *KeyingNode::setupPreBlur(NodeConverter &converter, + NodeInput *inputImage, + int size) const +{ + ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation(); + convertRGBToYCCOperation->setMode(BLI_YCC_ITU_BT709); + converter.addOperation(convertRGBToYCCOperation); + + converter.mapInputSocket(inputImage, convertRGBToYCCOperation->getInputSocket(0)); + + CombineChannelsOperation *combineOperation = new CombineChannelsOperation(); + converter.addOperation(combineOperation); + + for (int channel = 0; channel < 4; channel++) { + SeparateChannelOperation *separateOperation = new SeparateChannelOperation(); + separateOperation->setChannel(channel); + converter.addOperation(separateOperation); + + converter.addLink(convertRGBToYCCOperation->getOutputSocket(0), + separateOperation->getInputSocket(0)); + + if (ELEM(channel, 0, 3)) { + converter.addLink(separateOperation->getOutputSocket(0), + combineOperation->getInputSocket(channel)); + } + else { + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + converter.addOperation(blurXOperation); + + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + converter.addOperation(blurYOperation); + + converter.addLink(separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); + converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); + converter.addLink(blurYOperation->getOutputSocket(0), + combineOperation->getInputSocket(channel)); + } + } + + ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation(); + convertYCCToRGBOperation->setMode(BLI_YCC_ITU_BT709); + converter.addOperation(convertYCCToRGBOperation); + + converter.addLink(combineOperation->getOutputSocket(0), + convertYCCToRGBOperation->getInputSocket(0)); + + return convertYCCToRGBOperation->getOutputSocket(0); +} + +NodeOperationOutput *KeyingNode::setupPostBlur(NodeConverter &converter, + NodeOperationOutput *postBlurInput, + int size) const +{ + KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); + blurXOperation->setSize(size); + blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); + converter.addOperation(blurXOperation); + + KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); + blurYOperation->setSize(size); + blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); + converter.addOperation(blurYOperation); + + converter.addLink(postBlurInput, blurXOperation->getInputSocket(0)); + converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); + + return blurYOperation->getOutputSocket(); +} + +NodeOperationOutput *KeyingNode::setupDilateErode(NodeConverter &converter, + NodeOperationOutput *dilateErodeInput, + int distance) const +{ + DilateDistanceOperation *dilateErodeOperation; + if (distance > 0) { + dilateErodeOperation = new DilateDistanceOperation(); + dilateErodeOperation->setDistance(distance); + } + else { + dilateErodeOperation = new ErodeDistanceOperation(); + dilateErodeOperation->setDistance(-distance); + } + converter.addOperation(dilateErodeOperation); + + converter.addLink(dilateErodeInput, dilateErodeOperation->getInputSocket(0)); + + return dilateErodeOperation->getOutputSocket(0); +} + +NodeOperationOutput *KeyingNode::setupFeather(NodeConverter &converter, + const CompositorContext &context, + NodeOperationOutput *featherInput, + int falloff, + int distance) const +{ + /* this uses a modified gaussian blur function otherwise its far too slow */ + CompositorQuality quality = context.getQuality(); + + /* initialize node data */ + NodeBlurData data; + memset(&data, 0, sizeof(NodeBlurData)); + data.filtertype = R_FILTER_GAUSS; + if (distance > 0) { + data.sizex = data.sizey = distance; + } + else { + data.sizex = data.sizey = -distance; + } + + GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); + operationx->setData(&data); + operationx->setQuality(quality); + operationx->setSize(1.0f); + operationx->setSubtract(distance < 0); + operationx->setFalloff(falloff); + converter.addOperation(operationx); + + GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); + operationy->setData(&data); + operationy->setQuality(quality); + operationy->setSize(1.0f); + operationy->setSubtract(distance < 0); + operationy->setFalloff(falloff); + converter.addOperation(operationy); + + converter.addLink(featherInput, operationx->getInputSocket(0)); + converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); + + return operationy->getOutputSocket(); +} + +NodeOperationOutput *KeyingNode::setupDespill(NodeConverter &converter, + NodeOperationOutput *despillInput, + NodeInput *inputScreen, + float factor, + float colorBalance) const +{ + KeyingDespillOperation *despillOperation = new KeyingDespillOperation(); + despillOperation->setDespillFactor(factor); + despillOperation->setColorBalance(colorBalance); + converter.addOperation(despillOperation); + + converter.addLink(despillInput, despillOperation->getInputSocket(0)); + converter.mapInputSocket(inputScreen, despillOperation->getInputSocket(1)); + + return despillOperation->getOutputSocket(0); +} + +NodeOperationOutput *KeyingNode::setupClip(NodeConverter &converter, + NodeOperationOutput *clipInput, + int kernelRadius, + float kernelTolerance, + float clipBlack, + float clipWhite, + bool edgeMatte) const +{ + KeyingClipOperation *clipOperation = new KeyingClipOperation(); + clipOperation->setKernelRadius(kernelRadius); + clipOperation->setKernelTolerance(kernelTolerance); + clipOperation->setClipBlack(clipBlack); + clipOperation->setClipWhite(clipWhite); + clipOperation->setIsEdgeMatte(edgeMatte); + converter.addOperation(clipOperation); + + converter.addLink(clipInput, clipOperation->getInputSocket(0)); + + return clipOperation->getOutputSocket(0); +} + +void KeyingNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + NodeKeyingData *keying_data = (NodeKeyingData *)editorNode->storage; + + NodeInput *inputImage = this->getInputSocket(0); + NodeInput *inputScreen = this->getInputSocket(1); + NodeInput *inputGarbageMatte = this->getInputSocket(2); + NodeInput *inputCoreMatte = this->getInputSocket(3); + NodeOutput *outputImage = this->getOutputSocket(0); + NodeOutput *outputMatte = this->getOutputSocket(1); + NodeOutput *outputEdges = this->getOutputSocket(2); + NodeOperationOutput *postprocessedMatte = nullptr, *postprocessedImage = nullptr, + *edgesMatte = nullptr; + + /* keying operation */ + KeyingOperation *keyingOperation = new KeyingOperation(); + keyingOperation->setScreenBalance(keying_data->screen_balance); + converter.addOperation(keyingOperation); + + converter.mapInputSocket(inputScreen, keyingOperation->getInputSocket(1)); + + if (keying_data->blur_pre) { + /* Chroma pre-blur operation for input of keying operation. */ + NodeOperationOutput *preBlurredImage = setupPreBlur( + converter, inputImage, keying_data->blur_pre); + converter.addLink(preBlurredImage, keyingOperation->getInputSocket(0)); + } + else { + converter.mapInputSocket(inputImage, keyingOperation->getInputSocket(0)); + } + + postprocessedMatte = keyingOperation->getOutputSocket(); + + /* black / white clipping */ + if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) { + postprocessedMatte = setupClip(converter, + postprocessedMatte, + keying_data->edge_kernel_radius, + keying_data->edge_kernel_tolerance, + keying_data->clip_black, + keying_data->clip_white, + false); + } + + /* output edge matte */ + edgesMatte = setupClip(converter, + postprocessedMatte, + keying_data->edge_kernel_radius, + keying_data->edge_kernel_tolerance, + keying_data->clip_black, + keying_data->clip_white, + true); + + /* apply garbage matte */ + if (inputGarbageMatte->isLinked()) { + SetValueOperation *valueOperation = new SetValueOperation(); + valueOperation->setValue(1.0f); + converter.addOperation(valueOperation); + + MathSubtractOperation *subtractOperation = new MathSubtractOperation(); + converter.addOperation(subtractOperation); + + MathMinimumOperation *minOperation = new MathMinimumOperation(); + converter.addOperation(minOperation); + + converter.addLink(valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0)); + converter.mapInputSocket(inputGarbageMatte, subtractOperation->getInputSocket(1)); + + converter.addLink(subtractOperation->getOutputSocket(), minOperation->getInputSocket(0)); + converter.addLink(postprocessedMatte, minOperation->getInputSocket(1)); + + postprocessedMatte = minOperation->getOutputSocket(); + } + + /* apply core matte */ + if (inputCoreMatte->isLinked()) { + MathMaximumOperation *maxOperation = new MathMaximumOperation(); + converter.addOperation(maxOperation); + + converter.mapInputSocket(inputCoreMatte, maxOperation->getInputSocket(0)); + converter.addLink(postprocessedMatte, maxOperation->getInputSocket(1)); + + postprocessedMatte = maxOperation->getOutputSocket(); + } + + /* apply blur on matte if needed */ + if (keying_data->blur_post) { + postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post); + } + + /* matte dilate/erode */ + if (keying_data->dilate_distance != 0) { + postprocessedMatte = setupDilateErode( + converter, postprocessedMatte, keying_data->dilate_distance); + } + + /* matte feather */ + if (keying_data->feather_distance != 0) { + postprocessedMatte = setupFeather(converter, + context, + postprocessedMatte, + keying_data->feather_falloff, + keying_data->feather_distance); + } + + /* set alpha channel to output image */ + SetAlphaMultiplyOperation *alphaOperation = new SetAlphaMultiplyOperation(); + converter.addOperation(alphaOperation); + + converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0)); + converter.addLink(postprocessedMatte, alphaOperation->getInputSocket(1)); + + postprocessedImage = alphaOperation->getOutputSocket(); + + /* despill output image */ + if (keying_data->despill_factor > 0.0f) { + postprocessedImage = setupDespill(converter, + postprocessedImage, + inputScreen, + keying_data->despill_factor, + keying_data->despill_balance); + } + + /* connect result to output sockets */ + converter.mapOutputSocket(outputImage, postprocessedImage); + converter.mapOutputSocket(outputMatte, postprocessedMatte); + + if (edgesMatte) { + converter.mapOutputSocket(outputEdges, edgesMatte); + } +} diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp deleted file mode 100644 index 9b493d3f332..00000000000 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_KeyingNode.h" - -#include "COM_ExecutionSystem.h" - -#include "COM_KeyingBlurOperation.h" -#include "COM_KeyingClipOperation.h" -#include "COM_KeyingDespillOperation.h" -#include "COM_KeyingOperation.h" - -#include "COM_MathBaseOperation.h" - -#include "COM_ConvertOperation.h" -#include "COM_SetValueOperation.h" - -#include "COM_DilateErodeOperation.h" - -#include "COM_SetAlphaMultiplyOperation.h" - -#include "COM_GaussianAlphaXBlurOperation.h" -#include "COM_GaussianAlphaYBlurOperation.h" - -KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -NodeOperationOutput *KeyingNode::setupPreBlur(NodeConverter &converter, - NodeInput *inputImage, - int size) const -{ - ConvertRGBToYCCOperation *convertRGBToYCCOperation = new ConvertRGBToYCCOperation(); - convertRGBToYCCOperation->setMode(BLI_YCC_ITU_BT709); - converter.addOperation(convertRGBToYCCOperation); - - converter.mapInputSocket(inputImage, convertRGBToYCCOperation->getInputSocket(0)); - - CombineChannelsOperation *combineOperation = new CombineChannelsOperation(); - converter.addOperation(combineOperation); - - for (int channel = 0; channel < 4; channel++) { - SeparateChannelOperation *separateOperation = new SeparateChannelOperation(); - separateOperation->setChannel(channel); - converter.addOperation(separateOperation); - - converter.addLink(convertRGBToYCCOperation->getOutputSocket(0), - separateOperation->getInputSocket(0)); - - if (ELEM(channel, 0, 3)) { - converter.addLink(separateOperation->getOutputSocket(0), - combineOperation->getInputSocket(channel)); - } - else { - KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); - blurXOperation->setSize(size); - blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); - converter.addOperation(blurXOperation); - - KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); - blurYOperation->setSize(size); - blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); - converter.addOperation(blurYOperation); - - converter.addLink(separateOperation->getOutputSocket(), blurXOperation->getInputSocket(0)); - converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); - converter.addLink(blurYOperation->getOutputSocket(0), - combineOperation->getInputSocket(channel)); - } - } - - ConvertYCCToRGBOperation *convertYCCToRGBOperation = new ConvertYCCToRGBOperation(); - convertYCCToRGBOperation->setMode(BLI_YCC_ITU_BT709); - converter.addOperation(convertYCCToRGBOperation); - - converter.addLink(combineOperation->getOutputSocket(0), - convertYCCToRGBOperation->getInputSocket(0)); - - return convertYCCToRGBOperation->getOutputSocket(0); -} - -NodeOperationOutput *KeyingNode::setupPostBlur(NodeConverter &converter, - NodeOperationOutput *postBlurInput, - int size) const -{ - KeyingBlurOperation *blurXOperation = new KeyingBlurOperation(); - blurXOperation->setSize(size); - blurXOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_X); - converter.addOperation(blurXOperation); - - KeyingBlurOperation *blurYOperation = new KeyingBlurOperation(); - blurYOperation->setSize(size); - blurYOperation->setAxis(KeyingBlurOperation::BLUR_AXIS_Y); - converter.addOperation(blurYOperation); - - converter.addLink(postBlurInput, blurXOperation->getInputSocket(0)); - converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0)); - - return blurYOperation->getOutputSocket(); -} - -NodeOperationOutput *KeyingNode::setupDilateErode(NodeConverter &converter, - NodeOperationOutput *dilateErodeInput, - int distance) const -{ - DilateDistanceOperation *dilateErodeOperation; - if (distance > 0) { - dilateErodeOperation = new DilateDistanceOperation(); - dilateErodeOperation->setDistance(distance); - } - else { - dilateErodeOperation = new ErodeDistanceOperation(); - dilateErodeOperation->setDistance(-distance); - } - converter.addOperation(dilateErodeOperation); - - converter.addLink(dilateErodeInput, dilateErodeOperation->getInputSocket(0)); - - return dilateErodeOperation->getOutputSocket(0); -} - -NodeOperationOutput *KeyingNode::setupFeather(NodeConverter &converter, - const CompositorContext &context, - NodeOperationOutput *featherInput, - int falloff, - int distance) const -{ - /* this uses a modified gaussian blur function otherwise its far too slow */ - CompositorQuality quality = context.getQuality(); - - /* initialize node data */ - NodeBlurData data; - memset(&data, 0, sizeof(NodeBlurData)); - data.filtertype = R_FILTER_GAUSS; - if (distance > 0) { - data.sizex = data.sizey = distance; - } - else { - data.sizex = data.sizey = -distance; - } - - GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation(); - operationx->setData(&data); - operationx->setQuality(quality); - operationx->setSize(1.0f); - operationx->setSubtract(distance < 0); - operationx->setFalloff(falloff); - converter.addOperation(operationx); - - GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation(); - operationy->setData(&data); - operationy->setQuality(quality); - operationy->setSize(1.0f); - operationy->setSubtract(distance < 0); - operationy->setFalloff(falloff); - converter.addOperation(operationy); - - converter.addLink(featherInput, operationx->getInputSocket(0)); - converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0)); - - return operationy->getOutputSocket(); -} - -NodeOperationOutput *KeyingNode::setupDespill(NodeConverter &converter, - NodeOperationOutput *despillInput, - NodeInput *inputScreen, - float factor, - float colorBalance) const -{ - KeyingDespillOperation *despillOperation = new KeyingDespillOperation(); - despillOperation->setDespillFactor(factor); - despillOperation->setColorBalance(colorBalance); - converter.addOperation(despillOperation); - - converter.addLink(despillInput, despillOperation->getInputSocket(0)); - converter.mapInputSocket(inputScreen, despillOperation->getInputSocket(1)); - - return despillOperation->getOutputSocket(0); -} - -NodeOperationOutput *KeyingNode::setupClip(NodeConverter &converter, - NodeOperationOutput *clipInput, - int kernelRadius, - float kernelTolerance, - float clipBlack, - float clipWhite, - bool edgeMatte) const -{ - KeyingClipOperation *clipOperation = new KeyingClipOperation(); - clipOperation->setKernelRadius(kernelRadius); - clipOperation->setKernelTolerance(kernelTolerance); - clipOperation->setClipBlack(clipBlack); - clipOperation->setClipWhite(clipWhite); - clipOperation->setIsEdgeMatte(edgeMatte); - converter.addOperation(clipOperation); - - converter.addLink(clipInput, clipOperation->getInputSocket(0)); - - return clipOperation->getOutputSocket(0); -} - -void KeyingNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - NodeKeyingData *keying_data = (NodeKeyingData *)editorNode->storage; - - NodeInput *inputImage = this->getInputSocket(0); - NodeInput *inputScreen = this->getInputSocket(1); - NodeInput *inputGarbageMatte = this->getInputSocket(2); - NodeInput *inputCoreMatte = this->getInputSocket(3); - NodeOutput *outputImage = this->getOutputSocket(0); - NodeOutput *outputMatte = this->getOutputSocket(1); - NodeOutput *outputEdges = this->getOutputSocket(2); - NodeOperationOutput *postprocessedMatte = nullptr, *postprocessedImage = nullptr, - *edgesMatte = nullptr; - - /* keying operation */ - KeyingOperation *keyingOperation = new KeyingOperation(); - keyingOperation->setScreenBalance(keying_data->screen_balance); - converter.addOperation(keyingOperation); - - converter.mapInputSocket(inputScreen, keyingOperation->getInputSocket(1)); - - if (keying_data->blur_pre) { - /* Chroma pre-blur operation for input of keying operation. */ - NodeOperationOutput *preBlurredImage = setupPreBlur( - converter, inputImage, keying_data->blur_pre); - converter.addLink(preBlurredImage, keyingOperation->getInputSocket(0)); - } - else { - converter.mapInputSocket(inputImage, keyingOperation->getInputSocket(0)); - } - - postprocessedMatte = keyingOperation->getOutputSocket(); - - /* black / white clipping */ - if (keying_data->clip_black > 0.0f || keying_data->clip_white < 1.0f) { - postprocessedMatte = setupClip(converter, - postprocessedMatte, - keying_data->edge_kernel_radius, - keying_data->edge_kernel_tolerance, - keying_data->clip_black, - keying_data->clip_white, - false); - } - - /* output edge matte */ - edgesMatte = setupClip(converter, - postprocessedMatte, - keying_data->edge_kernel_radius, - keying_data->edge_kernel_tolerance, - keying_data->clip_black, - keying_data->clip_white, - true); - - /* apply garbage matte */ - if (inputGarbageMatte->isLinked()) { - SetValueOperation *valueOperation = new SetValueOperation(); - valueOperation->setValue(1.0f); - converter.addOperation(valueOperation); - - MathSubtractOperation *subtractOperation = new MathSubtractOperation(); - converter.addOperation(subtractOperation); - - MathMinimumOperation *minOperation = new MathMinimumOperation(); - converter.addOperation(minOperation); - - converter.addLink(valueOperation->getOutputSocket(), subtractOperation->getInputSocket(0)); - converter.mapInputSocket(inputGarbageMatte, subtractOperation->getInputSocket(1)); - - converter.addLink(subtractOperation->getOutputSocket(), minOperation->getInputSocket(0)); - converter.addLink(postprocessedMatte, minOperation->getInputSocket(1)); - - postprocessedMatte = minOperation->getOutputSocket(); - } - - /* apply core matte */ - if (inputCoreMatte->isLinked()) { - MathMaximumOperation *maxOperation = new MathMaximumOperation(); - converter.addOperation(maxOperation); - - converter.mapInputSocket(inputCoreMatte, maxOperation->getInputSocket(0)); - converter.addLink(postprocessedMatte, maxOperation->getInputSocket(1)); - - postprocessedMatte = maxOperation->getOutputSocket(); - } - - /* apply blur on matte if needed */ - if (keying_data->blur_post) { - postprocessedMatte = setupPostBlur(converter, postprocessedMatte, keying_data->blur_post); - } - - /* matte dilate/erode */ - if (keying_data->dilate_distance != 0) { - postprocessedMatte = setupDilateErode( - converter, postprocessedMatte, keying_data->dilate_distance); - } - - /* matte feather */ - if (keying_data->feather_distance != 0) { - postprocessedMatte = setupFeather(converter, - context, - postprocessedMatte, - keying_data->feather_falloff, - keying_data->feather_distance); - } - - /* set alpha channel to output image */ - SetAlphaMultiplyOperation *alphaOperation = new SetAlphaMultiplyOperation(); - converter.addOperation(alphaOperation); - - converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0)); - converter.addLink(postprocessedMatte, alphaOperation->getInputSocket(1)); - - postprocessedImage = alphaOperation->getOutputSocket(); - - /* despill output image */ - if (keying_data->despill_factor > 0.0f) { - postprocessedImage = setupDespill(converter, - postprocessedImage, - inputScreen, - keying_data->despill_factor, - keying_data->despill_balance); - } - - /* connect result to output sockets */ - converter.mapOutputSocket(outputImage, postprocessedImage); - converter.mapOutputSocket(outputMatte, postprocessedMatte); - - if (edgesMatte) { - converter.mapOutputSocket(outputEdges, edgesMatte); - } -} diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cc b/source/blender/compositor/nodes/COM_KeyingScreenNode.cc new file mode 100644 index 00000000000..93a9a071226 --- /dev/null +++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cc @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_KeyingScreenNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_KeyingScreenOperation.h" + +#include "DNA_movieclip_types.h" + +KeyingScreenNode::KeyingScreenNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void KeyingScreenNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + MovieClip *clip = (MovieClip *)editorNode->id; + NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *)editorNode->storage; + + NodeOutput *outputScreen = this->getOutputSocket(0); + + // always connect the output image + KeyingScreenOperation *operation = new KeyingScreenOperation(); + operation->setMovieClip(clip); + operation->setTrackingObject(keyingscreen_data->tracking_object); + operation->setFramenumber(context.getFramenumber()); + converter.addOperation(operation); + + converter.mapOutputSocket(outputScreen, operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp deleted file mode 100644 index 93a9a071226..00000000000 --- a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_KeyingScreenNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_KeyingScreenOperation.h" - -#include "DNA_movieclip_types.h" - -KeyingScreenNode::KeyingScreenNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void KeyingScreenNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - MovieClip *clip = (MovieClip *)editorNode->id; - NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *)editorNode->storage; - - NodeOutput *outputScreen = this->getOutputSocket(0); - - // always connect the output image - KeyingScreenOperation *operation = new KeyingScreenOperation(); - operation->setMovieClip(clip); - operation->setTrackingObject(keyingscreen_data->tracking_object); - operation->setFramenumber(context.getFramenumber()); - converter.addOperation(operation); - - converter.mapOutputSocket(outputScreen, operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cc b/source/blender/compositor/nodes/COM_LensDistortionNode.cc new file mode 100644 index 00000000000..34d2fba6433 --- /dev/null +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cc @@ -0,0 +1,61 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_LensDistortionNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_ProjectorLensDistortionOperation.h" +#include "COM_ScreenLensDistortionOperation.h" + +LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void LensDistortionNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorNode = this->getbNode(); + NodeLensDist *data = (NodeLensDist *)editorNode->storage; + if (data->proj) { + ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } + else { + ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); + operation->setFit(data->fit); + operation->setJitter(data->jit); + + if (!getInputSocket(1)->isLinked()) { + operation->setDistortion(getInputSocket(1)->getEditorValueFloat()); + } + if (!getInputSocket(2)->isLinked()) { + operation->setDispersion(getInputSocket(2)->getEditorValueFloat()); + } + + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); + } +} diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp deleted file mode 100644 index 34d2fba6433..00000000000 --- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_LensDistortionNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_ProjectorLensDistortionOperation.h" -#include "COM_ScreenLensDistortionOperation.h" - -LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void LensDistortionNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorNode = this->getbNode(); - NodeLensDist *data = (NodeLensDist *)editorNode->storage; - if (data->proj) { - ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } - else { - ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); - operation->setFit(data->fit); - operation->setJitter(data->jit); - - if (!getInputSocket(1)->isLinked()) { - operation->setDistortion(getInputSocket(1)->getEditorValueFloat()); - } - if (!getInputSocket(2)->isLinked()) { - operation->setDispersion(getInputSocket(2)->getEditorValueFloat()); - } - - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); - } -} diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cc b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cc new file mode 100644 index 00000000000..8bfea1eff49 --- /dev/null +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cc @@ -0,0 +1,53 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_LuminanceMatteNode.h" +#include "BKE_node.h" +#include "COM_ConvertOperation.h" +#include "COM_LuminanceMatteOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" + +LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void LuminanceMatteNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *editorsnode = getbNode(); + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocketImage = this->getOutputSocket(0); + NodeOutput *outputSocketMatte = this->getOutputSocket(1); + + LuminanceMatteOperation *operationSet = new LuminanceMatteOperation(); + operationSet->setSettings((NodeChroma *)editorsnode->storage); + converter.addOperation(operationSet); + + converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); + converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); + + SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); + + converter.addPreview(operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp deleted file mode 100644 index 8bfea1eff49..00000000000 --- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_LuminanceMatteNode.h" -#include "BKE_node.h" -#include "COM_ConvertOperation.h" -#include "COM_LuminanceMatteOperation.h" -#include "COM_SetAlphaMultiplyOperation.h" - -LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void LuminanceMatteNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *editorsnode = getbNode(); - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocketImage = this->getOutputSocket(0); - NodeOutput *outputSocketMatte = this->getOutputSocket(1); - - LuminanceMatteOperation *operationSet = new LuminanceMatteOperation(); - operationSet->setSettings((NodeChroma *)editorsnode->storage); - converter.addOperation(operationSet); - - converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); - converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); - - SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket()); - - converter.addPreview(operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cc b/source/blender/compositor/nodes/COM_MapRangeNode.cc new file mode 100644 index 00000000000..352bc0dd48d --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapRangeNode.cc @@ -0,0 +1,49 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_MapRangeNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_MapRangeOperation.h" + +MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MapRangeNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *valueSocket = this->getInputSocket(0); + NodeInput *sourceMinSocket = this->getInputSocket(1); + NodeInput *sourceMaxSocket = this->getInputSocket(2); + NodeInput *destMinSocket = this->getInputSocket(3); + NodeInput *destMaxSocket = this->getInputSocket(4); + NodeOutput *outputSocket = this->getOutputSocket(0); + + MapRangeOperation *operation = new MapRangeOperation(); + operation->setUseClamp(this->getbNode()->custom1); + converter.addOperation(operation); + + converter.mapInputSocket(valueSocket, operation->getInputSocket(0)); + converter.mapInputSocket(sourceMinSocket, operation->getInputSocket(1)); + converter.mapInputSocket(sourceMaxSocket, operation->getInputSocket(2)); + converter.mapInputSocket(destMinSocket, operation->getInputSocket(3)); + converter.mapInputSocket(destMaxSocket, operation->getInputSocket(4)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp deleted file mode 100644 index 352bc0dd48d..00000000000 --- a/source/blender/compositor/nodes/COM_MapRangeNode.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_MapRangeNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_MapRangeOperation.h" - -MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MapRangeNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *valueSocket = this->getInputSocket(0); - NodeInput *sourceMinSocket = this->getInputSocket(1); - NodeInput *sourceMaxSocket = this->getInputSocket(2); - NodeInput *destMinSocket = this->getInputSocket(3); - NodeInput *destMaxSocket = this->getInputSocket(4); - NodeOutput *outputSocket = this->getOutputSocket(0); - - MapRangeOperation *operation = new MapRangeOperation(); - operation->setUseClamp(this->getbNode()->custom1); - converter.addOperation(operation); - - converter.mapInputSocket(valueSocket, operation->getInputSocket(0)); - converter.mapInputSocket(sourceMinSocket, operation->getInputSocket(1)); - converter.mapInputSocket(sourceMaxSocket, operation->getInputSocket(2)); - converter.mapInputSocket(destMinSocket, operation->getInputSocket(3)); - converter.mapInputSocket(destMaxSocket, operation->getInputSocket(4)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cc b/source/blender/compositor/nodes/COM_MapUVNode.cc new file mode 100644 index 00000000000..feb9c75ec56 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapUVNode.cc @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MapUVNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_MapUVOperation.h" + +MapUVNode::MapUVNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MapUVNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bNode *node = this->getbNode(); + + MapUVOperation *operation = new MapUVOperation(); + operation->setAlpha((float)node->custom1); + operation->setResolutionInputSocketIndex(1); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp deleted file mode 100644 index feb9c75ec56..00000000000 --- a/source/blender/compositor/nodes/COM_MapUVNode.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MapUVNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_MapUVOperation.h" - -MapUVNode::MapUVNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MapUVNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bNode *node = this->getbNode(); - - MapUVOperation *operation = new MapUVOperation(); - operation->setAlpha((float)node->custom1); - operation->setResolutionInputSocketIndex(1); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cc b/source/blender/compositor/nodes/COM_MapValueNode.cc new file mode 100644 index 00000000000..e07df8ad367 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapValueNode.cc @@ -0,0 +1,43 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MapValueNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_MapValueOperation.h" + +MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MapValueNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + TexMapping *storage = (TexMapping *)this->getbNode()->storage; + + NodeInput *colorSocket = this->getInputSocket(0); + NodeOutput *valueSocket = this->getOutputSocket(0); + + MapValueOperation *convertProg = new MapValueOperation(); + convertProg->setSettings(storage); + converter.addOperation(convertProg); + + converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0)); + converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp deleted file mode 100644 index e07df8ad367..00000000000 --- a/source/blender/compositor/nodes/COM_MapValueNode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MapValueNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_MapValueOperation.h" - -MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MapValueNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - TexMapping *storage = (TexMapping *)this->getbNode()->storage; - - NodeInput *colorSocket = this->getInputSocket(0); - NodeOutput *valueSocket = this->getOutputSocket(0); - - MapValueOperation *convertProg = new MapValueOperation(); - convertProg->setSettings(storage); - converter.addOperation(convertProg); - - converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0)); - converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_MaskNode.cc b/source/blender/compositor/nodes/COM_MaskNode.cc new file mode 100644 index 00000000000..a6415a3992e --- /dev/null +++ b/source/blender/compositor/nodes/COM_MaskNode.cc @@ -0,0 +1,70 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_MaskNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_MaskOperation.h" + +#include "DNA_mask_types.h" + +MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MaskNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + const RenderData *rd = context.getRenderData(); + const float render_size_factor = context.getRenderPercentageAsFactor(); + + NodeOutput *outputMask = this->getOutputSocket(0); + + bNode *editorNode = this->getbNode(); + NodeMask *data = (NodeMask *)editorNode->storage; + Mask *mask = (Mask *)editorNode->id; + + // always connect the output image + MaskOperation *operation = new MaskOperation(); + + if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) { + operation->setMaskWidth(data->size_x); + operation->setMaskHeight(data->size_y); + } + else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) { + operation->setMaskWidth(data->size_x * render_size_factor); + operation->setMaskHeight(data->size_y * render_size_factor); + } + else { + operation->setMaskWidth(rd->xsch * render_size_factor); + operation->setMaskHeight(rd->ysch * render_size_factor); + } + + operation->setMask(mask); + operation->setFramenumber(context.getFramenumber()); + operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); + + if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editorNode->custom2 > 1) && + (editorNode->custom3 > FLT_EPSILON)) { + operation->setMotionBlurSamples(editorNode->custom2); + operation->setMotionBlurShutter(editorNode->custom3); + } + + converter.addOperation(operation); + converter.mapOutputSocket(outputMask, operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp deleted file mode 100644 index a6415a3992e..00000000000 --- a/source/blender/compositor/nodes/COM_MaskNode.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_MaskNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_MaskOperation.h" - -#include "DNA_mask_types.h" - -MaskNode::MaskNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MaskNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - const RenderData *rd = context.getRenderData(); - const float render_size_factor = context.getRenderPercentageAsFactor(); - - NodeOutput *outputMask = this->getOutputSocket(0); - - bNode *editorNode = this->getbNode(); - NodeMask *data = (NodeMask *)editorNode->storage; - Mask *mask = (Mask *)editorNode->id; - - // always connect the output image - MaskOperation *operation = new MaskOperation(); - - if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED) { - operation->setMaskWidth(data->size_x); - operation->setMaskHeight(data->size_y); - } - else if (editorNode->custom1 & CMP_NODEFLAG_MASK_FIXED_SCENE) { - operation->setMaskWidth(data->size_x * render_size_factor); - operation->setMaskHeight(data->size_y * render_size_factor); - } - else { - operation->setMaskWidth(rd->xsch * render_size_factor); - operation->setMaskHeight(rd->ysch * render_size_factor); - } - - operation->setMask(mask); - operation->setFramenumber(context.getFramenumber()); - operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0); - - if ((editorNode->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) && (editorNode->custom2 > 1) && - (editorNode->custom3 > FLT_EPSILON)) { - operation->setMotionBlurSamples(editorNode->custom2); - operation->setMotionBlurShutter(editorNode->custom3); - } - - converter.addOperation(operation); - converter.mapOutputSocket(outputMask, operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_MathNode.cc b/source/blender/compositor/nodes/COM_MathNode.cc new file mode 100644 index 00000000000..0edf880400f --- /dev/null +++ b/source/blender/compositor/nodes/COM_MathNode.cc @@ -0,0 +1,161 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MathNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_MathBaseOperation.h" + +void MathNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + MathBaseOperation *operation = nullptr; + + switch (this->getbNode()->custom1) { + case NODE_MATH_ADD: + operation = new MathAddOperation(); + break; + case NODE_MATH_SUBTRACT: + operation = new MathSubtractOperation(); + break; + case NODE_MATH_MULTIPLY: + operation = new MathMultiplyOperation(); + break; + case NODE_MATH_DIVIDE: + operation = new MathDivideOperation(); + break; + case NODE_MATH_SINE: + operation = new MathSineOperation(); + break; + case NODE_MATH_COSINE: + operation = new MathCosineOperation(); + break; + case NODE_MATH_TANGENT: + operation = new MathTangentOperation(); + break; + case NODE_MATH_ARCSINE: + operation = new MathArcSineOperation(); + break; + case NODE_MATH_ARCCOSINE: + operation = new MathArcCosineOperation(); + break; + case NODE_MATH_ARCTANGENT: + operation = new MathArcTangentOperation(); + break; + case NODE_MATH_SINH: + operation = new MathHyperbolicSineOperation(); + break; + case NODE_MATH_COSH: + operation = new MathHyperbolicCosineOperation(); + break; + case NODE_MATH_TANH: + operation = new MathHyperbolicTangentOperation(); + break; + case NODE_MATH_POWER: + operation = new MathPowerOperation(); + break; + case NODE_MATH_LOGARITHM: + operation = new MathLogarithmOperation(); + break; + case NODE_MATH_MINIMUM: + operation = new MathMinimumOperation(); + break; + case NODE_MATH_MAXIMUM: + operation = new MathMaximumOperation(); + break; + case NODE_MATH_ROUND: + operation = new MathRoundOperation(); + break; + case NODE_MATH_LESS_THAN: + operation = new MathLessThanOperation(); + break; + case NODE_MATH_GREATER_THAN: + operation = new MathGreaterThanOperation(); + break; + case NODE_MATH_MODULO: + operation = new MathModuloOperation(); + break; + case NODE_MATH_ABSOLUTE: + operation = new MathAbsoluteOperation(); + break; + case NODE_MATH_RADIANS: + operation = new MathRadiansOperation(); + break; + case NODE_MATH_DEGREES: + operation = new MathDegreesOperation(); + break; + case NODE_MATH_ARCTAN2: + operation = new MathArcTan2Operation(); + break; + case NODE_MATH_FLOOR: + operation = new MathFloorOperation(); + break; + case NODE_MATH_CEIL: + operation = new MathCeilOperation(); + break; + case NODE_MATH_FRACTION: + operation = new MathFractOperation(); + break; + case NODE_MATH_SQRT: + operation = new MathSqrtOperation(); + break; + case NODE_MATH_INV_SQRT: + operation = new MathInverseSqrtOperation(); + break; + case NODE_MATH_SIGN: + operation = new MathSignOperation(); + break; + case NODE_MATH_EXPONENT: + operation = new MathExponentOperation(); + break; + case NODE_MATH_TRUNC: + operation = new MathTruncOperation(); + break; + case NODE_MATH_SNAP: + operation = new MathSnapOperation(); + break; + case NODE_MATH_WRAP: + operation = new MathWrapOperation(); + break; + case NODE_MATH_PINGPONG: + operation = new MathPingpongOperation(); + break; + case NODE_MATH_COMPARE: + operation = new MathCompareOperation(); + break; + case NODE_MATH_MULTIPLY_ADD: + operation = new MathMultiplyAddOperation(); + break; + case NODE_MATH_SMOOTH_MIN: + operation = new MathSmoothMinOperation(); + break; + case NODE_MATH_SMOOTH_MAX: + operation = new MathSmoothMaxOperation(); + break; + } + + if (operation) { + bool useClamp = getbNode()->custom2; + operation->setUseClamp(useClamp); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp deleted file mode 100644 index 0edf880400f..00000000000 --- a/source/blender/compositor/nodes/COM_MathNode.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MathNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_MathBaseOperation.h" - -void MathNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - MathBaseOperation *operation = nullptr; - - switch (this->getbNode()->custom1) { - case NODE_MATH_ADD: - operation = new MathAddOperation(); - break; - case NODE_MATH_SUBTRACT: - operation = new MathSubtractOperation(); - break; - case NODE_MATH_MULTIPLY: - operation = new MathMultiplyOperation(); - break; - case NODE_MATH_DIVIDE: - operation = new MathDivideOperation(); - break; - case NODE_MATH_SINE: - operation = new MathSineOperation(); - break; - case NODE_MATH_COSINE: - operation = new MathCosineOperation(); - break; - case NODE_MATH_TANGENT: - operation = new MathTangentOperation(); - break; - case NODE_MATH_ARCSINE: - operation = new MathArcSineOperation(); - break; - case NODE_MATH_ARCCOSINE: - operation = new MathArcCosineOperation(); - break; - case NODE_MATH_ARCTANGENT: - operation = new MathArcTangentOperation(); - break; - case NODE_MATH_SINH: - operation = new MathHyperbolicSineOperation(); - break; - case NODE_MATH_COSH: - operation = new MathHyperbolicCosineOperation(); - break; - case NODE_MATH_TANH: - operation = new MathHyperbolicTangentOperation(); - break; - case NODE_MATH_POWER: - operation = new MathPowerOperation(); - break; - case NODE_MATH_LOGARITHM: - operation = new MathLogarithmOperation(); - break; - case NODE_MATH_MINIMUM: - operation = new MathMinimumOperation(); - break; - case NODE_MATH_MAXIMUM: - operation = new MathMaximumOperation(); - break; - case NODE_MATH_ROUND: - operation = new MathRoundOperation(); - break; - case NODE_MATH_LESS_THAN: - operation = new MathLessThanOperation(); - break; - case NODE_MATH_GREATER_THAN: - operation = new MathGreaterThanOperation(); - break; - case NODE_MATH_MODULO: - operation = new MathModuloOperation(); - break; - case NODE_MATH_ABSOLUTE: - operation = new MathAbsoluteOperation(); - break; - case NODE_MATH_RADIANS: - operation = new MathRadiansOperation(); - break; - case NODE_MATH_DEGREES: - operation = new MathDegreesOperation(); - break; - case NODE_MATH_ARCTAN2: - operation = new MathArcTan2Operation(); - break; - case NODE_MATH_FLOOR: - operation = new MathFloorOperation(); - break; - case NODE_MATH_CEIL: - operation = new MathCeilOperation(); - break; - case NODE_MATH_FRACTION: - operation = new MathFractOperation(); - break; - case NODE_MATH_SQRT: - operation = new MathSqrtOperation(); - break; - case NODE_MATH_INV_SQRT: - operation = new MathInverseSqrtOperation(); - break; - case NODE_MATH_SIGN: - operation = new MathSignOperation(); - break; - case NODE_MATH_EXPONENT: - operation = new MathExponentOperation(); - break; - case NODE_MATH_TRUNC: - operation = new MathTruncOperation(); - break; - case NODE_MATH_SNAP: - operation = new MathSnapOperation(); - break; - case NODE_MATH_WRAP: - operation = new MathWrapOperation(); - break; - case NODE_MATH_PINGPONG: - operation = new MathPingpongOperation(); - break; - case NODE_MATH_COMPARE: - operation = new MathCompareOperation(); - break; - case NODE_MATH_MULTIPLY_ADD: - operation = new MathMultiplyAddOperation(); - break; - case NODE_MATH_SMOOTH_MIN: - operation = new MathSmoothMinOperation(); - break; - case NODE_MATH_SMOOTH_MAX: - operation = new MathSmoothMaxOperation(); - break; - } - - if (operation) { - bool useClamp = getbNode()->custom2; - operation->setUseClamp(useClamp); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - } -} diff --git a/source/blender/compositor/nodes/COM_MixNode.cc b/source/blender/compositor/nodes/COM_MixNode.cc new file mode 100644 index 00000000000..d082590d21b --- /dev/null +++ b/source/blender/compositor/nodes/COM_MixNode.cc @@ -0,0 +1,112 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MixNode.h" + +#include "COM_MixOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" /* the ramp types */ + +MixNode::MixNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MixNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *valueSocket = this->getInputSocket(0); + NodeInput *color1Socket = this->getInputSocket(1); + NodeInput *color2Socket = this->getInputSocket(2); + NodeOutput *outputSocket = this->getOutputSocket(0); + bNode *editorNode = this->getbNode(); + bool useAlphaPremultiply = (this->getbNode()->custom2 & 1) != 0; + bool useClamp = (this->getbNode()->custom2 & 2) != 0; + + 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 MixColorBurnOperation(); + 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(useAlphaPremultiply); + convertProg->setUseClamp(useClamp); + converter.addOperation(convertProg); + + converter.mapInputSocket(valueSocket, convertProg->getInputSocket(0)); + converter.mapInputSocket(color1Socket, convertProg->getInputSocket(1)); + converter.mapInputSocket(color2Socket, convertProg->getInputSocket(2)); + converter.mapOutputSocket(outputSocket, convertProg->getOutputSocket(0)); + + converter.addPreview(convertProg->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp deleted file mode 100644 index d082590d21b..00000000000 --- a/source/blender/compositor/nodes/COM_MixNode.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MixNode.h" - -#include "COM_MixOperation.h" - -#include "COM_ExecutionSystem.h" -#include "COM_SetValueOperation.h" -#include "DNA_material_types.h" /* the ramp types */ - -MixNode::MixNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MixNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *valueSocket = this->getInputSocket(0); - NodeInput *color1Socket = this->getInputSocket(1); - NodeInput *color2Socket = this->getInputSocket(2); - NodeOutput *outputSocket = this->getOutputSocket(0); - bNode *editorNode = this->getbNode(); - bool useAlphaPremultiply = (this->getbNode()->custom2 & 1) != 0; - bool useClamp = (this->getbNode()->custom2 & 2) != 0; - - 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 MixColorBurnOperation(); - 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(useAlphaPremultiply); - convertProg->setUseClamp(useClamp); - converter.addOperation(convertProg); - - converter.mapInputSocket(valueSocket, convertProg->getInputSocket(0)); - converter.mapInputSocket(color1Socket, convertProg->getInputSocket(1)); - converter.mapInputSocket(color2Socket, convertProg->getInputSocket(2)); - converter.mapOutputSocket(outputSocket, convertProg->getOutputSocket(0)); - - converter.addPreview(convertProg->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cc b/source/blender/compositor/nodes/COM_MovieClipNode.cc new file mode 100644 index 00000000000..7cc8f2ea19c --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieClipNode.cc @@ -0,0 +1,108 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MovieClipNode.h" +#include "COM_ConvertColorProfileOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_MovieClipOperation.h" +#include "COM_SetValueOperation.h" + +#include "BKE_movieclip.h" +#include "BKE_tracking.h" + +#include "DNA_movieclip_types.h" + +#include "IMB_imbuf.h" + +MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MovieClipNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeOutput *outputMovieClip = this->getOutputSocket(0); + NodeOutput *alphaMovieClip = this->getOutputSocket(1); + NodeOutput *offsetXMovieClip = this->getOutputSocket(2); + NodeOutput *offsetYMovieClip = this->getOutputSocket(3); + NodeOutput *scaleMovieClip = this->getOutputSocket(4); + NodeOutput *angleMovieClip = this->getOutputSocket(5); + + bNode *editorNode = this->getbNode(); + MovieClip *movieClip = (MovieClip *)editorNode->id; + MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage; + bool cacheFrame = !context.isRendering(); + + ImBuf *ibuf = nullptr; + if (movieClip) { + if (cacheFrame) { + ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser); + } + else { + ibuf = BKE_movieclip_get_ibuf_flag( + movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP); + } + } + + // always connect the output image + MovieClipOperation *operation = new MovieClipOperation(); + operation->setMovieClip(movieClip); + operation->setMovieClipUser(movieClipUser); + operation->setFramenumber(context.getFramenumber()); + operation->setCacheFrame(cacheFrame); + + converter.addOperation(operation); + converter.mapOutputSocket(outputMovieClip, operation->getOutputSocket()); + converter.addPreview(operation->getOutputSocket()); + + MovieClipAlphaOperation *alphaOperation = new MovieClipAlphaOperation(); + alphaOperation->setMovieClip(movieClip); + alphaOperation->setMovieClipUser(movieClipUser); + alphaOperation->setFramenumber(context.getFramenumber()); + alphaOperation->setCacheFrame(cacheFrame); + + converter.addOperation(alphaOperation); + converter.mapOutputSocket(alphaMovieClip, alphaOperation->getOutputSocket()); + + 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) { + int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, + context.getFramenumber()); + + BKE_tracking_stabilization_data_get( + movieClip, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle); + } + } + + converter.addOutputValue(offsetXMovieClip, loc[0]); + converter.addOutputValue(offsetYMovieClip, loc[1]); + converter.addOutputValue(scaleMovieClip, scale); + converter.addOutputValue(angleMovieClip, angle); + + if (ibuf) { + IMB_freeImBuf(ibuf); + } +} diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp deleted file mode 100644 index 7cc8f2ea19c..00000000000 --- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MovieClipNode.h" -#include "COM_ConvertColorProfileOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_MovieClipOperation.h" -#include "COM_SetValueOperation.h" - -#include "BKE_movieclip.h" -#include "BKE_tracking.h" - -#include "DNA_movieclip_types.h" - -#include "IMB_imbuf.h" - -MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MovieClipNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeOutput *outputMovieClip = this->getOutputSocket(0); - NodeOutput *alphaMovieClip = this->getOutputSocket(1); - NodeOutput *offsetXMovieClip = this->getOutputSocket(2); - NodeOutput *offsetYMovieClip = this->getOutputSocket(3); - NodeOutput *scaleMovieClip = this->getOutputSocket(4); - NodeOutput *angleMovieClip = this->getOutputSocket(5); - - bNode *editorNode = this->getbNode(); - MovieClip *movieClip = (MovieClip *)editorNode->id; - MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage; - bool cacheFrame = !context.isRendering(); - - ImBuf *ibuf = nullptr; - if (movieClip) { - if (cacheFrame) { - ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser); - } - else { - ibuf = BKE_movieclip_get_ibuf_flag( - movieClip, movieClipUser, movieClip->flag, MOVIECLIP_CACHE_SKIP); - } - } - - // always connect the output image - MovieClipOperation *operation = new MovieClipOperation(); - operation->setMovieClip(movieClip); - operation->setMovieClipUser(movieClipUser); - operation->setFramenumber(context.getFramenumber()); - operation->setCacheFrame(cacheFrame); - - converter.addOperation(operation); - converter.mapOutputSocket(outputMovieClip, operation->getOutputSocket()); - converter.addPreview(operation->getOutputSocket()); - - MovieClipAlphaOperation *alphaOperation = new MovieClipAlphaOperation(); - alphaOperation->setMovieClip(movieClip); - alphaOperation->setMovieClipUser(movieClipUser); - alphaOperation->setFramenumber(context.getFramenumber()); - alphaOperation->setCacheFrame(cacheFrame); - - converter.addOperation(alphaOperation); - converter.mapOutputSocket(alphaMovieClip, alphaOperation->getOutputSocket()); - - 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) { - int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(movieClip, - context.getFramenumber()); - - BKE_tracking_stabilization_data_get( - movieClip, clip_framenr, ibuf->x, ibuf->y, loc, &scale, &angle); - } - } - - converter.addOutputValue(offsetXMovieClip, loc[0]); - converter.addOutputValue(offsetYMovieClip, loc[1]); - converter.addOutputValue(scaleMovieClip, scale); - converter.addOutputValue(angleMovieClip, angle); - - if (ibuf) { - IMB_freeImBuf(ibuf); - } -} diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cc b/source/blender/compositor/nodes/COM_MovieDistortionNode.cc new file mode 100644 index 00000000000..ebace6d5fff --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cc @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_MovieDistortionNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_MovieDistortionOperation.h" +#include "DNA_movieclip_types.h" + +MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void MovieDistortionNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *bnode = this->getbNode(); + MovieClip *clip = (MovieClip *)bnode->id; + + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + + MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1); + operation->setMovieClip(clip); + operation->setFramenumber(context.getFramenumber()); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp deleted file mode 100644 index ebace6d5fff..00000000000 --- a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_MovieDistortionNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_MovieDistortionOperation.h" -#include "DNA_movieclip_types.h" - -MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void MovieDistortionNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *bnode = this->getbNode(); - MovieClip *clip = (MovieClip *)bnode->id; - - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - - MovieDistortionOperation *operation = new MovieDistortionOperation(bnode->custom1 == 1); - operation->setMovieClip(clip); - operation->setFramenumber(context.getFramenumber()); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_NormalNode.cc b/source/blender/compositor/nodes/COM_NormalNode.cc new file mode 100644 index 00000000000..1f48a26fd75 --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalNode.cc @@ -0,0 +1,56 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_NormalNode.h" +#include "BKE_node.h" +#include "COM_DotproductOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetVectorOperation.h" + +NormalNode::NormalNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void NormalNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + NodeOutput *outputSocketDotproduct = this->getOutputSocket(1); + + SetVectorOperation *operationSet = new SetVectorOperation(); + float normal[3]; + outputSocket->getEditorValueVector(normal); + /* animation can break normalization, this restores it */ + normalize_v3(normal); + operationSet->setX(normal[0]); + operationSet->setY(normal[1]); + operationSet->setZ(normal[2]); + operationSet->setW(0.0f); + converter.addOperation(operationSet); + + converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0)); + + DotproductOperation *operation = new DotproductOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.addLink(operationSet->getOutputSocket(0), operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocketDotproduct, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp deleted file mode 100644 index 1f48a26fd75..00000000000 --- a/source/blender/compositor/nodes/COM_NormalNode.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_NormalNode.h" -#include "BKE_node.h" -#include "COM_DotproductOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetVectorOperation.h" - -NormalNode::NormalNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void NormalNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - NodeOutput *outputSocketDotproduct = this->getOutputSocket(1); - - SetVectorOperation *operationSet = new SetVectorOperation(); - float normal[3]; - outputSocket->getEditorValueVector(normal); - /* animation can break normalization, this restores it */ - normalize_v3(normal); - operationSet->setX(normal[0]); - operationSet->setY(normal[1]); - operationSet->setZ(normal[2]); - operationSet->setW(0.0f); - converter.addOperation(operationSet); - - converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0)); - - DotproductOperation *operation = new DotproductOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.addLink(operationSet->getOutputSocket(0), operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocketDotproduct, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cc b/source/blender/compositor/nodes/COM_NormalizeNode.cc new file mode 100644 index 00000000000..72459fd477c --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalizeNode.cc @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_NormalizeNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_NormalizeOperation.h" + +NormalizeNode::NormalizeNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void NormalizeNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NormalizeOperation *operation = new NormalizeOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp deleted file mode 100644 index 72459fd477c..00000000000 --- a/source/blender/compositor/nodes/COM_NormalizeNode.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_NormalizeNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_NormalizeOperation.h" - -NormalizeNode::NormalizeNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void NormalizeNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NormalizeOperation *operation = new NormalizeOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cc b/source/blender/compositor/nodes/COM_OutputFileNode.cc new file mode 100644 index 00000000000..dcc1fbdec67 --- /dev/null +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cc @@ -0,0 +1,153 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_OutputFileNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_OutputFileMultiViewOperation.h" +#include "COM_OutputFileOperation.h" + +#include "BKE_scene.h" + +#include "BLI_path_util.h" + +OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void OutputFileNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage; + const bool is_multiview = (context.getRenderData()->scemode & R_MULTIVIEW) != 0; + + if (!context.isRendering()) { + /* only output files when rendering a sequence - + * otherwise, it overwrites the output files just + * scrubbing through the timeline when the compositor updates. + */ + return; + } + + if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) { + const bool use_half_float = (storage->format.depth == R_IMF_CHAN_DEPTH_16); + /* single output operation for the multilayer file */ + OutputOpenExrMultiLayerOperation *outputOperation; + + if (is_multiview && storage->format.views_format == R_IMF_VIEWS_MULTIVIEW) { + outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(context.getScene(), + context.getRenderData(), + context.getbNodeTree(), + storage->base_path, + storage->format.exr_codec, + use_half_float, + context.getViewName()); + } + else { + outputOperation = new OutputOpenExrMultiLayerOperation(context.getScene(), + context.getRenderData(), + context.getbNodeTree(), + storage->base_path, + storage->format.exr_codec, + use_half_float, + context.getViewName()); + } + converter.addOperation(outputOperation); + + int num_inputs = getNumberOfInputSockets(); + bool previewAdded = false; + for (int i = 0; i < num_inputs; i++) { + NodeInput *input = getInputSocket(i); + NodeImageMultiFileSocket *sockdata = + (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage; + + /* note: layer becomes an empty placeholder if the input is not linked */ + outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked()); + + converter.mapInputSocket(input, outputOperation->getInputSocket(i)); + + if (!previewAdded) { + converter.addNodeInputPreview(input); + previewAdded = true; + } + } + } + else { /* single layer format */ + int num_inputs = getNumberOfInputSockets(); + bool previewAdded = false; + for (int i = 0; i < num_inputs; i++) { + NodeInput *input = getInputSocket(i); + if (input->isLinked()) { + 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); + + NodeOperation *outputOperation = nullptr; + + if (is_multiview && format->views_format == R_IMF_VIEWS_MULTIVIEW) { + outputOperation = new OutputOpenExrSingleLayerMultiViewOperation( + context.getRenderData(), + context.getbNodeTree(), + input->getDataType(), + format, + path, + context.getViewSettings(), + context.getDisplaySettings(), + context.getViewName(), + sockdata->save_as_render); + } + else if ((!is_multiview) || (format->views_format == R_IMF_VIEWS_INDIVIDUAL)) { + outputOperation = new OutputSingleLayerOperation(context.getRenderData(), + context.getbNodeTree(), + input->getDataType(), + format, + path, + context.getViewSettings(), + context.getDisplaySettings(), + context.getViewName(), + sockdata->save_as_render); + } + else { /* R_IMF_VIEWS_STEREO_3D */ + outputOperation = new OutputStereoOperation(context.getRenderData(), + context.getbNodeTree(), + input->getDataType(), + format, + path, + sockdata->layer, + context.getViewSettings(), + context.getDisplaySettings(), + context.getViewName(), + sockdata->save_as_render); + } + + converter.addOperation(outputOperation); + converter.mapInputSocket(input, outputOperation->getInputSocket(0)); + + if (!previewAdded) { + converter.addNodeInputPreview(input); + previewAdded = true; + } + } + } + } +} diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp deleted file mode 100644 index dcc1fbdec67..00000000000 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_OutputFileNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_OutputFileMultiViewOperation.h" -#include "COM_OutputFileOperation.h" - -#include "BKE_scene.h" - -#include "BLI_path_util.h" - -OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void OutputFileNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeImageMultiFile *storage = (NodeImageMultiFile *)this->getbNode()->storage; - const bool is_multiview = (context.getRenderData()->scemode & R_MULTIVIEW) != 0; - - if (!context.isRendering()) { - /* only output files when rendering a sequence - - * otherwise, it overwrites the output files just - * scrubbing through the timeline when the compositor updates. - */ - return; - } - - if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) { - const bool use_half_float = (storage->format.depth == R_IMF_CHAN_DEPTH_16); - /* single output operation for the multilayer file */ - OutputOpenExrMultiLayerOperation *outputOperation; - - if (is_multiview && storage->format.views_format == R_IMF_VIEWS_MULTIVIEW) { - outputOperation = new OutputOpenExrMultiLayerMultiViewOperation(context.getScene(), - context.getRenderData(), - context.getbNodeTree(), - storage->base_path, - storage->format.exr_codec, - use_half_float, - context.getViewName()); - } - else { - outputOperation = new OutputOpenExrMultiLayerOperation(context.getScene(), - context.getRenderData(), - context.getbNodeTree(), - storage->base_path, - storage->format.exr_codec, - use_half_float, - context.getViewName()); - } - converter.addOperation(outputOperation); - - int num_inputs = getNumberOfInputSockets(); - bool previewAdded = false; - for (int i = 0; i < num_inputs; i++) { - NodeInput *input = getInputSocket(i); - NodeImageMultiFileSocket *sockdata = - (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage; - - /* note: layer becomes an empty placeholder if the input is not linked */ - outputOperation->add_layer(sockdata->layer, input->getDataType(), input->isLinked()); - - converter.mapInputSocket(input, outputOperation->getInputSocket(i)); - - if (!previewAdded) { - converter.addNodeInputPreview(input); - previewAdded = true; - } - } - } - else { /* single layer format */ - int num_inputs = getNumberOfInputSockets(); - bool previewAdded = false; - for (int i = 0; i < num_inputs; i++) { - NodeInput *input = getInputSocket(i); - if (input->isLinked()) { - 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); - - NodeOperation *outputOperation = nullptr; - - if (is_multiview && format->views_format == R_IMF_VIEWS_MULTIVIEW) { - outputOperation = new OutputOpenExrSingleLayerMultiViewOperation( - context.getRenderData(), - context.getbNodeTree(), - input->getDataType(), - format, - path, - context.getViewSettings(), - context.getDisplaySettings(), - context.getViewName(), - sockdata->save_as_render); - } - else if ((!is_multiview) || (format->views_format == R_IMF_VIEWS_INDIVIDUAL)) { - outputOperation = new OutputSingleLayerOperation(context.getRenderData(), - context.getbNodeTree(), - input->getDataType(), - format, - path, - context.getViewSettings(), - context.getDisplaySettings(), - context.getViewName(), - sockdata->save_as_render); - } - else { /* R_IMF_VIEWS_STEREO_3D */ - outputOperation = new OutputStereoOperation(context.getRenderData(), - context.getbNodeTree(), - input->getDataType(), - format, - path, - sockdata->layer, - context.getViewSettings(), - context.getDisplaySettings(), - context.getViewName(), - sockdata->save_as_render); - } - - converter.addOperation(outputOperation); - converter.mapInputSocket(input, outputOperation->getInputSocket(0)); - - if (!previewAdded) { - converter.addNodeInputPreview(input); - previewAdded = true; - } - } - } - } -} diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cc b/source/blender/compositor/nodes/COM_PixelateNode.cc new file mode 100644 index 00000000000..f238f68727e --- /dev/null +++ b/source/blender/compositor/nodes/COM_PixelateNode.cc @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_PixelateNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_PixelateOperation.h" + +PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void PixelateNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + DataType datatype = inputSocket->getDataType(); + + if (inputSocket->isLinked()) { + NodeOutput *link = inputSocket->getLink(); + datatype = link->getDataType(); + } + + PixelateOperation *operation = new PixelateOperation(datatype); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cpp b/source/blender/compositor/nodes/COM_PixelateNode.cpp deleted file mode 100644 index f238f68727e..00000000000 --- a/source/blender/compositor/nodes/COM_PixelateNode.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_PixelateNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_PixelateOperation.h" - -PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void PixelateNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - DataType datatype = inputSocket->getDataType(); - - if (inputSocket->isLinked()) { - NodeOutput *link = inputSocket->getLink(); - datatype = link->getDataType(); - } - - PixelateOperation *operation = new PixelateOperation(datatype); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cc b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cc new file mode 100644 index 00000000000..6b9b51631ec --- /dev/null +++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cc @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2013, Blender Foundation. + */ + +#include "COM_PlaneTrackDeformNode.h" +#include "COM_ExecutionSystem.h" + +#include "COM_PlaneTrackOperation.h" + +#include "BKE_movieclip.h" +#include "BKE_node.h" +#include "BKE_tracking.h" + +PlaneTrackDeformNode::PlaneTrackDeformNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void PlaneTrackDeformNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + MovieClip *clip = (MovieClip *)editorNode->id; + NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *)editorNode->storage; + + int frame_number = context.getFramenumber(); + + NodeInput *input_image = this->getInputSocket(0); + NodeOutput *output_warped_image = this->getOutputSocket(0); + NodeOutput *output_plane = this->getOutputSocket(1); + + PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation(); + warp_image_operation->setMovieClip(clip); + warp_image_operation->setTrackingObject(data->tracking_object); + warp_image_operation->setPlaneTrackName(data->plane_track_name); + warp_image_operation->setFramenumber(frame_number); + if (data->flag & CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR) { + warp_image_operation->setMotionBlurSamples(data->motion_blur_samples); + warp_image_operation->setMotionBlurShutter(data->motion_blur_shutter); + } + converter.addOperation(warp_image_operation); + + converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0)); + converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket()); + + PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation(); + plane_mask_operation->setMovieClip(clip); + plane_mask_operation->setTrackingObject(data->tracking_object); + plane_mask_operation->setPlaneTrackName(data->plane_track_name); + plane_mask_operation->setFramenumber(frame_number); + if (data->flag & CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR) { + plane_mask_operation->setMotionBlurSamples(data->motion_blur_samples); + plane_mask_operation->setMotionBlurShutter(data->motion_blur_shutter); + } + converter.addOperation(plane_mask_operation); + + converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp deleted file mode 100644 index 6b9b51631ec..00000000000 --- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2013, Blender Foundation. - */ - -#include "COM_PlaneTrackDeformNode.h" -#include "COM_ExecutionSystem.h" - -#include "COM_PlaneTrackOperation.h" - -#include "BKE_movieclip.h" -#include "BKE_node.h" -#include "BKE_tracking.h" - -PlaneTrackDeformNode::PlaneTrackDeformNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void PlaneTrackDeformNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - MovieClip *clip = (MovieClip *)editorNode->id; - NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *)editorNode->storage; - - int frame_number = context.getFramenumber(); - - NodeInput *input_image = this->getInputSocket(0); - NodeOutput *output_warped_image = this->getOutputSocket(0); - NodeOutput *output_plane = this->getOutputSocket(1); - - PlaneTrackWarpImageOperation *warp_image_operation = new PlaneTrackWarpImageOperation(); - warp_image_operation->setMovieClip(clip); - warp_image_operation->setTrackingObject(data->tracking_object); - warp_image_operation->setPlaneTrackName(data->plane_track_name); - warp_image_operation->setFramenumber(frame_number); - if (data->flag & CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR) { - warp_image_operation->setMotionBlurSamples(data->motion_blur_samples); - warp_image_operation->setMotionBlurShutter(data->motion_blur_shutter); - } - converter.addOperation(warp_image_operation); - - converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0)); - converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket()); - - PlaneTrackMaskOperation *plane_mask_operation = new PlaneTrackMaskOperation(); - plane_mask_operation->setMovieClip(clip); - plane_mask_operation->setTrackingObject(data->tracking_object); - plane_mask_operation->setPlaneTrackName(data->plane_track_name); - plane_mask_operation->setFramenumber(frame_number); - if (data->flag & CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR) { - plane_mask_operation->setMotionBlurSamples(data->motion_blur_samples); - plane_mask_operation->setMotionBlurShutter(data->motion_blur_shutter); - } - converter.addOperation(plane_mask_operation); - - converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cc b/source/blender/compositor/nodes/COM_RenderLayersNode.cc new file mode 100644 index 00000000000..6be86c04c4d --- /dev/null +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cc @@ -0,0 +1,176 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_RenderLayersNode.h" +#include "COM_RenderLayersProg.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_SetVectorOperation.h" +#include "COM_TranslateOperation.h" + +RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void RenderLayersNode::testSocketLink(NodeConverter &converter, + const CompositorContext &context, + NodeOutput *output, + RenderLayersProg *operation, + Scene *scene, + int layerId, + bool is_preview) const +{ + operation->setScene(scene); + operation->setLayerId(layerId); + operation->setRenderData(context.getRenderData()); + operation->setViewName(context.getViewName()); + + converter.mapOutputSocket(output, operation->getOutputSocket()); + converter.addOperation(operation); + + if (is_preview) { /* only for image socket */ + converter.addPreview(operation->getOutputSocket()); + } +} + +void RenderLayersNode::testRenderLink(NodeConverter &converter, + const CompositorContext &context, + Render *re) const +{ + Scene *scene = (Scene *)this->getbNode()->id; + const short layerId = this->getbNode()->custom1; + RenderResult *rr = RE_AcquireResultRead(re); + if (rr == nullptr) { + missingRenderLink(converter); + return; + } + ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, layerId); + if (view_layer == nullptr) { + missingRenderLink(converter); + return; + } + RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name); + if (rl == nullptr) { + missingRenderLink(converter); + return; + } + const int num_outputs = this->getNumberOfOutputSockets(); + for (int i = 0; i < num_outputs; i++) { + NodeOutput *output = this->getOutputSocket(i); + NodeImageLayer *storage = (NodeImageLayer *)output->getbNodeSocket()->storage; + RenderPass *rpass = (RenderPass *)BLI_findstring( + &rl->passes, storage->pass_name, offsetof(RenderPass, name)); + if (rpass == nullptr) { + missingSocketLink(converter, output); + continue; + } + RenderLayersProg *operation; + bool is_preview; + if (STREQ(rpass->name, RE_PASSNAME_COMBINED) && + STREQ(output->getbNodeSocket()->name, "Alpha")) { + operation = new RenderLayersAlphaProg(rpass->name, COM_DT_VALUE, rpass->channels); + is_preview = false; + } + else if (STREQ(rpass->name, RE_PASSNAME_Z)) { + operation = new RenderLayersDepthProg(rpass->name, COM_DT_VALUE, rpass->channels); + is_preview = false; + } + else { + DataType type; + switch (rpass->channels) { + case 4: + type = COM_DT_COLOR; + break; + case 3: + type = COM_DT_VECTOR; + break; + case 1: + type = COM_DT_VALUE; + break; + default: + BLI_assert(!"Unexpected number of channels for pass"); + type = COM_DT_VALUE; + break; + } + operation = new RenderLayersProg(rpass->name, type, rpass->channels); + is_preview = STREQ(output->getbNodeSocket()->name, "Image"); + } + testSocketLink(converter, context, output, operation, scene, layerId, is_preview); + } +} + +void RenderLayersNode::missingSocketLink(NodeConverter &converter, NodeOutput *output) const +{ + NodeOperation *operation; + switch (output->getDataType()) { + case COM_DT_COLOR: { + const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + SetColorOperation *color_operation = new SetColorOperation(); + color_operation->setChannels(color); + operation = color_operation; + break; + } + case COM_DT_VECTOR: { + const float vector[3] = {0.0f, 0.0f, 0.0f}; + SetVectorOperation *vector_operation = new SetVectorOperation(); + vector_operation->setVector(vector); + operation = vector_operation; + break; + } + case COM_DT_VALUE: { + SetValueOperation *value_operation = new SetValueOperation(); + value_operation->setValue(0.0f); + operation = value_operation; + break; + } + default: { + BLI_assert("!Unexpected data type"); + return; + } + } + + converter.mapOutputSocket(output, operation->getOutputSocket()); + converter.addOperation(operation); +} + +void RenderLayersNode::missingRenderLink(NodeConverter &converter) const +{ + const int num_outputs = this->getNumberOfOutputSockets(); + for (int i = 0; i < num_outputs; i++) { + NodeOutput *output = this->getOutputSocket(i); + missingSocketLink(converter, output); + } +} + +void RenderLayersNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + Scene *scene = (Scene *)this->getbNode()->id; + Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr; + + if (re != nullptr) { + testRenderLink(converter, context, re); + RE_ReleaseResult(re); + } + else { + missingRenderLink(converter); + } +} diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp deleted file mode 100644 index 6be86c04c4d..00000000000 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_RenderLayersNode.h" -#include "COM_RenderLayersProg.h" -#include "COM_RotateOperation.h" -#include "COM_ScaleOperation.h" -#include "COM_SetColorOperation.h" -#include "COM_SetValueOperation.h" -#include "COM_SetVectorOperation.h" -#include "COM_TranslateOperation.h" - -RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void RenderLayersNode::testSocketLink(NodeConverter &converter, - const CompositorContext &context, - NodeOutput *output, - RenderLayersProg *operation, - Scene *scene, - int layerId, - bool is_preview) const -{ - operation->setScene(scene); - operation->setLayerId(layerId); - operation->setRenderData(context.getRenderData()); - operation->setViewName(context.getViewName()); - - converter.mapOutputSocket(output, operation->getOutputSocket()); - converter.addOperation(operation); - - if (is_preview) { /* only for image socket */ - converter.addPreview(operation->getOutputSocket()); - } -} - -void RenderLayersNode::testRenderLink(NodeConverter &converter, - const CompositorContext &context, - Render *re) const -{ - Scene *scene = (Scene *)this->getbNode()->id; - const short layerId = this->getbNode()->custom1; - RenderResult *rr = RE_AcquireResultRead(re); - if (rr == nullptr) { - missingRenderLink(converter); - return; - } - ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, layerId); - if (view_layer == nullptr) { - missingRenderLink(converter); - return; - } - RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name); - if (rl == nullptr) { - missingRenderLink(converter); - return; - } - const int num_outputs = this->getNumberOfOutputSockets(); - for (int i = 0; i < num_outputs; i++) { - NodeOutput *output = this->getOutputSocket(i); - NodeImageLayer *storage = (NodeImageLayer *)output->getbNodeSocket()->storage; - RenderPass *rpass = (RenderPass *)BLI_findstring( - &rl->passes, storage->pass_name, offsetof(RenderPass, name)); - if (rpass == nullptr) { - missingSocketLink(converter, output); - continue; - } - RenderLayersProg *operation; - bool is_preview; - if (STREQ(rpass->name, RE_PASSNAME_COMBINED) && - STREQ(output->getbNodeSocket()->name, "Alpha")) { - operation = new RenderLayersAlphaProg(rpass->name, COM_DT_VALUE, rpass->channels); - is_preview = false; - } - else if (STREQ(rpass->name, RE_PASSNAME_Z)) { - operation = new RenderLayersDepthProg(rpass->name, COM_DT_VALUE, rpass->channels); - is_preview = false; - } - else { - DataType type; - switch (rpass->channels) { - case 4: - type = COM_DT_COLOR; - break; - case 3: - type = COM_DT_VECTOR; - break; - case 1: - type = COM_DT_VALUE; - break; - default: - BLI_assert(!"Unexpected number of channels for pass"); - type = COM_DT_VALUE; - break; - } - operation = new RenderLayersProg(rpass->name, type, rpass->channels); - is_preview = STREQ(output->getbNodeSocket()->name, "Image"); - } - testSocketLink(converter, context, output, operation, scene, layerId, is_preview); - } -} - -void RenderLayersNode::missingSocketLink(NodeConverter &converter, NodeOutput *output) const -{ - NodeOperation *operation; - switch (output->getDataType()) { - case COM_DT_COLOR: { - const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - SetColorOperation *color_operation = new SetColorOperation(); - color_operation->setChannels(color); - operation = color_operation; - break; - } - case COM_DT_VECTOR: { - const float vector[3] = {0.0f, 0.0f, 0.0f}; - SetVectorOperation *vector_operation = new SetVectorOperation(); - vector_operation->setVector(vector); - operation = vector_operation; - break; - } - case COM_DT_VALUE: { - SetValueOperation *value_operation = new SetValueOperation(); - value_operation->setValue(0.0f); - operation = value_operation; - break; - } - default: { - BLI_assert("!Unexpected data type"); - return; - } - } - - converter.mapOutputSocket(output, operation->getOutputSocket()); - converter.addOperation(operation); -} - -void RenderLayersNode::missingRenderLink(NodeConverter &converter) const -{ - const int num_outputs = this->getNumberOfOutputSockets(); - for (int i = 0; i < num_outputs; i++) { - NodeOutput *output = this->getOutputSocket(i); - missingSocketLink(converter, output); - } -} - -void RenderLayersNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - Scene *scene = (Scene *)this->getbNode()->id; - Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr; - - if (re != nullptr) { - testRenderLink(converter, context, re); - RE_ReleaseResult(re); - } - else { - missingRenderLink(converter); - } -} diff --git a/source/blender/compositor/nodes/COM_RotateNode.cc b/source/blender/compositor/nodes/COM_RotateNode.cc new file mode 100644 index 00000000000..cbade778bcb --- /dev/null +++ b/source/blender/compositor/nodes/COM_RotateNode.cc @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_RotateNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_RotateOperation.h" +#include "COM_SetSamplerOperation.h" + +RotateNode::RotateNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void RotateNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputDegreeSocket = this->getInputSocket(1); + NodeOutput *outputSocket = this->getOutputSocket(0); + RotateOperation *operation = new RotateOperation(); + SetSamplerOperation *sampler = new SetSamplerOperation(); + sampler->setSampler((PixelSampler)this->getbNode()->custom1); + + converter.addOperation(sampler); + converter.addOperation(operation); + + converter.addLink(sampler->getOutputSocket(), operation->getInputSocket(0)); + converter.mapInputSocket(inputSocket, sampler->getInputSocket(0)); + converter.mapInputSocket(inputDegreeSocket, operation->getInputSocket(1)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp deleted file mode 100644 index cbade778bcb..00000000000 --- a/source/blender/compositor/nodes/COM_RotateNode.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_RotateNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_RotateOperation.h" -#include "COM_SetSamplerOperation.h" - -RotateNode::RotateNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void RotateNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputDegreeSocket = this->getInputSocket(1); - NodeOutput *outputSocket = this->getOutputSocket(0); - RotateOperation *operation = new RotateOperation(); - SetSamplerOperation *sampler = new SetSamplerOperation(); - sampler->setSampler((PixelSampler)this->getbNode()->custom1); - - converter.addOperation(sampler); - converter.addOperation(operation); - - converter.addLink(sampler->getOutputSocket(), operation->getInputSocket(0)); - converter.mapInputSocket(inputSocket, sampler->getInputSocket(0)); - converter.mapInputSocket(inputDegreeSocket, operation->getInputSocket(1)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cc b/source/blender/compositor/nodes/COM_ScaleNode.cc new file mode 100644 index 00000000000..9ffcd5306b0 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ScaleNode.cc @@ -0,0 +1,107 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ScaleNode.h" + +#include "BKE_node.h" +#include "COM_ExecutionSystem.h" +#include "COM_ScaleOperation.h" +#include "COM_SetSamplerOperation.h" +#include "COM_SetValueOperation.h" + +ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ScaleNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *bnode = this->getbNode(); + + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputXSocket = this->getInputSocket(1); + NodeInput *inputYSocket = this->getInputSocket(2); + NodeOutput *outputSocket = this->getOutputSocket(0); + + switch (bnode->custom1) { + case CMP_SCALE_RELATIVE: { + ScaleOperation *operation = new ScaleOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); + converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); + break; + } + case CMP_SCALE_SCENEPERCENT: { + SetValueOperation *scaleFactorOperation = new SetValueOperation(); + scaleFactorOperation->setValue(context.getRenderPercentageAsFactor()); + converter.addOperation(scaleFactorOperation); + + ScaleOperation *operation = new ScaleOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); + converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); + + break; + } + case CMP_SCALE_RENDERPERCENT: { + const RenderData *rd = context.getRenderData(); + const float render_size_factor = context.getRenderPercentageAsFactor(); + ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation(); + /* framing options */ + operation->setIsAspect((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) != 0); + operation->setIsCrop((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0); + operation->setOffset(bnode->custom3, bnode->custom4); + operation->setNewWidth(rd->xsch * render_size_factor); + operation->setNewHeight(rd->ysch * render_size_factor); + operation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); + + break; + } + case CMP_SCALE_ABSOLUTE: { + /* TODO: what is the use of this one.... perhaps some issues when the ui was updated... */ + ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); + converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); + + break; + } + } +} diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp deleted file mode 100644 index 9ffcd5306b0..00000000000 --- a/source/blender/compositor/nodes/COM_ScaleNode.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ScaleNode.h" - -#include "BKE_node.h" -#include "COM_ExecutionSystem.h" -#include "COM_ScaleOperation.h" -#include "COM_SetSamplerOperation.h" -#include "COM_SetValueOperation.h" - -ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ScaleNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *bnode = this->getbNode(); - - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputXSocket = this->getInputSocket(1); - NodeInput *inputYSocket = this->getInputSocket(2); - NodeOutput *outputSocket = this->getOutputSocket(0); - - switch (bnode->custom1) { - case CMP_SCALE_RELATIVE: { - ScaleOperation *operation = new ScaleOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); - converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); - break; - } - case CMP_SCALE_SCENEPERCENT: { - SetValueOperation *scaleFactorOperation = new SetValueOperation(); - scaleFactorOperation->setValue(context.getRenderPercentageAsFactor()); - converter.addOperation(scaleFactorOperation); - - ScaleOperation *operation = new ScaleOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); - converter.addLink(scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); - - break; - } - case CMP_SCALE_RENDERPERCENT: { - const RenderData *rd = context.getRenderData(); - const float render_size_factor = context.getRenderPercentageAsFactor(); - ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation(); - /* framing options */ - operation->setIsAspect((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) != 0); - operation->setIsCrop((bnode->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0); - operation->setOffset(bnode->custom3, bnode->custom4); - operation->setNewWidth(rd->xsch * render_size_factor); - operation->setNewHeight(rd->ysch * render_size_factor); - operation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); - - break; - } - case CMP_SCALE_ABSOLUTE: { - /* TODO: what is the use of this one.... perhaps some issues when the ui was updated... */ - ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); - converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - operation->setVariableSize(inputXSocket->isLinked() || inputYSocket->isLinked()); - - break; - } - } -} diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cc b/source/blender/compositor/nodes/COM_SeparateColorNode.cc new file mode 100644 index 00000000000..203aa25c9e9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cc @@ -0,0 +1,121 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_SeparateColorNode.h" + +#include "COM_ConvertOperation.h" + +SeparateColorNode::SeparateColorNode(bNode *editorNode) : Node(editorNode) +{ +} + +void SeparateColorNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeInput *imageSocket = this->getInputSocket(0); + NodeOutput *outputRSocket = this->getOutputSocket(0); + NodeOutput *outputGSocket = this->getOutputSocket(1); + NodeOutput *outputBSocket = this->getOutputSocket(2); + NodeOutput *outputASocket = this->getOutputSocket(3); + + NodeOperation *color_conv = getColorConverter(context); + if (color_conv) { + converter.addOperation(color_conv); + + converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0)); + } + + { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(0); + converter.addOperation(operation); + + if (color_conv) { + converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); + } + else { + converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); + } + converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0)); + } + + { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(1); + converter.addOperation(operation); + + if (color_conv) { + converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); + } + else { + converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); + } + converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0)); + } + + { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(2); + converter.addOperation(operation); + + if (color_conv) { + converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); + } + else { + converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); + } + converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0)); + } + + { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(3); + converter.addOperation(operation); + + if (color_conv) { + converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); + } + else { + converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); + } + converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0)); + } +} + +NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return nullptr; /* no conversion needed */ +} + +NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return new ConvertRGBToHSVOperation(); +} + +NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext & /*context*/) const +{ + ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation(); + bNode *editorNode = this->getbNode(); + operation->setMode(editorNode->custom1); + return operation; +} + +NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext & /*context*/) const +{ + return new ConvertRGBToYUVOperation(); +} diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp deleted file mode 100644 index 203aa25c9e9..00000000000 --- a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_SeparateColorNode.h" - -#include "COM_ConvertOperation.h" - -SeparateColorNode::SeparateColorNode(bNode *editorNode) : Node(editorNode) -{ -} - -void SeparateColorNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeInput *imageSocket = this->getInputSocket(0); - NodeOutput *outputRSocket = this->getOutputSocket(0); - NodeOutput *outputGSocket = this->getOutputSocket(1); - NodeOutput *outputBSocket = this->getOutputSocket(2); - NodeOutput *outputASocket = this->getOutputSocket(3); - - NodeOperation *color_conv = getColorConverter(context); - if (color_conv) { - converter.addOperation(color_conv); - - converter.mapInputSocket(imageSocket, color_conv->getInputSocket(0)); - } - - { - SeparateChannelOperation *operation = new SeparateChannelOperation(); - operation->setChannel(0); - converter.addOperation(operation); - - if (color_conv) { - converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); - } - else { - converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); - } - converter.mapOutputSocket(outputRSocket, operation->getOutputSocket(0)); - } - - { - SeparateChannelOperation *operation = new SeparateChannelOperation(); - operation->setChannel(1); - converter.addOperation(operation); - - if (color_conv) { - converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); - } - else { - converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); - } - converter.mapOutputSocket(outputGSocket, operation->getOutputSocket(0)); - } - - { - SeparateChannelOperation *operation = new SeparateChannelOperation(); - operation->setChannel(2); - converter.addOperation(operation); - - if (color_conv) { - converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); - } - else { - converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); - } - converter.mapOutputSocket(outputBSocket, operation->getOutputSocket(0)); - } - - { - SeparateChannelOperation *operation = new SeparateChannelOperation(); - operation->setChannel(3); - converter.addOperation(operation); - - if (color_conv) { - converter.addLink(color_conv->getOutputSocket(), operation->getInputSocket(0)); - } - else { - converter.mapInputSocket(imageSocket, operation->getInputSocket(0)); - } - converter.mapOutputSocket(outputASocket, operation->getOutputSocket(0)); - } -} - -NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return nullptr; /* no conversion needed */ -} - -NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return new ConvertRGBToHSVOperation(); -} - -NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext & /*context*/) const -{ - ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation(); - bNode *editorNode = this->getbNode(); - operation->setMode(editorNode->custom1); - return operation; -} - -NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext & /*context*/) const -{ - return new ConvertRGBToYUVOperation(); -} diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cc b/source/blender/compositor/nodes/COM_SetAlphaNode.cc new file mode 100644 index 00000000000..233a5e96ff4 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cc @@ -0,0 +1,48 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_SetAlphaNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetAlphaMultiplyOperation.h" +#include "COM_SetAlphaReplaceOperation.h" + +void SetAlphaNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + const bNode *editorNode = this->getbNode(); + const NodeSetAlpha *storage = static_cast(editorNode->storage); + NodeOperation *operation = nullptr; + switch (storage->mode) { + case CMP_NODE_SETALPHA_MODE_APPLY: + operation = new SetAlphaMultiplyOperation(); + break; + case CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA: + operation = new SetAlphaReplaceOperation(); + break; + } + + if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) { + operation->setResolutionInputSocketIndex(1); + } + + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp deleted file mode 100644 index 233a5e96ff4..00000000000 --- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_SetAlphaNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetAlphaMultiplyOperation.h" -#include "COM_SetAlphaReplaceOperation.h" - -void SetAlphaNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - const bNode *editorNode = this->getbNode(); - const NodeSetAlpha *storage = static_cast(editorNode->storage); - NodeOperation *operation = nullptr; - switch (storage->mode) { - case CMP_NODE_SETALPHA_MODE_APPLY: - operation = new SetAlphaMultiplyOperation(); - break; - case CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA: - operation = new SetAlphaReplaceOperation(); - break; - } - - if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) { - operation->setResolutionInputSocketIndex(1); - } - - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cc b/source/blender/compositor/nodes/COM_SocketProxyNode.cc new file mode 100644 index 00000000000..a84dbf680fe --- /dev/null +++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cc @@ -0,0 +1,103 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_SocketProxyNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_ReadBufferOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_SetVectorOperation.h" +#include "COM_SocketProxyOperation.h" +#include "COM_WriteBufferOperation.h" + +SocketProxyNode::SocketProxyNode(bNode *editorNode, + bNodeSocket *editorInput, + bNodeSocket *editorOutput, + bool use_conversion) + : Node(editorNode, false), m_use_conversion(use_conversion) +{ + 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, 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(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion); + converter.mapOutputSocket(getOutputSocket(), proxy_output); +} + +SocketBufferNode::SocketBufferNode(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, 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 SocketBufferNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeOutput *output = this->getOutputSocket(0); + NodeInput *input = this->getInputSocket(0); + + DataType datatype = output->getDataType(); + WriteBufferOperation *writeOperation = new WriteBufferOperation(datatype); + ReadBufferOperation *readOperation = new ReadBufferOperation(datatype); + readOperation->setMemoryProxy(writeOperation->getMemoryProxy()); + converter.addOperation(writeOperation); + converter.addOperation(readOperation); + + converter.mapInputSocket(input, writeOperation->getInputSocket(0)); + converter.mapOutputSocket(output, readOperation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp deleted file mode 100644 index a84dbf680fe..00000000000 --- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_SocketProxyNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_ReadBufferOperation.h" -#include "COM_SetColorOperation.h" -#include "COM_SetValueOperation.h" -#include "COM_SetVectorOperation.h" -#include "COM_SocketProxyOperation.h" -#include "COM_WriteBufferOperation.h" - -SocketProxyNode::SocketProxyNode(bNode *editorNode, - bNodeSocket *editorInput, - bNodeSocket *editorOutput, - bool use_conversion) - : Node(editorNode, false), m_use_conversion(use_conversion) -{ - 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, 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(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion); - converter.mapOutputSocket(getOutputSocket(), proxy_output); -} - -SocketBufferNode::SocketBufferNode(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, 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 SocketBufferNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeOutput *output = this->getOutputSocket(0); - NodeInput *input = this->getInputSocket(0); - - DataType datatype = output->getDataType(); - WriteBufferOperation *writeOperation = new WriteBufferOperation(datatype); - ReadBufferOperation *readOperation = new ReadBufferOperation(datatype); - readOperation->setMemoryProxy(writeOperation->getMemoryProxy()); - converter.addOperation(writeOperation); - converter.addOperation(readOperation); - - converter.mapInputSocket(input, writeOperation->getInputSocket(0)); - converter.mapOutputSocket(output, readOperation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cc b/source/blender/compositor/nodes/COM_SplitViewerNode.cc new file mode 100644 index 00000000000..75703876d9e --- /dev/null +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cc @@ -0,0 +1,75 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_SplitViewerNode.h" +#include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_scene.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SplitOperation.h" +#include "COM_ViewerOperation.h" + +SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void SplitViewerNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && + (editorNode->flag & NODE_DO_OUTPUT); + + NodeInput *image1Socket = this->getInputSocket(0); + NodeInput *image2Socket = this->getInputSocket(1); + Image *image = (Image *)this->getbNode()->id; + ImageUser *imageUser = (ImageUser *)this->getbNode()->storage; + + SplitOperation *splitViewerOperation = new SplitOperation(); + splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); + splitViewerOperation->setXSplit(!this->getbNode()->custom2); + + converter.addOperation(splitViewerOperation); + converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0)); + converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1)); + + ViewerOperation *viewerOperation = new ViewerOperation(); + viewerOperation->setImage(image); + viewerOperation->setImageUser(imageUser); + viewerOperation->setViewSettings(context.getViewSettings()); + viewerOperation->setDisplaySettings(context.getDisplaySettings()); + viewerOperation->setRenderData(context.getRenderData()); + viewerOperation->setViewName(context.getViewName()); + + /* defaults - the viewer node has these options but not exposed for split view + * we could use the split to define an area of interest on one axis at least */ + viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT); + viewerOperation->setCenterX(0.5f); + viewerOperation->setCenterY(0.5f); + + converter.addOperation(viewerOperation); + converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0)); + + converter.addPreview(splitViewerOperation->getOutputSocket()); + + if (do_output) { + converter.registerViewer(viewerOperation); + } +} diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp deleted file mode 100644 index 75703876d9e..00000000000 --- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_SplitViewerNode.h" -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_scene.h" - -#include "COM_ExecutionSystem.h" -#include "COM_SplitOperation.h" -#include "COM_ViewerOperation.h" - -SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void SplitViewerNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && - (editorNode->flag & NODE_DO_OUTPUT); - - NodeInput *image1Socket = this->getInputSocket(0); - NodeInput *image2Socket = this->getInputSocket(1); - Image *image = (Image *)this->getbNode()->id; - ImageUser *imageUser = (ImageUser *)this->getbNode()->storage; - - SplitOperation *splitViewerOperation = new SplitOperation(); - splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); - splitViewerOperation->setXSplit(!this->getbNode()->custom2); - - converter.addOperation(splitViewerOperation); - converter.mapInputSocket(image1Socket, splitViewerOperation->getInputSocket(0)); - converter.mapInputSocket(image2Socket, splitViewerOperation->getInputSocket(1)); - - ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setImage(image); - viewerOperation->setImageUser(imageUser); - viewerOperation->setViewSettings(context.getViewSettings()); - viewerOperation->setDisplaySettings(context.getDisplaySettings()); - viewerOperation->setRenderData(context.getRenderData()); - viewerOperation->setViewName(context.getViewName()); - - /* defaults - the viewer node has these options but not exposed for split view - * we could use the split to define an area of interest on one axis at least */ - viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT); - viewerOperation->setCenterX(0.5f); - viewerOperation->setCenterY(0.5f); - - converter.addOperation(viewerOperation); - converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0)); - - converter.addPreview(splitViewerOperation->getOutputSocket()); - - if (do_output) { - converter.registerViewer(viewerOperation); - } -} diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cc b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc new file mode 100644 index 00000000000..38db080a154 --- /dev/null +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cc @@ -0,0 +1,113 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_Stabilize2dNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_MovieClipAttributeOperation.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_SetSamplerOperation.h" +#include "COM_TranslateOperation.h" + +#include "BKE_tracking.h" + +#include "DNA_movieclip_types.h" + +Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void Stabilize2dNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + NodeInput *imageInput = this->getInputSocket(0); + MovieClip *clip = (MovieClip *)editorNode->id; + bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0; + + ScaleOperation *scaleOperation = new ScaleOperation(); + scaleOperation->setSampler((PixelSampler)editorNode->custom1); + RotateOperation *rotateOperation = new RotateOperation(); + rotateOperation->setDoDegree2RadConversion(false); + TranslateOperation *translateOperation = new TranslateOperation(); + MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); + SetSamplerOperation *psoperation = new SetSamplerOperation(); + psoperation->setSampler((PixelSampler)editorNode->custom1); + + scaleAttribute->setAttribute(MCA_SCALE); + scaleAttribute->setFramenumber(context.getFramenumber()); + scaleAttribute->setMovieClip(clip); + scaleAttribute->setInvert(invert); + + angleAttribute->setAttribute(MCA_ANGLE); + angleAttribute->setFramenumber(context.getFramenumber()); + angleAttribute->setMovieClip(clip); + angleAttribute->setInvert(invert); + + xAttribute->setAttribute(MCA_X); + xAttribute->setFramenumber(context.getFramenumber()); + xAttribute->setMovieClip(clip); + xAttribute->setInvert(invert); + + yAttribute->setAttribute(MCA_Y); + yAttribute->setFramenumber(context.getFramenumber()); + yAttribute->setMovieClip(clip); + yAttribute->setInvert(invert); + + converter.addOperation(scaleAttribute); + converter.addOperation(angleAttribute); + converter.addOperation(xAttribute); + converter.addOperation(yAttribute); + converter.addOperation(scaleOperation); + converter.addOperation(translateOperation); + converter.addOperation(rotateOperation); + converter.addOperation(psoperation); + + converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1)); + converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2)); + + converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1)); + + converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); + converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); + + converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket()); + + if (invert) { + // Translate -> Rotate -> Scale. + converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0)); + + converter.addLink(translateOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); + converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0)); + + converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0)); + } + else { + // Scale -> Rotate -> Translate. + converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0)); + + converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); + converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); + + converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0)); + } +} diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp deleted file mode 100644 index 38db080a154..00000000000 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_Stabilize2dNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_MovieClipAttributeOperation.h" -#include "COM_RotateOperation.h" -#include "COM_ScaleOperation.h" -#include "COM_SetSamplerOperation.h" -#include "COM_TranslateOperation.h" - -#include "BKE_tracking.h" - -#include "DNA_movieclip_types.h" - -Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void Stabilize2dNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - NodeInput *imageInput = this->getInputSocket(0); - MovieClip *clip = (MovieClip *)editorNode->id; - bool invert = (editorNode->custom2 & CMP_NODEFLAG_STABILIZE_INVERSE) != 0; - - ScaleOperation *scaleOperation = new ScaleOperation(); - scaleOperation->setSampler((PixelSampler)editorNode->custom1); - RotateOperation *rotateOperation = new RotateOperation(); - rotateOperation->setDoDegree2RadConversion(false); - TranslateOperation *translateOperation = new TranslateOperation(); - MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); - MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); - SetSamplerOperation *psoperation = new SetSamplerOperation(); - psoperation->setSampler((PixelSampler)editorNode->custom1); - - scaleAttribute->setAttribute(MCA_SCALE); - scaleAttribute->setFramenumber(context.getFramenumber()); - scaleAttribute->setMovieClip(clip); - scaleAttribute->setInvert(invert); - - angleAttribute->setAttribute(MCA_ANGLE); - angleAttribute->setFramenumber(context.getFramenumber()); - angleAttribute->setMovieClip(clip); - angleAttribute->setInvert(invert); - - xAttribute->setAttribute(MCA_X); - xAttribute->setFramenumber(context.getFramenumber()); - xAttribute->setMovieClip(clip); - xAttribute->setInvert(invert); - - yAttribute->setAttribute(MCA_Y); - yAttribute->setFramenumber(context.getFramenumber()); - yAttribute->setMovieClip(clip); - yAttribute->setInvert(invert); - - converter.addOperation(scaleAttribute); - converter.addOperation(angleAttribute); - converter.addOperation(xAttribute); - converter.addOperation(yAttribute); - converter.addOperation(scaleOperation); - converter.addOperation(translateOperation); - converter.addOperation(rotateOperation); - converter.addOperation(psoperation); - - converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1)); - converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2)); - - converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1)); - - converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); - converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); - - converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket()); - - if (invert) { - // Translate -> Rotate -> Scale. - converter.mapInputSocket(imageInput, translateOperation->getInputSocket(0)); - - converter.addLink(translateOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), scaleOperation->getInputSocket(0)); - - converter.addLink(scaleOperation->getOutputSocket(), psoperation->getInputSocket(0)); - } - else { - // Scale -> Rotate -> Translate. - converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0)); - - converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); - converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); - - converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0)); - } -} diff --git a/source/blender/compositor/nodes/COM_SunBeamsNode.cc b/source/blender/compositor/nodes/COM_SunBeamsNode.cc new file mode 100644 index 00000000000..d899a54c03c --- /dev/null +++ b/source/blender/compositor/nodes/COM_SunBeamsNode.cc @@ -0,0 +1,39 @@ +/* This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2014, Blender Foundation. + */ + +#include "COM_SunBeamsNode.h" +#include "COM_SunBeamsOperation.h" + +SunBeamsNode::SunBeamsNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void SunBeamsNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *inputSocket = this->getInputSocket(0); + NodeOutput *outputSocket = this->getOutputSocket(0); + NodeSunBeams *data = (NodeSunBeams *)getbNode()->storage; + + SunBeamsOperation *operation = new SunBeamsOperation(); + operation->setData(*data); + converter.addOperation(operation); + + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_SunBeamsNode.cpp b/source/blender/compositor/nodes/COM_SunBeamsNode.cpp deleted file mode 100644 index d899a54c03c..00000000000 --- a/source/blender/compositor/nodes/COM_SunBeamsNode.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2014, Blender Foundation. - */ - -#include "COM_SunBeamsNode.h" -#include "COM_SunBeamsOperation.h" - -SunBeamsNode::SunBeamsNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void SunBeamsNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *inputSocket = this->getInputSocket(0); - NodeOutput *outputSocket = this->getOutputSocket(0); - NodeSunBeams *data = (NodeSunBeams *)getbNode()->storage; - - SunBeamsOperation *operation = new SunBeamsOperation(); - operation->setData(*data); - converter.addOperation(operation); - - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cc b/source/blender/compositor/nodes/COM_SwitchNode.cc new file mode 100644 index 00000000000..947774e98ae --- /dev/null +++ b/source/blender/compositor/nodes/COM_SwitchNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_SwitchNode.h" + +SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void SwitchNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + bool condition = this->getbNode()->custom1; + + NodeOperationOutput *result; + if (!condition) { + result = converter.addInputProxy(getInputSocket(0), false); + } + else { + result = converter.addInputProxy(getInputSocket(1), false); + } + + converter.mapOutputSocket(getOutputSocket(0), result); +} diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp deleted file mode 100644 index 947774e98ae..00000000000 --- a/source/blender/compositor/nodes/COM_SwitchNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_SwitchNode.h" - -SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void SwitchNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - bool condition = this->getbNode()->custom1; - - NodeOperationOutput *result; - if (!condition) { - result = converter.addInputProxy(getInputSocket(0), false); - } - else { - result = converter.addInputProxy(getInputSocket(1), false); - } - - converter.mapOutputSocket(getOutputSocket(0), result); -} diff --git a/source/blender/compositor/nodes/COM_SwitchViewNode.cc b/source/blender/compositor/nodes/COM_SwitchViewNode.cc new file mode 100644 index 00000000000..e534ebfac9a --- /dev/null +++ b/source/blender/compositor/nodes/COM_SwitchViewNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2015, Blender Foundation. + */ + +#include "COM_SwitchViewNode.h" +#include "BLI_listbase.h" + +SwitchViewNode::SwitchViewNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void SwitchViewNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + NodeOperationOutput *result; + const char *viewName = context.getViewName(); + bNode *bnode = this->getbNode(); + + /* get the internal index of the socket with a matching name */ + int nr = BLI_findstringindex(&bnode->inputs, viewName, offsetof(bNodeSocket, name)); + nr = MAX2(nr, 0); + + result = converter.addInputProxy(getInputSocket(nr), false); + converter.mapOutputSocket(getOutputSocket(0), result); +} diff --git a/source/blender/compositor/nodes/COM_SwitchViewNode.cpp b/source/blender/compositor/nodes/COM_SwitchViewNode.cpp deleted file mode 100644 index e534ebfac9a..00000000000 --- a/source/blender/compositor/nodes/COM_SwitchViewNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2015, Blender Foundation. - */ - -#include "COM_SwitchViewNode.h" -#include "BLI_listbase.h" - -SwitchViewNode::SwitchViewNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void SwitchViewNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - NodeOperationOutput *result; - const char *viewName = context.getViewName(); - bNode *bnode = this->getbNode(); - - /* get the internal index of the socket with a matching name */ - int nr = BLI_findstringindex(&bnode->inputs, viewName, offsetof(bNodeSocket, name)); - nr = MAX2(nr, 0); - - result = converter.addInputProxy(getInputSocket(nr), false); - converter.mapOutputSocket(getOutputSocket(0), result); -} diff --git a/source/blender/compositor/nodes/COM_TextureNode.cc b/source/blender/compositor/nodes/COM_TextureNode.cc new file mode 100644 index 00000000000..3381b5098d7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TextureNode.cc @@ -0,0 +1,56 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_TextureNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TextureOperation.h" + +TextureNode::TextureNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TextureNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + Tex *texture = (Tex *)editorNode->id; + TextureOperation *operation = new TextureOperation(); + const ColorManagedDisplaySettings *displaySettings = context.getDisplaySettings(); + bool sceneColorManage = !STREQ(displaySettings->display_device, "None"); + operation->setTexture(texture); + operation->setRenderData(context.getRenderData()); + operation->setSceneColorManage(sceneColorManage); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(1), operation->getOutputSocket()); + + converter.addPreview(operation->getOutputSocket()); + + TextureAlphaOperation *alphaOperation = new TextureAlphaOperation(); + alphaOperation->setTexture(texture); + alphaOperation->setRenderData(context.getRenderData()); + alphaOperation->setSceneColorManage(sceneColorManage); + converter.addOperation(alphaOperation); + + converter.mapInputSocket(getInputSocket(0), alphaOperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), alphaOperation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(0), alphaOperation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp deleted file mode 100644 index 3381b5098d7..00000000000 --- a/source/blender/compositor/nodes/COM_TextureNode.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_TextureNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_TextureOperation.h" - -TextureNode::TextureNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void TextureNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - Tex *texture = (Tex *)editorNode->id; - TextureOperation *operation = new TextureOperation(); - const ColorManagedDisplaySettings *displaySettings = context.getDisplaySettings(); - bool sceneColorManage = !STREQ(displaySettings->display_device, "None"); - operation->setTexture(texture); - operation->setRenderData(context.getRenderData()); - operation->setSceneColorManage(sceneColorManage); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(1), operation->getOutputSocket()); - - converter.addPreview(operation->getOutputSocket()); - - TextureAlphaOperation *alphaOperation = new TextureAlphaOperation(); - alphaOperation->setTexture(texture); - alphaOperation->setRenderData(context.getRenderData()); - alphaOperation->setSceneColorManage(sceneColorManage); - converter.addOperation(alphaOperation); - - converter.mapInputSocket(getInputSocket(0), alphaOperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), alphaOperation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(0), alphaOperation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_TimeNode.cc b/source/blender/compositor/nodes/COM_TimeNode.cc new file mode 100644 index 00000000000..247e0d11df6 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TimeNode.cc @@ -0,0 +1,58 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_TimeNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" + +#include "BKE_colortools.h" + +#include "BLI_utildefines.h" + +TimeNode::TimeNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TimeNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + SetValueOperation *operation = new SetValueOperation(); + 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); + } + + BKE_curvemapping_init((CurveMapping *)node->storage); + fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); + operation->setValue(clamp_f(fac, 0.0f, 1.0f)); + converter.addOperation(operation); + + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp deleted file mode 100644 index 247e0d11df6..00000000000 --- a/source/blender/compositor/nodes/COM_TimeNode.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_TimeNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetValueOperation.h" - -#include "BKE_colortools.h" - -#include "BLI_utildefines.h" - -TimeNode::TimeNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void TimeNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - SetValueOperation *operation = new SetValueOperation(); - 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); - } - - BKE_curvemapping_init((CurveMapping *)node->storage); - fac = BKE_curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac); - operation->setValue(clamp_f(fac, 0.0f, 1.0f)); - converter.addOperation(operation); - - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cc b/source/blender/compositor/nodes/COM_TonemapNode.cc new file mode 100644 index 00000000000..db329e56f9b --- /dev/null +++ b/source/blender/compositor/nodes/COM_TonemapNode.cc @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_TonemapNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TonemapOperation.h" + +TonemapNode::TonemapNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TonemapNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage; + + TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : + new TonemapOperation(); + operation->setData(data); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); +} diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp deleted file mode 100644 index db329e56f9b..00000000000 --- a/source/blender/compositor/nodes/COM_TonemapNode.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_TonemapNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_TonemapOperation.h" - -TonemapNode::TonemapNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void TonemapNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage; - - TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : - new TonemapOperation(); - operation->setData(data); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0)); -} diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cc b/source/blender/compositor/nodes/COM_TrackPositionNode.cc new file mode 100644 index 00000000000..52e7f7d832b --- /dev/null +++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cc @@ -0,0 +1,111 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2012, Blender Foundation. + */ + +#include "COM_TrackPositionNode.h" + +#include "COM_ConvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_TrackPositionOperation.h" + +#include "DNA_movieclip_types.h" + +#include "BKE_node.h" + +TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +static TrackPositionOperation *create_motion_operation(NodeConverter &converter, + MovieClip *clip, + NodeTrackPosData *trackpos_data, + int axis, + int frame_number, + int delta) +{ + TrackPositionOperation *operation = new TrackPositionOperation(); + operation->setMovieClip(clip); + operation->setTrackingObject(trackpos_data->tracking_object); + operation->setTrackName(trackpos_data->track_name); + operation->setFramenumber(frame_number); + operation->setAxis(axis); + operation->setPosition(CMP_TRACKPOS_ABSOLUTE); + operation->setRelativeFrame(frame_number + delta); + operation->setSpeedOutput(true); + converter.addOperation(operation); + return operation; +} + +void TrackPositionNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + MovieClip *clip = (MovieClip *)editorNode->id; + NodeTrackPosData *trackpos_data = (NodeTrackPosData *)editorNode->storage; + + NodeOutput *outputX = this->getOutputSocket(0); + NodeOutput *outputY = this->getOutputSocket(1); + NodeOutput *outputSpeed = this->getOutputSocket(2); + + int frame_number; + if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) { + frame_number = editorNode->custom2; + } + else { + frame_number = context.getFramenumber(); + } + + TrackPositionOperation *operationX = new TrackPositionOperation(); + operationX->setMovieClip(clip); + operationX->setTrackingObject(trackpos_data->tracking_object); + operationX->setTrackName(trackpos_data->track_name); + operationX->setFramenumber(frame_number); + operationX->setAxis(0); + operationX->setPosition(editorNode->custom1); + operationX->setRelativeFrame(editorNode->custom2); + converter.addOperation(operationX); + converter.mapOutputSocket(outputX, operationX->getOutputSocket()); + + TrackPositionOperation *operationY = new TrackPositionOperation(); + operationY->setMovieClip(clip); + operationY->setTrackingObject(trackpos_data->tracking_object); + operationY->setTrackName(trackpos_data->track_name); + operationY->setFramenumber(frame_number); + operationY->setAxis(1); + operationY->setPosition(editorNode->custom1); + operationY->setRelativeFrame(editorNode->custom2); + converter.addOperation(operationY); + converter.mapOutputSocket(outputY, operationY->getOutputSocket()); + + TrackPositionOperation *operationMotionPreX = create_motion_operation( + converter, clip, trackpos_data, 0, frame_number, -1); + TrackPositionOperation *operationMotionPreY = create_motion_operation( + converter, clip, trackpos_data, 1, frame_number, -1); + TrackPositionOperation *operationMotionPostX = create_motion_operation( + converter, clip, trackpos_data, 0, frame_number, 1); + TrackPositionOperation *operationMotionPostY = create_motion_operation( + converter, clip, trackpos_data, 1, frame_number, 1); + + CombineChannelsOperation *combine_operation = new CombineChannelsOperation(); + converter.addOperation(combine_operation); + converter.addLink(operationMotionPreX->getOutputSocket(), combine_operation->getInputSocket(0)); + converter.addLink(operationMotionPreY->getOutputSocket(), combine_operation->getInputSocket(1)); + converter.addLink(operationMotionPostX->getOutputSocket(), combine_operation->getInputSocket(2)); + converter.addLink(operationMotionPostY->getOutputSocket(), combine_operation->getInputSocket(3)); + converter.mapOutputSocket(outputSpeed, combine_operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp deleted file mode 100644 index 52e7f7d832b..00000000000 --- a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2012, Blender Foundation. - */ - -#include "COM_TrackPositionNode.h" - -#include "COM_ConvertOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_TrackPositionOperation.h" - -#include "DNA_movieclip_types.h" - -#include "BKE_node.h" - -TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -static TrackPositionOperation *create_motion_operation(NodeConverter &converter, - MovieClip *clip, - NodeTrackPosData *trackpos_data, - int axis, - int frame_number, - int delta) -{ - TrackPositionOperation *operation = new TrackPositionOperation(); - operation->setMovieClip(clip); - operation->setTrackingObject(trackpos_data->tracking_object); - operation->setTrackName(trackpos_data->track_name); - operation->setFramenumber(frame_number); - operation->setAxis(axis); - operation->setPosition(CMP_TRACKPOS_ABSOLUTE); - operation->setRelativeFrame(frame_number + delta); - operation->setSpeedOutput(true); - converter.addOperation(operation); - return operation; -} - -void TrackPositionNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - MovieClip *clip = (MovieClip *)editorNode->id; - NodeTrackPosData *trackpos_data = (NodeTrackPosData *)editorNode->storage; - - NodeOutput *outputX = this->getOutputSocket(0); - NodeOutput *outputY = this->getOutputSocket(1); - NodeOutput *outputSpeed = this->getOutputSocket(2); - - int frame_number; - if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) { - frame_number = editorNode->custom2; - } - else { - frame_number = context.getFramenumber(); - } - - TrackPositionOperation *operationX = new TrackPositionOperation(); - operationX->setMovieClip(clip); - operationX->setTrackingObject(trackpos_data->tracking_object); - operationX->setTrackName(trackpos_data->track_name); - operationX->setFramenumber(frame_number); - operationX->setAxis(0); - operationX->setPosition(editorNode->custom1); - operationX->setRelativeFrame(editorNode->custom2); - converter.addOperation(operationX); - converter.mapOutputSocket(outputX, operationX->getOutputSocket()); - - TrackPositionOperation *operationY = new TrackPositionOperation(); - operationY->setMovieClip(clip); - operationY->setTrackingObject(trackpos_data->tracking_object); - operationY->setTrackName(trackpos_data->track_name); - operationY->setFramenumber(frame_number); - operationY->setAxis(1); - operationY->setPosition(editorNode->custom1); - operationY->setRelativeFrame(editorNode->custom2); - converter.addOperation(operationY); - converter.mapOutputSocket(outputY, operationY->getOutputSocket()); - - TrackPositionOperation *operationMotionPreX = create_motion_operation( - converter, clip, trackpos_data, 0, frame_number, -1); - TrackPositionOperation *operationMotionPreY = create_motion_operation( - converter, clip, trackpos_data, 1, frame_number, -1); - TrackPositionOperation *operationMotionPostX = create_motion_operation( - converter, clip, trackpos_data, 0, frame_number, 1); - TrackPositionOperation *operationMotionPostY = create_motion_operation( - converter, clip, trackpos_data, 1, frame_number, 1); - - CombineChannelsOperation *combine_operation = new CombineChannelsOperation(); - converter.addOperation(combine_operation); - converter.addLink(operationMotionPreX->getOutputSocket(), combine_operation->getInputSocket(0)); - converter.addLink(operationMotionPreY->getOutputSocket(), combine_operation->getInputSocket(1)); - converter.addLink(operationMotionPostX->getOutputSocket(), combine_operation->getInputSocket(2)); - converter.addLink(operationMotionPostY->getOutputSocket(), combine_operation->getInputSocket(3)); - converter.mapOutputSocket(outputSpeed, combine_operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_TransformNode.cc b/source/blender/compositor/nodes/COM_TransformNode.cc new file mode 100644 index 00000000000..cd5ba8ba201 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TransformNode.cc @@ -0,0 +1,68 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_TransformNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_SetSamplerOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_TranslateOperation.h" + +TransformNode::TransformNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TransformNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *imageInput = this->getInputSocket(0); + NodeInput *xInput = this->getInputSocket(1); + NodeInput *yInput = this->getInputSocket(2); + NodeInput *angleInput = this->getInputSocket(3); + NodeInput *scaleInput = this->getInputSocket(4); + + ScaleOperation *scaleOperation = new ScaleOperation(); + converter.addOperation(scaleOperation); + + RotateOperation *rotateOperation = new RotateOperation(); + rotateOperation->setDoDegree2RadConversion(false); + converter.addOperation(rotateOperation); + + TranslateOperation *translateOperation = new TranslateOperation(); + converter.addOperation(translateOperation); + + SetSamplerOperation *sampler = new SetSamplerOperation(); + sampler->setSampler((PixelSampler)this->getbNode()->custom1); + converter.addOperation(sampler); + + converter.mapInputSocket(imageInput, sampler->getInputSocket(0)); + converter.addLink(sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); + converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(1)); + converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(2)); // xscale = yscale + + converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); + converter.mapInputSocket(angleInput, rotateOperation->getInputSocket(1)); + + converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); + converter.mapInputSocket(xInput, translateOperation->getInputSocket(1)); + converter.mapInputSocket(yInput, translateOperation->getInputSocket(2)); + + converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp deleted file mode 100644 index cd5ba8ba201..00000000000 --- a/source/blender/compositor/nodes/COM_TransformNode.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_TransformNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_RotateOperation.h" -#include "COM_ScaleOperation.h" -#include "COM_SetSamplerOperation.h" -#include "COM_SetValueOperation.h" -#include "COM_TranslateOperation.h" - -TransformNode::TransformNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void TransformNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *imageInput = this->getInputSocket(0); - NodeInput *xInput = this->getInputSocket(1); - NodeInput *yInput = this->getInputSocket(2); - NodeInput *angleInput = this->getInputSocket(3); - NodeInput *scaleInput = this->getInputSocket(4); - - ScaleOperation *scaleOperation = new ScaleOperation(); - converter.addOperation(scaleOperation); - - RotateOperation *rotateOperation = new RotateOperation(); - rotateOperation->setDoDegree2RadConversion(false); - converter.addOperation(rotateOperation); - - TranslateOperation *translateOperation = new TranslateOperation(); - converter.addOperation(translateOperation); - - SetSamplerOperation *sampler = new SetSamplerOperation(); - sampler->setSampler((PixelSampler)this->getbNode()->custom1); - converter.addOperation(sampler); - - converter.mapInputSocket(imageInput, sampler->getInputSocket(0)); - converter.addLink(sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); - converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(1)); - converter.mapInputSocket(scaleInput, scaleOperation->getInputSocket(2)); // xscale = yscale - - converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); - converter.mapInputSocket(angleInput, rotateOperation->getInputSocket(1)); - - converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); - converter.mapInputSocket(xInput, translateOperation->getInputSocket(1)); - converter.mapInputSocket(yInput, translateOperation->getInputSocket(2)); - - converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cc b/source/blender/compositor/nodes/COM_TranslateNode.cc new file mode 100644 index 00000000000..0e9bf825787 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TranslateNode.cc @@ -0,0 +1,71 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_TranslateNode.h" + +#include "COM_ExecutionSystem.h" +#include "COM_TranslateOperation.h" +#include "COM_WrapOperation.h" +#include "COM_WriteBufferOperation.h" + +TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void TranslateNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *bnode = this->getbNode(); + NodeTranslateData *data = (NodeTranslateData *)bnode->storage; + + NodeInput *inputSocket = this->getInputSocket(0); + NodeInput *inputXSocket = this->getInputSocket(1); + NodeInput *inputYSocket = this->getInputSocket(2); + NodeOutput *outputSocket = this->getOutputSocket(0); + + TranslateOperation *operation = new TranslateOperation(); + if (data->relative) { + const RenderData *rd = context.getRenderData(); + const float render_size_factor = context.getRenderPercentageAsFactor(); + float fx = rd->xsch * render_size_factor; + float fy = rd->ysch * render_size_factor; + + operation->setFactorXY(fx, fy); + } + + converter.addOperation(operation); + converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); + converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); + converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); + + if (data->wrap_axis) { + WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR); + WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR); + wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy()); + wrapOperation->setWrapping(data->wrap_axis); + + converter.addOperation(writeOperation); + converter.addOperation(wrapOperation); + converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0)); + converter.addLink(wrapOperation->getOutputSocket(), operation->getInputSocket(0)); + } + else { + converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); + } +} diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp deleted file mode 100644 index 0e9bf825787..00000000000 --- a/source/blender/compositor/nodes/COM_TranslateNode.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_TranslateNode.h" - -#include "COM_ExecutionSystem.h" -#include "COM_TranslateOperation.h" -#include "COM_WrapOperation.h" -#include "COM_WriteBufferOperation.h" - -TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void TranslateNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *bnode = this->getbNode(); - NodeTranslateData *data = (NodeTranslateData *)bnode->storage; - - NodeInput *inputSocket = this->getInputSocket(0); - NodeInput *inputXSocket = this->getInputSocket(1); - NodeInput *inputYSocket = this->getInputSocket(2); - NodeOutput *outputSocket = this->getOutputSocket(0); - - TranslateOperation *operation = new TranslateOperation(); - if (data->relative) { - const RenderData *rd = context.getRenderData(); - const float render_size_factor = context.getRenderPercentageAsFactor(); - float fx = rd->xsch * render_size_factor; - float fy = rd->ysch * render_size_factor; - - operation->setFactorXY(fx, fy); - } - - converter.addOperation(operation); - converter.mapInputSocket(inputXSocket, operation->getInputSocket(1)); - converter.mapInputSocket(inputYSocket, operation->getInputSocket(2)); - converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); - - if (data->wrap_axis) { - WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR); - WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR); - wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy()); - wrapOperation->setWrapping(data->wrap_axis); - - converter.addOperation(writeOperation); - converter.addOperation(wrapOperation); - converter.mapInputSocket(inputSocket, writeOperation->getInputSocket(0)); - converter.addLink(wrapOperation->getOutputSocket(), operation->getInputSocket(0)); - } - else { - converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); - } -} diff --git a/source/blender/compositor/nodes/COM_ValueNode.cc b/source/blender/compositor/nodes/COM_ValueNode.cc new file mode 100644 index 00000000000..4227db0d10e --- /dev/null +++ b/source/blender/compositor/nodes/COM_ValueNode.cc @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ValueNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" + +ValueNode::ValueNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ValueNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + SetValueOperation *operation = new SetValueOperation(); + NodeOutput *output = this->getOutputSocket(0); + operation->setValue(output->getEditorValueFloat()); + converter.addOperation(operation); + + converter.mapOutputSocket(output, operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp deleted file mode 100644 index 4227db0d10e..00000000000 --- a/source/blender/compositor/nodes/COM_ValueNode.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ValueNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetValueOperation.h" - -ValueNode::ValueNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ValueNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - SetValueOperation *operation = new SetValueOperation(); - NodeOutput *output = this->getOutputSocket(0); - operation->setValue(output->getEditorValueFloat()); - converter.addOperation(operation); - - converter.mapOutputSocket(output, operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cc b/source/blender/compositor/nodes/COM_VectorBlurNode.cc new file mode 100644 index 00000000000..a92991c8b49 --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cc @@ -0,0 +1,43 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_VectorBlurNode.h" +#include "COM_VectorBlurOperation.h" +#include "DNA_node_types.h" + +VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void VectorBlurNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *node = this->getbNode(); + NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage; + + VectorBlurOperation *operation = new VectorBlurOperation(); + operation->setVectorBlurSettings(vectorBlurSettings); + operation->setQuality(context.getQuality()); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp deleted file mode 100644 index a92991c8b49..00000000000 --- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_VectorBlurNode.h" -#include "COM_VectorBlurOperation.h" -#include "DNA_node_types.h" - -VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void VectorBlurNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *node = this->getbNode(); - NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage; - - VectorBlurOperation *operation = new VectorBlurOperation(); - operation->setVectorBlurSettings(vectorBlurSettings); - operation->setQuality(context.getQuality()); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cc b/source/blender/compositor/nodes/COM_VectorCurveNode.cc new file mode 100644 index 00000000000..1201a9f9613 --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cc @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_VectorCurveNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_VectorCurveOperation.h" + +VectorCurveNode::VectorCurveNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void VectorCurveNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + VectorCurveOperation *operation = new VectorCurveOperation(); + operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); +} diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp deleted file mode 100644 index 1201a9f9613..00000000000 --- a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_VectorCurveNode.h" -#include "COM_ExecutionSystem.h" -#include "COM_VectorCurveOperation.h" - -VectorCurveNode::VectorCurveNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void VectorCurveNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - VectorCurveOperation *operation = new VectorCurveOperation(); - operation->setCurveMapping((CurveMapping *)this->getbNode()->storage); - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); -} diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cc b/source/blender/compositor/nodes/COM_ViewLevelsNode.cc new file mode 100644 index 00000000000..7b86fb1d64d --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cc @@ -0,0 +1,61 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ViewLevelsNode.h" +#include "COM_CalculateMeanOperation.h" +#include "COM_CalculateStandardDeviationOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" + +ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ViewLevelsNode::convertToOperations(NodeConverter &converter, + const CompositorContext & /*context*/) const +{ + NodeInput *input = this->getInputSocket(0); + if (input->isLinked()) { + // add preview to inputSocket; + + /* calculate mean operation */ + { + CalculateMeanOperation *operation = new CalculateMeanOperation(); + operation->setSetting(this->getbNode()->custom1); + + converter.addOperation(operation); + converter.mapInputSocket(input, operation->getInputSocket(0)); + converter.mapOutputSocket(this->getOutputSocket(0), operation->getOutputSocket()); + } + + /* calculate standard deviation operation */ + { + CalculateStandardDeviationOperation *operation = new CalculateStandardDeviationOperation(); + operation->setSetting(this->getbNode()->custom1); + + converter.addOperation(operation); + converter.mapInputSocket(input, operation->getInputSocket(0)); + converter.mapOutputSocket(this->getOutputSocket(1), operation->getOutputSocket()); + } + } + else { + converter.addOutputValue(getOutputSocket(0), 0.0f); + converter.addOutputValue(getOutputSocket(1), 0.0f); + } +} diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp deleted file mode 100644 index 7b86fb1d64d..00000000000 --- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ViewLevelsNode.h" -#include "COM_CalculateMeanOperation.h" -#include "COM_CalculateStandardDeviationOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_SetValueOperation.h" - -ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ViewLevelsNode::convertToOperations(NodeConverter &converter, - const CompositorContext & /*context*/) const -{ - NodeInput *input = this->getInputSocket(0); - if (input->isLinked()) { - // add preview to inputSocket; - - /* calculate mean operation */ - { - CalculateMeanOperation *operation = new CalculateMeanOperation(); - operation->setSetting(this->getbNode()->custom1); - - converter.addOperation(operation); - converter.mapInputSocket(input, operation->getInputSocket(0)); - converter.mapOutputSocket(this->getOutputSocket(0), operation->getOutputSocket()); - } - - /* calculate standard deviation operation */ - { - CalculateStandardDeviationOperation *operation = new CalculateStandardDeviationOperation(); - operation->setSetting(this->getbNode()->custom1); - - converter.addOperation(operation); - converter.mapInputSocket(input, operation->getInputSocket(0)); - converter.mapOutputSocket(this->getOutputSocket(1), operation->getOutputSocket()); - } - } - else { - converter.addOutputValue(getOutputSocket(0), 0.0f); - converter.addOutputValue(getOutputSocket(1), 0.0f); - } -} diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cc b/source/blender/compositor/nodes/COM_ViewerNode.cc new file mode 100644 index 00000000000..fa6c1bc3c28 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewerNode.cc @@ -0,0 +1,84 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ViewerNode.h" +#include "BKE_global.h" +#include "BKE_image.h" +#include "BKE_scene.h" +#include "BLI_listbase.h" + +#include "COM_ExecutionSystem.h" +#include "COM_ViewerOperation.h" + +ViewerNode::ViewerNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void ViewerNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + bNode *editorNode = this->getbNode(); + bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && + (editorNode->flag & NODE_DO_OUTPUT); + bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; + + NodeInput *imageSocket = this->getInputSocket(0); + NodeInput *alphaSocket = this->getInputSocket(1); + NodeInput *depthSocket = this->getInputSocket(2); + Image *image = (Image *)this->getbNode()->id; + ImageUser *imageUser = (ImageUser *)this->getbNode()->storage; + ViewerOperation *viewerOperation = new ViewerOperation(); + viewerOperation->setbNodeTree(context.getbNodeTree()); + viewerOperation->setImage(image); + viewerOperation->setImageUser(imageUser); + viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); + viewerOperation->setCenterX(editorNode->custom3); + viewerOperation->setCenterY(editorNode->custom4); + /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ + viewerOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); + viewerOperation->setRenderData(context.getRenderData()); + viewerOperation->setViewName(context.getViewName()); + + viewerOperation->setViewSettings(context.getViewSettings()); + viewerOperation->setDisplaySettings(context.getDisplaySettings()); + + viewerOperation->setResolutionInputSocketIndex(0); + if (!imageSocket->isLinked()) { + if (alphaSocket->isLinked()) { + viewerOperation->setResolutionInputSocketIndex(1); + } + } + + converter.addOperation(viewerOperation); + converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0)); + /* only use alpha link if "use alpha" is enabled */ + if (ignore_alpha) { + converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f); + } + else { + converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1)); + } + converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2)); + + converter.addNodeInputPreview(imageSocket); + + if (do_output) { + converter.registerViewer(viewerOperation); + } +} diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp deleted file mode 100644 index fa6c1bc3c28..00000000000 --- a/source/blender/compositor/nodes/COM_ViewerNode.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ViewerNode.h" -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_scene.h" -#include "BLI_listbase.h" - -#include "COM_ExecutionSystem.h" -#include "COM_ViewerOperation.h" - -ViewerNode::ViewerNode(bNode *editorNode) : Node(editorNode) -{ - /* pass */ -} - -void ViewerNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - bNode *editorNode = this->getbNode(); - bool do_output = (editorNode->flag & NODE_DO_OUTPUT_RECALC || context.isRendering()) && - (editorNode->flag & NODE_DO_OUTPUT); - bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0; - - NodeInput *imageSocket = this->getInputSocket(0); - NodeInput *alphaSocket = this->getInputSocket(1); - NodeInput *depthSocket = this->getInputSocket(2); - Image *image = (Image *)this->getbNode()->id; - ImageUser *imageUser = (ImageUser *)this->getbNode()->storage; - ViewerOperation *viewerOperation = new ViewerOperation(); - viewerOperation->setbNodeTree(context.getbNodeTree()); - viewerOperation->setImage(image); - viewerOperation->setImageUser(imageUser); - viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); - viewerOperation->setCenterX(editorNode->custom3); - viewerOperation->setCenterY(editorNode->custom4); - /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ - viewerOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked()); - viewerOperation->setRenderData(context.getRenderData()); - viewerOperation->setViewName(context.getViewName()); - - viewerOperation->setViewSettings(context.getViewSettings()); - viewerOperation->setDisplaySettings(context.getDisplaySettings()); - - viewerOperation->setResolutionInputSocketIndex(0); - if (!imageSocket->isLinked()) { - if (alphaSocket->isLinked()) { - viewerOperation->setResolutionInputSocketIndex(1); - } - } - - converter.addOperation(viewerOperation); - converter.mapInputSocket(imageSocket, viewerOperation->getInputSocket(0)); - /* only use alpha link if "use alpha" is enabled */ - if (ignore_alpha) { - converter.addInputValue(viewerOperation->getInputSocket(1), 1.0f); - } - else { - converter.mapInputSocket(alphaSocket, viewerOperation->getInputSocket(1)); - } - converter.mapInputSocket(depthSocket, viewerOperation->getInputSocket(2)); - - converter.addNodeInputPreview(imageSocket); - - if (do_output) { - converter.registerViewer(viewerOperation); - } -} diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cc b/source/blender/compositor/nodes/COM_ZCombineNode.cc new file mode 100644 index 00000000000..b61c018d029 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ZCombineNode.cc @@ -0,0 +1,101 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Copyright 2011, Blender Foundation. + */ + +#include "COM_ZCombineNode.h" + +#include "COM_ZCombineOperation.h" + +#include "COM_AntiAliasOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_MathBaseOperation.h" +#include "COM_MixOperation.h" +#include "COM_SetValueOperation.h" + +#include "DNA_material_types.h" /* the ramp types */ + +void ZCombineNode::convertToOperations(NodeConverter &converter, + const CompositorContext &context) const +{ + if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) { + ZCombineOperation *operation = nullptr; + if (this->getbNode()->custom1) { + operation = new ZCombineAlphaOperation(); + } + else { + operation = new ZCombineOperation(); + } + converter.addOperation(operation); + + converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); + converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); + converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); + + MathMinimumOperation *zoperation = new MathMinimumOperation(); + converter.addOperation(zoperation); + + converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); + } + else { + /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */ + // not full anti alias, use masking for Z combine. be aware it uses anti aliasing. + // step 1 create mask + NodeOperation *maskoperation; + if (this->getbNode()->custom1) { + maskoperation = new MathGreaterThanOperation(); + converter.addOperation(maskoperation); + + converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); + } + else { + maskoperation = new MathLessThanOperation(); + converter.addOperation(maskoperation); + + converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); + } + + // step 2 anti alias mask bit of an expensive operation, but does the trick + AntiAliasOperation *antialiasoperation = new AntiAliasOperation(); + converter.addOperation(antialiasoperation); + + converter.addLink(maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0)); + + // use mask to blend between the input colors. + ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1 ? + new ZCombineMaskAlphaOperation() : + new ZCombineMaskOperation(); + converter.addOperation(zcombineoperation); + + converter.addLink(antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(0), zcombineoperation->getInputSocket(1)); + converter.mapInputSocket(getInputSocket(2), zcombineoperation->getInputSocket(2)); + converter.mapOutputSocket(getOutputSocket(0), zcombineoperation->getOutputSocket()); + + MathMinimumOperation *zoperation = new MathMinimumOperation(); + converter.addOperation(zoperation); + + converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); + converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); + converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp deleted file mode 100644 index b61c018d029..00000000000 --- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright 2011, Blender Foundation. - */ - -#include "COM_ZCombineNode.h" - -#include "COM_ZCombineOperation.h" - -#include "COM_AntiAliasOperation.h" -#include "COM_ExecutionSystem.h" -#include "COM_MathBaseOperation.h" -#include "COM_MixOperation.h" -#include "COM_SetValueOperation.h" - -#include "DNA_material_types.h" /* the ramp types */ - -void ZCombineNode::convertToOperations(NodeConverter &converter, - const CompositorContext &context) const -{ - if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) { - ZCombineOperation *operation = nullptr; - if (this->getbNode()->custom1) { - operation = new ZCombineAlphaOperation(); - } - else { - operation = new ZCombineOperation(); - } - converter.addOperation(operation); - - converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2)); - converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3)); - converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket()); - - MathMinimumOperation *zoperation = new MathMinimumOperation(); - converter.addOperation(zoperation); - - converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); - } - else { - /* XXX custom1 is "use_alpha", what on earth is this supposed to do here?!? */ - // not full anti alias, use masking for Z combine. be aware it uses anti aliasing. - // step 1 create mask - NodeOperation *maskoperation; - if (this->getbNode()->custom1) { - maskoperation = new MathGreaterThanOperation(); - converter.addOperation(maskoperation); - - converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); - } - else { - maskoperation = new MathLessThanOperation(); - converter.addOperation(maskoperation); - - converter.mapInputSocket(getInputSocket(1), maskoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(3), maskoperation->getInputSocket(1)); - } - - // step 2 anti alias mask bit of an expensive operation, but does the trick - AntiAliasOperation *antialiasoperation = new AntiAliasOperation(); - converter.addOperation(antialiasoperation); - - converter.addLink(maskoperation->getOutputSocket(), antialiasoperation->getInputSocket(0)); - - // use mask to blend between the input colors. - ZCombineMaskOperation *zcombineoperation = this->getbNode()->custom1 ? - new ZCombineMaskAlphaOperation() : - new ZCombineMaskOperation(); - converter.addOperation(zcombineoperation); - - converter.addLink(antialiasoperation->getOutputSocket(), zcombineoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(0), zcombineoperation->getInputSocket(1)); - converter.mapInputSocket(getInputSocket(2), zcombineoperation->getInputSocket(2)); - converter.mapOutputSocket(getOutputSocket(0), zcombineoperation->getOutputSocket()); - - MathMinimumOperation *zoperation = new MathMinimumOperation(); - converter.addOperation(zoperation); - - converter.mapInputSocket(getInputSocket(1), zoperation->getInputSocket(0)); - converter.mapInputSocket(getInputSocket(3), zoperation->getInputSocket(1)); - converter.mapOutputSocket(getOutputSocket(1), zoperation->getOutputSocket()); - } -} -- cgit v1.2.3