Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/CMakeLists.txt1032
-rw-r--r--source/blender/compositor/COM_compositor.h10
-rw-r--r--source/blender/compositor/COM_defines.h54
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.cpp16
-rw-r--r--source/blender/compositor/intern/COM_CPUDevice.h23
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.cpp30
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrder.h44
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp16
-rw-r--r--source/blender/compositor/intern/COM_ChunkOrderHotspot.h19
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.cpp26
-rw-r--r--source/blender/compositor/intern/COM_CompositorContext.h403
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp811
-rw-r--r--source/blender/compositor/intern/COM_Converter.h80
-rw-r--r--source/blender/compositor/intern/COM_Debug.cpp733
-rw-r--r--source/blender/compositor/intern/COM_Debug.h70
-rw-r--r--source/blender/compositor/intern/COM_Device.h53
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.cpp964
-rw-r--r--source/blender/compositor/intern/COM_ExecutionGroup.h750
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.cpp333
-rw-r--r--source/blender/compositor/intern/COM_ExecutionSystem.h147
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.cpp268
-rw-r--r--source/blender/compositor/intern/COM_MemoryBuffer.h563
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.cpp27
-rw-r--r--source/blender/compositor/intern/COM_MemoryProxy.h167
-rw-r--r--source/blender/compositor/intern/COM_Node.cpp186
-rw-r--r--source/blender/compositor/intern/COM_Node.h487
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.cpp97
-rw-r--r--source/blender/compositor/intern/COM_NodeConverter.h154
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.cpp394
-rw-r--r--source/blender/compositor/intern/COM_NodeGraph.h157
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.cpp258
-rw-r--r--source/blender/compositor/intern/COM_NodeOperation.h760
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.cpp953
-rw-r--r--source/blender/compositor/intern/COM_NodeOperationBuilder.h237
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.cpp334
-rw-r--r--source/blender/compositor/intern/COM_OpenCLDevice.h174
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.cpp35
-rw-r--r--source/blender/compositor/intern/COM_SingleThreadedOperation.h50
-rw-r--r--source/blender/compositor/intern/COM_SocketReader.h178
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.cpp4
-rw-r--r--source/blender/compositor/intern/COM_WorkPackage.h57
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.cpp460
-rw-r--r--source/blender/compositor/intern/COM_WorkScheduler.h138
-rw-r--r--source/blender/compositor/intern/COM_compositor.cpp151
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.cpp68
-rw-r--r--source/blender/compositor/nodes/COM_AlphaOverNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp265
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp71
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_BokehImageNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.cpp67
-rw-r--r--source/blender/compositor/nodes/COM_BoxMaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_BrightnessNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.cpp113
-rw-r--r--source/blender/compositor/nodes/COM_ChannelMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.cpp55
-rw-r--r--source/blender/compositor/nodes/COM_ChromaMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.cpp69
-rw-r--r--source/blender/compositor/nodes/COM_ColorBalanceNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_ColorCorrectionNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.cpp51
-rw-r--r--source/blender/compositor/nodes/COM_ColorCurveNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.cpp51
-rw-r--r--source/blender/compositor/nodes/COM_ColorMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_ColorNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.cpp33
-rw-r--r--source/blender/compositor/nodes/COM_ColorRampNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.cpp31
-rw-r--r--source/blender/compositor/nodes/COM_ColorSpillNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.cpp17
-rw-r--r--source/blender/compositor/nodes/COM_ColorToBWNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.cpp94
-rw-r--r--source/blender/compositor/nodes/COM_CombineColorNode.h50
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.cpp54
-rw-r--r--source/blender/compositor/nodes/COM_CompositorNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_ConvertAlphaNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_CornerPinNode.cpp47
-rw-r--r--source/blender/compositor/nodes/COM_CornerPinNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.cpp38
-rw-r--r--source/blender/compositor/nodes/COM_CropNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_CryptomatteNode.cpp138
-rw-r--r--source/blender/compositor/nodes/COM_CryptomatteNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.cpp189
-rw-r--r--source/blender/compositor/nodes/COM_DefocusNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.cpp29
-rw-r--r--source/blender/compositor/nodes/COM_DespeckleNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp39
-rw-r--r--source/blender/compositor/nodes/COM_DifferenceMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.cpp221
-rw-r--r--source/blender/compositor/nodes/COM_DilateErodeNode.h9
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_DisplaceNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.cpp133
-rw-r--r--source/blender/compositor/nodes/COM_DistanceMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp23
-rw-r--r--source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.cpp67
-rw-r--r--source/blender/compositor/nodes/COM_EllipseMaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.cpp107
-rw-r--r--source/blender/compositor/nodes/COM_FilterNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.cpp45
-rw-r--r--source/blender/compositor/nodes/COM_FlipNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_GammaNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.cpp80
-rw-r--r--source/blender/compositor/nodes/COM_GlareNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp59
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp55
-rw-r--r--source/blender/compositor/nodes/COM_HueSaturationValueNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.cpp35
-rw-r--r--source/blender/compositor/nodes/COM_IDMaskNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.cpp454
-rw-r--r--source/blender/compositor/nodes/COM_ImageNode.h21
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.cpp23
-rw-r--r--source/blender/compositor/nodes/COM_InpaintNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_InvertNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp518
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.h43
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.cpp29
-rw-r--r--source/blender/compositor/nodes/COM_KeyingScreenNode.h7
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.cpp51
-rw-r--r--source/blender/compositor/nodes/COM_LensDistortionNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp35
-rw-r--r--source/blender/compositor/nodes/COM_LuminanceMatteNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.cpp35
-rw-r--r--source/blender/compositor/nodes/COM_MapRangeNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_MapUVNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_MapValueNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.cpp67
-rw-r--r--source/blender/compositor/nodes/COM_MaskNode.h9
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.cpp169
-rw-r--r--source/blender/compositor/nodes/COM_MathNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.cpp154
-rw-r--r--source/blender/compositor/nodes/COM_MixNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.cpp120
-rw-r--r--source/blender/compositor/nodes/COM_MovieClipNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_MovieDistortionNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.cpp43
-rw-r--r--source/blender/compositor/nodes/COM_NormalNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.cpp13
-rw-r--r--source/blender/compositor/nodes/COM_NormalizeNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.cpp203
-rw-r--r--source/blender/compositor/nodes/COM_OutputFileNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.cpp27
-rw-r--r--source/blender/compositor/nodes/COM_PixelateNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp71
-rw-r--r--source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h10
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.cpp240
-rw-r--r--source/blender/compositor/nodes/COM_RenderLayersNode.h35
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.cpp29
-rw-r--r--source/blender/compositor/nodes/COM_RotateNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.cpp155
-rw-r--r--source/blender/compositor/nodes/COM_ScaleNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.cpp150
-rw-r--r--source/blender/compositor/nodes/COM_SeparateColorNode.h50
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_SetAlphaNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.cpp88
-rw-r--r--source/blender/compositor/nodes/COM_SocketProxyNode.h36
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.cpp64
-rw-r--r--source/blender/compositor/nodes/COM_SplitViewerNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.cpp107
-rw-r--r--source/blender/compositor/nodes/COM_Stabilize2dNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SunBeamsNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_SunBeamsNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.cpp19
-rw-r--r--source/blender/compositor/nodes/COM_SwitchNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_SwitchViewNode.cpp21
-rw-r--r--source/blender/compositor/nodes/COM_SwitchViewNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.cpp47
-rw-r--r--source/blender/compositor/nodes/COM_TextureNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.cpp45
-rw-r--r--source/blender/compositor/nodes/COM_TimeNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.cpp18
-rw-r--r--source/blender/compositor/nodes/COM_TonemapNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_TrackPositionNode.cpp131
-rw-r--r--source/blender/compositor/nodes/COM_TrackPositionNode.h7
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.cpp55
-rw-r--r--source/blender/compositor/nodes/COM_TransformNode.h8
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.cpp65
-rw-r--r--source/blender/compositor/nodes/COM_TranslateNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_ValueNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp25
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.cpp15
-rw-r--r--source/blender/compositor/nodes/COM_VectorCurveNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.cpp53
-rw-r--r--source/blender/compositor/nodes/COM_ViewLevelsNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.cpp82
-rw-r--r--source/blender/compositor/nodes/COM_ViewerNode.h6
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.cpp137
-rw-r--r--source/blender/compositor/nodes/COM_ZCombineNode.h8
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverKeyOperation.h19
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp49
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverMixedOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp47
-rw-r--r--source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h20
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.cpp217
-rw-r--r--source/blender/compositor/operations/COM_AntiAliasOperation.h45
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp133
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp224
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp354
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.h81
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.cpp153
-rw-r--r--source/blender/compositor/operations/COM_BokehImageOperation.h193
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.cpp140
-rw-r--r--source/blender/compositor/operations/COM_BoxMaskOperation.h61
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.cpp101
-rw-r--r--source/blender/compositor/operations/COM_BrightnessOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.cpp155
-rw-r--r--source/blender/compositor/operations/COM_CalculateMeanOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp128
-rw-r--r--source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h19
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.cpp59
-rw-r--r--source/blender/compositor/operations/COM_ChangeHSVOperation.h34
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.cpp152
-rw-r--r--source/blender/compositor/operations/COM_ChannelMatteOperation.h76
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp145
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.h37
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp63
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h67
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp72
-rw-r--r--source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp212
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.h81
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.cpp192
-rw-r--r--source/blender/compositor/operations/COM_ColorCurveOperation.h99
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.cpp72
-rw-r--r--source/blender/compositor/operations/COM_ColorMatteOperation.h37
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.cpp25
-rw-r--r--source/blender/compositor/operations/COM_ColorRampOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.cpp148
-rw-r--r--source/blender/compositor/operations/COM_ColorSpillOperation.h66
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.cpp379
-rw-r--r--source/blender/compositor/operations/COM_CompositorOperation.h142
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp26
-rw-r--r--source/blender/compositor/operations/COM_ConvertColorProfileOperation.h85
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp122
-rw-r--r--source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h84
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cpp487
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.h187
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp142
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h6
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp155
-rw-r--r--source/blender/compositor/operations/COM_ConvolutionFilterOperation.h31
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.cpp134
-rw-r--r--source/blender/compositor/operations/COM_CropOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.cpp75
-rw-r--r--source/blender/compositor/operations/COM_CryptomatteOperation.h17
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.cpp32
-rw-r--r--source/blender/compositor/operations/COM_CurveBaseOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp174
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.h50
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp88
-rw-r--r--source/blender/compositor/operations/COM_DifferenceMatteOperation.h37
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.cpp852
-rw-r--r--source/blender/compositor/operations/COM_DilateErodeOperation.h267
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp189
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.h60
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.cpp290
-rw-r--r--source/blender/compositor/operations/COM_DisplaceOperation.h66
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp170
-rw-r--r--source/blender/compositor/operations/COM_DisplaceSimpleOperation.h71
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp89
-rw-r--r--source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp6
-rw-r--r--source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.cpp35
-rw-r--r--source/blender/compositor/operations/COM_DotproductOperation.h16
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp2457
-rw-r--r--source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h78
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.cpp153
-rw-r--r--source/blender/compositor/operations/COM_EllipseMaskOperation.h61
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp505
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h80
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.cpp67
-rw-r--r--source/blender/compositor/operations/COM_FlipOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp96
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.h77
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_GammaOperation.h41
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp247
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h75
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp248
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h75
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp543
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h78
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp254
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.h74
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp256
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.h74
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.cpp60
-rw-r--r--source/blender/compositor/operations/COM_GlareBaseOperation.h65
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp694
-rw-r--r--source/blender/compositor/operations/COM_GlareFogGlowOperation.h11
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.cpp192
-rw-r--r--source/blender/compositor/operations/COM_GlareGhostOperation.h11
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp146
-rw-r--r--source/blender/compositor/operations/COM_GlareSimpleStarOperation.h11
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.cpp126
-rw-r--r--source/blender/compositor/operations/COM_GlareStreaksOperation.h11
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.cpp50
-rw-r--r--source/blender/compositor/operations/COM_GlareThresholdOperation.h68
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp55
-rw-r--r--source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.cpp25
-rw-r--r--source/blender/compositor/operations/COM_IDMaskOperation.h18
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.cpp257
-rw-r--r--source/blender/compositor/operations/COM_ImageOperation.h115
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.cpp399
-rw-r--r--source/blender/compositor/operations/COM_InpaintOperation.h77
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.cpp61
-rw-r--r--source/blender/compositor/operations/COM_InvertOperation.h67
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cpp95
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.h48
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.cpp155
-rw-r--r--source/blender/compositor/operations/COM_KeyingClipOperation.h50
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp62
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.h38
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp118
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.h24
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.cpp507
-rw-r--r--source/blender/compositor/operations/COM_KeyingScreenOperation.h90
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp63
-rw-r--r--source/blender/compositor/operations/COM_LuminanceMatteOperation.h35
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.cpp111
-rw-r--r--source/blender/compositor/operations/COM_MapRangeOperation.h65
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp267
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.h64
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.cpp37
-rw-r--r--source/blender/compositor/operations/COM_MapValueOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.cpp217
-rw-r--r--source/blender/compositor/operations/COM_MaskOperation.h117
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp505
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.h273
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.cpp1204
-rw-r--r--source/blender/compositor/operations/COM_MixOperation.h217
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp95
-rw-r--r--source/blender/compositor/operations/COM_MovieClipAttributeOperation.h62
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.cpp143
-rw-r--r--source/blender/compositor/operations/COM_MovieClipOperation.h65
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.cpp177
-rw-r--r--source/blender/compositor/operations/COM_MovieDistortionOperation.h59
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.cpp156
-rw-r--r--source/blender/compositor/operations/COM_MultilayerImageOperation.h63
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.cpp143
-rw-r--r--source/blender/compositor/operations/COM_NormalizeOperation.h57
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp467
-rw-r--r--source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h63
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.cpp485
-rw-r--r--source/blender/compositor/operations/COM_OutputFileOperation.h159
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.cpp23
-rw-r--r--source/blender/compositor/operations/COM_PixelateOperation.h55
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp262
-rw-r--r--source/blender/compositor/operations/COM_PlaneCornerPinOperation.h36
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp304
-rw-r--r--source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h121
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.cpp144
-rw-r--r--source/blender/compositor/operations/COM_PlaneTrackOperation.h105
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.cpp175
-rw-r--r--source/blender/compositor/operations/COM_PreviewOperation.h51
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp126
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.cpp78
-rw-r--r--source/blender/compositor/operations/COM_QualityStepHelper.h52
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.cpp150
-rw-r--r--source/blender/compositor/operations/COM_ReadBufferOperation.h69
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.cpp357
-rw-r--r--source/blender/compositor/operations/COM_RenderLayersProg.h188
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.cpp119
-rw-r--r--source/blender/compositor/operations/COM_RotateOperation.h40
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp408
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.h155
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp516
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h112
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.cpp31
-rw-r--r--source/blender/compositor/operations/COM_SetAlphaOperation.h29
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_SetColorOperation.h79
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.cpp15
-rw-r--r--source/blender/compositor/operations/COM_SetSamplerOperation.h35
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.cpp14
-rw-r--r--source/blender/compositor/operations/COM_SetValueOperation.h49
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_SetVectorOperation.h87
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.cpp9
-rw-r--r--source/blender/compositor/operations/COM_SocketProxyOperation.h28
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.cpp62
-rw-r--r--source/blender/compositor/operations/COM_SplitOperation.h33
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.cpp535
-rw-r--r--source/blender/compositor/operations/COM_SunBeamsOperation.h27
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.cpp182
-rw-r--r--source/blender/compositor/operations/COM_TextureOperation.h76
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.cpp186
-rw-r--r--source/blender/compositor/operations/COM_TonemapOperation.h87
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.cpp180
-rw-r--r--source/blender/compositor/operations/COM_TrackPositionOperation.h86
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.cpp70
-rw-r--r--source/blender/compositor/operations/COM_TranslateOperation.h74
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp543
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h158
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp1429
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.h72
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.cpp28
-rw-r--r--source/blender/compositor/operations/COM_VectorCurveOperation.h39
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.cpp282
-rw-r--r--source/blender/compositor/operations/COM_ViewerOperation.h143
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.cpp126
-rw-r--r--source/blender/compositor/operations/COM_WrapOperation.h23
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.cpp310
-rw-r--r--source/blender/compositor/operations/COM_WriteBufferOperation.h52
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.cpp187
-rw-r--r--source/blender/compositor/operations/COM_ZCombineOperation.h57
432 files changed, 27235 insertions, 24508 deletions
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index 2b03b713e3c..49aee93c8a4 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -19,26 +19,26 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
- .
- intern
- nodes
- operations
- ../blenkernel
- ../blenlib
- ../blentranslation
- ../depsgraph
- ../imbuf
- ../makesdna
- ../makesrna
- ../windowmanager
- ../nodes
- ../nodes/composite
- ../nodes/intern
- ../render/extern/include
- ../render/intern/include
- ../../../extern/clew/include
- ../../../intern/guardedalloc
- ../../../intern/atomic
+ .
+ intern
+ nodes
+ operations
+ ../blenkernel
+ ../blenlib
+ ../blentranslation
+ ../depsgraph
+ ../imbuf
+ ../makesdna
+ ../makesrna
+ ../windowmanager
+ ../nodes
+ ../nodes/composite
+ ../nodes/intern
+ ../render/extern/include
+ ../render/intern/include
+ ../../../extern/clew/include
+ ../../../intern/guardedalloc
+ ../../../intern/atomic
)
set(INC_SYS
@@ -46,507 +46,507 @@ set(INC_SYS
)
set(SRC
- COM_compositor.h
- COM_defines.h
-
- intern/COM_CPUDevice.cpp
- intern/COM_CPUDevice.h
- intern/COM_ChunkOrder.cpp
- intern/COM_ChunkOrder.h
- intern/COM_ChunkOrderHotspot.cpp
- intern/COM_ChunkOrderHotspot.h
- intern/COM_CompositorContext.cpp
- intern/COM_CompositorContext.h
- intern/COM_Converter.cpp
- intern/COM_Converter.h
- intern/COM_Debug.cpp
- intern/COM_Debug.h
- intern/COM_Device.cpp
- intern/COM_Device.h
- intern/COM_ExecutionGroup.cpp
- intern/COM_ExecutionGroup.h
- intern/COM_ExecutionSystem.cpp
- intern/COM_ExecutionSystem.h
- intern/COM_MemoryBuffer.cpp
- intern/COM_MemoryBuffer.h
- intern/COM_MemoryProxy.cpp
- intern/COM_MemoryProxy.h
- intern/COM_Node.cpp
- intern/COM_Node.h
- intern/COM_NodeConverter.cpp
- intern/COM_NodeConverter.h
- intern/COM_NodeGraph.cpp
- intern/COM_NodeGraph.h
- intern/COM_NodeOperation.cpp
- intern/COM_NodeOperation.h
- intern/COM_NodeOperationBuilder.cpp
- intern/COM_NodeOperationBuilder.h
- intern/COM_OpenCLDevice.cpp
- intern/COM_OpenCLDevice.h
- intern/COM_SingleThreadedOperation.cpp
- intern/COM_SingleThreadedOperation.h
- intern/COM_SocketReader.cpp
- intern/COM_SocketReader.h
- intern/COM_WorkPackage.cpp
- intern/COM_WorkPackage.h
- intern/COM_WorkScheduler.cpp
- intern/COM_WorkScheduler.h
- intern/COM_compositor.cpp
-
- operations/COM_QualityStepHelper.cpp
- operations/COM_QualityStepHelper.h
-
- # Internal nodes
- nodes/COM_SocketProxyNode.cpp
- nodes/COM_SocketProxyNode.h
-
- # input nodes
- nodes/COM_BokehImageNode.cpp
- nodes/COM_BokehImageNode.h
- nodes/COM_ColorNode.cpp
- nodes/COM_ColorNode.h
- nodes/COM_ImageNode.cpp
- nodes/COM_ImageNode.h
- nodes/COM_MaskNode.cpp
- nodes/COM_MaskNode.h
- nodes/COM_MovieClipNode.cpp
- nodes/COM_MovieClipNode.h
- nodes/COM_OutputFileNode.cpp
- nodes/COM_OutputFileNode.h
- nodes/COM_RenderLayersNode.cpp
- nodes/COM_RenderLayersNode.h
- nodes/COM_SwitchNode.cpp
- nodes/COM_SwitchNode.h
- nodes/COM_SwitchViewNode.cpp
- nodes/COM_SwitchViewNode.h
- nodes/COM_TextureNode.cpp
- nodes/COM_TextureNode.h
- nodes/COM_TimeNode.cpp
- nodes/COM_TimeNode.h
- nodes/COM_ValueNode.cpp
- nodes/COM_ValueNode.h
-
- # output nodes
- nodes/COM_CompositorNode.cpp
- nodes/COM_CompositorNode.h
- nodes/COM_SplitViewerNode.cpp
- nodes/COM_SplitViewerNode.h
- nodes/COM_ViewLevelsNode.cpp
- nodes/COM_ViewLevelsNode.h
- nodes/COM_ViewerNode.cpp
- nodes/COM_ViewerNode.h
- operations/COM_CalculateMeanOperation.cpp
- operations/COM_CalculateMeanOperation.h
- operations/COM_CalculateStandardDeviationOperation.cpp
- operations/COM_CalculateStandardDeviationOperation.h
-
- # distort nodes
- nodes/COM_FlipNode.cpp
- nodes/COM_FlipNode.h
- nodes/COM_RotateNode.cpp
- nodes/COM_RotateNode.h
- nodes/COM_ScaleNode.cpp
- nodes/COM_ScaleNode.h
- nodes/COM_TranslateNode.cpp
- nodes/COM_TranslateNode.h
-
- nodes/COM_DisplaceNode.cpp
- nodes/COM_DisplaceNode.h
- nodes/COM_MapUVNode.cpp
- nodes/COM_MapUVNode.h
-
- nodes/COM_ChannelMatteNode.cpp
- nodes/COM_ChannelMatteNode.h
- nodes/COM_ChromaMatteNode.cpp
- nodes/COM_ChromaMatteNode.h
- nodes/COM_ColorMatteNode.cpp
- nodes/COM_ColorMatteNode.h
- nodes/COM_DifferenceMatteNode.cpp
- nodes/COM_DifferenceMatteNode.h
- nodes/COM_DistanceMatteNode.cpp
- nodes/COM_DistanceMatteNode.h
- nodes/COM_LensDistortionNode.cpp
- nodes/COM_LensDistortionNode.h
- nodes/COM_LuminanceMatteNode.cpp
- nodes/COM_LuminanceMatteNode.h
-
- nodes/COM_GlareNode.cpp
- nodes/COM_GlareNode.h
-
- nodes/COM_SunBeamsNode.cpp
- nodes/COM_SunBeamsNode.h
- operations/COM_SunBeamsOperation.cpp
- operations/COM_SunBeamsOperation.h
-
- nodes/COM_CryptomatteNode.cpp
- nodes/COM_CryptomatteNode.h
- operations/COM_CryptomatteOperation.cpp
- operations/COM_CryptomatteOperation.h
-
- nodes/COM_CornerPinNode.cpp
- nodes/COM_CornerPinNode.h
- nodes/COM_PlaneTrackDeformNode.cpp
- nodes/COM_PlaneTrackDeformNode.h
-
- nodes/COM_CropNode.cpp
- nodes/COM_CropNode.h
- operations/COM_CropOperation.cpp
- operations/COM_CropOperation.h
-
- nodes/COM_DefocusNode.cpp
- nodes/COM_DefocusNode.h
- nodes/COM_MovieDistortionNode.cpp
- nodes/COM_MovieDistortionNode.h
- nodes/COM_Stabilize2dNode.cpp
- nodes/COM_Stabilize2dNode.h
- nodes/COM_TransformNode.cpp
- nodes/COM_TransformNode.h
-
- # color nodes
- nodes/COM_AlphaOverNode.cpp
- nodes/COM_AlphaOverNode.h
- nodes/COM_BrightnessNode.cpp
- nodes/COM_BrightnessNode.h
- nodes/COM_ColorBalanceNode.cpp
- nodes/COM_ColorBalanceNode.h
- nodes/COM_ColorCorrectionNode.cpp
- nodes/COM_ColorCorrectionNode.h
- nodes/COM_ColorCurveNode.cpp
- nodes/COM_ColorCurveNode.h
- nodes/COM_ColorRampNode.cpp
- nodes/COM_ColorRampNode.h
- nodes/COM_ColorToBWNode.cpp
- nodes/COM_ColorToBWNode.h
- nodes/COM_ConvertAlphaNode.cpp
- nodes/COM_ConvertAlphaNode.h
- nodes/COM_GammaNode.cpp
- nodes/COM_GammaNode.h
- nodes/COM_HueSaturationValueCorrectNode.cpp
- nodes/COM_HueSaturationValueCorrectNode.h
- nodes/COM_HueSaturationValueNode.cpp
- nodes/COM_HueSaturationValueNode.h
- nodes/COM_InvertNode.cpp
- nodes/COM_InvertNode.h
- nodes/COM_MixNode.cpp
- nodes/COM_MixNode.h
- nodes/COM_SetAlphaNode.cpp
- nodes/COM_SetAlphaNode.h
- nodes/COM_TonemapNode.cpp
- nodes/COM_TonemapNode.h
- nodes/COM_VectorCurveNode.cpp
- nodes/COM_VectorCurveNode.h
- nodes/COM_ZCombineNode.cpp
- nodes/COM_ZCombineNode.h
- operations/COM_TonemapOperation.cpp
- operations/COM_TonemapOperation.h
-
- # converter nodes
- nodes/COM_CombineColorNode.cpp
- nodes/COM_CombineColorNode.h
- nodes/COM_IDMaskNode.cpp
- nodes/COM_IDMaskNode.h
- nodes/COM_SeparateColorNode.cpp
- nodes/COM_SeparateColorNode.h
-
- nodes/COM_MapRangeNode.cpp
- nodes/COM_MapRangeNode.h
- nodes/COM_MapValueNode.cpp
- nodes/COM_MapValueNode.h
- nodes/COM_MathNode.cpp
- nodes/COM_MathNode.h
- nodes/COM_NormalNode.cpp
- nodes/COM_NormalNode.h
- nodes/COM_NormalizeNode.cpp
- nodes/COM_NormalizeNode.h
-
- operations/COM_NormalizeOperation.cpp
- operations/COM_NormalizeOperation.h
-
- nodes/COM_PixelateNode.cpp
- nodes/COM_PixelateNode.h
- operations/COM_PixelateOperation.cpp
- operations/COM_PixelateOperation.h
-
- # Filter nodes
- nodes/COM_BilateralBlurNode.cpp
- nodes/COM_BilateralBlurNode.h
- operations/COM_BilateralBlurOperation.cpp
- operations/COM_BilateralBlurOperation.h
- nodes/COM_VectorBlurNode.cpp
- nodes/COM_VectorBlurNode.h
- operations/COM_VectorBlurOperation.cpp
- operations/COM_VectorBlurOperation.h
-
- nodes/COM_BlurNode.cpp
- nodes/COM_BlurNode.h
- nodes/COM_BokehBlurNode.cpp
- nodes/COM_BokehBlurNode.h
- nodes/COM_DespeckleNode.cpp
- nodes/COM_DespeckleNode.h
- nodes/COM_DilateErodeNode.cpp
- nodes/COM_DilateErodeNode.h
- nodes/COM_DirectionalBlurNode.cpp
- nodes/COM_DirectionalBlurNode.h
- nodes/COM_FilterNode.cpp
- nodes/COM_FilterNode.h
- nodes/COM_InpaintNode.cpp
- nodes/COM_InpaintNode.h
- operations/COM_BlurBaseOperation.cpp
- operations/COM_BlurBaseOperation.h
- operations/COM_BokehBlurOperation.cpp
- operations/COM_BokehBlurOperation.h
- operations/COM_DirectionalBlurOperation.cpp
- operations/COM_DirectionalBlurOperation.h
- operations/COM_FastGaussianBlurOperation.cpp
- operations/COM_FastGaussianBlurOperation.h
- operations/COM_GammaCorrectOperation.cpp
- operations/COM_GammaCorrectOperation.h
- operations/COM_GaussianAlphaXBlurOperation.cpp
- operations/COM_GaussianAlphaXBlurOperation.h
- operations/COM_GaussianAlphaYBlurOperation.cpp
- operations/COM_GaussianAlphaYBlurOperation.h
- operations/COM_GaussianBokehBlurOperation.cpp
- operations/COM_GaussianBokehBlurOperation.h
- operations/COM_GaussianXBlurOperation.cpp
- operations/COM_GaussianXBlurOperation.h
- operations/COM_GaussianYBlurOperation.cpp
- operations/COM_GaussianYBlurOperation.h
- operations/COM_MovieClipAttributeOperation.cpp
- operations/COM_MovieClipAttributeOperation.h
- operations/COM_MovieDistortionOperation.cpp
- operations/COM_MovieDistortionOperation.h
- operations/COM_VariableSizeBokehBlurOperation.cpp
- operations/COM_VariableSizeBokehBlurOperation.h
-
- # Matte nodes
- nodes/COM_BoxMaskNode.cpp
- nodes/COM_BoxMaskNode.h
- nodes/COM_ColorSpillNode.cpp
- nodes/COM_ColorSpillNode.h
- nodes/COM_DoubleEdgeMaskNode.cpp
- nodes/COM_DoubleEdgeMaskNode.h
- nodes/COM_EllipseMaskNode.cpp
- nodes/COM_EllipseMaskNode.h
-
- operations/COM_DoubleEdgeMaskOperation.cpp
- operations/COM_DoubleEdgeMaskOperation.h
-
-
- nodes/COM_KeyingScreenNode.cpp
- nodes/COM_KeyingScreenNode.h
- operations/COM_KeyingScreenOperation.cpp
- operations/COM_KeyingScreenOperation.h
-
- nodes/COM_TrackPositionNode.cpp
- nodes/COM_TrackPositionNode.h
- operations/COM_TrackPositionOperation.cpp
- operations/COM_TrackPositionOperation.h
-
- nodes/COM_KeyingNode.cpp
- nodes/COM_KeyingNode.h
- operations/COM_KeyingBlurOperation.cpp
- operations/COM_KeyingBlurOperation.h
- operations/COM_KeyingClipOperation.cpp
- operations/COM_KeyingClipOperation.h
- operations/COM_KeyingDespillOperation.cpp
- operations/COM_KeyingDespillOperation.h
- operations/COM_KeyingOperation.cpp
- operations/COM_KeyingOperation.h
-
- operations/COM_ColorSpillOperation.cpp
- operations/COM_ColorSpillOperation.h
- operations/COM_RenderLayersProg.cpp
- operations/COM_RenderLayersProg.h
-
- operations/COM_BokehImageOperation.cpp
- operations/COM_BokehImageOperation.h
- operations/COM_ImageOperation.cpp
- operations/COM_ImageOperation.h
- operations/COM_MultilayerImageOperation.cpp
- operations/COM_MultilayerImageOperation.h
- operations/COM_TextureOperation.cpp
- operations/COM_TextureOperation.h
-
-
- operations/COM_SocketProxyOperation.cpp
- operations/COM_SocketProxyOperation.h
-
- operations/COM_CompositorOperation.cpp
- operations/COM_CompositorOperation.h
- operations/COM_ConvertDepthToRadiusOperation.cpp
- operations/COM_ConvertDepthToRadiusOperation.h
- operations/COM_OutputFileMultiViewOperation.cpp
- operations/COM_OutputFileMultiViewOperation.h
- operations/COM_OutputFileOperation.cpp
- operations/COM_OutputFileOperation.h
- operations/COM_PreviewOperation.cpp
- operations/COM_PreviewOperation.h
- operations/COM_SplitOperation.cpp
- operations/COM_SplitOperation.h
- operations/COM_ViewerOperation.cpp
- operations/COM_ViewerOperation.h
- operations/COM_ZCombineOperation.cpp
- operations/COM_ZCombineOperation.h
-
- operations/COM_ChangeHSVOperation.cpp
- operations/COM_ChangeHSVOperation.h
- operations/COM_ChannelMatteOperation.cpp
- operations/COM_ChannelMatteOperation.h
- operations/COM_ChromaMatteOperation.cpp
- operations/COM_ChromaMatteOperation.h
- operations/COM_ColorCurveOperation.cpp
- operations/COM_ColorCurveOperation.h
- operations/COM_ColorMatteOperation.cpp
- operations/COM_ColorMatteOperation.h
- operations/COM_ColorRampOperation.cpp
- operations/COM_ColorRampOperation.h
- operations/COM_CurveBaseOperation.cpp
- operations/COM_CurveBaseOperation.h
- operations/COM_DifferenceMatteOperation.cpp
- operations/COM_DifferenceMatteOperation.h
- operations/COM_DistanceRGBMatteOperation.cpp
- operations/COM_DistanceRGBMatteOperation.h
- operations/COM_DistanceYCCMatteOperation.cpp
- operations/COM_DistanceYCCMatteOperation.h
- operations/COM_HueSaturationValueCorrectOperation.cpp
- operations/COM_HueSaturationValueCorrectOperation.h
- operations/COM_LuminanceMatteOperation.cpp
- operations/COM_LuminanceMatteOperation.h
- operations/COM_VectorCurveOperation.cpp
- operations/COM_VectorCurveOperation.h
-
- operations/COM_BrightnessOperation.cpp
- operations/COM_BrightnessOperation.h
- operations/COM_ColorCorrectionOperation.cpp
- operations/COM_ColorCorrectionOperation.h
- operations/COM_GammaOperation.cpp
- operations/COM_GammaOperation.h
- operations/COM_MixOperation.cpp
- operations/COM_MixOperation.h
- operations/COM_ReadBufferOperation.cpp
- operations/COM_ReadBufferOperation.h
- operations/COM_SetColorOperation.cpp
- operations/COM_SetColorOperation.h
- operations/COM_SetValueOperation.cpp
- operations/COM_SetValueOperation.h
- operations/COM_SetVectorOperation.cpp
- operations/COM_SetVectorOperation.h
- operations/COM_WriteBufferOperation.cpp
- operations/COM_WriteBufferOperation.h
-
- operations/COM_MathBaseOperation.cpp
- operations/COM_MathBaseOperation.h
-
- operations/COM_AlphaOverKeyOperation.cpp
- operations/COM_AlphaOverKeyOperation.h
- operations/COM_AlphaOverMixedOperation.cpp
- operations/COM_AlphaOverMixedOperation.h
- operations/COM_AlphaOverPremultiplyOperation.cpp
- operations/COM_AlphaOverPremultiplyOperation.h
-
- operations/COM_ColorBalanceASCCDLOperation.cpp
- operations/COM_ColorBalanceASCCDLOperation.h
- operations/COM_ColorBalanceLGGOperation.cpp
- operations/COM_ColorBalanceLGGOperation.h
- operations/COM_InvertOperation.cpp
- operations/COM_InvertOperation.h
- operations/COM_MapRangeOperation.cpp
- operations/COM_MapRangeOperation.h
- operations/COM_MapValueOperation.cpp
- operations/COM_MapValueOperation.h
- operations/COM_SetAlphaOperation.cpp
- operations/COM_SetAlphaOperation.h
-
- # Distort operation
- operations/COM_DisplaceOperation.cpp
- operations/COM_DisplaceOperation.h
- operations/COM_DisplaceSimpleOperation.cpp
- operations/COM_DisplaceSimpleOperation.h
- operations/COM_FlipOperation.cpp
- operations/COM_FlipOperation.h
- operations/COM_MapUVOperation.cpp
- operations/COM_MapUVOperation.h
- operations/COM_PlaneCornerPinOperation.cpp
- operations/COM_PlaneCornerPinOperation.h
- operations/COM_PlaneDistortCommonOperation.cpp
- operations/COM_PlaneDistortCommonOperation.h
- operations/COM_PlaneTrackOperation.cpp
- operations/COM_PlaneTrackOperation.h
- operations/COM_ProjectorLensDistortionOperation.cpp
- operations/COM_ProjectorLensDistortionOperation.h
- operations/COM_RotateOperation.cpp
- operations/COM_RotateOperation.h
- operations/COM_ScaleOperation.cpp
- operations/COM_ScaleOperation.h
- operations/COM_ScreenLensDistortionOperation.cpp
- operations/COM_ScreenLensDistortionOperation.h
- operations/COM_TranslateOperation.cpp
- operations/COM_TranslateOperation.h
- operations/COM_WrapOperation.cpp
- operations/COM_WrapOperation.h
-
- #Filter operations
- operations/COM_ConvolutionEdgeFilterOperation.cpp
- operations/COM_ConvolutionEdgeFilterOperation.h
- operations/COM_ConvolutionFilterOperation.cpp
- operations/COM_ConvolutionFilterOperation.h
- operations/COM_DespeckleOperation.cpp
- operations/COM_DespeckleOperation.h
- operations/COM_DilateErodeOperation.cpp
- operations/COM_DilateErodeOperation.h
- operations/COM_GlareBaseOperation.cpp
- operations/COM_GlareBaseOperation.h
- operations/COM_GlareFogGlowOperation.cpp
- operations/COM_GlareFogGlowOperation.h
- operations/COM_GlareGhostOperation.cpp
- operations/COM_GlareGhostOperation.h
- operations/COM_GlareSimpleStarOperation.cpp
- operations/COM_GlareSimpleStarOperation.h
- operations/COM_GlareStreaksOperation.cpp
- operations/COM_GlareStreaksOperation.h
- operations/COM_GlareThresholdOperation.cpp
- operations/COM_GlareThresholdOperation.h
- operations/COM_InpaintOperation.cpp
- operations/COM_InpaintOperation.h
- operations/COM_SetSamplerOperation.cpp
- operations/COM_SetSamplerOperation.h
-
-
- #Convert operations
- operations/COM_ConvertOperation.cpp
- operations/COM_ConvertOperation.h
- operations/COM_IDMaskOperation.cpp
- operations/COM_IDMaskOperation.h
-
- operations/COM_DotproductOperation.cpp
- operations/COM_DotproductOperation.h
-
- # Matte operation
- operations/COM_BoxMaskOperation.cpp
- operations/COM_BoxMaskOperation.h
- operations/COM_EllipseMaskOperation.cpp
- operations/COM_EllipseMaskOperation.h
-
- operations/COM_ConvertColorProfileOperation.cpp
- operations/COM_ConvertColorProfileOperation.h
- operations/COM_MovieClipOperation.cpp
- operations/COM_MovieClipOperation.h
-
- operations/COM_AntiAliasOperation.cpp
- operations/COM_AntiAliasOperation.h
-
- operations/COM_MaskOperation.cpp
- operations/COM_MaskOperation.h
+ COM_compositor.h
+ COM_defines.h
+
+ intern/COM_CPUDevice.cpp
+ intern/COM_CPUDevice.h
+ intern/COM_ChunkOrder.cpp
+ intern/COM_ChunkOrder.h
+ intern/COM_ChunkOrderHotspot.cpp
+ intern/COM_ChunkOrderHotspot.h
+ intern/COM_CompositorContext.cpp
+ intern/COM_CompositorContext.h
+ intern/COM_Converter.cpp
+ intern/COM_Converter.h
+ intern/COM_Debug.cpp
+ intern/COM_Debug.h
+ intern/COM_Device.cpp
+ intern/COM_Device.h
+ intern/COM_ExecutionGroup.cpp
+ intern/COM_ExecutionGroup.h
+ intern/COM_ExecutionSystem.cpp
+ intern/COM_ExecutionSystem.h
+ intern/COM_MemoryBuffer.cpp
+ intern/COM_MemoryBuffer.h
+ intern/COM_MemoryProxy.cpp
+ intern/COM_MemoryProxy.h
+ intern/COM_Node.cpp
+ intern/COM_Node.h
+ intern/COM_NodeConverter.cpp
+ intern/COM_NodeConverter.h
+ intern/COM_NodeGraph.cpp
+ intern/COM_NodeGraph.h
+ intern/COM_NodeOperation.cpp
+ intern/COM_NodeOperation.h
+ intern/COM_NodeOperationBuilder.cpp
+ intern/COM_NodeOperationBuilder.h
+ intern/COM_OpenCLDevice.cpp
+ intern/COM_OpenCLDevice.h
+ intern/COM_SingleThreadedOperation.cpp
+ intern/COM_SingleThreadedOperation.h
+ intern/COM_SocketReader.cpp
+ intern/COM_SocketReader.h
+ intern/COM_WorkPackage.cpp
+ intern/COM_WorkPackage.h
+ intern/COM_WorkScheduler.cpp
+ intern/COM_WorkScheduler.h
+ intern/COM_compositor.cpp
+
+ operations/COM_QualityStepHelper.cpp
+ operations/COM_QualityStepHelper.h
+
+ # Internal nodes
+ nodes/COM_SocketProxyNode.cpp
+ nodes/COM_SocketProxyNode.h
+
+ # input nodes
+ nodes/COM_BokehImageNode.cpp
+ nodes/COM_BokehImageNode.h
+ nodes/COM_ColorNode.cpp
+ nodes/COM_ColorNode.h
+ nodes/COM_ImageNode.cpp
+ nodes/COM_ImageNode.h
+ nodes/COM_MaskNode.cpp
+ nodes/COM_MaskNode.h
+ nodes/COM_MovieClipNode.cpp
+ nodes/COM_MovieClipNode.h
+ nodes/COM_OutputFileNode.cpp
+ nodes/COM_OutputFileNode.h
+ nodes/COM_RenderLayersNode.cpp
+ nodes/COM_RenderLayersNode.h
+ nodes/COM_SwitchNode.cpp
+ nodes/COM_SwitchNode.h
+ nodes/COM_SwitchViewNode.cpp
+ nodes/COM_SwitchViewNode.h
+ nodes/COM_TextureNode.cpp
+ nodes/COM_TextureNode.h
+ nodes/COM_TimeNode.cpp
+ nodes/COM_TimeNode.h
+ nodes/COM_ValueNode.cpp
+ nodes/COM_ValueNode.h
+
+ # output nodes
+ nodes/COM_CompositorNode.cpp
+ nodes/COM_CompositorNode.h
+ nodes/COM_SplitViewerNode.cpp
+ nodes/COM_SplitViewerNode.h
+ nodes/COM_ViewLevelsNode.cpp
+ nodes/COM_ViewLevelsNode.h
+ nodes/COM_ViewerNode.cpp
+ nodes/COM_ViewerNode.h
+ operations/COM_CalculateMeanOperation.cpp
+ operations/COM_CalculateMeanOperation.h
+ operations/COM_CalculateStandardDeviationOperation.cpp
+ operations/COM_CalculateStandardDeviationOperation.h
+
+ # distort nodes
+ nodes/COM_FlipNode.cpp
+ nodes/COM_FlipNode.h
+ nodes/COM_RotateNode.cpp
+ nodes/COM_RotateNode.h
+ nodes/COM_ScaleNode.cpp
+ nodes/COM_ScaleNode.h
+ nodes/COM_TranslateNode.cpp
+ nodes/COM_TranslateNode.h
+
+ nodes/COM_DisplaceNode.cpp
+ nodes/COM_DisplaceNode.h
+ nodes/COM_MapUVNode.cpp
+ nodes/COM_MapUVNode.h
+
+ nodes/COM_ChannelMatteNode.cpp
+ nodes/COM_ChannelMatteNode.h
+ nodes/COM_ChromaMatteNode.cpp
+ nodes/COM_ChromaMatteNode.h
+ nodes/COM_ColorMatteNode.cpp
+ nodes/COM_ColorMatteNode.h
+ nodes/COM_DifferenceMatteNode.cpp
+ nodes/COM_DifferenceMatteNode.h
+ nodes/COM_DistanceMatteNode.cpp
+ nodes/COM_DistanceMatteNode.h
+ nodes/COM_LensDistortionNode.cpp
+ nodes/COM_LensDistortionNode.h
+ nodes/COM_LuminanceMatteNode.cpp
+ nodes/COM_LuminanceMatteNode.h
+
+ nodes/COM_GlareNode.cpp
+ nodes/COM_GlareNode.h
+
+ nodes/COM_SunBeamsNode.cpp
+ nodes/COM_SunBeamsNode.h
+ operations/COM_SunBeamsOperation.cpp
+ operations/COM_SunBeamsOperation.h
+
+ nodes/COM_CryptomatteNode.cpp
+ nodes/COM_CryptomatteNode.h
+ operations/COM_CryptomatteOperation.cpp
+ operations/COM_CryptomatteOperation.h
+
+ nodes/COM_CornerPinNode.cpp
+ nodes/COM_CornerPinNode.h
+ nodes/COM_PlaneTrackDeformNode.cpp
+ nodes/COM_PlaneTrackDeformNode.h
+
+ nodes/COM_CropNode.cpp
+ nodes/COM_CropNode.h
+ operations/COM_CropOperation.cpp
+ operations/COM_CropOperation.h
+
+ nodes/COM_DefocusNode.cpp
+ nodes/COM_DefocusNode.h
+ nodes/COM_MovieDistortionNode.cpp
+ nodes/COM_MovieDistortionNode.h
+ nodes/COM_Stabilize2dNode.cpp
+ nodes/COM_Stabilize2dNode.h
+ nodes/COM_TransformNode.cpp
+ nodes/COM_TransformNode.h
+
+ # color nodes
+ nodes/COM_AlphaOverNode.cpp
+ nodes/COM_AlphaOverNode.h
+ nodes/COM_BrightnessNode.cpp
+ nodes/COM_BrightnessNode.h
+ nodes/COM_ColorBalanceNode.cpp
+ nodes/COM_ColorBalanceNode.h
+ nodes/COM_ColorCorrectionNode.cpp
+ nodes/COM_ColorCorrectionNode.h
+ nodes/COM_ColorCurveNode.cpp
+ nodes/COM_ColorCurveNode.h
+ nodes/COM_ColorRampNode.cpp
+ nodes/COM_ColorRampNode.h
+ nodes/COM_ColorToBWNode.cpp
+ nodes/COM_ColorToBWNode.h
+ nodes/COM_ConvertAlphaNode.cpp
+ nodes/COM_ConvertAlphaNode.h
+ nodes/COM_GammaNode.cpp
+ nodes/COM_GammaNode.h
+ nodes/COM_HueSaturationValueCorrectNode.cpp
+ nodes/COM_HueSaturationValueCorrectNode.h
+ nodes/COM_HueSaturationValueNode.cpp
+ nodes/COM_HueSaturationValueNode.h
+ nodes/COM_InvertNode.cpp
+ nodes/COM_InvertNode.h
+ nodes/COM_MixNode.cpp
+ nodes/COM_MixNode.h
+ nodes/COM_SetAlphaNode.cpp
+ nodes/COM_SetAlphaNode.h
+ nodes/COM_TonemapNode.cpp
+ nodes/COM_TonemapNode.h
+ nodes/COM_VectorCurveNode.cpp
+ nodes/COM_VectorCurveNode.h
+ nodes/COM_ZCombineNode.cpp
+ nodes/COM_ZCombineNode.h
+ operations/COM_TonemapOperation.cpp
+ operations/COM_TonemapOperation.h
+
+ # converter nodes
+ nodes/COM_CombineColorNode.cpp
+ nodes/COM_CombineColorNode.h
+ nodes/COM_IDMaskNode.cpp
+ nodes/COM_IDMaskNode.h
+ nodes/COM_SeparateColorNode.cpp
+ nodes/COM_SeparateColorNode.h
+
+ nodes/COM_MapRangeNode.cpp
+ nodes/COM_MapRangeNode.h
+ nodes/COM_MapValueNode.cpp
+ nodes/COM_MapValueNode.h
+ nodes/COM_MathNode.cpp
+ nodes/COM_MathNode.h
+ nodes/COM_NormalNode.cpp
+ nodes/COM_NormalNode.h
+ nodes/COM_NormalizeNode.cpp
+ nodes/COM_NormalizeNode.h
+
+ operations/COM_NormalizeOperation.cpp
+ operations/COM_NormalizeOperation.h
+
+ nodes/COM_PixelateNode.cpp
+ nodes/COM_PixelateNode.h
+ operations/COM_PixelateOperation.cpp
+ operations/COM_PixelateOperation.h
+
+ # Filter nodes
+ nodes/COM_BilateralBlurNode.cpp
+ nodes/COM_BilateralBlurNode.h
+ operations/COM_BilateralBlurOperation.cpp
+ operations/COM_BilateralBlurOperation.h
+ nodes/COM_VectorBlurNode.cpp
+ nodes/COM_VectorBlurNode.h
+ operations/COM_VectorBlurOperation.cpp
+ operations/COM_VectorBlurOperation.h
+
+ nodes/COM_BlurNode.cpp
+ nodes/COM_BlurNode.h
+ nodes/COM_BokehBlurNode.cpp
+ nodes/COM_BokehBlurNode.h
+ nodes/COM_DespeckleNode.cpp
+ nodes/COM_DespeckleNode.h
+ nodes/COM_DilateErodeNode.cpp
+ nodes/COM_DilateErodeNode.h
+ nodes/COM_DirectionalBlurNode.cpp
+ nodes/COM_DirectionalBlurNode.h
+ nodes/COM_FilterNode.cpp
+ nodes/COM_FilterNode.h
+ nodes/COM_InpaintNode.cpp
+ nodes/COM_InpaintNode.h
+ operations/COM_BlurBaseOperation.cpp
+ operations/COM_BlurBaseOperation.h
+ operations/COM_BokehBlurOperation.cpp
+ operations/COM_BokehBlurOperation.h
+ operations/COM_DirectionalBlurOperation.cpp
+ operations/COM_DirectionalBlurOperation.h
+ operations/COM_FastGaussianBlurOperation.cpp
+ operations/COM_FastGaussianBlurOperation.h
+ operations/COM_GammaCorrectOperation.cpp
+ operations/COM_GammaCorrectOperation.h
+ operations/COM_GaussianAlphaXBlurOperation.cpp
+ operations/COM_GaussianAlphaXBlurOperation.h
+ operations/COM_GaussianAlphaYBlurOperation.cpp
+ operations/COM_GaussianAlphaYBlurOperation.h
+ operations/COM_GaussianBokehBlurOperation.cpp
+ operations/COM_GaussianBokehBlurOperation.h
+ operations/COM_GaussianXBlurOperation.cpp
+ operations/COM_GaussianXBlurOperation.h
+ operations/COM_GaussianYBlurOperation.cpp
+ operations/COM_GaussianYBlurOperation.h
+ operations/COM_MovieClipAttributeOperation.cpp
+ operations/COM_MovieClipAttributeOperation.h
+ operations/COM_MovieDistortionOperation.cpp
+ operations/COM_MovieDistortionOperation.h
+ operations/COM_VariableSizeBokehBlurOperation.cpp
+ operations/COM_VariableSizeBokehBlurOperation.h
+
+ # Matte nodes
+ nodes/COM_BoxMaskNode.cpp
+ nodes/COM_BoxMaskNode.h
+ nodes/COM_ColorSpillNode.cpp
+ nodes/COM_ColorSpillNode.h
+ nodes/COM_DoubleEdgeMaskNode.cpp
+ nodes/COM_DoubleEdgeMaskNode.h
+ nodes/COM_EllipseMaskNode.cpp
+ nodes/COM_EllipseMaskNode.h
+
+ operations/COM_DoubleEdgeMaskOperation.cpp
+ operations/COM_DoubleEdgeMaskOperation.h
+
+
+ nodes/COM_KeyingScreenNode.cpp
+ nodes/COM_KeyingScreenNode.h
+ operations/COM_KeyingScreenOperation.cpp
+ operations/COM_KeyingScreenOperation.h
+
+ nodes/COM_TrackPositionNode.cpp
+ nodes/COM_TrackPositionNode.h
+ operations/COM_TrackPositionOperation.cpp
+ operations/COM_TrackPositionOperation.h
+
+ nodes/COM_KeyingNode.cpp
+ nodes/COM_KeyingNode.h
+ operations/COM_KeyingBlurOperation.cpp
+ operations/COM_KeyingBlurOperation.h
+ operations/COM_KeyingClipOperation.cpp
+ operations/COM_KeyingClipOperation.h
+ operations/COM_KeyingDespillOperation.cpp
+ operations/COM_KeyingDespillOperation.h
+ operations/COM_KeyingOperation.cpp
+ operations/COM_KeyingOperation.h
+
+ operations/COM_ColorSpillOperation.cpp
+ operations/COM_ColorSpillOperation.h
+ operations/COM_RenderLayersProg.cpp
+ operations/COM_RenderLayersProg.h
+
+ operations/COM_BokehImageOperation.cpp
+ operations/COM_BokehImageOperation.h
+ operations/COM_ImageOperation.cpp
+ operations/COM_ImageOperation.h
+ operations/COM_MultilayerImageOperation.cpp
+ operations/COM_MultilayerImageOperation.h
+ operations/COM_TextureOperation.cpp
+ operations/COM_TextureOperation.h
+
+
+ operations/COM_SocketProxyOperation.cpp
+ operations/COM_SocketProxyOperation.h
+
+ operations/COM_CompositorOperation.cpp
+ operations/COM_CompositorOperation.h
+ operations/COM_ConvertDepthToRadiusOperation.cpp
+ operations/COM_ConvertDepthToRadiusOperation.h
+ operations/COM_OutputFileMultiViewOperation.cpp
+ operations/COM_OutputFileMultiViewOperation.h
+ operations/COM_OutputFileOperation.cpp
+ operations/COM_OutputFileOperation.h
+ operations/COM_PreviewOperation.cpp
+ operations/COM_PreviewOperation.h
+ operations/COM_SplitOperation.cpp
+ operations/COM_SplitOperation.h
+ operations/COM_ViewerOperation.cpp
+ operations/COM_ViewerOperation.h
+ operations/COM_ZCombineOperation.cpp
+ operations/COM_ZCombineOperation.h
+
+ operations/COM_ChangeHSVOperation.cpp
+ operations/COM_ChangeHSVOperation.h
+ operations/COM_ChannelMatteOperation.cpp
+ operations/COM_ChannelMatteOperation.h
+ operations/COM_ChromaMatteOperation.cpp
+ operations/COM_ChromaMatteOperation.h
+ operations/COM_ColorCurveOperation.cpp
+ operations/COM_ColorCurveOperation.h
+ operations/COM_ColorMatteOperation.cpp
+ operations/COM_ColorMatteOperation.h
+ operations/COM_ColorRampOperation.cpp
+ operations/COM_ColorRampOperation.h
+ operations/COM_CurveBaseOperation.cpp
+ operations/COM_CurveBaseOperation.h
+ operations/COM_DifferenceMatteOperation.cpp
+ operations/COM_DifferenceMatteOperation.h
+ operations/COM_DistanceRGBMatteOperation.cpp
+ operations/COM_DistanceRGBMatteOperation.h
+ operations/COM_DistanceYCCMatteOperation.cpp
+ operations/COM_DistanceYCCMatteOperation.h
+ operations/COM_HueSaturationValueCorrectOperation.cpp
+ operations/COM_HueSaturationValueCorrectOperation.h
+ operations/COM_LuminanceMatteOperation.cpp
+ operations/COM_LuminanceMatteOperation.h
+ operations/COM_VectorCurveOperation.cpp
+ operations/COM_VectorCurveOperation.h
+
+ operations/COM_BrightnessOperation.cpp
+ operations/COM_BrightnessOperation.h
+ operations/COM_ColorCorrectionOperation.cpp
+ operations/COM_ColorCorrectionOperation.h
+ operations/COM_GammaOperation.cpp
+ operations/COM_GammaOperation.h
+ operations/COM_MixOperation.cpp
+ operations/COM_MixOperation.h
+ operations/COM_ReadBufferOperation.cpp
+ operations/COM_ReadBufferOperation.h
+ operations/COM_SetColorOperation.cpp
+ operations/COM_SetColorOperation.h
+ operations/COM_SetValueOperation.cpp
+ operations/COM_SetValueOperation.h
+ operations/COM_SetVectorOperation.cpp
+ operations/COM_SetVectorOperation.h
+ operations/COM_WriteBufferOperation.cpp
+ operations/COM_WriteBufferOperation.h
+
+ operations/COM_MathBaseOperation.cpp
+ operations/COM_MathBaseOperation.h
+
+ operations/COM_AlphaOverKeyOperation.cpp
+ operations/COM_AlphaOverKeyOperation.h
+ operations/COM_AlphaOverMixedOperation.cpp
+ operations/COM_AlphaOverMixedOperation.h
+ operations/COM_AlphaOverPremultiplyOperation.cpp
+ operations/COM_AlphaOverPremultiplyOperation.h
+
+ operations/COM_ColorBalanceASCCDLOperation.cpp
+ operations/COM_ColorBalanceASCCDLOperation.h
+ operations/COM_ColorBalanceLGGOperation.cpp
+ operations/COM_ColorBalanceLGGOperation.h
+ operations/COM_InvertOperation.cpp
+ operations/COM_InvertOperation.h
+ operations/COM_MapRangeOperation.cpp
+ operations/COM_MapRangeOperation.h
+ operations/COM_MapValueOperation.cpp
+ operations/COM_MapValueOperation.h
+ operations/COM_SetAlphaOperation.cpp
+ operations/COM_SetAlphaOperation.h
+
+ # Distort operation
+ operations/COM_DisplaceOperation.cpp
+ operations/COM_DisplaceOperation.h
+ operations/COM_DisplaceSimpleOperation.cpp
+ operations/COM_DisplaceSimpleOperation.h
+ operations/COM_FlipOperation.cpp
+ operations/COM_FlipOperation.h
+ operations/COM_MapUVOperation.cpp
+ operations/COM_MapUVOperation.h
+ operations/COM_PlaneCornerPinOperation.cpp
+ operations/COM_PlaneCornerPinOperation.h
+ operations/COM_PlaneDistortCommonOperation.cpp
+ operations/COM_PlaneDistortCommonOperation.h
+ operations/COM_PlaneTrackOperation.cpp
+ operations/COM_PlaneTrackOperation.h
+ operations/COM_ProjectorLensDistortionOperation.cpp
+ operations/COM_ProjectorLensDistortionOperation.h
+ operations/COM_RotateOperation.cpp
+ operations/COM_RotateOperation.h
+ operations/COM_ScaleOperation.cpp
+ operations/COM_ScaleOperation.h
+ operations/COM_ScreenLensDistortionOperation.cpp
+ operations/COM_ScreenLensDistortionOperation.h
+ operations/COM_TranslateOperation.cpp
+ operations/COM_TranslateOperation.h
+ operations/COM_WrapOperation.cpp
+ operations/COM_WrapOperation.h
+
+ #Filter operations
+ operations/COM_ConvolutionEdgeFilterOperation.cpp
+ operations/COM_ConvolutionEdgeFilterOperation.h
+ operations/COM_ConvolutionFilterOperation.cpp
+ operations/COM_ConvolutionFilterOperation.h
+ operations/COM_DespeckleOperation.cpp
+ operations/COM_DespeckleOperation.h
+ operations/COM_DilateErodeOperation.cpp
+ operations/COM_DilateErodeOperation.h
+ operations/COM_GlareBaseOperation.cpp
+ operations/COM_GlareBaseOperation.h
+ operations/COM_GlareFogGlowOperation.cpp
+ operations/COM_GlareFogGlowOperation.h
+ operations/COM_GlareGhostOperation.cpp
+ operations/COM_GlareGhostOperation.h
+ operations/COM_GlareSimpleStarOperation.cpp
+ operations/COM_GlareSimpleStarOperation.h
+ operations/COM_GlareStreaksOperation.cpp
+ operations/COM_GlareStreaksOperation.h
+ operations/COM_GlareThresholdOperation.cpp
+ operations/COM_GlareThresholdOperation.h
+ operations/COM_InpaintOperation.cpp
+ operations/COM_InpaintOperation.h
+ operations/COM_SetSamplerOperation.cpp
+ operations/COM_SetSamplerOperation.h
+
+
+ #Convert operations
+ operations/COM_ConvertOperation.cpp
+ operations/COM_ConvertOperation.h
+ operations/COM_IDMaskOperation.cpp
+ operations/COM_IDMaskOperation.h
+
+ operations/COM_DotproductOperation.cpp
+ operations/COM_DotproductOperation.h
+
+ # Matte operation
+ operations/COM_BoxMaskOperation.cpp
+ operations/COM_BoxMaskOperation.h
+ operations/COM_EllipseMaskOperation.cpp
+ operations/COM_EllipseMaskOperation.h
+
+ operations/COM_ConvertColorProfileOperation.cpp
+ operations/COM_ConvertColorProfileOperation.h
+ operations/COM_MovieClipOperation.cpp
+ operations/COM_MovieClipOperation.h
+
+ operations/COM_AntiAliasOperation.cpp
+ operations/COM_AntiAliasOperation.h
+
+ operations/COM_MaskOperation.cpp
+ operations/COM_MaskOperation.h
)
set(LIB
- bf_blenkernel
- bf_blenlib
- extern_clew
+ bf_blenkernel
+ bf_blenlib
+ extern_clew
)
list(APPEND INC
- ${CMAKE_CURRENT_BINARY_DIR}/operations
+ ${CMAKE_CURRENT_BINARY_DIR}/operations
)
data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/operations/COM_OpenCLKernels.cl
@@ -555,7 +555,7 @@ data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/operations/COM_OpenCLKernels.cl
add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
if(WITH_INTERNATIONAL)
- add_definitions(-DWITH_INTERNATIONAL)
+ add_definitions(-DWITH_INTERNATIONAL)
endif()
blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h
index d81560f6ede..9046a5e5dc3 100644
--- a/source/blender/compositor/COM_compositor.h
+++ b/source/blender/compositor/COM_compositor.h
@@ -309,8 +309,12 @@ extern "C" {
* should be checked further, probably it'll be also needed for preview
* generation in display space
*/
-void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
+void COM_execute(RenderData *rd,
+ Scene *scene,
+ bNodeTree *editingtree,
+ int rendering,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
const char *viewName);
/**
@@ -329,4 +333,4 @@ void COM_deinitialize(void);
}
#endif
-#endif /* __COM_COMPOSITOR_H__ */
+#endif /* __COM_COMPOSITOR_H__ */
diff --git a/source/blender/compositor/COM_defines.h b/source/blender/compositor/COM_defines.h
index 926b63de682..de731b8e0da 100644
--- a/source/blender/compositor/COM_defines.h
+++ b/source/blender/compositor/COM_defines.h
@@ -24,12 +24,12 @@
* \ingroup Model
*/
typedef enum DataType {
- /** \brief Value data type */
- COM_DT_VALUE = 1,
- /** \brief Vector data type */
- COM_DT_VECTOR = 2,
- /** \brief Color data type */
- COM_DT_COLOR = 4,
+ /** \brief Value data type */
+ COM_DT_VALUE = 1,
+ /** \brief Vector data type */
+ COM_DT_VECTOR = 2,
+ /** \brief Color data type */
+ COM_DT_COLOR = 4,
} DataType;
/**
@@ -38,12 +38,12 @@ typedef enum DataType {
* \ingroup Execution
*/
typedef enum CompositorQuality {
- /** \brief High quality setting */
- COM_QUALITY_HIGH = 0,
- /** \brief Medium quality setting */
- COM_QUALITY_MEDIUM = 1,
- /** \brief Low quality setting */
- COM_QUALITY_LOW = 2,
+ /** \brief High quality setting */
+ COM_QUALITY_HIGH = 0,
+ /** \brief Medium quality setting */
+ COM_QUALITY_MEDIUM = 1,
+ /** \brief Low quality setting */
+ COM_QUALITY_LOW = 2,
} CompositorQuality;
/**
@@ -51,12 +51,12 @@ typedef enum CompositorQuality {
* \ingroup Execution
*/
typedef enum CompositorPriority {
- /** \brief High quality setting */
- COM_PRIORITY_HIGH = 2,
- /** \brief Medium quality setting */
- COM_PRIORITY_MEDIUM = 1,
- /** \brief Low quality setting */
- COM_PRIORITY_LOW = 0,
+ /** \brief High quality setting */
+ COM_PRIORITY_HIGH = 2,
+ /** \brief Medium quality setting */
+ COM_PRIORITY_MEDIUM = 1,
+ /** \brief Low quality setting */
+ COM_PRIORITY_LOW = 0,
} CompositorPriority;
// configurable items
@@ -87,14 +87,14 @@ typedef enum CompositorPriority {
* \ingroup Execution
*/
typedef enum OrderOfChunks {
- /** \brief order from a distance to centerX/centerY */
- COM_TO_CENTER_OUT = 0,
- /** \brief order randomly */
- COM_TO_RANDOM = 1,
- /** \brief no ordering */
- COM_TO_TOP_DOWN = 2,
- /** \brief experimental ordering with 9 hotspots */
- COM_TO_RULE_OF_THIRDS = 3,
+ /** \brief order from a distance to centerX/centerY */
+ COM_TO_CENTER_OUT = 0,
+ /** \brief order randomly */
+ COM_TO_RANDOM = 1,
+ /** \brief no ordering */
+ COM_TO_TOP_DOWN = 2,
+ /** \brief experimental ordering with 9 hotspots */
+ COM_TO_RULE_OF_THIRDS = 3,
} OrderOfChunks;
#define COM_ORDER_OF_CHUNKS_DEFAULT COM_TO_CENTER_OUT
@@ -107,4 +107,4 @@ typedef enum OrderOfChunks {
#define COM_BLUR_BOKEH_PIXELS 512
-#endif /* __COM_DEFINES_H__ */
+#endif /* __COM_DEFINES_H__ */
diff --git a/source/blender/compositor/intern/COM_CPUDevice.cpp b/source/blender/compositor/intern/COM_CPUDevice.cpp
index 102a882876b..bcb14e4dbb2 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.cpp
+++ b/source/blender/compositor/intern/COM_CPUDevice.cpp
@@ -18,21 +18,19 @@
#include "COM_CPUDevice.h"
-CPUDevice::CPUDevice(int thread_id)
- : Device(),
- m_thread_id(thread_id)
+CPUDevice::CPUDevice(int thread_id) : Device(), m_thread_id(thread_id)
{
}
void CPUDevice::execute(WorkPackage *work)
{
- const unsigned int chunkNumber = work->getChunkNumber();
- ExecutionGroup *executionGroup = work->getExecutionGroup();
- rcti rect;
+ const unsigned int chunkNumber = work->getChunkNumber();
+ ExecutionGroup *executionGroup = work->getExecutionGroup();
+ rcti rect;
- executionGroup->determineChunkRect(&rect, chunkNumber);
+ executionGroup->determineChunkRect(&rect, chunkNumber);
- executionGroup->getOutputOperation()->executeRegion(&rect, chunkNumber);
+ executionGroup->getOutputOperation()->executeRegion(&rect, chunkNumber);
- executionGroup->finalizeChunkExecution(chunkNumber, NULL);
+ executionGroup->finalizeChunkExecution(chunkNumber, NULL);
}
diff --git a/source/blender/compositor/intern/COM_CPUDevice.h b/source/blender/compositor/intern/COM_CPUDevice.h
index 36016a44252..d82046a729f 100644
--- a/source/blender/compositor/intern/COM_CPUDevice.h
+++ b/source/blender/compositor/intern/COM_CPUDevice.h
@@ -26,19 +26,22 @@
* \note for every hardware thread in the system a CPUDevice instance will exist in the workscheduler
*/
class CPUDevice : public Device {
-public:
- CPUDevice(int thread_id);
+ public:
+ CPUDevice(int thread_id);
- /**
- * \brief execute a WorkPackage
- * \param work: the WorkPackage to execute
- */
- void execute(WorkPackage *work);
+ /**
+ * \brief execute a WorkPackage
+ * \param work: the WorkPackage to execute
+ */
+ void execute(WorkPackage *work);
- int thread_id() { return m_thread_id; }
+ int thread_id()
+ {
+ return m_thread_id;
+ }
-protected:
- int m_thread_id;
+ protected:
+ int m_thread_id;
};
#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.cpp b/source/blender/compositor/intern/COM_ChunkOrder.cpp
index f26a8af1f5c..7c9e5013c5d 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrder.cpp
@@ -21,27 +21,27 @@
ChunkOrder::ChunkOrder()
{
- this->m_distance = 0.0;
- this->m_number = 0;
- this->m_x = 0;
- this->m_y = 0;
+ this->m_distance = 0.0;
+ this->m_number = 0;
+ this->m_x = 0;
+ this->m_y = 0;
}
void ChunkOrder::determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots)
{
- unsigned int index;
- double distance = FLT_MAX;
- for (index = 0; index < numberOfHotspots; index++) {
- ChunkOrderHotspot *hotspot = hotspots[index];
- double ndistance = hotspot->determineDistance(this->m_x, this->m_y);
- if (ndistance < distance) {
- distance = ndistance;
- }
- }
- this->m_distance = distance;
+ unsigned int index;
+ double distance = FLT_MAX;
+ for (index = 0; index < numberOfHotspots; index++) {
+ ChunkOrderHotspot *hotspot = hotspots[index];
+ double ndistance = hotspot->determineDistance(this->m_x, this->m_y);
+ if (ndistance < distance) {
+ distance = ndistance;
+ }
+ }
+ this->m_distance = distance;
}
bool operator<(const ChunkOrder &a, const ChunkOrder &b)
{
- return a.m_distance < b.m_distance;
+ return a.m_distance < b.m_distance;
}
diff --git a/source/blender/compositor/intern/COM_ChunkOrder.h b/source/blender/compositor/intern/COM_ChunkOrder.h
index 52c0e0a800a..e75c07136b4 100644
--- a/source/blender/compositor/intern/COM_ChunkOrder.h
+++ b/source/blender/compositor/intern/COM_ChunkOrder.h
@@ -21,21 +21,37 @@
#include "COM_ChunkOrderHotspot.h"
class ChunkOrder {
-private:
- unsigned int m_number;
- int m_x;
- int m_y;
- double m_distance;
-public:
- ChunkOrder();
- void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
- friend bool operator<(const ChunkOrder &a, const ChunkOrder &b);
+ private:
+ unsigned int m_number;
+ int m_x;
+ int m_y;
+ double m_distance;
- void setChunkNumber(unsigned int chunknumber) { this->m_number = chunknumber; }
- void setX(int x) { this->m_x = x; }
- void setY(int y) { this->m_y = y; }
- unsigned int getChunkNumber() { return this->m_number; }
- double getDistance() { return this->m_distance; }
+ public:
+ ChunkOrder();
+ void determineDistance(ChunkOrderHotspot **hotspots, unsigned int numberOfHotspots);
+ friend bool operator<(const ChunkOrder &a, const ChunkOrder &b);
+
+ void setChunkNumber(unsigned int chunknumber)
+ {
+ this->m_number = chunknumber;
+ }
+ void setX(int x)
+ {
+ this->m_x = x;
+ }
+ void setY(int y)
+ {
+ this->m_y = y;
+ }
+ unsigned int getChunkNumber()
+ {
+ return this->m_number;
+ }
+ double getDistance()
+ {
+ return this->m_distance;
+ }
};
#endif
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
index cf299e8370b..e95dd4233c4 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.cpp
@@ -21,16 +21,16 @@
ChunkOrderHotspot::ChunkOrderHotspot(int x, int y, float addition)
{
- this->m_x = x;
- this->m_y = y;
- this->m_addition = addition;
+ this->m_x = x;
+ this->m_y = y;
+ this->m_addition = addition;
}
double ChunkOrderHotspot::determineDistance(int x, int y)
{
- int dx = x - this->m_x;
- int dy = y - this->m_y;
- double result = sqrt((double)(dx * dx + dy * dy));
- result += (double)this->m_addition;
- return result;
+ int dx = x - this->m_x;
+ int dy = y - this->m_y;
+ double result = sqrt((double)(dx * dx + dy * dy));
+ result += (double)this->m_addition;
+ return result;
}
diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
index 2b6b646310b..f0bc92ad6d6 100644
--- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
+++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h
@@ -20,22 +20,21 @@
#define __COM_CHUNKORDERHOTSPOT_H__
#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
+# include "MEM_guardedalloc.h"
#endif
class ChunkOrderHotspot {
-private:
- int m_x;
- int m_y;
- float m_addition;
-
-public:
- ChunkOrderHotspot(int x, int y, float addition);
- double determineDistance(int x, int y);
+ private:
+ int m_x;
+ int m_y;
+ float m_addition;
+ public:
+ ChunkOrderHotspot(int x, int y, float addition);
+ double determineDistance(int x, int y);
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")
#endif
};
diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp
index 0715436bf51..e572fe7c99e 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.cpp
+++ b/source/blender/compositor/intern/COM_CompositorContext.cpp
@@ -22,21 +22,21 @@
CompositorContext::CompositorContext()
{
- this->m_scene = NULL;
- this->m_rd = NULL;
- this->m_quality = COM_QUALITY_HIGH;
- this->m_hasActiveOpenCLDevices = false;
- this->m_fastCalculation = false;
- this->m_viewSettings = NULL;
- this->m_displaySettings = NULL;
+ this->m_scene = NULL;
+ this->m_rd = NULL;
+ this->m_quality = COM_QUALITY_HIGH;
+ this->m_hasActiveOpenCLDevices = false;
+ this->m_fastCalculation = false;
+ this->m_viewSettings = NULL;
+ this->m_displaySettings = NULL;
}
int CompositorContext::getFramenumber() const
{
- if (this->m_rd) {
- return this->m_rd->cfra;
- }
- else {
- return -1; /* this should never happen */
- }
+ if (this->m_rd) {
+ return this->m_rd->cfra;
+ }
+ else {
+ return -1; /* this should never happen */
+ }
}
diff --git a/source/blender/compositor/intern/COM_CompositorContext.h b/source/blender/compositor/intern/COM_CompositorContext.h
index e36dd5ac2aa..466779ec9bd 100644
--- a/source/blender/compositor/intern/COM_CompositorContext.h
+++ b/source/blender/compositor/intern/COM_CompositorContext.h
@@ -31,172 +31,243 @@
* \brief Overall context of the compositor
*/
class CompositorContext {
-private:
- /**
- * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * \see ExecutionSystem
- */
- bool m_rendering;
-
- /**
- * \brief The quality of the composite.
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * \see ExecutionSystem
- */
- CompositorQuality m_quality;
-
- Scene *m_scene;
-
- /**
- * \brief Reference to the render data that is being composited.
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * \see ExecutionSystem
- */
- RenderData *m_rd;
-
- /**
- * \brief reference to the bNodeTree
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- * \see ExecutionSystem
- */
- bNodeTree *m_bnodetree;
-
- /**
- * \brief Preview image hash table
- * This field is initialized in ExecutionSystem and must only be read from that point on.
- */
- bNodeInstanceHash *m_previews;
-
- /**
- * \brief does this system have active opencl devices?
- */
- bool m_hasActiveOpenCLDevices;
-
- /**
- * \brief Skip slow nodes
- */
- bool m_fastCalculation;
-
- /* \brief color management settings */
- const ColorManagedViewSettings *m_viewSettings;
- const ColorManagedDisplaySettings *m_displaySettings;
-
- /**
- * \brief active rendering view name
- */
- const char *m_viewName;
-
-public:
- /**
- * \brief constructor initializes the context with default values.
- */
- CompositorContext();
-
- /**
- * \brief set the rendering field of the context
- */
- void setRendering(bool rendering) { this->m_rendering = rendering; }
-
- /**
- * \brief get the rendering field of the context
- */
- bool isRendering() const { return this->m_rendering; }
-
- /**
- * \brief set the scene of the context
- */
- void setRenderData(RenderData *rd) { this->m_rd = rd; }
-
- /**
- * \brief set the bnodetree of the context
- */
- void setbNodeTree(bNodeTree *bnodetree) { this->m_bnodetree = bnodetree; }
-
- /**
- * \brief get the bnodetree of the context
- */
- const bNodeTree *getbNodeTree() const { return this->m_bnodetree; }
-
- /**
- * \brief get the scene of the context
- */
- const RenderData *getRenderData() const { return this->m_rd; }
-
- void setScene(Scene *scene) { m_scene = scene; }
- Scene *getScene() const { return m_scene; }
-
- /**
- * \brief set the preview image hash table
- */
- void setPreviewHash(bNodeInstanceHash *previews) { this->m_previews = previews; }
-
- /**
- * \brief get the preview image hash table
- */
- bNodeInstanceHash *getPreviewHash() const { return this->m_previews; }
-
- /**
- * \brief set view settings of color color management
- */
- void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
-
- /**
- * \brief get view settings of color color management
- */
- const ColorManagedViewSettings *getViewSettings() const { return this->m_viewSettings; }
-
- /**
- * \brief set display settings of color color management
- */
- void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
-
- /**
- * \brief get display settings of color color management
- */
- const ColorManagedDisplaySettings *getDisplaySettings() const { return this->m_displaySettings; }
-
- /**
- * \brief set the quality
- */
- void setQuality(CompositorQuality quality) { this->m_quality = quality; }
-
- /**
- * \brief get the quality
- */
- CompositorQuality getQuality() const { return this->m_quality; }
-
- /**
- * \brief get the current framenumber of the scene in this context
- */
- int getFramenumber() const;
-
- /**
- * \brief has this system active openclDevices?
- */
- bool getHasActiveOpenCLDevices() const { return this->m_hasActiveOpenCLDevices; }
-
- /**
- * \brief set has this system active openclDevices?
- */
- void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices) { this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices; }
-
- /**
- * \brief get the active rendering view
- */
- const char *getViewName() const { return this->m_viewName; }
-
- /**
- * \brief set the active rendering view
- */
- void setViewName(const char *viewName) { this->m_viewName = viewName; }
-
- int getChunksize() const { return this->getbNodeTree()->chunksize; }
-
- void setFastCalculation(bool fastCalculation) {this->m_fastCalculation = fastCalculation;}
- bool isFastCalculation() const { return this->m_fastCalculation; }
- bool isGroupnodeBufferEnabled() const { return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0; }
+ private:
+ /**
+ * \brief The rendering field describes if we are rendering (F12) or if we are editing (Node editor)
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \see ExecutionSystem
+ */
+ bool m_rendering;
+
+ /**
+ * \brief The quality of the composite.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \see ExecutionSystem
+ */
+ CompositorQuality m_quality;
+
+ Scene *m_scene;
+
+ /**
+ * \brief Reference to the render data that is being composited.
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \see ExecutionSystem
+ */
+ RenderData *m_rd;
+
+ /**
+ * \brief reference to the bNodeTree
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ * \see ExecutionSystem
+ */
+ bNodeTree *m_bnodetree;
+
+ /**
+ * \brief Preview image hash table
+ * This field is initialized in ExecutionSystem and must only be read from that point on.
+ */
+ bNodeInstanceHash *m_previews;
+
+ /**
+ * \brief does this system have active opencl devices?
+ */
+ bool m_hasActiveOpenCLDevices;
+
+ /**
+ * \brief Skip slow nodes
+ */
+ bool m_fastCalculation;
+
+ /* \brief color management settings */
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
+
+ /**
+ * \brief active rendering view name
+ */
+ const char *m_viewName;
+
+ public:
+ /**
+ * \brief constructor initializes the context with default values.
+ */
+ CompositorContext();
+
+ /**
+ * \brief set the rendering field of the context
+ */
+ void setRendering(bool rendering)
+ {
+ this->m_rendering = rendering;
+ }
+
+ /**
+ * \brief get the rendering field of the context
+ */
+ bool isRendering() const
+ {
+ return this->m_rendering;
+ }
+
+ /**
+ * \brief set the scene of the context
+ */
+ void setRenderData(RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+
+ /**
+ * \brief set the bnodetree of the context
+ */
+ void setbNodeTree(bNodeTree *bnodetree)
+ {
+ this->m_bnodetree = bnodetree;
+ }
+
+ /**
+ * \brief get the bnodetree of the context
+ */
+ const bNodeTree *getbNodeTree() const
+ {
+ return this->m_bnodetree;
+ }
+
+ /**
+ * \brief get the scene of the context
+ */
+ const RenderData *getRenderData() const
+ {
+ return this->m_rd;
+ }
+
+ void setScene(Scene *scene)
+ {
+ m_scene = scene;
+ }
+ Scene *getScene() const
+ {
+ return m_scene;
+ }
+
+ /**
+ * \brief set the preview image hash table
+ */
+ void setPreviewHash(bNodeInstanceHash *previews)
+ {
+ this->m_previews = previews;
+ }
+
+ /**
+ * \brief get the preview image hash table
+ */
+ bNodeInstanceHash *getPreviewHash() const
+ {
+ return this->m_previews;
+ }
+
+ /**
+ * \brief set view settings of color color management
+ */
+ void setViewSettings(const ColorManagedViewSettings *viewSettings)
+ {
+ this->m_viewSettings = viewSettings;
+ }
+
+ /**
+ * \brief get view settings of color color management
+ */
+ const ColorManagedViewSettings *getViewSettings() const
+ {
+ return this->m_viewSettings;
+ }
+
+ /**
+ * \brief set display settings of color color management
+ */
+ void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
+ {
+ this->m_displaySettings = displaySettings;
+ }
+
+ /**
+ * \brief get display settings of color color management
+ */
+ const ColorManagedDisplaySettings *getDisplaySettings() const
+ {
+ return this->m_displaySettings;
+ }
+
+ /**
+ * \brief set the quality
+ */
+ void setQuality(CompositorQuality quality)
+ {
+ this->m_quality = quality;
+ }
+
+ /**
+ * \brief get the quality
+ */
+ CompositorQuality getQuality() const
+ {
+ return this->m_quality;
+ }
+
+ /**
+ * \brief get the current framenumber of the scene in this context
+ */
+ int getFramenumber() const;
+
+ /**
+ * \brief has this system active openclDevices?
+ */
+ bool getHasActiveOpenCLDevices() const
+ {
+ return this->m_hasActiveOpenCLDevices;
+ }
+
+ /**
+ * \brief set has this system active openclDevices?
+ */
+ void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices)
+ {
+ this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
+ }
+
+ /**
+ * \brief get the active rendering view
+ */
+ const char *getViewName() const
+ {
+ return this->m_viewName;
+ }
+
+ /**
+ * \brief set the active rendering view
+ */
+ void setViewName(const char *viewName)
+ {
+ this->m_viewName = viewName;
+ }
+
+ int getChunksize() const
+ {
+ return this->getbNodeTree()->chunksize;
+ }
+
+ void setFastCalculation(bool fastCalculation)
+ {
+ this->m_fastCalculation = fastCalculation;
+ }
+ bool isFastCalculation() const
+ {
+ return this->m_fastCalculation;
+ }
+ bool isGroupnodeBufferEnabled() const
+ {
+ return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0;
+ }
};
-
#endif
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index c97105da385..d7fac8bb5b4 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -117,435 +117,430 @@ extern "C" {
bool Converter::is_fast_node(bNode *b_node)
{
- return !(b_node->type == CMP_NODE_BLUR ||
- b_node->type == CMP_NODE_VECBLUR ||
- b_node->type == CMP_NODE_BILATERALBLUR ||
- b_node->type == CMP_NODE_DEFOCUS ||
- b_node->type == CMP_NODE_BOKEHBLUR ||
- b_node->type == CMP_NODE_GLARE ||
- b_node->type == CMP_NODE_DBLUR ||
- b_node->type == CMP_NODE_MOVIEDISTORTION ||
- b_node->type == CMP_NODE_LENSDIST ||
- b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
- b_node->type == CMP_NODE_DILATEERODE);
+ return !(b_node->type == CMP_NODE_BLUR || b_node->type == CMP_NODE_VECBLUR ||
+ b_node->type == CMP_NODE_BILATERALBLUR || b_node->type == CMP_NODE_DEFOCUS ||
+ b_node->type == CMP_NODE_BOKEHBLUR || b_node->type == CMP_NODE_GLARE ||
+ b_node->type == CMP_NODE_DBLUR || b_node->type == CMP_NODE_MOVIEDISTORTION ||
+ b_node->type == CMP_NODE_LENSDIST || b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
+ b_node->type == CMP_NODE_DILATEERODE);
}
Node *Converter::convert(bNode *b_node)
{
- Node *node = NULL;
+ Node *node = NULL;
- /* ignore undefined nodes with missing or invalid node data */
- if (!nodeIsRegistered(b_node))
- return NULL;
+ /* ignore undefined nodes with missing or invalid node data */
+ if (!nodeIsRegistered(b_node))
+ return NULL;
- switch (b_node->type) {
- case CMP_NODE_COMPOSITE:
- node = new CompositorNode(b_node);
- break;
- case CMP_NODE_R_LAYERS:
- node = new RenderLayersNode(b_node);
- break;
- case CMP_NODE_TEXTURE:
- node = new TextureNode(b_node);
- break;
- case CMP_NODE_RGBTOBW:
- node = new ColorToBWNode(b_node);
- break;
- case CMP_NODE_MIX_RGB:
- node = new MixNode(b_node);
- break;
- case CMP_NODE_TRANSLATE:
- node = new TranslateNode(b_node);
- break;
- case CMP_NODE_SCALE:
- node = new ScaleNode(b_node);
- break;
- case CMP_NODE_ROTATE:
- node = new RotateNode(b_node);
- break;
- case CMP_NODE_FLIP:
- node = new FlipNode(b_node);
- break;
- case CMP_NODE_FILTER:
- node = new FilterNode(b_node);
- break;
- case CMP_NODE_ID_MASK:
- node = new IDMaskNode(b_node);
- break;
- case CMP_NODE_BRIGHTCONTRAST:
- node = new BrightnessNode(b_node);
- break;
- case CMP_NODE_SEPRGBA:
- node = new SeparateRGBANode(b_node);
- break;
- case CMP_NODE_COMBRGBA:
- node = new CombineRGBANode(b_node);
- break;
- case CMP_NODE_SEPHSVA:
- node = new SeparateHSVANode(b_node);
- break;
- case CMP_NODE_COMBHSVA:
- node = new CombineHSVANode(b_node);
- break;
- case CMP_NODE_SEPYUVA:
- node = new SeparateYUVANode(b_node);
- break;
- case CMP_NODE_COMBYUVA:
- node = new CombineYUVANode(b_node);
- break;
- case CMP_NODE_SEPYCCA:
- node = new SeparateYCCANode(b_node);
- break;
- case CMP_NODE_COMBYCCA:
- node = new CombineYCCANode(b_node);
- break;
- case CMP_NODE_ALPHAOVER:
- node = new AlphaOverNode(b_node);
- break;
- case CMP_NODE_COLORBALANCE:
- node = new ColorBalanceNode(b_node);
- break;
- case CMP_NODE_VIEWER:
- node = new ViewerNode(b_node);
- break;
- case CMP_NODE_SPLITVIEWER:
- node = new SplitViewerNode(b_node);
- break;
- case CMP_NODE_INVERT:
- node = new InvertNode(b_node);
- break;
- case NODE_GROUP:
- case NODE_GROUP_INPUT:
- case NODE_GROUP_OUTPUT:
- /* handled in NodeCompiler */
- break;
- case CMP_NODE_NORMAL:
- node = new NormalNode(b_node);
- break;
- case CMP_NODE_NORMALIZE:
- node = new NormalizeNode(b_node);
- break;
- case CMP_NODE_IMAGE:
- node = new ImageNode(b_node);
- break;
- case CMP_NODE_SETALPHA:
- node = new SetAlphaNode(b_node);
- break;
- case CMP_NODE_PREMULKEY:
- node = new ConvertAlphaNode(b_node);
- break;
- case CMP_NODE_MATH:
- node = new MathNode(b_node);
- break;
- case CMP_NODE_HUE_SAT:
- node = new HueSaturationValueNode(b_node);
- break;
- case CMP_NODE_COLORCORRECTION:
- node = new ColorCorrectionNode(b_node);
- break;
- case CMP_NODE_MASK_BOX:
- node = new BoxMaskNode(b_node);
- break;
- case CMP_NODE_MASK_ELLIPSE:
- node = new EllipseMaskNode(b_node);
- break;
- case CMP_NODE_GAMMA:
- node = new GammaNode(b_node);
- break;
- case CMP_NODE_CURVE_RGB:
- node = new ColorCurveNode(b_node);
- break;
- case CMP_NODE_CURVE_VEC:
- node = new VectorCurveNode(b_node);
- break;
- case CMP_NODE_HUECORRECT:
- node = new HueSaturationValueCorrectNode(b_node);
- break;
- case CMP_NODE_MAP_UV:
- node = new MapUVNode(b_node);
- break;
- case CMP_NODE_DISPLACE:
- node = new DisplaceNode(b_node);
- break;
- case CMP_NODE_VALTORGB:
- node = new ColorRampNode(b_node);
- break;
- case CMP_NODE_DIFF_MATTE:
- node = new DifferenceMatteNode(b_node);
- break;
- case CMP_NODE_LUMA_MATTE:
- node = new LuminanceMatteNode(b_node);
- break;
- case CMP_NODE_DIST_MATTE:
- node = new DistanceMatteNode(b_node);
- break;
- case CMP_NODE_CHROMA_MATTE:
- node = new ChromaMatteNode(b_node);
- break;
- case CMP_NODE_COLOR_MATTE:
- node = new ColorMatteNode(b_node);
- break;
- case CMP_NODE_CHANNEL_MATTE:
- node = new ChannelMatteNode(b_node);
- break;
- case CMP_NODE_BLUR:
- node = new BlurNode(b_node);
- break;
- case CMP_NODE_BOKEHIMAGE:
- node = new BokehImageNode(b_node);
- break;
- case CMP_NODE_BOKEHBLUR:
- node = new BokehBlurNode(b_node);
- break;
- case CMP_NODE_DILATEERODE:
- node = new DilateErodeNode(b_node);
- break;
- case CMP_NODE_INPAINT:
- node = new InpaintNode(b_node);
- break;
- case CMP_NODE_DESPECKLE:
- node = new DespeckleNode(b_node);
- break;
- case CMP_NODE_LENSDIST:
- node = new LensDistortionNode(b_node);
- break;
- case CMP_NODE_RGB:
- node = new ColorNode(b_node);
- break;
- case CMP_NODE_VALUE:
- node = new ValueNode(b_node);
- break;
- case CMP_NODE_TIME:
- node = new TimeNode(b_node);
- break;
- case CMP_NODE_DBLUR:
- node = new DirectionalBlurNode(b_node);
- break;
- case CMP_NODE_ZCOMBINE:
- node = new ZCombineNode(b_node);
- break;
- case CMP_NODE_TONEMAP:
- node = new TonemapNode(b_node);
- break;
- case CMP_NODE_SWITCH:
- node = new SwitchNode(b_node);
- break;
- case CMP_NODE_SWITCH_VIEW:
- node = new SwitchViewNode(b_node);
- break;
- case CMP_NODE_GLARE:
- node = new GlareNode(b_node);
- break;
- case CMP_NODE_MOVIECLIP:
- node = new MovieClipNode(b_node);
- break;
- case CMP_NODE_COLOR_SPILL:
- node = new ColorSpillNode(b_node);
- break;
- case CMP_NODE_OUTPUT_FILE:
- node = new OutputFileNode(b_node);
- break;
- case CMP_NODE_MAP_VALUE:
- node = new MapValueNode(b_node);
- break;
- case CMP_NODE_MAP_RANGE:
- node = new MapRangeNode(b_node);
- break;
- case CMP_NODE_TRANSFORM:
- node = new TransformNode(b_node);
- break;
- case CMP_NODE_STABILIZE2D:
- node = new Stabilize2dNode(b_node);
- break;
- case CMP_NODE_BILATERALBLUR:
- node = new BilateralBlurNode(b_node);
- break;
- case CMP_NODE_VECBLUR:
- node = new VectorBlurNode(b_node);
- break;
- case CMP_NODE_MOVIEDISTORTION:
- node = new MovieDistortionNode(b_node);
- break;
- case CMP_NODE_VIEW_LEVELS:
- node = new ViewLevelsNode(b_node);
- break;
- case CMP_NODE_DEFOCUS:
- node = new DefocusNode(b_node);
- break;
- case CMP_NODE_DOUBLEEDGEMASK:
- node = new DoubleEdgeMaskNode(b_node);
- break;
- case CMP_NODE_CROP:
- node = new CropNode(b_node);
- break;
- case CMP_NODE_MASK:
- node = new MaskNode(b_node);
- break;
- case CMP_NODE_KEYINGSCREEN:
- node = new KeyingScreenNode(b_node);
- break;
- case CMP_NODE_KEYING:
- node = new KeyingNode(b_node);
- break;
- case CMP_NODE_TRACKPOS:
- node = new TrackPositionNode(b_node);
- break;
- /* not implemented yet */
- case CMP_NODE_PIXELATE:
- node = new PixelateNode(b_node);
- break;
- case CMP_NODE_PLANETRACKDEFORM:
- node = new PlaneTrackDeformNode(b_node);
- break;
- case CMP_NODE_CORNERPIN:
- node = new CornerPinNode(b_node);
- break;
- case CMP_NODE_SUNBEAMS:
- node = new SunBeamsNode(b_node);
- break;
- case CMP_NODE_CRYPTOMATTE:
- node = new CryptomatteNode(b_node);
- break;
- }
- return node;
+ switch (b_node->type) {
+ case CMP_NODE_COMPOSITE:
+ node = new CompositorNode(b_node);
+ break;
+ case CMP_NODE_R_LAYERS:
+ node = new RenderLayersNode(b_node);
+ break;
+ case CMP_NODE_TEXTURE:
+ node = new TextureNode(b_node);
+ break;
+ case CMP_NODE_RGBTOBW:
+ node = new ColorToBWNode(b_node);
+ break;
+ case CMP_NODE_MIX_RGB:
+ node = new MixNode(b_node);
+ break;
+ case CMP_NODE_TRANSLATE:
+ node = new TranslateNode(b_node);
+ break;
+ case CMP_NODE_SCALE:
+ node = new ScaleNode(b_node);
+ break;
+ case CMP_NODE_ROTATE:
+ node = new RotateNode(b_node);
+ break;
+ case CMP_NODE_FLIP:
+ node = new FlipNode(b_node);
+ break;
+ case CMP_NODE_FILTER:
+ node = new FilterNode(b_node);
+ break;
+ case CMP_NODE_ID_MASK:
+ node = new IDMaskNode(b_node);
+ break;
+ case CMP_NODE_BRIGHTCONTRAST:
+ node = new BrightnessNode(b_node);
+ break;
+ case CMP_NODE_SEPRGBA:
+ node = new SeparateRGBANode(b_node);
+ break;
+ case CMP_NODE_COMBRGBA:
+ node = new CombineRGBANode(b_node);
+ break;
+ case CMP_NODE_SEPHSVA:
+ node = new SeparateHSVANode(b_node);
+ break;
+ case CMP_NODE_COMBHSVA:
+ node = new CombineHSVANode(b_node);
+ break;
+ case CMP_NODE_SEPYUVA:
+ node = new SeparateYUVANode(b_node);
+ break;
+ case CMP_NODE_COMBYUVA:
+ node = new CombineYUVANode(b_node);
+ break;
+ case CMP_NODE_SEPYCCA:
+ node = new SeparateYCCANode(b_node);
+ break;
+ case CMP_NODE_COMBYCCA:
+ node = new CombineYCCANode(b_node);
+ break;
+ case CMP_NODE_ALPHAOVER:
+ node = new AlphaOverNode(b_node);
+ break;
+ case CMP_NODE_COLORBALANCE:
+ node = new ColorBalanceNode(b_node);
+ break;
+ case CMP_NODE_VIEWER:
+ node = new ViewerNode(b_node);
+ break;
+ case CMP_NODE_SPLITVIEWER:
+ node = new SplitViewerNode(b_node);
+ break;
+ case CMP_NODE_INVERT:
+ node = new InvertNode(b_node);
+ break;
+ case NODE_GROUP:
+ case NODE_GROUP_INPUT:
+ case NODE_GROUP_OUTPUT:
+ /* handled in NodeCompiler */
+ break;
+ case CMP_NODE_NORMAL:
+ node = new NormalNode(b_node);
+ break;
+ case CMP_NODE_NORMALIZE:
+ node = new NormalizeNode(b_node);
+ break;
+ case CMP_NODE_IMAGE:
+ node = new ImageNode(b_node);
+ break;
+ case CMP_NODE_SETALPHA:
+ node = new SetAlphaNode(b_node);
+ break;
+ case CMP_NODE_PREMULKEY:
+ node = new ConvertAlphaNode(b_node);
+ break;
+ case CMP_NODE_MATH:
+ node = new MathNode(b_node);
+ break;
+ case CMP_NODE_HUE_SAT:
+ node = new HueSaturationValueNode(b_node);
+ break;
+ case CMP_NODE_COLORCORRECTION:
+ node = new ColorCorrectionNode(b_node);
+ break;
+ case CMP_NODE_MASK_BOX:
+ node = new BoxMaskNode(b_node);
+ break;
+ case CMP_NODE_MASK_ELLIPSE:
+ node = new EllipseMaskNode(b_node);
+ break;
+ case CMP_NODE_GAMMA:
+ node = new GammaNode(b_node);
+ break;
+ case CMP_NODE_CURVE_RGB:
+ node = new ColorCurveNode(b_node);
+ break;
+ case CMP_NODE_CURVE_VEC:
+ node = new VectorCurveNode(b_node);
+ break;
+ case CMP_NODE_HUECORRECT:
+ node = new HueSaturationValueCorrectNode(b_node);
+ break;
+ case CMP_NODE_MAP_UV:
+ node = new MapUVNode(b_node);
+ break;
+ case CMP_NODE_DISPLACE:
+ node = new DisplaceNode(b_node);
+ break;
+ case CMP_NODE_VALTORGB:
+ node = new ColorRampNode(b_node);
+ break;
+ case CMP_NODE_DIFF_MATTE:
+ node = new DifferenceMatteNode(b_node);
+ break;
+ case CMP_NODE_LUMA_MATTE:
+ node = new LuminanceMatteNode(b_node);
+ break;
+ case CMP_NODE_DIST_MATTE:
+ node = new DistanceMatteNode(b_node);
+ break;
+ case CMP_NODE_CHROMA_MATTE:
+ node = new ChromaMatteNode(b_node);
+ break;
+ case CMP_NODE_COLOR_MATTE:
+ node = new ColorMatteNode(b_node);
+ break;
+ case CMP_NODE_CHANNEL_MATTE:
+ node = new ChannelMatteNode(b_node);
+ break;
+ case CMP_NODE_BLUR:
+ node = new BlurNode(b_node);
+ break;
+ case CMP_NODE_BOKEHIMAGE:
+ node = new BokehImageNode(b_node);
+ break;
+ case CMP_NODE_BOKEHBLUR:
+ node = new BokehBlurNode(b_node);
+ break;
+ case CMP_NODE_DILATEERODE:
+ node = new DilateErodeNode(b_node);
+ break;
+ case CMP_NODE_INPAINT:
+ node = new InpaintNode(b_node);
+ break;
+ case CMP_NODE_DESPECKLE:
+ node = new DespeckleNode(b_node);
+ break;
+ case CMP_NODE_LENSDIST:
+ node = new LensDistortionNode(b_node);
+ break;
+ case CMP_NODE_RGB:
+ node = new ColorNode(b_node);
+ break;
+ case CMP_NODE_VALUE:
+ node = new ValueNode(b_node);
+ break;
+ case CMP_NODE_TIME:
+ node = new TimeNode(b_node);
+ break;
+ case CMP_NODE_DBLUR:
+ node = new DirectionalBlurNode(b_node);
+ break;
+ case CMP_NODE_ZCOMBINE:
+ node = new ZCombineNode(b_node);
+ break;
+ case CMP_NODE_TONEMAP:
+ node = new TonemapNode(b_node);
+ break;
+ case CMP_NODE_SWITCH:
+ node = new SwitchNode(b_node);
+ break;
+ case CMP_NODE_SWITCH_VIEW:
+ node = new SwitchViewNode(b_node);
+ break;
+ case CMP_NODE_GLARE:
+ node = new GlareNode(b_node);
+ break;
+ case CMP_NODE_MOVIECLIP:
+ node = new MovieClipNode(b_node);
+ break;
+ case CMP_NODE_COLOR_SPILL:
+ node = new ColorSpillNode(b_node);
+ break;
+ case CMP_NODE_OUTPUT_FILE:
+ node = new OutputFileNode(b_node);
+ break;
+ case CMP_NODE_MAP_VALUE:
+ node = new MapValueNode(b_node);
+ break;
+ case CMP_NODE_MAP_RANGE:
+ node = new MapRangeNode(b_node);
+ break;
+ case CMP_NODE_TRANSFORM:
+ node = new TransformNode(b_node);
+ break;
+ case CMP_NODE_STABILIZE2D:
+ node = new Stabilize2dNode(b_node);
+ break;
+ case CMP_NODE_BILATERALBLUR:
+ node = new BilateralBlurNode(b_node);
+ break;
+ case CMP_NODE_VECBLUR:
+ node = new VectorBlurNode(b_node);
+ break;
+ case CMP_NODE_MOVIEDISTORTION:
+ node = new MovieDistortionNode(b_node);
+ break;
+ case CMP_NODE_VIEW_LEVELS:
+ node = new ViewLevelsNode(b_node);
+ break;
+ case CMP_NODE_DEFOCUS:
+ node = new DefocusNode(b_node);
+ break;
+ case CMP_NODE_DOUBLEEDGEMASK:
+ node = new DoubleEdgeMaskNode(b_node);
+ break;
+ case CMP_NODE_CROP:
+ node = new CropNode(b_node);
+ break;
+ case CMP_NODE_MASK:
+ node = new MaskNode(b_node);
+ break;
+ case CMP_NODE_KEYINGSCREEN:
+ node = new KeyingScreenNode(b_node);
+ break;
+ case CMP_NODE_KEYING:
+ node = new KeyingNode(b_node);
+ break;
+ case CMP_NODE_TRACKPOS:
+ node = new TrackPositionNode(b_node);
+ break;
+ /* not implemented yet */
+ case CMP_NODE_PIXELATE:
+ node = new PixelateNode(b_node);
+ break;
+ case CMP_NODE_PLANETRACKDEFORM:
+ node = new PlaneTrackDeformNode(b_node);
+ break;
+ case CMP_NODE_CORNERPIN:
+ node = new CornerPinNode(b_node);
+ break;
+ case CMP_NODE_SUNBEAMS:
+ node = new SunBeamsNode(b_node);
+ break;
+ case CMP_NODE_CRYPTOMATTE:
+ node = new CryptomatteNode(b_node);
+ break;
+ }
+ return node;
}
NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperationInput *to)
{
- DataType fromDatatype = from->getDataType();
- DataType toDatatype = to->getDataType();
+ DataType fromDatatype = from->getDataType();
+ DataType toDatatype = to->getDataType();
- if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
- return new ConvertValueToColorOperation();
- }
- else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
- return new ConvertValueToVectorOperation();
- }
- else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
- return new ConvertColorToValueOperation();
- }
- else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
- return new ConvertColorToVectorOperation();
- }
- else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
- return new ConvertVectorToValueOperation();
- }
- else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
- return new ConvertVectorToColorOperation();
- }
+ if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
+ return new ConvertValueToColorOperation();
+ }
+ else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
+ return new ConvertValueToVectorOperation();
+ }
+ else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
+ return new ConvertColorToValueOperation();
+ }
+ else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
+ return new ConvertColorToVectorOperation();
+ }
+ else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) {
+ return new ConvertVectorToValueOperation();
+ }
+ else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) {
+ return new ConvertVectorToColorOperation();
+ }
- return NULL;
+ return NULL;
}
-void Converter::convertResolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket)
+void Converter::convertResolution(NodeOperationBuilder &builder,
+ NodeOperationOutput *fromSocket,
+ NodeOperationInput *toSocket)
{
- InputResizeMode mode = toSocket->getResizeMode();
+ InputResizeMode mode = toSocket->getResizeMode();
- NodeOperation *toOperation = &toSocket->getOperation();
- const float toWidth = toOperation->getWidth();
- const float toHeight = toOperation->getHeight();
- NodeOperation *fromOperation = &fromSocket->getOperation();
- const float fromWidth = fromOperation->getWidth();
- const float fromHeight = fromOperation->getHeight();
- bool doCenter = false;
- bool doScale = false;
- float addX = (toWidth - fromWidth) / 2.0f;
- float addY = (toHeight - fromHeight) / 2.0f;
- float scaleX = 0;
- float scaleY = 0;
+ NodeOperation *toOperation = &toSocket->getOperation();
+ const float toWidth = toOperation->getWidth();
+ const float toHeight = toOperation->getHeight();
+ NodeOperation *fromOperation = &fromSocket->getOperation();
+ const float fromWidth = fromOperation->getWidth();
+ const float fromHeight = fromOperation->getHeight();
+ bool doCenter = false;
+ bool doScale = false;
+ float addX = (toWidth - fromWidth) / 2.0f;
+ float addY = (toHeight - fromHeight) / 2.0f;
+ float scaleX = 0;
+ float scaleY = 0;
- switch (mode) {
- case COM_SC_NO_RESIZE:
- break;
- case COM_SC_CENTER:
- doCenter = true;
- break;
- case COM_SC_FIT_WIDTH:
- doCenter = true;
- doScale = true;
- scaleX = scaleY = toWidth / fromWidth;
- break;
- case COM_SC_FIT_HEIGHT:
- doCenter = true;
- doScale = true;
- scaleX = scaleY = toHeight / fromHeight;
- break;
- case COM_SC_FIT:
- doCenter = true;
- doScale = true;
- scaleX = toWidth / fromWidth;
- scaleY = toHeight / fromHeight;
- if (scaleX < scaleY) {
- scaleX = scaleY;
- }
- else {
- scaleY = scaleX;
- }
- break;
- case COM_SC_STRETCH:
- doCenter = true;
- doScale = true;
- scaleX = toWidth / fromWidth;
- scaleY = toHeight / fromHeight;
- break;
+ switch (mode) {
+ case COM_SC_NO_RESIZE:
+ break;
+ case COM_SC_CENTER:
+ doCenter = true;
+ break;
+ case COM_SC_FIT_WIDTH:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toWidth / fromWidth;
+ break;
+ case COM_SC_FIT_HEIGHT:
+ doCenter = true;
+ doScale = true;
+ scaleX = scaleY = toHeight / fromHeight;
+ break;
+ case COM_SC_FIT:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth / fromWidth;
+ scaleY = toHeight / fromHeight;
+ if (scaleX < scaleY) {
+ scaleX = scaleY;
+ }
+ else {
+ scaleY = scaleX;
+ }
+ break;
+ case COM_SC_STRETCH:
+ doCenter = true;
+ doScale = true;
+ scaleX = toWidth / fromWidth;
+ scaleY = toHeight / fromHeight;
+ break;
+ }
- }
+ if (doCenter) {
+ NodeOperation *first = NULL;
+ ScaleOperation *scaleOperation = NULL;
+ if (doScale) {
+ scaleOperation = new ScaleOperation();
+ scaleOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
+ scaleOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
+ first = scaleOperation;
+ SetValueOperation *sxop = new SetValueOperation();
+ sxop->setValue(scaleX);
+ builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
+ SetValueOperation *syop = new SetValueOperation();
+ syop->setValue(scaleY);
+ builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2));
+ builder.addOperation(sxop);
+ builder.addOperation(syop);
- if (doCenter) {
- NodeOperation *first = NULL;
- ScaleOperation *scaleOperation = NULL;
- if (doScale) {
- scaleOperation = new ScaleOperation();
- scaleOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
- scaleOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
- first = scaleOperation;
- SetValueOperation *sxop = new SetValueOperation();
- sxop->setValue(scaleX);
- builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
- SetValueOperation *syop = new SetValueOperation();
- syop->setValue(scaleY);
- builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2));
- builder.addOperation(sxop);
- builder.addOperation(syop);
+ unsigned int resolution[2] = {fromOperation->getWidth(), fromOperation->getHeight()};
+ scaleOperation->setResolution(resolution);
+ sxop->setResolution(resolution);
+ syop->setResolution(resolution);
+ builder.addOperation(scaleOperation);
+ }
- unsigned int resolution[2] = {fromOperation->getWidth(),
- fromOperation->getHeight()};
- scaleOperation->setResolution(resolution);
- sxop->setResolution(resolution);
- syop->setResolution(resolution);
- builder.addOperation(scaleOperation);
- }
+ TranslateOperation *translateOperation = new TranslateOperation();
+ translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
+ translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
+ if (!first)
+ first = translateOperation;
+ SetValueOperation *xop = new SetValueOperation();
+ xop->setValue(addX);
+ builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
+ SetValueOperation *yop = new SetValueOperation();
+ yop->setValue(addY);
+ builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2));
+ builder.addOperation(xop);
+ builder.addOperation(yop);
- TranslateOperation *translateOperation = new TranslateOperation();
- translateOperation->getInputSocket(1)->setResizeMode(COM_SC_NO_RESIZE);
- translateOperation->getInputSocket(2)->setResizeMode(COM_SC_NO_RESIZE);
- if (!first) first = translateOperation;
- SetValueOperation *xop = new SetValueOperation();
- xop->setValue(addX);
- builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
- SetValueOperation *yop = new SetValueOperation();
- yop->setValue(addY);
- builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2));
- builder.addOperation(xop);
- builder.addOperation(yop);
+ unsigned int resolution[2] = {toOperation->getWidth(), toOperation->getHeight()};
+ translateOperation->setResolution(resolution);
+ xop->setResolution(resolution);
+ yop->setResolution(resolution);
+ builder.addOperation(translateOperation);
- unsigned int resolution[2] = {toOperation->getWidth(),
- toOperation->getHeight()};
- translateOperation->setResolution(resolution);
- xop->setResolution(resolution);
- yop->setResolution(resolution);
- builder.addOperation(translateOperation);
+ if (doScale) {
+ translateOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ }
- if (doScale) {
- translateOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
- builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
- }
-
- /* remove previous link and replace */
- builder.removeInputLink(toSocket);
- first->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
- toSocket->setResizeMode(COM_SC_NO_RESIZE);
- builder.addLink(fromSocket, first->getInputSocket(0));
- builder.addLink(translateOperation->getOutputSocket(), toSocket);
- }
+ /* remove previous link and replace */
+ builder.removeInputLink(toSocket);
+ first->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
+ toSocket->setResizeMode(COM_SC_NO_RESIZE);
+ builder.addLink(fromSocket, first->getInputSocket(0));
+ builder.addLink(translateOperation->getOutputSocket(), toSocket);
+ }
}
diff --git a/source/blender/compositor/intern/COM_Converter.h b/source/blender/compositor/intern/COM_Converter.h
index 512bd10f29f..0d7fc40de17 100644
--- a/source/blender/compositor/intern/COM_Converter.h
+++ b/source/blender/compositor/intern/COM_Converter.h
@@ -35,50 +35,52 @@ class NodeOperationBuilder;
* \brief Conversion methods for the compositor
*/
class Converter {
-public:
- /**
- * \brief Convert/wraps a bNode in its Node instance.
- *
- * For all nodetypes a wrapper class is created.
- *
- * \note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
- *
- * \see Node
- */
- static Node *convert(bNode *b_node);
+ public:
+ /**
+ * \brief Convert/wraps a bNode in its Node instance.
+ *
+ * For all nodetypes a wrapper class is created.
+ *
+ * \note When adding a new node to blender, this method needs to be changed to return the correct Node instance.
+ *
+ * \see Node
+ */
+ static Node *convert(bNode *b_node);
- /**
- * \brief True if the node is considered 'fast'.
- *
- * Slow nodes will be skipped if fast execution is required.
- */
- static bool is_fast_node(bNode *b_node);
+ /**
+ * \brief True if the node is considered 'fast'.
+ *
+ * Slow nodes will be skipped if fast execution is required.
+ */
+ static bool is_fast_node(bNode *b_node);
- /**
- * \brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
- *
- * \note this method is called when conversion is needed.
- *
- * \param link: the NodeLink what needs conversion
- * \param system: the ExecutionSystem to add the conversion to.
- * \see NodeLink - a link between two sockets
- */
- static NodeOperation *convertDataType(NodeOperationOutput *from, NodeOperationInput *to);
+ /**
+ * \brief This method will add a datetype conversion rule when the to-socket does not support the from-socket actual data type.
+ *
+ * \note this method is called when conversion is needed.
+ *
+ * \param link: the NodeLink what needs conversion
+ * \param system: the ExecutionSystem to add the conversion to.
+ * \see NodeLink - a link between two sockets
+ */
+ static NodeOperation *convertDataType(NodeOperationOutput *from, NodeOperationInput *to);
- /**
- * \brief This method will add a resolution rule based on the settings of the NodeInput.
- *
- * \note Conversion logic is implemented in this method
- * \see InputSocketResizeMode for the possible conversions.
- *
- * \param link: the NodeLink what needs conversion
- * \param system: the ExecutionSystem to add the conversion to.
- * \see NodeLink - a link between two sockets
- */
- static void convertResolution(NodeOperationBuilder &builder, NodeOperationOutput *fromSocket, NodeOperationInput *toSocket);
+ /**
+ * \brief This method will add a resolution rule based on the settings of the NodeInput.
+ *
+ * \note Conversion logic is implemented in this method
+ * \see InputSocketResizeMode for the possible conversions.
+ *
+ * \param link: the NodeLink what needs conversion
+ * \param system: the ExecutionSystem to add the conversion to.
+ * \see NodeLink - a link between two sockets
+ */
+ static void convertResolution(NodeOperationBuilder &builder,
+ NodeOperationOutput *fromSocket,
+ NodeOperationInput *toSocket);
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:Converter")
#endif
};
#endif
diff --git a/source/blender/compositor/intern/COM_Debug.cpp b/source/blender/compositor/intern/COM_Debug.cpp
index 59acdad000c..67ac350de83 100644
--- a/source/blender/compositor/intern/COM_Debug.cpp
+++ b/source/blender/compositor/intern/COM_Debug.cpp
@@ -20,29 +20,28 @@
#ifdef COM_DEBUG
-#include <typeinfo>
-#include <map>
-#include <vector>
+# include <typeinfo>
+# include <map>
+# include <vector>
extern "C" {
-#include "BLI_sys_types.h"
-#include "BLI_fileops.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-
-#include "DNA_node_types.h"
-#include "BKE_appdir.h"
-#include "BKE_node.h"
+# include "BLI_sys_types.h"
+# include "BLI_fileops.h"
+# include "BLI_path_util.h"
+# include "BLI_string.h"
+
+# include "DNA_node_types.h"
+# include "BKE_appdir.h"
+# include "BKE_node.h"
}
-#include "COM_Node.h"
-#include "COM_ExecutionSystem.h"
-#include "COM_ExecutionGroup.h"
-
-#include "COM_ReadBufferOperation.h"
-#include "COM_ViewerOperation.h"
-#include "COM_WriteBufferOperation.h"
+# include "COM_Node.h"
+# include "COM_ExecutionSystem.h"
+# include "COM_ExecutionGroup.h"
+# include "COM_ReadBufferOperation.h"
+# include "COM_ViewerOperation.h"
+# include "COM_WriteBufferOperation.h"
int DebugInfo::m_file_index = 0;
DebugInfo::NodeNameMap DebugInfo::m_node_names;
@@ -53,373 +52,465 @@ DebugInfo::GroupStateMap DebugInfo::m_group_states;
std::string DebugInfo::node_name(const Node *node)
{
- NodeNameMap::const_iterator it = m_node_names.find(node);
- if (it != m_node_names.end())
- return it->second;
- else
- return "";
+ NodeNameMap::const_iterator it = m_node_names.find(node);
+ if (it != m_node_names.end())
+ return it->second;
+ else
+ return "";
}
std::string DebugInfo::operation_name(const NodeOperation *op)
{
- OpNameMap::const_iterator it = m_op_names.find(op);
- if (it != m_op_names.end())
- return it->second;
- else
- return "";
+ OpNameMap::const_iterator it = m_op_names.find(op);
+ if (it != m_op_names.end())
+ return it->second;
+ else
+ return "";
}
void DebugInfo::convert_started()
{
- m_op_names.clear();
+ m_op_names.clear();
}
void DebugInfo::execute_started(const ExecutionSystem *system)
{
- m_file_index = 1;
- m_group_states.clear();
- for (ExecutionSystem::Groups::const_iterator it = system->m_groups.begin(); it != system->m_groups.end(); ++it)
- m_group_states[*it] = EG_WAIT;
+ m_file_index = 1;
+ m_group_states.clear();
+ for (ExecutionSystem::Groups::const_iterator it = system->m_groups.begin();
+ it != system->m_groups.end();
+ ++it)
+ m_group_states[*it] = EG_WAIT;
}
void DebugInfo::node_added(const Node *node)
{
- m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
+ m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
}
void DebugInfo::node_to_operations(const Node *node)
{
- m_current_node_name = m_node_names[node];
+ m_current_node_name = m_node_names[node];
}
void DebugInfo::operation_added(const NodeOperation *operation)
{
- m_op_names[operation] = m_current_node_name;
+ m_op_names[operation] = m_current_node_name;
}
void DebugInfo::operation_read_write_buffer(const NodeOperation *operation)
{
- m_current_op_name = m_op_names[operation];
+ m_current_op_name = m_op_names[operation];
}
void DebugInfo::execution_group_started(const ExecutionGroup *group)
{
- m_group_states[group] = EG_RUNNING;
+ m_group_states[group] = EG_RUNNING;
}
void DebugInfo::execution_group_finished(const ExecutionGroup *group)
{
- m_group_states[group] = EG_FINISHED;
+ m_group_states[group] = EG_FINISHED;
}
-int DebugInfo::graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen)
+int DebugInfo::graphviz_operation(const ExecutionSystem *system,
+ const NodeOperation *operation,
+ const ExecutionGroup *group,
+ char *str,
+ int maxlen)
{
- int len = 0;
-
- std::string fillcolor = "gainsboro";
- if (operation->isViewerOperation()) {
- const ViewerOperation *viewer = (const ViewerOperation *)operation;
- if (viewer->isActiveViewerOutput()) {
- fillcolor = "lightskyblue1";
- }
- else {
- fillcolor = "lightskyblue3";
- }
- }
- else if (operation->isOutputOperation(system->getContext().isRendering())) {
- fillcolor = "dodgerblue1";
- }
- else if (operation->isSetOperation()) {
- fillcolor = "khaki1";
- }
- else if (operation->isReadBufferOperation()) {
- fillcolor = "darkolivegreen3";
- }
- else if (operation->isWriteBufferOperation()) {
- fillcolor = "darkorange";
- }
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %p\r\n", operation);
- if (group)
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p_%p\"", operation, group);
- else
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p\"", operation);
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " [fillcolor=%s,style=filled,shape=record,label=\"{", fillcolor.c_str());
-
- int totinputs = operation->getNumberOfInputSockets();
- if (totinputs != 0) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
- for (int k = 0; k < totinputs; k++) {
- NodeOperationInput *socket = operation->getInputSocket(k);
- if (k != 0) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
- }
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket);
- switch (socket->getDataType()) {
- case COM_DT_VALUE:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
- break;
- case COM_DT_VECTOR:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
- break;
- case COM_DT_COLOR:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
- break;
- }
- }
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
- }
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "%s\\n(%s)", m_op_names[operation].c_str(), typeid(*operation).name());
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " (%u,%u)", operation->getWidth(), operation->getHeight());
-
- int totoutputs = operation->getNumberOfOutputSockets();
- if (totoutputs != 0) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
- for (int k = 0; k < totoutputs; k++) {
- NodeOperationOutput *socket = operation->getOutputSocket(k);
- if (k != 0) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
- }
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket);
- switch (socket->getDataType()) {
- case COM_DT_VALUE:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
- break;
- case COM_DT_VECTOR:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
- break;
- case COM_DT_COLOR:
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
- break;
- }
- }
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}");
- }
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\"]");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
-
- return len;
+ int len = 0;
+
+ std::string fillcolor = "gainsboro";
+ if (operation->isViewerOperation()) {
+ const ViewerOperation *viewer = (const ViewerOperation *)operation;
+ if (viewer->isActiveViewerOutput()) {
+ fillcolor = "lightskyblue1";
+ }
+ else {
+ fillcolor = "lightskyblue3";
+ }
+ }
+ else if (operation->isOutputOperation(system->getContext().isRendering())) {
+ fillcolor = "dodgerblue1";
+ }
+ else if (operation->isSetOperation()) {
+ fillcolor = "khaki1";
+ }
+ else if (operation->isReadBufferOperation()) {
+ fillcolor = "darkolivegreen3";
+ }
+ else if (operation->isWriteBufferOperation()) {
+ fillcolor = "darkorange";
+ }
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %p\r\n", operation);
+ if (group)
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p_%p\"", operation, group);
+ else
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p\"", operation);
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ " [fillcolor=%s,style=filled,shape=record,label=\"{",
+ fillcolor.c_str());
+
+ int totinputs = operation->getNumberOfInputSockets();
+ if (totinputs != 0) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
+ for (int k = 0; k < totinputs; k++) {
+ NodeOperationInput *socket = operation->getInputSocket(k);
+ if (k != 0) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
+ }
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket);
+ switch (socket->getDataType()) {
+ case COM_DT_VALUE:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
+ break;
+ case COM_DT_VECTOR:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
+ break;
+ case COM_DT_COLOR:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
+ break;
+ }
+ }
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
+ }
+
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "%s\\n(%s)",
+ m_op_names[operation].c_str(),
+ typeid(*operation).name());
+
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ " (%u,%u)",
+ operation->getWidth(),
+ operation->getHeight());
+
+ int totoutputs = operation->getNumberOfOutputSockets();
+ if (totoutputs != 0) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
+ for (int k = 0; k < totoutputs; k++) {
+ NodeOperationOutput *socket = operation->getOutputSocket(k);
+ if (k != 0) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
+ }
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket);
+ switch (socket->getDataType()) {
+ case COM_DT_VALUE:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
+ break;
+ case COM_DT_VECTOR:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
+ break;
+ case COM_DT_COLOR:
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
+ break;
+ }
+ }
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}");
+ }
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\"]");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
+
+ return len;
}
int DebugInfo::graphviz_legend_color(const char *name, const char *color, char *str, int maxlen)
{
- int len = 0;
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD>%s</TD><TD BGCOLOR=\"%s\"></TD></TR>\r\n", name, color);
- return len;
+ int len = 0;
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "<TR><TD>%s</TD><TD BGCOLOR=\"%s\"></TD></TR>\r\n",
+ name,
+ color);
+ return len;
}
-int DebugInfo::graphviz_legend_line(const char * /*name*/, const char * /*color*/, const char * /*style*/, char *str, int maxlen)
+int DebugInfo::graphviz_legend_line(
+ const char * /*name*/, const char * /*color*/, const char * /*style*/, char *str, int maxlen)
{
- /* XXX TODO */
- int len = 0;
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
- return len;
+ /* XXX TODO */
+ int len = 0;
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
+ return len;
}
-int DebugInfo::graphviz_legend_group(const char *name, const char *color, const char * /*style*/, char *str, int maxlen)
+int DebugInfo::graphviz_legend_group(
+ const char *name, const char *color, const char * /*style*/, char *str, int maxlen)
{
- int len = 0;
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD>%s</TD><TD CELLPADDING=\"4\"><TABLE BORDER=\"1\" CELLBORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD BGCOLOR=\"%s\"></TD></TR></TABLE></TD></TR>\r\n", name, color);
- return len;
+ int len = 0;
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "<TR><TD>%s</TD><TD CELLPADDING=\"4\"><TABLE BORDER=\"1\" CELLBORDER=\"0\" "
+ "CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD "
+ "BGCOLOR=\"%s\"></TD></TR></TABLE></TD></TR>\r\n",
+ name,
+ color);
+ return len;
}
int DebugInfo::graphviz_legend(char *str, int maxlen)
{
- int len = 0;
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rank = sink;\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Legend [shape=none, margin=0, label=<\r\n");
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " <TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD COLSPAN=\"2\"><B>Legend</B></TD></TR>\r\n");
-
- len += graphviz_legend_color("NodeOperation", "gainsboro", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Output", "dodgerblue1", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Viewer", "lightskyblue3", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Active Viewer", "lightskyblue1", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Write Buffer", "darkorange", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Read Buffer", "darkolivegreen3", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_color("Input Value", "khaki1", str + len, maxlen > len ? maxlen - len : 0);
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD></TD></TR>\r\n");
-
- len += graphviz_legend_group("Group Waiting", "white", "dashed", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_group("Group Running", "firebrick1", "solid", str + len, maxlen > len ? maxlen - len : 0);
- len += graphviz_legend_group("Group Finished", "chartreuse4", "solid", str + len, maxlen > len ? maxlen - len : 0);
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "</TABLE>\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, ">];\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
-
- return len;
+ int len = 0;
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rank = sink;\r\n");
+ len += snprintf(
+ str + len, maxlen > len ? maxlen - len : 0, "Legend [shape=none, margin=0, label=<\r\n");
+
+ len += snprintf(
+ str + len,
+ maxlen > len ? maxlen - len : 0,
+ " <TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"4\">\r\n");
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "<TR><TD COLSPAN=\"2\"><B>Legend</B></TD></TR>\r\n");
+
+ len += graphviz_legend_color(
+ "NodeOperation", "gainsboro", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Output", "dodgerblue1", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Viewer", "lightskyblue3", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Active Viewer", "lightskyblue1", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Write Buffer", "darkorange", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Read Buffer", "darkolivegreen3", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_color(
+ "Input Value", "khaki1", str + len, maxlen > len ? maxlen - len : 0);
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<TR><TD></TD></TR>\r\n");
+
+ len += graphviz_legend_group(
+ "Group Waiting", "white", "dashed", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_group(
+ "Group Running", "firebrick1", "solid", str + len, maxlen > len ? maxlen - len : 0);
+ len += graphviz_legend_group(
+ "Group Finished", "chartreuse4", "solid", str + len, maxlen > len ? maxlen - len : 0);
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "</TABLE>\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, ">];\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
+
+ return len;
}
bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int maxlen)
{
- char strbuf[64];
- int len = 0;
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "digraph compositorexecution {\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "ranksep=1.5\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rankdir=LR\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "splines=false\r\n");
-
-#if 0
- for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin();
- it != system->m_operations.end(); ++it)
- {
- NodeOperation *op = *it;
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name);
- }
-#endif
-
- int totops = system->m_operations.size();
- int totgroups = system->m_groups.size();
- std::map<NodeOperation *, std::vector<std::string> > op_groups;
- for (int i = 0; i < totgroups; ++i) {
- const ExecutionGroup *group = system->m_groups[i];
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", i);
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", i);
- /* used as a check for executing group */
- if (m_group_states[group] == EG_WAIT) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=dashed\r\n");
- }
- else if (m_group_states[group] == EG_RUNNING) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=firebrick1\r\n");
- }
- else if (m_group_states[group] == EG_FINISHED) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
- }
-
- for (ExecutionGroup::Operations::const_iterator it = group->m_operations.begin(); it != group->m_operations.end(); ++it) {
- NodeOperation *operation = *it;
-
- sprintf(strbuf, "_%p", group);
- op_groups[operation].push_back(std::string(strbuf));
-
- len += graphviz_operation(system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
- }
-
-// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
-// len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
- }
-
- /* operations not included in any group */
- for (int j = 0; j < totops; ++j) {
- NodeOperation *operation = system->m_operations[j];
- if (op_groups.find(operation) != op_groups.end())
- continue;
-
- op_groups[operation].push_back(std::string(""));
-
- len += graphviz_operation(system, operation, 0, str + len, maxlen > len ? maxlen - len : 0);
- }
-
- for (int i = 0; i < totops; i++) {
- NodeOperation *operation = system->m_operations[i];
-
- if (operation->isReadBufferOperation()) {
- ReadBufferOperation *read = (ReadBufferOperation *)operation;
- WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
- std::vector<std::string> &read_groups = op_groups[read];
- std::vector<std::string> &write_groups = op_groups[write];
-
- for (int k = 0; k < write_groups.size(); ++k) {
- for (int l = 0; l < read_groups.size(); ++l) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p%s\" -> \"O_%p%s\" [style=dotted]\r\n", write, write_groups[k].c_str(), read, read_groups[l].c_str());
- }
- }
- }
- }
-
- for (int i = 0; i < totops; i++) {
- NodeOperation *op = system->m_operations[i];
-
- for (NodeOperation::Inputs::const_iterator it = op->m_inputs.begin(); it != op->m_inputs.end(); ++it) {
- NodeOperationInput *to = *it;
- NodeOperationOutput *from = to->getLink();
-
- if (!from)
- continue;
-
- std::string color;
- switch (from->getDataType()) {
- case COM_DT_VALUE:
- color = "gray";
- break;
- case COM_DT_VECTOR:
- color = "blue";
- break;
- case COM_DT_COLOR:
- color = "orange";
- break;
- }
-
- NodeOperation *to_op = &to->getOperation();
- NodeOperation *from_op = &from->getOperation();
- std::vector<std::string> &from_groups = op_groups[from_op];
- std::vector<std::string> &to_groups = op_groups[to_op];
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// CONNECTION: %p.%p -> %p.%p\r\n",
- from_op, from, to_op, to);
- for (int k = 0; k < from_groups.size(); ++k) {
- for (int l = 0; l < to_groups.size(); ++l) {
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\"O_%p%s\":\"OUT_%p\":e -> \"O_%p%s\":\"IN_%p\":w",
- from_op, from_groups[k].c_str(), from, to_op, to_groups[l].c_str(), to);
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, " [color=%s]", color.c_str());
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
- }
- }
- }
- }
-
- len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0);
-
- len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
-
- return (len < maxlen);
+ char strbuf[64];
+ int len = 0;
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "digraph compositorexecution {\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "ranksep=1.5\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "rankdir=LR\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "splines=false\r\n");
+
+# if 0
+ for (ExecutionSystem::Operations::const_iterator it = system->m_operations.begin();
+ it != system->m_operations.end(); ++it)
+ {
+ NodeOperation *op = *it;
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// OPERATION: %s\r\n", node->getbNode()->typeinfo->ui_name);
+ }
+# endif
+
+ int totops = system->m_operations.size();
+ int totgroups = system->m_groups.size();
+ std::map<NodeOperation *, std::vector<std::string>> op_groups;
+ for (int i = 0; i < totgroups; ++i) {
+ const ExecutionGroup *group = system->m_groups[i];
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", i);
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", i);
+ /* used as a check for executing group */
+ if (m_group_states[group] == EG_WAIT) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=dashed\r\n");
+ }
+ else if (m_group_states[group] == EG_RUNNING) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=firebrick1\r\n");
+ }
+ else if (m_group_states[group] == EG_FINISHED) {
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
+ }
+
+ for (ExecutionGroup::Operations::const_iterator it = group->m_operations.begin();
+ it != group->m_operations.end();
+ ++it) {
+ NodeOperation *operation = *it;
+
+ sprintf(strbuf, "_%p", group);
+ op_groups[operation].push_back(std::string(strbuf));
+
+ len += graphviz_operation(
+ system, operation, group, str + len, maxlen > len ? maxlen - len : 0);
+ }
+
+ // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, "// OUTPUTOPERATION: %p\r\n", group->getOutputOperation());
+ // len += snprintf(str+len, maxlen>len ? maxlen-len : 0, " O_%p\r\n", group->getOutputOperation());
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
+ }
+
+ /* operations not included in any group */
+ for (int j = 0; j < totops; ++j) {
+ NodeOperation *operation = system->m_operations[j];
+ if (op_groups.find(operation) != op_groups.end())
+ continue;
+
+ op_groups[operation].push_back(std::string(""));
+
+ len += graphviz_operation(system, operation, 0, str + len, maxlen > len ? maxlen - len : 0);
+ }
+
+ for (int i = 0; i < totops; i++) {
+ NodeOperation *operation = system->m_operations[i];
+
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation *read = (ReadBufferOperation *)operation;
+ WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
+ std::vector<std::string> &read_groups = op_groups[read];
+ std::vector<std::string> &write_groups = op_groups[write];
+
+ for (int k = 0; k < write_groups.size(); ++k) {
+ for (int l = 0; l < read_groups.size(); ++l) {
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "\"O_%p%s\" -> \"O_%p%s\" [style=dotted]\r\n",
+ write,
+ write_groups[k].c_str(),
+ read,
+ read_groups[l].c_str());
+ }
+ }
+ }
+ }
+
+ for (int i = 0; i < totops; i++) {
+ NodeOperation *op = system->m_operations[i];
+
+ for (NodeOperation::Inputs::const_iterator it = op->m_inputs.begin(); it != op->m_inputs.end();
+ ++it) {
+ NodeOperationInput *to = *it;
+ NodeOperationOutput *from = to->getLink();
+
+ if (!from)
+ continue;
+
+ std::string color;
+ switch (from->getDataType()) {
+ case COM_DT_VALUE:
+ color = "gray";
+ break;
+ case COM_DT_VECTOR:
+ color = "blue";
+ break;
+ case COM_DT_COLOR:
+ color = "orange";
+ break;
+ }
+
+ NodeOperation *to_op = &to->getOperation();
+ NodeOperation *from_op = &from->getOperation();
+ std::vector<std::string> &from_groups = op_groups[from_op];
+ std::vector<std::string> &to_groups = op_groups[to_op];
+
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "// CONNECTION: %p.%p -> %p.%p\r\n",
+ from_op,
+ from,
+ to_op,
+ to);
+ for (int k = 0; k < from_groups.size(); ++k) {
+ for (int l = 0; l < to_groups.size(); ++l) {
+ len += snprintf(str + len,
+ maxlen > len ? maxlen - len : 0,
+ "\"O_%p%s\":\"OUT_%p\":e -> \"O_%p%s\":\"IN_%p\":w",
+ from_op,
+ from_groups[k].c_str(),
+ from,
+ to_op,
+ to_groups[l].c_str(),
+ to);
+ len += snprintf(
+ str + len, maxlen > len ? maxlen - len : 0, " [color=%s]", color.c_str());
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "\r\n");
+ }
+ }
+ }
+ }
+
+ len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0);
+
+ len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
+
+ return (len < maxlen);
}
void DebugInfo::graphviz(const ExecutionSystem *system)
{
- char str[1000000];
- if (graphviz_system(system, str, sizeof(str) - 1)) {
- char basename[FILE_MAX];
- char filename[FILE_MAX];
-
- BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index);
- BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
- ++m_file_index;
-
- FILE *fp = BLI_fopen(filename, "wb");
- fputs(str, fp);
- fclose(fp);
- }
+ char str[1000000];
+ if (graphviz_system(system, str, sizeof(str) - 1)) {
+ char basename[FILE_MAX];
+ char filename[FILE_MAX];
+
+ BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index);
+ BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
+ ++m_file_index;
+
+ FILE *fp = BLI_fopen(filename, "wb");
+ fputs(str, fp);
+ fclose(fp);
+ }
}
#else
-std::string DebugInfo::node_name(const Node * /*node*/) { return ""; }
-std::string DebugInfo::operation_name(const NodeOperation * /*op*/) { return ""; }
-void DebugInfo::convert_started() {}
-void DebugInfo::execute_started(const ExecutionSystem * /*system*/) {}
-void DebugInfo::node_added(const Node * /*node*/) {}
-void DebugInfo::node_to_operations(const Node * /*node*/) {}
-void DebugInfo::operation_added(const NodeOperation * /*operation*/) {}
-void DebugInfo::operation_read_write_buffer(const NodeOperation * /*operation*/) {}
-void DebugInfo::execution_group_started(const ExecutionGroup * /*group*/) {}
-void DebugInfo::execution_group_finished(const ExecutionGroup * /*group*/) {}
-void DebugInfo::graphviz(const ExecutionSystem * /*system*/) {}
+std::string DebugInfo::node_name(const Node * /*node*/)
+{
+ return "";
+}
+std::string DebugInfo::operation_name(const NodeOperation * /*op*/)
+{
+ return "";
+}
+void DebugInfo::convert_started()
+{
+}
+void DebugInfo::execute_started(const ExecutionSystem * /*system*/)
+{
+}
+void DebugInfo::node_added(const Node * /*node*/)
+{
+}
+void DebugInfo::node_to_operations(const Node * /*node*/)
+{
+}
+void DebugInfo::operation_added(const NodeOperation * /*operation*/)
+{
+}
+void DebugInfo::operation_read_write_buffer(const NodeOperation * /*operation*/)
+{
+}
+void DebugInfo::execution_group_started(const ExecutionGroup * /*group*/)
+{
+}
+void DebugInfo::execution_group_finished(const ExecutionGroup * /*group*/)
+{
+}
+void DebugInfo::graphviz(const ExecutionSystem * /*system*/)
+{
+}
#endif
diff --git a/source/blender/compositor/intern/COM_Debug.h b/source/blender/compositor/intern/COM_Debug.h
index 955bcf120cc..250f360fa35 100644
--- a/source/blender/compositor/intern/COM_Debug.h
+++ b/source/blender/compositor/intern/COM_Debug.h
@@ -30,49 +30,51 @@ class ExecutionSystem;
class ExecutionGroup;
class DebugInfo {
-public:
- typedef enum {
- EG_WAIT,
- EG_RUNNING,
- EG_FINISHED
- } GroupState;
+ public:
+ typedef enum { EG_WAIT, EG_RUNNING, EG_FINISHED } GroupState;
- typedef std::map<const Node *, std::string> NodeNameMap;
- typedef std::map<const NodeOperation *, std::string> OpNameMap;
- typedef std::map<const ExecutionGroup *, GroupState> GroupStateMap;
+ typedef std::map<const Node *, std::string> NodeNameMap;
+ typedef std::map<const NodeOperation *, std::string> OpNameMap;
+ typedef std::map<const ExecutionGroup *, GroupState> GroupStateMap;
- static std::string node_name(const Node *node);
- static std::string operation_name(const NodeOperation *op);
+ static std::string node_name(const Node *node);
+ static std::string operation_name(const NodeOperation *op);
- static void convert_started();
- static void execute_started(const ExecutionSystem *system);
+ static void convert_started();
+ static void execute_started(const ExecutionSystem *system);
- static void node_added(const Node *node);
- static void node_to_operations(const Node *node);
- static void operation_added(const NodeOperation *operation);
- static void operation_read_write_buffer(const NodeOperation *operation);
+ static void node_added(const Node *node);
+ static void node_to_operations(const Node *node);
+ static void operation_added(const NodeOperation *operation);
+ static void operation_read_write_buffer(const NodeOperation *operation);
- static void execution_group_started(const ExecutionGroup *group);
- static void execution_group_finished(const ExecutionGroup *group);
+ static void execution_group_started(const ExecutionGroup *group);
+ static void execution_group_finished(const ExecutionGroup *group);
- static void graphviz(const ExecutionSystem *system);
+ static void graphviz(const ExecutionSystem *system);
#ifdef COM_DEBUG
-protected:
- static int graphviz_operation(const ExecutionSystem *system, const NodeOperation *operation, const ExecutionGroup *group, char *str, int maxlen);
- static int graphviz_legend_color(const char *name, const char *color, char *str, int maxlen);
- static int graphviz_legend_line(const char *name, const char *color, const char *style, char *str, int maxlen);
- static int graphviz_legend_group(const char *name, const char *color, const char *style, char *str, int maxlen);
- static int graphviz_legend(char *str, int maxlen);
- static bool graphviz_system(const ExecutionSystem *system, char *str, int maxlen);
+ protected:
+ static int graphviz_operation(const ExecutionSystem *system,
+ const NodeOperation *operation,
+ const ExecutionGroup *group,
+ char *str,
+ int maxlen);
+ static int graphviz_legend_color(const char *name, const char *color, char *str, int maxlen);
+ static int graphviz_legend_line(
+ const char *name, const char *color, const char *style, char *str, int maxlen);
+ static int graphviz_legend_group(
+ const char *name, const char *color, const char *style, char *str, int maxlen);
+ static int graphviz_legend(char *str, int maxlen);
+ static bool graphviz_system(const ExecutionSystem *system, char *str, int maxlen);
-private:
- static int m_file_index;
- static NodeNameMap m_node_names; /**< map nodes to usable names for debug output */
- static OpNameMap m_op_names; /**< map operations to usable names for debug output */
- static std::string m_current_node_name; /**< base name for all operations added by a node */
- static std::string m_current_op_name; /**< base name for automatic sub-operations */
- static GroupStateMap m_group_states; /**< for visualizing group states */
+ private:
+ static int m_file_index;
+ static NodeNameMap m_node_names; /**< map nodes to usable names for debug output */
+ static OpNameMap m_op_names; /**< map operations to usable names for debug output */
+ static std::string m_current_node_name; /**< base name for all operations added by a node */
+ static std::string m_current_op_name; /**< base name for automatic sub-operations */
+ static GroupStateMap m_group_states; /**< for visualizing group states */
#endif
};
diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h
index 6767a475c82..8573f69658e 100644
--- a/source/blender/compositor/intern/COM_Device.h
+++ b/source/blender/compositor/intern/COM_Device.h
@@ -28,31 +28,38 @@
*/
class Device {
-public:
- /**
- * \brief Declaration of the virtual destructor
- * \note resolve warning gcc 4.7
- */
- virtual ~Device() {}
-
- /**
- * \brief initialize the device
- */
- virtual bool initialize() { return true; }
-
- /**
- * \brief deinitialize the device
- */
- virtual void deinitialize() {}
-
- /**
- * \brief execute a WorkPackage
- * \param work: the WorkPackage to execute
- */
- virtual void execute(WorkPackage *work) = 0;
+ public:
+ /**
+ * \brief Declaration of the virtual destructor
+ * \note resolve warning gcc 4.7
+ */
+ virtual ~Device()
+ {
+ }
+
+ /**
+ * \brief initialize the device
+ */
+ virtual bool initialize()
+ {
+ return true;
+ }
+
+ /**
+ * \brief deinitialize the device
+ */
+ virtual void deinitialize()
+ {
+ }
+
+ /**
+ * \brief execute a WorkPackage
+ * \param work: the WorkPackage to execute
+ */
+ virtual void execute(WorkPackage *work) = 0;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:Device")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:Device")
#endif
};
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
index f636a211ff6..50caf51cf48 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp
@@ -43,135 +43,147 @@
ExecutionGroup::ExecutionGroup()
{
- this->m_isOutput = false;
- this->m_complex = false;
- this->m_chunkExecutionStates = NULL;
- this->m_bTree = NULL;
- this->m_height = 0;
- this->m_width = 0;
- this->m_cachedMaxReadBufferOffset = 0;
- this->m_numberOfXChunks = 0;
- this->m_numberOfYChunks = 0;
- this->m_numberOfChunks = 0;
- this->m_initialized = false;
- this->m_openCL = false;
- this->m_singleThreaded = false;
- this->m_chunksFinished = 0;
- BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
- this->m_executionStartTime = 0;
+ this->m_isOutput = false;
+ this->m_complex = false;
+ this->m_chunkExecutionStates = NULL;
+ this->m_bTree = NULL;
+ this->m_height = 0;
+ this->m_width = 0;
+ this->m_cachedMaxReadBufferOffset = 0;
+ this->m_numberOfXChunks = 0;
+ this->m_numberOfYChunks = 0;
+ this->m_numberOfChunks = 0;
+ this->m_initialized = false;
+ this->m_openCL = false;
+ this->m_singleThreaded = false;
+ this->m_chunksFinished = 0;
+ BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
+ this->m_executionStartTime = 0;
}
CompositorPriority ExecutionGroup::getRenderPriotrity()
{
- return this->getOutputOperation()->getRenderPriority();
+ return this->getOutputOperation()->getRenderPriority();
}
bool ExecutionGroup::canContainOperation(NodeOperation *operation)
{
- if (!this->m_initialized) { return true; }
-
- if (operation->isReadBufferOperation()) { return true; }
- if (operation->isWriteBufferOperation()) { return false; }
- if (operation->isSetOperation()) { return true; }
-
- /* complex groups don't allow further ops (except read buffer and values, see above) */
- if (m_complex) { return false; }
- /* complex ops can't be added to other groups (except their own, which they initialize, see above) */
- if (operation->isComplex()) { return false; }
-
- return true;
+ if (!this->m_initialized) {
+ return true;
+ }
+
+ if (operation->isReadBufferOperation()) {
+ return true;
+ }
+ if (operation->isWriteBufferOperation()) {
+ return false;
+ }
+ if (operation->isSetOperation()) {
+ return true;
+ }
+
+ /* complex groups don't allow further ops (except read buffer and values, see above) */
+ if (m_complex) {
+ return false;
+ }
+ /* complex ops can't be added to other groups (except their own, which they initialize, see above) */
+ if (operation->isComplex()) {
+ return false;
+ }
+
+ return true;
}
bool ExecutionGroup::addOperation(NodeOperation *operation)
{
- if (!canContainOperation(operation))
- return false;
+ if (!canContainOperation(operation))
+ return false;
- if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
- m_complex = operation->isComplex();
- m_openCL = operation->isOpenCL();
- m_singleThreaded = operation->isSingleThreaded();
- m_initialized = true;
- }
+ if (!operation->isReadBufferOperation() && !operation->isWriteBufferOperation()) {
+ m_complex = operation->isComplex();
+ m_openCL = operation->isOpenCL();
+ m_singleThreaded = operation->isSingleThreaded();
+ m_initialized = true;
+ }
- m_operations.push_back(operation);
+ m_operations.push_back(operation);
- return true;
+ return true;
}
NodeOperation *ExecutionGroup::getOutputOperation() const
{
- return this->m_operations[0]; // the first operation of the group is always the output operation.
+ return this
+ ->m_operations[0]; // the first operation of the group is always the output operation.
}
void ExecutionGroup::initExecution()
{
- if (this->m_chunkExecutionStates != NULL) {
- MEM_freeN(this->m_chunkExecutionStates);
- }
- unsigned int index;
- determineNumberOfChunks();
-
- this->m_chunkExecutionStates = NULL;
- if (this->m_numberOfChunks != 0) {
- this->m_chunkExecutionStates = (ChunkExecutionState *)MEM_mallocN(sizeof(ChunkExecutionState) * this->m_numberOfChunks, __func__);
- for (index = 0; index < this->m_numberOfChunks; index++) {
- this->m_chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED;
- }
- }
-
-
- unsigned int maxNumber = 0;
-
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
- this->m_cachedReadOperations.push_back(readOperation);
- maxNumber = max(maxNumber, readOperation->getOffset());
- }
- }
- maxNumber++;
- this->m_cachedMaxReadBufferOffset = maxNumber;
-
+ if (this->m_chunkExecutionStates != NULL) {
+ MEM_freeN(this->m_chunkExecutionStates);
+ }
+ unsigned int index;
+ determineNumberOfChunks();
+
+ this->m_chunkExecutionStates = NULL;
+ if (this->m_numberOfChunks != 0) {
+ this->m_chunkExecutionStates = (ChunkExecutionState *)MEM_mallocN(
+ sizeof(ChunkExecutionState) * this->m_numberOfChunks, __func__);
+ for (index = 0; index < this->m_numberOfChunks; index++) {
+ this->m_chunkExecutionStates[index] = COM_ES_NOT_SCHEDULED;
+ }
+ }
+
+ unsigned int maxNumber = 0;
+
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
+ this->m_cachedReadOperations.push_back(readOperation);
+ maxNumber = max(maxNumber, readOperation->getOffset());
+ }
+ }
+ maxNumber++;
+ this->m_cachedMaxReadBufferOffset = maxNumber;
}
void ExecutionGroup::deinitExecution()
{
- if (this->m_chunkExecutionStates != NULL) {
- MEM_freeN(this->m_chunkExecutionStates);
- this->m_chunkExecutionStates = NULL;
- }
- this->m_numberOfChunks = 0;
- this->m_numberOfXChunks = 0;
- this->m_numberOfYChunks = 0;
- this->m_cachedReadOperations.clear();
- this->m_bTree = NULL;
+ if (this->m_chunkExecutionStates != NULL) {
+ MEM_freeN(this->m_chunkExecutionStates);
+ this->m_chunkExecutionStates = NULL;
+ }
+ this->m_numberOfChunks = 0;
+ this->m_numberOfXChunks = 0;
+ this->m_numberOfYChunks = 0;
+ this->m_cachedReadOperations.clear();
+ this->m_bTree = NULL;
}
void ExecutionGroup::determineResolution(unsigned int resolution[2])
{
- NodeOperation *operation = this->getOutputOperation();
- resolution[0] = operation->getWidth();
- resolution[1] = operation->getHeight();
- this->setResolution(resolution);
- BLI_rcti_init(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height);
+ NodeOperation *operation = this->getOutputOperation();
+ resolution[0] = operation->getWidth();
+ resolution[1] = operation->getHeight();
+ this->setResolution(resolution);
+ BLI_rcti_init(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height);
}
void ExecutionGroup::determineNumberOfChunks()
{
- if (this->m_singleThreaded) {
- this->m_numberOfXChunks = 1;
- this->m_numberOfYChunks = 1;
- this->m_numberOfChunks = 1;
- }
- else {
- const float chunkSizef = this->m_chunkSize;
- const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
- const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
- this->m_numberOfXChunks = ceil(border_width / chunkSizef);
- this->m_numberOfYChunks = ceil(border_height / chunkSizef);
- this->m_numberOfChunks = this->m_numberOfXChunks * this->m_numberOfYChunks;
- }
+ if (this->m_singleThreaded) {
+ this->m_numberOfXChunks = 1;
+ this->m_numberOfYChunks = 1;
+ this->m_numberOfChunks = 1;
+ }
+ else {
+ const float chunkSizef = this->m_chunkSize;
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+ this->m_numberOfXChunks = ceil(border_width / chunkSizef);
+ this->m_numberOfYChunks = ceil(border_height / chunkSizef);
+ this->m_numberOfChunks = this->m_numberOfXChunks * this->m_numberOfYChunks;
+ }
}
/**
@@ -179,422 +191,452 @@ void ExecutionGroup::determineNumberOfChunks()
*/
void ExecutionGroup::execute(ExecutionSystem *graph)
{
- const CompositorContext &context = graph->getContext();
- const bNodeTree *bTree = context.getbNodeTree();
- if (this->m_width == 0 || this->m_height == 0) {return; } /// \note: break out... no pixels to calculate.
- if (bTree->test_break && bTree->test_break(bTree->tbh)) {return; } /// \note: early break out for blur and preview nodes
- if (this->m_numberOfChunks == 0) {return; } /// \note: early break out
- unsigned int chunkNumber;
-
- this->m_executionStartTime = PIL_check_seconds_timer();
-
- this->m_chunksFinished = 0;
- this->m_bTree = bTree;
- unsigned int index;
- unsigned int *chunkOrder = (unsigned int *)MEM_mallocN(sizeof(unsigned int) * this->m_numberOfChunks, __func__);
-
- for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) {
- chunkOrder[chunkNumber] = chunkNumber;
- }
- NodeOperation *operation = this->getOutputOperation();
- float centerX = 0.5;
- float centerY = 0.5;
- OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
-
- if (operation->isViewerOperation()) {
- ViewerOperation *viewer = (ViewerOperation *)operation;
- centerX = viewer->getCenterX();
- centerY = viewer->getCenterY();
- chunkorder = viewer->getChunkOrder();
- }
-
- const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
- const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
-
- switch (chunkorder) {
- case COM_TO_RANDOM:
- for (index = 0; index < 2 * this->m_numberOfChunks; index++) {
- int index1 = rand() % this->m_numberOfChunks;
- int index2 = rand() % this->m_numberOfChunks;
- int s = chunkOrder[index1];
- chunkOrder[index1] = chunkOrder[index2];
- chunkOrder[index2] = s;
- }
- break;
- case COM_TO_CENTER_OUT:
- {
- ChunkOrderHotspot *hotspots[1];
- hotspots[0] = new ChunkOrderHotspot(border_width * centerX, border_height * centerY, 0.0f);
- rcti rect;
- ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
- for (index = 0; index < this->m_numberOfChunks; index++) {
- determineChunkRect(&rect, index);
- chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
- chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
- chunkOrders[index].determineDistance(hotspots, 1);
- }
-
- std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks - 1]);
- for (index = 0; index < this->m_numberOfChunks; index++) {
- chunkOrder[index] = chunkOrders[index].getChunkNumber();
- }
-
- delete hotspots[0];
- MEM_freeN(chunkOrders);
- break;
- }
- case COM_TO_RULE_OF_THIRDS:
- {
- ChunkOrderHotspot *hotspots[9];
- unsigned int tx = border_width / 6;
- unsigned int ty = border_height / 6;
- unsigned int mx = border_width / 2;
- unsigned int my = border_height / 2;
- unsigned int bx = mx + 2 * tx;
- unsigned int by = my + 2 * ty;
-
- float addition = this->m_numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER;
- hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0);
- hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1);
- hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2);
- hotspots[3] = new ChunkOrderHotspot(bx, by, addition * 3);
- hotspots[4] = new ChunkOrderHotspot(tx, ty, addition * 4);
- hotspots[5] = new ChunkOrderHotspot(bx, ty, addition * 5);
- hotspots[6] = new ChunkOrderHotspot(tx, by, addition * 6);
- hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7);
- hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8);
- rcti rect;
- ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
- for (index = 0; index < this->m_numberOfChunks; index++) {
- determineChunkRect(&rect, index);
- chunkOrders[index].setChunkNumber(index);
- chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
- chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
- chunkOrders[index].determineDistance(hotspots, 9);
- }
-
- std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks]);
-
- for (index = 0; index < this->m_numberOfChunks; index++) {
- chunkOrder[index] = chunkOrders[index].getChunkNumber();
- }
-
- delete hotspots[0];
- delete hotspots[1];
- delete hotspots[2];
- delete hotspots[3];
- delete hotspots[4];
- delete hotspots[5];
- delete hotspots[6];
- delete hotspots[7];
- delete hotspots[8];
- MEM_freeN(chunkOrders);
- break;
- }
- case COM_TO_TOP_DOWN:
- default:
- break;
- }
-
- DebugInfo::execution_group_started(this);
- DebugInfo::graphviz(graph);
-
- bool breaked = false;
- bool finished = false;
- unsigned int startIndex = 0;
- const int maxNumberEvaluated = BLI_system_thread_count() * 2;
-
- while (!finished && !breaked) {
- bool startEvaluated = false;
- finished = true;
- int numberEvaluated = 0;
-
- for (index = startIndex; index < this->m_numberOfChunks && numberEvaluated < maxNumberEvaluated; index++) {
- chunkNumber = chunkOrder[index];
- int yChunk = chunkNumber / this->m_numberOfXChunks;
- int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks);
- const ChunkExecutionState state = this->m_chunkExecutionStates[chunkNumber];
- if (state == COM_ES_NOT_SCHEDULED) {
- scheduleChunkWhenPossible(graph, xChunk, yChunk);
- finished = false;
- startEvaluated = true;
- numberEvaluated++;
-
- if (bTree->update_draw)
- bTree->update_draw(bTree->udh);
- }
- else if (state == COM_ES_SCHEDULED) {
- finished = false;
- startEvaluated = true;
- numberEvaluated++;
- }
- else if (state == COM_ES_EXECUTED && !startEvaluated) {
- startIndex = index + 1;
- }
- }
-
- WorkScheduler::finish();
-
- if (bTree->test_break && bTree->test_break(bTree->tbh)) {
- breaked = true;
- }
- }
- DebugInfo::execution_group_finished(this);
- DebugInfo::graphviz(graph);
-
- MEM_freeN(chunkOrder);
+ const CompositorContext &context = graph->getContext();
+ const bNodeTree *bTree = context.getbNodeTree();
+ if (this->m_width == 0 || this->m_height == 0) {
+ return;
+ } /// \note: break out... no pixels to calculate.
+ if (bTree->test_break && bTree->test_break(bTree->tbh)) {
+ return;
+ } /// \note: early break out for blur and preview nodes
+ if (this->m_numberOfChunks == 0) {
+ return;
+ } /// \note: early break out
+ unsigned int chunkNumber;
+
+ this->m_executionStartTime = PIL_check_seconds_timer();
+
+ this->m_chunksFinished = 0;
+ this->m_bTree = bTree;
+ unsigned int index;
+ unsigned int *chunkOrder = (unsigned int *)MEM_mallocN(
+ sizeof(unsigned int) * this->m_numberOfChunks, __func__);
+
+ for (chunkNumber = 0; chunkNumber < this->m_numberOfChunks; chunkNumber++) {
+ chunkOrder[chunkNumber] = chunkNumber;
+ }
+ NodeOperation *operation = this->getOutputOperation();
+ float centerX = 0.5;
+ float centerY = 0.5;
+ OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
+
+ if (operation->isViewerOperation()) {
+ ViewerOperation *viewer = (ViewerOperation *)operation;
+ centerX = viewer->getCenterX();
+ centerY = viewer->getCenterY();
+ chunkorder = viewer->getChunkOrder();
+ }
+
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+
+ switch (chunkorder) {
+ case COM_TO_RANDOM:
+ for (index = 0; index < 2 * this->m_numberOfChunks; index++) {
+ int index1 = rand() % this->m_numberOfChunks;
+ int index2 = rand() % this->m_numberOfChunks;
+ int s = chunkOrder[index1];
+ chunkOrder[index1] = chunkOrder[index2];
+ chunkOrder[index2] = s;
+ }
+ break;
+ case COM_TO_CENTER_OUT: {
+ ChunkOrderHotspot *hotspots[1];
+ hotspots[0] = new ChunkOrderHotspot(border_width * centerX, border_height * centerY, 0.0f);
+ rcti rect;
+ ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(
+ sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
+ for (index = 0; index < this->m_numberOfChunks; index++) {
+ determineChunkRect(&rect, index);
+ chunkOrders[index].setChunkNumber(index);
+ chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
+ chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
+ chunkOrders[index].determineDistance(hotspots, 1);
+ }
+
+ std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks - 1]);
+ for (index = 0; index < this->m_numberOfChunks; index++) {
+ chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ }
+
+ delete hotspots[0];
+ MEM_freeN(chunkOrders);
+ break;
+ }
+ case COM_TO_RULE_OF_THIRDS: {
+ ChunkOrderHotspot *hotspots[9];
+ unsigned int tx = border_width / 6;
+ unsigned int ty = border_height / 6;
+ unsigned int mx = border_width / 2;
+ unsigned int my = border_height / 2;
+ unsigned int bx = mx + 2 * tx;
+ unsigned int by = my + 2 * ty;
+
+ float addition = this->m_numberOfChunks / COM_RULE_OF_THIRDS_DIVIDER;
+ hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0);
+ hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1);
+ hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2);
+ hotspots[3] = new ChunkOrderHotspot(bx, by, addition * 3);
+ hotspots[4] = new ChunkOrderHotspot(tx, ty, addition * 4);
+ hotspots[5] = new ChunkOrderHotspot(bx, ty, addition * 5);
+ hotspots[6] = new ChunkOrderHotspot(tx, by, addition * 6);
+ hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7);
+ hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8);
+ rcti rect;
+ ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(
+ sizeof(ChunkOrder) * this->m_numberOfChunks, __func__);
+ for (index = 0; index < this->m_numberOfChunks; index++) {
+ determineChunkRect(&rect, index);
+ chunkOrders[index].setChunkNumber(index);
+ chunkOrders[index].setX(rect.xmin - this->m_viewerBorder.xmin);
+ chunkOrders[index].setY(rect.ymin - this->m_viewerBorder.ymin);
+ chunkOrders[index].determineDistance(hotspots, 9);
+ }
+
+ std::sort(&chunkOrders[0], &chunkOrders[this->m_numberOfChunks]);
+
+ for (index = 0; index < this->m_numberOfChunks; index++) {
+ chunkOrder[index] = chunkOrders[index].getChunkNumber();
+ }
+
+ delete hotspots[0];
+ delete hotspots[1];
+ delete hotspots[2];
+ delete hotspots[3];
+ delete hotspots[4];
+ delete hotspots[5];
+ delete hotspots[6];
+ delete hotspots[7];
+ delete hotspots[8];
+ MEM_freeN(chunkOrders);
+ break;
+ }
+ case COM_TO_TOP_DOWN:
+ default:
+ break;
+ }
+
+ DebugInfo::execution_group_started(this);
+ DebugInfo::graphviz(graph);
+
+ bool breaked = false;
+ bool finished = false;
+ unsigned int startIndex = 0;
+ const int maxNumberEvaluated = BLI_system_thread_count() * 2;
+
+ while (!finished && !breaked) {
+ bool startEvaluated = false;
+ finished = true;
+ int numberEvaluated = 0;
+
+ for (index = startIndex;
+ index < this->m_numberOfChunks && numberEvaluated < maxNumberEvaluated;
+ index++) {
+ chunkNumber = chunkOrder[index];
+ int yChunk = chunkNumber / this->m_numberOfXChunks;
+ int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks);
+ const ChunkExecutionState state = this->m_chunkExecutionStates[chunkNumber];
+ if (state == COM_ES_NOT_SCHEDULED) {
+ scheduleChunkWhenPossible(graph, xChunk, yChunk);
+ finished = false;
+ startEvaluated = true;
+ numberEvaluated++;
+
+ if (bTree->update_draw)
+ bTree->update_draw(bTree->udh);
+ }
+ else if (state == COM_ES_SCHEDULED) {
+ finished = false;
+ startEvaluated = true;
+ numberEvaluated++;
+ }
+ else if (state == COM_ES_EXECUTED && !startEvaluated) {
+ startIndex = index + 1;
+ }
+ }
+
+ WorkScheduler::finish();
+
+ if (bTree->test_break && bTree->test_break(bTree->tbh)) {
+ breaked = true;
+ }
+ }
+ DebugInfo::execution_group_finished(this);
+ DebugInfo::graphviz(graph);
+
+ MEM_freeN(chunkOrder);
}
MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
{
- rcti rect;
- vector<MemoryProxy *> memoryproxies;
- unsigned int index;
- determineChunkRect(&rect, chunkNumber);
-
- this->determineDependingMemoryProxies(&memoryproxies);
- MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(sizeof(MemoryBuffer *) * this->m_cachedMaxReadBufferOffset, __func__);
- rcti output;
- for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index];
- MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
- this->determineDependingAreaOfInterest(&rect, readOperation, &output);
- MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(memoryProxy, &output);
- memoryBuffers[readOperation->getOffset()] = memoryBuffer;
- }
- return memoryBuffers;
+ rcti rect;
+ vector<MemoryProxy *> memoryproxies;
+ unsigned int index;
+ determineChunkRect(&rect, chunkNumber);
+
+ this->determineDependingMemoryProxies(&memoryproxies);
+ MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(
+ sizeof(MemoryBuffer *) * this->m_cachedMaxReadBufferOffset, __func__);
+ rcti output;
+ for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation =
+ (ReadBufferOperation *)this->m_cachedReadOperations[index];
+ MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
+ this->determineDependingAreaOfInterest(&rect, readOperation, &output);
+ MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(
+ memoryProxy, &output);
+ memoryBuffers[readOperation->getOffset()] = memoryBuffer;
+ }
+ return memoryBuffers;
}
-MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
+MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy,
+ rcti *rect)
{
- MemoryBuffer *imageBuffer = memoryProxy->getBuffer();
- MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect);
- result->copyContentFrom(imageBuffer);
- return result;
+ MemoryBuffer *imageBuffer = memoryProxy->getBuffer();
+ MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect);
+ result->copyContentFrom(imageBuffer);
+ return result;
}
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
{
- if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
- this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
-
- atomic_add_and_fetch_u(&this->m_chunksFinished, 1);
- if (memoryBuffers) {
- for (unsigned int index = 0; index < this->m_cachedMaxReadBufferOffset; index++) {
- MemoryBuffer *buffer = memoryBuffers[index];
- if (buffer) {
- if (buffer->isTemporarily()) {
- memoryBuffers[index] = NULL;
- delete buffer;
- }
- }
- }
- MEM_freeN(memoryBuffers);
- }
- if (this->m_bTree) {
- // status report is only performed for top level Execution Groups.
- float progress = this->m_chunksFinished;
- progress /= this->m_numberOfChunks;
- this->m_bTree->progress(this->m_bTree->prh, progress);
-
- char buf[128];
- BLI_snprintf(buf, sizeof(buf), IFACE_("Compositing | Tile %u-%u"),
- this->m_chunksFinished,
- this->m_numberOfChunks);
- this->m_bTree->stats_draw(this->m_bTree->sdh, buf);
- }
+ if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED)
+ this->m_chunkExecutionStates[chunkNumber] = COM_ES_EXECUTED;
+
+ atomic_add_and_fetch_u(&this->m_chunksFinished, 1);
+ if (memoryBuffers) {
+ for (unsigned int index = 0; index < this->m_cachedMaxReadBufferOffset; index++) {
+ MemoryBuffer *buffer = memoryBuffers[index];
+ if (buffer) {
+ if (buffer->isTemporarily()) {
+ memoryBuffers[index] = NULL;
+ delete buffer;
+ }
+ }
+ }
+ MEM_freeN(memoryBuffers);
+ }
+ if (this->m_bTree) {
+ // status report is only performed for top level Execution Groups.
+ float progress = this->m_chunksFinished;
+ progress /= this->m_numberOfChunks;
+ this->m_bTree->progress(this->m_bTree->prh, progress);
+
+ char buf[128];
+ BLI_snprintf(buf,
+ sizeof(buf),
+ IFACE_("Compositing | Tile %u-%u"),
+ this->m_chunksFinished,
+ this->m_numberOfChunks);
+ this->m_bTree->stats_draw(this->m_bTree->sdh, buf);
+ }
}
-inline void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const
+inline void ExecutionGroup::determineChunkRect(rcti *rect,
+ const unsigned int xChunk,
+ const unsigned int yChunk) const
{
- const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
- const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
-
- if (this->m_singleThreaded) {
- BLI_rcti_init(rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
- }
- else {
- const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
- const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
- const unsigned int width = min((unsigned int) this->m_viewerBorder.xmax, this->m_width);
- const unsigned int height = min((unsigned int) this->m_viewerBorder.ymax, this->m_height);
- BLI_rcti_init(rect, min(minx, this->m_width), min(minx + this->m_chunkSize, width), min(miny, this->m_height), min(miny + this->m_chunkSize, height));
- }
+ const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
+ const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
+
+ if (this->m_singleThreaded) {
+ BLI_rcti_init(
+ rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
+ }
+ else {
+ const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
+ const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
+ const unsigned int width = min((unsigned int)this->m_viewerBorder.xmax, this->m_width);
+ const unsigned int height = min((unsigned int)this->m_viewerBorder.ymax, this->m_height);
+ BLI_rcti_init(rect,
+ min(minx, this->m_width),
+ min(minx + this->m_chunkSize, width),
+ min(miny, this->m_height),
+ min(miny + this->m_chunkSize, height));
+ }
}
void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumber) const
{
- const unsigned int yChunk = chunkNumber / this->m_numberOfXChunks;
- const unsigned int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks);
- determineChunkRect(rect, xChunk, yChunk);
+ const unsigned int yChunk = chunkNumber / this->m_numberOfXChunks;
+ const unsigned int xChunk = chunkNumber - (yChunk * this->m_numberOfXChunks);
+ determineChunkRect(rect, xChunk, yChunk);
}
-MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int /*chunkNumber*/,
- rcti *rect)
+MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int /*chunkNumber*/, rcti *rect)
{
- // we assume that this method is only called from complex execution groups.
- NodeOperation *operation = this->getOutputOperation();
- if (operation->isWriteBufferOperation()) {
- WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
- MemoryBuffer *buffer = new MemoryBuffer(writeOperation->getMemoryProxy(), rect);
- return buffer;
- }
- return NULL;
+ // we assume that this method is only called from complex execution groups.
+ NodeOperation *operation = this->getOutputOperation();
+ if (operation->isWriteBufferOperation()) {
+ WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
+ MemoryBuffer *buffer = new MemoryBuffer(writeOperation->getMemoryProxy(), rect);
+ return buffer;
+ }
+ return NULL;
}
-
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
{
- if (this->m_singleThreaded) {
- return scheduleChunkWhenPossible(graph, 0, 0);
- }
- // find all chunks inside the rect
- // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
-
- int indexx, indexy;
- int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0);
- int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin);
- int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0);
- int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin);
- int minxchunk = minx / (int)m_chunkSize;
- int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize;
- int minychunk = miny / (int)m_chunkSize;
- int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize;
- minxchunk = max_ii(minxchunk, 0);
- minychunk = max_ii(minychunk, 0);
- maxxchunk = min_ii(maxxchunk, (int)m_numberOfXChunks);
- maxychunk = min_ii(maxychunk, (int)m_numberOfYChunks);
-
- bool result = true;
- for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
- for (indexy = minychunk; indexy < maxychunk; indexy++) {
- if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
- result = false;
- }
- }
- }
-
- return result;
+ if (this->m_singleThreaded) {
+ return scheduleChunkWhenPossible(graph, 0, 0);
+ }
+ // find all chunks inside the rect
+ // determine minxchunk, minychunk, maxxchunk, maxychunk where x and y are chunknumbers
+
+ int indexx, indexy;
+ int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0);
+ int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin);
+ int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0);
+ int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin);
+ int minxchunk = minx / (int)m_chunkSize;
+ int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize;
+ int minychunk = miny / (int)m_chunkSize;
+ int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize;
+ minxchunk = max_ii(minxchunk, 0);
+ minychunk = max_ii(minychunk, 0);
+ maxxchunk = min_ii(maxxchunk, (int)m_numberOfXChunks);
+ maxychunk = min_ii(maxychunk, (int)m_numberOfYChunks);
+
+ bool result = true;
+ for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
+ for (indexy = minychunk; indexy < maxychunk; indexy++) {
+ if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
+ result = false;
+ }
+ }
+ }
+
+ return result;
}
bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
{
- if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) {
- this->m_chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED;
- WorkScheduler::schedule(this, chunkNumber);
- return true;
- }
- return false;
+ if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_NOT_SCHEDULED) {
+ this->m_chunkExecutionStates[chunkNumber] = COM_ES_SCHEDULED;
+ WorkScheduler::schedule(this, chunkNumber);
+ return true;
+ }
+ return false;
}
bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk)
{
- if (xChunk < 0 || xChunk >= (int)this->m_numberOfXChunks) {
- return true;
- }
- if (yChunk < 0 || yChunk >= (int)this->m_numberOfYChunks) {
- return true;
- }
- int chunkNumber = yChunk * this->m_numberOfXChunks + xChunk;
- // chunk is already executed
- if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) {
- return true;
- }
-
- // chunk is scheduled, but not executed
- if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) {
- return false;
- }
-
- // chunk is nor executed nor scheduled.
- vector<MemoryProxy *> memoryProxies;
- this->determineDependingMemoryProxies(&memoryProxies);
-
- rcti rect;
- determineChunkRect(&rect, xChunk, yChunk);
- unsigned int index;
- bool canBeExecuted = true;
- rcti area;
-
- for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)this->m_cachedReadOperations[index];
- BLI_rcti_init(&area, 0, 0, 0, 0);
- MemoryProxy *memoryProxy = memoryProxies[index];
- determineDependingAreaOfInterest(&rect, readOperation, &area);
- ExecutionGroup *group = memoryProxy->getExecutor();
-
- if (group != NULL) {
- if (!group->scheduleAreaWhenPossible(graph, &area)) {
- canBeExecuted = false;
- }
- }
- else {
- throw "ERROR";
- }
- }
-
- if (canBeExecuted) {
- scheduleChunk(chunkNumber);
- }
-
- return false;
+ if (xChunk < 0 || xChunk >= (int)this->m_numberOfXChunks) {
+ return true;
+ }
+ if (yChunk < 0 || yChunk >= (int)this->m_numberOfYChunks) {
+ return true;
+ }
+ int chunkNumber = yChunk * this->m_numberOfXChunks + xChunk;
+ // chunk is already executed
+ if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_EXECUTED) {
+ return true;
+ }
+
+ // chunk is scheduled, but not executed
+ if (this->m_chunkExecutionStates[chunkNumber] == COM_ES_SCHEDULED) {
+ return false;
+ }
+
+ // chunk is nor executed nor scheduled.
+ vector<MemoryProxy *> memoryProxies;
+ this->determineDependingMemoryProxies(&memoryProxies);
+
+ rcti rect;
+ determineChunkRect(&rect, xChunk, yChunk);
+ unsigned int index;
+ bool canBeExecuted = true;
+ rcti area;
+
+ for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation =
+ (ReadBufferOperation *)this->m_cachedReadOperations[index];
+ BLI_rcti_init(&area, 0, 0, 0, 0);
+ MemoryProxy *memoryProxy = memoryProxies[index];
+ determineDependingAreaOfInterest(&rect, readOperation, &area);
+ ExecutionGroup *group = memoryProxy->getExecutor();
+
+ if (group != NULL) {
+ if (!group->scheduleAreaWhenPossible(graph, &area)) {
+ canBeExecuted = false;
+ }
+ }
+ else {
+ throw "ERROR";
+ }
+ }
+
+ if (canBeExecuted) {
+ scheduleChunk(chunkNumber);
+ }
+
+ return false;
}
-void ExecutionGroup::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+void ExecutionGroup::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
+ this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
}
void ExecutionGroup::determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies)
{
- unsigned int index;
- for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *) this->m_cachedReadOperations[index];
- memoryProxies->push_back(readOperation->getMemoryProxy());
- }
+ unsigned int index;
+ for (index = 0; index < this->m_cachedReadOperations.size(); index++) {
+ ReadBufferOperation *readOperation =
+ (ReadBufferOperation *)this->m_cachedReadOperations[index];
+ memoryProxies->push_back(readOperation->getMemoryProxy());
+ }
}
bool ExecutionGroup::isOpenCL()
{
- return this->m_openCL;
+ return this->m_openCL;
}
void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax)
{
- NodeOperation *operation = this->getOutputOperation();
-
- if (operation->isViewerOperation() || operation->isPreviewOperation()) {
- BLI_rcti_init(&this->m_viewerBorder, xmin * this->m_width, xmax * this->m_width,
- ymin * this->m_height, ymax * this->m_height);
- }
+ NodeOperation *operation = this->getOutputOperation();
+
+ if (operation->isViewerOperation() || operation->isPreviewOperation()) {
+ BLI_rcti_init(&this->m_viewerBorder,
+ xmin * this->m_width,
+ xmax * this->m_width,
+ ymin * this->m_height,
+ ymax * this->m_height);
+ }
}
void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float ymax)
{
- NodeOperation *operation = this->getOutputOperation();
-
- if (operation->isOutputOperation(true)) {
- /* Basically, setting border need to happen for only operations
- * which operates in render resolution buffers (like compositor
- * output nodes).
- *
- * In this cases adding border will lead to mapping coordinates
- * from output buffer space to input buffer spaces when executing
- * operation.
- *
- * But nodes like viewer and file output just shall display or
- * safe the same exact buffer which goes to their input, no need
- * in any kind of coordinates mapping.
- */
-
- bool operationNeedsBorder = !(operation->isViewerOperation() ||
- operation->isPreviewOperation() ||
- operation->isFileOutputOperation());
-
- if (operationNeedsBorder) {
- BLI_rcti_init(&this->m_viewerBorder, xmin * this->m_width, xmax * this->m_width,
- ymin * this->m_height, ymax * this->m_height);
- }
- }
+ NodeOperation *operation = this->getOutputOperation();
+
+ if (operation->isOutputOperation(true)) {
+ /* Basically, setting border need to happen for only operations
+ * which operates in render resolution buffers (like compositor
+ * output nodes).
+ *
+ * In this cases adding border will lead to mapping coordinates
+ * from output buffer space to input buffer spaces when executing
+ * operation.
+ *
+ * But nodes like viewer and file output just shall display or
+ * safe the same exact buffer which goes to their input, no need
+ * in any kind of coordinates mapping.
+ */
+
+ bool operationNeedsBorder = !(operation->isViewerOperation() ||
+ operation->isPreviewOperation() ||
+ operation->isFileOutputOperation());
+
+ if (operationNeedsBorder) {
+ BLI_rcti_init(&this->m_viewerBorder,
+ xmin * this->m_width,
+ xmax * this->m_width,
+ ymin * this->m_height,
+ ymax * this->m_height);
+ }
+ }
}
diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h
index c7a371b226a..ff9ac5d0582 100644
--- a/source/blender/compositor/intern/COM_ExecutionGroup.h
+++ b/source/blender/compositor/intern/COM_ExecutionGroup.h
@@ -39,18 +39,18 @@ class Device;
* \ingroup Execution
*/
typedef enum ChunkExecutionState {
- /**
- * \brief chunk is not yet scheduled
- */
- COM_ES_NOT_SCHEDULED = 0,
- /**
- * \brief chunk is scheduled, but not yet executed
- */
- COM_ES_SCHEDULED = 1,
- /**
- * \brief chunk is executed.
- */
- COM_ES_EXECUTED = 2,
+ /**
+ * \brief chunk is not yet scheduled
+ */
+ COM_ES_NOT_SCHEDULED = 0,
+ /**
+ * \brief chunk is scheduled, but not yet executed
+ */
+ COM_ES_SCHEDULED = 1,
+ /**
+ * \brief chunk is executed.
+ */
+ COM_ES_EXECUTED = 2,
} ChunkExecutionState;
/**
@@ -59,361 +59,381 @@ typedef enum ChunkExecutionState {
* \ingroup Execution
*/
class ExecutionGroup {
-public:
- typedef std::vector<NodeOperation*> Operations;
-
-private:
- // fields
-
- /**
- * \brief list of operations in this ExecutionGroup
- */
- Operations m_operations;
-
- /**
- * \brief is this ExecutionGroup an input ExecutionGroup
- * an input execution group is a group that is at the end of the calculation (the output is important for the user)
- */
- int m_isOutput;
-
- /**
- * \brief Width of the output
- */
- unsigned int m_width;
-
- /**
- * \brief Height of the output
- */
- unsigned int m_height;
-
- /**
- * \brief size of a single chunk, being Width or of height
- * a chunk is always a square, except at the edges of the MemoryBuffer
- */
- unsigned int m_chunkSize;
-
- /**
- * \brief number of chunks in the x-axis
- */
- unsigned int m_numberOfXChunks;
-
- /**
- * \brief number of chunks in the y-axis
- */
- unsigned int m_numberOfYChunks;
-
- /**
- * \brief total number of chunks
- */
- unsigned int m_numberOfChunks;
-
- /**
- * \brief contains this ExecutionGroup a complex NodeOperation.
- */
- bool m_complex;
-
- /**
- * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
- */
- bool m_openCL;
-
- /**
- * \brief Is this Execution group SingleThreaded
- */
- bool m_singleThreaded;
-
- /**
- * \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
- * \note this is used to construct the MemoryBuffers that will be passed during execution.
- */
- unsigned int m_cachedMaxReadBufferOffset;
-
- /**
- * \brief a cached vector of all read operations in the execution group.
- */
- Operations m_cachedReadOperations;
-
- /**
- * \brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
- * \note can only be used to call the callbacks for progress, status and break
- */
- const bNodeTree *m_bTree;
-
- /**
- * \brief total number of chunks that have been calculated for this ExecutionGroup
- */
- unsigned int m_chunksFinished;
-
- /**
- * \brief the chunkExecutionStates holds per chunk the execution state. this state can be
- * - COM_ES_NOT_SCHEDULED: not scheduled
- * - COM_ES_SCHEDULED: scheduled
- * - COM_ES_EXECUTED: executed
- */
- ChunkExecutionState *m_chunkExecutionStates;
-
- /**
- * \brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
- * \note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
- * \note Operation containing the settings that is important for the ExecutiongGroup is added,
- * \note When this occurs, these settings are copied over from the node to the ExecutionGroup
- * \note and the Initialized flag is set to true.
- * \see complex
- * \see openCL
- */
- bool m_initialized;
-
- /**
- * \brief denotes boundary for border compositing
- * \note measured in pixel space
- */
- rcti m_viewerBorder;
-
- /**
- * \brief start time of execution
- */
- double m_executionStartTime;
-
- // methods
- /**
- * \brief check whether parameter operation can be added to the execution group
- * \param operation: the operation to be added
- */
- bool canContainOperation(NodeOperation *operation);
-
- /**
- * \brief calculate the actual chunk size of this execution group.
- * \note A chunk size is an unsigned int that is both the height and width of a chunk.
- * \note The chunk size will not be stored in the chunkSize field. This needs to be done
- * \note by the calling method.
- */
- unsigned int determineChunkSize();
-
-
- /**
- * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
- * \note Only gives useful results ater the determination of the chunksize
- * \see determineChunkSize()
- */
- void determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const;
-
- /**
- * \brief determine the number of chunks, based on the chunkSize, width and height.
- * \note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
- */
- void determineNumberOfChunks();
-
- /**
- * \brief try to schedule a specific chunk.
- * \note scheduling succeeds when all input requirements are met and the chunks hasn't been scheduled yet.
- * \param graph:
- * \param xChunk:
- * \param yChunk:
- * \return [true:false]
- * true: package(s) are scheduled
- * false: scheduling is deferred (depending workpackages are scheduled)
- */
- bool scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk);
-
- /**
- * \brief try to schedule a specific area.
- * \note Check if a certain area is available, when not available this are will be checked.
- * \note This method is called from other ExecutionGroup's.
- * \param graph:
- * \param rect:
- * \return [true:false]
- * true: package(s) are scheduled
- * false: scheduling is deferred (depending workpackages are scheduled)
- */
- bool scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *rect);
-
- /**
- * \brief add a chunk to the WorkScheduler.
- * \param chunknumber:
- */
- bool scheduleChunk(unsigned int chunkNumber);
-
- /**
- * \brief determine the area of interest of a certain input area
- * \note This method only evaluates a single ReadBufferOperation
- * \param input: the input area
- * \param readOperation: The ReadBufferOperation where the area needs to be evaluated
- * \param output: the area needed of the ReadBufferOperation. Result
- */
- void determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
-
-public:
- // constructors
- ExecutionGroup();
-
- // methods
- /**
- * \brief add an operation to this ExecutionGroup
- * \note this method will add input of the operations recursively
- * \note this method can create multiple ExecutionGroup's
- * \param system:
- * \param operation:
- * \return True if the operation was successfully added
- */
- bool addOperation(NodeOperation *operation);
-
- /**
- * \brief is this ExecutionGroup an output ExecutionGroup
- * \note An OutputExecution group are groups containing a
- * \note ViewerOperation, CompositeOperation, PreviewOperation.
- * \see NodeOperation.isOutputOperation
- */
- int isOutputExecutionGroup() const { return this->m_isOutput; }
-
- /**
- * \brief set whether this ExecutionGroup is an output
- * \param isOutput:
- */
- void setOutputExecutionGroup(int isOutput) { this->m_isOutput = isOutput; }
-
- /**
- * \brief determine the resolution of this ExecutionGroup
- * \param resolution:
- */
- void determineResolution(unsigned int resolution[2]);
-
- /**
- * \brief set the resolution of this executiongroup
- * \param resolution:
- */
- void setResolution(unsigned int resolution[2]) { this->m_width = resolution[0]; this->m_height = resolution[1]; }
-
- /**
- * \brief get the width of this execution group
- */
- unsigned int getWidth() const { return m_width; }
-
- /**
- * \brief get the height of this execution group
- */
- unsigned int getHeight() const { return m_height; }
-
- /**
- * \brief does this ExecutionGroup contains a complex NodeOperation
- */
- bool isComplex() const { return m_complex; }
-
-
- /**
- * \brief get the output operation of this ExecutionGroup
- * \return NodeOperation *output operation
- */
- NodeOperation *getOutputOperation() const;
-
- /**
- * \brief compose multiple chunks into a single chunk
- * \return Memorybuffer *consolidated chunk
- */
- MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
-
- /**
- * \brief initExecution is called just before the execution of the whole graph will be done.
- * \note The implementation will calculate the chunkSize of this execution group.
- */
- void initExecution();
-
- /**
- * \brief get all inputbuffers needed to calculate an chunk
- * \note all inputbuffers must be executed
- * \param chunkNumber: the chunk to be calculated
- * \return (MemoryBuffer **) the inputbuffers
- */
- MemoryBuffer **getInputBuffersCPU();
-
- /**
- * \brief get all inputbuffers needed to calculate an chunk
- * \note all inputbuffers must be executed
- * \param chunkNumber: the chunk to be calculated
- * \return (MemoryBuffer **) the inputbuffers
- */
- MemoryBuffer **getInputBuffersOpenCL(int chunkNumber);
-
- /**
- * \brief allocate the outputbuffer of a chunk
- * \param chunkNumber: the number of the chunk in the ExecutionGroup
- * \param rect: the rect of that chunk
- * \see determineChunkRect
- */
- MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
-
- /**
- * \brief after a chunk is executed the needed resources can be freed or unlocked.
- * \param chunknumber:
- * \param memorybuffers:
- */
- void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers);
-
- /**
- * \brief deinitExecution is called just after execution the whole graph.
- * \note It will release all needed resources
- */
- void deinitExecution();
-
-
- /**
- * \brief schedule an ExecutionGroup
- * \note this method will return when all chunks have been calculated, or the execution has breaked (by user)
- *
- * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
- * - ChunkOrdering
- * - CenterX
- * - CenterY
- *
- * After determining the order of the chunks the chunks will be scheduled
- *
- * \see ViewerOperation
- * \param system:
- */
- void execute(ExecutionSystem *system);
-
- /**
- * \brief this method determines the MemoryProxy's where this execution group depends on.
- * \note After this method determineDependingAreaOfInterest can be called to determine
- * \note the area of the MemoryProxy.creator that has to be executed.
- * \param memoryProxies: result
- */
- void determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies);
-
- /**
- * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
- * \note Only gives useful results ater the determination of the chunksize
- * \see determineChunkSize()
- */
- void determineChunkRect(rcti *rect, const unsigned int chunkNumber) const;
-
- /**
- * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
- * \see WorkScheduler.schedule
- */
- bool isOpenCL();
-
- void setChunksize(int chunksize) { this->m_chunkSize = chunksize; }
-
- /**
- * \brief get the Render priority of this ExecutionGroup
- * \see ExecutionSystem.execute
- */
- CompositorPriority getRenderPriotrity();
-
- /**
- * \brief set border for viewer operation
- * \note all the coordinates are assumed to be in normalized space
- */
- void setViewerBorder(float xmin, float xmax, float ymin, float ymax);
-
- void setRenderBorder(float xmin, float xmax, float ymin, float ymax);
-
- /* allow the DebugInfo class to look at internals */
- friend class DebugInfo;
+ public:
+ typedef std::vector<NodeOperation *> Operations;
+
+ private:
+ // fields
+
+ /**
+ * \brief list of operations in this ExecutionGroup
+ */
+ Operations m_operations;
+
+ /**
+ * \brief is this ExecutionGroup an input ExecutionGroup
+ * an input execution group is a group that is at the end of the calculation (the output is important for the user)
+ */
+ int m_isOutput;
+
+ /**
+ * \brief Width of the output
+ */
+ unsigned int m_width;
+
+ /**
+ * \brief Height of the output
+ */
+ unsigned int m_height;
+
+ /**
+ * \brief size of a single chunk, being Width or of height
+ * a chunk is always a square, except at the edges of the MemoryBuffer
+ */
+ unsigned int m_chunkSize;
+
+ /**
+ * \brief number of chunks in the x-axis
+ */
+ unsigned int m_numberOfXChunks;
+
+ /**
+ * \brief number of chunks in the y-axis
+ */
+ unsigned int m_numberOfYChunks;
+
+ /**
+ * \brief total number of chunks
+ */
+ unsigned int m_numberOfChunks;
+
+ /**
+ * \brief contains this ExecutionGroup a complex NodeOperation.
+ */
+ bool m_complex;
+
+ /**
+ * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ */
+ bool m_openCL;
+
+ /**
+ * \brief Is this Execution group SingleThreaded
+ */
+ bool m_singleThreaded;
+
+ /**
+ * \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
+ * \note this is used to construct the MemoryBuffers that will be passed during execution.
+ */
+ unsigned int m_cachedMaxReadBufferOffset;
+
+ /**
+ * \brief a cached vector of all read operations in the execution group.
+ */
+ Operations m_cachedReadOperations;
+
+ /**
+ * \brief reference to the original bNodeTree, this field is only set for the 'top' execution group.
+ * \note can only be used to call the callbacks for progress, status and break
+ */
+ const bNodeTree *m_bTree;
+
+ /**
+ * \brief total number of chunks that have been calculated for this ExecutionGroup
+ */
+ unsigned int m_chunksFinished;
+
+ /**
+ * \brief the chunkExecutionStates holds per chunk the execution state. this state can be
+ * - COM_ES_NOT_SCHEDULED: not scheduled
+ * - COM_ES_SCHEDULED: scheduled
+ * - COM_ES_EXECUTED: executed
+ */
+ ChunkExecutionState *m_chunkExecutionStates;
+
+ /**
+ * \brief indicator when this ExecutionGroup has valid Operations in its vector for Execution
+ * \note When building the ExecutionGroup Operations are added via recursion. First a WriteBufferOperations is added, then the
+ * \note Operation containing the settings that is important for the ExecutiongGroup is added,
+ * \note When this occurs, these settings are copied over from the node to the ExecutionGroup
+ * \note and the Initialized flag is set to true.
+ * \see complex
+ * \see openCL
+ */
+ bool m_initialized;
+
+ /**
+ * \brief denotes boundary for border compositing
+ * \note measured in pixel space
+ */
+ rcti m_viewerBorder;
+
+ /**
+ * \brief start time of execution
+ */
+ double m_executionStartTime;
+
+ // methods
+ /**
+ * \brief check whether parameter operation can be added to the execution group
+ * \param operation: the operation to be added
+ */
+ bool canContainOperation(NodeOperation *operation);
+
+ /**
+ * \brief calculate the actual chunk size of this execution group.
+ * \note A chunk size is an unsigned int that is both the height and width of a chunk.
+ * \note The chunk size will not be stored in the chunkSize field. This needs to be done
+ * \note by the calling method.
+ */
+ unsigned int determineChunkSize();
+
+ /**
+ * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
+ * \note Only gives useful results ater the determination of the chunksize
+ * \see determineChunkSize()
+ */
+ void determineChunkRect(rcti *rect, const unsigned int xChunk, const unsigned int yChunk) const;
+
+ /**
+ * \brief determine the number of chunks, based on the chunkSize, width and height.
+ * \note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
+ */
+ void determineNumberOfChunks();
+
+ /**
+ * \brief try to schedule a specific chunk.
+ * \note scheduling succeeds when all input requirements are met and the chunks hasn't been scheduled yet.
+ * \param graph:
+ * \param xChunk:
+ * \param yChunk:
+ * \return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk);
+
+ /**
+ * \brief try to schedule a specific area.
+ * \note Check if a certain area is available, when not available this are will be checked.
+ * \note This method is called from other ExecutionGroup's.
+ * \param graph:
+ * \param rect:
+ * \return [true:false]
+ * true: package(s) are scheduled
+ * false: scheduling is deferred (depending workpackages are scheduled)
+ */
+ bool scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *rect);
+
+ /**
+ * \brief add a chunk to the WorkScheduler.
+ * \param chunknumber:
+ */
+ bool scheduleChunk(unsigned int chunkNumber);
+
+ /**
+ * \brief determine the area of interest of a certain input area
+ * \note This method only evaluates a single ReadBufferOperation
+ * \param input: the input area
+ * \param readOperation: The ReadBufferOperation where the area needs to be evaluated
+ * \param output: the area needed of the ReadBufferOperation. Result
+ */
+ void determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ public:
+ // constructors
+ ExecutionGroup();
+
+ // methods
+ /**
+ * \brief add an operation to this ExecutionGroup
+ * \note this method will add input of the operations recursively
+ * \note this method can create multiple ExecutionGroup's
+ * \param system:
+ * \param operation:
+ * \return True if the operation was successfully added
+ */
+ bool addOperation(NodeOperation *operation);
+
+ /**
+ * \brief is this ExecutionGroup an output ExecutionGroup
+ * \note An OutputExecution group are groups containing a
+ * \note ViewerOperation, CompositeOperation, PreviewOperation.
+ * \see NodeOperation.isOutputOperation
+ */
+ int isOutputExecutionGroup() const
+ {
+ return this->m_isOutput;
+ }
+
+ /**
+ * \brief set whether this ExecutionGroup is an output
+ * \param isOutput:
+ */
+ void setOutputExecutionGroup(int isOutput)
+ {
+ this->m_isOutput = isOutput;
+ }
+
+ /**
+ * \brief determine the resolution of this ExecutionGroup
+ * \param resolution:
+ */
+ void determineResolution(unsigned int resolution[2]);
+
+ /**
+ * \brief set the resolution of this executiongroup
+ * \param resolution:
+ */
+ void setResolution(unsigned int resolution[2])
+ {
+ this->m_width = resolution[0];
+ this->m_height = resolution[1];
+ }
+
+ /**
+ * \brief get the width of this execution group
+ */
+ unsigned int getWidth() const
+ {
+ return m_width;
+ }
+
+ /**
+ * \brief get the height of this execution group
+ */
+ unsigned int getHeight() const
+ {
+ return m_height;
+ }
+
+ /**
+ * \brief does this ExecutionGroup contains a complex NodeOperation
+ */
+ bool isComplex() const
+ {
+ return m_complex;
+ }
+
+ /**
+ * \brief get the output operation of this ExecutionGroup
+ * \return NodeOperation *output operation
+ */
+ NodeOperation *getOutputOperation() const;
+
+ /**
+ * \brief compose multiple chunks into a single chunk
+ * \return Memorybuffer *consolidated chunk
+ */
+ MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *output);
+
+ /**
+ * \brief initExecution is called just before the execution of the whole graph will be done.
+ * \note The implementation will calculate the chunkSize of this execution group.
+ */
+ void initExecution();
+
+ /**
+ * \brief get all inputbuffers needed to calculate an chunk
+ * \note all inputbuffers must be executed
+ * \param chunkNumber: the chunk to be calculated
+ * \return (MemoryBuffer **) the inputbuffers
+ */
+ MemoryBuffer **getInputBuffersCPU();
+
+ /**
+ * \brief get all inputbuffers needed to calculate an chunk
+ * \note all inputbuffers must be executed
+ * \param chunkNumber: the chunk to be calculated
+ * \return (MemoryBuffer **) the inputbuffers
+ */
+ MemoryBuffer **getInputBuffersOpenCL(int chunkNumber);
+
+ /**
+ * \brief allocate the outputbuffer of a chunk
+ * \param chunkNumber: the number of the chunk in the ExecutionGroup
+ * \param rect: the rect of that chunk
+ * \see determineChunkRect
+ */
+ MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
+
+ /**
+ * \brief after a chunk is executed the needed resources can be freed or unlocked.
+ * \param chunknumber:
+ * \param memorybuffers:
+ */
+ void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers);
+
+ /**
+ * \brief deinitExecution is called just after execution the whole graph.
+ * \note It will release all needed resources
+ */
+ void deinitExecution();
+
+ /**
+ * \brief schedule an ExecutionGroup
+ * \note this method will return when all chunks have been calculated, or the execution has breaked (by user)
+ *
+ * first the order of the chunks will be determined. This is determined by finding the ViewerOperation and get the relevant information from it.
+ * - ChunkOrdering
+ * - CenterX
+ * - CenterY
+ *
+ * After determining the order of the chunks the chunks will be scheduled
+ *
+ * \see ViewerOperation
+ * \param system:
+ */
+ void execute(ExecutionSystem *system);
+
+ /**
+ * \brief this method determines the MemoryProxy's where this execution group depends on.
+ * \note After this method determineDependingAreaOfInterest can be called to determine
+ * \note the area of the MemoryProxy.creator that has to be executed.
+ * \param memoryProxies: result
+ */
+ void determineDependingMemoryProxies(vector<MemoryProxy *> *memoryProxies);
+
+ /**
+ * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
+ * \note Only gives useful results ater the determination of the chunksize
+ * \see determineChunkSize()
+ */
+ void determineChunkRect(rcti *rect, const unsigned int chunkNumber) const;
+
+ /**
+ * \brief can this ExecutionGroup be scheduled on an OpenCLDevice
+ * \see WorkScheduler.schedule
+ */
+ bool isOpenCL();
+
+ void setChunksize(int chunksize)
+ {
+ this->m_chunkSize = chunksize;
+ }
+
+ /**
+ * \brief get the Render priority of this ExecutionGroup
+ * \see ExecutionSystem.execute
+ */
+ CompositorPriority getRenderPriotrity();
+
+ /**
+ * \brief set border for viewer operation
+ * \note all the coordinates are assumed to be in normalized space
+ */
+ void setViewerBorder(float xmin, float xmax, float ymin, float ymax);
+
+ void setRenderBorder(float xmin, float xmax, float ymin, float ymax);
+
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
#endif
};
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
index 67e69129246..0d1fefc857d 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp
@@ -35,193 +35,202 @@ extern "C" {
#include "COM_Debug.h"
#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
+# include "MEM_guardedalloc.h"
#endif
-ExecutionSystem::ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editingtree, bool rendering, bool fastcalculation,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
+ExecutionSystem::ExecutionSystem(RenderData *rd,
+ Scene *scene,
+ bNodeTree *editingtree,
+ bool rendering,
+ bool fastcalculation,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
const char *viewName)
{
- this->m_context.setViewName(viewName);
- this->m_context.setScene(scene);
- this->m_context.setbNodeTree(editingtree);
- this->m_context.setPreviewHash(editingtree->previews);
- this->m_context.setFastCalculation(fastcalculation);
- /* initialize the CompositorContext */
- if (rendering) {
- this->m_context.setQuality((CompositorQuality)editingtree->render_quality);
- }
- else {
- this->m_context.setQuality((CompositorQuality)editingtree->edit_quality);
- }
- this->m_context.setRendering(rendering);
- this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() && (editingtree->flag & NTREE_COM_OPENCL));
-
- this->m_context.setRenderData(rd);
- this->m_context.setViewSettings(viewSettings);
- this->m_context.setDisplaySettings(displaySettings);
-
- {
- NodeOperationBuilder builder(&m_context, editingtree);
- builder.convertToOperations(this);
- }
-
- unsigned int index;
- unsigned int resolution[2];
-
- rctf *viewer_border = &editingtree->viewer_border;
- bool use_viewer_border = (editingtree->flag & NTREE_VIEWER_BORDER) &&
- viewer_border->xmin < viewer_border->xmax &&
- viewer_border->ymin < viewer_border->ymax;
-
- editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | Determining resolution"));
-
- for (index = 0; index < this->m_groups.size(); index++) {
- resolution[0] = 0;
- resolution[1] = 0;
- ExecutionGroup *executionGroup = this->m_groups[index];
- executionGroup->determineResolution(resolution);
-
- if (rendering) {
- /* case when cropping to render border happens is handled in
- * compositor output and render layer nodes
- */
- if ((rd->mode & R_BORDER) && !(rd->mode & R_CROP)) {
- executionGroup->setRenderBorder(rd->border.xmin, rd->border.xmax,
- rd->border.ymin, rd->border.ymax);
- }
- }
-
- if (use_viewer_border) {
- executionGroup->setViewerBorder(viewer_border->xmin, viewer_border->xmax,
- viewer_border->ymin, viewer_border->ymax);
- }
- }
-
-// DebugInfo::graphviz(this);
+ this->m_context.setViewName(viewName);
+ this->m_context.setScene(scene);
+ this->m_context.setbNodeTree(editingtree);
+ this->m_context.setPreviewHash(editingtree->previews);
+ this->m_context.setFastCalculation(fastcalculation);
+ /* initialize the CompositorContext */
+ if (rendering) {
+ this->m_context.setQuality((CompositorQuality)editingtree->render_quality);
+ }
+ else {
+ this->m_context.setQuality((CompositorQuality)editingtree->edit_quality);
+ }
+ this->m_context.setRendering(rendering);
+ this->m_context.setHasActiveOpenCLDevices(WorkScheduler::hasGPUDevices() &&
+ (editingtree->flag & NTREE_COM_OPENCL));
+
+ this->m_context.setRenderData(rd);
+ this->m_context.setViewSettings(viewSettings);
+ this->m_context.setDisplaySettings(displaySettings);
+
+ {
+ NodeOperationBuilder builder(&m_context, editingtree);
+ builder.convertToOperations(this);
+ }
+
+ unsigned int index;
+ unsigned int resolution[2];
+
+ rctf *viewer_border = &editingtree->viewer_border;
+ bool use_viewer_border = (editingtree->flag & NTREE_VIEWER_BORDER) &&
+ viewer_border->xmin < viewer_border->xmax &&
+ viewer_border->ymin < viewer_border->ymax;
+
+ editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | Determining resolution"));
+
+ for (index = 0; index < this->m_groups.size(); index++) {
+ resolution[0] = 0;
+ resolution[1] = 0;
+ ExecutionGroup *executionGroup = this->m_groups[index];
+ executionGroup->determineResolution(resolution);
+
+ if (rendering) {
+ /* case when cropping to render border happens is handled in
+ * compositor output and render layer nodes
+ */
+ if ((rd->mode & R_BORDER) && !(rd->mode & R_CROP)) {
+ executionGroup->setRenderBorder(
+ rd->border.xmin, rd->border.xmax, rd->border.ymin, rd->border.ymax);
+ }
+ }
+
+ if (use_viewer_border) {
+ executionGroup->setViewerBorder(
+ viewer_border->xmin, viewer_border->xmax, viewer_border->ymin, viewer_border->ymax);
+ }
+ }
+
+ // DebugInfo::graphviz(this);
}
ExecutionSystem::~ExecutionSystem()
{
- unsigned int index;
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- delete operation;
- }
- this->m_operations.clear();
- for (index = 0; index < this->m_groups.size(); index++) {
- ExecutionGroup *group = this->m_groups[index];
- delete group;
- }
- this->m_groups.clear();
+ unsigned int index;
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ delete operation;
+ }
+ this->m_operations.clear();
+ for (index = 0; index < this->m_groups.size(); index++) {
+ ExecutionGroup *group = this->m_groups[index];
+ delete group;
+ }
+ this->m_groups.clear();
}
void ExecutionSystem::set_operations(const Operations &operations, const Groups &groups)
{
- m_operations = operations;
- m_groups = groups;
+ m_operations = operations;
+ m_groups = groups;
}
void ExecutionSystem::execute()
{
- const bNodeTree *editingtree = this->m_context.getbNodeTree();
- editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | Initializing execution"));
-
- DebugInfo::execute_started(this);
-
- unsigned int order = 0;
- for (vector<NodeOperation *>::iterator iter = this->m_operations.begin(); iter != this->m_operations.end(); ++iter) {
- NodeOperation *operation = *iter;
- if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
- readOperation->setOffset(order);
- order++;
- }
- }
- unsigned int index;
-
- // First allocale all write buffer
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (operation->isWriteBufferOperation()) {
- operation->setbNodeTree(this->m_context.getbNodeTree());
- operation->initExecution();
- }
- }
- // Connect read buffers to their write buffers
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (operation->isReadBufferOperation()) {
- ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
- readOperation->updateMemoryBuffer();
- }
- }
- // initialize other operations
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- if (!operation->isWriteBufferOperation()) {
- operation->setbNodeTree(this->m_context.getbNodeTree());
- operation->initExecution();
- }
- }
- for (index = 0; index < this->m_groups.size(); index++) {
- ExecutionGroup *executionGroup = this->m_groups[index];
- executionGroup->setChunksize(this->m_context.getChunksize());
- executionGroup->initExecution();
- }
-
- WorkScheduler::start(this->m_context);
-
- executeGroups(COM_PRIORITY_HIGH);
- if (!this->getContext().isFastCalculation()) {
- executeGroups(COM_PRIORITY_MEDIUM);
- executeGroups(COM_PRIORITY_LOW);
- }
-
- WorkScheduler::finish();
- WorkScheduler::stop();
-
- editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | De-initializing execution"));
- for (index = 0; index < this->m_operations.size(); index++) {
- NodeOperation *operation = this->m_operations[index];
- operation->deinitExecution();
- }
- for (index = 0; index < this->m_groups.size(); index++) {
- ExecutionGroup *executionGroup = this->m_groups[index];
- executionGroup->deinitExecution();
- }
+ const bNodeTree *editingtree = this->m_context.getbNodeTree();
+ editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | Initializing execution"));
+
+ DebugInfo::execute_started(this);
+
+ unsigned int order = 0;
+ for (vector<NodeOperation *>::iterator iter = this->m_operations.begin();
+ iter != this->m_operations.end();
+ ++iter) {
+ NodeOperation *operation = *iter;
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
+ readOperation->setOffset(order);
+ order++;
+ }
+ }
+ unsigned int index;
+
+ // First allocale all write buffer
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ if (operation->isWriteBufferOperation()) {
+ operation->setbNodeTree(this->m_context.getbNodeTree());
+ operation->initExecution();
+ }
+ }
+ // Connect read buffers to their write buffers
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ if (operation->isReadBufferOperation()) {
+ ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
+ readOperation->updateMemoryBuffer();
+ }
+ }
+ // initialize other operations
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ if (!operation->isWriteBufferOperation()) {
+ operation->setbNodeTree(this->m_context.getbNodeTree());
+ operation->initExecution();
+ }
+ }
+ for (index = 0; index < this->m_groups.size(); index++) {
+ ExecutionGroup *executionGroup = this->m_groups[index];
+ executionGroup->setChunksize(this->m_context.getChunksize());
+ executionGroup->initExecution();
+ }
+
+ WorkScheduler::start(this->m_context);
+
+ executeGroups(COM_PRIORITY_HIGH);
+ if (!this->getContext().isFastCalculation()) {
+ executeGroups(COM_PRIORITY_MEDIUM);
+ executeGroups(COM_PRIORITY_LOW);
+ }
+
+ WorkScheduler::finish();
+ WorkScheduler::stop();
+
+ editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing | De-initializing execution"));
+ for (index = 0; index < this->m_operations.size(); index++) {
+ NodeOperation *operation = this->m_operations[index];
+ operation->deinitExecution();
+ }
+ for (index = 0; index < this->m_groups.size(); index++) {
+ ExecutionGroup *executionGroup = this->m_groups[index];
+ executionGroup->deinitExecution();
+ }
}
void ExecutionSystem::executeGroups(CompositorPriority priority)
{
- unsigned int index;
- vector<ExecutionGroup *> executionGroups;
- this->findOutputExecutionGroup(&executionGroups, priority);
-
- for (index = 0; index < executionGroups.size(); index++) {
- ExecutionGroup *group = executionGroups[index];
- group->execute(this);
- }
+ unsigned int index;
+ vector<ExecutionGroup *> executionGroups;
+ this->findOutputExecutionGroup(&executionGroups, priority);
+
+ for (index = 0; index < executionGroups.size(); index++) {
+ ExecutionGroup *group = executionGroups[index];
+ group->execute(this);
+ }
}
-void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const
+void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result,
+ CompositorPriority priority) const
{
- unsigned int index;
- for (index = 0; index < this->m_groups.size(); index++) {
- ExecutionGroup *group = this->m_groups[index];
- if (group->isOutputExecutionGroup() && group->getRenderPriotrity() == priority) {
- result->push_back(group);
- }
- }
+ unsigned int index;
+ for (index = 0; index < this->m_groups.size(); index++) {
+ ExecutionGroup *group = this->m_groups[index];
+ if (group->isOutputExecutionGroup() && group->getRenderPriotrity() == priority) {
+ result->push_back(group);
+ }
+ }
}
void ExecutionSystem::findOutputExecutionGroup(vector<ExecutionGroup *> *result) const
{
- unsigned int index;
- for (index = 0; index < this->m_groups.size(); index++) {
- ExecutionGroup *group = this->m_groups[index];
- if (group->isOutputExecutionGroup()) {
- result->push_back(group);
- }
- }
+ unsigned int index;
+ for (index = 0; index < this->m_groups.size(); index++) {
+ ExecutionGroup *group = this->m_groups[index];
+ if (group->isOutputExecutionGroup()) {
+ result->push_back(group);
+ }
+ }
}
diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.h b/source/blender/compositor/intern/COM_ExecutionSystem.h
index 476dd3ccc06..55c2ed6c22b 100644
--- a/source/blender/compositor/intern/COM_ExecutionSystem.h
+++ b/source/blender/compositor/intern/COM_ExecutionSystem.h
@@ -107,77 +107,86 @@ class ExecutionGroup;
* \brief the ExecutionSystem contains the whole compositor tree.
*/
class ExecutionSystem {
-public:
- typedef std::vector<NodeOperation*> Operations;
- typedef std::vector<ExecutionGroup*> Groups;
-
-private:
- /**
- * \brief the context used during execution
- */
- CompositorContext m_context;
-
- /**
- * \brief vector of operations
- */
- Operations m_operations;
-
- /**
- * \brief vector of groups
- */
- Groups m_groups;
-
-private: //methods
- /**
- * find all execution group with output nodes
- */
- void findOutputExecutionGroup(vector<ExecutionGroup *> *result, CompositorPriority priority) const;
-
- /**
- * find all execution group with output nodes
- */
- void findOutputExecutionGroup(vector<ExecutionGroup *> *result) const;
-
-public:
- /**
- * \brief Create a new ExecutionSystem and initialize it with the
- * editingtree.
- *
- * \param editingtree: [bNodeTree *]
- * \param rendering: [true false]
- */
- ExecutionSystem(RenderData *rd, Scene *scene, bNodeTree *editingtree, bool rendering, bool fastcalculation,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
- const char *viewName);
-
- /**
- * Destructor
- */
- ~ExecutionSystem();
-
- void set_operations(const Operations &operations, const Groups &groups);
-
- /**
- * \brief execute this system
- * - initialize the NodeOperation's and ExecutionGroup's
- * - schedule the output ExecutionGroup's based on their priority
- * - deinitialize the ExecutionGroup's and NodeOperation's
- */
- void execute();
-
- /**
- * \brief get the reference to the compositor context
- */
- const CompositorContext &getContext() const { return this->m_context; }
-
-private:
- void executeGroups(CompositorPriority priority);
-
- /* allow the DebugInfo class to look at internals */
- friend class DebugInfo;
+ public:
+ typedef std::vector<NodeOperation *> Operations;
+ typedef std::vector<ExecutionGroup *> Groups;
+
+ private:
+ /**
+ * \brief the context used during execution
+ */
+ CompositorContext m_context;
+
+ /**
+ * \brief vector of operations
+ */
+ Operations m_operations;
+
+ /**
+ * \brief vector of groups
+ */
+ Groups m_groups;
+
+ private: //methods
+ /**
+ * find all execution group with output nodes
+ */
+ void findOutputExecutionGroup(vector<ExecutionGroup *> *result,
+ CompositorPriority priority) const;
+
+ /**
+ * find all execution group with output nodes
+ */
+ void findOutputExecutionGroup(vector<ExecutionGroup *> *result) const;
+
+ public:
+ /**
+ * \brief Create a new ExecutionSystem and initialize it with the
+ * editingtree.
+ *
+ * \param editingtree: [bNodeTree *]
+ * \param rendering: [true false]
+ */
+ ExecutionSystem(RenderData *rd,
+ Scene *scene,
+ bNodeTree *editingtree,
+ bool rendering,
+ bool fastcalculation,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName);
+
+ /**
+ * Destructor
+ */
+ ~ExecutionSystem();
+
+ void set_operations(const Operations &operations, const Groups &groups);
+
+ /**
+ * \brief execute this system
+ * - initialize the NodeOperation's and ExecutionGroup's
+ * - schedule the output ExecutionGroup's based on their priority
+ * - deinitialize the ExecutionGroup's and NodeOperation's
+ */
+ void execute();
+
+ /**
+ * \brief get the reference to the compositor context
+ */
+ const CompositorContext &getContext() const
+ {
+ return this->m_context;
+ }
+
+ private:
+ void executeGroups(CompositorPriority priority);
+
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionSystem")
#endif
};
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
index 5f3cf83d4b2..b958314d1b4 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp
@@ -20,202 +20,212 @@
#include "MEM_guardedalloc.h"
-using std::min;
using std::max;
+using std::min;
static unsigned int determine_num_channels(DataType datatype)
{
- switch (datatype) {
- case COM_DT_VALUE:
- return COM_NUM_CHANNELS_VALUE;
- case COM_DT_VECTOR:
- return COM_NUM_CHANNELS_VECTOR;
- case COM_DT_COLOR:
- default:
- return COM_NUM_CHANNELS_COLOR;
- }
+ switch (datatype) {
+ case COM_DT_VALUE:
+ return COM_NUM_CHANNELS_VALUE;
+ case COM_DT_VECTOR:
+ return COM_NUM_CHANNELS_VECTOR;
+ case COM_DT_COLOR:
+ default:
+ return COM_NUM_CHANNELS_COLOR;
+ }
}
unsigned int MemoryBuffer::determineBufferSize()
{
- return getWidth() * getHeight();
+ return getWidth() * getHeight();
}
int MemoryBuffer::getWidth() const
{
- return this->m_width;
+ return this->m_width;
}
int MemoryBuffer::getHeight() const
{
- return this->m_height;
+ return this->m_height;
}
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect)
{
- BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
- this->m_width = BLI_rcti_size_x(&this->m_rect);
- this->m_height = BLI_rcti_size_y(&this->m_rect);
- this->m_memoryProxy = memoryProxy;
- this->m_chunkNumber = chunkNumber;
- this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
- this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
- this->m_state = COM_MB_ALLOCATED;
- this->m_datatype = memoryProxy->getDataType();
+ BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->m_width = BLI_rcti_size_x(&this->m_rect);
+ this->m_height = BLI_rcti_size_y(&this->m_rect);
+ this->m_memoryProxy = memoryProxy;
+ this->m_chunkNumber = chunkNumber;
+ this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
+ this->m_buffer = (float *)MEM_mallocN_aligned(
+ sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
+ this->m_state = COM_MB_ALLOCATED;
+ this->m_datatype = memoryProxy->getDataType();
}
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
{
- BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
- this->m_width = BLI_rcti_size_x(&this->m_rect);
- this->m_height = BLI_rcti_size_y(&this->m_rect);
- this->m_memoryProxy = memoryProxy;
- this->m_chunkNumber = -1;
- this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
- this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
- this->m_state = COM_MB_TEMPORARILY;
- this->m_datatype = memoryProxy->getDataType();
+ BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->m_width = BLI_rcti_size_x(&this->m_rect);
+ this->m_height = BLI_rcti_size_y(&this->m_rect);
+ this->m_memoryProxy = memoryProxy;
+ this->m_chunkNumber = -1;
+ this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
+ this->m_buffer = (float *)MEM_mallocN_aligned(
+ sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
+ this->m_state = COM_MB_TEMPORARILY;
+ this->m_datatype = memoryProxy->getDataType();
}
MemoryBuffer::MemoryBuffer(DataType dataType, rcti *rect)
{
- BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
- this->m_width = BLI_rcti_size_x(&this->m_rect);
- this->m_height = BLI_rcti_size_y(&this->m_rect);
- this->m_height = this->m_rect.ymax - this->m_rect.ymin;
- this->m_memoryProxy = NULL;
- this->m_chunkNumber = -1;
- this->m_num_channels = determine_num_channels(dataType);
- this->m_buffer = (float *)MEM_mallocN_aligned(sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
- this->m_state = COM_MB_TEMPORARILY;
- this->m_datatype = dataType;
+ BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
+ this->m_width = BLI_rcti_size_x(&this->m_rect);
+ this->m_height = BLI_rcti_size_y(&this->m_rect);
+ this->m_height = this->m_rect.ymax - this->m_rect.ymin;
+ this->m_memoryProxy = NULL;
+ this->m_chunkNumber = -1;
+ this->m_num_channels = determine_num_channels(dataType);
+ this->m_buffer = (float *)MEM_mallocN_aligned(
+ sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
+ this->m_state = COM_MB_TEMPORARILY;
+ this->m_datatype = dataType;
}
MemoryBuffer *MemoryBuffer::duplicate()
{
- MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect);
- memcpy(result->m_buffer, this->m_buffer, this->determineBufferSize() * this->m_num_channels * sizeof(float));
- return result;
+ MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect);
+ memcpy(result->m_buffer,
+ this->m_buffer,
+ this->determineBufferSize() * this->m_num_channels * sizeof(float));
+ return result;
}
void MemoryBuffer::clear()
{
- memset(this->m_buffer, 0, this->determineBufferSize() * this->m_num_channels * sizeof(float));
+ memset(this->m_buffer, 0, this->determineBufferSize() * this->m_num_channels * sizeof(float));
}
-
float MemoryBuffer::getMaximumValue()
{
- float result = this->m_buffer[0];
- const unsigned int size = this->determineBufferSize();
- unsigned int i;
+ float result = this->m_buffer[0];
+ const unsigned int size = this->determineBufferSize();
+ unsigned int i;
- const float *fp_src = this->m_buffer;
+ const float *fp_src = this->m_buffer;
- for (i = 0; i < size; i++, fp_src += this->m_num_channels) {
- float value = *fp_src;
- if (value > result) {
- result = value;
- }
- }
+ for (i = 0; i < size; i++, fp_src += this->m_num_channels) {
+ float value = *fp_src;
+ if (value > result) {
+ result = value;
+ }
+ }
- return result;
+ return result;
}
float MemoryBuffer::getMaximumValue(rcti *rect)
{
- rcti rect_clamp;
+ rcti rect_clamp;
- /* first clamp the rect by the bounds or we get un-initialized values */
- BLI_rcti_isect(rect, &this->m_rect, &rect_clamp);
+ /* first clamp the rect by the bounds or we get un-initialized values */
+ BLI_rcti_isect(rect, &this->m_rect, &rect_clamp);
- if (!BLI_rcti_is_empty(&rect_clamp)) {
- MemoryBuffer *temp = new MemoryBuffer(this->m_datatype, &rect_clamp);
- temp->copyContentFrom(this);
- float result = temp->getMaximumValue();
- delete temp;
- return result;
- }
- else {
- BLI_assert(0);
- return 0.0f;
- }
+ if (!BLI_rcti_is_empty(&rect_clamp)) {
+ MemoryBuffer *temp = new MemoryBuffer(this->m_datatype, &rect_clamp);
+ temp->copyContentFrom(this);
+ float result = temp->getMaximumValue();
+ delete temp;
+ return result;
+ }
+ else {
+ BLI_assert(0);
+ return 0.0f;
+ }
}
MemoryBuffer::~MemoryBuffer()
{
- if (this->m_buffer) {
- MEM_freeN(this->m_buffer);
- this->m_buffer = NULL;
- }
+ if (this->m_buffer) {
+ MEM_freeN(this->m_buffer);
+ this->m_buffer = NULL;
+ }
}
void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
{
- if (!otherBuffer) {
- BLI_assert(0);
- return;
- }
- unsigned int otherY;
- unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin);
- unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax);
- unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin);
- unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax);
- int offset;
- int otherOffset;
-
-
- for (otherY = minY; otherY < maxY; otherY++) {
- otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_width + minX - otherBuffer->m_rect.xmin) * this->m_num_channels;
- offset = ((otherY - this->m_rect.ymin) * this->m_width + minX - this->m_rect.xmin) * this->m_num_channels;
- memcpy(&this->m_buffer[offset], &otherBuffer->m_buffer[otherOffset], (maxX - minX) * this->m_num_channels * sizeof(float));
- }
+ if (!otherBuffer) {
+ BLI_assert(0);
+ return;
+ }
+ unsigned int otherY;
+ unsigned int minX = max(this->m_rect.xmin, otherBuffer->m_rect.xmin);
+ unsigned int maxX = min(this->m_rect.xmax, otherBuffer->m_rect.xmax);
+ unsigned int minY = max(this->m_rect.ymin, otherBuffer->m_rect.ymin);
+ unsigned int maxY = min(this->m_rect.ymax, otherBuffer->m_rect.ymax);
+ int offset;
+ int otherOffset;
+
+ for (otherY = minY; otherY < maxY; otherY++) {
+ otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_width + minX -
+ otherBuffer->m_rect.xmin) *
+ this->m_num_channels;
+ offset = ((otherY - this->m_rect.ymin) * this->m_width + minX - this->m_rect.xmin) *
+ this->m_num_channels;
+ memcpy(&this->m_buffer[offset],
+ &otherBuffer->m_buffer[otherOffset],
+ (maxX - minX) * this->m_num_channels * sizeof(float));
+ }
}
void MemoryBuffer::writePixel(int x, int y, const float color[4])
{
- if (x >= this->m_rect.xmin && x < this->m_rect.xmax &&
- y >= this->m_rect.ymin && y < this->m_rect.ymax)
- {
- const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * this->m_num_channels;
- memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels);
- }
+ if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
+ y < this->m_rect.ymax) {
+ const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) *
+ this->m_num_channels;
+ memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels);
+ }
}
void MemoryBuffer::addPixel(int x, int y, const float color[4])
{
- if (x >= this->m_rect.xmin && x < this->m_rect.xmax &&
- y >= this->m_rect.ymin && y < this->m_rect.ymax)
- {
- const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * this->m_num_channels;
- float *dst = &this->m_buffer[offset];
- const float *src = color;
- for (int i = 0; i < this->m_num_channels ; i++, dst++, src++) {
- *dst += *src;
- }
- }
+ if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
+ y < this->m_rect.ymax) {
+ const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) *
+ this->m_num_channels;
+ float *dst = &this->m_buffer[offset];
+ const float *src = color;
+ for (int i = 0; i < this->m_num_channels; i++, dst++, src++) {
+ *dst += *src;
+ }
+ }
}
static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4])
{
- MemoryBuffer *buffer = (MemoryBuffer *) userdata;
- buffer->read(result, x, y);
+ MemoryBuffer *buffer = (MemoryBuffer *)userdata;
+ buffer->read(result, x, y);
}
void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
{
- BLI_assert(this->m_datatype == COM_DT_COLOR);
- float inv_width = 1.0f / (float)this->getWidth(),
- inv_height = 1.0f / (float)this->getHeight();
- /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
- * but compositor uses pixel space. For now let's just divide the values and
- * switch compositor to normalized space for EWA later.
- */
- float uv_normal[2] = {uv[0] * inv_width, uv[1] * inv_height};
- float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height};
- float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
-
- BLI_ewa_filter(this->getWidth(), this->getHeight(),
- false,
- true,
- uv_normal, du_normal, dv_normal,
- read_ewa_pixel_sampled,
- this,
- result);
+ BLI_assert(this->m_datatype == COM_DT_COLOR);
+ float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight();
+ /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
+ * but compositor uses pixel space. For now let's just divide the values and
+ * switch compositor to normalized space for EWA later.
+ */
+ float uv_normal[2] = {uv[0] * inv_width, uv[1] * inv_height};
+ float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height};
+ float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
+
+ BLI_ewa_filter(this->getWidth(),
+ this->getHeight(),
+ false,
+ true,
+ uv_normal,
+ du_normal,
+ dv_normal,
+ read_ewa_pixel_sampled,
+ this,
+ result);
}
diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.h b/source/blender/compositor/intern/COM_MemoryBuffer.h
index 63897da0b8a..12cd55c95a3 100644
--- a/source/blender/compositor/intern/COM_MemoryBuffer.h
+++ b/source/blender/compositor/intern/COM_MemoryBuffer.h
@@ -26,8 +26,8 @@ class MemoryBuffer;
#include "COM_SocketReader.h"
extern "C" {
-# include "BLI_math.h"
-# include "BLI_rect.h"
+#include "BLI_math.h"
+#include "BLI_rect.h"
}
/**
@@ -35,18 +35,18 @@ extern "C" {
* \ingroup Memory
*/
typedef enum MemoryBufferState {
- /** \brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
- COM_MB_ALLOCATED = 1,
- /** \brief memory is available for use, content has been created */
- COM_MB_AVAILABLE = 2,
- /** \brief chunk is consolidated from other chunks. special state.*/
- COM_MB_TEMPORARILY = 6,
+ /** \brief memory has been allocated on creator device and CPU machine, but kernel has not been executed */
+ COM_MB_ALLOCATED = 1,
+ /** \brief memory is available for use, content has been created */
+ COM_MB_AVAILABLE = 2,
+ /** \brief chunk is consolidated from other chunks. special state.*/
+ COM_MB_TEMPORARILY = 6,
} MemoryBufferState;
typedef enum MemoryBufferExtend {
- COM_MB_CLIP,
- COM_MB_EXTEND,
- COM_MB_REPEAT,
+ COM_MB_CLIP,
+ COM_MB_EXTEND,
+ COM_MB_REPEAT,
} MemoryBufferExtend;
class MemoryProxy;
@@ -55,262 +55,299 @@ class MemoryProxy;
* \brief a MemoryBuffer contains access to the data of a chunk
*/
class MemoryBuffer {
-private:
- /**
- * \brief proxy of the memory (same for all chunks in the same buffer)
- */
- MemoryProxy *m_memoryProxy;
-
- /**
- * \brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
- */
- DataType m_datatype;
-
-
- /**
- * \brief region of this buffer inside relative to the MemoryProxy
- */
- rcti m_rect;
-
- /**
- * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
- * \see memoryProxy
- */
- unsigned int m_chunkNumber;
-
- /**
- * \brief state of the buffer
- */
- MemoryBufferState m_state;
-
- /**
- * \brief the actual float buffer/data
- */
- float *m_buffer;
-
- /**
- * \brief the number of channels of a single value in the buffer.
- * For value buffers this is 1, vector 3 and color 4
- */
- unsigned int m_num_channels;
-
- int m_width;
- int m_height;
-
-public:
- /**
- * \brief construct new MemoryBuffer for a chunk
- */
- MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
-
- /**
- * \brief construct new temporarily MemoryBuffer for an area
- */
- MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
-
- /**
- * \brief construct new temporarily MemoryBuffer for an area
- */
- MemoryBuffer(DataType datatype, rcti *rect);
-
- /**
- * \brief destructor
- */
- ~MemoryBuffer();
-
- /**
- * \brief read the ChunkNumber of this MemoryBuffer
- */
- unsigned int getChunkNumber() { return this->m_chunkNumber; }
-
- unsigned int get_num_channels() { return this->m_num_channels; }
-
- /**
- * \brief get the data of this MemoryBuffer
- * \note buffer should already be available in memory
- */
- float *getBuffer() { return this->m_buffer; }
-
- /**
- * \brief after execution the state will be set to available by calling this method
- */
- void setCreatedState()
- {
- this->m_state = COM_MB_AVAILABLE;
- }
-
- inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
- {
- int w = this->m_width;
- int h = this->m_height;
- x = x - m_rect.xmin;
- y = y - m_rect.ymin;
-
- switch (extend_x) {
- case COM_MB_CLIP:
- break;
- case COM_MB_EXTEND:
- if (x < 0) x = 0;
- if (x >= w) x = w;
- break;
- case COM_MB_REPEAT:
- x = (x >= 0.0f ? (x % w) : (x % w) + w);
- break;
- }
-
- switch (extend_y) {
- case COM_MB_CLIP:
- break;
- case COM_MB_EXTEND:
- if (y < 0) y = 0;
- if (y >= h) y = h;
- break;
- case COM_MB_REPEAT:
- y = (y >= 0.0f ? (y % h) : (y % h) + h);
- break;
- }
- }
-
- inline void wrap_pixel(float &x, float &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
- {
- float w = (float)this->m_width;
- float h = (float)this->m_height;
- x = x - m_rect.xmin;
- y = y - m_rect.ymin;
-
- switch (extend_x) {
- case COM_MB_CLIP:
- break;
- case COM_MB_EXTEND:
- if (x < 0) x = 0.0f;
- if (x >= w) x = w;
- break;
- case COM_MB_REPEAT:
- x = fmodf(x, w);
- break;
- }
-
- switch (extend_y) {
- case COM_MB_CLIP:
- break;
- case COM_MB_EXTEND:
- if (y < 0) y = 0.0f;
- if (y >= h) y = h;
- break;
- case COM_MB_REPEAT:
- y = fmodf(y, h);
- break;
- }
- }
-
- inline void read(float *result, int x, int y,
- MemoryBufferExtend extend_x = COM_MB_CLIP,
- MemoryBufferExtend extend_y = COM_MB_CLIP)
- {
- bool clip_x = (extend_x == COM_MB_CLIP && (x < m_rect.xmin || x >= m_rect.xmax));
- bool clip_y = (extend_y == COM_MB_CLIP && (y < m_rect.ymin || y >= m_rect.ymax));
- if (clip_x || clip_y) {
- /* clip result outside rect is zero */
- memset(result, 0, this->m_num_channels * sizeof(float));
- }
- else {
- int u = x;
- int v = y;
- this->wrap_pixel(u, v, extend_x, extend_y);
- const int offset = (this->m_width * y + x) * this->m_num_channels;
- float *buffer = &this->m_buffer[offset];
- memcpy(result, buffer, sizeof(float) * this->m_num_channels);
- }
- }
-
- inline void readNoCheck(float *result, int x, int y,
- MemoryBufferExtend extend_x = COM_MB_CLIP,
- MemoryBufferExtend extend_y = COM_MB_CLIP)
- {
- int u = x;
- int v = y;
-
- this->wrap_pixel(u, v, extend_x, extend_y);
- const int offset = (this->m_width * v + u) * this->m_num_channels;
-
- BLI_assert(offset >= 0);
- BLI_assert(offset < this->determineBufferSize() * this->m_num_channels);
- BLI_assert(!(extend_x == COM_MB_CLIP && (u < m_rect.xmin || u >= m_rect.xmax)) &&
- !(extend_y == COM_MB_CLIP && (v < m_rect.ymin || v >= m_rect.ymax)));
+ private:
+ /**
+ * \brief proxy of the memory (same for all chunks in the same buffer)
+ */
+ MemoryProxy *m_memoryProxy;
+
+ /**
+ * \brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
+ */
+ DataType m_datatype;
+
+ /**
+ * \brief region of this buffer inside relative to the MemoryProxy
+ */
+ rcti m_rect;
+
+ /**
+ * brief refers to the chunknumber within the executiongroup where related to the MemoryProxy
+ * \see memoryProxy
+ */
+ unsigned int m_chunkNumber;
+
+ /**
+ * \brief state of the buffer
+ */
+ MemoryBufferState m_state;
+
+ /**
+ * \brief the actual float buffer/data
+ */
+ float *m_buffer;
+
+ /**
+ * \brief the number of channels of a single value in the buffer.
+ * For value buffers this is 1, vector 3 and color 4
+ */
+ unsigned int m_num_channels;
+
+ int m_width;
+ int m_height;
+
+ public:
+ /**
+ * \brief construct new MemoryBuffer for a chunk
+ */
+ MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
+
+ /**
+ * \brief construct new temporarily MemoryBuffer for an area
+ */
+ MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
+
+ /**
+ * \brief construct new temporarily MemoryBuffer for an area
+ */
+ MemoryBuffer(DataType datatype, rcti *rect);
+
+ /**
+ * \brief destructor
+ */
+ ~MemoryBuffer();
+
+ /**
+ * \brief read the ChunkNumber of this MemoryBuffer
+ */
+ unsigned int getChunkNumber()
+ {
+ return this->m_chunkNumber;
+ }
+
+ unsigned int get_num_channels()
+ {
+ return this->m_num_channels;
+ }
+
+ /**
+ * \brief get the data of this MemoryBuffer
+ * \note buffer should already be available in memory
+ */
+ float *getBuffer()
+ {
+ return this->m_buffer;
+ }
+
+ /**
+ * \brief after execution the state will be set to available by calling this method
+ */
+ void setCreatedState()
+ {
+ this->m_state = COM_MB_AVAILABLE;
+ }
+
+ inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
+ {
+ int w = this->m_width;
+ int h = this->m_height;
+ x = x - m_rect.xmin;
+ y = y - m_rect.ymin;
+
+ switch (extend_x) {
+ case COM_MB_CLIP:
+ break;
+ case COM_MB_EXTEND:
+ if (x < 0)
+ x = 0;
+ if (x >= w)
+ x = w;
+ break;
+ case COM_MB_REPEAT:
+ x = (x >= 0.0f ? (x % w) : (x % w) + w);
+ break;
+ }
+
+ switch (extend_y) {
+ case COM_MB_CLIP:
+ break;
+ case COM_MB_EXTEND:
+ if (y < 0)
+ y = 0;
+ if (y >= h)
+ y = h;
+ break;
+ case COM_MB_REPEAT:
+ y = (y >= 0.0f ? (y % h) : (y % h) + h);
+ break;
+ }
+ }
+
+ inline void wrap_pixel(float &x,
+ float &y,
+ MemoryBufferExtend extend_x,
+ MemoryBufferExtend extend_y)
+ {
+ float w = (float)this->m_width;
+ float h = (float)this->m_height;
+ x = x - m_rect.xmin;
+ y = y - m_rect.ymin;
+
+ switch (extend_x) {
+ case COM_MB_CLIP:
+ break;
+ case COM_MB_EXTEND:
+ if (x < 0)
+ x = 0.0f;
+ if (x >= w)
+ x = w;
+ break;
+ case COM_MB_REPEAT:
+ x = fmodf(x, w);
+ break;
+ }
+
+ switch (extend_y) {
+ case COM_MB_CLIP:
+ break;
+ case COM_MB_EXTEND:
+ if (y < 0)
+ y = 0.0f;
+ if (y >= h)
+ y = h;
+ break;
+ case COM_MB_REPEAT:
+ y = fmodf(y, h);
+ break;
+ }
+ }
+
+ inline void read(float *result,
+ int x,
+ int y,
+ MemoryBufferExtend extend_x = COM_MB_CLIP,
+ MemoryBufferExtend extend_y = COM_MB_CLIP)
+ {
+ bool clip_x = (extend_x == COM_MB_CLIP && (x < m_rect.xmin || x >= m_rect.xmax));
+ bool clip_y = (extend_y == COM_MB_CLIP && (y < m_rect.ymin || y >= m_rect.ymax));
+ if (clip_x || clip_y) {
+ /* clip result outside rect is zero */
+ memset(result, 0, this->m_num_channels * sizeof(float));
+ }
+ else {
+ int u = x;
+ int v = y;
+ this->wrap_pixel(u, v, extend_x, extend_y);
+ const int offset = (this->m_width * y + x) * this->m_num_channels;
+ float *buffer = &this->m_buffer[offset];
+ memcpy(result, buffer, sizeof(float) * this->m_num_channels);
+ }
+ }
+
+ inline void readNoCheck(float *result,
+ int x,
+ int y,
+ MemoryBufferExtend extend_x = COM_MB_CLIP,
+ MemoryBufferExtend extend_y = COM_MB_CLIP)
+ {
+ int u = x;
+ int v = y;
+
+ this->wrap_pixel(u, v, extend_x, extend_y);
+ const int offset = (this->m_width * v + u) * this->m_num_channels;
+
+ BLI_assert(offset >= 0);
+ BLI_assert(offset < this->determineBufferSize() * this->m_num_channels);
+ BLI_assert(!(extend_x == COM_MB_CLIP && (u < m_rect.xmin || u >= m_rect.xmax)) &&
+ !(extend_y == COM_MB_CLIP && (v < m_rect.ymin || v >= m_rect.ymax)));
#if 0
- /* always true */
- BLI_assert((int)(MEM_allocN_len(this->m_buffer) / sizeof(*this->m_buffer)) ==
- (int)(this->determineBufferSize() * COM_NUMBER_OF_CHANNELS));
+ /* always true */
+ BLI_assert((int)(MEM_allocN_len(this->m_buffer) / sizeof(*this->m_buffer)) ==
+ (int)(this->determineBufferSize() * COM_NUMBER_OF_CHANNELS));
#endif
- float *buffer = &this->m_buffer[offset];
- memcpy(result, buffer, sizeof(float) * this->m_num_channels);
- }
-
- void writePixel(int x, int y, const float color[4]);
- void addPixel(int x, int y, const float color[4]);
- inline void readBilinear(float *result, float x, float y,
- MemoryBufferExtend extend_x = COM_MB_CLIP,
- MemoryBufferExtend extend_y = COM_MB_CLIP)
- {
- float u = x;
- float v = y;
- this->wrap_pixel(u, v, extend_x, extend_y);
- if ((extend_x != COM_MB_REPEAT && (u < 0.0f || u >= this->m_width)) ||
- (extend_y != COM_MB_REPEAT && (v < 0.0f || v >= this->m_height)))
- {
- copy_vn_fl(result, this->m_num_channels, 0.0f);
- return;
- }
- BLI_bilinear_interpolation_wrap_fl(
- this->m_buffer, result, this->m_width, this->m_height, this->m_num_channels, u, v,
- extend_x == COM_MB_REPEAT, extend_y == COM_MB_REPEAT);
- }
-
- void readEWA(float *result, const float uv[2], const float derivatives[2][2]);
-
- /**
- * \brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
- */
- inline bool isTemporarily() const { return this->m_state == COM_MB_TEMPORARILY; }
-
- /**
- * \brief add the content from otherBuffer to this MemoryBuffer
- * \param otherBuffer: source buffer
- *
- * \note take care when running this on a new buffer since it wont fill in
- * uninitialized values in areas where the buffers don't overlap.
- */
- void copyContentFrom(MemoryBuffer *otherBuffer);
-
- /**
- * \brief get the rect of this MemoryBuffer
- */
- rcti *getRect() { return &this->m_rect; }
-
- /**
- * \brief get the width of this MemoryBuffer
- */
- int getWidth() const;
-
- /**
- * \brief get the height of this MemoryBuffer
- */
- int getHeight() const;
-
- /**
- * \brief clear the buffer. Make all pixels black transparent.
- */
- void clear();
-
- MemoryBuffer *duplicate();
-
- float getMaximumValue();
- float getMaximumValue(rcti *rect);
-private:
- unsigned int determineBufferSize();
+ float *buffer = &this->m_buffer[offset];
+ memcpy(result, buffer, sizeof(float) * this->m_num_channels);
+ }
+
+ void writePixel(int x, int y, const float color[4]);
+ void addPixel(int x, int y, const float color[4]);
+ inline void readBilinear(float *result,
+ float x,
+ float y,
+ MemoryBufferExtend extend_x = COM_MB_CLIP,
+ MemoryBufferExtend extend_y = COM_MB_CLIP)
+ {
+ float u = x;
+ float v = y;
+ this->wrap_pixel(u, v, extend_x, extend_y);
+ if ((extend_x != COM_MB_REPEAT && (u < 0.0f || u >= this->m_width)) ||
+ (extend_y != COM_MB_REPEAT && (v < 0.0f || v >= this->m_height))) {
+ copy_vn_fl(result, this->m_num_channels, 0.0f);
+ return;
+ }
+ BLI_bilinear_interpolation_wrap_fl(this->m_buffer,
+ result,
+ this->m_width,
+ this->m_height,
+ this->m_num_channels,
+ u,
+ v,
+ extend_x == COM_MB_REPEAT,
+ extend_y == COM_MB_REPEAT);
+ }
+
+ void readEWA(float *result, const float uv[2], const float derivatives[2][2]);
+
+ /**
+ * \brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
+ */
+ inline bool isTemporarily() const
+ {
+ return this->m_state == COM_MB_TEMPORARILY;
+ }
+
+ /**
+ * \brief add the content from otherBuffer to this MemoryBuffer
+ * \param otherBuffer: source buffer
+ *
+ * \note take care when running this on a new buffer since it wont fill in
+ * uninitialized values in areas where the buffers don't overlap.
+ */
+ void copyContentFrom(MemoryBuffer *otherBuffer);
+
+ /**
+ * \brief get the rect of this MemoryBuffer
+ */
+ rcti *getRect()
+ {
+ return &this->m_rect;
+ }
+
+ /**
+ * \brief get the width of this MemoryBuffer
+ */
+ int getWidth() const;
+
+ /**
+ * \brief get the height of this MemoryBuffer
+ */
+ int getHeight() const;
+
+ /**
+ * \brief clear the buffer. Make all pixels black transparent.
+ */
+ void clear();
+
+ MemoryBuffer *duplicate();
+
+ float getMaximumValue();
+ float getMaximumValue(rcti *rect);
+
+ private:
+ unsigned int determineBufferSize();
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer")
#endif
};
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.cpp b/source/blender/compositor/intern/COM_MemoryProxy.cpp
index ab8df14de56..b73bac469d0 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.cpp
+++ b/source/blender/compositor/intern/COM_MemoryProxy.cpp
@@ -18,29 +18,28 @@
#include "COM_MemoryProxy.h"
-
MemoryProxy::MemoryProxy(DataType datatype)
{
- this->m_writeBufferOperation = NULL;
- this->m_executor = NULL;
- this->m_datatype = datatype;
+ this->m_writeBufferOperation = NULL;
+ this->m_executor = NULL;
+ this->m_datatype = datatype;
}
void MemoryProxy::allocate(unsigned int width, unsigned int height)
{
- rcti result;
- result.xmin = 0;
- result.xmax = width;
- result.ymin = 0;
- result.ymax = height;
+ rcti result;
+ result.xmin = 0;
+ result.xmax = width;
+ result.ymin = 0;
+ result.ymax = height;
- this->m_buffer = new MemoryBuffer(this, 1, &result);
+ this->m_buffer = new MemoryBuffer(this, 1, &result);
}
void MemoryProxy::free()
{
- if (this->m_buffer) {
- delete this->m_buffer;
- this->m_buffer = NULL;
- }
+ if (this->m_buffer) {
+ delete this->m_buffer;
+ this->m_buffer = NULL;
+ }
}
diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h
index 6f911a92f42..c363bf610cc 100644
--- a/source/blender/compositor/intern/COM_MemoryProxy.h
+++ b/source/blender/compositor/intern/COM_MemoryProxy.h
@@ -18,7 +18,6 @@
class MemoryProxy;
-
#ifndef __COM_MEMORYPROXY_H__
#define __COM_MEMORYPROXY_H__
#include "COM_ExecutionGroup.h"
@@ -33,82 +32,100 @@ class WriteBufferOperation;
* \ingroup Memory
*/
class MemoryProxy {
-private:
- /**
- * \brief reference to the output operation of the executiongroup
- */
- WriteBufferOperation *m_writeBufferOperation;
-
- /**
- * \brief reference to the executor. the Execution group that can fill a chunk
- */
- ExecutionGroup *m_executor;
-
- /**
- * \brief datatype of this MemoryProxy
- */
- /* DataType m_datatype; */ /* UNUSED */
-
- /**
- * \brief channel information of this buffer
- */
- /* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */
-
- /**
- * \brief the allocated memory
- */
- MemoryBuffer *m_buffer;
-
- /**
- * \brief datatype of this MemoryProxy
- */
- DataType m_datatype;
-
-public:
- MemoryProxy(DataType type);
-
- /**
- * \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
- * \param group: the ExecutionGroup to set
- */
- void setExecutor(ExecutionGroup *executor) { this->m_executor = executor; }
-
- /**
- * \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
- */
- ExecutionGroup *getExecutor() { return this->m_executor; }
-
- /**
- * \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
- * \param operation:
- */
- void setWriteBufferOperation(WriteBufferOperation *operation) { this->m_writeBufferOperation = operation; }
-
- /**
- * \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
- * \return WriteBufferOperation
- */
- WriteBufferOperation *getWriteBufferOperation() { return this->m_writeBufferOperation; }
-
- /**
- * \brief allocate memory of size width x height
- */
- void allocate(unsigned int width, unsigned int height);
-
- /**
- * \brief free the allocated memory
- */
- void free();
-
- /**
- * \brief get the allocated memory
- */
- inline MemoryBuffer *getBuffer() { return this->m_buffer; }
-
- inline DataType getDataType() { return this->m_datatype; }
+ private:
+ /**
+ * \brief reference to the output operation of the executiongroup
+ */
+ WriteBufferOperation *m_writeBufferOperation;
+
+ /**
+ * \brief reference to the executor. the Execution group that can fill a chunk
+ */
+ ExecutionGroup *m_executor;
+
+ /**
+ * \brief datatype of this MemoryProxy
+ */
+ /* DataType m_datatype; */ /* UNUSED */
+
+ /**
+ * \brief channel information of this buffer
+ */
+ /* ChannelInfo m_channelInfo[COM_NUMBER_OF_CHANNELS]; */ /* UNUSED */
+
+ /**
+ * \brief the allocated memory
+ */
+ MemoryBuffer *m_buffer;
+
+ /**
+ * \brief datatype of this MemoryProxy
+ */
+ DataType m_datatype;
+
+ public:
+ MemoryProxy(DataType type);
+
+ /**
+ * \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ * \param group: the ExecutionGroup to set
+ */
+ void setExecutor(ExecutionGroup *executor)
+ {
+ this->m_executor = executor;
+ }
+
+ /**
+ * \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
+ */
+ ExecutionGroup *getExecutor()
+ {
+ return this->m_executor;
+ }
+
+ /**
+ * \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * \param operation:
+ */
+ void setWriteBufferOperation(WriteBufferOperation *operation)
+ {
+ this->m_writeBufferOperation = operation;
+ }
+
+ /**
+ * \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
+ * \return WriteBufferOperation
+ */
+ WriteBufferOperation *getWriteBufferOperation()
+ {
+ return this->m_writeBufferOperation;
+ }
+
+ /**
+ * \brief allocate memory of size width x height
+ */
+ void allocate(unsigned int width, unsigned int height);
+
+ /**
+ * \brief free the allocated memory
+ */
+ void free();
+
+ /**
+ * \brief get the allocated memory
+ */
+ inline MemoryBuffer *getBuffer()
+ {
+ return this->m_buffer;
+ }
+
+ inline DataType getDataType()
+ {
+ return this->m_datatype;
+ }
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryProxy")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryProxy")
#endif
};
diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp
index 5435c0475c8..b38493e19f2 100644
--- a/source/blender/compositor/intern/COM_Node.cpp
+++ b/source/blender/compositor/intern/COM_Node.cpp
@@ -38,175 +38,171 @@ extern "C" {
**** Node ****
**************/
-Node::Node(bNode *editorNode, bool create_sockets) :
- m_editorNodeTree(NULL),
- m_editorNode(editorNode),
- m_inActiveGroup(false),
- m_instanceKey(NODE_INSTANCE_KEY_NONE)
-{
- if (create_sockets) {
- bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
- while (input != NULL) {
- DataType dt = COM_DT_VALUE;
- if (input->type == SOCK_RGBA) dt = COM_DT_COLOR;
- if (input->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
-
- this->addInputSocket(dt, input);
- input = input->next;
- }
- bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
- while (output != NULL) {
- DataType dt = COM_DT_VALUE;
- if (output->type == SOCK_RGBA) dt = COM_DT_COLOR;
- if (output->type == SOCK_VECTOR) dt = COM_DT_VECTOR;
-
- this->addOutputSocket(dt, output);
- output = output->next;
- }
- }
+Node::Node(bNode *editorNode, bool create_sockets)
+ : m_editorNodeTree(NULL),
+ m_editorNode(editorNode),
+ m_inActiveGroup(false),
+ m_instanceKey(NODE_INSTANCE_KEY_NONE)
+{
+ if (create_sockets) {
+ bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
+ while (input != NULL) {
+ DataType dt = COM_DT_VALUE;
+ if (input->type == SOCK_RGBA)
+ dt = COM_DT_COLOR;
+ if (input->type == SOCK_VECTOR)
+ dt = COM_DT_VECTOR;
+
+ this->addInputSocket(dt, input);
+ input = input->next;
+ }
+ bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
+ while (output != NULL) {
+ DataType dt = COM_DT_VALUE;
+ if (output->type == SOCK_RGBA)
+ dt = COM_DT_COLOR;
+ if (output->type == SOCK_VECTOR)
+ dt = COM_DT_VECTOR;
+
+ this->addOutputSocket(dt, output);
+ output = output->next;
+ }
+ }
}
Node::~Node()
{
- while (!this->m_outputsockets.empty()) {
- delete (this->m_outputsockets.back());
- this->m_outputsockets.pop_back();
- }
- while (!this->m_inputsockets.empty()) {
- delete (this->m_inputsockets.back());
- this->m_inputsockets.pop_back();
- }
+ while (!this->m_outputsockets.empty()) {
+ delete (this->m_outputsockets.back());
+ this->m_outputsockets.pop_back();
+ }
+ while (!this->m_inputsockets.empty()) {
+ delete (this->m_inputsockets.back());
+ this->m_inputsockets.pop_back();
+ }
}
void Node::addInputSocket(DataType datatype)
{
- this->addInputSocket(datatype, NULL);
+ this->addInputSocket(datatype, NULL);
}
void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
{
- NodeInput *socket = new NodeInput(this, bSocket, datatype);
- this->m_inputsockets.push_back(socket);
+ NodeInput *socket = new NodeInput(this, bSocket, datatype);
+ this->m_inputsockets.push_back(socket);
}
void Node::addOutputSocket(DataType datatype)
{
- this->addOutputSocket(datatype, NULL);
-
+ this->addOutputSocket(datatype, NULL);
}
void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
{
- NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
- this->m_outputsockets.push_back(socket);
+ NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
+ this->m_outputsockets.push_back(socket);
}
NodeOutput *Node::getOutputSocket(unsigned int index) const
{
- BLI_assert(index < this->m_outputsockets.size());
- return this->m_outputsockets[index];
+ BLI_assert(index < this->m_outputsockets.size());
+ return this->m_outputsockets[index];
}
NodeInput *Node::getInputSocket(unsigned int index) const
{
- BLI_assert(index < this->m_inputsockets.size());
- return this->m_inputsockets[index];
+ BLI_assert(index < this->m_inputsockets.size());
+ return this->m_inputsockets[index];
}
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;
- int index = 0;
- while (bSock != NULL) {
- if (index == editorNodeInputSocketIndex) {
- return bSock;
- }
- index++;
- bSock = bSock->next;
- }
- return NULL;
+ bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;
+ int index = 0;
+ while (bSock != NULL) {
+ if (index == editorNodeInputSocketIndex) {
+ return bSock;
+ }
+ index++;
+ bSock = bSock->next;
+ }
+ return NULL;
}
bNodeSocket *Node::getEditorOutputSocket(int editorNodeInputSocketIndex)
{
- bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first;
- int index = 0;
- while (bSock != NULL) {
- if (index == editorNodeInputSocketIndex) {
- return bSock;
- }
- index++;
- bSock = bSock->next;
- }
- return NULL;
+ bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first;
+ int index = 0;
+ while (bSock != NULL) {
+ if (index == editorNodeInputSocketIndex) {
+ return bSock;
+ }
+ index++;
+ bSock = bSock->next;
+ }
+ return NULL;
}
-
/*******************
**** NodeInput ****
*******************/
-NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype) :
- m_node(node),
- m_editorSocket(b_socket),
- m_datatype(datatype),
- m_link(NULL)
+NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
+ : m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(NULL)
{
}
void NodeInput::setLink(NodeOutput *link)
{
- m_link = link;
+ m_link = link;
}
float NodeInput::getEditorValueFloat()
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get(&ptr, "default_value");
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get(&ptr, "default_value");
}
void NodeInput::getEditorValueColor(float *value)
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
}
void NodeInput::getEditorValueVector(float *value)
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
}
-
/********************
**** NodeOutput ****
********************/
-NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype) :
- m_node(node),
- m_editorSocket(b_socket),
- m_datatype(datatype)
+NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype)
+ : m_node(node), m_editorSocket(b_socket), m_datatype(datatype)
{
}
float NodeOutput::getEditorValueFloat()
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get(&ptr, "default_value");
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get(&ptr, "default_value");
}
void NodeOutput::getEditorValueColor(float *value)
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
}
void NodeOutput::getEditorValueVector(float *value)
{
- PointerRNA ptr;
- RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
- return RNA_float_get_array(&ptr, "default_value", value);
+ PointerRNA ptr;
+ RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
+ return RNA_float_get_array(&ptr, "default_value", value);
}
diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h
index 33c86bd2cc1..9bacf271283 100644
--- a/source/blender/compositor/intern/COM_Node.h
+++ b/source/blender/compositor/intern/COM_Node.h
@@ -38,230 +38,295 @@ class NodeConverter;
* My node documentation.
*/
class Node {
-public:
- typedef std::vector<NodeInput *> Inputs;
- typedef std::vector<NodeOutput *> Outputs;
-
-private:
- /**
- * \brief stores the reference to the SDNA bNode struct
- */
- bNodeTree *m_editorNodeTree;
-
- /**
- * \brief stores the reference to the SDNA bNode struct
- */
- bNode *m_editorNode;
-
- /**
- * \brief the list of actual inputsockets \see NodeInput
- */
- Inputs m_inputsockets;
-
- /**
- * \brief the list of actual outputsockets \see NodeOutput
- */
- Outputs m_outputsockets;
-
- /**
- * \brief Is this node part of the active group
- */
- bool m_inActiveGroup;
-
- /**
- * \brief Instance key to identify the node in an instance hash table
- */
- bNodeInstanceKey m_instanceKey;
-
-protected:
- /**
- * \brief get access to the vector of input sockets
- */
- const Inputs &getInputSockets() const { return this->m_inputsockets; }
-
- /**
- * \brief get access to the vector of input sockets
- */
- const Outputs &getOutputSockets() const { return this->m_outputsockets; }
-
-public:
- Node(bNode *editorNode, bool create_sockets = true);
- virtual ~Node();
-
- /**
- * \brief get the reference to the SDNA bNode struct
- */
- bNode *getbNode() const {return m_editorNode;}
-
- /**
- * \brief get the reference to the SDNA bNodeTree struct
- */
- bNodeTree *getbNodeTree() const {return m_editorNodeTree;}
-
- /**
- * \brief set the reference to the bNode
- * \note used in Node instances to receive the storage/settings and complex node for highlight during execution
- * \param bNode:
- */
- void setbNode(bNode *node) {this->m_editorNode = node;}
-
- /**
- * \brief set the reference to the bNodeTree
- * \param bNodeTree:
- */
- void setbNodeTree(bNodeTree *nodetree) {this->m_editorNodeTree = nodetree;}
-
- /**
- * \brief Return the number of input sockets of this node.
- */
- unsigned int getNumberOfInputSockets() const { return this->m_inputsockets.size(); }
-
- /**
- * \brief Return the number of output sockets of this node.
- */
- unsigned int getNumberOfOutputSockets() const { return this->m_outputsockets.size(); }
-
- /**
- * get the reference to a certain outputsocket
- * \param index:
- * the index of the needed outputsocket
- */
- NodeOutput *getOutputSocket(const unsigned int index) const;
-
- /**
- * get the reference to the first outputsocket
- * \param index:
- * the index of the needed outputsocket
- */
- inline NodeOutput *getOutputSocket() const { return getOutputSocket(0); }
-
- /**
- * get the reference to a certain inputsocket
- * \param index:
- * the index of the needed inputsocket
- */
- NodeInput *getInputSocket(const unsigned int index) const;
-
- /** Check if this is an input node
- * An input node is a node that only has output sockets and no input sockets
- */
- bool isInputNode() const { return m_inputsockets.empty(); }
-
- /**
- * \brief Is this node in the active group (the group that is being edited)
- * \param isInActiveGroup:
- */
- void setIsInActiveGroup(bool value) { this->m_inActiveGroup = value; }
-
- /**
- * \brief Is this node part of the active group
- * the active group is the group that is currently being edited. When no group is edited,
- * the active group will be the main tree (all nodes that are not part of a group will be active)
- * \return bool [false:true]
- */
- inline bool isInActiveGroup() const { return this->m_inActiveGroup; }
-
- /**
- * \brief convert node to operation
- *
- * \todo this must be described further
- *
- * \param system: the ExecutionSystem where the operations need to be added
- * \param context: reference to the CompositorContext
- */
- virtual void convertToOperations(NodeConverter &converter, const CompositorContext &context) const = 0;
-
- /**
- * Create dummy warning operation, use when we can't get the source data.
- */
- NodeOperation *convertToOperations_invalid_index(NodeConverter *compiler, int index) const;
- /**
- * when a node has no valid data (missing image or a group nodes ID pointer is NULL)
- * call this function from #convertToOperations, this way the node sockets are converted
- * into valid outputs, without this the compositor system gets confused and crashes, see [#32490]
- */
- void convertToOperations_invalid(NodeConverter *compiler) const;
-
- void setInstanceKey(bNodeInstanceKey instance_key) { m_instanceKey = instance_key; }
- bNodeInstanceKey getInstanceKey() const { return m_instanceKey; }
-
-protected:
- /**
- * \brief add an NodeInput to the collection of inputsockets
- * \note may only be called in an constructor
- * \param socket: the NodeInput to add
- */
- void addInputSocket(DataType datatype);
- void addInputSocket(DataType datatype, bNodeSocket *socket);
-
- /**
- * \brief add an NodeOutput to the collection of outputsockets
- * \note may only be called in an constructor
- * \param socket: the NodeOutput to add
- */
- void addOutputSocket(DataType datatype);
- void addOutputSocket(DataType datatype, bNodeSocket *socket);
-
- bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
- bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
+ public:
+ typedef std::vector<NodeInput *> Inputs;
+ typedef std::vector<NodeOutput *> Outputs;
+
+ private:
+ /**
+ * \brief stores the reference to the SDNA bNode struct
+ */
+ bNodeTree *m_editorNodeTree;
+
+ /**
+ * \brief stores the reference to the SDNA bNode struct
+ */
+ bNode *m_editorNode;
+
+ /**
+ * \brief the list of actual inputsockets \see NodeInput
+ */
+ Inputs m_inputsockets;
+
+ /**
+ * \brief the list of actual outputsockets \see NodeOutput
+ */
+ Outputs m_outputsockets;
+
+ /**
+ * \brief Is this node part of the active group
+ */
+ bool m_inActiveGroup;
+
+ /**
+ * \brief Instance key to identify the node in an instance hash table
+ */
+ bNodeInstanceKey m_instanceKey;
+
+ protected:
+ /**
+ * \brief get access to the vector of input sockets
+ */
+ const Inputs &getInputSockets() const
+ {
+ return this->m_inputsockets;
+ }
+
+ /**
+ * \brief get access to the vector of input sockets
+ */
+ const Outputs &getOutputSockets() const
+ {
+ return this->m_outputsockets;
+ }
+
+ public:
+ Node(bNode *editorNode, bool create_sockets = true);
+ virtual ~Node();
+
+ /**
+ * \brief get the reference to the SDNA bNode struct
+ */
+ bNode *getbNode() const
+ {
+ return m_editorNode;
+ }
+
+ /**
+ * \brief get the reference to the SDNA bNodeTree struct
+ */
+ bNodeTree *getbNodeTree() const
+ {
+ return m_editorNodeTree;
+ }
+
+ /**
+ * \brief set the reference to the bNode
+ * \note used in Node instances to receive the storage/settings and complex node for highlight during execution
+ * \param bNode:
+ */
+ void setbNode(bNode *node)
+ {
+ this->m_editorNode = node;
+ }
+
+ /**
+ * \brief set the reference to the bNodeTree
+ * \param bNodeTree:
+ */
+ void setbNodeTree(bNodeTree *nodetree)
+ {
+ this->m_editorNodeTree = nodetree;
+ }
+
+ /**
+ * \brief Return the number of input sockets of this node.
+ */
+ unsigned int getNumberOfInputSockets() const
+ {
+ return this->m_inputsockets.size();
+ }
+
+ /**
+ * \brief Return the number of output sockets of this node.
+ */
+ unsigned int getNumberOfOutputSockets() const
+ {
+ return this->m_outputsockets.size();
+ }
+
+ /**
+ * get the reference to a certain outputsocket
+ * \param index:
+ * the index of the needed outputsocket
+ */
+ NodeOutput *getOutputSocket(const unsigned int index) const;
+
+ /**
+ * get the reference to the first outputsocket
+ * \param index:
+ * the index of the needed outputsocket
+ */
+ inline NodeOutput *getOutputSocket() const
+ {
+ return getOutputSocket(0);
+ }
+
+ /**
+ * get the reference to a certain inputsocket
+ * \param index:
+ * the index of the needed inputsocket
+ */
+ NodeInput *getInputSocket(const unsigned int index) const;
+
+ /** Check if this is an input node
+ * An input node is a node that only has output sockets and no input sockets
+ */
+ bool isInputNode() const
+ {
+ return m_inputsockets.empty();
+ }
+
+ /**
+ * \brief Is this node in the active group (the group that is being edited)
+ * \param isInActiveGroup:
+ */
+ void setIsInActiveGroup(bool value)
+ {
+ this->m_inActiveGroup = value;
+ }
+
+ /**
+ * \brief Is this node part of the active group
+ * the active group is the group that is currently being edited. When no group is edited,
+ * the active group will be the main tree (all nodes that are not part of a group will be active)
+ * \return bool [false:true]
+ */
+ inline bool isInActiveGroup() const
+ {
+ return this->m_inActiveGroup;
+ }
+
+ /**
+ * \brief convert node to operation
+ *
+ * \todo this must be described further
+ *
+ * \param system: the ExecutionSystem where the operations need to be added
+ * \param context: reference to the CompositorContext
+ */
+ virtual void convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const = 0;
+
+ /**
+ * Create dummy warning operation, use when we can't get the source data.
+ */
+ NodeOperation *convertToOperations_invalid_index(NodeConverter *compiler, int index) const;
+ /**
+ * when a node has no valid data (missing image or a group nodes ID pointer is NULL)
+ * call this function from #convertToOperations, this way the node sockets are converted
+ * into valid outputs, without this the compositor system gets confused and crashes, see [#32490]
+ */
+ void convertToOperations_invalid(NodeConverter *compiler) const;
+
+ void setInstanceKey(bNodeInstanceKey instance_key)
+ {
+ m_instanceKey = instance_key;
+ }
+ bNodeInstanceKey getInstanceKey() const
+ {
+ return m_instanceKey;
+ }
+
+ protected:
+ /**
+ * \brief add an NodeInput to the collection of inputsockets
+ * \note may only be called in an constructor
+ * \param socket: the NodeInput to add
+ */
+ void addInputSocket(DataType datatype);
+ void addInputSocket(DataType datatype, bNodeSocket *socket);
+
+ /**
+ * \brief add an NodeOutput to the collection of outputsockets
+ * \note may only be called in an constructor
+ * \param socket: the NodeOutput to add
+ */
+ void addOutputSocket(DataType datatype);
+ void addOutputSocket(DataType datatype, bNodeSocket *socket);
+
+ bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
+ bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
};
-
/**
* \brief NodeInput are sockets that can receive data/input
* \ingroup Model
*/
class NodeInput {
-private:
- Node *m_node;
- bNodeSocket *m_editorSocket;
-
- DataType m_datatype;
-
- /**
- * \brief link connected to this NodeInput.
- * An input socket can only have a single link
- */
- NodeOutput *m_link;
-
-public:
- NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
-
- Node *getNode() const { return this->m_node; }
- DataType getDataType() const { return m_datatype; }
- bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
-
- void setLink(NodeOutput *link);
- bool isLinked() const { return m_link; }
- NodeOutput *getLink() { return m_link; }
-
- float getEditorValueFloat();
- void getEditorValueColor(float *value);
- void getEditorValueVector(float *value);
+ private:
+ Node *m_node;
+ bNodeSocket *m_editorSocket;
+
+ DataType m_datatype;
+
+ /**
+ * \brief link connected to this NodeInput.
+ * An input socket can only have a single link
+ */
+ NodeOutput *m_link;
+
+ public:
+ NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
+
+ Node *getNode() const
+ {
+ return this->m_node;
+ }
+ DataType getDataType() const
+ {
+ return m_datatype;
+ }
+ bNodeSocket *getbNodeSocket() const
+ {
+ return this->m_editorSocket;
+ }
+
+ void setLink(NodeOutput *link);
+ bool isLinked() const
+ {
+ return m_link;
+ }
+ NodeOutput *getLink()
+ {
+ return m_link;
+ }
+
+ float getEditorValueFloat();
+ void getEditorValueColor(float *value);
+ void getEditorValueVector(float *value);
};
-
/**
* \brief NodeOutput are sockets that can send data/input
* \ingroup Model
*/
class NodeOutput {
-private:
- Node *m_node;
- bNodeSocket *m_editorSocket;
-
- DataType m_datatype;
-
-public:
- NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
-
- Node *getNode() const { return this->m_node; }
- DataType getDataType() const { return m_datatype; }
- bNodeSocket *getbNodeSocket() const { return this->m_editorSocket; }
-
- float getEditorValueFloat();
- void getEditorValueColor(float *value);
- void getEditorValueVector(float *value);
+ private:
+ Node *m_node;
+ bNodeSocket *m_editorSocket;
+
+ DataType m_datatype;
+
+ public:
+ NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
+
+ Node *getNode() const
+ {
+ return this->m_node;
+ }
+ DataType getDataType() const
+ {
+ return m_datatype;
+ }
+ bNodeSocket *getbNodeSocket() const
+ {
+ return this->m_editorSocket;
+ }
+
+ float getEditorValueFloat();
+ void getEditorValueColor(float *value);
+ void getEditorValueVector(float *value);
};
-#endif /* __COM_NODE_H__ */
+#endif /* __COM_NODE_H__ */
diff --git a/source/blender/compositor/intern/COM_NodeConverter.cpp b/source/blender/compositor/intern/COM_NodeConverter.cpp
index c775a9ed49f..c44721e3939 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.cpp
+++ b/source/blender/compositor/intern/COM_NodeConverter.cpp
@@ -31,135 +31,134 @@ extern "C" {
#include "COM_NodeConverter.h" /* own include */
-NodeConverter::NodeConverter(NodeOperationBuilder *builder) :
- m_builder(builder)
+NodeConverter::NodeConverter(NodeOperationBuilder *builder) : m_builder(builder)
{
}
void NodeConverter::addOperation(NodeOperation *operation)
{
- m_builder->addOperation(operation);
+ m_builder->addOperation(operation);
}
void NodeConverter::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
{
- m_builder->mapInputSocket(node_socket, operation_socket);
+ m_builder->mapInputSocket(node_socket, operation_socket);
}
void NodeConverter::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
{
- m_builder->mapOutputSocket(node_socket, operation_socket);
+ m_builder->mapOutputSocket(node_socket, operation_socket);
}
void NodeConverter::addLink(NodeOperationOutput *from, NodeOperationInput *to)
{
- m_builder->addLink(from, to);
+ m_builder->addLink(from, to);
}
void NodeConverter::addPreview(NodeOperationOutput *output)
{
- m_builder->addPreview(output);
+ m_builder->addPreview(output);
}
void NodeConverter::addNodeInputPreview(NodeInput *input)
{
- m_builder->addNodeInputPreview(input);
+ m_builder->addNodeInputPreview(input);
}
NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
{
- /* this is a really bad situation - bring on the pink! - so artists know this is bad */
- const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
+ /* this is a really bad situation - bring on the pink! - so artists know this is bad */
+ const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
- SetColorOperation *operation = new SetColorOperation();
- operation->setChannels(warning_color);
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(warning_color);
- m_builder->addOperation(operation);
- m_builder->mapOutputSocket(output, operation->getOutputSocket());
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
- return operation;
+ return operation;
}
NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_conversion)
{
- SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
- m_builder->addOperation(proxy);
+ SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
+ m_builder->addOperation(proxy);
- m_builder->mapInputSocket(input, proxy->getInputSocket(0));
+ m_builder->mapInputSocket(input, proxy->getInputSocket(0));
- return proxy->getOutputSocket();
+ return proxy->getOutputSocket();
}
NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output, bool use_conversion)
{
- SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
- m_builder->addOperation(proxy);
+ SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
+ m_builder->addOperation(proxy);
- m_builder->mapOutputSocket(output, proxy->getOutputSocket());
+ m_builder->mapOutputSocket(output, proxy->getOutputSocket());
- return proxy->getInputSocket(0);
+ return proxy->getInputSocket(0);
}
void NodeConverter::addInputValue(NodeOperationInput *input, float value)
{
- SetValueOperation *operation = new SetValueOperation();
- operation->setValue(value);
+ SetValueOperation *operation = new SetValueOperation();
+ operation->setValue(value);
- m_builder->addOperation(operation);
- m_builder->addLink(operation->getOutputSocket(), input);
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
}
void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4])
{
- SetColorOperation *operation = new SetColorOperation();
- operation->setChannels(value);
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(value);
- m_builder->addOperation(operation);
- m_builder->addLink(operation->getOutputSocket(), input);
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
}
void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3])
{
- SetVectorOperation *operation = new SetVectorOperation();
- operation->setVector(value);
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setVector(value);
- m_builder->addOperation(operation);
- m_builder->addLink(operation->getOutputSocket(), input);
+ m_builder->addOperation(operation);
+ m_builder->addLink(operation->getOutputSocket(), input);
}
void NodeConverter::addOutputValue(NodeOutput *output, float value)
{
- SetValueOperation *operation = new SetValueOperation();
- operation->setValue(value);
+ SetValueOperation *operation = new SetValueOperation();
+ operation->setValue(value);
- m_builder->addOperation(operation);
- m_builder->mapOutputSocket(output, operation->getOutputSocket());
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
void NodeConverter::addOutputColor(NodeOutput *output, const float value[4])
{
- SetColorOperation *operation = new SetColorOperation();
- operation->setChannels(value);
+ SetColorOperation *operation = new SetColorOperation();
+ operation->setChannels(value);
- m_builder->addOperation(operation);
- m_builder->mapOutputSocket(output, operation->getOutputSocket());
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
void NodeConverter::addOutputVector(NodeOutput *output, const float value[3])
{
- SetVectorOperation *operation = new SetVectorOperation();
- operation->setVector(value);
+ SetVectorOperation *operation = new SetVectorOperation();
+ operation->setVector(value);
- m_builder->addOperation(operation);
- m_builder->mapOutputSocket(output, operation->getOutputSocket());
+ m_builder->addOperation(operation);
+ m_builder->mapOutputSocket(output, operation->getOutputSocket());
}
void NodeConverter::registerViewer(ViewerOperation *viewer)
{
- m_builder->registerViewer(viewer);
+ m_builder->registerViewer(viewer);
}
ViewerOperation *NodeConverter::active_viewer() const
{
- return m_builder->active_viewer();
+ return m_builder->active_viewer();
}
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
index c3d9a115435..56e9aa85010 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.h
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -40,85 +40,85 @@ class ViewerOperation;
* and map original node sockets to their inputs or outputs.
*/
class NodeConverter {
-public:
- NodeConverter(NodeOperationBuilder *builder);
-
- /**
- * Insert a new operation into the operations graph.
- * The operation must be created by the node.
- */
- void addOperation(NodeOperation *operation);
-
- /**
- * Map input socket of the node to an operation socket.
- * Links between nodes will then generate equivalent links between
- * the mapped operation sockets.
- *
- * \note A \a Node input can be mapped to multiple \a NodeOperation inputs.
- */
- void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
- /**
- * Map output socket of the node to an operation socket.
- * Links between nodes will then generate equivalent links between
- * the mapped operation sockets.
- *
- * \note A \a Node output can only be mapped to one \a NodeOperation output.
- * Any existing operation output mapping will be replaced.
- */
- void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
-
- /**
- * Create a proxy operation for a node input.
- * This operation will be removed later and replaced
- * by direct links between the connected operations.
- */
- NodeOperationOutput *addInputProxy(NodeInput *input, bool use_conversion);
- /**
- * Create a proxy operation for a node output.
- * This operation will be removed later and replaced
- * by direct links between the connected operations.
- */
- NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion);
-
- /** Define a constant input value. */
- void addInputValue(NodeOperationInput *input, float value);
- /** Define a constant input color. */
- void addInputColor(NodeOperationInput *input, const float value[4]);
- /** Define a constant input vector. */
- void addInputVector(NodeOperationInput *input, const float value[3]);
-
- /** Define a constant output value. */
- void addOutputValue(NodeOutput *output, float value);
- /** Define a constant output color. */
- void addOutputColor(NodeOutput *output, const float value[4]);
- /** Define a constant output vector. */
- void addOutputVector(NodeOutput *output, const float value[3]);
-
- /** Add an explicit link between two operations. */
- void addLink(NodeOperationOutput *from, NodeOperationInput *to);
-
- /** Add a preview operation for a operation output. */
- void addPreview(NodeOperationOutput *output);
- /** Add a preview operation for a node input. */
- void addNodeInputPreview(NodeInput *input);
-
- /**
- * When a node has no valid data
- * \note missing image / group pointer, or missing renderlayer from EXR
- */
- NodeOperation *setInvalidOutput(NodeOutput *output);
-
- /** Define a viewer operation as the active output, if possible */
- void registerViewer(ViewerOperation *viewer);
- /** The currently active viewer output operation */
- ViewerOperation *active_viewer() const;
-
-private:
- /** The internal builder for storing the results of the graph construction. */
- NodeOperationBuilder *m_builder;
+ public:
+ NodeConverter(NodeOperationBuilder *builder);
+
+ /**
+ * Insert a new operation into the operations graph.
+ * The operation must be created by the node.
+ */
+ void addOperation(NodeOperation *operation);
+
+ /**
+ * Map input socket of the node to an operation socket.
+ * Links between nodes will then generate equivalent links between
+ * the mapped operation sockets.
+ *
+ * \note A \a Node input can be mapped to multiple \a NodeOperation inputs.
+ */
+ void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
+ /**
+ * Map output socket of the node to an operation socket.
+ * Links between nodes will then generate equivalent links between
+ * the mapped operation sockets.
+ *
+ * \note A \a Node output can only be mapped to one \a NodeOperation output.
+ * Any existing operation output mapping will be replaced.
+ */
+ void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
+
+ /**
+ * Create a proxy operation for a node input.
+ * This operation will be removed later and replaced
+ * by direct links between the connected operations.
+ */
+ NodeOperationOutput *addInputProxy(NodeInput *input, bool use_conversion);
+ /**
+ * Create a proxy operation for a node output.
+ * This operation will be removed later and replaced
+ * by direct links between the connected operations.
+ */
+ NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion);
+
+ /** Define a constant input value. */
+ void addInputValue(NodeOperationInput *input, float value);
+ /** Define a constant input color. */
+ void addInputColor(NodeOperationInput *input, const float value[4]);
+ /** Define a constant input vector. */
+ void addInputVector(NodeOperationInput *input, const float value[3]);
+
+ /** Define a constant output value. */
+ void addOutputValue(NodeOutput *output, float value);
+ /** Define a constant output color. */
+ void addOutputColor(NodeOutput *output, const float value[4]);
+ /** Define a constant output vector. */
+ void addOutputVector(NodeOutput *output, const float value[3]);
+
+ /** Add an explicit link between two operations. */
+ void addLink(NodeOperationOutput *from, NodeOperationInput *to);
+
+ /** Add a preview operation for a operation output. */
+ void addPreview(NodeOperationOutput *output);
+ /** Add a preview operation for a node input. */
+ void addNodeInputPreview(NodeInput *input);
+
+ /**
+ * When a node has no valid data
+ * \note missing image / group pointer, or missing renderlayer from EXR
+ */
+ NodeOperation *setInvalidOutput(NodeOutput *output);
+
+ /** Define a viewer operation as the active output, if possible */
+ void registerViewer(ViewerOperation *viewer);
+ /** The currently active viewer output operation */
+ ViewerOperation *active_viewer() const;
+
+ private:
+ /** The internal builder for storing the results of the graph construction. */
+ NodeOperationBuilder *m_builder;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
#endif
};
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index f23b186416d..89f4542d42f 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -45,254 +45,282 @@ NodeGraph::NodeGraph()
NodeGraph::~NodeGraph()
{
- for (int index = 0; index < this->m_nodes.size(); index++) {
- Node *node = this->m_nodes[index];
- delete node;
- }
+ for (int index = 0; index < this->m_nodes.size(); index++) {
+ Node *node = this->m_nodes[index];
+ delete node;
+ }
}
void NodeGraph::from_bNodeTree(const CompositorContext &context, bNodeTree *tree)
{
- add_bNodeTree(context, 0, tree, NODE_INSTANCE_KEY_BASE);
+ add_bNodeTree(context, 0, tree, NODE_INSTANCE_KEY_BASE);
}
bNodeSocket *NodeGraph::find_b_node_input(bNode *b_group_node, const char *identifier)
{
- for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->inputs.first; b_sock; b_sock = b_sock->next) {
- if (STREQ(b_sock->identifier, identifier))
- return b_sock;
- }
- return NULL;
+ for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->inputs.first; b_sock;
+ b_sock = b_sock->next) {
+ if (STREQ(b_sock->identifier, identifier))
+ return b_sock;
+ }
+ return NULL;
}
bNodeSocket *NodeGraph::find_b_node_output(bNode *b_group_node, const char *identifier)
{
- for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->outputs.first; b_sock; b_sock = b_sock->next) {
- if (STREQ(b_sock->identifier, identifier))
- return b_sock;
- }
- return NULL;
+ for (bNodeSocket *b_sock = (bNodeSocket *)b_group_node->outputs.first; b_sock;
+ b_sock = b_sock->next) {
+ if (STREQ(b_sock->identifier, identifier))
+ return b_sock;
+ }
+ return NULL;
}
-void NodeGraph::add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group)
+void NodeGraph::add_node(Node *node,
+ bNodeTree *b_ntree,
+ bNodeInstanceKey key,
+ bool is_active_group)
{
- node->setbNodeTree(b_ntree);
- node->setInstanceKey(key);
- node->setIsInActiveGroup(is_active_group);
+ node->setbNodeTree(b_ntree);
+ node->setInstanceKey(key);
+ node->setIsInActiveGroup(is_active_group);
- m_nodes.push_back(node);
+ m_nodes.push_back(node);
- DebugInfo::node_added(node);
+ DebugInfo::node_added(node);
}
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
{
- m_links.push_back(Link(fromSocket, toSocket));
+ m_links.push_back(Link(fromSocket, toSocket));
- /* register with the input */
- toSocket->setLink(fromSocket);
+ /* register with the input */
+ toSocket->setLink(fromSocket);
}
-void NodeGraph::add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key)
+void NodeGraph::add_bNodeTree(const CompositorContext &context,
+ int nodes_start,
+ bNodeTree *tree,
+ bNodeInstanceKey parent_key)
{
- const bNodeTree *basetree = context.getbNodeTree();
-
- /* update viewers in the active edittree as well the base tree (for backdrop) */
- bool is_active_group = (parent_key.value == basetree->active_viewer_key.value);
-
- /* add all nodes of the tree to the node list */
- for (bNode *node = (bNode *)tree->nodes.first; node; node = node->next) {
- bNodeInstanceKey key = BKE_node_instance_key(parent_key, tree, node);
- add_bNode(context, tree, node, key, is_active_group);
- }
-
- NodeRange node_range(m_nodes.begin() + nodes_start, m_nodes.end());
- /* add all nodelinks of the tree to the link list */
- for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
- add_bNodeLink(node_range, nodelink);
- }
+ const bNodeTree *basetree = context.getbNodeTree();
+
+ /* update viewers in the active edittree as well the base tree (for backdrop) */
+ bool is_active_group = (parent_key.value == basetree->active_viewer_key.value);
+
+ /* add all nodes of the tree to the node list */
+ for (bNode *node = (bNode *)tree->nodes.first; node; node = node->next) {
+ bNodeInstanceKey key = BKE_node_instance_key(parent_key, tree, node);
+ add_bNode(context, tree, node, key, is_active_group);
+ }
+
+ NodeRange node_range(m_nodes.begin() + nodes_start, m_nodes.end());
+ /* add all nodelinks of the tree to the link list */
+ for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
+ add_bNodeLink(node_range, nodelink);
+ }
}
-void NodeGraph::add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+void NodeGraph::add_bNode(const CompositorContext &context,
+ bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group)
{
- /* replace muted nodes by proxies for internal links */
- if (b_node->flag & NODE_MUTED) {
- add_proxies_mute(b_ntree, b_node, key, is_active_group);
- return;
- }
-
- /* replace slow nodes with proxies for fast execution */
- if (context.isFastCalculation() && !Converter::is_fast_node(b_node)) {
- add_proxies_skip(b_ntree, b_node, key, is_active_group);
- return;
- }
-
- /* special node types */
- if (ELEM(b_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
- add_proxies_group(context, b_node, key);
- }
- else if (b_node->type == NODE_REROUTE) {
- add_proxies_reroute(b_ntree, b_node, key, is_active_group);
- }
- else {
- /* regular nodes, handled in Converter */
- Node *node = Converter::convert(b_node);
- if (node)
- add_node(node, b_ntree, key, is_active_group);
- }
+ /* replace muted nodes by proxies for internal links */
+ if (b_node->flag & NODE_MUTED) {
+ add_proxies_mute(b_ntree, b_node, key, is_active_group);
+ return;
+ }
+
+ /* replace slow nodes with proxies for fast execution */
+ if (context.isFastCalculation() && !Converter::is_fast_node(b_node)) {
+ add_proxies_skip(b_ntree, b_node, key, is_active_group);
+ return;
+ }
+
+ /* special node types */
+ if (ELEM(b_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
+ add_proxies_group(context, b_node, key);
+ }
+ else if (b_node->type == NODE_REROUTE) {
+ add_proxies_reroute(b_ntree, b_node, key, is_active_group);
+ }
+ else {
+ /* regular nodes, handled in Converter */
+ Node *node = Converter::convert(b_node);
+ if (node)
+ add_node(node, b_ntree, key, is_active_group);
+ }
}
NodeGraph::NodeInputs NodeGraph::find_inputs(const NodeRange &node_range, bNodeSocket *b_socket)
{
- NodeInputs result;
- for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
- Node *node = *it;
- for (int index = 0; index < node->getNumberOfInputSockets(); index++) {
- NodeInput *input = node->getInputSocket(index);
- if (input->getbNodeSocket() == b_socket) {
- result.push_back(input);
- }
- }
- }
- return result;
+ NodeInputs result;
+ for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
+ Node *node = *it;
+ for (int index = 0; index < node->getNumberOfInputSockets(); index++) {
+ NodeInput *input = node->getInputSocket(index);
+ if (input->getbNodeSocket() == b_socket) {
+ result.push_back(input);
+ }
+ }
+ }
+ return result;
}
NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_socket)
{
- for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
- Node *node = *it;
- for (int index = 0; index < node->getNumberOfOutputSockets(); index++) {
- NodeOutput *output = node->getOutputSocket(index);
- if (output->getbNodeSocket() == b_socket) {
- return output;
- }
- }
- }
- return NULL;
+ for (NodeGraph::NodeIterator it = node_range.first; it != node_range.second; ++it) {
+ Node *node = *it;
+ for (int index = 0; index < node->getNumberOfOutputSockets(); index++) {
+ NodeOutput *output = node->getOutputSocket(index);
+ if (output->getbNodeSocket() == b_socket) {
+ return output;
+ }
+ }
+ }
+ return NULL;
}
void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink)
{
- /// \note: ignore invalid links
- if (!(b_nodelink->flag & NODE_LINK_VALID))
- return;
- if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL))
- return;
-
- /* Note: a DNA input socket can have multiple NodeInput in the compositor tree! (proxies)
- * The output then gets linked to each one of them.
- */
-
- NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
- if (!output)
- return;
-
- NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
- for (NodeInputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
- NodeInput *input = *it;
- if (input->isLinked())
- continue;
- add_link(output, input);
- }
+ /// \note: ignore invalid links
+ if (!(b_nodelink->flag & NODE_LINK_VALID))
+ return;
+ if ((b_nodelink->fromsock->flag & SOCK_UNAVAIL) || (b_nodelink->tosock->flag & SOCK_UNAVAIL))
+ return;
+
+ /* Note: a DNA input socket can have multiple NodeInput in the compositor tree! (proxies)
+ * The output then gets linked to each one of them.
+ */
+
+ NodeOutput *output = find_output(node_range, b_nodelink->fromsock);
+ if (!output)
+ return;
+
+ NodeInputs inputs = find_inputs(node_range, b_nodelink->tosock);
+ for (NodeInputs::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
+ NodeInput *input = *it;
+ if (input->isLinked())
+ continue;
+ add_link(output, input);
+ }
}
/* **** Special proxy node type conversions **** */
-void NodeGraph::add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+void NodeGraph::add_proxies_mute(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group)
{
- for (bNodeLink *b_link = (bNodeLink *)b_node->internal_links.first; b_link; b_link = b_link->next) {
- SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock, false);
- add_node(proxy, b_ntree, key, is_active_group);
- }
+ for (bNodeLink *b_link = (bNodeLink *)b_node->internal_links.first; b_link;
+ b_link = b_link->next) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock, false);
+ add_node(proxy, b_ntree, key, is_active_group);
+ }
}
-void NodeGraph::add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+void NodeGraph::add_proxies_skip(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group)
{
- for (bNodeSocket *output = (bNodeSocket *)b_node->outputs.first; output; output = output->next) {
- bNodeSocket *input;
-
- /* look for first input with matching datatype for each output */
- for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
- if (input->type == output->type)
- break;
- }
-
- if (input) {
- SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output, true);
- add_node(proxy, b_ntree, key, is_active_group);
- }
- }
+ for (bNodeSocket *output = (bNodeSocket *)b_node->outputs.first; output; output = output->next) {
+ bNodeSocket *input;
+
+ /* look for first input with matching datatype for each output */
+ for (input = (bNodeSocket *)b_node->inputs.first; input; input = input->next) {
+ if (input->type == output->type)
+ break;
+ }
+
+ if (input) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output, true);
+ add_node(proxy, b_ntree, key, is_active_group);
+ }
+ }
}
void NodeGraph::add_proxies_group_inputs(bNode *b_node, bNode *b_node_io)
{
- bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
- BLI_assert(b_group_tree); /* should have been checked in advance */
-
- /* not important for proxies */
- bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
- bool is_active_group = false;
-
- for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
- bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier);
- if (b_sock_group) {
- SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io, true);
- add_node(proxy, b_group_tree, key, is_active_group);
- }
- }
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+ BLI_assert(b_group_tree); /* should have been checked in advance */
+
+ /* not important for proxies */
+ bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
+ bool is_active_group = false;
+
+ for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io;
+ b_sock_io = b_sock_io->next) {
+ bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier);
+ if (b_sock_group) {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io, true);
+ add_node(proxy, b_group_tree, key, is_active_group);
+ }
+ }
}
void NodeGraph::add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer)
{
- bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
- BLI_assert(b_group_tree); /* should have been checked in advance */
-
- /* not important for proxies */
- bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
- bool is_active_group = false;
-
- for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->inputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
- bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
- if (b_sock_group) {
- if (use_buffer) {
- SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group);
- add_node(buffer, b_group_tree, key, is_active_group);
- }
- else {
- SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_io, b_sock_group, true);
- add_node(proxy, b_group_tree, key, is_active_group);
- }
- }
- }
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+ BLI_assert(b_group_tree); /* should have been checked in advance */
+
+ /* not important for proxies */
+ bNodeInstanceKey key = NODE_INSTANCE_KEY_BASE;
+ bool is_active_group = false;
+
+ for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->inputs.first; b_sock_io;
+ b_sock_io = b_sock_io->next) {
+ bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
+ if (b_sock_group) {
+ if (use_buffer) {
+ SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group);
+ add_node(buffer, b_group_tree, key, is_active_group);
+ }
+ else {
+ SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_io, b_sock_group, true);
+ add_node(proxy, b_group_tree, key, is_active_group);
+ }
+ }
+ }
}
-void NodeGraph::add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key)
+void NodeGraph::add_proxies_group(const CompositorContext &context,
+ bNode *b_node,
+ bNodeInstanceKey key)
{
- bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
+ bNodeTree *b_group_tree = (bNodeTree *)b_node->id;
- /* missing node group datablock can happen with library linking */
- if (!b_group_tree) {
- /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
- return;
- }
+ /* missing node group datablock can happen with library linking */
+ if (!b_group_tree) {
+ /* this error case its handled in convertToOperations() so we don't get un-convertred sockets */
+ return;
+ }
- /* use node list size before adding proxies, so they can be connected in add_bNodeTree */
- int nodes_start = m_nodes.size();
+ /* use node list size before adding proxies, so they can be connected in add_bNodeTree */
+ int nodes_start = m_nodes.size();
- /* create proxy nodes for group input/output nodes */
- for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io; b_node_io = b_node_io->next) {
- if (b_node_io->type == NODE_GROUP_INPUT)
- add_proxies_group_inputs(b_node, b_node_io);
+ /* create proxy nodes for group input/output nodes */
+ for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;
+ b_node_io = b_node_io->next) {
+ if (b_node_io->type == NODE_GROUP_INPUT)
+ add_proxies_group_inputs(b_node, b_node_io);
- if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
- add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
- }
+ if (b_node_io->type == NODE_GROUP_OUTPUT && (b_node_io->flag & NODE_DO_OUTPUT))
+ add_proxies_group_outputs(b_node, b_node_io, context.isGroupnodeBufferEnabled());
+ }
- add_bNodeTree(context, nodes_start, b_group_tree, key);
+ add_bNodeTree(context, nodes_start, b_group_tree, key);
}
-void NodeGraph::add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
+void NodeGraph::add_proxies_reroute(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group)
{
- SocketProxyNode *proxy = new SocketProxyNode(b_node, (bNodeSocket *)b_node->inputs.first, (bNodeSocket *)b_node->outputs.first, false);
- add_node(proxy, b_ntree, key, is_active_group);
+ SocketProxyNode *proxy = new SocketProxyNode(
+ b_node, (bNodeSocket *)b_node->inputs.first, (bNodeSocket *)b_node->outputs.first, false);
+ add_node(proxy, b_ntree, key, is_active_group);
}
diff --git a/source/blender/compositor/intern/COM_NodeGraph.h b/source/blender/compositor/intern/COM_NodeGraph.h
index a2da8fec911..087b3dda48d 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.h
+++ b/source/blender/compositor/intern/COM_NodeGraph.h
@@ -40,73 +40,100 @@ class NodeOutput;
* This structure is converted into operations by \a NodeCompiler.
*/
class NodeGraph {
-public:
- class Link {
- private:
- NodeOutput *m_from;
- NodeInput *m_to;
-
- public:
- Link(NodeOutput *from, NodeInput *to) :
- m_from(from),
- m_to(to)
- {}
-
- NodeOutput *getFromSocket() const { return m_from; }
- NodeInput *getToSocket() const { return m_to; }
- };
-
- typedef std::vector<Node *> Nodes;
- typedef Nodes::iterator NodeIterator;
- typedef std::vector<Link> Links;
-
-private:
- Nodes m_nodes;
- Links m_links;
-
-public:
- NodeGraph();
- ~NodeGraph();
-
- const Nodes &nodes() const { return m_nodes; }
- const Links &links() const { return m_links; }
-
- void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
-
-protected:
- typedef std::pair<NodeIterator, NodeIterator> NodeRange;
- typedef std::vector<NodeInput *> NodeInputs;
-
- static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
- static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
-
- void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
- void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
-
- void add_bNodeTree(const CompositorContext &context, int nodes_start, bNodeTree *tree, bNodeInstanceKey parent_key);
-
- void add_bNode(const CompositorContext &context, bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
-
- NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket *b_socket);
- NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
- void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);
-
- /* **** Special proxy node type conversions **** */
- /* These nodes are not represented in the node graph themselves,
- * but converted into a number of proxy links
- */
-
- void add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
- void add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
-
- void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
- void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
- void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key);
-
- void add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group);
+ public:
+ class Link {
+ private:
+ NodeOutput *m_from;
+ NodeInput *m_to;
+
+ public:
+ Link(NodeOutput *from, NodeInput *to) : m_from(from), m_to(to)
+ {
+ }
+
+ NodeOutput *getFromSocket() const
+ {
+ return m_from;
+ }
+ NodeInput *getToSocket() const
+ {
+ return m_to;
+ }
+ };
+
+ typedef std::vector<Node *> Nodes;
+ typedef Nodes::iterator NodeIterator;
+ typedef std::vector<Link> Links;
+
+ private:
+ Nodes m_nodes;
+ Links m_links;
+
+ public:
+ NodeGraph();
+ ~NodeGraph();
+
+ const Nodes &nodes() const
+ {
+ return m_nodes;
+ }
+ const Links &links() const
+ {
+ return m_links;
+ }
+
+ void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
+
+ protected:
+ typedef std::pair<NodeIterator, NodeIterator> NodeRange;
+ typedef std::vector<NodeInput *> NodeInputs;
+
+ static bNodeSocket *find_b_node_input(bNode *b_node, const char *identifier);
+ static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
+
+ void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
+ void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
+
+ void add_bNodeTree(const CompositorContext &context,
+ int nodes_start,
+ bNodeTree *tree,
+ bNodeInstanceKey parent_key);
+
+ void add_bNode(const CompositorContext &context,
+ bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group);
+
+ NodeInputs find_inputs(const NodeRange &node_range, bNodeSocket *b_socket);
+ NodeOutput *find_output(const NodeRange &node_range, bNodeSocket *b_socket);
+ void add_bNodeLink(const NodeRange &node_range, bNodeLink *bNodeLink);
+
+ /* **** Special proxy node type conversions **** */
+ /* These nodes are not represented in the node graph themselves,
+ * but converted into a number of proxy links
+ */
+
+ void add_proxies_mute(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group);
+ void add_proxies_skip(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group);
+
+ void add_proxies_group_inputs(bNode *b_node, bNode *b_node_io);
+ void add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool use_buffer);
+ void add_proxies_group(const CompositorContext &context, bNode *b_node, bNodeInstanceKey key);
+
+ void add_proxies_reroute(bNodeTree *b_ntree,
+ bNode *b_node,
+ bNodeInstanceKey key,
+ bool is_active_group);
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeGraph")
#endif
};
diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp
index 9f569307581..b0f7bf746fa 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperation.cpp
@@ -30,213 +30,215 @@
NodeOperation::NodeOperation()
{
- this->m_resolutionInputSocketIndex = 0;
- this->m_complex = false;
- this->m_width = 0;
- this->m_height = 0;
- this->m_isResolutionSet = false;
- this->m_openCL = false;
- this->m_btree = NULL;
+ this->m_resolutionInputSocketIndex = 0;
+ this->m_complex = false;
+ this->m_width = 0;
+ this->m_height = 0;
+ this->m_isResolutionSet = false;
+ this->m_openCL = false;
+ this->m_btree = NULL;
}
NodeOperation::~NodeOperation()
{
- while (!this->m_outputs.empty()) {
- delete (this->m_outputs.back());
- this->m_outputs.pop_back();
- }
- while (!this->m_inputs.empty()) {
- delete (this->m_inputs.back());
- this->m_inputs.pop_back();
- }
+ while (!this->m_outputs.empty()) {
+ delete (this->m_outputs.back());
+ this->m_outputs.pop_back();
+ }
+ while (!this->m_inputs.empty()) {
+ delete (this->m_inputs.back());
+ this->m_inputs.pop_back();
+ }
}
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index) const
{
- BLI_assert(index < m_outputs.size());
- return m_outputs[index];
+ BLI_assert(index < m_outputs.size());
+ return m_outputs[index];
}
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index) const
{
- BLI_assert(index < m_inputs.size());
- return m_inputs[index];
+ BLI_assert(index < m_inputs.size());
+ return m_inputs[index];
}
void NodeOperation::addInputSocket(DataType datatype, InputResizeMode resize_mode)
{
- NodeOperationInput *socket = new NodeOperationInput(this, datatype, resize_mode);
- m_inputs.push_back(socket);
+ NodeOperationInput *socket = new NodeOperationInput(this, datatype, resize_mode);
+ m_inputs.push_back(socket);
}
void NodeOperation::addOutputSocket(DataType datatype)
{
- NodeOperationOutput *socket = new NodeOperationOutput(this, datatype);
- m_outputs.push_back(socket);
-}
-
-void NodeOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
-{
- unsigned int temp[2];
- unsigned int temp2[2];
-
- for (unsigned int index = 0; index < m_inputs.size(); index++) {
- NodeOperationInput *input = m_inputs[index];
- if (input->isConnected()) {
- if (index == this->m_resolutionInputSocketIndex) {
- input->determineResolution(resolution, preferredResolution);
- temp2[0] = resolution[0];
- temp2[1] = resolution[1];
- break;
- }
- }
- }
- for (unsigned int index = 0; index < m_inputs.size(); index++) {
- NodeOperationInput *input = m_inputs[index];
- if (input->isConnected()) {
- if (index != this->m_resolutionInputSocketIndex) {
- input->determineResolution(temp, temp2);
- }
- }
- }
+ NodeOperationOutput *socket = new NodeOperationOutput(this, datatype);
+ m_outputs.push_back(socket);
+}
+
+void NodeOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
+{
+ unsigned int temp[2];
+ unsigned int temp2[2];
+
+ for (unsigned int index = 0; index < m_inputs.size(); index++) {
+ NodeOperationInput *input = m_inputs[index];
+ if (input->isConnected()) {
+ if (index == this->m_resolutionInputSocketIndex) {
+ input->determineResolution(resolution, preferredResolution);
+ temp2[0] = resolution[0];
+ temp2[1] = resolution[1];
+ break;
+ }
+ }
+ }
+ for (unsigned int index = 0; index < m_inputs.size(); index++) {
+ NodeOperationInput *input = m_inputs[index];
+ if (input->isConnected()) {
+ if (index != this->m_resolutionInputSocketIndex) {
+ input->determineResolution(temp, temp2);
+ }
+ }
+ }
}
void NodeOperation::setResolutionInputSocketIndex(unsigned int index)
{
- this->m_resolutionInputSocketIndex = index;
+ this->m_resolutionInputSocketIndex = index;
}
void NodeOperation::initExecution()
{
- /* pass */
+ /* pass */
}
void NodeOperation::initMutex()
{
- BLI_mutex_init(&this->m_mutex);
+ BLI_mutex_init(&this->m_mutex);
}
void NodeOperation::lockMutex()
{
- BLI_mutex_lock(&this->m_mutex);
+ BLI_mutex_lock(&this->m_mutex);
}
void NodeOperation::unlockMutex()
{
- BLI_mutex_unlock(&this->m_mutex);
+ BLI_mutex_unlock(&this->m_mutex);
}
void NodeOperation::deinitMutex()
{
- BLI_mutex_end(&this->m_mutex);
+ BLI_mutex_end(&this->m_mutex);
}
void NodeOperation::deinitExecution()
{
- /* pass */
+ /* pass */
}
SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
{
- return this->getInputSocket(inputSocketIndex)->getReader();
+ return this->getInputSocket(inputSocketIndex)->getReader();
}
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
{
- NodeOperationInput *input = getInputSocket(inputSocketIndex);
- if (input && input->isConnected())
- return &input->getLink()->getOperation();
- else
- return NULL;
+ NodeOperationInput *input = getInputSocket(inputSocketIndex);
+ if (input && input->isConnected())
+ return &input->getLink()->getOperation();
+ else
+ return NULL;
}
void NodeOperation::getConnectedInputSockets(Inputs *sockets)
{
- for (Inputs::const_iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) {
- NodeOperationInput *input = *it;
- if (input->isConnected()) {
- sockets->push_back(input);
- }
- }
-}
-
-bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
-{
- if (isInputOperation()) {
- BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
- return false;
- }
- else {
- rcti tempOutput;
- bool first = true;
- for (int i = 0; i < getNumberOfInputSockets(); i ++) {
- NodeOperation *inputOperation = this->getInputOperation(i);
- if (inputOperation && inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
- if (first) {
- output->xmin = tempOutput.xmin;
- output->ymin = tempOutput.ymin;
- output->xmax = tempOutput.xmax;
- output->ymax = tempOutput.ymax;
- first = false;
- }
- else {
- output->xmin = min(output->xmin, tempOutput.xmin);
- output->ymin = min(output->ymin, tempOutput.ymin);
- output->xmax = max(output->xmax, tempOutput.xmax);
- output->ymax = max(output->ymax, tempOutput.ymax);
- }
- }
- }
- return !first;
- }
+ for (Inputs::const_iterator it = m_inputs.begin(); it != m_inputs.end(); ++it) {
+ NodeOperationInput *input = *it;
+ if (input->isConnected()) {
+ sockets->push_back(input);
+ }
+ }
+}
+
+bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
+{
+ if (isInputOperation()) {
+ BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
+ return false;
+ }
+ else {
+ rcti tempOutput;
+ bool first = true;
+ for (int i = 0; i < getNumberOfInputSockets(); i++) {
+ NodeOperation *inputOperation = this->getInputOperation(i);
+ if (inputOperation &&
+ inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
+ if (first) {
+ output->xmin = tempOutput.xmin;
+ output->ymin = tempOutput.ymin;
+ output->xmax = tempOutput.xmax;
+ output->ymax = tempOutput.ymax;
+ first = false;
+ }
+ else {
+ output->xmin = min(output->xmin, tempOutput.xmin);
+ output->ymin = min(output->ymin, tempOutput.ymin);
+ output->xmax = max(output->xmax, tempOutput.xmax);
+ output->ymax = max(output->ymax, tempOutput.ymax);
+ }
+ }
+ }
+ return !first;
+ }
}
-
/*****************
**** OpInput ****
*****************/
-NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, InputResizeMode resizeMode) :
- m_operation(op),
- m_datatype(datatype),
- m_resizeMode(resizeMode),
- m_link(NULL)
+NodeOperationInput::NodeOperationInput(NodeOperation *op,
+ DataType datatype,
+ InputResizeMode resizeMode)
+ : m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(NULL)
{
}
SocketReader *NodeOperationInput::getReader()
{
- if (isConnected()) {
- return &m_link->getOperation();
- }
- else {
- return NULL;
- }
+ if (isConnected()) {
+ return &m_link->getOperation();
+ }
+ else {
+ return NULL;
+ }
}
-void NodeOperationInput::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void NodeOperationInput::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- if (m_link)
- m_link->determineResolution(resolution, preferredResolution);
+ if (m_link)
+ m_link->determineResolution(resolution, preferredResolution);
}
-
/******************
**** OpOutput ****
******************/
-NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype) :
- m_operation(op),
- m_datatype(datatype)
+NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype)
+ : m_operation(op), m_datatype(datatype)
{
}
-void NodeOperationOutput::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void NodeOperationOutput::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation &operation = getOperation();
- if (operation.isResolutionSet()) {
- resolution[0] = operation.getWidth();
- resolution[1] = operation.getHeight();
- }
- else {
- operation.determineResolution(resolution, preferredResolution);
- operation.setResolution(resolution);
- }
+ NodeOperation &operation = getOperation();
+ if (operation.isResolutionSet()) {
+ resolution[0] = operation.getWidth();
+ resolution[1] = operation.getHeight();
+ }
+ else {
+ operation.determineResolution(resolution, preferredResolution);
+ operation.setResolution(resolution);
+ }
}
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 9296b1bfd22..939d3e1f8a7 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -37,8 +37,8 @@ extern "C" {
#include "clew.h"
using std::list;
-using std::min;
using std::max;
+using std::min;
class OpenCLDevice;
class ReadBufferOperation;
@@ -53,18 +53,18 @@ class NodeOperationOutput;
* \ingroup Model
*/
typedef enum InputResizeMode {
- /** \brief Center the input image to the center of the working area of the node, no resizing occurs */
- COM_SC_CENTER = NS_CR_CENTER,
- /** \brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
- COM_SC_NO_RESIZE = NS_CR_NONE,
- /** \brief Fit the width of the input image to the width of the working area of the node */
- COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
- /** \brief Fit the height of the input image to the height of the working area of the node */
- COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
- /** \brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
- COM_SC_FIT = NS_CR_FIT,
- /** \brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
- COM_SC_STRETCH = NS_CR_STRETCH,
+ /** \brief Center the input image to the center of the working area of the node, no resizing occurs */
+ COM_SC_CENTER = NS_CR_CENTER,
+ /** \brief The bottom left of the input image is the bottom left of the working area of the node, no resizing occurs */
+ COM_SC_NO_RESIZE = NS_CR_NONE,
+ /** \brief Fit the width of the input image to the width of the working area of the node */
+ COM_SC_FIT_WIDTH = NS_CR_FIT_WIDTH,
+ /** \brief Fit the height of the input image to the height of the working area of the node */
+ COM_SC_FIT_HEIGHT = NS_CR_FIT_HEIGHT,
+ /** \brief Fit the width or the height of the input image to the width or height of the working area of the node, image will be larger than the working area */
+ COM_SC_FIT = NS_CR_FIT,
+ /** \brief Fit the width and the height of the input image to the width and height of the working area of the node, image will be equally larger than the working area */
+ COM_SC_STRETCH = NS_CR_STRETCH,
} InputResizeMode;
/**
@@ -74,332 +74,442 @@ typedef enum InputResizeMode {
* \ingroup Model
*/
class NodeOperation : public SocketReader {
-public:
- typedef std::vector<NodeOperationInput*> Inputs;
- typedef std::vector<NodeOperationOutput*> Outputs;
-
-private:
- Inputs m_inputs;
- Outputs m_outputs;
-
- /**
- * \brief the index of the input socket that will be used to determine the resolution
- */
- unsigned int m_resolutionInputSocketIndex;
-
- /**
- * \brief is this operation a complex one.
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
- bool m_complex;
-
- /**
- * \brief can this operation be scheduled on an OpenCL device.
- * \note Only applicable if complex is True
- */
- bool m_openCL;
-
- /**
- * \brief mutex reference for very special node initializations
- * \note only use when you really know what you are doing.
- * this mutex is used to share data among chunks in the same operation
- * \see TonemapOperation for an example of usage
- * \see NodeOperation.initMutex initializes this mutex
- * \see NodeOperation.deinitMutex deinitializes this mutex
- * \see NodeOperation.getMutex retrieve a pointer to this mutex.
- */
- ThreadMutex m_mutex;
-
- /**
- * \brief reference to the editing bNodeTree, used for break and update callback
- */
- const bNodeTree *m_btree;
-
- /**
- * \brief set to truth when resolution for this operation is set
- */
- bool m_isResolutionSet;
-
-public:
- virtual ~NodeOperation();
-
- unsigned int getNumberOfInputSockets() const { return m_inputs.size(); }
- unsigned int getNumberOfOutputSockets() const { return m_outputs.size(); }
- NodeOperationOutput *getOutputSocket(unsigned int index) const;
- NodeOperationOutput *getOutputSocket() const { return getOutputSocket(0); }
- NodeOperationInput *getInputSocket(unsigned int index) const;
-
- /** Check if this is an input operation
- * An input operation is an operation that only has output sockets and no input sockets
- */
- bool isInputOperation() const { return m_inputs.empty(); }
-
- /**
- * \brief determine the resolution of this node
- * \note this method will not set the resolution, this is the responsibility of the caller
- * \param resolution: the result of this operation
- * \param preferredResolution: the preferable resolution as no resolution could be determined
- */
- virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- /**
- * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
- *
- * Default behavior if not overridden, this operation will not be evaluated as being an output of the ExecutionSystem.
- *
- * \see ExecutionSystem
- * \group check
- * \param rendering: [true false]
- * true: rendering
- * false: editing
- *
- * \return bool the result of this method
- */
- virtual bool isOutputOperation(bool /*rendering*/) const { return false; }
-
- virtual int isSingleThreaded() { return false; }
-
- void setbNodeTree(const bNodeTree *tree) { this->m_btree = tree; }
- virtual void initExecution();
-
- /**
- * \brief when a chunk is executed by a CPUDevice, this method is called
- * \ingroup execution
- * \param rect: the rectangle of the chunk (location and size)
- * \param chunkNumber: the chunkNumber to be calculated
- * \param memoryBuffers: all input MemoryBuffer's needed
- */
- virtual void executeRegion(rcti * /*rect*/,
- unsigned int /*chunkNumber*/) {}
-
- /**
- * \brief when a chunk is executed by an OpenCLDevice, this method is called
- * \ingroup execution
- * \note this method is only implemented in WriteBufferOperation
- * \param context: the OpenCL context
- * \param program: the OpenCL program containing all compositor kernels
- * \param queue: the OpenCL command queue of the device the chunk is executed on
- * \param rect: the rectangle of the chunk (location and size)
- * \param chunkNumber: the chunkNumber to be calculated
- * \param memoryBuffers: all input MemoryBuffer's needed
- * \param outputBuffer: the outputbuffer to write to
- */
- virtual void executeOpenCLRegion(OpenCLDevice * /*device*/,
- rcti * /*rect*/,
- unsigned int /*chunkNumber*/,
- MemoryBuffer ** /*memoryBuffers*/,
- MemoryBuffer * /*outputBuffer*/) {}
-
- /**
- * \brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
- * \ingroup execution
- * \param context: the OpenCL context
- * \param program: the OpenCL program containing all compositor kernels
- * \param queue: the OpenCL command queue of the device the chunk is executed on
- * \param outputMemoryBuffer: the allocated memory buffer in main CPU memory
- * \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory
- * \param inputMemoryBuffers: all input MemoryBuffer's needed
- * \param clMemToCleanUp: all created cl_mem references must be added to this list. Framework will clean this after execution
- * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list. Framework will clean this after execution
- */
- virtual void executeOpenCL(OpenCLDevice * /*device*/,
- MemoryBuffer * /*outputMemoryBuffer*/,
- cl_mem /*clOutputBuffer*/,
- MemoryBuffer ** /*inputMemoryBuffers*/,
- list<cl_mem> * /*clMemToCleanUp*/,
- list<cl_kernel> * /*clKernelsToCleanUp*/) {}
- virtual void deinitExecution();
-
- bool isResolutionSet() {
- return this->m_isResolutionSet;
- }
-
- /**
- * \brief set the resolution
- * \param resolution: the resolution to set
- */
- void setResolution(unsigned int resolution[2]) {
- if (!isResolutionSet()) {
- this->m_width = resolution[0];
- this->m_height = resolution[1];
- this->m_isResolutionSet = true;
- }
- }
-
-
- void getConnectedInputSockets(Inputs *sockets);
-
- /**
- * \brief is this operation complex
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
- bool isComplex() const { return this->m_complex; }
-
- virtual bool isSetOperation() const { return false; }
-
- /**
- * \brief is this operation of type ReadBufferOperation
- * \return [true:false]
- * \see ReadBufferOperation
- */
- virtual bool isReadBufferOperation() const { return false; }
-
- /**
- * \brief is this operation of type WriteBufferOperation
- * \return [true:false]
- * \see WriteBufferOperation
- */
- virtual bool isWriteBufferOperation() const { return false; }
-
- /**
- * \brief is this operation the active viewer output
- * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
- * \return [true:false]
- * \see BaseViewerOperation
- */
- virtual bool isActiveViewerOutput() const { return false; }
-
- virtual bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- /**
- * \brief set the index of the input socket that will determine the resolution of this operation
- * \param index: the index to set
- */
- void setResolutionInputSocketIndex(unsigned int index);
-
- /**
- * \brief get the render priority of this node.
- * \note only applicable for output operations like ViewerOperation
- * \return CompositorPriority
- */
- virtual CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
-
- /**
- * \brief can this NodeOperation be scheduled on an OpenCLDevice
- * \see WorkScheduler.schedule
- * \see ExecutionGroup.addOperation
- */
- bool isOpenCL() const { return this->m_openCL; }
-
- virtual bool isViewerOperation() const { return false; }
- virtual bool isPreviewOperation() const { return false; }
- virtual bool isFileOutputOperation() const { return false; }
- virtual bool isProxyOperation() const { return false; }
-
- virtual bool useDatatypeConversion() const { return true; }
-
- inline bool isBreaked() const {
- return this->m_btree->test_break(this->m_btree->tbh);
- }
-
- inline void updateDraw() {
- if (this->m_btree->update_draw)
- this->m_btree->update_draw(this->m_btree->udh);
- }
-protected:
- NodeOperation();
-
- void addInputSocket(DataType datatype, InputResizeMode resize_mode = COM_SC_CENTER);
- void addOutputSocket(DataType datatype);
-
- void setWidth(unsigned int width) { this->m_width = width; this->m_isResolutionSet = true; }
- void setHeight(unsigned int height) { this->m_height = height; this->m_isResolutionSet = true; }
- SocketReader *getInputSocketReader(unsigned int inputSocketindex);
- NodeOperation *getInputOperation(unsigned int inputSocketindex);
-
- void deinitMutex();
- void initMutex();
- void lockMutex();
- void unlockMutex();
-
- /**
- * \brief set whether this operation is complex
- *
- * Complex operations are typically doing many reads to calculate the output of a single pixel.
- * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
- */
- void setComplex(bool complex) { this->m_complex = complex; }
-
- /**
- * \brief set if this NodeOperation can be scheduled on a OpenCLDevice
- */
- void setOpenCL(bool openCL) { this->m_openCL = openCL; }
-
- /* allow the DebugInfo class to look at internals */
- friend class DebugInfo;
+ public:
+ typedef std::vector<NodeOperationInput *> Inputs;
+ typedef std::vector<NodeOperationOutput *> Outputs;
+
+ private:
+ Inputs m_inputs;
+ Outputs m_outputs;
+
+ /**
+ * \brief the index of the input socket that will be used to determine the resolution
+ */
+ unsigned int m_resolutionInputSocketIndex;
+
+ /**
+ * \brief is this operation a complex one.
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ bool m_complex;
+
+ /**
+ * \brief can this operation be scheduled on an OpenCL device.
+ * \note Only applicable if complex is True
+ */
+ bool m_openCL;
+
+ /**
+ * \brief mutex reference for very special node initializations
+ * \note only use when you really know what you are doing.
+ * this mutex is used to share data among chunks in the same operation
+ * \see TonemapOperation for an example of usage
+ * \see NodeOperation.initMutex initializes this mutex
+ * \see NodeOperation.deinitMutex deinitializes this mutex
+ * \see NodeOperation.getMutex retrieve a pointer to this mutex.
+ */
+ ThreadMutex m_mutex;
+
+ /**
+ * \brief reference to the editing bNodeTree, used for break and update callback
+ */
+ const bNodeTree *m_btree;
+
+ /**
+ * \brief set to truth when resolution for this operation is set
+ */
+ bool m_isResolutionSet;
+
+ public:
+ virtual ~NodeOperation();
+
+ unsigned int getNumberOfInputSockets() const
+ {
+ return m_inputs.size();
+ }
+ unsigned int getNumberOfOutputSockets() const
+ {
+ return m_outputs.size();
+ }
+ NodeOperationOutput *getOutputSocket(unsigned int index) const;
+ NodeOperationOutput *getOutputSocket() const
+ {
+ return getOutputSocket(0);
+ }
+ NodeOperationInput *getInputSocket(unsigned int index) const;
+
+ /** Check if this is an input operation
+ * An input operation is an operation that only has output sockets and no input sockets
+ */
+ bool isInputOperation() const
+ {
+ return m_inputs.empty();
+ }
+
+ /**
+ * \brief determine the resolution of this node
+ * \note this method will not set the resolution, this is the responsibility of the caller
+ * \param resolution: the result of this operation
+ * \param preferredResolution: the preferable resolution as no resolution could be determined
+ */
+ virtual void determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2]);
+
+ /**
+ * \brief isOutputOperation determines whether this operation is an output of the ExecutionSystem during rendering or editing.
+ *
+ * Default behavior if not overridden, this operation will not be evaluated as being an output of the ExecutionSystem.
+ *
+ * \see ExecutionSystem
+ * \group check
+ * \param rendering: [true false]
+ * true: rendering
+ * false: editing
+ *
+ * \return bool the result of this method
+ */
+ virtual bool isOutputOperation(bool /*rendering*/) const
+ {
+ return false;
+ }
+
+ virtual int isSingleThreaded()
+ {
+ return false;
+ }
+
+ void setbNodeTree(const bNodeTree *tree)
+ {
+ this->m_btree = tree;
+ }
+ virtual void initExecution();
+
+ /**
+ * \brief when a chunk is executed by a CPUDevice, this method is called
+ * \ingroup execution
+ * \param rect: the rectangle of the chunk (location and size)
+ * \param chunkNumber: the chunkNumber to be calculated
+ * \param memoryBuffers: all input MemoryBuffer's needed
+ */
+ virtual void executeRegion(rcti * /*rect*/, unsigned int /*chunkNumber*/)
+ {
+ }
+
+ /**
+ * \brief when a chunk is executed by an OpenCLDevice, this method is called
+ * \ingroup execution
+ * \note this method is only implemented in WriteBufferOperation
+ * \param context: the OpenCL context
+ * \param program: the OpenCL program containing all compositor kernels
+ * \param queue: the OpenCL command queue of the device the chunk is executed on
+ * \param rect: the rectangle of the chunk (location and size)
+ * \param chunkNumber: the chunkNumber to be calculated
+ * \param memoryBuffers: all input MemoryBuffer's needed
+ * \param outputBuffer: the outputbuffer to write to
+ */
+ virtual void executeOpenCLRegion(OpenCLDevice * /*device*/,
+ rcti * /*rect*/,
+ unsigned int /*chunkNumber*/,
+ MemoryBuffer ** /*memoryBuffers*/,
+ MemoryBuffer * /*outputBuffer*/)
+ {
+ }
+
+ /**
+ * \brief custom handle to add new tasks to the OpenCL command queue in order to execute a chunk on an GPUDevice
+ * \ingroup execution
+ * \param context: the OpenCL context
+ * \param program: the OpenCL program containing all compositor kernels
+ * \param queue: the OpenCL command queue of the device the chunk is executed on
+ * \param outputMemoryBuffer: the allocated memory buffer in main CPU memory
+ * \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory
+ * \param inputMemoryBuffers: all input MemoryBuffer's needed
+ * \param clMemToCleanUp: all created cl_mem references must be added to this list. Framework will clean this after execution
+ * \param clKernelsToCleanUp: all created cl_kernel references must be added to this list. Framework will clean this after execution
+ */
+ virtual void executeOpenCL(OpenCLDevice * /*device*/,
+ MemoryBuffer * /*outputMemoryBuffer*/,
+ cl_mem /*clOutputBuffer*/,
+ MemoryBuffer ** /*inputMemoryBuffers*/,
+ list<cl_mem> * /*clMemToCleanUp*/,
+ list<cl_kernel> * /*clKernelsToCleanUp*/)
+ {
+ }
+ virtual void deinitExecution();
+
+ bool isResolutionSet()
+ {
+ return this->m_isResolutionSet;
+ }
+
+ /**
+ * \brief set the resolution
+ * \param resolution: the resolution to set
+ */
+ void setResolution(unsigned int resolution[2])
+ {
+ if (!isResolutionSet()) {
+ this->m_width = resolution[0];
+ this->m_height = resolution[1];
+ this->m_isResolutionSet = true;
+ }
+ }
+
+ void getConnectedInputSockets(Inputs *sockets);
+
+ /**
+ * \brief is this operation complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ bool isComplex() const
+ {
+ return this->m_complex;
+ }
+
+ virtual bool isSetOperation() const
+ {
+ return false;
+ }
+
+ /**
+ * \brief is this operation of type ReadBufferOperation
+ * \return [true:false]
+ * \see ReadBufferOperation
+ */
+ virtual bool isReadBufferOperation() const
+ {
+ return false;
+ }
+
+ /**
+ * \brief is this operation of type WriteBufferOperation
+ * \return [true:false]
+ * \see WriteBufferOperation
+ */
+ virtual bool isWriteBufferOperation() const
+ {
+ return false;
+ }
+
+ /**
+ * \brief is this operation the active viewer output
+ * user can select an ViewerNode to be active (the result of this node will be drawn on the backdrop)
+ * \return [true:false]
+ * \see BaseViewerOperation
+ */
+ virtual bool isActiveViewerOutput() const
+ {
+ return false;
+ }
+
+ virtual bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ /**
+ * \brief set the index of the input socket that will determine the resolution of this operation
+ * \param index: the index to set
+ */
+ void setResolutionInputSocketIndex(unsigned int index);
+
+ /**
+ * \brief get the render priority of this node.
+ * \note only applicable for output operations like ViewerOperation
+ * \return CompositorPriority
+ */
+ virtual CompositorPriority getRenderPriority() const
+ {
+ return COM_PRIORITY_LOW;
+ }
+
+ /**
+ * \brief can this NodeOperation be scheduled on an OpenCLDevice
+ * \see WorkScheduler.schedule
+ * \see ExecutionGroup.addOperation
+ */
+ bool isOpenCL() const
+ {
+ return this->m_openCL;
+ }
+
+ virtual bool isViewerOperation() const
+ {
+ return false;
+ }
+ virtual bool isPreviewOperation() const
+ {
+ return false;
+ }
+ virtual bool isFileOutputOperation() const
+ {
+ return false;
+ }
+ virtual bool isProxyOperation() const
+ {
+ return false;
+ }
+
+ virtual bool useDatatypeConversion() const
+ {
+ return true;
+ }
+
+ inline bool isBreaked() const
+ {
+ return this->m_btree->test_break(this->m_btree->tbh);
+ }
+
+ inline void updateDraw()
+ {
+ if (this->m_btree->update_draw)
+ this->m_btree->update_draw(this->m_btree->udh);
+ }
+
+ protected:
+ NodeOperation();
+
+ void addInputSocket(DataType datatype, InputResizeMode resize_mode = COM_SC_CENTER);
+ void addOutputSocket(DataType datatype);
+
+ void setWidth(unsigned int width)
+ {
+ this->m_width = width;
+ this->m_isResolutionSet = true;
+ }
+ void setHeight(unsigned int height)
+ {
+ this->m_height = height;
+ this->m_isResolutionSet = true;
+ }
+ SocketReader *getInputSocketReader(unsigned int inputSocketindex);
+ NodeOperation *getInputOperation(unsigned int inputSocketindex);
+
+ void deinitMutex();
+ void initMutex();
+ void lockMutex();
+ void unlockMutex();
+
+ /**
+ * \brief set whether this operation is complex
+ *
+ * Complex operations are typically doing many reads to calculate the output of a single pixel.
+ * Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
+ */
+ void setComplex(bool complex)
+ {
+ this->m_complex = complex;
+ }
+
+ /**
+ * \brief set if this NodeOperation can be scheduled on a OpenCLDevice
+ */
+ void setOpenCL(bool openCL)
+ {
+ this->m_openCL = openCL;
+ }
+
+ /* allow the DebugInfo class to look at internals */
+ friend class DebugInfo;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
};
-
class NodeOperationInput {
-private:
- NodeOperation *m_operation;
-
- /** Datatype of this socket. Is used for automatically data transformation.
- * \section data-conversion
- */
- DataType m_datatype;
-
- /** Resize mode of this socket */
- InputResizeMode m_resizeMode;
-
- /** Connected output */
- NodeOperationOutput *m_link;
-
-public:
- NodeOperationInput(NodeOperation *op, DataType datatype, InputResizeMode resizeMode = COM_SC_CENTER);
-
- NodeOperation &getOperation() const { return *m_operation; }
- DataType getDataType() const { return m_datatype; }
-
- void setLink(NodeOperationOutput *link) { m_link = link; }
- NodeOperationOutput *getLink() const { return m_link; }
- bool isConnected() const { return m_link; }
-
- void setResizeMode(InputResizeMode resizeMode) { this->m_resizeMode = resizeMode; }
- InputResizeMode getResizeMode() const { return this->m_resizeMode; }
-
- SocketReader *getReader();
-
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ private:
+ NodeOperation *m_operation;
+
+ /** Datatype of this socket. Is used for automatically data transformation.
+ * \section data-conversion
+ */
+ DataType m_datatype;
+
+ /** Resize mode of this socket */
+ InputResizeMode m_resizeMode;
+
+ /** Connected output */
+ NodeOperationOutput *m_link;
+
+ public:
+ NodeOperationInput(NodeOperation *op,
+ DataType datatype,
+ InputResizeMode resizeMode = COM_SC_CENTER);
+
+ NodeOperation &getOperation() const
+ {
+ return *m_operation;
+ }
+ DataType getDataType() const
+ {
+ return m_datatype;
+ }
+
+ void setLink(NodeOperationOutput *link)
+ {
+ m_link = link;
+ }
+ NodeOperationOutput *getLink() const
+ {
+ return m_link;
+ }
+ bool isConnected() const
+ {
+ return m_link;
+ }
+
+ void setResizeMode(InputResizeMode resizeMode)
+ {
+ this->m_resizeMode = resizeMode;
+ }
+ InputResizeMode getResizeMode() const
+ {
+ return this->m_resizeMode;
+ }
+
+ SocketReader *getReader();
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
};
-
class NodeOperationOutput {
-private:
- NodeOperation *m_operation;
-
- /** Datatype of this socket. Is used for automatically data transformation.
- * \section data-conversion
- */
- DataType m_datatype;
-
-public:
- NodeOperationOutput(NodeOperation *op, DataType datatype);
-
- NodeOperation &getOperation() const { return *m_operation; }
- DataType getDataType() const { return m_datatype; }
-
- /**
- * \brief determine the resolution of this data going through this socket
- * \param resolution: the result of this operation
- * \param preferredResolution: the preferable resolution as no resolution could be determined
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ private:
+ NodeOperation *m_operation;
+
+ /** Datatype of this socket. Is used for automatically data transformation.
+ * \section data-conversion
+ */
+ DataType m_datatype;
+
+ public:
+ NodeOperationOutput(NodeOperation *op, DataType datatype);
+
+ NodeOperation &getOperation() const
+ {
+ return *m_operation;
+ }
+ DataType getDataType() const
+ {
+ return m_datatype;
+ }
+
+ /**
+ * \brief determine the resolution of this data going through this socket
+ * \param resolution: the result of this operation
+ * \param preferredResolution: the preferable resolution as no resolution could be determined
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation")
#endif
};
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 37a1d7c005f..0f331a25ed9 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -39,12 +39,10 @@ extern "C" {
#include "COM_NodeOperationBuilder.h" /* own include */
-NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree) :
- m_context(context),
- m_current_node(NULL),
- m_active_viewer(NULL)
+NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree)
+ : m_context(context), m_current_node(NULL), m_active_viewer(NULL)
{
- m_graph.from_bNodeTree(*context, b_nodetree);
+ m_graph.from_bNodeTree(*context, b_nodetree);
}
NodeOperationBuilder::~NodeOperationBuilder()
@@ -53,208 +51,215 @@ NodeOperationBuilder::~NodeOperationBuilder()
void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
{
- /* interface handle for nodes */
- NodeConverter converter(this);
+ /* interface handle for nodes */
+ NodeConverter converter(this);
- for (int index = 0; index < m_graph.nodes().size(); index++) {
- Node *node = (Node *)m_graph.nodes()[index];
+ for (int index = 0; index < m_graph.nodes().size(); index++) {
+ Node *node = (Node *)m_graph.nodes()[index];
- m_current_node = node;
+ m_current_node = node;
- DebugInfo::node_to_operations(node);
- node->convertToOperations(converter, *m_context);
- }
+ DebugInfo::node_to_operations(node);
+ node->convertToOperations(converter, *m_context);
+ }
- m_current_node = NULL;
+ m_current_node = NULL;
- /* The input map constructed by nodes maps operation inputs to node inputs.
- * Inverting yields a map of node inputs to all connected operation inputs,
- * so multiple operations can use the same node input.
- */
- OpInputInverseMap inverse_input_map;
- for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
- inverse_input_map[it->second].push_back(it->first);
+ /* The input map constructed by nodes maps operation inputs to node inputs.
+ * Inverting yields a map of node inputs to all connected operation inputs,
+ * so multiple operations can use the same node input.
+ */
+ OpInputInverseMap inverse_input_map;
+ for (InputSocketMap::const_iterator it = m_input_map.begin(); it != m_input_map.end(); ++it)
+ inverse_input_map[it->second].push_back(it->first);
- for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end(); ++it) {
- const NodeGraph::Link &link = *it;
- NodeOutput *from = link.getFromSocket();
- NodeInput *to = link.getToSocket();
+ for (NodeGraph::Links::const_iterator it = m_graph.links().begin(); it != m_graph.links().end();
+ ++it) {
+ const NodeGraph::Link &link = *it;
+ NodeOutput *from = link.getFromSocket();
+ NodeInput *to = link.getToSocket();
- NodeOperationOutput *op_from = find_operation_output(m_output_map, from);
- const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
- if (!op_from || op_to_list.empty()) {
- /* XXX allow this? error/debug message? */
- //BLI_assert(false);
- /* XXX note: this can happen with certain nodes (e.g. OutputFile)
- * which only generate operations in certain circumstances (rendering)
- * just let this pass silently for now ...
- */
- continue;
- }
+ NodeOperationOutput *op_from = find_operation_output(m_output_map, from);
+ const OpInputs &op_to_list = find_operation_inputs(inverse_input_map, to);
+ if (!op_from || op_to_list.empty()) {
+ /* XXX allow this? error/debug message? */
+ //BLI_assert(false);
+ /* XXX note: this can happen with certain nodes (e.g. OutputFile)
+ * which only generate operations in certain circumstances (rendering)
+ * just let this pass silently for now ...
+ */
+ continue;
+ }
- for (OpInputs::const_iterator it = op_to_list.begin(); it != op_to_list.end(); ++it) {
- NodeOperationInput *op_to = *it;
- addLink(op_from, op_to);
- }
- }
+ for (OpInputs::const_iterator it = op_to_list.begin(); it != op_to_list.end(); ++it) {
+ NodeOperationInput *op_to = *it;
+ addLink(op_from, op_to);
+ }
+ }
- add_operation_input_constants();
+ add_operation_input_constants();
- resolve_proxies();
+ resolve_proxies();
- add_datatype_conversions();
+ add_datatype_conversions();
- determineResolutions();
+ determineResolutions();
- /* surround complex ops with read/write buffer */
- add_complex_operation_buffers();
+ /* surround complex ops with read/write buffer */
+ add_complex_operation_buffers();
- /* links not available from here on */
- /* XXX make m_links a local variable to avoid confusion! */
- m_links.clear();
+ /* links not available from here on */
+ /* XXX make m_links a local variable to avoid confusion! */
+ m_links.clear();
- prune_operations();
+ prune_operations();
- /* ensure topological (link-based) order of nodes */
- /*sort_operations();*/ /* not needed yet */
+ /* ensure topological (link-based) order of nodes */
+ /*sort_operations();*/ /* not needed yet */
- /* create execution groups */
- group_operations();
+ /* create execution groups */
+ group_operations();
- /* transfer resulting operations to the system */
- system->set_operations(m_operations, m_groups);
+ /* transfer resulting operations to the system */
+ system->set_operations(m_operations, m_groups);
}
void NodeOperationBuilder::addOperation(NodeOperation *operation)
{
- m_operations.push_back(operation);
+ m_operations.push_back(operation);
}
-void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
+void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket,
+ NodeOperationInput *operation_socket)
{
- BLI_assert(m_current_node);
- BLI_assert(node_socket->getNode() == m_current_node);
+ BLI_assert(m_current_node);
+ BLI_assert(node_socket->getNode() == m_current_node);
- /* note: this maps operation sockets to node sockets.
- * for resolving links the map will be inverted first in convertToOperations,
- * to get a list of links for each node input socket.
- */
- m_input_map[operation_socket] = node_socket;
+ /* note: this maps operation sockets to node sockets.
+ * for resolving links the map will be inverted first in convertToOperations,
+ * to get a list of links for each node input socket.
+ */
+ m_input_map[operation_socket] = node_socket;
}
-void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
+void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket,
+ NodeOperationOutput *operation_socket)
{
- BLI_assert(m_current_node);
- BLI_assert(node_socket->getNode() == m_current_node);
+ BLI_assert(m_current_node);
+ BLI_assert(node_socket->getNode() == m_current_node);
- m_output_map[node_socket] = operation_socket;
+ m_output_map[node_socket] = operation_socket;
}
void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to)
{
- if (to->isConnected())
- return;
+ if (to->isConnected())
+ return;
- m_links.push_back(Link(from, to));
+ m_links.push_back(Link(from, to));
- /* register with the input */
- to->setLink(from);
+ /* register with the input */
+ to->setLink(from);
}
void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
{
- for (Links::iterator it = m_links.begin(); it != m_links.end(); ++it) {
- Link &link = *it;
- if (link.to() == to) {
- /* unregister with the input */
- to->setLink(NULL);
+ for (Links::iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ Link &link = *it;
+ if (link.to() == to) {
+ /* unregister with the input */
+ to->setLink(NULL);
- m_links.erase(it);
- return;
- }
- }
+ m_links.erase(it);
+ return;
+ }
+ }
}
-NodeInput *NodeOperationBuilder::find_node_input(const InputSocketMap &map, NodeOperationInput *op_input)
+NodeInput *NodeOperationBuilder::find_node_input(const InputSocketMap &map,
+ NodeOperationInput *op_input)
{
- InputSocketMap::const_iterator it = map.find(op_input);
- return (it != map.end() ? it->second : NULL);
+ InputSocketMap::const_iterator it = map.find(op_input);
+ return (it != map.end() ? it->second : NULL);
}
-const NodeOperationBuilder::OpInputs &NodeOperationBuilder::find_operation_inputs(const OpInputInverseMap &map, NodeInput *node_input)
+const NodeOperationBuilder::OpInputs &NodeOperationBuilder::find_operation_inputs(
+ const OpInputInverseMap &map, NodeInput *node_input)
{
- static const OpInputs empty_list;
- OpInputInverseMap::const_iterator it = map.find(node_input);
- return (it != map.end() ? it->second : empty_list);
+ static const OpInputs empty_list;
+ OpInputInverseMap::const_iterator it = map.find(node_input);
+ return (it != map.end() ? it->second : empty_list);
}
-NodeOperationOutput *NodeOperationBuilder::find_operation_output(const OutputSocketMap &map, NodeOutput *node_output)
+NodeOperationOutput *NodeOperationBuilder::find_operation_output(const OutputSocketMap &map,
+ NodeOutput *node_output)
{
- OutputSocketMap::const_iterator it = map.find(node_output);
- return (it != map.end() ? it->second : NULL);
+ OutputSocketMap::const_iterator it = map.find(node_output);
+ return (it != map.end() ? it->second : NULL);
}
PreviewOperation *NodeOperationBuilder::make_preview_operation() const
{
- BLI_assert(m_current_node);
+ BLI_assert(m_current_node);
- if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
- return NULL;
- /* previews only in the active group */
- if (!m_current_node->isInActiveGroup())
- return NULL;
- /* do not calculate previews of hidden nodes */
- if (m_current_node->getbNode()->flag & NODE_HIDDEN)
- return NULL;
+ if (!(m_current_node->getbNode()->flag & NODE_PREVIEW))
+ return NULL;
+ /* previews only in the active group */
+ if (!m_current_node->isInActiveGroup())
+ return NULL;
+ /* do not calculate previews of hidden nodes */
+ if (m_current_node->getbNode()->flag & NODE_HIDDEN)
+ return NULL;
- bNodeInstanceHash *previews = m_context->getPreviewHash();
- if (previews) {
- PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(), m_context->getDisplaySettings());
- operation->setbNodeTree(m_context->getbNodeTree());
- operation->verifyPreview(previews, m_current_node->getInstanceKey());
- return operation;
- }
+ bNodeInstanceHash *previews = m_context->getPreviewHash();
+ if (previews) {
+ PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(),
+ m_context->getDisplaySettings());
+ operation->setbNodeTree(m_context->getbNodeTree());
+ operation->verifyPreview(previews, m_current_node->getInstanceKey());
+ return operation;
+ }
- return NULL;
+ return NULL;
}
void NodeOperationBuilder::addPreview(NodeOperationOutput *output)
{
- PreviewOperation *operation = make_preview_operation();
- if (operation) {
- addOperation(operation);
+ PreviewOperation *operation = make_preview_operation();
+ if (operation) {
+ addOperation(operation);
- addLink(output, operation->getInputSocket(0));
- }
+ addLink(output, operation->getInputSocket(0));
+ }
}
void NodeOperationBuilder::addNodeInputPreview(NodeInput *input)
{
- PreviewOperation *operation = make_preview_operation();
- if (operation) {
- addOperation(operation);
+ PreviewOperation *operation = make_preview_operation();
+ if (operation) {
+ addOperation(operation);
- mapInputSocket(input, operation->getInputSocket(0));
- }
+ mapInputSocket(input, operation->getInputSocket(0));
+ }
}
void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
{
- if (m_active_viewer) {
- if (m_current_node->isInActiveGroup()) {
- /* deactivate previous viewer */
- m_active_viewer->setActive(false);
+ if (m_active_viewer) {
+ if (m_current_node->isInActiveGroup()) {
+ /* deactivate previous viewer */
+ m_active_viewer->setActive(false);
- m_active_viewer = viewer;
- viewer->setActive(true);
- }
- }
- else {
- if (m_current_node->getbNodeTree() == m_context->getbNodeTree()) {
- m_active_viewer = viewer;
- viewer->setActive(true);
- }
- }
+ m_active_viewer = viewer;
+ viewer->setActive(true);
+ }
+ }
+ else {
+ if (m_current_node->getbNodeTree() == m_context->getbNodeTree()) {
+ m_active_viewer = viewer;
+ viewer->setActive(true);
+ }
+ }
}
/****************************
@@ -263,430 +268,436 @@ void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
void NodeOperationBuilder::add_datatype_conversions()
{
- Links convert_links;
- for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
- const Link &link = *it;
+ Links convert_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
- /* proxy operations can skip data type conversion */
- NodeOperation *from_op = &link.from()->getOperation();
- NodeOperation *to_op = &link.to()->getOperation();
- if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
- continue;
+ /* proxy operations can skip data type conversion */
+ NodeOperation *from_op = &link.from()->getOperation();
+ NodeOperation *to_op = &link.to()->getOperation();
+ if (!(from_op->useDatatypeConversion() || to_op->useDatatypeConversion()))
+ continue;
- if (link.from()->getDataType() != link.to()->getDataType())
- convert_links.push_back(link);
- }
- for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
- const Link &link = *it;
- NodeOperation *converter = Converter::convertDataType(link.from(), link.to());
- if (converter) {
- addOperation(converter);
+ if (link.from()->getDataType() != link.to()->getDataType())
+ convert_links.push_back(link);
+ }
+ for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
+ const Link &link = *it;
+ NodeOperation *converter = Converter::convertDataType(link.from(), link.to());
+ if (converter) {
+ addOperation(converter);
- removeInputLink(link.to());
- addLink(link.from(), converter->getInputSocket(0));
- addLink(converter->getOutputSocket(0), link.to());
- }
- }
+ removeInputLink(link.to());
+ addLink(link.from(), converter->getInputSocket(0));
+ addLink(converter->getOutputSocket(0), link.to());
+ }
+ }
}
void NodeOperationBuilder::add_operation_input_constants()
{
- /* Note: unconnected inputs cached first to avoid modifying
- * m_operations while iterating over it
- */
- typedef std::vector<NodeOperationInput*> Inputs;
- Inputs pending_inputs;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
- for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
- NodeOperationInput *input = op->getInputSocket(k);
- if (!input->isConnected())
- pending_inputs.push_back(input);
- }
- }
- for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
- NodeOperationInput *input = *it;
- add_input_constant_value(input, find_node_input(m_input_map, input));
- }
-}
-
-void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, NodeInput *node_input)
-{
- switch (input->getDataType()) {
- case COM_DT_VALUE: {
- float value;
- if (node_input && node_input->getbNodeSocket())
- value = node_input->getEditorValueFloat();
- else
- value = 0.0f;
-
- SetValueOperation *op = new SetValueOperation();
- op->setValue(value);
- addOperation(op);
- addLink(op->getOutputSocket(), input);
- break;
- }
- case COM_DT_COLOR: {
- float value[4];
- if (node_input && node_input->getbNodeSocket())
- node_input->getEditorValueColor(value);
- else
- zero_v4(value);
-
- SetColorOperation *op = new SetColorOperation();
- op->setChannels(value);
- addOperation(op);
- addLink(op->getOutputSocket(), input);
- break;
- }
- case COM_DT_VECTOR: {
- float value[3];
- if (node_input && node_input->getbNodeSocket())
- node_input->getEditorValueVector(value);
- else
- zero_v3(value);
-
- SetVectorOperation *op = new SetVectorOperation();
- op->setVector(value);
- addOperation(op);
- addLink(op->getOutputSocket(), input);
- break;
- }
- }
+ /* Note: unconnected inputs cached first to avoid modifying
+ * m_operations while iterating over it
+ */
+ typedef std::vector<NodeOperationInput *> Inputs;
+ Inputs pending_inputs;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+ for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
+ NodeOperationInput *input = op->getInputSocket(k);
+ if (!input->isConnected())
+ pending_inputs.push_back(input);
+ }
+ }
+ for (Inputs::const_iterator it = pending_inputs.begin(); it != pending_inputs.end(); ++it) {
+ NodeOperationInput *input = *it;
+ add_input_constant_value(input, find_node_input(m_input_map, input));
+ }
+}
+
+void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
+ NodeInput *node_input)
+{
+ switch (input->getDataType()) {
+ case COM_DT_VALUE: {
+ float value;
+ if (node_input && node_input->getbNodeSocket())
+ value = node_input->getEditorValueFloat();
+ else
+ value = 0.0f;
+
+ SetValueOperation *op = new SetValueOperation();
+ op->setValue(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ case COM_DT_COLOR: {
+ float value[4];
+ if (node_input && node_input->getbNodeSocket())
+ node_input->getEditorValueColor(value);
+ else
+ zero_v4(value);
+
+ SetColorOperation *op = new SetColorOperation();
+ op->setChannels(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ case COM_DT_VECTOR: {
+ float value[3];
+ if (node_input && node_input->getbNodeSocket())
+ node_input->getEditorValueVector(value);
+ else
+ zero_v3(value);
+
+ SetVectorOperation *op = new SetVectorOperation();
+ op->setVector(value);
+ addOperation(op);
+ addLink(op->getOutputSocket(), input);
+ break;
+ }
+ }
}
void NodeOperationBuilder::resolve_proxies()
{
- Links proxy_links;
- for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
- const Link &link = *it;
- /* don't replace links from proxy to proxy, since we may need them for replacing others! */
- if (link.from()->getOperation().isProxyOperation() &&
- !link.to()->getOperation().isProxyOperation())
- {
- proxy_links.push_back(link);
- }
- }
-
- for (Links::const_iterator it = proxy_links.begin(); it != proxy_links.end(); ++it) {
- const Link &link = *it;
-
- NodeOperationInput *to = link.to();
- NodeOperationOutput *from = link.from();
- do {
- /* walk upstream bypassing the proxy operation */
- from = from->getOperation().getInputSocket(0)->getLink();
- } while (from && from->getOperation().isProxyOperation());
-
- removeInputLink(to);
- /* we may not have a final proxy input link,
- * in that case it just gets dropped
- */
- if (from)
- addLink(from, to);
- }
+ Links proxy_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ /* don't replace links from proxy to proxy, since we may need them for replacing others! */
+ if (link.from()->getOperation().isProxyOperation() &&
+ !link.to()->getOperation().isProxyOperation()) {
+ proxy_links.push_back(link);
+ }
+ }
+
+ for (Links::const_iterator it = proxy_links.begin(); it != proxy_links.end(); ++it) {
+ const Link &link = *it;
+
+ NodeOperationInput *to = link.to();
+ NodeOperationOutput *from = link.from();
+ do {
+ /* walk upstream bypassing the proxy operation */
+ from = from->getOperation().getInputSocket(0)->getLink();
+ } while (from && from->getOperation().isProxyOperation());
+
+ removeInputLink(to);
+ /* we may not have a final proxy input link,
+ * in that case it just gets dropped
+ */
+ if (from)
+ addLink(from, to);
+ }
}
void NodeOperationBuilder::determineResolutions()
{
- /* determine all resolutions of the operations (Width/Height) */
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
-
- if (op->isOutputOperation(m_context->isRendering()) && !op->isPreviewOperation()) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- op->determineResolution(resolution, preferredResolution);
- op->setResolution(resolution);
- }
- }
-
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
-
- if (op->isOutputOperation(m_context->isRendering()) && op->isPreviewOperation()) {
- unsigned int resolution[2] = {0, 0};
- unsigned int preferredResolution[2] = {0, 0};
- op->determineResolution(resolution, preferredResolution);
- op->setResolution(resolution);
- }
- }
-
- /* add convert resolution operations when needed */
- {
- Links convert_links;
- for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
- const Link &link = *it;
-
- if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
- NodeOperation &from_op = link.from()->getOperation();
- NodeOperation &to_op = link.to()->getOperation();
- if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight())
- convert_links.push_back(link);
- }
- }
- for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
- const Link &link = *it;
- Converter::convertResolution(*this, link.from(), link.to());
- }
- }
-}
-
-NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links(NodeOperationOutput *output) const
-{
- OpInputs inputs;
- for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
- const Link &link = *it;
- if (link.from() == output)
- inputs.push_back(link.to());
- }
- return inputs;
-}
-
-WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(NodeOperationOutput *output) const
-{
- for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
- const Link &link = *it;
- if (link.from() == output) {
- NodeOperation &op = link.to()->getOperation();
- if (op.isWriteBufferOperation())
- return (WriteBufferOperation *)(&op);
- }
- }
- return NULL;
+ /* determine all resolutions of the operations (Width/Height) */
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering()) && !op->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
+ op->determineResolution(resolution, preferredResolution);
+ op->setResolution(resolution);
+ }
+ }
+
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering()) && op->isPreviewOperation()) {
+ unsigned int resolution[2] = {0, 0};
+ unsigned int preferredResolution[2] = {0, 0};
+ op->determineResolution(resolution, preferredResolution);
+ op->setResolution(resolution);
+ }
+ }
+
+ /* add convert resolution operations when needed */
+ {
+ Links convert_links;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+
+ if (link.to()->getResizeMode() != COM_SC_NO_RESIZE) {
+ NodeOperation &from_op = link.from()->getOperation();
+ NodeOperation &to_op = link.to()->getOperation();
+ if (from_op.getWidth() != to_op.getWidth() || from_op.getHeight() != to_op.getHeight())
+ convert_links.push_back(link);
+ }
+ }
+ for (Links::const_iterator it = convert_links.begin(); it != convert_links.end(); ++it) {
+ const Link &link = *it;
+ Converter::convertResolution(*this, link.from(), link.to());
+ }
+ }
+}
+
+NodeOperationBuilder::OpInputs NodeOperationBuilder::cache_output_links(
+ NodeOperationOutput *output) const
+{
+ OpInputs inputs;
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ if (link.from() == output)
+ inputs.push_back(link.to());
+ }
+ return inputs;
+}
+
+WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(
+ NodeOperationOutput *output) const
+{
+ for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
+ const Link &link = *it;
+ if (link.from() == output) {
+ NodeOperation &op = link.to()->getOperation();
+ if (op.isWriteBufferOperation())
+ return (WriteBufferOperation *)(&op);
+ }
+ }
+ return NULL;
}
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
NodeOperationInput *input)
{
- if (!input->isConnected())
- return;
+ if (!input->isConnected())
+ return;
- NodeOperationOutput *output = input->getLink();
- if (output->getOperation().isReadBufferOperation()) {
- /* input is already buffered, no need to add another */
- return;
- }
+ NodeOperationOutput *output = input->getLink();
+ if (output->getOperation().isReadBufferOperation()) {
+ /* input is already buffered, no need to add another */
+ return;
+ }
- /* this link will be replaced below */
- removeInputLink(input);
+ /* this link will be replaced below */
+ removeInputLink(input);
- /* check of other end already has write operation, otherwise add a new one */
- WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
- if (!writeoperation) {
- writeoperation = new WriteBufferOperation(output->getDataType());
- writeoperation->setbNodeTree(m_context->getbNodeTree());
- addOperation(writeoperation);
+ /* check of other end already has write operation, otherwise add a new one */
+ WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
+ if (!writeoperation) {
+ writeoperation = new WriteBufferOperation(output->getDataType());
+ writeoperation->setbNodeTree(m_context->getbNodeTree());
+ addOperation(writeoperation);
- addLink(output, writeoperation->getInputSocket(0));
+ addLink(output, writeoperation->getInputSocket(0));
- writeoperation->readResolutionFromInputSocket();
- }
+ writeoperation->readResolutionFromInputSocket();
+ }
- /* add readbuffer op for the input */
- ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType());
- readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
- this->addOperation(readoperation);
+ /* add readbuffer op for the input */
+ ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType());
+ readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
+ this->addOperation(readoperation);
- addLink(readoperation->getOutputSocket(), input);
+ addLink(readoperation->getOutputSocket(), input);
- readoperation->readResolutionFromWriteBuffer();
+ readoperation->readResolutionFromWriteBuffer();
}
-void NodeOperationBuilder::add_output_buffers(NodeOperation *operation, NodeOperationOutput *output)
+void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
+ NodeOperationOutput *output)
{
- /* cache connected sockets, so we can safely remove links first before replacing them */
- OpInputs targets = cache_output_links(output);
- if (targets.empty())
- return;
+ /* cache connected sockets, so we can safely remove links first before replacing them */
+ OpInputs targets = cache_output_links(output);
+ if (targets.empty())
+ return;
- WriteBufferOperation *writeOperation = NULL;
- for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- NodeOperationInput *target = *it;
+ WriteBufferOperation *writeOperation = NULL;
+ for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
+ NodeOperationInput *target = *it;
- /* try to find existing write buffer operation */
- if (target->getOperation().isWriteBufferOperation()) {
- BLI_assert(writeOperation == NULL); /* there should only be one write op connected */
- writeOperation = (WriteBufferOperation *)(&target->getOperation());
- }
- else {
- /* remove all links to other nodes */
- removeInputLink(target);
- }
- }
+ /* try to find existing write buffer operation */
+ if (target->getOperation().isWriteBufferOperation()) {
+ BLI_assert(writeOperation == NULL); /* there should only be one write op connected */
+ writeOperation = (WriteBufferOperation *)(&target->getOperation());
+ }
+ else {
+ /* remove all links to other nodes */
+ removeInputLink(target);
+ }
+ }
- /* if no write buffer operation exists yet, create a new one */
- if (!writeOperation) {
- writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
- writeOperation->setbNodeTree(m_context->getbNodeTree());
- addOperation(writeOperation);
+ /* if no write buffer operation exists yet, create a new one */
+ if (!writeOperation) {
+ writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
+ writeOperation->setbNodeTree(m_context->getbNodeTree());
+ addOperation(writeOperation);
- addLink(output, writeOperation->getInputSocket(0));
- }
+ addLink(output, writeOperation->getInputSocket(0));
+ }
- writeOperation->readResolutionFromInputSocket();
+ writeOperation->readResolutionFromInputSocket();
- /* add readbuffer op for every former connected input */
- for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- NodeOperationInput *target = *it;
- if (&target->getOperation() == writeOperation)
- continue; /* skip existing write op links */
+ /* add readbuffer op for every former connected input */
+ for (OpInputs::const_iterator it = targets.begin(); it != targets.end(); ++it) {
+ NodeOperationInput *target = *it;
+ if (&target->getOperation() == writeOperation)
+ continue; /* skip existing write op links */
- ReadBufferOperation *readoperation = new ReadBufferOperation(operation->getOutputSocket()->getDataType());
- readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
- addOperation(readoperation);
+ ReadBufferOperation *readoperation = new ReadBufferOperation(
+ operation->getOutputSocket()->getDataType());
+ readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
+ addOperation(readoperation);
- addLink(readoperation->getOutputSocket(), target);
+ addLink(readoperation->getOutputSocket(), target);
- readoperation->readResolutionFromWriteBuffer();
- }
+ readoperation->readResolutionFromWriteBuffer();
+ }
}
void NodeOperationBuilder::add_complex_operation_buffers()
{
- /* note: complex ops and get cached here first, since adding operations
- * will invalidate iterators over the main m_operations
- */
- Operations complex_ops;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
- if ((*it)->isComplex())
- complex_ops.push_back(*it);
+ /* note: complex ops and get cached here first, since adding operations
+ * will invalidate iterators over the main m_operations
+ */
+ Operations complex_ops;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
+ if ((*it)->isComplex())
+ complex_ops.push_back(*it);
- for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
- NodeOperation *op = *it;
+ for (Operations::const_iterator it = complex_ops.begin(); it != complex_ops.end(); ++it) {
+ NodeOperation *op = *it;
- DebugInfo::operation_read_write_buffer(op);
+ DebugInfo::operation_read_write_buffer(op);
- for (int index = 0; index < op->getNumberOfInputSockets(); index++)
- add_input_buffers(op, op->getInputSocket(index));
+ for (int index = 0; index < op->getNumberOfInputSockets(); index++)
+ add_input_buffers(op, op->getInputSocket(index));
- for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
- add_output_buffers(op, op->getOutputSocket(index));
- }
+ for (int index = 0; index < op->getNumberOfOutputSockets(); index++)
+ add_output_buffers(op, op->getOutputSocket(index));
+ }
}
-typedef std::set<NodeOperation*> Tags;
+typedef std::set<NodeOperation *> Tags;
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
{
- if (reachable.find(op) != reachable.end())
- return;
- reachable.insert(op);
+ if (reachable.find(op) != reachable.end())
+ return;
+ reachable.insert(op);
- for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
- NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
- find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
- }
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
+ }
- /* associated write-buffer operations are executed as well */
- if (op->isReadBufferOperation()) {
- ReadBufferOperation *read_op = (ReadBufferOperation *)op;
- MemoryProxy *memproxy = read_op->getMemoryProxy();
- find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation());
- }
+ /* associated write-buffer operations are executed as well */
+ if (op->isReadBufferOperation()) {
+ ReadBufferOperation *read_op = (ReadBufferOperation *)op;
+ MemoryProxy *memproxy = read_op->getMemoryProxy();
+ find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation());
+ }
}
void NodeOperationBuilder::prune_operations()
{
- Tags reachable;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
+ Tags reachable;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
- /* output operations are primary executed operations */
- if (op->isOutputOperation(m_context->isRendering()))
- find_reachable_operations_recursive(reachable, op);
- }
+ /* output operations are primary executed operations */
+ if (op->isOutputOperation(m_context->isRendering()))
+ find_reachable_operations_recursive(reachable, op);
+ }
- /* delete unreachable operations */
- Operations reachable_ops;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
+ /* delete unreachable operations */
+ Operations reachable_ops;
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
- if (reachable.find(op) != reachable.end())
- reachable_ops.push_back(op);
- else
- delete op;
- }
- /* finally replace the operations list with the pruned list */
- m_operations = reachable_ops;
+ if (reachable.find(op) != reachable.end())
+ reachable_ops.push_back(op);
+ else
+ delete op;
+ }
+ /* finally replace the operations list with the pruned list */
+ m_operations = reachable_ops;
}
/* topological (depth-first) sorting of operations */
-static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted, Tags &visited, NodeOperation *op)
+static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted,
+ Tags &visited,
+ NodeOperation *op)
{
- if (visited.find(op) != visited.end())
- return;
- visited.insert(op);
+ if (visited.find(op) != visited.end())
+ return;
+ visited.insert(op);
- for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
- NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
- sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
- }
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
+ }
- sorted.push_back(op);
+ sorted.push_back(op);
}
void NodeOperationBuilder::sort_operations()
{
- Operations sorted;
- sorted.reserve(m_operations.size());
- Tags visited;
+ Operations sorted;
+ sorted.reserve(m_operations.size());
+ Tags visited;
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
- sort_operations_recursive(sorted, visited, *it);
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it)
+ sort_operations_recursive(sorted, visited, *it);
- m_operations = sorted;
+ m_operations = sorted;
}
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
{
- if (visited.find(op) != visited.end())
- return;
- visited.insert(op);
+ if (visited.find(op) != visited.end())
+ return;
+ visited.insert(op);
- if (!group->addOperation(op))
- return;
+ if (!group->addOperation(op))
+ return;
- /* add all eligible input ops to the group */
- for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
- NodeOperationInput *input = op->getInputSocket(i);
- if (input->isConnected())
- add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
- }
+ /* add all eligible input ops to the group */
+ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) {
+ NodeOperationInput *input = op->getInputSocket(i);
+ if (input->isConnected())
+ add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
+ }
}
ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
{
- ExecutionGroup *group = new ExecutionGroup();
- m_groups.push_back(group);
+ ExecutionGroup *group = new ExecutionGroup();
+ m_groups.push_back(group);
- Tags visited;
- add_group_operations_recursive(visited, op, group);
+ Tags visited;
+ add_group_operations_recursive(visited, op, group);
- return group;
+ return group;
}
void NodeOperationBuilder::group_operations()
{
- for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
- NodeOperation *op = *it;
-
- if (op->isOutputOperation(m_context->isRendering())) {
- ExecutionGroup *group = make_group(op);
- group->setOutputExecutionGroup(true);
- }
-
- /* add new groups for associated memory proxies where needed */
- if (op->isReadBufferOperation()) {
- ReadBufferOperation *read_op = (ReadBufferOperation *)op;
- MemoryProxy *memproxy = read_op->getMemoryProxy();
-
- if (memproxy->getExecutor() == NULL) {
- ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
- memproxy->setExecutor(group);
- }
- }
- }
+ for (Operations::const_iterator it = m_operations.begin(); it != m_operations.end(); ++it) {
+ NodeOperation *op = *it;
+
+ if (op->isOutputOperation(m_context->isRendering())) {
+ ExecutionGroup *group = make_group(op);
+ group->setOutputExecutionGroup(true);
+ }
+
+ /* add new groups for associated memory proxies where needed */
+ if (op->isReadBufferOperation()) {
+ ReadBufferOperation *read_op = (ReadBufferOperation *)op;
+ MemoryProxy *memproxy = read_op->getMemoryProxy();
+
+ if (memproxy->getExecutor() == NULL) {
+ ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
+ memproxy->setExecutor(group);
+ }
+ }
+ }
}
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.h b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
index f4ab18b4f31..917fa2888fd 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.h
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.h
@@ -44,123 +44,136 @@ class WriteBufferOperation;
class ViewerOperation;
class NodeOperationBuilder {
-public:
- class Link {
- private:
- NodeOperationOutput *m_from;
- NodeOperationInput *m_to;
+ public:
+ class Link {
+ private:
+ NodeOperationOutput *m_from;
+ NodeOperationInput *m_to;
+
+ public:
+ Link(NodeOperationOutput *from, NodeOperationInput *to) : m_from(from), m_to(to)
+ {
+ }
+
+ NodeOperationOutput *from() const
+ {
+ return m_from;
+ }
+ NodeOperationInput *to() const
+ {
+ return m_to;
+ }
+ };
+
+ typedef std::vector<NodeOperation *> Operations;
+ typedef std::vector<Link> Links;
+ typedef std::vector<ExecutionGroup *> Groups;
+
+ typedef std::map<NodeOperationInput *, NodeInput *> InputSocketMap;
+ typedef std::map<NodeOutput *, NodeOperationOutput *> OutputSocketMap;
+
+ typedef std::vector<NodeOperationInput *> OpInputs;
+ typedef std::map<NodeInput *, OpInputs> OpInputInverseMap;
+
+ private:
+ const CompositorContext *m_context;
+ NodeGraph m_graph;
+
+ Operations m_operations;
+ Links m_links;
+ Groups m_groups;
+
+ /** Maps operation inputs to node inputs */
+ InputSocketMap m_input_map;
+ /** Maps node outputs to operation outputs */
+ OutputSocketMap m_output_map;
+
+ Node *m_current_node;
+
+ /** Operation that will be writing to the viewer image
+ * Only one operation can occupy this place at a time,
+ * to avoid race conditions
+ */
+ ViewerOperation *m_active_viewer;
+
+ public:
+ NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree);
+ ~NodeOperationBuilder();
+
+ const CompositorContext &context() const
+ {
+ return *m_context;
+ }
+
+ void convertToOperations(ExecutionSystem *system);
+
+ void addOperation(NodeOperation *operation);
+
+ /** Map input socket of the current node to an operation socket */
+ void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
+ /** Map output socket of the current node to an operation socket */
+ void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
+
+ void addLink(NodeOperationOutput *from, NodeOperationInput *to);
+ void removeInputLink(NodeOperationInput *to);
+
+ /** Add a preview operation for a operation output */
+ void addPreview(NodeOperationOutput *output);
+ /** Add a preview operation for a node input */
+ void addNodeInputPreview(NodeInput *input);
+
+ /** Define a viewer operation as the active output, if possible */
+ void registerViewer(ViewerOperation *viewer);
+ /** The currently active viewer output operation */
+ ViewerOperation *active_viewer() const
+ {
+ return m_active_viewer;
+ }
+
+ protected:
+ static NodeInput *find_node_input(const InputSocketMap &map, NodeOperationInput *op_input);
+ static const OpInputs &find_operation_inputs(const OpInputInverseMap &map,
+ NodeInput *node_input);
+ static NodeOperationOutput *find_operation_output(const OutputSocketMap &map,
+ NodeOutput *node_output);
+
+ /** Add datatype conversion where needed */
+ void add_datatype_conversions();
+
+ /** Construct a constant value operation for every unconnected input */
+ void add_operation_input_constants();
+ void add_input_constant_value(NodeOperationInput *input, NodeInput *node_input);
+
+ /** Replace proxy operations with direct links */
+ void resolve_proxies();
+
+ /** Calculate resolution for each operation */
+ void determineResolutions();
+
+ /** Helper function to store connected inputs for replacement */
+ OpInputs cache_output_links(NodeOperationOutput *output) const;
+ /** Find a connected write buffer operation to an OpOutput */
+ WriteBufferOperation *find_attached_write_buffer_operation(NodeOperationOutput *output) const;
+ /** Add read/write buffer operations around complex operations */
+ void add_complex_operation_buffers();
+ void add_input_buffers(NodeOperation *operation, NodeOperationInput *input);
+ void add_output_buffers(NodeOperation *operation, NodeOperationOutput *output);
+
+ /** Remove unreachable operations */
+ void prune_operations();
- public:
- Link(NodeOperationOutput *from, NodeOperationInput *to) :
- m_from(from),
- m_to(to)
- {}
+ /** Sort operations by link dependencies */
+ void sort_operations();
- NodeOperationOutput *from() const { return m_from; }
- NodeOperationInput *to() const { return m_to; }
- };
+ /** Create execution groups */
+ void group_operations();
+ ExecutionGroup *make_group(NodeOperation *op);
- typedef std::vector<NodeOperation *> Operations;
- typedef std::vector<Link> Links;
- typedef std::vector<ExecutionGroup *> Groups;
-
- typedef std::map<NodeOperationInput *, NodeInput *> InputSocketMap;
- typedef std::map<NodeOutput *, NodeOperationOutput *> OutputSocketMap;
-
- typedef std::vector<NodeOperationInput *> OpInputs;
- typedef std::map<NodeInput *, OpInputs> OpInputInverseMap;
-
-private:
- const CompositorContext *m_context;
- NodeGraph m_graph;
-
- Operations m_operations;
- Links m_links;
- Groups m_groups;
-
- /** Maps operation inputs to node inputs */
- InputSocketMap m_input_map;
- /** Maps node outputs to operation outputs */
- OutputSocketMap m_output_map;
-
- Node *m_current_node;
-
- /** Operation that will be writing to the viewer image
- * Only one operation can occupy this place at a time,
- * to avoid race conditions
- */
- ViewerOperation *m_active_viewer;
-
-public:
- NodeOperationBuilder(const CompositorContext *context, bNodeTree *b_nodetree);
- ~NodeOperationBuilder();
-
- const CompositorContext &context() const { return *m_context; }
-
- void convertToOperations(ExecutionSystem *system);
-
- void addOperation(NodeOperation *operation);
-
- /** Map input socket of the current node to an operation socket */
- void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
- /** Map output socket of the current node to an operation socket */
- void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
-
- void addLink(NodeOperationOutput *from, NodeOperationInput *to);
- void removeInputLink(NodeOperationInput *to);
-
- /** Add a preview operation for a operation output */
- void addPreview(NodeOperationOutput *output);
- /** Add a preview operation for a node input */
- void addNodeInputPreview(NodeInput *input);
-
- /** Define a viewer operation as the active output, if possible */
- void registerViewer(ViewerOperation *viewer);
- /** The currently active viewer output operation */
- ViewerOperation *active_viewer() const { return m_active_viewer; }
-
-protected:
- static NodeInput *find_node_input(const InputSocketMap &map, NodeOperationInput *op_input);
- static const OpInputs &find_operation_inputs(const OpInputInverseMap &map, NodeInput *node_input);
- static NodeOperationOutput *find_operation_output(const OutputSocketMap &map, NodeOutput *node_output);
-
- /** Add datatype conversion where needed */
- void add_datatype_conversions();
-
- /** Construct a constant value operation for every unconnected input */
- void add_operation_input_constants();
- void add_input_constant_value(NodeOperationInput *input, NodeInput *node_input);
-
- /** Replace proxy operations with direct links */
- void resolve_proxies();
-
- /** Calculate resolution for each operation */
- void determineResolutions();
-
- /** Helper function to store connected inputs for replacement */
- OpInputs cache_output_links(NodeOperationOutput *output) const;
- /** Find a connected write buffer operation to an OpOutput */
- WriteBufferOperation *find_attached_write_buffer_operation(NodeOperationOutput *output) const;
- /** Add read/write buffer operations around complex operations */
- void add_complex_operation_buffers();
- void add_input_buffers(NodeOperation *operation, NodeOperationInput *input);
- void add_output_buffers(NodeOperation *operation, NodeOperationOutput *output);
-
- /** Remove unreachable operations */
- void prune_operations();
-
- /** Sort operations by link dependencies */
- void sort_operations();
-
- /** Create execution groups */
- void group_operations();
- ExecutionGroup *make_group(NodeOperation *op);
-
-private:
- PreviewOperation *make_preview_operation() const;
+ private:
+ PreviewOperation *make_preview_operation() const;
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompilerImpl")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompilerImpl")
#endif
};
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.cpp b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
index fd74c7ebfa4..12e072b9b12 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.cpp
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.cpp
@@ -19,200 +19,250 @@
#include "COM_OpenCLDevice.h"
#include "COM_WorkScheduler.h"
-typedef enum COM_VendorID {NVIDIA = 0x10DE, AMD = 0x1002} COM_VendorID;
+typedef enum COM_VendorID { NVIDIA = 0x10DE, AMD = 0x1002 } COM_VendorID;
const cl_image_format IMAGE_FORMAT_COLOR = {
- CL_RGBA,
- CL_FLOAT,
+ CL_RGBA,
+ CL_FLOAT,
};
const cl_image_format IMAGE_FORMAT_VECTOR = {
- CL_RGB,
- CL_FLOAT,
+ CL_RGB,
+ CL_FLOAT,
};
const cl_image_format IMAGE_FORMAT_VALUE = {
- CL_R,
- CL_FLOAT,
+ CL_R,
+ CL_FLOAT,
};
-OpenCLDevice::OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId)
+OpenCLDevice::OpenCLDevice(cl_context context,
+ cl_device_id device,
+ cl_program program,
+ cl_int vendorId)
{
- this->m_device = device;
- this->m_context = context;
- this->m_program = program;
- this->m_queue = NULL;
- this->m_vendorID = vendorId;
+ this->m_device = device;
+ this->m_context = context;
+ this->m_program = program;
+ this->m_queue = NULL;
+ this->m_vendorID = vendorId;
}
bool OpenCLDevice::initialize()
{
- cl_int error;
- this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error);
- return false;
+ cl_int error;
+ this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error);
+ return false;
}
void OpenCLDevice::deinitialize()
{
- if (this->m_queue) {
- clReleaseCommandQueue(this->m_queue);
- }
+ if (this->m_queue) {
+ clReleaseCommandQueue(this->m_queue);
+ }
}
void OpenCLDevice::execute(WorkPackage *work)
{
- const unsigned int chunkNumber = work->getChunkNumber();
- ExecutionGroup *executionGroup = work->getExecutionGroup();
- rcti rect;
+ const unsigned int chunkNumber = work->getChunkNumber();
+ ExecutionGroup *executionGroup = work->getExecutionGroup();
+ rcti rect;
- executionGroup->determineChunkRect(&rect, chunkNumber);
- MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
- MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
+ executionGroup->determineChunkRect(&rect, chunkNumber);
+ MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
+ MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
- executionGroup->getOutputOperation()->executeOpenCLRegion(this, &rect,
- chunkNumber, inputBuffers, outputBuffer);
+ executionGroup->getOutputOperation()->executeOpenCLRegion(
+ this, &rect, chunkNumber, inputBuffers, outputBuffer);
- delete outputBuffer;
+ delete outputBuffer;
- executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
+ executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
}
-cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex,
- list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers,
+cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ int offsetIndex,
+ list<cl_mem> *cleanup,
+ MemoryBuffer **inputMemoryBuffers,
SocketReader *reader)
{
- return COM_clAttachMemoryBufferToKernelParameter(kernel, parameterIndex, offsetIndex, cleanup, inputMemoryBuffers, (ReadBufferOperation *)reader);
+ return COM_clAttachMemoryBufferToKernelParameter(kernel,
+ parameterIndex,
+ offsetIndex,
+ cleanup,
+ inputMemoryBuffers,
+ (ReadBufferOperation *)reader);
}
const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer)
{
- const cl_image_format *imageFormat;
- int num_channels = memoryBuffer->get_num_channels();
- if (num_channels == 1) {
- imageFormat = &IMAGE_FORMAT_VALUE;
- }
- else if (num_channels == 3) {
- imageFormat = &IMAGE_FORMAT_VECTOR;
- }
- else {
- imageFormat = &IMAGE_FORMAT_COLOR;
- }
-
- return imageFormat;
+ const cl_image_format *imageFormat;
+ int num_channels = memoryBuffer->get_num_channels();
+ if (num_channels == 1) {
+ imageFormat = &IMAGE_FORMAT_VALUE;
+ }
+ else if (num_channels == 3) {
+ imageFormat = &IMAGE_FORMAT_VECTOR;
+ }
+ else {
+ imageFormat = &IMAGE_FORMAT_COLOR;
+ }
+
+ return imageFormat;
}
-cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex,
- list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers,
+cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ int offsetIndex,
+ list<cl_mem> *cleanup,
+ MemoryBuffer **inputMemoryBuffers,
ReadBufferOperation *reader)
{
- cl_int error;
-
- MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
-
- const cl_image_format *imageFormat = determineImageFormat(result);
-
- cl_mem clBuffer = clCreateImage2D(this->m_context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, imageFormat, result->getWidth(),
- result->getHeight(), 0, result->getBuffer(), &error);
-
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- if (error == CL_SUCCESS) cleanup->push_back(clBuffer);
-
- error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
-
- COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result);
- return clBuffer;
+ cl_int error;
+
+ MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
+
+ const cl_image_format *imageFormat = determineImageFormat(result);
+
+ cl_mem clBuffer = clCreateImage2D(this->m_context,
+ CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
+ imageFormat,
+ result->getWidth(),
+ result->getHeight(),
+ 0,
+ result->getBuffer(),
+ &error);
+
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ if (error == CL_SUCCESS)
+ cleanup->push_back(clBuffer);
+
+ error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+
+ COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result);
+ return clBuffer;
}
-void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffer)
+void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel,
+ int offsetIndex,
+ MemoryBuffer *memoryBuffer)
{
- if (offsetIndex != -1) {
- cl_int error;
- rcti *rect = memoryBuffer->getRect();
- cl_int2 offset = {{rect->xmin, rect->ymin}};
-
- error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- }
+ if (offsetIndex != -1) {
+ cl_int error;
+ rcti *rect = memoryBuffer->getRect();
+ cl_int2 offset = {{rect->xmin, rect->ymin}};
+
+ error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ }
}
-void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation *operation)
+void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel,
+ int offsetIndex,
+ NodeOperation *operation)
{
- if (offsetIndex != -1) {
- cl_int error;
- cl_int2 offset = {{(cl_int)operation->getWidth(), (cl_int)operation->getHeight()}};
-
- error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- }
+ if (offsetIndex != -1) {
+ cl_int error;
+ cl_int2 offset = {{(cl_int)operation->getWidth(), (cl_int)operation->getHeight()}};
+
+ error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ }
}
-void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer)
+void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ cl_mem clOutputMemoryBuffer)
{
- cl_int error;
- error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ cl_int error;
+ error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
}
void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer)
{
- cl_int error;
- const size_t size[] = {(size_t)outputMemoryBuffer->getWidth(), (size_t)outputMemoryBuffer->getHeight()};
-
- error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
+ cl_int error;
+ const size_t size[] = {(size_t)outputMemoryBuffer->getWidth(),
+ (size_t)outputMemoryBuffer->getHeight()};
+
+ error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
}
-void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation *operation)
+void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
+ MemoryBuffer *outputMemoryBuffer,
+ int offsetIndex,
+ NodeOperation *operation)
{
- cl_int error;
- const int width = outputMemoryBuffer->getWidth();
- const int height = outputMemoryBuffer->getHeight();
- int offsetx;
- int offsety;
- int localSize = 1024;
- size_t size[2];
- cl_int2 offset;
-
- if (this->m_vendorID == NVIDIA) {
- localSize = 32;
- }
-
- bool breaked = false;
- for (offsety = 0; offsety < height && (!breaked); offsety += localSize) {
- offset.s[1] = offsety;
- if (offsety + localSize < height) {
- size[1] = localSize;
- }
- else {
- size[1] = height - offsety;
- }
-
- for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) {
- if (offsetx + localSize < width) {
- size[0] = localSize;
- }
- else {
- size[0] = width - offsetx;
- }
- offset.s[0] = offsetx;
-
- error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- clFlush(this->m_queue);
- if (operation->isBreaked()) {
- breaked = false;
- }
- }
- }
+ cl_int error;
+ const int width = outputMemoryBuffer->getWidth();
+ const int height = outputMemoryBuffer->getHeight();
+ int offsetx;
+ int offsety;
+ int localSize = 1024;
+ size_t size[2];
+ cl_int2 offset;
+
+ if (this->m_vendorID == NVIDIA) {
+ localSize = 32;
+ }
+
+ bool breaked = false;
+ for (offsety = 0; offsety < height && (!breaked); offsety += localSize) {
+ offset.s[1] = offsety;
+ if (offsety + localSize < height) {
+ size[1] = localSize;
+ }
+ else {
+ size[1] = height - offsety;
+ }
+
+ for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) {
+ if (offsetx + localSize < width) {
+ size[0] = localSize;
+ }
+ else {
+ size[0] = width - offsetx;
+ }
+ offset.s[0] = offsetx;
+
+ error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ error = clEnqueueNDRangeKernel(this->m_queue, kernel, 2, NULL, size, 0, 0, 0, NULL);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ clFlush(this->m_queue);
+ if (operation->isBreaked()) {
+ breaked = false;
+ }
+ }
+ }
}
-cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp)
+cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
+ list<cl_kernel> *clKernelsToCleanUp)
{
- cl_int error;
- cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- else {
- if (clKernelsToCleanUp) clKernelsToCleanUp->push_back(kernel);
- }
- return kernel;
-
+ cl_int error;
+ cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ else {
+ if (clKernelsToCleanUp)
+ clKernelsToCleanUp->push_back(kernel);
+ }
+ return kernel;
}
diff --git a/source/blender/compositor/intern/COM_OpenCLDevice.h b/source/blender/compositor/intern/COM_OpenCLDevice.h
index 8cd0c31e658..7a83bda162c 100644
--- a/source/blender/compositor/intern/COM_OpenCLDevice.h
+++ b/source/blender/compositor/intern/COM_OpenCLDevice.h
@@ -33,81 +33,105 @@ using std::list;
* an instance of this class represents a single cl_device
*/
class OpenCLDevice : public Device {
-private:
- /**
- * \brief opencl context
- */
- cl_context m_context;
-
- /**
- * \brief opencl device
- */
- cl_device_id m_device;
-
- /**
- * \brief opencl program
- */
- cl_program m_program;
-
- /**
- * \brief opencl command queue
- */
- cl_command_queue m_queue;
-
- /**
- * \brief opencl vendor ID
- */
- cl_int m_vendorID;
-
-public:
- /**
- * \brief constructor with opencl device
- * \param context:
- * \param device:
- * \param program:
- * \param vendorID:
- */
- OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId);
-
-
- /**
- * \brief initialize the device
- * During initialization the OpenCL cl_command_queue is created
- * the command queue is stored in the field queue.
- * \see queue
- */
- bool initialize();
-
- /**
- * \brief deinitialize the device
- * During deintiialization the command queue is cleared
- */
- void deinitialize();
-
- /**
- * \brief execute a WorkPackage
- * \param work: the WorkPackage to execute
- */
- void execute(WorkPackage *work);
-
- /**
- * \brief determine an image format
- * \param memorybuffer:
- */
- static const cl_image_format *determineImageFormat(MemoryBuffer *memoryBuffer);
-
- cl_context getContext() { return this->m_context; }
-
- cl_command_queue getQueue() { return this->m_queue; }
-
- cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, SocketReader *reader);
- cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, int offsetIndex, list<cl_mem> *cleanup, MemoryBuffer **inputMemoryBuffers, ReadBufferOperation *reader);
- void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel, int offsetIndex, MemoryBuffer *memoryBuffers);
- void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel, int parameterIndex, cl_mem clOutputMemoryBuffer);
- void COM_clAttachSizeToKernelParameter(cl_kernel kernel, int offsetIndex, NodeOperation *operation);
- void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer);
- void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer, int offsetIndex, NodeOperation *operation);
- cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp);
+ private:
+ /**
+ * \brief opencl context
+ */
+ cl_context m_context;
+
+ /**
+ * \brief opencl device
+ */
+ cl_device_id m_device;
+
+ /**
+ * \brief opencl program
+ */
+ cl_program m_program;
+
+ /**
+ * \brief opencl command queue
+ */
+ cl_command_queue m_queue;
+
+ /**
+ * \brief opencl vendor ID
+ */
+ cl_int m_vendorID;
+
+ public:
+ /**
+ * \brief constructor with opencl device
+ * \param context:
+ * \param device:
+ * \param program:
+ * \param vendorID:
+ */
+ OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId);
+
+ /**
+ * \brief initialize the device
+ * During initialization the OpenCL cl_command_queue is created
+ * the command queue is stored in the field queue.
+ * \see queue
+ */
+ bool initialize();
+
+ /**
+ * \brief deinitialize the device
+ * During deintiialization the command queue is cleared
+ */
+ void deinitialize();
+
+ /**
+ * \brief execute a WorkPackage
+ * \param work: the WorkPackage to execute
+ */
+ void execute(WorkPackage *work);
+
+ /**
+ * \brief determine an image format
+ * \param memorybuffer:
+ */
+ static const cl_image_format *determineImageFormat(MemoryBuffer *memoryBuffer);
+
+ cl_context getContext()
+ {
+ return this->m_context;
+ }
+
+ cl_command_queue getQueue()
+ {
+ return this->m_queue;
+ }
+
+ cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ int offsetIndex,
+ list<cl_mem> *cleanup,
+ MemoryBuffer **inputMemoryBuffers,
+ SocketReader *reader);
+ cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ int offsetIndex,
+ list<cl_mem> *cleanup,
+ MemoryBuffer **inputMemoryBuffers,
+ ReadBufferOperation *reader);
+ void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel,
+ int offsetIndex,
+ MemoryBuffer *memoryBuffers);
+ void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel,
+ int parameterIndex,
+ cl_mem clOutputMemoryBuffer);
+ void COM_clAttachSizeToKernelParameter(cl_kernel kernel,
+ int offsetIndex,
+ NodeOperation *operation);
+ void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer);
+ void COM_clEnqueueRange(cl_kernel kernel,
+ MemoryBuffer *outputMemoryBuffer,
+ int offsetIndex,
+ NodeOperation *operation);
+ cl_kernel COM_clCreateKernel(const char *kernelname, list<cl_kernel> *clKernelsToCleanUp);
};
#endif
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
index 10d9929d2cc..e6b018eeb94 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.cpp
@@ -20,37 +20,38 @@
SingleThreadedOperation::SingleThreadedOperation() : NodeOperation()
{
- this->m_cachedInstance = NULL;
- setComplex(true);
+ this->m_cachedInstance = NULL;
+ setComplex(true);
}
void SingleThreadedOperation::initExecution()
{
- initMutex();
+ initMutex();
}
void SingleThreadedOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- this->m_cachedInstance->readNoCheck(output, x, y);
+ this->m_cachedInstance->readNoCheck(output, x, y);
}
void SingleThreadedOperation::deinitExecution()
{
- deinitMutex();
- if (this->m_cachedInstance) {
- delete this->m_cachedInstance;
- this->m_cachedInstance = NULL;
- }
+ deinitMutex();
+ if (this->m_cachedInstance) {
+ delete this->m_cachedInstance;
+ this->m_cachedInstance = NULL;
+ }
}
void *SingleThreadedOperation::initializeTileData(rcti *rect)
{
- if (this->m_cachedInstance) return this->m_cachedInstance;
+ if (this->m_cachedInstance)
+ return this->m_cachedInstance;
- lockMutex();
- if (this->m_cachedInstance == NULL) {
- //
- this->m_cachedInstance = createMemoryBuffer(rect);
- }
- unlockMutex();
- return this->m_cachedInstance;
+ lockMutex();
+ if (this->m_cachedInstance == NULL) {
+ //
+ this->m_cachedInstance = createMemoryBuffer(rect);
+ }
+ unlockMutex();
+ return this->m_cachedInstance;
}
diff --git a/source/blender/compositor/intern/COM_SingleThreadedOperation.h b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
index bafd092a5b1..68c7f05a6c2 100644
--- a/source/blender/compositor/intern/COM_SingleThreadedOperation.h
+++ b/source/blender/compositor/intern/COM_SingleThreadedOperation.h
@@ -21,36 +21,40 @@
#include "COM_NodeOperation.h"
class SingleThreadedOperation : public NodeOperation {
-private:
- MemoryBuffer *m_cachedInstance;
+ private:
+ MemoryBuffer *m_cachedInstance;
-protected:
- inline bool isCached() {
- return this->m_cachedInstance != NULL;
- }
+ protected:
+ inline bool isCached()
+ {
+ return this->m_cachedInstance != NULL;
+ }
-public:
- SingleThreadedOperation();
+ public:
+ SingleThreadedOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
- virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0;
+ virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0;
- int isSingleThreaded() { return true; }
+ int isSingleThreaded()
+ {
+ return true;
+ }
};
#endif
diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h
index dfab1084dae..82bebd5e7b9 100644
--- a/source/blender/compositor/intern/COM_SocketReader.h
+++ b/source/blender/compositor/intern/COM_SocketReader.h
@@ -22,13 +22,13 @@
#include "COM_defines.h"
#ifdef WITH_CXX_GUARDEDALLOC
-#include "MEM_guardedalloc.h"
+# include "MEM_guardedalloc.h"
#endif
typedef enum PixelSampler {
- COM_PS_NEAREST = 0,
- COM_PS_BILINEAR = 1,
- COM_PS_BICUBIC = 2,
+ COM_PS_NEAREST = 0,
+ COM_PS_BILINEAR = 1,
+ COM_PS_BICUBIC = 2,
} PixelSampler;
class MemoryBuffer;
@@ -38,82 +38,104 @@ class MemoryBuffer;
* \ingroup Execution
*/
class SocketReader {
-private:
-protected:
- /**
- * \brief Holds the width of the output of this operation.
- */
- unsigned int m_width;
-
- /**
- * \brief Holds the height of the output of this operation.
- */
- unsigned int m_height;
-
-
- /**
- * \brief calculate a single pixel
- * \note this method is called for non-complex
- * \param result: is a float[4] array to store the result
- * \param x: the x-coordinate of the pixel to calculate in image space
- * \param y: the y-coordinate of the pixel to calculate in image space
- * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
- */
- virtual void executePixelSampled(float /*output*/[4],
- float /*x*/,
- float /*y*/,
- PixelSampler /*sampler*/) { }
-
- /**
- * \brief calculate a single pixel
- * \note this method is called for complex
- * \param result: is a float[4] array to store the result
- * \param x: the x-coordinate of the pixel to calculate in image space
- * \param y: the y-coordinate of the pixel to calculate in image space
- * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
- * \param chunkData: chunk specific data a during execution time.
- */
- virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/) {
- executePixelSampled(output, x, y, COM_PS_NEAREST);
- }
-
- /**
- * \brief calculate a single pixel using an EWA filter
- * \note this method is called for complex
- * \param result: is a float[4] array to store the result
- * \param x: the x-coordinate of the pixel to calculate in image space
- * \param y: the y-coordinate of the pixel to calculate in image space
- * \param dx:
- * \param dy:
- * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
- */
- virtual void executePixelFiltered(float /*output*/[4],
- float /*x*/, float /*y*/,
- float /*dx*/[2], float /*dy*/[2]) {}
-
-public:
- inline void readSampled(float result[4], float x, float y, PixelSampler sampler) {
- executePixelSampled(result, x, y, sampler);
- }
- inline void read(float result[4], int x, int y, void *chunkData) {
- executePixel(result, x, y, chunkData);
- }
- inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2]) {
- executePixelFiltered(result, x, y, dx, dy);
- }
-
- virtual void *initializeTileData(rcti * /*rect*/) { return 0; }
- virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/) {}
-
- virtual ~SocketReader() {}
-
- virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/) { return 0; }
-
- inline unsigned int getWidth() const { return this->m_width; }
- inline unsigned int getHeight() const { return this->m_height; }
+ private:
+ protected:
+ /**
+ * \brief Holds the width of the output of this operation.
+ */
+ unsigned int m_width;
+
+ /**
+ * \brief Holds the height of the output of this operation.
+ */
+ unsigned int m_height;
+
+ /**
+ * \brief calculate a single pixel
+ * \note this method is called for non-complex
+ * \param result: is a float[4] array to store the result
+ * \param x: the x-coordinate of the pixel to calculate in image space
+ * \param y: the y-coordinate of the pixel to calculate in image space
+ * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+ */
+ virtual void executePixelSampled(float /*output*/[4],
+ float /*x*/,
+ float /*y*/,
+ PixelSampler /*sampler*/)
+ {
+ }
+
+ /**
+ * \brief calculate a single pixel
+ * \note this method is called for complex
+ * \param result: is a float[4] array to store the result
+ * \param x: the x-coordinate of the pixel to calculate in image space
+ * \param y: the y-coordinate of the pixel to calculate in image space
+ * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+ * \param chunkData: chunk specific data a during execution time.
+ */
+ virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
+ {
+ executePixelSampled(output, x, y, COM_PS_NEAREST);
+ }
+
+ /**
+ * \brief calculate a single pixel using an EWA filter
+ * \note this method is called for complex
+ * \param result: is a float[4] array to store the result
+ * \param x: the x-coordinate of the pixel to calculate in image space
+ * \param y: the y-coordinate of the pixel to calculate in image space
+ * \param dx:
+ * \param dy:
+ * \param inputBuffers: chunks that can be read by their ReadBufferOperation.
+ */
+ virtual void executePixelFiltered(
+ float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2])
+ {
+ }
+
+ public:
+ inline void readSampled(float result[4], float x, float y, PixelSampler sampler)
+ {
+ executePixelSampled(result, x, y, sampler);
+ }
+ inline void read(float result[4], int x, int y, void *chunkData)
+ {
+ executePixel(result, x, y, chunkData);
+ }
+ inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2])
+ {
+ executePixelFiltered(result, x, y, dx, dy);
+ }
+
+ virtual void *initializeTileData(rcti * /*rect*/)
+ {
+ return 0;
+ }
+ virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/)
+ {
+ }
+
+ virtual ~SocketReader()
+ {
+ }
+
+ virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/)
+ {
+ return 0;
+ }
+
+ inline unsigned int getWidth() const
+ {
+ return this->m_width;
+ }
+ inline unsigned int getHeight() const
+ {
+ return this->m_height;
+ }
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:SocketReader")
#endif
};
diff --git a/source/blender/compositor/intern/COM_WorkPackage.cpp b/source/blender/compositor/intern/COM_WorkPackage.cpp
index 9612ba01e2a..795f8d88d50 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.cpp
+++ b/source/blender/compositor/intern/COM_WorkPackage.cpp
@@ -20,6 +20,6 @@
WorkPackage::WorkPackage(ExecutionGroup *group, unsigned int chunkNumber)
{
- this->m_executionGroup = group;
- this->m_chunkNumber = chunkNumber;
+ this->m_executionGroup = group;
+ this->m_chunkNumber = chunkNumber;
}
diff --git a/source/blender/compositor/intern/COM_WorkPackage.h b/source/blender/compositor/intern/COM_WorkPackage.h
index fc2a4167952..2a0e47301f5 100644
--- a/source/blender/compositor/intern/COM_WorkPackage.h
+++ b/source/blender/compositor/intern/COM_WorkPackage.h
@@ -28,36 +28,43 @@ class ExecutionGroup;
* \see WorkScheduler
*/
class WorkPackage {
-private:
- /**
- * \brief executionGroup with the operations-setup to be evaluated
- */
- ExecutionGroup *m_executionGroup;
+ private:
+ /**
+ * \brief executionGroup with the operations-setup to be evaluated
+ */
+ ExecutionGroup *m_executionGroup;
- /**
- * \brief number of the chunk to be executed
- */
- unsigned int m_chunkNumber;
-public:
- /**
- * constructor
- * \param group: the ExecutionGroup
- * \param chunkNumber: the number of the chunk
- */
- WorkPackage(ExecutionGroup *group, unsigned int chunkNumber);
+ /**
+ * \brief number of the chunk to be executed
+ */
+ unsigned int m_chunkNumber;
- /**
- * \brief get the ExecutionGroup
- */
- ExecutionGroup *getExecutionGroup() const { return this->m_executionGroup; }
+ public:
+ /**
+ * constructor
+ * \param group: the ExecutionGroup
+ * \param chunkNumber: the number of the chunk
+ */
+ WorkPackage(ExecutionGroup *group, unsigned int chunkNumber);
- /**
- * \brief get the number of the chunk
- */
- unsigned int getChunkNumber() const { return this->m_chunkNumber; }
+ /**
+ * \brief get the ExecutionGroup
+ */
+ ExecutionGroup *getExecutionGroup() const
+ {
+ return this->m_executionGroup;
+ }
+
+ /**
+ * \brief get the number of the chunk
+ */
+ unsigned int getChunkNumber() const
+ {
+ return this->m_chunkNumber;
+ }
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkPackage")
#endif
};
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp
index d5efe849f1b..e03a0aa6269 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.cpp
+++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp
@@ -35,18 +35,17 @@
#include "BKE_global.h"
#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
-# ifndef DEBUG /* test this so we dont get warnings in debug builds */
+# ifndef DEBUG /* test this so we dont get warnings in debug builds */
# warning COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD is activated. Use only for debugging.
# endif
#elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- /* do nothing - default */
+/* do nothing - default */
#else
# error COM_CURRENT_THREADING_MODEL No threading model selected
#endif
-
/// \brief list of all CPUDevices. for every hardware thread an instance of CPUDevice is created
-static vector<CPUDevice*> g_cpudevices;
+static vector<CPUDevice *> g_cpudevices;
static ThreadLocal(CPUDevice *) g_thread_device;
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
@@ -56,7 +55,7 @@ static bool g_cpuInitialized = false;
/// \brief all scheduled work for the cpu
static ThreadQueue *g_cpuqueue;
static ThreadQueue *g_gpuqueue;
-#ifdef COM_OPENCL_ENABLED
+# ifdef COM_OPENCL_ENABLED
static cl_context g_context;
static cl_program g_program;
/// \brief list of all OpenCLDevices. for every OpenCL GPU device an instance of OpenCLDevice is created
@@ -64,134 +63,132 @@ static vector<OpenCLDevice *> g_gpudevices;
/// \brief list of all thread for every GPUDevice in cpudevices a thread exists
static ListBase g_gputhreads;
/// \brief all scheduled work for the gpu
-#ifdef COM_OPENCL_ENABLED
+# ifdef COM_OPENCL_ENABLED
static bool g_openclActive = false;
static bool g_openclInitialized = false;
-#endif
-#endif
+# endif
+# endif
#endif
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
void *WorkScheduler::thread_execute_cpu(void *data)
{
- CPUDevice *device = (CPUDevice *)data;
- WorkPackage *work;
- BLI_thread_local_set(g_thread_device, device);
- while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) {
- device->execute(work);
- delete work;
- }
-
- return NULL;
+ CPUDevice *device = (CPUDevice *)data;
+ WorkPackage *work;
+ BLI_thread_local_set(g_thread_device, device);
+ while ((work = (WorkPackage *)BLI_thread_queue_pop(g_cpuqueue))) {
+ device->execute(work);
+ delete work;
+ }
+
+ return NULL;
}
void *WorkScheduler::thread_execute_gpu(void *data)
{
- Device *device = (Device *)data;
- WorkPackage *work;
+ Device *device = (Device *)data;
+ WorkPackage *work;
- while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) {
- device->execute(work);
- delete work;
- }
+ while ((work = (WorkPackage *)BLI_thread_queue_pop(g_gpuqueue))) {
+ device->execute(work);
+ delete work;
+ }
- return NULL;
+ return NULL;
}
#endif
-
-
void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber)
{
- WorkPackage *package = new WorkPackage(group, chunkNumber);
+ WorkPackage *package = new WorkPackage(group, chunkNumber);
#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
- CPUDevice device(0);
- device.execute(package);
- delete package;
+ CPUDevice device(0);
+ device.execute(package);
+ delete package;
#elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
-#ifdef COM_OPENCL_ENABLED
- if (group->isOpenCL() && g_openclActive) {
- BLI_thread_queue_push(g_gpuqueue, package);
- }
- else {
- BLI_thread_queue_push(g_cpuqueue, package);
- }
-#else
- BLI_thread_queue_push(g_cpuqueue, package);
-#endif
+# ifdef COM_OPENCL_ENABLED
+ if (group->isOpenCL() && g_openclActive) {
+ BLI_thread_queue_push(g_gpuqueue, package);
+ }
+ else {
+ BLI_thread_queue_push(g_cpuqueue, package);
+ }
+# else
+ BLI_thread_queue_push(g_cpuqueue, package);
+# endif
#endif
}
void WorkScheduler::start(CompositorContext &context)
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- unsigned int index;
- g_cpuqueue = BLI_thread_queue_init();
- BLI_threadpool_init(&g_cputhreads, thread_execute_cpu, g_cpudevices.size());
- for (index = 0; index < g_cpudevices.size(); index++) {
- Device *device = g_cpudevices[index];
- BLI_threadpool_insert(&g_cputhreads, device);
- }
-#ifdef COM_OPENCL_ENABLED
- if (context.getHasActiveOpenCLDevices()) {
- g_gpuqueue = BLI_thread_queue_init();
- BLI_threadpool_init(&g_gputhreads, thread_execute_gpu, g_gpudevices.size());
- for (index = 0; index < g_gpudevices.size(); index++) {
- Device *device = g_gpudevices[index];
- BLI_threadpool_insert(&g_gputhreads, device);
- }
- g_openclActive = true;
- }
- else {
- g_openclActive = false;
- }
-#endif
+ unsigned int index;
+ g_cpuqueue = BLI_thread_queue_init();
+ BLI_threadpool_init(&g_cputhreads, thread_execute_cpu, g_cpudevices.size());
+ for (index = 0; index < g_cpudevices.size(); index++) {
+ Device *device = g_cpudevices[index];
+ BLI_threadpool_insert(&g_cputhreads, device);
+ }
+# ifdef COM_OPENCL_ENABLED
+ if (context.getHasActiveOpenCLDevices()) {
+ g_gpuqueue = BLI_thread_queue_init();
+ BLI_threadpool_init(&g_gputhreads, thread_execute_gpu, g_gpudevices.size());
+ for (index = 0; index < g_gpudevices.size(); index++) {
+ Device *device = g_gpudevices[index];
+ BLI_threadpool_insert(&g_gputhreads, device);
+ }
+ g_openclActive = true;
+ }
+ else {
+ g_openclActive = false;
+ }
+# endif
#endif
}
void WorkScheduler::finish()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
-#ifdef COM_OPENCL_ENABLED
- if (g_openclActive) {
- BLI_thread_queue_wait_finish(g_gpuqueue);
- BLI_thread_queue_wait_finish(g_cpuqueue);
- }
- else {
- BLI_thread_queue_wait_finish(g_cpuqueue);
- }
-#else
- BLI_thread_queue_wait_finish(cpuqueue);
-#endif
+# ifdef COM_OPENCL_ENABLED
+ if (g_openclActive) {
+ BLI_thread_queue_wait_finish(g_gpuqueue);
+ BLI_thread_queue_wait_finish(g_cpuqueue);
+ }
+ else {
+ BLI_thread_queue_wait_finish(g_cpuqueue);
+ }
+# else
+ BLI_thread_queue_wait_finish(cpuqueue);
+# endif
#endif
}
void WorkScheduler::stop()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- BLI_thread_queue_nowait(g_cpuqueue);
- BLI_threadpool_end(&g_cputhreads);
- BLI_thread_queue_free(g_cpuqueue);
- g_cpuqueue = NULL;
-#ifdef COM_OPENCL_ENABLED
- if (g_openclActive) {
- BLI_thread_queue_nowait(g_gpuqueue);
- BLI_threadpool_end(&g_gputhreads);
- BLI_thread_queue_free(g_gpuqueue);
- g_gpuqueue = NULL;
- }
-#endif
+ BLI_thread_queue_nowait(g_cpuqueue);
+ BLI_threadpool_end(&g_cputhreads);
+ BLI_thread_queue_free(g_cpuqueue);
+ g_cpuqueue = NULL;
+# ifdef COM_OPENCL_ENABLED
+ if (g_openclActive) {
+ BLI_thread_queue_nowait(g_gpuqueue);
+ BLI_threadpool_end(&g_gputhreads);
+ BLI_thread_queue_free(g_gpuqueue);
+ g_gpuqueue = NULL;
+ }
+# endif
#endif
}
bool WorkScheduler::hasGPUDevices()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
-#ifdef COM_OPENCL_ENABLED
- return g_gpudevices.size() > 0;
-#else
- return 0;
-#endif
+# ifdef COM_OPENCL_ENABLED
+ return g_gpudevices.size() > 0;
+# else
+ return 0;
+# endif
#else
- return 0;
+ return 0;
#endif
}
@@ -201,153 +198,172 @@ static void CL_CALLBACK clContextError(const char *errinfo,
size_t /*cb*/,
void * /*user_data*/)
{
- printf("OPENCL error: %s\n", errinfo);
+ printf("OPENCL error: %s\n", errinfo);
}
#endif
void WorkScheduler::initialize(bool use_opencl, int num_cpu_threads)
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- /* deinitialize if number of threads doesn't match */
- if (g_cpudevices.size() != num_cpu_threads) {
- Device *device;
-
- while (g_cpudevices.size() > 0) {
- device = g_cpudevices.back();
- g_cpudevices.pop_back();
- device->deinitialize();
- delete device;
- }
- if (g_cpuInitialized) {
- BLI_thread_local_delete(g_thread_device);
- }
- g_cpuInitialized = false;
- }
-
- /* initialize CPU threads */
- if (!g_cpuInitialized) {
- for (int index = 0; index < num_cpu_threads; index++) {
- CPUDevice *device = new CPUDevice(index);
- device->initialize();
- g_cpudevices.push_back(device);
- }
- BLI_thread_local_create(g_thread_device);
- g_cpuInitialized = true;
- }
-
-#ifdef COM_OPENCL_ENABLED
- /* deinitialize OpenCL GPU's */
- if (use_opencl && !g_openclInitialized) {
- g_context = NULL;
- g_program = NULL;
-
- if (clewInit() != CLEW_SUCCESS) /* this will check for errors and skip if already initialized */
- return;
-
- if (clCreateContextFromType) {
- cl_uint numberOfPlatforms = 0;
- cl_int error;
- error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
- if (error == -1001) { } /* GPU not supported */
- else if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- if (G.f & G_DEBUG) printf("%u number of platforms\n", numberOfPlatforms);
- cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(sizeof(cl_platform_id) * numberOfPlatforms, __func__);
- error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
- unsigned int indexPlatform;
- for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
- cl_platform_id platform = platforms[indexPlatform];
- cl_uint numberOfDevices = 0;
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
- if (numberOfDevices <= 0)
- continue;
-
- cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(sizeof(cl_device_id) * numberOfDevices, __func__);
- clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0);
-
- g_context = clCreateContext(NULL, numberOfDevices, cldevices, clContextError, NULL, &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, NULL};
- g_program = clCreateProgramWithSource(g_context, 1, cl_str, 0, &error);
- error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0);
- if (error != CL_SUCCESS) {
- cl_int error2;
- size_t ret_val_size = 0;
- printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
- error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
- if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__);
- error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
- if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- build_log[ret_val_size] = '\0';
- printf("%s", build_log);
- MEM_freeN(build_log);
- }
- else {
- unsigned int indexDevices;
- for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) {
- cl_device_id device = cldevices[indexDevices];
- cl_int vendorID = 0;
- cl_int error2 = clGetDeviceInfo(device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL);
- if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error2, clewErrorString(error2)); }
- OpenCLDevice *clDevice = new OpenCLDevice(g_context, device, g_program, vendorID);
- clDevice->initialize();
- g_gpudevices.push_back(clDevice);
- }
- }
- MEM_freeN(cldevices);
- }
- MEM_freeN(platforms);
- }
-
- g_openclInitialized = true;
- }
-#endif
+ /* deinitialize if number of threads doesn't match */
+ if (g_cpudevices.size() != num_cpu_threads) {
+ Device *device;
+
+ while (g_cpudevices.size() > 0) {
+ device = g_cpudevices.back();
+ g_cpudevices.pop_back();
+ device->deinitialize();
+ delete device;
+ }
+ if (g_cpuInitialized) {
+ BLI_thread_local_delete(g_thread_device);
+ }
+ g_cpuInitialized = false;
+ }
+
+ /* initialize CPU threads */
+ if (!g_cpuInitialized) {
+ for (int index = 0; index < num_cpu_threads; index++) {
+ CPUDevice *device = new CPUDevice(index);
+ device->initialize();
+ g_cpudevices.push_back(device);
+ }
+ BLI_thread_local_create(g_thread_device);
+ g_cpuInitialized = true;
+ }
+
+# ifdef COM_OPENCL_ENABLED
+ /* deinitialize OpenCL GPU's */
+ if (use_opencl && !g_openclInitialized) {
+ g_context = NULL;
+ g_program = NULL;
+
+ if (clewInit() !=
+ CLEW_SUCCESS) /* this will check for errors and skip if already initialized */
+ return;
+
+ if (clCreateContextFromType) {
+ cl_uint numberOfPlatforms = 0;
+ cl_int error;
+ error = clGetPlatformIDs(0, 0, &numberOfPlatforms);
+ if (error == -1001) {
+ } /* GPU not supported */
+ else if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ if (G.f & G_DEBUG)
+ printf("%u number of platforms\n", numberOfPlatforms);
+ cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
+ sizeof(cl_platform_id) * numberOfPlatforms, __func__);
+ error = clGetPlatformIDs(numberOfPlatforms, platforms, 0);
+ unsigned int indexPlatform;
+ for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
+ cl_platform_id platform = platforms[indexPlatform];
+ cl_uint numberOfDevices = 0;
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, 0, &numberOfDevices);
+ if (numberOfDevices <= 0)
+ continue;
+
+ cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
+ sizeof(cl_device_id) * numberOfDevices, __func__);
+ clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, 0);
+
+ g_context = clCreateContext(
+ NULL, numberOfDevices, cldevices, clContextError, NULL, &error);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, NULL};
+ g_program = clCreateProgramWithSource(g_context, 1, cl_str, 0, &error);
+ error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0);
+ if (error != CL_SUCCESS) {
+ cl_int error2;
+ size_t ret_val_size = 0;
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ error2 = clGetProgramBuildInfo(
+ g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
+ if (error2 != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__);
+ error2 = clGetProgramBuildInfo(
+ g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
+ if (error2 != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ build_log[ret_val_size] = '\0';
+ printf("%s", build_log);
+ MEM_freeN(build_log);
+ }
+ else {
+ unsigned int indexDevices;
+ for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) {
+ cl_device_id device = cldevices[indexDevices];
+ cl_int vendorID = 0;
+ cl_int error2 = clGetDeviceInfo(
+ device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, NULL);
+ if (error2 != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error2, clewErrorString(error2));
+ }
+ OpenCLDevice *clDevice = new OpenCLDevice(g_context, device, g_program, vendorID);
+ clDevice->initialize();
+ g_gpudevices.push_back(clDevice);
+ }
+ }
+ MEM_freeN(cldevices);
+ }
+ MEM_freeN(platforms);
+ }
+
+ g_openclInitialized = true;
+ }
+# endif
#endif
}
void WorkScheduler::deinitialize()
{
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- /* deinitialize CPU threads */
- if (g_cpuInitialized) {
- Device *device;
- while (g_cpudevices.size() > 0) {
- device = g_cpudevices.back();
- g_cpudevices.pop_back();
- device->deinitialize();
- delete device;
- }
- BLI_thread_local_delete(g_thread_device);
- g_cpuInitialized = false;
- }
-
-#ifdef COM_OPENCL_ENABLED
- /* deinitialize OpenCL GPU's */
- if (g_openclInitialized) {
- Device *device;
- while (g_gpudevices.size() > 0) {
- device = g_gpudevices.back();
- g_gpudevices.pop_back();
- device->deinitialize();
- delete device;
- }
- if (g_program) {
- clReleaseProgram(g_program);
- g_program = NULL;
- }
- if (g_context) {
- clReleaseContext(g_context);
- g_context = NULL;
- }
-
- g_openclInitialized = false;
- }
-#endif
+ /* deinitialize CPU threads */
+ if (g_cpuInitialized) {
+ Device *device;
+ while (g_cpudevices.size() > 0) {
+ device = g_cpudevices.back();
+ g_cpudevices.pop_back();
+ device->deinitialize();
+ delete device;
+ }
+ BLI_thread_local_delete(g_thread_device);
+ g_cpuInitialized = false;
+ }
+
+# ifdef COM_OPENCL_ENABLED
+ /* deinitialize OpenCL GPU's */
+ if (g_openclInitialized) {
+ Device *device;
+ while (g_gpudevices.size() > 0) {
+ device = g_gpudevices.back();
+ g_gpudevices.pop_back();
+ device->deinitialize();
+ delete device;
+ }
+ if (g_program) {
+ clReleaseProgram(g_program);
+ g_program = NULL;
+ }
+ if (g_context) {
+ clReleaseContext(g_context);
+ g_context = NULL;
+ }
+
+ g_openclInitialized = false;
+ }
+# endif
#endif
}
int WorkScheduler::current_thread_id()
{
- CPUDevice *device = (CPUDevice *)BLI_thread_local_get(g_thread_device);
- return device->thread_id();
+ CPUDevice *device = (CPUDevice *)BLI_thread_local_get(g_thread_device);
+ return device->thread_id();
}
diff --git a/source/blender/compositor/intern/COM_WorkScheduler.h b/source/blender/compositor/intern/COM_WorkScheduler.h
index adac501148e..2b523272123 100644
--- a/source/blender/compositor/intern/COM_WorkScheduler.h
+++ b/source/blender/compositor/intern/COM_WorkScheduler.h
@@ -21,7 +21,7 @@
#include "COM_ExecutionGroup.h"
extern "C" {
-# include "BLI_threads.h"
+#include "BLI_threads.h"
}
#include "COM_WorkPackage.h"
#include "COM_defines.h"
@@ -33,86 +33,86 @@ extern "C" {
class WorkScheduler {
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
- /**
- * \brief are we being stopped.
- */
- static bool isStopping();
+ /**
+ * \brief are we being stopped.
+ */
+ static bool isStopping();
- /**
- * \brief main thread loop for cpudevices
- * inside this loop new work is queried and being executed
- */
- static void *thread_execute_cpu(void *data);
+ /**
+ * \brief main thread loop for cpudevices
+ * inside this loop new work is queried and being executed
+ */
+ static void *thread_execute_cpu(void *data);
- /**
- * \brief main thread loop for gpudevices
- * inside this loop new work is queried and being executed
- */
- static void *thread_execute_gpu(void *data);
+ /**
+ * \brief main thread loop for gpudevices
+ * inside this loop new work is queried and being executed
+ */
+ static void *thread_execute_gpu(void *data);
#endif
-public:
- /**
- * \brief schedule a chunk of a group to be calculated.
- * An execution group schedules a chunk in the WorkScheduler
- * when ExecutionGroup.isOpenCL is set the work will be handled by a OpenCLDevice
- * otherwise the work is scheduled for an CPUDevice
- * \see ExecutionGroup.execute
- * \param group: the execution group
- * \param chunkNumber: the number of the chunk in the group to be executed
- */
- static void schedule(ExecutionGroup *group, int chunkNumber);
+ public:
+ /**
+ * \brief schedule a chunk of a group to be calculated.
+ * An execution group schedules a chunk in the WorkScheduler
+ * when ExecutionGroup.isOpenCL is set the work will be handled by a OpenCLDevice
+ * otherwise the work is scheduled for an CPUDevice
+ * \see ExecutionGroup.execute
+ * \param group: the execution group
+ * \param chunkNumber: the number of the chunk in the group to be executed
+ */
+ static void schedule(ExecutionGroup *group, int chunkNumber);
- /**
- * \brief initialize the WorkScheduler
- *
- * during initialization the mutexes are initialized.
- * there are two mutexes (for every device type one)
- * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
- * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
- * these devices are stored in a separate list (cpudevices & gpudevices)
- *
- * This function can be called multiple times to lazily initialize OpenCL.
- */
- static void initialize(bool use_opencl, int num_cpu_threads);
+ /**
+ * \brief initialize the WorkScheduler
+ *
+ * during initialization the mutexes are initialized.
+ * there are two mutexes (for every device type one)
+ * After mutex initialization the system is queried in order to count the number of CPUDevices and GPUDevices to be created.
+ * For every hardware thread a CPUDevice and for every OpenCL GPU device a OpenCLDevice is created.
+ * these devices are stored in a separate list (cpudevices & gpudevices)
+ *
+ * This function can be called multiple times to lazily initialize OpenCL.
+ */
+ static void initialize(bool use_opencl, int num_cpu_threads);
- /**
- * \brief deinitialize the WorkScheduler
- * free all allocated resources
- */
- static void deinitialize();
+ /**
+ * \brief deinitialize the WorkScheduler
+ * free all allocated resources
+ */
+ static void deinitialize();
- /**
- * \brief Start the execution
- * this methods will start the WorkScheduler. Inside this method all threads are initialized.
- * for every device a thread is created.
- * \see initialize Initialization and query of the number of devices
- */
- static void start(CompositorContext &context);
+ /**
+ * \brief Start the execution
+ * this methods will start the WorkScheduler. Inside this method all threads are initialized.
+ * for every device a thread is created.
+ * \see initialize Initialization and query of the number of devices
+ */
+ static void start(CompositorContext &context);
- /**
- * \brief stop the execution
- * All created thread by the start method are destroyed.
- * \see start
- */
- static void stop();
+ /**
+ * \brief stop the execution
+ * All created thread by the start method are destroyed.
+ * \see start
+ */
+ static void stop();
- /**
- * \brief wait for all work to be completed.
- */
- static void finish();
+ /**
+ * \brief wait for all work to be completed.
+ */
+ static void finish();
- /**
- * \brief Are there OpenCL capable GPU devices initialized?
- * the result of this method is stored in the CompositorContext
- * A node can generate a different operation tree when OpenCLDevices exists.
- * \see CompositorContext.getHasActiveOpenCLDevices
- */
- static bool hasGPUDevices();
+ /**
+ * \brief Are there OpenCL capable GPU devices initialized?
+ * the result of this method is stored in the CompositorContext
+ * A node can generate a different operation tree when OpenCLDevices exists.
+ * \see CompositorContext.getHasActiveOpenCLDevices
+ */
+ static bool hasGPUDevices();
- static int current_thread_id();
+ static int current_thread_id();
#ifdef WITH_CXX_GUARDEDALLOC
- MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkScheduler")
+ MEM_CXX_CLASS_ALLOC_FUNCS("COM:WorkScheduler")
#endif
};
diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp
index 04fb550cf4b..50b578a9bc7 100644
--- a/source/blender/compositor/intern/COM_compositor.cpp
+++ b/source/blender/compositor/intern/COM_compositor.cpp
@@ -16,7 +16,6 @@
* Copyright 2011, Blender Foundation.
*/
-
extern "C" {
#include "BKE_node.h"
#include "BLI_threads.h"
@@ -35,85 +34,89 @@ extern "C" {
static ThreadMutex s_compositorMutex;
static bool is_compositorMutex_init = false;
-void COM_execute(RenderData *rd, Scene *scene, bNodeTree *editingtree, int rendering,
+void COM_execute(RenderData *rd,
+ Scene *scene,
+ bNodeTree *editingtree,
+ int rendering,
const ColorManagedViewSettings *viewSettings,
const ColorManagedDisplaySettings *displaySettings,
const char *viewName)
{
- /* initialize mutex, TODO this mutex init is actually not thread safe and
- * should be done somewhere as part of blender startup, all the other
- * initializations can be done lazily */
- if (is_compositorMutex_init == false) {
- BLI_mutex_init(&s_compositorMutex);
- is_compositorMutex_init = true;
- }
-
- BLI_mutex_lock(&s_compositorMutex);
-
- if (editingtree->test_break(editingtree->tbh)) {
- // during editing multiple calls to this method can be triggered.
- // make sure one the last one will be doing the work.
- BLI_mutex_unlock(&s_compositorMutex);
- return;
- }
-
- /* Make sure node tree has previews.
- * Don't create previews in advance, this is done when adding preview operations.
- * Reserved preview size is determined by render output for now.
- *
- * We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid
- * insane preview resolution, which might even overflow preview dimensions.
- */
- const float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
- int preview_width, preview_height;
- if (aspect < 1.0f) {
- preview_width = COM_PREVIEW_SIZE;
- preview_height = (int)(COM_PREVIEW_SIZE * aspect);
- }
- else {
- preview_width = (int)(COM_PREVIEW_SIZE / aspect);
- preview_height = COM_PREVIEW_SIZE;
- }
- BKE_node_preview_init_tree(editingtree, preview_width, preview_height, false);
-
- /* initialize workscheduler, will check if already done. TODO deinitialize somewhere */
- bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0;
- WorkScheduler::initialize(use_opencl, BKE_render_num_threads(rd));
-
- /* set progress bar to 0% and status to init compositing */
- editingtree->progress(editingtree->prh, 0.0);
- editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing"));
-
- bool twopass = (editingtree->flag & NTREE_TWO_PASS) && !rendering;
- /* initialize execution system */
- if (twopass) {
- ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName);
- system->execute();
- delete system;
-
- if (editingtree->test_break(editingtree->tbh)) {
- // during editing multiple calls to this method can be triggered.
- // make sure one the last one will be doing the work.
- BLI_mutex_unlock(&s_compositorMutex);
- return;
- }
- }
-
- ExecutionSystem *system = new ExecutionSystem(rd, scene, editingtree, rendering, false,
- viewSettings, displaySettings, viewName);
- system->execute();
- delete system;
-
- BLI_mutex_unlock(&s_compositorMutex);
+ /* initialize mutex, TODO this mutex init is actually not thread safe and
+ * should be done somewhere as part of blender startup, all the other
+ * initializations can be done lazily */
+ if (is_compositorMutex_init == false) {
+ BLI_mutex_init(&s_compositorMutex);
+ is_compositorMutex_init = true;
+ }
+
+ BLI_mutex_lock(&s_compositorMutex);
+
+ if (editingtree->test_break(editingtree->tbh)) {
+ // during editing multiple calls to this method can be triggered.
+ // make sure one the last one will be doing the work.
+ BLI_mutex_unlock(&s_compositorMutex);
+ return;
+ }
+
+ /* Make sure node tree has previews.
+ * Don't create previews in advance, this is done when adding preview operations.
+ * Reserved preview size is determined by render output for now.
+ *
+ * We fit the aspect into COM_PREVIEW_SIZE x COM_PREVIEW_SIZE image to avoid
+ * insane preview resolution, which might even overflow preview dimensions.
+ */
+ const float aspect = rd->xsch > 0 ? (float)rd->ysch / (float)rd->xsch : 1.0f;
+ int preview_width, preview_height;
+ if (aspect < 1.0f) {
+ preview_width = COM_PREVIEW_SIZE;
+ preview_height = (int)(COM_PREVIEW_SIZE * aspect);
+ }
+ else {
+ preview_width = (int)(COM_PREVIEW_SIZE / aspect);
+ preview_height = COM_PREVIEW_SIZE;
+ }
+ BKE_node_preview_init_tree(editingtree, preview_width, preview_height, false);
+
+ /* initialize workscheduler, will check if already done. TODO deinitialize somewhere */
+ bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL) != 0;
+ WorkScheduler::initialize(use_opencl, BKE_render_num_threads(rd));
+
+ /* set progress bar to 0% and status to init compositing */
+ editingtree->progress(editingtree->prh, 0.0);
+ editingtree->stats_draw(editingtree->sdh, IFACE_("Compositing"));
+
+ bool twopass = (editingtree->flag & NTREE_TWO_PASS) && !rendering;
+ /* initialize execution system */
+ if (twopass) {
+ ExecutionSystem *system = new ExecutionSystem(
+ rd, scene, editingtree, rendering, twopass, viewSettings, displaySettings, viewName);
+ system->execute();
+ delete system;
+
+ if (editingtree->test_break(editingtree->tbh)) {
+ // during editing multiple calls to this method can be triggered.
+ // make sure one the last one will be doing the work.
+ BLI_mutex_unlock(&s_compositorMutex);
+ return;
+ }
+ }
+
+ ExecutionSystem *system = new ExecutionSystem(
+ rd, scene, editingtree, rendering, false, viewSettings, displaySettings, viewName);
+ system->execute();
+ delete system;
+
+ BLI_mutex_unlock(&s_compositorMutex);
}
void COM_deinitialize()
{
- if (is_compositorMutex_init) {
- BLI_mutex_lock(&s_compositorMutex);
- WorkScheduler::deinitialize();
- is_compositorMutex_init = false;
- BLI_mutex_unlock(&s_compositorMutex);
- BLI_mutex_end(&s_compositorMutex);
- }
+ if (is_compositorMutex_init) {
+ BLI_mutex_lock(&s_compositorMutex);
+ WorkScheduler::deinitialize();
+ is_compositorMutex_init = false;
+ BLI_mutex_unlock(&s_compositorMutex);
+ BLI_mutex_end(&s_compositorMutex);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
index ba370e38fa6..db05043a925 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp
@@ -24,43 +24,43 @@
#include "COM_AlphaOverPremultiplyOperation.h"
#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
+#include "DNA_material_types.h" // the ramp types
-void AlphaOverNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void AlphaOverNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *color1Socket = this->getInputSocket(1);
- NodeInput *color2Socket = this->getInputSocket(2);
- bNode *editorNode = this->getbNode();
+ 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;
+ 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();
+ }
- }
- 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);
+ }
- 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));
+ 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.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h
index b064d257c81..27e868e6f25 100644
--- a/source/blender/compositor/nodes/COM_AlphaOverNode.h
+++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h
@@ -26,9 +26,11 @@
* \ingroup Node
*/
class AlphaOverNode : public Node {
-public:
- AlphaOverNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ AlphaOverNode(bNode *editorNode) : Node(editorNode)
+ {
+ }
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
index 6a73b043b0e..453b1180467 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -23,18 +23,19 @@
BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BilateralBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
index 6d0120780e1..abed491c891 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BilateralBlurNode : public Node {
-public:
- BilateralBlurNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BilateralBlurNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index 92ab468c5c8..a43441a2b13 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -31,139 +31,140 @@
BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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 = NULL, *output_operation = NULL;
-
- 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());
- }
+ 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 = NULL, *output_operation = NULL;
+
+ 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.h b/source/blender/compositor/nodes/COM_BlurNode.h
index a8931f42b42..f0d6cad320e 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.h
+++ b/source/blender/compositor/nodes/COM_BlurNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BlurNode : public Node {
-public:
- BlurNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BlurNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
index c20ca9181d1..56b5d35cbf5 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -27,50 +27,51 @@
BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BokehBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void BokehBlurNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *b_node = this->getbNode();
+ bNode *b_node = this->getbNode();
- NodeInput *inputSizeSocket = this->getInputSocket(2);
+ NodeInput *inputSizeSocket = this->getInputSocket(2);
- bool connectedSizeSocket = inputSizeSocket->isLinked();
- const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
+ 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);
+ 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));
+ 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));
+ 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));
+ // 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());
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
- if (!connectedSizeSocket) {
- operation->setSize(this->getInputSocket(2)->getEditorValueFloat());
- }
- }
+ if (!connectedSizeSocket) {
+ operation->setSize(this->getInputSocket(2)->getEditorValueFloat());
+ }
+ }
}
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h
index 0edb48accf0..e2f728fb30b 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.h
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BokehBlurNode : public Node {
-public:
- BokehBlurNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BokehBlurNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
index f8527144cc1..87fe4979c1d 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp
@@ -22,16 +22,17 @@
BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BokehImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void BokehImageNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- BokehImageOperation *operation = new BokehImageOperation();
- operation->setData((NodeBokehImage *)this->getbNode()->storage);
+ BokehImageOperation *operation = new BokehImageOperation();
+ operation->setData((NodeBokehImage *)this->getbNode()->storage);
- converter.addOperation(operation);
- converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
+ converter.addOperation(operation);
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
- converter.addPreview(operation->getOutputSocket(0));
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h
index d84a31a1bc2..3e78e8d5185 100644
--- a/source/blender/compositor/nodes/COM_BokehImageNode.h
+++ b/source/blender/compositor/nodes/COM_BokehImageNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BokehImageNode : public Node {
-public:
- BokehImageNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BokehImageNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
index a161440cba4..98b4811743f 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp
@@ -25,46 +25,47 @@
BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BoxMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void BoxMaskNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
+ 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);
+ 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);
+ 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();
- ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
+ /* Scale that image up to render resolution */
+ const RenderData *rd = context.getRenderData();
+ ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
- scaleOperation->setIsAspect(false);
- scaleOperation->setIsCrop(false);
- scaleOperation->setOffset(0.0f, 0.0f);
- scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
- scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
- scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
- converter.addOperation(scaleOperation);
+ scaleOperation->setIsAspect(false);
+ scaleOperation->setIsCrop(false);
+ scaleOperation->setOffset(0.0f, 0.0f);
+ scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
+ scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
+ 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.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));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h
index 4ba0aac98b6..0d39014bbd0 100644
--- a/source/blender/compositor/nodes/COM_BoxMaskNode.h
+++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BoxMaskNode : public Node {
-public:
- BoxMaskNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BoxMaskNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
index 26e6106051a..fcd2a6de1f4 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.cpp
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp
@@ -22,18 +22,19 @@
BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void BrightnessNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_BrightnessNode.h
index 787c735ac7a..8529fc17d9c 100644
--- a/source/blender/compositor/nodes/COM_BrightnessNode.h
+++ b/source/blender/compositor/nodes/COM_BrightnessNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class BrightnessNode : public Node {
-public:
- BrightnessNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ BrightnessNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index e7e575b3276..d320a6645e1 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -24,71 +24,72 @@
ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ChannelMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ChannelMatteNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *node = this->getbNode();
+ bNode *node = this->getbNode();
- NodeInput *inputSocketImage = this->getInputSocket(0);
- NodeOutput *outputSocketImage = this->getOutputSocket(0);
- NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+ NodeInput *inputSocketImage = this->getInputSocket(0);
+ NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ NodeOutput *outputSocketMatte = this->getOutputSocket(1);
- NodeOperation *convert = NULL, *inv_convert = NULL;
- /* 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;
- }
+ NodeOperation *convert = NULL, *inv_convert = NULL;
+ /* 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);
+ ChannelMatteOperation *operation = new ChannelMatteOperation();
+ /* pass the ui properties to the operation */
+ operation->setSettings((NodeChroma *)node->storage, node->custom2);
+ converter.addOperation(operation);
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- converter.addOperation(operationAlpha);
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ converter.addOperation(operationAlpha);
- if (convert != NULL) {
- converter.addOperation(convert);
+ if (convert != NULL) {
+ 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.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));
+ converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
- if (inv_convert != NULL) {
- 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());
- }
+ if (inv_convert != NULL) {
+ 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.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
index 94d01e40a72..e6cd8bf6f0d 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ChannelMatteNode : public Node {
-public:
- ChannelMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ChannelMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ChannelMatteNODE_H */
+#endif /* COM_ChannelMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
index 5d758628a24..75d161d7d4d 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp
@@ -24,41 +24,42 @@
ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ChromaMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ChromaMatteNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *editorsnode = getbNode();
+ bNode *editorsnode = getbNode();
- NodeInput *inputSocketImage = this->getInputSocket(0);
- NodeInput *inputSocketKey = this->getInputSocket(1);
- NodeOutput *outputSocketImage = this->getOutputSocket(0);
- NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+ 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);
+ 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);
+ ChromaMatteOperation *operation = new ChromaMatteOperation();
+ operation->setSettings((NodeChroma *)editorsnode->storage);
+ converter.addOperation(operation);
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- converter.addOperation(operationAlpha);
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ 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, 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.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
- converter.addPreview(operationAlpha->getOutputSocket());
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
index b86b1aa734c..cfb6f23ebcb 100644
--- a/source/blender/compositor/nodes/COM_ChromaMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ChromaMatteNode : public Node {
-public:
- ChromaMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ChromaMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ChromaMatteNODE_H */
+#endif /* COM_ChromaMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
index 4fab93c07a1..64503ca306b 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp
@@ -25,48 +25,49 @@
ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorBalanceNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ColorBalanceNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *node = this->getbNode();
- NodeColorBalance *n = (NodeColorBalance *)node->storage;
+ bNode *node = this->getbNode();
+ NodeColorBalance *n = (NodeColorBalance *)node->storage;
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeInput *inputImageSocket = this->getInputSocket(1);
- NodeOutput *outputSocket = this->getOutputSocket(0);
+ 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();
+ 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;
- }
+ 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();
+ 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);
+ 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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
index a5e48ed8e0f..482b34e7809 100644
--- a/source/blender/compositor/nodes/COM_ColorBalanceNode.h
+++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorBalanceNode : public Node {
-public:
- ColorBalanceNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorBalanceNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ColorBalanceNODE_H */
+#endif /* COM_ColorBalanceNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
index 6881a047fc5..3c2bf0aad07 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp
@@ -22,21 +22,22 @@
ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorCorrectionNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ColorCorrectionNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *editorNode = getbNode();
+ 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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
index 9f3f1e3a84e..0275106095e 100644
--- a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorCorrectionNode : public Node {
-public:
- ColorCorrectionNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorCorrectionNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
index 1e77f254c8e..e1888f3f0bc 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp
@@ -22,35 +22,36 @@
ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorCurveNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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.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.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());
- }
+ 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.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h
index fcf3c56698e..2a529e5713e 100644
--- a/source/blender/compositor/nodes/COM_ColorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorCurveNode : public Node {
-public:
- ColorCurveNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorCurveNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
index e9b9280f5d7..f5cb84975e9 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp
@@ -24,39 +24,40 @@
ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ColorMatteNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *editorsnode = getbNode();
+ bNode *editorsnode = getbNode();
- NodeInput *inputSocketImage = this->getInputSocket(0);
- NodeInput *inputSocketKey = this->getInputSocket(1);
- NodeOutput *outputSocketImage = this->getOutputSocket(0);
- NodeOutput *outputSocketMatte = this->getOutputSocket(1);
+ 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);
+ 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);
+ ColorMatteOperation *operation = new ColorMatteOperation();
+ operation->setSettings((NodeChroma *)editorsnode->storage);
+ converter.addOperation(operation);
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- converter.addOperation(operationAlpha);
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ 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, 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.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
+ converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
- converter.addPreview(operationAlpha->getOutputSocket());
+ converter.addPreview(operationAlpha->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h
index 39f142f5fe8..1f02a091307 100644
--- a/source/blender/compositor/nodes/COM_ColorMatteNode.h
+++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorMatteNode : public Node {
-public:
- ColorMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ColorMatteNODE_H */
+#endif /* COM_ColorMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp
index 45909515101..6bc700e3aa1 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorNode.cpp
@@ -22,17 +22,18 @@
ColorNode::ColorNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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());
+ converter.mapOutputSocket(output, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h
index d10a150cbf0..5c7580a9ec9 100644
--- a/source/blender/compositor/nodes/COM_ColorNode.h
+++ b/source/blender/compositor/nodes/COM_ColorNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorNode : public Node {
-public:
- ColorNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
index 3f9b7095103..0745f32218d 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp
@@ -25,27 +25,28 @@
ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorRampNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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();
+ 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);
+ ColorRampOperation *operation = new ColorRampOperation();
+ operation->setColorBand((ColorBand *)editorNode->storage);
+ converter.addOperation(operation);
- converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
- converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
- SeparateChannelOperation *operation2 = new SeparateChannelOperation();
- operation2->setChannel(3);
- converter.addOperation(operation2);
+ SeparateChannelOperation *operation2 = new SeparateChannelOperation();
+ operation2->setChannel(3);
+ converter.addOperation(operation2);
- converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0));
- converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket());
+ converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0));
+ converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h
index fe4af608f2c..3f7a188e549 100644
--- a/source/blender/compositor/nodes/COM_ColorRampNode.h
+++ b/source/blender/compositor/nodes/COM_ColorRampNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorRampNode : public Node {
-public:
- ColorRampNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorRampNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ColorRampNODE_H */
+#endif /* COM_ColorRampNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
index 7253c5b4ca5..d1a3099e998 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp
@@ -22,25 +22,26 @@
ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorSpillNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ColorSpillNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *editorsnode = getbNode();
+ bNode *editorsnode = getbNode();
- NodeInput *inputSocketImage = this->getInputSocket(0);
- NodeInput *inputSocketFac = this->getInputSocket(1);
- NodeOutput *outputSocketImage = this->getOutputSocket(0);
+ 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);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h
index fee2d8fa9e3..4678d1dd7b1 100644
--- a/source/blender/compositor/nodes/COM_ColorSpillNode.h
+++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ColorSpillNode : public Node {
-public:
- ColorSpillNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorSpillNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_ColorSpillNODE_H */
+#endif /* COM_ColorSpillNODE_H */
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
index 371a4085481..4115bad5d3f 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp
@@ -23,17 +23,18 @@
ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ColorToBWNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ColorToBWNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *colorSocket = this->getInputSocket(0);
- NodeOutput *valueSocket = this->getOutputSocket(0);
+ NodeInput *colorSocket = this->getInputSocket(0);
+ NodeOutput *valueSocket = this->getOutputSocket(0);
- ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
- converter.addOperation(convertProg);
+ ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
+ converter.addOperation(convertProg);
- converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
- converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
+ converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
+ converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h
index 179dda5092f..d811cab8019 100644
--- a/source/blender/compositor/nodes/COM_ColorToBWNode.h
+++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class ColorToBWNode : public Node {
-public:
- ColorToBWNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ColorToBWNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.cpp b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
index 4c5cdbc2d9c..2f9b14db6af 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.cpp
@@ -20,72 +20,70 @@
#include "COM_ConvertOperation.h"
-
-CombineColorNode::CombineColorNode(bNode *editorNode) :
- Node(editorNode)
+CombineColorNode::CombineColorNode(bNode *editorNode) : Node(editorNode)
{
}
-void CombineColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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);
+ 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));
+ 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);
+ 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());
- }
+ 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
+NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return NULL; /* no conversion needed */
+ return NULL; /* no conversion needed */
}
-NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return new ConvertHSVToRGBOperation();
+ return new ConvertHSVToRGBOperation();
}
-NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext & /*context*/) const
{
- ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
- bNode *editorNode = this->getbNode();
- operation->setMode(editorNode->custom1);
- return operation;
+ ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
+ bNode *editorNode = this->getbNode();
+ operation->setMode(editorNode->custom1);
+ return operation;
}
-NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return new ConvertYUVToRGBOperation();
+ return new ConvertYUVToRGBOperation();
}
diff --git a/source/blender/compositor/nodes/COM_CombineColorNode.h b/source/blender/compositor/nodes/COM_CombineColorNode.h
index 870a13b7492..203a8e84306 100644
--- a/source/blender/compositor/nodes/COM_CombineColorNode.h
+++ b/source/blender/compositor/nodes/COM_CombineColorNode.h
@@ -22,48 +22,48 @@
#include "COM_Node.h"
class CombineColorNode : public Node {
-public:
- CombineColorNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ CombineColorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-protected:
- virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
+ protected:
+ virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
};
class CombineRGBANode : public CombineColorNode {
-public:
- CombineRGBANode(bNode *editorNode) :
- CombineColorNode(editorNode)
- {}
+ public:
+ CombineRGBANode(bNode *editorNode) : CombineColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class CombineHSVANode : public CombineColorNode {
-public:
- CombineHSVANode(bNode *editorNode) :
- CombineColorNode(editorNode)
- {}
+ public:
+ CombineHSVANode(bNode *editorNode) : CombineColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class CombineYCCANode : public CombineColorNode {
-public:
- CombineYCCANode(bNode *editorNode) :
- CombineColorNode(editorNode)
- {}
+ public:
+ CombineYCCANode(bNode *editorNode) : CombineColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class CombineYUVANode : public CombineColorNode {
-public:
- CombineYUVANode(bNode *editorNode) :
- CombineColorNode(editorNode)
- {}
+ public:
+ CombineYUVANode(bNode *editorNode) : CombineColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp
index e0a6dc4aaeb..30072d6a5a7 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.cpp
+++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp
@@ -22,38 +22,38 @@
CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void CompositorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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;
+ 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);
+ 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);
+ 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.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);
+ converter.addNodeInputPreview(imageSocket);
}
diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h
index a3a28903405..8fb2a5a5cf5 100644
--- a/source/blender/compositor/nodes/COM_CompositorNode.h
+++ b/source/blender/compositor/nodes/COM_CompositorNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class CompositorNode : public Node {
-public:
- CompositorNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ CompositorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
index 30856814d5f..da8985de5ac 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp
@@ -20,21 +20,22 @@
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
-void ConvertAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ConvertAlphaNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeOperation *operation = NULL;
- bNode *node = this->getbNode();
+ NodeOperation *operation = NULL;
+ bNode *node = this->getbNode();
- /* value hardcoded in rna_nodetree.c */
- if (node->custom1 == 1) {
- operation = new ConvertPremulToStraightOperation();
- }
- else {
- operation = new ConvertStraightToPremulOperation();
- }
+ /* value hardcoded in rna_nodetree.c */
+ if (node->custom1 == 1) {
+ operation = new ConvertPremulToStraightOperation();
+ }
+ else {
+ operation = new ConvertStraightToPremulOperation();
+ }
- converter.addOperation(operation);
+ converter.addOperation(operation);
- converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
- converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
index 0de34e1ae88..8fdeae39ada 100644
--- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h
@@ -26,9 +26,11 @@
* \ingroup Node
*/
class ConvertAlphaNode : public Node {
-public:
- ConvertAlphaNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ConvertAlphaNode(bNode *editorNode) : Node(editorNode)
+ {
+ }
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CornerPinNode.cpp b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
index 3eefd53e3e8..9a9ecb755af 100644
--- a/source/blender/compositor/nodes/COM_CornerPinNode.cpp
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.cpp
@@ -24,31 +24,32 @@ CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode)
{
}
-void CornerPinNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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 };
+ 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);
+ 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);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_CornerPinNode.h
index de7b98c598f..ea62dea12de 100644
--- a/source/blender/compositor/nodes/COM_CornerPinNode.h
+++ b/source/blender/compositor/nodes/COM_CornerPinNode.h
@@ -29,9 +29,9 @@ extern "C" {
* \ingroup Node
*/
class CornerPinNode : public Node {
-public:
- CornerPinNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ CornerPinNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif /* __COM_CORNERPINNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp
index a7b4090463b..0f0883b0151 100644
--- a/source/blender/compositor/nodes/COM_CropNode.cpp
+++ b/source/blender/compositor/nodes/COM_CropNode.cpp
@@ -19,29 +19,29 @@
#include "COM_CropNode.h"
#include "COM_CropOperation.h"
-
CropNode::CropNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void CropNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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());
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h
index 9e24fc492bc..295d4fb77e1 100644
--- a/source/blender/compositor/nodes/COM_CropNode.h
+++ b/source/blender/compositor/nodes/COM_CropNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class CropNode : public Node {
-public:
- CropNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ CropNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
index ad15911062c..4219fd49d44 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp
@@ -27,91 +27,91 @@
CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
/* This is taken from the Cryptomatte specification 1.0. */
static inline float hash_to_float(uint32_t hash)
{
- uint32_t mantissa = hash & (( 1 << 23) - 1);
- uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
- exponent = max(exponent, (uint32_t) 1);
- exponent = min(exponent, (uint32_t) 254);
- exponent = exponent << 23;
- uint32_t sign = (hash >> 31);
- sign = sign << 31;
- uint32_t float_bits = sign | exponent | mantissa;
- float f;
- /* Bit casting relies on equal size for both types. */
- BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
- ::memcpy(&f, &float_bits, sizeof(float));
- return f;
+ uint32_t mantissa = hash & ((1 << 23) - 1);
+ uint32_t exponent = (hash >> 23) & ((1 << 8) - 1);
+ exponent = max(exponent, (uint32_t)1);
+ exponent = min(exponent, (uint32_t)254);
+ exponent = exponent << 23;
+ uint32_t sign = (hash >> 31);
+ sign = sign << 31;
+ uint32_t float_bits = sign | exponent | mantissa;
+ float f;
+ /* Bit casting relies on equal size for both types. */
+ BLI_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "float and uint32_t are not the same size")
+ ::memcpy(&f, &float_bits, sizeof(float));
+ return f;
}
-void CryptomatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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;
+ bNode *node = this->getbNode();
+ NodeCryptomatte *cryptoMatteSettings = (NodeCryptomatte *)node->storage;
- CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
- if (cryptoMatteSettings) {
- if (cryptoMatteSettings->matte_id) {
- /* Split the string by commas, ignoring white space. */
- std::string input = cryptoMatteSettings->matte_id;
- std::istringstream ss(input);
- while (ss.good()) {
- std::string token;
- getline(ss, token, ',');
- /* Ignore empty tokens. */
- if (token.length() > 0) {
- size_t first = token.find_first_not_of(' ');
- size_t last = token.find_last_not_of(' ');
- if (first == std::string::npos || last == std::string::npos) {
- break;
- }
- token = token.substr(first, (last - first + 1));
- if (*token.begin() == '<' && *(--token.end()) == '>') {
- operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
- }
- else {
- uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
- operation->addObjectIndex(hash_to_float(hash));
- }
- }
- }
- }
- }
+ CryptomatteOperation *operation = new CryptomatteOperation(getNumberOfInputSockets() - 1);
+ if (cryptoMatteSettings) {
+ if (cryptoMatteSettings->matte_id) {
+ /* Split the string by commas, ignoring white space. */
+ std::string input = cryptoMatteSettings->matte_id;
+ std::istringstream ss(input);
+ while (ss.good()) {
+ std::string token;
+ getline(ss, token, ',');
+ /* Ignore empty tokens. */
+ if (token.length() > 0) {
+ size_t first = token.find_first_not_of(' ');
+ size_t last = token.find_last_not_of(' ');
+ if (first == std::string::npos || last == std::string::npos) {
+ break;
+ }
+ token = token.substr(first, (last - first + 1));
+ if (*token.begin() == '<' && *(--token.end()) == '>') {
+ operation->addObjectIndex(atof(token.substr(1, token.length() - 2).c_str()));
+ }
+ else {
+ uint32_t hash = BLI_hash_mm3((const unsigned char *)token.c_str(), token.length(), 0);
+ operation->addObjectIndex(hash_to_float(hash));
+ }
+ }
+ }
+ }
+ }
- converter.addOperation(operation);
+ converter.addOperation(operation);
- for (int i = 0; i < getNumberOfInputSockets() - 1; ++i) {
- converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i));
- }
+ 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);
+ SeparateChannelOperation *separateOperation = new SeparateChannelOperation;
+ separateOperation->setChannel(3);
+ converter.addOperation(separateOperation);
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- converter.addOperation(operationAlpha);
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ converter.addOperation(operationAlpha);
- converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
- converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
+ converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0));
+ converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1));
- SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
- converter.addOperation(clearAlphaOperation);
- converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f);
+ SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation();
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_CryptomatteNode.h
index 3a4aa3b94d0..91f8051f125 100644
--- a/source/blender/compositor/nodes/COM_CryptomatteNode.h
+++ b/source/blender/compositor/nodes/COM_CryptomatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class CryptomatteNode : public Node {
-public:
- CryptomatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ CryptomatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp
index 371921ff345..5e83372a70a 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.cpp
+++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp
@@ -32,109 +32,110 @@
DefocusNode::DefocusNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DefocusNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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 : NULL;
-
- 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);
+ bNode *node = this->getbNode();
+ NodeDefocus *data = (NodeDefocus *)node->storage;
+ Scene *scene = node->id ? (Scene *)node->id : context.getScene();
+ Object *camob = scene ? scene->camera : NULL;
+
+ 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);
+ InverseSearchRadiusOperation *search = new InverseSearchRadiusOperation();
+ search->setMaxBlur(data->maxblur);
+ converter.addOperation(search);
- converter.addLink(radiusOperation->getOutputSocket(0), search->getInputSocket(0));
+ 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));
+ 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));
+ 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());
- }
+ 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.h b/source/blender/compositor/nodes/COM_DefocusNode.h
index 201cbdac2dc..f2589c7ae1a 100644
--- a/source/blender/compositor/nodes/COM_DefocusNode.h
+++ b/source/blender/compositor/nodes/COM_DefocusNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DefocusNode : public Node {
-public:
- DefocusNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DefocusNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.cpp b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
index 255fc996032..16de1bd29d7 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.cpp
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.cpp
@@ -24,24 +24,25 @@
DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DespeckleNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ 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.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
- converter.addPreview(operation->getOutputSocket(0));
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_DespeckleNode.h b/source/blender/compositor/nodes/COM_DespeckleNode.h
index f5071417587..ee510a0568c 100644
--- a/source/blender/compositor/nodes/COM_DespeckleNode.h
+++ b/source/blender/compositor/nodes/COM_DespeckleNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DespeckleNode : public Node {
-public:
- DespeckleNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DespeckleNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
index 0e104b69da7..b579502e068 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp
@@ -23,31 +23,32 @@
DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DifferenceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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();
+ 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);
+ 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));
+ converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
+ converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
- SetAlphaOperation *operation = new SetAlphaOperation();
- converter.addOperation(operation);
+ SetAlphaOperation *operation = new SetAlphaOperation();
+ converter.addOperation(operation);
- converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
- converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
- converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
- converter.addPreview(operation->getOutputSocket());
+ converter.addPreview(operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
index ea44a4f86a2..3a86a0bbf85 100644
--- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DifferenceMatteNode : public Node {
-public:
- DifferenceMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DifferenceMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_DifferenceMatteNODE_H */
+#endif /* COM_DifferenceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
index bab54993eaf..cde94b23ed8 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp
@@ -26,121 +26,122 @@
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;
- }
+ /* 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
+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 */
+ 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);
- }
+ if (!connectedSizeSocket) {
+ operationx->setSize(size);
+ operationy->setSize(size);
+ }
#else
- operationx->setSize(1.0f);
- operationy->setSize(1.0f);
+ 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));
- }
- }
+ 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.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h
index 565680c0c86..0093d78ca5b 100644
--- a/source/blender/compositor/nodes/COM_DilateErodeNode.h
+++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h
@@ -26,10 +26,11 @@
* \ingroup Node
*/
class DilateErodeNode : public Node {
- NodeBlurData m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesn't have this */
-public:
- DilateErodeNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ NodeBlurData
+ m_alpha_blur; /* only used for blurring alpha, since the dilate/erode node doesn't have this */
+ public:
+ DilateErodeNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
index 7e627ac8d41..faae759ba0c 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -23,17 +23,18 @@
DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DirectionalBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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());
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
index 63a27aefc4e..0f9249a83a5 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DirectionalBlurNode : public Node {
-public:
- DirectionalBlurNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DirectionalBlurNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
index afd3280d44a..6ff273b14b7 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.cpp
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp
@@ -23,21 +23,22 @@
DisplaceNode::DisplaceNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DisplaceNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_DisplaceNode.h
index b162d76209f..e6a13e06772 100644
--- a/source/blender/compositor/nodes/COM_DisplaceNode.h
+++ b/source/blender/compositor/nodes/COM_DisplaceNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class DisplaceNode : public Node {
-public:
- DisplaceNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DisplaceNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 3c1e73da148..5f001f723e8 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -25,73 +25,74 @@
DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DistanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
-
- SetAlphaOperation *operationAlpha = new SetAlphaOperation();
- 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());
- }
+ 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);
+
+ SetAlphaOperation *operationAlpha = new SetAlphaOperation();
+ 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.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
index 84a525c58a7..baba9bb8c97 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DistanceMatteNode : public Node {
-public:
- DistanceMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DistanceMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_DistanceMatteNODE_H */
+#endif /* COM_DistanceMatteNODE_H */
diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
index 9ed9b532bdc..907a9f49353 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp
@@ -22,20 +22,21 @@
DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void DoubleEdgeMaskNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- DoubleEdgeMaskOperation *operation;
- bNode *bnode = this->getbNode();
+ DoubleEdgeMaskOperation *operation;
+ bNode *bnode = this->getbNode();
- operation = new DoubleEdgeMaskOperation();
- operation->setAdjecentOnly(bnode->custom1);
- operation->setKeepInside(bnode->custom2);
- converter.addOperation(operation);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
index 45a10492ba2..c45d42675f3 100644
--- a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
+++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class DoubleEdgeMaskNode : public Node {
-public:
- DoubleEdgeMaskNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ DoubleEdgeMaskNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
index d44ac848864..349d0908a98 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp
@@ -25,45 +25,46 @@
EllipseMaskNode::EllipseMaskNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void EllipseMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void EllipseMaskNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
+ 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);
+ 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);
+ 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();
- ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
- scaleOperation->setIsAspect(false);
- scaleOperation->setIsCrop(false);
- scaleOperation->setOffset(0.0f, 0.0f);
- scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
- scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
- scaleOperation->getInputSocket(0)->setResizeMode(COM_SC_NO_RESIZE);
- converter.addOperation(scaleOperation);
+ /* Scale that image up to render resolution */
+ const RenderData *rd = context.getRenderData();
+ ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
+ scaleOperation->setIsAspect(false);
+ scaleOperation->setIsCrop(false);
+ scaleOperation->setOffset(0.0f, 0.0f);
+ scaleOperation->setNewWidth(rd->xsch * rd->size / 100.0f);
+ scaleOperation->setNewHeight(rd->ysch * rd->size / 100.0f);
+ 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.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));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
}
diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
index c4cef996137..b7093bf68fa 100644
--- a/source/blender/compositor/nodes/COM_EllipseMaskNode.h
+++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class EllipseMaskNode : public Node {
-public:
- EllipseMaskNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ EllipseMaskNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp
index 14a2bb4fe38..1972cabc7c4 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cpp
+++ b/source/blender/compositor/nodes/COM_FilterNode.cpp
@@ -25,55 +25,72 @@
FilterNode::FilterNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void FilterNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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 = NULL;
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeInput *inputImageSocket = this->getInputSocket(1);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+ ConvolutionFilterOperation *operation = NULL;
- switch (this->getbNode()->custom1) {
- case CMP_FILT_SOFT:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(1 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, 1 / 16.0f, 2 / 16.0f, 1 / 16.0f);
- break;
- case CMP_FILT_SHARP:
- operation = new ConvolutionFilterOperation();
- operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
- break;
- case CMP_FILT_LAPLACE:
- operation = new 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);
+ 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.mapInputSocket(inputImageSocket, operation->getInputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
- converter.addPreview(operation->getOutputSocket(0));
+ converter.addPreview(operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h
index b1aa0099fbc..d0e824051bb 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.h
+++ b/source/blender/compositor/nodes/COM_FilterNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class FilterNode : public Node {
-public:
- FilterNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ FilterNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_FILTERNODE_H__ */
+#endif /* __COM_FILTERNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp
index 16473c6586d..59b881bfcf7 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.cpp
+++ b/source/blender/compositor/nodes/COM_FlipNode.cpp
@@ -23,30 +23,31 @@
FlipNode::FlipNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void FlipNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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;
- }
+ 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));
+ converter.addOperation(operation);
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h
index a62482ab7fd..2122961dac9 100644
--- a/source/blender/compositor/nodes/COM_FlipNode.h
+++ b/source/blender/compositor/nodes/COM_FlipNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class FlipNode : public Node {
-public:
- FlipNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ FlipNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp
index 9ba9a305a3d..0c60c871864 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.cpp
+++ b/source/blender/compositor/nodes/COM_GammaNode.cpp
@@ -22,15 +22,16 @@
GammaNode::GammaNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void GammaNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void GammaNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- GammaOperation *operation = new GammaOperation();
- converter.addOperation(operation);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_GammaNode.h
index a54623e1b94..46573fc4b3f 100644
--- a/source/blender/compositor/nodes/COM_GammaNode.h
+++ b/source/blender/compositor/nodes/COM_GammaNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class GammaNode : public Node {
-public:
- GammaNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ GammaNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp
index 73e3f6b82c8..6a65486a97f 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.cpp
+++ b/source/blender/compositor/nodes/COM_GlareNode.cpp
@@ -29,54 +29,54 @@
GlareNode::GlareNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void GlareNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void GlareNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *node = this->getbNode();
- NodeGlare *glare = (NodeGlare *)node->storage;
+ bNode *node = this->getbNode();
+ NodeGlare *glare = (NodeGlare *)node->storage;
- GlareBaseOperation *glareoperation = NULL;
- 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);
+ GlareBaseOperation *glareoperation = NULL;
+ 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);
+ GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation();
+ thresholdOperation->setGlareSettings(glare);
- SetValueOperation *mixvalueoperation = new SetValueOperation();
- mixvalueoperation->setValue(0.5f + glare->mix * 0.5f);
+ 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);
+ 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.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());
+ 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.h b/source/blender/compositor/nodes/COM_GlareNode.h
index f67a418c8b6..051ae1d1dc3 100644
--- a/source/blender/compositor/nodes/COM_GlareNode.h
+++ b/source/blender/compositor/nodes/COM_GlareNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class GlareNode : public Node {
-public:
- GlareNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ GlareNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
index b0f87c27d8d..b1157242e10 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp
@@ -28,36 +28,37 @@
HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void HueSaturationValueCorrectNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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());
+ 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.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
index 73be77bbce6..270d29cc41b 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class HueSaturationValueCorrectNode : public Node {
-public:
- HueSaturationValueCorrectNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ HueSaturationValueCorrectNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
index 33415978818..8aae5f0409c 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp
@@ -28,39 +28,40 @@
HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void HueSaturationValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ ConvertRGBToHSVOperation *rgbToHSV = new ConvertRGBToHSVOperation();
+ converter.addOperation(rgbToHSV);
- ConvertHSVToRGBOperation *hsvToRGB = new ConvertHSVToRGBOperation();
- converter.addOperation(hsvToRGB);
+ 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);
+ 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);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
index 3b4231115be..5e023a0762d 100644
--- a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
+++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class HueSaturationValueNode : public Node {
-public:
- HueSaturationValueNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ HueSaturationValueNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
index cac65aacf53..50dd2ed93e9 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp
@@ -23,26 +23,27 @@
IDMaskNode::IDMaskNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void IDMaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void IDMaskNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *bnode = this->getbNode();
+ bNode *bnode = this->getbNode();
- IDMaskOperation *operation;
- operation = new IDMaskOperation();
- operation->setObjectIndex(bnode->custom1);
- converter.addOperation(operation);
+ 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.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));
- }
+ converter.addLink(operation->getOutputSocket(), antiAliasOperation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), antiAliasOperation->getOutputSocket(0));
+ }
}
diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h
index 296385f6923..3f4019bf5b7 100644
--- a/source/blender/compositor/nodes/COM_IDMaskNode.h
+++ b/source/blender/compositor/nodes/COM_IDMaskNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class IDMaskNode : public Node {
-public:
- IDMaskNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ IDMaskNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp
index fb3a222cc66..cf25e9f26ae 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.cpp
+++ b/source/blender/compositor/nodes/COM_ImageNode.cpp
@@ -31,238 +31,268 @@
ImageNode::ImageNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
-
+ /* pass */
}
-NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user,
- int framenumber, int outputsocketIndex, int passindex, int view, DataType datatype) const
+NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter,
+ RenderLayer *rl,
+ Image *image,
+ ImageUser *user,
+ int framenumber,
+ int outputsocketIndex,
+ int passindex,
+ int view,
+ DataType datatype) const
{
- NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
- MultilayerBaseOperation *operation = NULL;
- switch (datatype) {
- case COM_DT_VALUE:
- operation = new MultilayerValueOperation(passindex, view);
- break;
- case COM_DT_VECTOR:
- operation = new MultilayerVectorOperation(passindex, view);
- break;
- case COM_DT_COLOR:
- operation = new MultilayerColorOperation(passindex, view);
- break;
- default:
- break;
- }
- operation->setImage(image);
- operation->setRenderLayer(rl);
- operation->setImageUser(user);
- operation->setFramenumber(framenumber);
+ NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
+ MultilayerBaseOperation *operation = NULL;
+ switch (datatype) {
+ case COM_DT_VALUE:
+ operation = new MultilayerValueOperation(passindex, view);
+ break;
+ case COM_DT_VECTOR:
+ operation = new MultilayerVectorOperation(passindex, view);
+ break;
+ case COM_DT_COLOR:
+ operation = new MultilayerColorOperation(passindex, view);
+ break;
+ default:
+ break;
+ }
+ operation->setImage(image);
+ operation->setRenderLayer(rl);
+ operation->setImageUser(user);
+ operation->setFramenumber(framenumber);
- converter.addOperation(operation);
- converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
- return operation;
+ return operation;
}
-void ImageNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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(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, NULL);
- if (image->rr) {
- RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
- if (rl) {
- NodeOutput *socket;
- int index;
+ /// 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(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, NULL);
+ if (image->rr) {
+ RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer);
+ if (rl) {
+ NodeOutput *socket;
+ int index;
- is_multilayer_ok = true;
+ is_multilayer_ok = true;
- for (index = 0; index < numberOfOutputs; index++) {
- NodeOperation *operation = NULL;
- 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;
+ for (index = 0; index < numberOfOutputs; index++) {
+ NodeOperation *operation = NULL;
+ 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;
- }
+ 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) */
+ /* 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 (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) {
- int passindex = BLI_findindex(&rl->passes, rpass);
- switch (rpass->channels) {
- case 1:
- operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
- passindex, 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, image, imageuser, framenumber, index,
- passindex, view, COM_DT_VECTOR);
- break;
- case 4:
- operation = doMultilayerCheck(converter, rl, image, imageuser, framenumber, index,
- passindex, 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;
- }
- }
- }
+ if (rpass) {
+ int passindex = BLI_findindex(&rl->passes, rpass);
+ switch (rpass->channels) {
+ case 1:
+ operation = doMultilayerCheck(converter,
+ rl,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ 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,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ view,
+ COM_DT_VECTOR);
+ break;
+ case 4:
+ operation = doMultilayerCheck(converter,
+ rl,
+ image,
+ imageuser,
+ framenumber,
+ index,
+ passindex,
+ 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;
+ }
+ }
+ }
- /* incase we can't load the layer */
- if (operation == NULL)
- converter.setInvalidOutput(getOutputSocket(index));
- }
- }
- }
- BKE_image_release_ibuf(image, ibuf, NULL);
+ /* incase we can't load the layer */
+ if (operation == NULL)
+ converter.setInvalidOutput(getOutputSocket(index));
+ }
+ }
+ }
+ BKE_image_release_ibuf(image, ibuf, NULL);
- /* without this, multilayer that fail to load will crash blender [#32490] */
- 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);
+ /* without this, multilayer that fail to load will crash blender [#32490] */
+ 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();
+ 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.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());
- }
+ 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);
+ 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(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 = NULL;
- 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;
- }
- }
+ 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 = NULL;
+ 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());
- }
- }
- }
- }
+ 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.h b/source/blender/compositor/nodes/COM_ImageNode.h
index 936d5941676..781fef37355 100644
--- a/source/blender/compositor/nodes/COM_ImageNode.h
+++ b/source/blender/compositor/nodes/COM_ImageNode.h
@@ -21,7 +21,7 @@
#include "DNA_node_types.h"
#include "DNA_image_types.h"
extern "C" {
-# include "RE_engine.h"
+#include "RE_engine.h"
}
/**
@@ -29,11 +29,18 @@ extern "C" {
* \ingroup Node
*/
class ImageNode : public Node {
-private:
- NodeOperation *doMultilayerCheck(NodeConverter &converter, RenderLayer *rl, Image *image, ImageUser *user,
- int framenumber, int outputsocketIndex, int passtype, int view, DataType datatype) const;
-public:
- ImageNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ private:
+ NodeOperation *doMultilayerCheck(NodeConverter &converter,
+ RenderLayer *rl,
+ Image *image,
+ ImageUser *user,
+ int framenumber,
+ int outputsocketIndex,
+ int passtype,
+ int view,
+ DataType datatype) const;
+ public:
+ ImageNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.cpp b/source/blender/compositor/nodes/COM_InpaintNode.cpp
index 84cc7a8118d..454aa3e147b 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.cpp
+++ b/source/blender/compositor/nodes/COM_InpaintNode.cpp
@@ -24,21 +24,22 @@
InpaintNode::InpaintNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void InpaintNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void InpaintNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *editorNode = this->getbNode();
+ bNode *editorNode = this->getbNode();
- /* if (editorNode->custom1 == CMP_NODE_INPAINT_SIMPLE) { */
- if (true) {
- InpaintSimpleOperation *operation = new InpaintSimpleOperation();
- operation->setIterations(editorNode->custom2);
- converter.addOperation(operation);
+ /* 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));
- }
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
+ }
}
diff --git a/source/blender/compositor/nodes/COM_InpaintNode.h b/source/blender/compositor/nodes/COM_InpaintNode.h
index bbfb462667b..61a7ac63146 100644
--- a/source/blender/compositor/nodes/COM_InpaintNode.h
+++ b/source/blender/compositor/nodes/COM_InpaintNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class InpaintNode : public Node {
-public:
- InpaintNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ InpaintNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp
index 769e0214b3b..82dd707a817 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.cpp
+++ b/source/blender/compositor/nodes/COM_InvertNode.cpp
@@ -23,18 +23,19 @@
InvertNode::InvertNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void InvertNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_InvertNode.h
index b15bfca012e..02e2eb38dc9 100644
--- a/source/blender/compositor/nodes/COM_InvertNode.h
+++ b/source/blender/compositor/nodes/COM_InvertNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class InvertNode : public Node {
-public:
- InvertNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ InvertNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 9050dba676b..1bb9b9aa057 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -39,273 +39,309 @@
KeyingNode::KeyingNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-NodeOperationOutput *KeyingNode::setupPreBlur(NodeConverter &converter, NodeInput *inputImage, int size) const
+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 (channel == 0 || channel == 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);
+ 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 (channel == 0 || channel == 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
+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 *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);
+ 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));
+ converter.addLink(postBlurInput, blurXOperation->getInputSocket(0));
+ converter.addLink(blurXOperation->getOutputSocket(), blurYOperation->getInputSocket(0));
- return blurYOperation->getOutputSocket();
+ return blurYOperation->getOutputSocket();
}
-NodeOperationOutput *KeyingNode::setupDilateErode(NodeConverter &converter, NodeOperationOutput *dilateErodeInput, int distance) const
+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);
+ 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
+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();
+ /* 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
+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);
+ 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));
+ converter.addLink(despillInput, despillOperation->getInputSocket(0));
+ converter.mapInputSocket(inputScreen, despillOperation->getInputSocket(1));
- return despillOperation->getOutputSocket(0);
+ return despillOperation->getOutputSocket(0);
}
-NodeOperationOutput *KeyingNode::setupClip(NodeConverter &converter, NodeOperationOutput *clipInput, int kernelRadius, float kernelTolerance,
- float clipBlack, float clipWhite, bool edgeMatte) const
+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);
+ 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));
+ converter.addLink(clipInput, clipOperation->getInputSocket(0));
- return clipOperation->getOutputSocket(0);
+ return clipOperation->getOutputSocket(0);
}
-void KeyingNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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 = NULL, *postprocessedImage = NULL, *edgesMatte = NULL;
-
- /* 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 preblur operation for input of keying operation */
- NodeOperationOutput *preBluredImage = setupPreBlur(converter, inputImage, keying_data->blur_pre);
- converter.addLink(preBluredImage, 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 */
- SetAlphaOperation *alphaOperation = new SetAlphaOperation();
- 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);
+ 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 = NULL, *postprocessedImage = NULL, *edgesMatte = NULL;
+
+ /* 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 preblur operation for input of keying operation */
+ NodeOperationOutput *preBluredImage = setupPreBlur(
+ converter, inputImage, keying_data->blur_pre);
+ converter.addLink(preBluredImage, 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 */
+ SetAlphaOperation *alphaOperation = new SetAlphaOperation();
+ 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.h b/source/blender/compositor/nodes/COM_KeyingNode.h
index cb752f517bd..9ae1d04b03f 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingNode.h
@@ -23,18 +23,35 @@
* \ingroup Node
*/
class KeyingNode : public Node {
-protected:
- NodeOperationOutput *setupPreBlur(NodeConverter &converter, NodeInput *inputImage, int size) const;
- NodeOperationOutput *setupPostBlur(NodeConverter &converter, NodeOperationOutput *postBlurInput, int size) const;
- NodeOperationOutput *setupDilateErode(NodeConverter &converter, NodeOperationOutput *dilateErodeInput, int distance) const;
- NodeOperationOutput *setupFeather(NodeConverter &converter, const CompositorContext &context, NodeOperationOutput *featherInput,
- int falloff, int distance) const;
- NodeOperationOutput *setupDespill(NodeConverter &converter, NodeOperationOutput *despillInput, NodeInput *inputSrceen,
- float factor, float colorBalance) const;
- NodeOperationOutput *setupClip(NodeConverter &converter, NodeOperationOutput *clipInput, int kernelRadius, float kernelTolerance,
- float clipBlack, float clipWhite, bool edgeMatte) const;
-public:
- KeyingNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ protected:
+ NodeOperationOutput *setupPreBlur(NodeConverter &converter,
+ NodeInput *inputImage,
+ int size) const;
+ NodeOperationOutput *setupPostBlur(NodeConverter &converter,
+ NodeOperationOutput *postBlurInput,
+ int size) const;
+ NodeOperationOutput *setupDilateErode(NodeConverter &converter,
+ NodeOperationOutput *dilateErodeInput,
+ int distance) const;
+ NodeOperationOutput *setupFeather(NodeConverter &converter,
+ const CompositorContext &context,
+ NodeOperationOutput *featherInput,
+ int falloff,
+ int distance) const;
+ NodeOperationOutput *setupDespill(NodeConverter &converter,
+ NodeOperationOutput *despillInput,
+ NodeInput *inputSrceen,
+ float factor,
+ float colorBalance) const;
+ NodeOperationOutput *setupClip(NodeConverter &converter,
+ NodeOperationOutput *clipInput,
+ int kernelRadius,
+ float kernelTolerance,
+ float clipBlack,
+ float clipWhite,
+ bool edgeMatte) const;
+ public:
+ KeyingNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
index 562e14a0ec0..6a005b2b712 100644
--- a/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.cpp
@@ -21,28 +21,29 @@
#include "COM_KeyingScreenOperation.h"
extern "C" {
-# include "DNA_movieclip_types.h"
+#include "DNA_movieclip_types.h"
}
KeyingScreenNode::KeyingScreenNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void KeyingScreenNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void KeyingScreenNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *editorNode = this->getbNode();
- MovieClip *clip = (MovieClip *) editorNode->id;
- NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;
+ bNode *editorNode = this->getbNode();
+ MovieClip *clip = (MovieClip *)editorNode->id;
+ NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *)editorNode->storage;
- NodeOutput *outputScreen = this->getOutputSocket(0);
+ 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);
+ // 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());
+ converter.mapOutputSocket(outputScreen, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_KeyingScreenNode.h b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
index 196ddd6db8d..edaf0238667 100644
--- a/source/blender/compositor/nodes/COM_KeyingScreenNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingScreenNode.h
@@ -24,8 +24,7 @@
* \ingroup Node
*/
class KeyingScreenNode : public Node {
-public:
- KeyingScreenNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+ public:
+ KeyingScreenNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index 4f8d8589a20..a4e638e20e6 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -23,36 +23,37 @@
LensDistortionNode::LensDistortionNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void LensDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ 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());
+ if (!getInputSocket(1)->isLinked())
+ operation->setDistortion(getInputSocket(1)->getEditorValueFloat());
+ if (!getInputSocket(2)->isLinked())
+ operation->setDispersion(getInputSocket(2)->getEditorValueFloat());
- converter.addOperation(operation);
+ 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));
- }
+ 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.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h
index 91b962a0faa..f4d9e127558 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class LensDistortionNode : public Node {
-public:
- LensDistortionNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ LensDistortionNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
index a5976ba3127..3599372f189 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp
@@ -24,29 +24,30 @@
LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void LuminanceMatteNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ LuminanceMatteOperation *operationSet = new LuminanceMatteOperation();
+ operationSet->setSettings((NodeChroma *)editorsnode->storage);
+ converter.addOperation(operationSet);
- converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
- converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
+ converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0));
+ converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0));
- SetAlphaOperation *operation = new SetAlphaOperation();
- converter.addOperation(operation);
+ SetAlphaOperation *operation = new SetAlphaOperation();
+ converter.addOperation(operation);
- converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
- converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
- converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.addLink(operationSet->getOutputSocket(), operation->getInputSocket(1));
+ converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
- converter.addPreview(operation->getOutputSocket());
+ converter.addPreview(operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
index 5412016f10b..57a8f25602a 100644
--- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
+++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class LuminanceMatteNode : public Node {
-public:
- LuminanceMatteNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ LuminanceMatteNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_LUMINANCEMATTENODE_H__ */
+#endif /* __COM_LUMINANCEMATTENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapRangeNode.cpp b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
index 7abd6f4a595..3b6d2fe0dcb 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.cpp
@@ -23,26 +23,27 @@
MapRangeNode::MapRangeNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MapRangeNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_MapRangeNode.h
index ce9ffa15c1e..b63524291c1 100644
--- a/source/blender/compositor/nodes/COM_MapRangeNode.h
+++ b/source/blender/compositor/nodes/COM_MapRangeNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class MapRangeNode : public Node {
-public:
- MapRangeNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MapRangeNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_MAPRANGENODE_H__ */
+#endif /* __COM_MAPRANGENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp
index 555fe9e87ae..fe4895833cf 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp
@@ -22,19 +22,20 @@
MapUVNode::MapUVNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MapUVNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void MapUVNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bNode *node = this->getbNode();
+ bNode *node = this->getbNode();
- MapUVOperation *operation = new MapUVOperation();
- operation->setAlpha((float)node->custom1);
- operation->setResolutionInputSocketIndex(1);
- converter.addOperation(operation);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_MapUVNode.h
index c751ee2e72c..46892453b92 100644
--- a/source/blender/compositor/nodes/COM_MapUVNode.h
+++ b/source/blender/compositor/nodes/COM_MapUVNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class MapUVNode : public Node {
-public:
- MapUVNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MapUVNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp
index 8d0d8e47d7f..4ed971a2fcc 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp
@@ -23,20 +23,21 @@
MapValueNode::MapValueNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MapValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void MapValueNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- TexMapping *storage = (TexMapping *)this->getbNode()->storage;
+ TexMapping *storage = (TexMapping *)this->getbNode()->storage;
- NodeInput *colorSocket = this->getInputSocket(0);
- NodeOutput *valueSocket = this->getOutputSocket(0);
+ NodeInput *colorSocket = this->getInputSocket(0);
+ NodeOutput *valueSocket = this->getOutputSocket(0);
- MapValueOperation *convertProg = new MapValueOperation();
- convertProg->setSettings(storage);
- converter.addOperation(convertProg);
+ MapValueOperation *convertProg = new MapValueOperation();
+ convertProg->setSettings(storage);
+ converter.addOperation(convertProg);
- converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
- converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
+ converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
+ converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h
index 65b9708d163..289b4f24138 100644
--- a/source/blender/compositor/nodes/COM_MapValueNode.h
+++ b/source/blender/compositor/nodes/COM_MapValueNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class MapValueNode : public Node {
-public:
- MapValueNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MapValueNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_MAPVALUENODE_H__ */
+#endif /* __COM_MAPVALUENODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MaskNode.cpp b/source/blender/compositor/nodes/COM_MaskNode.cpp
index 5158103c08a..cceeef6b437 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.cpp
+++ b/source/blender/compositor/nodes/COM_MaskNode.cpp
@@ -21,52 +21,51 @@
#include "COM_MaskOperation.h"
extern "C" {
-# include "DNA_mask_types.h"
+#include "DNA_mask_types.h"
}
MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MaskNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void MaskNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- const RenderData *rd = context.getRenderData();
+ const RenderData *rd = context.getRenderData();
- NodeOutput *outputMask = this->getOutputSocket(0);
+ NodeOutput *outputMask = this->getOutputSocket(0);
- bNode *editorNode = this->getbNode();
- NodeMask *data = (NodeMask *)editorNode->storage;
- Mask *mask = (Mask *)editorNode->id;
+ bNode *editorNode = this->getbNode();
+ NodeMask *data = (NodeMask *)editorNode->storage;
+ Mask *mask = (Mask *)editorNode->id;
- // always connect the output image
- MaskOperation *operation = new MaskOperation();
+ // 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 * (rd->size / 100.0f));
- operation->setMaskHeight(data->size_y * (rd->size / 100.0f));
- }
- else {
- operation->setMaskWidth(rd->xsch * rd->size / 100.0f);
- operation->setMaskHeight(rd->ysch * rd->size / 100.0f);
- }
+ 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 * (rd->size / 100.0f));
+ operation->setMaskHeight(data->size_y * (rd->size / 100.0f));
+ }
+ else {
+ operation->setMaskWidth(rd->xsch * rd->size / 100.0f);
+ operation->setMaskHeight(rd->ysch * rd->size / 100.0f);
+ }
- operation->setMask(mask);
- operation->setFramenumber(context.getFramenumber());
- operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_NO_FEATHER) == 0);
+ 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);
- }
+ 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());
+ converter.addOperation(operation);
+ converter.mapOutputSocket(outputMask, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_MaskNode.h b/source/blender/compositor/nodes/COM_MaskNode.h
index dec6112e8f6..6c8006a8de6 100644
--- a/source/blender/compositor/nodes/COM_MaskNode.h
+++ b/source/blender/compositor/nodes/COM_MaskNode.h
@@ -27,10 +27,9 @@
* \ingroup Node
*/
class MaskNode : public Node {
-public:
- MaskNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+ public:
+ MaskNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_MASKNODE_H__ */
+#endif /* __COM_MASKNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp
index 06753383dfe..5a2f934f37f 100644
--- a/source/blender/compositor/nodes/COM_MathNode.cpp
+++ b/source/blender/compositor/nodes/COM_MathNode.cpp
@@ -20,92 +20,93 @@
#include "COM_MathBaseOperation.h"
#include "COM_ExecutionSystem.h"
-void MathNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void MathNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- MathBaseOperation *operation = NULL;
+ MathBaseOperation *operation = NULL;
- switch (this->getbNode()->custom1) {
- case NODE_MATH_ADD:
- operation = new MathAddOperation();
- break;
- case NODE_MATH_SUB:
- operation = new MathSubtractOperation();
- break;
- case NODE_MATH_MUL:
- operation = new MathMultiplyOperation();
- break;
- case NODE_MATH_DIVIDE:
- operation = new MathDivideOperation();
- break;
- case NODE_MATH_SIN:
- operation = new MathSineOperation();
- break;
- case NODE_MATH_COS:
- operation = new MathCosineOperation();
- break;
- case NODE_MATH_TAN:
- operation = new MathTangentOperation();
- break;
- case NODE_MATH_ASIN:
- operation = new MathArcSineOperation();
- break;
- case NODE_MATH_ACOS:
- operation = new MathArcCosineOperation();
- break;
- case NODE_MATH_ATAN:
- operation = new MathArcTangentOperation();
- break;
- case NODE_MATH_POW:
- operation = new MathPowerOperation();
- break;
- case NODE_MATH_LOG:
- operation = new MathLogarithmOperation();
- break;
- case NODE_MATH_MIN:
- operation = new MathMinimumOperation();
- break;
- case NODE_MATH_MAX:
- operation = new MathMaximumOperation();
- break;
- case NODE_MATH_ROUND:
- operation = new MathRoundOperation();
- break;
- case NODE_MATH_LESS:
- operation = new MathLessThanOperation();
- break;
- case NODE_MATH_GREATER:
- operation = new MathGreaterThanOperation();
- break;
- case NODE_MATH_MOD:
- operation = new MathModuloOperation();
- break;
- case NODE_MATH_ABS:
- operation = new MathAbsoluteOperation();
- break;
- case NODE_MATH_ATAN2:
- operation = new MathArcTan2Operation();
- break;
- case NODE_MATH_FLOOR:
- operation = new MathFloorOperation();
- break;
- case NODE_MATH_CEIL:
- operation = new MathCeilOperation();
- break;
- case NODE_MATH_FRACT:
- operation = new MathFractOperation();
- break;
- case NODE_MATH_SQRT:
- operation = new MathSqrtOperation();
- break;
- }
+ switch (this->getbNode()->custom1) {
+ case NODE_MATH_ADD:
+ operation = new MathAddOperation();
+ break;
+ case NODE_MATH_SUB:
+ operation = new MathSubtractOperation();
+ break;
+ case NODE_MATH_MUL:
+ operation = new MathMultiplyOperation();
+ break;
+ case NODE_MATH_DIVIDE:
+ operation = new MathDivideOperation();
+ break;
+ case NODE_MATH_SIN:
+ operation = new MathSineOperation();
+ break;
+ case NODE_MATH_COS:
+ operation = new MathCosineOperation();
+ break;
+ case NODE_MATH_TAN:
+ operation = new MathTangentOperation();
+ break;
+ case NODE_MATH_ASIN:
+ operation = new MathArcSineOperation();
+ break;
+ case NODE_MATH_ACOS:
+ operation = new MathArcCosineOperation();
+ break;
+ case NODE_MATH_ATAN:
+ operation = new MathArcTangentOperation();
+ break;
+ case NODE_MATH_POW:
+ operation = new MathPowerOperation();
+ break;
+ case NODE_MATH_LOG:
+ operation = new MathLogarithmOperation();
+ break;
+ case NODE_MATH_MIN:
+ operation = new MathMinimumOperation();
+ break;
+ case NODE_MATH_MAX:
+ operation = new MathMaximumOperation();
+ break;
+ case NODE_MATH_ROUND:
+ operation = new MathRoundOperation();
+ break;
+ case NODE_MATH_LESS:
+ operation = new MathLessThanOperation();
+ break;
+ case NODE_MATH_GREATER:
+ operation = new MathGreaterThanOperation();
+ break;
+ case NODE_MATH_MOD:
+ operation = new MathModuloOperation();
+ break;
+ case NODE_MATH_ABS:
+ operation = new MathAbsoluteOperation();
+ break;
+ case NODE_MATH_ATAN2:
+ operation = new MathArcTan2Operation();
+ break;
+ case NODE_MATH_FLOOR:
+ operation = new MathFloorOperation();
+ break;
+ case NODE_MATH_CEIL:
+ operation = new MathCeilOperation();
+ break;
+ case NODE_MATH_FRACT:
+ operation = new MathFractOperation();
+ break;
+ case NODE_MATH_SQRT:
+ operation = new MathSqrtOperation();
+ break;
+ }
- if (operation) {
- bool useClamp = getbNode()->custom2;
- operation->setUseClamp(useClamp);
- converter.addOperation(operation);
+ 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.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
- }
+ 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_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h
index cf7c9276ba4..e53d84a221f 100644
--- a/source/blender/compositor/nodes/COM_MathNode.h
+++ b/source/blender/compositor/nodes/COM_MathNode.h
@@ -26,9 +26,11 @@
* \ingroup Node
*/
class MathNode : public Node {
-public:
- MathNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MathNode(bNode *editorNode) : Node(editorNode)
+ {
+ }
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp
index 4c5888135c7..27a605e28d4 100644
--- a/source/blender/compositor/nodes/COM_MixNode.cpp
+++ b/source/blender/compositor/nodes/COM_MixNode.cpp
@@ -22,91 +22,91 @@
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
-#include "DNA_material_types.h" // the ramp types
-
+#include "DNA_material_types.h" // the ramp types
MixNode::MixNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MixNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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;
+ 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 MixBurnOperation();
- break;
- case MA_RAMP_HUE:
- convertProg = new MixHueOperation();
- break;
- case MA_RAMP_COLOR:
- convertProg = new MixColorOperation();
- break;
- case MA_RAMP_SOFT:
- convertProg = new MixSoftLightOperation();
- break;
- case MA_RAMP_SCREEN:
- convertProg = new MixScreenOperation();
- break;
- case MA_RAMP_LINEAR:
- convertProg = new MixLinearLightOperation();
- break;
- case MA_RAMP_DIFF:
- convertProg = new MixDifferenceOperation();
- break;
- case MA_RAMP_SAT:
- convertProg = new MixSaturationOperation();
- break;
- case MA_RAMP_DIV:
- convertProg = new MixDivideOperation();
- break;
- case MA_RAMP_SUB:
- convertProg = new MixSubtractOperation();
- break;
- case MA_RAMP_DARK:
- convertProg = new MixDarkenOperation();
- break;
- case MA_RAMP_OVERLAY:
- convertProg = new MixOverlayOperation();
- break;
- case MA_RAMP_VAL:
- convertProg = new MixValueOperation();
- break;
- case MA_RAMP_DODGE:
- convertProg = new MixDodgeOperation();
- break;
+ MixBaseOperation *convertProg;
+ switch (editorNode->custom1) {
+ case MA_RAMP_ADD:
+ convertProg = new MixAddOperation();
+ break;
+ case MA_RAMP_MULT:
+ convertProg = new MixMultiplyOperation();
+ break;
+ case MA_RAMP_LIGHT:
+ convertProg = new MixLightenOperation();
+ break;
+ case MA_RAMP_BURN:
+ convertProg = new MixBurnOperation();
+ break;
+ case MA_RAMP_HUE:
+ convertProg = new MixHueOperation();
+ break;
+ case MA_RAMP_COLOR:
+ convertProg = new MixColorOperation();
+ break;
+ case MA_RAMP_SOFT:
+ convertProg = new MixSoftLightOperation();
+ break;
+ case MA_RAMP_SCREEN:
+ convertProg = new MixScreenOperation();
+ break;
+ case MA_RAMP_LINEAR:
+ convertProg = new MixLinearLightOperation();
+ break;
+ case MA_RAMP_DIFF:
+ convertProg = new MixDifferenceOperation();
+ break;
+ case MA_RAMP_SAT:
+ convertProg = new MixSaturationOperation();
+ break;
+ case MA_RAMP_DIV:
+ convertProg = new MixDivideOperation();
+ break;
+ case MA_RAMP_SUB:
+ convertProg = new MixSubtractOperation();
+ break;
+ case MA_RAMP_DARK:
+ convertProg = new MixDarkenOperation();
+ break;
+ case MA_RAMP_OVERLAY:
+ convertProg = new MixOverlayOperation();
+ break;
+ case MA_RAMP_VAL:
+ convertProg = new MixValueOperation();
+ break;
+ case MA_RAMP_DODGE:
+ convertProg = new MixDodgeOperation();
+ break;
- case MA_RAMP_BLEND:
- default:
- convertProg = new MixBlendOperation();
- break;
- }
- convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
- convertProg->setUseClamp(useClamp);
- converter.addOperation(convertProg);
+ 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.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));
+ converter.addPreview(convertProg->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h
index 5571599e106..511e1ffa7a8 100644
--- a/source/blender/compositor/nodes/COM_MixNode.h
+++ b/source/blender/compositor/nodes/COM_MixNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class MixNode : public Node {
-public:
- MixNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MixNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
index b79282d37b2..342f0a9f88a 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp
@@ -23,80 +23,84 @@
#include "COM_ConvertColorProfileOperation.h"
extern "C" {
-# include "DNA_movieclip_types.h"
-# include "BKE_movieclip.h"
-# include "BKE_tracking.h"
-# include "IMB_imbuf.h"
+#include "DNA_movieclip_types.h"
+#include "BKE_movieclip.h"
+#include "BKE_tracking.h"
+#include "IMB_imbuf.h"
}
MovieClipNode::MovieClipNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MovieClipNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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();
+ bNode *editorNode = this->getbNode();
+ MovieClip *movieClip = (MovieClip *)editorNode->id;
+ MovieClipUser *movieClipUser = (MovieClipUser *)editorNode->storage;
+ bool cacheFrame = !context.isRendering();
- ImBuf *ibuf = NULL;
- 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);
- }
+ ImBuf *ibuf = NULL;
+ 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);
+ // 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());
+ 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);
+ 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());
+ 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;
+ 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());
+ 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);
- }
- }
+ 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);
+ converter.addOutputValue(offsetXMovieClip, loc[0]);
+ converter.addOutputValue(offsetYMovieClip, loc[1]);
+ converter.addOutputValue(scaleMovieClip, scale);
+ converter.addOutputValue(angleMovieClip, angle);
- if (ibuf) {
- IMB_freeImBuf(ibuf);
- }
+ if (ibuf) {
+ IMB_freeImBuf(ibuf);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h
index 5664d472ce6..2c3f29772d5 100644
--- a/source/blender/compositor/nodes/COM_MovieClipNode.h
+++ b/source/blender/compositor/nodes/COM_MovieClipNode.h
@@ -27,9 +27,9 @@
* \ingroup Node
*/
class MovieClipNode : public Node {
-public:
- MovieClipNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MovieClipNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_MOVIECLIPNODE_H__ */
+#endif /* __COM_MOVIECLIPNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
index 5786f8cc385..d0ec152fca4 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp
@@ -24,22 +24,23 @@
MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void MovieDistortionNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void MovieDistortionNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *bnode = this->getbNode();
- MovieClip *clip = (MovieClip *)bnode->id;
+ bNode *bnode = this->getbNode();
+ MovieClip *clip = (MovieClip *)bnode->id;
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
+ 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);
+ 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));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
index 6cba1a1196c..da687080691 100644
--- a/source/blender/compositor/nodes/COM_MovieDistortionNode.h
+++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class MovieDistortionNode : public Node {
-public:
- MovieDistortionNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ MovieDistortionNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp
index 281f43dfec9..a6f39312601 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalNode.cpp
@@ -24,32 +24,33 @@
NormalNode::NormalNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void NormalNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void NormalNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
- NodeOutput *outputSocketDotproduct = this->getOutputSocket(1);
+ 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);
+ 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));
+ converter.mapOutputSocket(outputSocket, operationSet->getOutputSocket(0));
- DotproductOperation *operation = new DotproductOperation();
- converter.addOperation(operation);
+ 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));
+ 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.h b/source/blender/compositor/nodes/COM_NormalNode.h
index 5569feb8c7e..4151960c506 100644
--- a/source/blender/compositor/nodes/COM_NormalNode.h
+++ b/source/blender/compositor/nodes/COM_NormalNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class NormalNode : public Node {
-public:
- NormalNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ NormalNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* COM_NormalNODE_H */
+#endif /* COM_NormalNODE_H */
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
index 1adfcaddb0e..dc061279664 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.cpp
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.cpp
@@ -22,14 +22,15 @@
NormalizeNode::NormalizeNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void NormalizeNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void NormalizeNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NormalizeOperation *operation = new NormalizeOperation();
- converter.addOperation(operation);
+ NormalizeOperation *operation = new NormalizeOperation();
+ converter.addOperation(operation);
- converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
- converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h
index fa41753e697..593c98f2ce2 100644
--- a/source/blender/compositor/nodes/COM_NormalizeNode.h
+++ b/source/blender/compositor/nodes/COM_NormalizeNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class NormalizeNode : public Node {
-public:
- NormalizeNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ NormalizeNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
index beed19a0b95..822359771f3 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.cpp
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp
@@ -27,95 +27,122 @@
OutputFileNode::OutputFileNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void OutputFileNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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.getRenderData(), context.getbNodeTree(), storage->base_path,
- storage->format.exr_codec, use_half_float, context.getViewName());
- }
- else {
- outputOperation = new OutputOpenExrMultiLayerOperation(
- 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 = NULL;
-
- 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());
- }
- 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());
- }
- 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());
- }
-
- converter.addOperation(outputOperation);
- converter.mapInputSocket(input, outputOperation->getInputSocket(0));
-
- if (!previewAdded) {
- converter.addNodeInputPreview(input);
- previewAdded = true;
- }
- }
- }
- }
+ 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.getRenderData(),
+ context.getbNodeTree(),
+ storage->base_path,
+ storage->format.exr_codec,
+ use_half_float,
+ context.getViewName());
+ }
+ else {
+ outputOperation = new OutputOpenExrMultiLayerOperation(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 = NULL;
+
+ 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());
+ }
+ 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());
+ }
+ 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());
+ }
+
+ 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.h b/source/blender/compositor/nodes/COM_OutputFileNode.h
index 366528742b8..932fa375a3a 100644
--- a/source/blender/compositor/nodes/COM_OutputFileNode.h
+++ b/source/blender/compositor/nodes/COM_OutputFileNode.h
@@ -27,9 +27,9 @@
* \ingroup Node
*/
class OutputFileNode : public Node {
-public:
- OutputFileNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ OutputFileNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cpp b/source/blender/compositor/nodes/COM_PixelateNode.cpp
index 0db623866e8..be7747f3f14 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.cpp
+++ b/source/blender/compositor/nodes/COM_PixelateNode.cpp
@@ -23,23 +23,24 @@
PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void PixelateNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void PixelateNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
- DataType datatype = inputSocket->getDataType();
+ NodeInput *inputSocket = this->getInputSocket(0);
+ NodeOutput *outputSocket = this->getOutputSocket(0);
+ DataType datatype = inputSocket->getDataType();
- if (inputSocket->isLinked()) {
- NodeOutput *link = inputSocket->getLink();
- datatype = link->getDataType();
- }
+ if (inputSocket->isLinked()) {
+ NodeOutput *link = inputSocket->getLink();
+ datatype = link->getDataType();
+ }
- PixelateOperation *operation = new PixelateOperation(datatype);
- converter.addOperation(operation);
+ PixelateOperation *operation = new PixelateOperation(datatype);
+ converter.addOperation(operation);
- converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
- converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h
index 5738988672a..f46035398e2 100644
--- a/source/blender/compositor/nodes/COM_PixelateNode.h
+++ b/source/blender/compositor/nodes/COM_PixelateNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class PixelateNode : public Node {
-public:
- PixelateNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ PixelateNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
index 75bdf851f83..2285af01154 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.cpp
@@ -22,52 +22,53 @@
#include "COM_PlaneTrackOperation.h"
extern "C" {
-# include "BKE_node.h"
-# include "BKE_movieclip.h"
-# include "BKE_tracking.h"
+#include "BKE_node.h"
+#include "BKE_movieclip.h"
+#include "BKE_tracking.h"
}
PlaneTrackDeformNode::PlaneTrackDeformNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void PlaneTrackDeformNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void PlaneTrackDeformNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *editorNode = this->getbNode();
- MovieClip *clip = (MovieClip *) editorNode->id;
- NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *) editorNode->storage;
+ bNode *editorNode = this->getbNode();
+ MovieClip *clip = (MovieClip *)editorNode->id;
+ NodePlaneTrackDeformData *data = (NodePlaneTrackDeformData *)editorNode->storage;
- int frame_number = context.getFramenumber();
+ int frame_number = context.getFramenumber();
- NodeInput *input_image = this->getInputSocket(0);
- NodeOutput *output_warped_image = this->getOutputSocket(0);
- NodeOutput *output_plane = this->getOutputSocket(1);
+ 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);
+ 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());
+ 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);
+ 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());
+ converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
index b11daaf0abf..0d57163dc97 100644
--- a/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
+++ b/source/blender/compositor/nodes/COM_PlaneTrackDeformNode.h
@@ -19,8 +19,8 @@
#include "COM_Node.h"
extern "C" {
-# include "DNA_movieclip_types.h"
-# include "DNA_node_types.h"
+#include "DNA_movieclip_types.h"
+#include "DNA_node_types.h"
}
/**
@@ -28,7 +28,7 @@ extern "C" {
* \ingroup Node
*/
class PlaneTrackDeformNode : public Node {
-public:
- PlaneTrackDeformNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ PlaneTrackDeformNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
index e1897e09128..26f21713a77 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
@@ -27,7 +27,7 @@
RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
void RenderLayersNode::testSocketLink(NodeConverter &converter,
@@ -38,152 +38,138 @@ void RenderLayersNode::testSocketLink(NodeConverter &converter,
int layerId,
bool is_preview) const
{
- operation->setScene(scene);
- operation->setLayerId(layerId);
- operation->setRenderData(context.getRenderData());
- operation->setViewName(context.getViewName());
+ operation->setScene(scene);
+ operation->setLayerId(layerId);
+ operation->setRenderData(context.getRenderData());
+ operation->setViewName(context.getViewName());
- converter.mapOutputSocket(output, operation->getOutputSocket());
- converter.addOperation(operation);
+ converter.mapOutputSocket(output, operation->getOutputSocket());
+ converter.addOperation(operation);
- if (is_preview) /* only for image socket */
- converter.addPreview(operation->getOutputSocket());
+ 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 == NULL) {
- missingRenderLink(converter);
- return;
- }
- ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, layerId);
- if (view_layer == NULL) {
- missingRenderLink(converter);
- return;
- }
- RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
- if (rl == NULL) {
- 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 == NULL) {
- 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);
- }
+ Scene *scene = (Scene *)this->getbNode()->id;
+ const short layerId = this->getbNode()->custom1;
+ RenderResult *rr = RE_AcquireResultRead(re);
+ if (rr == NULL) {
+ missingRenderLink(converter);
+ return;
+ }
+ ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, layerId);
+ if (view_layer == NULL) {
+ missingRenderLink(converter);
+ return;
+ }
+ RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
+ if (rl == NULL) {
+ 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 == NULL) {
+ 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
+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;
- }
- }
+ 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);
+ 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);
- }
+ 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) : NULL;
+ Scene *scene = (Scene *)this->getbNode()->id;
+ Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
- if (re != NULL) {
- testRenderLink(converter, context, re);
- RE_ReleaseResult(re);
- }
- else {
- missingRenderLink(converter);
- }
+ if (re != NULL) {
+ testRenderLink(converter, context, re);
+ RE_ReleaseResult(re);
+ }
+ else {
+ missingRenderLink(converter);
+ }
}
diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h
index 50acb7aad42..7e574678f2b 100644
--- a/source/blender/compositor/nodes/COM_RenderLayersNode.h
+++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h
@@ -27,23 +27,22 @@ struct Render;
* \ingroup Node
*/
class RenderLayersNode : public Node {
-public:
- RenderLayersNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter,
- const CompositorContext &context) const;
-private:
- void testSocketLink(NodeConverter &converter,
- const CompositorContext &context,
- NodeOutput *output,
- RenderLayersProg *operation,
- Scene *scene,
- int layerId,
- bool is_preview) const;
- void testRenderLink(NodeConverter &converter,
- const CompositorContext &context,
- Render *re) const;
+ public:
+ RenderLayersNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
- void missingSocketLink(NodeConverter &converter,
- NodeOutput *output) const;
- void missingRenderLink(NodeConverter &converter) const;
+ private:
+ void testSocketLink(NodeConverter &converter,
+ const CompositorContext &context,
+ NodeOutput *output,
+ RenderLayersProg *operation,
+ Scene *scene,
+ int layerId,
+ bool is_preview) const;
+ void testRenderLink(NodeConverter &converter,
+ const CompositorContext &context,
+ Render *re) const;
+
+ void missingSocketLink(NodeConverter &converter, NodeOutput *output) const;
+ void missingRenderLink(NodeConverter &converter) const;
};
diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp
index d097d7b721f..e1c84ce3584 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.cpp
+++ b/source/blender/compositor/nodes/COM_RotateNode.cpp
@@ -24,23 +24,24 @@
RotateNode::RotateNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void RotateNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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.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));
+ 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.h b/source/blender/compositor/nodes/COM_RotateNode.h
index 2190ddd0b01..e7440bb7a8e 100644
--- a/source/blender/compositor/nodes/COM_RotateNode.h
+++ b/source/blender/compositor/nodes/COM_RotateNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class RotateNode : public Node {
-public:
- RotateNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ RotateNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp
index 61017f1a8e8..e47f673a8be 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.cpp
+++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp
@@ -26,88 +26,81 @@
ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ScaleNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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.getRenderData()->size / 100.0f);
- 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();
- 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 * rd->size / 100.0f);
- operation->setNewHeight(rd->ysch * rd->size / 100.0f);
- 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;
- }
- }
+ 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.getRenderData()->size / 100.0f);
+ 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();
+ 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 * rd->size / 100.0f);
+ operation->setNewHeight(rd->ysch * rd->size / 100.0f);
+ 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.h b/source/blender/compositor/nodes/COM_ScaleNode.h
index a58b81ed765..b6e589cfcec 100644
--- a/source/blender/compositor/nodes/COM_ScaleNode.h
+++ b/source/blender/compositor/nodes/COM_ScaleNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ScaleNode : public Node {
-public:
- ScaleNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ScaleNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
index 955994ec404..499b2fa96f9 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.cpp
@@ -20,96 +20,94 @@
#include "COM_ConvertOperation.h"
-
-SeparateColorNode::SeparateColorNode(bNode *editorNode) :
- Node(editorNode)
+SeparateColorNode::SeparateColorNode(bNode *editorNode) : Node(editorNode)
{
}
-void SeparateColorNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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));
- }
+ 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
+NodeOperation *SeparateRGBANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return NULL; /* no conversion needed */
+ return NULL; /* no conversion needed */
}
-NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *SeparateHSVANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return new ConvertRGBToHSVOperation();
+ return new ConvertRGBToHSVOperation();
}
-NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *SeparateYCCANode::getColorConverter(const CompositorContext & /*context*/) const
{
- ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
- bNode *editorNode = this->getbNode();
- operation->setMode(editorNode->custom1);
- return operation;
+ ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation();
+ bNode *editorNode = this->getbNode();
+ operation->setMode(editorNode->custom1);
+ return operation;
}
-NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext &/*context*/) const
+NodeOperation *SeparateYUVANode::getColorConverter(const CompositorContext & /*context*/) const
{
- return new ConvertRGBToYUVOperation();
+ return new ConvertRGBToYUVOperation();
}
diff --git a/source/blender/compositor/nodes/COM_SeparateColorNode.h b/source/blender/compositor/nodes/COM_SeparateColorNode.h
index 1238b02dfbb..f98a9d6d12f 100644
--- a/source/blender/compositor/nodes/COM_SeparateColorNode.h
+++ b/source/blender/compositor/nodes/COM_SeparateColorNode.h
@@ -22,48 +22,48 @@
#include "COM_Node.h"
class SeparateColorNode : public Node {
-public:
- SeparateColorNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SeparateColorNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-protected:
- virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
+ protected:
+ virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
};
class SeparateRGBANode : public SeparateColorNode {
-public:
- SeparateRGBANode(bNode *editorNode) :
- SeparateColorNode(editorNode)
- {}
+ public:
+ SeparateRGBANode(bNode *editorNode) : SeparateColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class SeparateHSVANode : public SeparateColorNode {
-public:
- SeparateHSVANode(bNode *editorNode) :
- SeparateColorNode(editorNode)
- {}
+ public:
+ SeparateHSVANode(bNode *editorNode) : SeparateColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class SeparateYCCANode : public SeparateColorNode {
-public:
- SeparateYCCANode(bNode *editorNode) :
- SeparateColorNode(editorNode)
- {}
+ public:
+ SeparateYCCANode(bNode *editorNode) : SeparateColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
class SeparateYUVANode : public SeparateColorNode {
-public:
- SeparateYUVANode(bNode *editorNode) :
- SeparateColorNode(editorNode)
- {}
+ public:
+ SeparateYUVANode(bNode *editorNode) : SeparateColorNode(editorNode)
+ {
+ }
- NodeOperation *getColorConverter(const CompositorContext &context) const;
+ NodeOperation *getColorConverter(const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
index 024970f296b..53454fedfe4 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp
@@ -20,17 +20,18 @@
#include "COM_SetAlphaOperation.h"
#include "COM_ExecutionSystem.h"
-void SetAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void SetAlphaNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- SetAlphaOperation *operation = new SetAlphaOperation();
+ SetAlphaOperation *operation = new SetAlphaOperation();
- if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) {
- operation->setResolutionInputSocketIndex(1);
- }
+ if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) {
+ operation->setResolutionInputSocketIndex(1);
+ }
- converter.addOperation(operation);
+ converter.addOperation(operation);
- converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
- converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
- converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
+ 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.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h
index 03d955cc8d3..9882b3e62e9 100644
--- a/source/blender/compositor/nodes/COM_SetAlphaNode.h
+++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h
@@ -26,9 +26,11 @@
* \ingroup Node
*/
class SetAlphaNode : public Node {
-public:
- SetAlphaNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SetAlphaNode(bNode *editorNode) : Node(editorNode)
+ {
+ }
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index 0b6e8b2f3f4..d924d2ce9f8 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -25,57 +25,71 @@
#include "COM_WriteBufferOperation.h"
#include "COM_ReadBufferOperation.h"
-SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion) :
- Node(editorNode, false),
- m_use_conversion(use_conversion)
+SocketProxyNode::SocketProxyNode(bNode *editorNode,
+ bNodeSocket *editorInput,
+ bNodeSocket *editorOutput,
+ bool use_conversion)
+ : Node(editorNode, false), m_use_conversion(use_conversion)
{
- DataType dt;
+ 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 (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);
+ 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
+void SocketProxyNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion);
- converter.mapOutputSocket(getOutputSocket(), proxy_output);
+ 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)
+SocketBufferNode::SocketBufferNode(bNode *editorNode,
+ bNodeSocket *editorInput,
+ bNodeSocket *editorOutput)
+ : Node(editorNode, false)
{
- DataType dt;
+ 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 (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);
+ 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
+void SocketBufferNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeOutput *output = this->getOutputSocket(0);
- NodeInput *input = this->getInputSocket(0);
+ 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);
+ 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());
+ converter.mapInputSocket(input, writeOperation->getInputSocket(0));
+ converter.mapOutputSocket(output, readOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index 6e288e59797..21e888d323e 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -26,23 +26,31 @@
* \ingroup Node
*/
class SocketProxyNode : public Node {
-public:
- SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
- bool getUseConversion() const { return m_use_conversion; }
- void setUseConversion(bool use_conversion) { m_use_conversion = use_conversion; }
-
-private:
- /** If true, the proxy will convert input and output data to/from the proxy socket types. */
- bool m_use_conversion;
+ public:
+ SocketProxyNode(bNode *editorNode,
+ bNodeSocket *editorInput,
+ bNodeSocket *editorOutput,
+ bool use_conversion);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+
+ bool getUseConversion() const
+ {
+ return m_use_conversion;
+ }
+ void setUseConversion(bool use_conversion)
+ {
+ m_use_conversion = use_conversion;
+ }
+
+ private:
+ /** If true, the proxy will convert input and output data to/from the proxy socket types. */
+ bool m_use_conversion;
};
-
class SocketBufferNode : public Node {
-public:
- SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SocketBufferNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
index a736000ead7..b44f82f71d0 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp
@@ -27,46 +27,48 @@
SplitViewerNode::SplitViewerNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void SplitViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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;
+ 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);
+ 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));
+ 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());
+ 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);
+ /* 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.addOperation(viewerOperation);
+ converter.addLink(splitViewerOperation->getOutputSocket(), viewerOperation->getInputSocket(0));
- converter.addPreview(splitViewerOperation->getOutputSocket());
+ converter.addPreview(splitViewerOperation->getOutputSocket());
- if (do_output)
- converter.registerViewer(viewerOperation);
+ if (do_output)
+ converter.registerViewer(viewerOperation);
}
diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h
index aedb805a36a..2e350720841 100644
--- a/source/blender/compositor/nodes/COM_SplitViewerNode.h
+++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class SplitViewerNode : public Node {
-public:
- SplitViewerNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SplitViewerNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
index 3dd7656e3f5..cc14d8d952f 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
@@ -25,74 +25,75 @@
#include "COM_SetSamplerOperation.h"
extern "C" {
-# include "DNA_movieclip_types.h"
-# include "BKE_tracking.h"
+#include "DNA_movieclip_types.h"
+#include "BKE_tracking.h"
}
Stabilize2dNode::Stabilize2dNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void Stabilize2dNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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;
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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.addOperation(scaleAttribute);
+ converter.addOperation(angleAttribute);
+ converter.addOperation(xAttribute);
+ converter.addOperation(yAttribute);
+ converter.addOperation(scaleOperation);
+ converter.addOperation(translateOperation);
+ converter.addOperation(rotateOperation);
+ converter.addOperation(psoperation);
- converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
- converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
- converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
+ converter.mapInputSocket(imageInput, scaleOperation->getInputSocket(0));
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1));
+ converter.addLink(scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2));
- converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
- converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
+ converter.addLink(scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0));
+ converter.addLink(angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1));
- converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
- converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
- converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
+ converter.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ converter.addLink(xAttribute->getOutputSocket(), translateOperation->getInputSocket(1));
+ converter.addLink(yAttribute->getOutputSocket(), translateOperation->getInputSocket(2));
- converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
- converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
+ converter.addLink(translateOperation->getOutputSocket(), psoperation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(), psoperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
index a17f1b0a7e1..bbf7b239d82 100644
--- a/source/blender/compositor/nodes/COM_Stabilize2dNode.h
+++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h
@@ -27,9 +27,9 @@
* \ingroup Node
*/
class Stabilize2dNode : public Node {
-public:
- Stabilize2dNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ Stabilize2dNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SunBeamsNode.cpp b/source/blender/compositor/nodes/COM_SunBeamsNode.cpp
index 31c8770792c..d899a54c03c 100644
--- a/source/blender/compositor/nodes/COM_SunBeamsNode.cpp
+++ b/source/blender/compositor/nodes/COM_SunBeamsNode.cpp
@@ -20,19 +20,20 @@
SunBeamsNode::SunBeamsNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void SunBeamsNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void SunBeamsNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *inputSocket = this->getInputSocket(0);
- NodeOutput *outputSocket = this->getOutputSocket(0);
- NodeSunBeams *data = (NodeSunBeams *)getbNode()->storage;
+ 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);
+ SunBeamsOperation *operation = new SunBeamsOperation();
+ operation->setData(*data);
+ converter.addOperation(operation);
- converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
- converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
+ converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
+ converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_SunBeamsNode.h b/source/blender/compositor/nodes/COM_SunBeamsNode.h
index 065454f5969..9d35f40f760 100644
--- a/source/blender/compositor/nodes/COM_SunBeamsNode.h
+++ b/source/blender/compositor/nodes/COM_SunBeamsNode.h
@@ -25,9 +25,9 @@
* \ingroup Node
*/
class SunBeamsNode : public Node {
-public:
- SunBeamsNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SunBeamsNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index c106dd8fc59..342f6bc159c 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -20,18 +20,19 @@
SwitchNode::SwitchNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void SwitchNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void SwitchNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- bool condition = this->getbNode()->custom1;
+ bool condition = this->getbNode()->custom1;
- NodeOperationOutput *result;
- if (!condition)
- result = converter.addInputProxy(getInputSocket(0), false);
- else
- result = converter.addInputProxy(getInputSocket(1), false);
+ NodeOperationOutput *result;
+ if (!condition)
+ result = converter.addInputProxy(getInputSocket(0), false);
+ else
+ result = converter.addInputProxy(getInputSocket(1), false);
- converter.mapOutputSocket(getOutputSocket(0), result);
+ converter.mapOutputSocket(getOutputSocket(0), result);
}
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h
index 7a2387fba66..509b748b18a 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchNode.h
@@ -27,8 +27,8 @@
* \ingroup Node
*/
class SwitchNode : public Node {
-public:
- SwitchNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SwitchNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_SwitchViewNode.cpp b/source/blender/compositor/nodes/COM_SwitchViewNode.cpp
index 45df513a383..e4a946e2e9d 100644
--- a/source/blender/compositor/nodes/COM_SwitchViewNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchViewNode.cpp
@@ -21,19 +21,20 @@
SwitchViewNode::SwitchViewNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void SwitchViewNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void SwitchViewNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- NodeOperationOutput *result;
- const char *viewName = context.getViewName();
- bNode *bnode = this->getbNode();
+ 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 = max(nr, 0);
+ /* get the internal index of the socket with a matching name */
+ int nr = BLI_findstringindex(&bnode->inputs, viewName, offsetof(bNodeSocket, name));
+ nr = max(nr, 0);
- result = converter.addInputProxy(getInputSocket(nr), false);
- converter.mapOutputSocket(getOutputSocket(0), result);
+ result = converter.addInputProxy(getInputSocket(nr), false);
+ converter.mapOutputSocket(getOutputSocket(0), result);
}
diff --git a/source/blender/compositor/nodes/COM_SwitchViewNode.h b/source/blender/compositor/nodes/COM_SwitchViewNode.h
index 92ae3fafffa..0260621961d 100644
--- a/source/blender/compositor/nodes/COM_SwitchViewNode.h
+++ b/source/blender/compositor/nodes/COM_SwitchViewNode.h
@@ -27,8 +27,8 @@
* \ingroup Node
*/
class SwitchViewNode : public Node {
-public:
- SwitchViewNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ SwitchViewNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp
index adf1333e226..3381b5098d7 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.cpp
+++ b/source/blender/compositor/nodes/COM_TextureNode.cpp
@@ -22,34 +22,35 @@
TextureNode::TextureNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void TextureNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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);
+ 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.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(1), operation->getOutputSocket());
- converter.addPreview(operation->getOutputSocket());
+ converter.addPreview(operation->getOutputSocket());
- TextureAlphaOperation *alphaOperation = new TextureAlphaOperation();
- alphaOperation->setTexture(texture);
- alphaOperation->setRenderData(context.getRenderData());
- alphaOperation->setSceneColorManage(sceneColorManage);
- converter.addOperation(alphaOperation);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_TextureNode.h
index 19285d98127..026d42ce2c3 100644
--- a/source/blender/compositor/nodes/COM_TextureNode.h
+++ b/source/blender/compositor/nodes/COM_TextureNode.h
@@ -24,7 +24,7 @@
* \ingroup Node
*/
class TextureNode : public Node {
-public:
- TextureNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ TextureNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp
index 8eb7848ba6c..45604882992 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.cpp
+++ b/source/blender/compositor/nodes/COM_TimeNode.cpp
@@ -20,38 +20,39 @@
#include "COM_SetValueOperation.h"
#include "COM_ExecutionSystem.h"
extern "C" {
-# include "BKE_colortools.h"
+#include "BKE_colortools.h"
}
#include "BLI_utildefines.h"
TimeNode::TimeNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void TimeNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void TimeNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- SetValueOperation *operation = new SetValueOperation();
- bNode *node = this->getbNode();
+ SetValueOperation *operation = new SetValueOperation();
+ bNode *node = this->getbNode();
- /* stack order output: fac */
- float fac = 0.0f;
- const int framenumber = context.getFramenumber();
+ /* 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);
- }
+ 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);
+ }
- curvemapping_initialize((CurveMapping *)node->storage);
- fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
- operation->setValue(clamp_f(fac, 0.0f, 1.0f));
- converter.addOperation(operation);
+ curvemapping_initialize((CurveMapping *)node->storage);
+ fac = 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());
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h
index 5f46a6e0dae..230ffe3b676 100644
--- a/source/blender/compositor/nodes/COM_TimeNode.h
+++ b/source/blender/compositor/nodes/COM_TimeNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class TimeNode : public Node {
-public:
- TimeNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ TimeNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp
index f6294161cec..2b13a6519e3 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.cpp
+++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp
@@ -22,17 +22,19 @@
TonemapNode::TonemapNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void TonemapNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void TonemapNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
+ NodeTonemap *data = (NodeTonemap *)this->getbNode()->storage;
- TonemapOperation *operation = data->type == 1 ? new PhotoreceptorTonemapOperation() : new TonemapOperation();
- operation->setData(data);
- converter.addOperation(operation);
+ 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));
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
}
diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h
index 17392da1eff..9e6c01a5e45 100644
--- a/source/blender/compositor/nodes/COM_TonemapNode.h
+++ b/source/blender/compositor/nodes/COM_TonemapNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class TonemapNode : public Node {
-public:
- TonemapNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ TonemapNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
index 7c9cd395890..da9f50a590b 100644
--- a/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
+++ b/source/blender/compositor/nodes/COM_TrackPositionNode.cpp
@@ -23,14 +23,14 @@
#include "COM_TrackPositionOperation.h"
extern "C" {
-# include "DNA_movieclip_types.h"
+#include "DNA_movieclip_types.h"
-# include "BKE_node.h"
+#include "BKE_node.h"
}
TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
static TrackPositionOperation *create_motion_operation(NodeConverter &converter,
@@ -40,77 +40,74 @@ static TrackPositionOperation *create_motion_operation(NodeConverter &converter,
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;
+ 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
+void TrackPositionNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *editorNode = this->getbNode();
- MovieClip *clip = (MovieClip *) editorNode->id;
- NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage;
+ 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);
+ 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();
- }
+ 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 *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 *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);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_TrackPositionNode.h
index 8b911fb2397..c9420764598 100644
--- a/source/blender/compositor/nodes/COM_TrackPositionNode.h
+++ b/source/blender/compositor/nodes/COM_TrackPositionNode.h
@@ -24,8 +24,7 @@
* \ingroup Node
*/
class TrackPositionNode : public Node {
-public:
- TrackPositionNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
-
+ public:
+ TrackPositionNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp
index 45c65c04eba..738039fc255 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.cpp
+++ b/source/blender/compositor/nodes/COM_TransformNode.cpp
@@ -26,42 +26,43 @@
TransformNode::TransformNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void TransformNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ 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);
+ ScaleOperation *scaleOperation = new ScaleOperation();
+ converter.addOperation(scaleOperation);
- RotateOperation *rotateOperation = new RotateOperation();
- rotateOperation->setDoDegree2RadConversion(false);
- converter.addOperation(rotateOperation);
+ RotateOperation *rotateOperation = new RotateOperation();
+ rotateOperation->setDoDegree2RadConversion(false);
+ converter.addOperation(rotateOperation);
- TranslateOperation *translateOperation = new TranslateOperation();
- converter.addOperation(translateOperation);
+ TranslateOperation *translateOperation = new TranslateOperation();
+ converter.addOperation(translateOperation);
- SetSamplerOperation *sampler = new SetSamplerOperation();
- sampler->setSampler((PixelSampler)this->getbNode()->custom1);
- converter.addOperation(sampler);
+ 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.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(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.addLink(rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0));
+ converter.mapInputSocket(xInput, translateOperation->getInputSocket(1));
+ converter.mapInputSocket(yInput, translateOperation->getInputSocket(2));
- converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket());
+ converter.mapOutputSocket(getOutputSocket(), translateOperation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h
index de6dee271b2..12eb66a19bb 100644
--- a/source/blender/compositor/nodes/COM_TransformNode.h
+++ b/source/blender/compositor/nodes/COM_TransformNode.h
@@ -27,9 +27,9 @@
* \ingroup Node
*/
class TransformNode : public Node {
-public:
- TransformNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ TransformNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
-#endif /* __COM_TRANSFORMNODE_H__ */
+#endif /* __COM_TRANSFORMNODE_H__ */
diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp
index a09f972dfec..8fed5c9b003 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.cpp
+++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp
@@ -25,45 +25,46 @@
TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void TranslateNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void TranslateNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *bnode = this->getbNode();
- NodeTranslateData *data = (NodeTranslateData *)bnode->storage;
+ 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);
+ 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();
- float fx = rd->xsch * rd->size / 100.0f;
- float fy = rd->ysch * rd->size / 100.0f;
+ TranslateOperation *operation = new TranslateOperation();
+ if (data->relative) {
+ const RenderData *rd = context.getRenderData();
+ float fx = rd->xsch * rd->size / 100.0f;
+ float fy = rd->ysch * rd->size / 100.0f;
- operation->setFactorXY(fx, fy);
- }
+ 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));
+ 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);
+ 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));
- }
+ 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.h b/source/blender/compositor/nodes/COM_TranslateNode.h
index 9a13906adde..d9ef6c639a0 100644
--- a/source/blender/compositor/nodes/COM_TranslateNode.h
+++ b/source/blender/compositor/nodes/COM_TranslateNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class TranslateNode : public Node {
-public:
- TranslateNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ TranslateNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp
index 207598d0c99..f9769c3709a 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.cpp
+++ b/source/blender/compositor/nodes/COM_ValueNode.cpp
@@ -22,15 +22,16 @@
ValueNode::ValueNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ValueNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+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);
+ SetValueOperation *operation = new SetValueOperation();
+ NodeOutput *output = this->getOutputSocket(0);
+ operation->setValue(output->getEditorValueFloat());
+ converter.addOperation(operation);
- converter.mapOutputSocket(output, operation->getOutputSocket());
+ converter.mapOutputSocket(output, operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h
index 870debf95ab..a973649aa46 100644
--- a/source/blender/compositor/nodes/COM_ValueNode.h
+++ b/source/blender/compositor/nodes/COM_ValueNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ValueNode : public Node {
-public:
- ValueNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ValueNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
index 776fa66acf5..4ff2f3ddfb1 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -22,21 +22,22 @@
VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void VectorBlurNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void VectorBlurNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- bNode *node = this->getbNode();
- NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
+ bNode *node = this->getbNode();
+ NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
- VectorBlurOperation *operation = new VectorBlurOperation();
- operation->setVectorBlurSettings(vectorBlurSettings);
- operation->setQuality(context.getQuality());
- converter.addOperation(operation);
+ 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());
+ 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.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h
index 9533de11b77..027c241f72d 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.h
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class VectorBlurNode : public Node {
-public:
- VectorBlurNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ VectorBlurNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
index 81dac70b8fc..4f8485a430b 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp
@@ -22,15 +22,16 @@
VectorCurveNode::VectorCurveNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void VectorCurveNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void VectorCurveNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- VectorCurveOperation *operation = new VectorCurveOperation();
- operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
- converter.addOperation(operation);
+ 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());
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
}
diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h
index 8495bf51e51..14bea25cf8d 100644
--- a/source/blender/compositor/nodes/COM_VectorCurveNode.h
+++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class VectorCurveNode : public Node {
-public:
- VectorCurveNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ VectorCurveNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
index 935ffb6e005..b6c12365ce0 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp
@@ -24,37 +24,38 @@
ViewLevelsNode::ViewLevelsNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ViewLevelsNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
+void ViewLevelsNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
{
- NodeInput *input = this->getInputSocket(0);
- if (input->isLinked()) {
- // add preview to inputSocket;
+ NodeInput *input = this->getInputSocket(0);
+ if (input->isLinked()) {
+ // add preview to inputSocket;
- /* calculate mean operation */
- {
- CalculateMeanOperation *operation = new CalculateMeanOperation();
- operation->setSetting(this->getbNode()->custom1);
+ /* 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());
- }
+ 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);
+ /* 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);
- }
+ 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.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
index 0973e8d0edb..851b1ecbd78 100644
--- a/source/blender/compositor/nodes/COM_ViewLevelsNode.h
+++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h
@@ -26,9 +26,9 @@
* \ingroup Node
*/
class ViewLevelsNode : public Node {
-public:
- ViewLevelsNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ViewLevelsNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp
index 0aae047689d..08f3be27c55 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.cpp
+++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp
@@ -27,53 +27,55 @@
ViewerNode::ViewerNode(bNode *editorNode) : Node(editorNode)
{
- /* pass */
+ /* pass */
}
-void ViewerNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+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;
+ 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());
+ 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->setViewSettings(context.getViewSettings());
+ viewerOperation->setDisplaySettings(context.getDisplaySettings());
- viewerOperation->setResolutionInputSocketIndex(0);
- if (!imageSocket->isLinked()) {
- if (alphaSocket->isLinked()) {
- viewerOperation->setResolutionInputSocketIndex(1);
- }
- }
+ 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.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);
+ converter.addNodeInputPreview(imageSocket);
- if (do_output)
- converter.registerViewer(viewerOperation);
+ if (do_output)
+ converter.registerViewer(viewerOperation);
}
diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h
index 3d6aabe2250..6168623e69c 100644
--- a/source/blender/compositor/nodes/COM_ViewerNode.h
+++ b/source/blender/compositor/nodes/COM_ViewerNode.h
@@ -26,8 +26,8 @@
* \ingroup Node
*/
class ViewerNode : public Node {
-public:
- ViewerNode(bNode *editorNode);
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ViewerNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
index 00b86c0f1e0..4faf828d6df 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.cpp
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp
@@ -26,73 +26,76 @@
#include "COM_AntiAliasOperation.h"
#include "COM_MixOperation.h"
-#include "DNA_material_types.h" // the ramp types
+#include "DNA_material_types.h" // the ramp types
-void ZCombineNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
+void ZCombineNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext &context) const
{
- if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
- ZCombineOperation *operation = NULL;
- 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());
- }
+ if ((context.getRenderData()->scemode & R_FULL_SAMPLE) || this->getbNode()->custom2) {
+ ZCombineOperation *operation = NULL;
+ 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.h b/source/blender/compositor/nodes/COM_ZCombineNode.h
index d5a7b4d3f1e..95e81ca8c8f 100644
--- a/source/blender/compositor/nodes/COM_ZCombineNode.h
+++ b/source/blender/compositor/nodes/COM_ZCombineNode.h
@@ -26,9 +26,11 @@
* \ingroup Node
*/
class ZCombineNode : public Node {
-public:
- ZCombineNode(bNode *editorNode) : Node(editorNode) {}
- void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+ public:
+ ZCombineNode(bNode *editorNode) : Node(editorNode)
+ {
+ }
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
index 8c483f9ff23..1be5ef1f2df 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.cpp
@@ -20,32 +20,35 @@
AlphaOverKeyOperation::AlphaOverKeyOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void AlphaOverKeyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverKeyOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputOverColor[4];
- float value[4];
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
- this->m_inputValueOperation->readSampled(value, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
- if (inputOverColor[3] <= 0.0f) {
- copy_v4_v4(output, inputColor1);
- }
- else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- copy_v4_v4(output, inputOverColor);
- }
- else {
- float premul = value[0] * inputOverColor[3];
- float mul = 1.0f - premul;
+ if (inputOverColor[3] <= 0.0f) {
+ copy_v4_v4(output, inputColor1);
+ }
+ else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
+ copy_v4_v4(output, inputOverColor);
+ }
+ else {
+ float premul = value[0] * inputOverColor[3];
+ float mul = 1.0f - premul;
- output[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
- output[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
- output[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
- output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
- }
+ output[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
+ output[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
+ output[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
+ output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
index 85b9ceed6be..a4475bc2fbc 100644
--- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h
@@ -20,21 +20,20 @@
#define __COM_ALPHAOVERKEYOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class AlphaOverKeyOperation : public MixBaseOperation {
-public:
- /**
- * Default constructor
- */
- AlphaOverKeyOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ AlphaOverKeyOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
index 0c7738e6c23..513158dcff6 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.cpp
@@ -20,33 +20,36 @@
AlphaOverMixedOperation::AlphaOverMixedOperation() : MixBaseOperation()
{
- this->m_x = 0.0f;
+ this->m_x = 0.0f;
}
-void AlphaOverMixedOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverMixedOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputOverColor[4];
- float value[4];
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
- this->m_inputValueOperation->readSampled(value, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
- if (inputOverColor[3] <= 0.0f) {
- copy_v4_v4(output, inputColor1);
- }
- else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- copy_v4_v4(output, inputOverColor);
- }
- else {
- float addfac = 1.0f - this->m_x + inputOverColor[3] * this->m_x;
- float premul = value[0] * addfac;
- float mul = 1.0f - value[0] * inputOverColor[3];
+ if (inputOverColor[3] <= 0.0f) {
+ copy_v4_v4(output, inputColor1);
+ }
+ else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
+ copy_v4_v4(output, inputOverColor);
+ }
+ else {
+ float addfac = 1.0f - this->m_x + inputOverColor[3] * this->m_x;
+ float premul = value[0] * addfac;
+ float mul = 1.0f - value[0] * inputOverColor[3];
- output[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
- output[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
- output[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
- output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
- }
+ output[0] = (mul * inputColor1[0]) + premul * inputOverColor[0];
+ output[1] = (mul * inputColor1[1]) + premul * inputOverColor[1];
+ output[2] = (mul * inputColor1[2]) + premul * inputOverColor[2];
+ output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
index 118aa426404..88fa3d963f4 100644
--- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h
@@ -20,25 +20,28 @@
#define __COM_ALPHAOVERMIXEDOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class AlphaOverMixedOperation : public MixBaseOperation {
-private:
- float m_x;
-public:
- /**
- * Default constructor
- */
- AlphaOverMixedOperation();
+ private:
+ float m_x;
+
+ public:
+ /**
+ * Default constructor
+ */
+ AlphaOverMixedOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void setX(float x) { this->m_x = x; }
+ void setX(float x)
+ {
+ this->m_x = x;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
index f482814481d..8e5bce7221f 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.cpp
@@ -20,32 +20,35 @@
AlphaOverPremultiplyOperation::AlphaOverPremultiplyOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void AlphaOverPremultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void AlphaOverPremultiplyOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputOverColor[4];
- float value[4];
+ float inputColor1[4];
+ float inputOverColor[4];
+ float value[4];
- this->m_inputValueOperation->readSampled(value, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputOverColor, x, y, sampler);
- /* Zero alpha values should still permit an add of RGB data */
- if (inputOverColor[3] < 0.0f) {
- copy_v4_v4(output, inputColor1);
- }
- else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
- copy_v4_v4(output, inputOverColor);
- }
- else {
- float mul = 1.0f - value[0] * inputOverColor[3];
+ /* Zero alpha values should still permit an add of RGB data */
+ if (inputOverColor[3] < 0.0f) {
+ copy_v4_v4(output, inputColor1);
+ }
+ else if (value[0] == 1.0f && inputOverColor[3] >= 1.0f) {
+ copy_v4_v4(output, inputOverColor);
+ }
+ else {
+ float mul = 1.0f - value[0] * inputOverColor[3];
- output[0] = (mul * inputColor1[0]) + value[0] * inputOverColor[0];
- output[1] = (mul * inputColor1[1]) + value[0] * inputOverColor[1];
- output[2] = (mul * inputColor1[2]) + value[0] * inputOverColor[2];
- output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
- }
+ output[0] = (mul * inputColor1[0]) + value[0] * inputOverColor[0];
+ output[1] = (mul * inputColor1[1]) + value[0] * inputOverColor[1];
+ output[2] = (mul * inputColor1[2]) + value[0] * inputOverColor[2];
+ output[3] = (mul * inputColor1[3]) + value[0] * inputOverColor[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
index bf0e53c87e4..4ef5f9d996e 100644
--- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
+++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h
@@ -20,22 +20,20 @@
#define __COM_ALPHAOVERPREMULTIPLYOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class AlphaOverPremultiplyOperation : public MixBaseOperation {
-public:
- /**
- * Default constructor
- */
- AlphaOverPremultiplyOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Default constructor
+ */
+ AlphaOverPremultiplyOperation();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
index a33fe6bcdb0..94514c64e08 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp
@@ -23,126 +23,165 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_render_ext.h"
+#include "RE_render_ext.h"
}
-
/* An implementation of the Scale3X edge-extrapolation algorithm.
*
* Code from GIMP plugin, based on code from Adam D. Moss (adam@gimp.org)
* licensed by the MIT license.
*/
-static int extrapolate9(float *E0, float *E1, float *E2,
- float *E3, float *E4, float *E5,
- float *E6, float *E7, float *E8,
- const float *A, const float *B, const float *C,
- const float *D, const float *E, const float *F,
- const float *G, const float *H, const float *I)
+static int extrapolate9(float *E0,
+ float *E1,
+ float *E2,
+ float *E3,
+ float *E4,
+ float *E5,
+ float *E6,
+ float *E7,
+ float *E8,
+ const float *A,
+ const float *B,
+ const float *C,
+ const float *D,
+ const float *E,
+ const float *F,
+ const float *G,
+ const float *H,
+ const float *I)
{
#define PEQ(X, Y) (fabsf(*X - *Y) < 1e-3f)
-#define PCPY(DST, SRC) do { *DST = *SRC; } while (0)
- if ((!PEQ(B, H)) && (!PEQ(D, F))) {
- if (PEQ(D, B)) PCPY(E0, D); else PCPY(E0, E);
- if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
- PCPY(E1, B); else PCPY(E1, E);
- if (PEQ(B, F)) PCPY(E2, F); else PCPY(E2, E);
- if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
- PCPY(E3, D); else PCPY(E3, E);
- PCPY(E4, E);
- if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
- PCPY(E5, F); else PCPY(E5, E);
- if (PEQ(D, H)) PCPY(E6, D); else PCPY(E6, E);
- if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
- PCPY(E7, H); else PCPY(E7, E);
- if (PEQ(H, F)) PCPY(E8, F); else PCPY(E8, E);
- return 1;
- }
- else {
- return 0;
- }
+#define PCPY(DST, SRC) \
+ do { \
+ *DST = *SRC; \
+ } while (0)
+ if ((!PEQ(B, H)) && (!PEQ(D, F))) {
+ if (PEQ(D, B))
+ PCPY(E0, D);
+ else
+ PCPY(E0, E);
+ if ((PEQ(D, B) && !PEQ(E, C)) || (PEQ(B, F) && !PEQ(E, A)))
+ PCPY(E1, B);
+ else
+ PCPY(E1, E);
+ if (PEQ(B, F))
+ PCPY(E2, F);
+ else
+ PCPY(E2, E);
+ if ((PEQ(D, B) && !PEQ(E, G)) || (PEQ(D, H) && !PEQ(E, A)))
+ PCPY(E3, D);
+ else
+ PCPY(E3, E);
+ PCPY(E4, E);
+ if ((PEQ(B, F) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, C)))
+ PCPY(E5, F);
+ else
+ PCPY(E5, E);
+ if (PEQ(D, H))
+ PCPY(E6, D);
+ else
+ PCPY(E6, E);
+ if ((PEQ(D, H) && !PEQ(E, I)) || (PEQ(H, F) && !PEQ(E, G)))
+ PCPY(E7, H);
+ else
+ PCPY(E7, E);
+ if (PEQ(H, F))
+ PCPY(E8, F);
+ else
+ PCPY(E8, E);
+ return 1;
+ }
+ else {
+ return 0;
+ }
#undef PEQ
#undef PCPY
}
AntiAliasOperation::AntiAliasOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_valueReader = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_valueReader = NULL;
+ this->setComplex(true);
}
void AntiAliasOperation::initExecution()
{
- this->m_valueReader = this->getInputSocketReader(0);
+ this->m_valueReader = this->getInputSocketReader(0);
}
-void AntiAliasOperation::executePixel(float output[4],
- int x, int y,
- void *data)
+void AntiAliasOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *input_buffer = (MemoryBuffer *)data;
- const int buffer_width = input_buffer->getWidth(),
- buffer_height = input_buffer->getHeight();
- if (y < 0 || y >= buffer_height || x < 0 || x >= buffer_width) {
- output[0] = 0.0f;
- }
- else {
- const float *buffer = input_buffer->getBuffer();
- const float *row_curr = &buffer[y * buffer_width];
- if (x == 0 || x == buffer_width - 1 ||
- y == 0 || y == buffer_height - 1)
- {
- output[0] = row_curr[x];
- return;
- }
- const float *row_prev = &buffer[(y - 1) * buffer_width],
- *row_next = &buffer[(y + 1) * buffer_width];
- float ninepix[9];
- if (extrapolate9(&ninepix[0], &ninepix[1], &ninepix[2],
- &ninepix[3], &ninepix[4], &ninepix[5],
- &ninepix[6], &ninepix[7], &ninepix[8],
- &row_prev[x - 1], &row_prev[x], &row_prev[x + 1],
- &row_curr[x - 1], &row_curr[x], &row_curr[x + 1],
- &row_next[x - 1], &row_next[x], &row_next[x + 1]))
- {
- /* Some rounding magic to so make weighting correct with the
- * original coefficients.
- */
- unsigned char result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] +
- 5 * ninepix[3] + 6 * ninepix[4] + 5 * ninepix[5] +
- 3 * ninepix[6] + 5 * ninepix[7] + 3 * ninepix[8]) * 255.0f +
- 19.0f) / 38.0f;
- output[0] = result / 255.0f;
- }
- else {
- output[0] = row_curr[x];
- }
- }
+ MemoryBuffer *input_buffer = (MemoryBuffer *)data;
+ const int buffer_width = input_buffer->getWidth(), buffer_height = input_buffer->getHeight();
+ if (y < 0 || y >= buffer_height || x < 0 || x >= buffer_width) {
+ output[0] = 0.0f;
+ }
+ else {
+ const float *buffer = input_buffer->getBuffer();
+ const float *row_curr = &buffer[y * buffer_width];
+ if (x == 0 || x == buffer_width - 1 || y == 0 || y == buffer_height - 1) {
+ output[0] = row_curr[x];
+ return;
+ }
+ const float *row_prev = &buffer[(y - 1) * buffer_width],
+ *row_next = &buffer[(y + 1) * buffer_width];
+ float ninepix[9];
+ if (extrapolate9(&ninepix[0],
+ &ninepix[1],
+ &ninepix[2],
+ &ninepix[3],
+ &ninepix[4],
+ &ninepix[5],
+ &ninepix[6],
+ &ninepix[7],
+ &ninepix[8],
+ &row_prev[x - 1],
+ &row_prev[x],
+ &row_prev[x + 1],
+ &row_curr[x - 1],
+ &row_curr[x],
+ &row_curr[x + 1],
+ &row_next[x - 1],
+ &row_next[x],
+ &row_next[x + 1])) {
+ /* Some rounding magic to so make weighting correct with the
+ * original coefficients.
+ */
+ unsigned char result = ((3 * ninepix[0] + 5 * ninepix[1] + 3 * ninepix[2] + 5 * ninepix[3] +
+ 6 * ninepix[4] + 5 * ninepix[5] + 3 * ninepix[6] + 5 * ninepix[7] +
+ 3 * ninepix[8]) *
+ 255.0f +
+ 19.0f) /
+ 38.0f;
+ output[0] = result / 255.0f;
+ }
+ else {
+ output[0] = row_curr[x];
+ }
+ }
}
void AntiAliasOperation::deinitExecution()
{
- this->m_valueReader = NULL;
+ this->m_valueReader = NULL;
}
-bool AntiAliasOperation::determineDependingAreaOfInterest(
- rcti *input,
- ReadBufferOperation *readOperation,
- rcti *output)
+bool AntiAliasOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti imageInput;
- NodeOperation *operation = getInputOperation(0);
- imageInput.xmax = input->xmax + 1;
- imageInput.xmin = input->xmin - 1;
- imageInput.ymax = input->ymax + 1;
- imageInput.ymin = input->ymin - 1;
- return operation->determineDependingAreaOfInterest(&imageInput,
- readOperation,
- output);
+ rcti imageInput;
+ NodeOperation *operation = getInputOperation(0);
+ imageInput.xmax = input->xmax + 1;
+ imageInput.xmin = input->xmin - 1;
+ imageInput.ymax = input->ymax + 1;
+ imageInput.ymin = input->ymin - 1;
+ return operation->determineDependingAreaOfInterest(&imageInput, readOperation, output);
}
void *AntiAliasOperation::initializeTileData(rcti *rect)
{
- return getInputOperation(0)->initializeTileData(rect);
+ return getInputOperation(0)->initializeTileData(rect);
}
diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.h b/source/blender/compositor/operations/COM_AntiAliasOperation.h
index d589be8a7dd..6141fb92c3f 100644
--- a/source/blender/compositor/operations/COM_AntiAliasOperation.h
+++ b/source/blender/compositor/operations/COM_AntiAliasOperation.h
@@ -27,30 +27,33 @@
* \ingroup operation
*/
class AntiAliasOperation : public NodeOperation {
-protected:
- /**
- * \brief Cached reference to the reader
- */
- SocketReader *m_valueReader;
-public:
- AntiAliasOperation();
+ protected:
+ /**
+ * \brief Cached reference to the reader
+ */
+ SocketReader *m_valueReader;
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ AntiAliasOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- void *initializeTileData(rcti *rect);
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void *initializeTileData(rcti *rect);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index f866eac8ae3..5628c575b70 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -20,93 +20,96 @@
#include "BLI_math.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
BilateralBlurOperation::BilateralBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
- this->m_inputColorProgram = NULL;
- this->m_inputDeterminatorProgram = NULL;
+ this->m_inputColorProgram = NULL;
+ this->m_inputDeterminatorProgram = NULL;
}
void BilateralBlurOperation::initExecution()
{
- this->m_inputColorProgram = getInputSocketReader(0);
- this->m_inputDeterminatorProgram = getInputSocketReader(1);
- this->m_space = this->m_data->sigma_space + this->m_data->iter;
- QualityStepHelper::initExecution(COM_QH_INCREASE);
+ this->m_inputColorProgram = getInputSocketReader(0);
+ this->m_inputDeterminatorProgram = getInputSocketReader(1);
+ this->m_space = this->m_data->sigma_space + this->m_data->iter;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
}
void BilateralBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- // read the determinator color at x, y, this will be used as the reference color for the determinator
- float determinatorReferenceColor[4];
- float determinator[4];
- float tempColor[4];
- float blurColor[4];
- float blurDivider;
- float space = this->m_space;
- float sigmacolor = this->m_data->sigma_color;
- int minx = floor(x - space);
- int maxx = ceil(x + space);
- int miny = floor(y - space);
- int maxy = ceil(y + space);
- float deltaColor;
- this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, data);
+ // read the determinator color at x, y, this will be used as the reference color for the determinator
+ float determinatorReferenceColor[4];
+ float determinator[4];
+ float tempColor[4];
+ float blurColor[4];
+ float blurDivider;
+ float space = this->m_space;
+ float sigmacolor = this->m_data->sigma_color;
+ int minx = floor(x - space);
+ int maxx = ceil(x + space);
+ int miny = floor(y - space);
+ int maxy = ceil(y + space);
+ float deltaColor;
+ this->m_inputDeterminatorProgram->read(determinatorReferenceColor, x, y, data);
- zero_v4(blurColor);
- blurDivider = 0.0f;
- /* TODO(sergey): This isn't really good bilateral filter, it should be
- * using gaussian bell for weights. Also sigma_color doesn't seem to be
- * used correct at all.
- */
- for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) {
- for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) {
- // read determinator
- this->m_inputDeterminatorProgram->read(determinator, xi, yi, data);
- deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
- fabsf(determinatorReferenceColor[1] - determinator[1]) +
- fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account
- if (deltaColor < sigmacolor) {
- // add this to the blur
- this->m_inputColorProgram->read(tempColor, xi, yi, data);
- add_v4_v4(blurColor, tempColor);
- blurDivider += 1.0f;
- }
- }
- }
+ zero_v4(blurColor);
+ blurDivider = 0.0f;
+ /* TODO(sergey): This isn't really good bilateral filter, it should be
+ * using gaussian bell for weights. Also sigma_color doesn't seem to be
+ * used correct at all.
+ */
+ for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) {
+ for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) {
+ // read determinator
+ this->m_inputDeterminatorProgram->read(determinator, xi, yi, data);
+ deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
+ fabsf(determinatorReferenceColor[1] - determinator[1]) +
+ fabsf(determinatorReferenceColor[2] -
+ determinator[2])); // do not take the alpha channel into account
+ if (deltaColor < sigmacolor) {
+ // add this to the blur
+ this->m_inputColorProgram->read(tempColor, xi, yi, data);
+ add_v4_v4(blurColor, tempColor);
+ blurDivider += 1.0f;
+ }
+ }
+ }
- if (blurDivider > 0.0f) {
- mul_v4_v4fl(output, blurColor, 1.0f / blurDivider);
- }
- else {
- output[0] = 0.0f;
- output[1] = 0.0f;
- output[2] = 0.0f;
- output[3] = 1.0f;
- }
+ if (blurDivider > 0.0f) {
+ mul_v4_v4fl(output, blurColor, 1.0f / blurDivider);
+ }
+ else {
+ output[0] = 0.0f;
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 1.0f;
+ }
}
void BilateralBlurOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputDeterminatorProgram = NULL;
+ this->m_inputColorProgram = NULL;
+ this->m_inputDeterminatorProgram = NULL;
}
-bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- int add = ceil(this->m_space) + 1;
+ rcti newInput;
+ int add = ceil(this->m_space) + 1;
- newInput.xmax = input->xmax + (add);
- newInput.xmin = input->xmin - (add);
- newInput.ymax = input->ymax + (add);
- newInput.ymin = input->ymin - (add);
+ newInput.xmax = input->xmax + (add);
+ newInput.xmin = input->xmin - (add);
+ newInput.ymax = input->ymax + (add);
+ newInput.ymin = input->ymin - (add);
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.h b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
index e0275beca50..c3482005d8c 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.h
@@ -22,32 +22,37 @@
#include "COM_QualityStepHelper.h"
class BilateralBlurOperation : public NodeOperation, public QualityStepHelper {
-private:
- SocketReader *m_inputColorProgram;
- SocketReader *m_inputDeterminatorProgram;
- NodeBilateralBlurData *m_data;
- float m_space;
-
-public:
- BilateralBlurOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void setData(NodeBilateralBlurData *data) { this->m_data = data; }
+ private:
+ SocketReader *m_inputColorProgram;
+ SocketReader *m_inputDeterminatorProgram;
+ NodeBilateralBlurData *m_data;
+ float m_space;
+
+ public:
+ BilateralBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void setData(NodeBilateralBlurData *data)
+ {
+ this->m_data = data;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index d1a55de1431..aca98085a3e 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -21,82 +21,81 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation()
{
- /* data_type is almost always COM_DT_COLOR except for alpha-blur */
- this->addInputSocket(data_type);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(data_type);
- this->setComplex(true);
- this->m_inputProgram = NULL;
- memset(&m_data, 0, sizeof(NodeBlurData));
- this->m_size = 1.0f;
- this->m_sizeavailable = false;
- this->m_extend_bounds = false;
+ /* data_type is almost always COM_DT_COLOR except for alpha-blur */
+ this->addInputSocket(data_type);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(data_type);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
+ memset(&m_data, 0, sizeof(NodeBlurData));
+ this->m_size = 1.0f;
+ this->m_sizeavailable = false;
+ this->m_extend_bounds = false;
}
void BlurBaseOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- this->m_inputSize = this->getInputSocketReader(1);
- this->m_data.image_in_width = this->getWidth();
- this->m_data.image_in_height = this->getHeight();
- if (this->m_data.relative) {
- switch (this->m_data.aspect) {
- case CMP_NODE_BLUR_ASPECT_NONE:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
- break;
- case CMP_NODE_BLUR_ASPECT_Y:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
- break;
- case CMP_NODE_BLUR_ASPECT_X:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
- break;
- }
- }
-
- QualityStepHelper::initExecution(COM_QH_MULTIPLY);
-
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputSize = this->getInputSocketReader(1);
+ this->m_data.image_in_width = this->getWidth();
+ this->m_data.image_in_height = this->getHeight();
+ if (this->m_data.relative) {
+ switch (this->m_data.aspect) {
+ case CMP_NODE_BLUR_ASPECT_NONE:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
+ break;
+ case CMP_NODE_BLUR_ASPECT_Y:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
+ break;
+ case CMP_NODE_BLUR_ASPECT_X:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
+ break;
+ }
+ }
+
+ QualityStepHelper::initExecution(COM_QH_MULTIPLY);
}
float *BlurBaseOperation::make_gausstab(float rad, int size)
{
- float *gausstab, sum, val;
- int i, n;
+ float *gausstab, sum, val;
+ int i, n;
- n = 2 * size + 1;
+ n = 2 * size + 1;
- gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__);
+ gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__);
- sum = 0.0f;
- float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
- for (i = -size; i <= size; i++) {
- val = RE_filter_value(this->m_data.filtertype, (float)i * fac);
- sum += val;
- gausstab[i + size] = val;
- }
+ sum = 0.0f;
+ float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
+ for (i = -size; i <= size; i++) {
+ val = RE_filter_value(this->m_data.filtertype, (float)i * fac);
+ sum += val;
+ gausstab[i + size] = val;
+ }
- sum = 1.0f / sum;
- for (i = 0; i < n; i++)
- gausstab[i] *= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
- return gausstab;
+ return gausstab;
}
#ifdef __SSE2__
__m128 *BlurBaseOperation::convert_gausstab_sse(const float *gausstab, int size)
{
- int n = 2 * size + 1;
- __m128 *gausstab_sse = (__m128 *) MEM_mallocN_aligned(sizeof(__m128) * n, 16, "gausstab sse");
- for (int i = 0; i < n; ++i) {
- gausstab_sse[i] = _mm_set1_ps(gausstab[i]);
- }
- return gausstab_sse;
+ int n = 2 * size + 1;
+ __m128 *gausstab_sse = (__m128 *)MEM_mallocN_aligned(sizeof(__m128) * n, 16, "gausstab sse");
+ for (int i = 0; i < n; ++i) {
+ gausstab_sse[i] = _mm_set1_ps(gausstab[i]);
+ }
+ return gausstab_sse;
}
#endif
@@ -104,81 +103,80 @@ __m128 *BlurBaseOperation::convert_gausstab_sse(const float *gausstab, int size)
* 'ease' is applied after, looks nicer */
float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff)
{
- float *dist_fac_invert, val;
- int i, n;
-
- n = 2 * size + 1;
-
- dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__);
-
- float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
- for (i = -size; i <= size; i++) {
- val = 1.0f - fabsf((float)i * fac);
-
- /* keep in sync with rna_enum_proportional_falloff_curve_only_items */
- switch (falloff) {
- case PROP_SMOOTH:
- /* ease - gives less hard lines for dilate/erode feather */
- val = (3.0f * val * val - 2.0f * val * val * val);
- break;
- case PROP_SPHERE:
- val = sqrtf(2.0f * val - val * val);
- break;
- case PROP_ROOT:
- val = sqrtf(val);
- break;
- case PROP_SHARP:
- val = val * val;
- break;
- case PROP_INVSQUARE:
- val = val * (2.0f - val);
- break;
- case PROP_LIN:
- /* fall-through */
+ float *dist_fac_invert, val;
+ int i, n;
+
+ n = 2 * size + 1;
+
+ dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__);
+
+ float fac = (rad > 0.0f ? 1.0f / rad : 0.0f);
+ for (i = -size; i <= size; i++) {
+ val = 1.0f - fabsf((float)i * fac);
+
+ /* keep in sync with rna_enum_proportional_falloff_curve_only_items */
+ switch (falloff) {
+ case PROP_SMOOTH:
+ /* ease - gives less hard lines for dilate/erode feather */
+ val = (3.0f * val * val - 2.0f * val * val * val);
+ break;
+ case PROP_SPHERE:
+ val = sqrtf(2.0f * val - val * val);
+ break;
+ case PROP_ROOT:
+ val = sqrtf(val);
+ break;
+ case PROP_SHARP:
+ val = val * val;
+ break;
+ case PROP_INVSQUARE:
+ val = val * (2.0f - val);
+ break;
+ case PROP_LIN:
+ /* fall-through */
#ifndef NDEBUG
- case -1:
- /* uninitialized! */
- BLI_assert(0);
- break;
+ case -1:
+ /* uninitialized! */
+ BLI_assert(0);
+ break;
#endif
- default:
- /* nothing */
- break;
- }
- dist_fac_invert[i + size] = val;
- }
-
- return dist_fac_invert;
+ default:
+ /* nothing */
+ break;
+ }
+ dist_fac_invert[i + size] = val;
+ }
+
+ return dist_fac_invert;
}
void BlurBaseOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputSize = NULL;
+ this->m_inputProgram = NULL;
+ this->m_inputSize = NULL;
}
void BlurBaseOperation::setData(const NodeBlurData *data)
{
- memcpy(&m_data, data, sizeof(NodeBlurData));
+ memcpy(&m_data, data, sizeof(NodeBlurData));
}
void BlurBaseOperation::updateSize()
{
- if (!this->m_sizeavailable) {
- float result[4];
- this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
- this->m_size = result[0];
- this->m_sizeavailable = true;
- }
+ if (!this->m_sizeavailable) {
+ float result[4];
+ this->getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
+ this->m_size = result[0];
+ this->m_sizeavailable = true;
+ }
}
void BlurBaseOperation::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution,
- preferredResolution);
- if (this->m_extend_bounds) {
- resolution[0] += 2 * this->m_size * m_data.sizex;
- resolution[1] += 2 * this->m_size * m_data.sizey;
- }
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ if (this->m_extend_bounds) {
+ resolution[0] += 2 * this->m_size * m_data.sizex;
+ resolution[1] += 2 * this->m_size * m_data.sizey;
+ }
}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index a2bac326d59..07893c19126 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -28,49 +28,53 @@
#endif
class BlurBaseOperation : public NodeOperation, public QualityStepHelper {
-private:
-
-protected:
-
- BlurBaseOperation(DataType data_type);
- float *make_gausstab(float rad, int size);
+ private:
+ protected:
+ BlurBaseOperation(DataType data_type);
+ float *make_gausstab(float rad, int size);
#ifdef __SSE2__
- __m128 *convert_gausstab_sse(const float *gaustab, int size);
+ __m128 *convert_gausstab_sse(const float *gaustab, int size);
#endif
- float *make_dist_fac_inverse(float rad, int size, int falloff);
+ float *make_dist_fac_inverse(float rad, int size, int falloff);
- void updateSize();
+ void updateSize();
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- SocketReader *m_inputSize;
- NodeBlurData m_data;
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputSize;
+ NodeBlurData m_data;
- float m_size;
- bool m_sizeavailable;
+ float m_size;
+ bool m_sizeavailable;
- bool m_extend_bounds;
+ bool m_extend_bounds;
-public:
- /**
- * Initialize the execution
- */
- void initExecution();
+ public:
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setData(const NodeBlurData *data);
+ void setData(const NodeBlurData *data);
- void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
+ void setSize(float size)
+ {
+ this->m_size = size;
+ this->m_sizeavailable = true;
+ }
- void setExtendBounds(bool extend_bounds) { this->m_extend_bounds = extend_bounds; }
+ void setExtendBounds(bool extend_bounds)
+ {
+ this->m_extend_bounds = extend_bounds;
+ }
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index b6e0779c206..4d858934796 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -21,218 +21,224 @@
#include "COM_OpenCLDevice.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
BokehBlurOperation::BokehBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->setOpenCL(true);
-
- this->m_size = 1.0f;
- this->m_sizeavailable = false;
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputBoundingBoxReader = NULL;
-
- this->m_extend_bounds = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->setOpenCL(true);
+
+ this->m_size = 1.0f;
+ this->m_sizeavailable = false;
+ this->m_inputProgram = NULL;
+ this->m_inputBokehProgram = NULL;
+ this->m_inputBoundingBoxReader = NULL;
+
+ this->m_extend_bounds = false;
}
void *BokehBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateSize();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateSize();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void BokehBlurOperation::initExecution()
{
- initMutex();
- this->m_inputProgram = getInputSocketReader(0);
- this->m_inputBokehProgram = getInputSocketReader(1);
- this->m_inputBoundingBoxReader = getInputSocketReader(2);
+ initMutex();
+ this->m_inputProgram = getInputSocketReader(0);
+ this->m_inputBokehProgram = getInputSocketReader(1);
+ this->m_inputBoundingBoxReader = getInputSocketReader(2);
- int width = this->m_inputBokehProgram->getWidth();
- int height = this->m_inputBokehProgram->getHeight();
+ int width = this->m_inputBokehProgram->getWidth();
+ int height = this->m_inputBokehProgram->getHeight();
- float dimension = min(width, height);
+ float dimension = min(width, height);
- this->m_bokehMidX = width / 2.0f;
- this->m_bokehMidY = height / 2.0f;
- this->m_bokehDimension = dimension / 2.0f;
- QualityStepHelper::initExecution(COM_QH_INCREASE);
+ this->m_bokehMidX = width / 2.0f;
+ this->m_bokehMidY = height / 2.0f;
+ this->m_bokehDimension = dimension / 2.0f;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
}
void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float color_accum[4];
- float tempBoundingBox[4];
- float bokeh[4];
-
- this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
- if (tempBoundingBox[0] > 0.0f) {
- float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
- const float max_dim = max(this->getWidth(), this->getHeight());
- int pixelSize = this->m_size * max_dim / 100.0f;
- zero_v4(color_accum);
-
- if (pixelSize < 2) {
- this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
- multiplier_accum[0] = 1.0f;
- multiplier_accum[1] = 1.0f;
- multiplier_accum[2] = 1.0f;
- multiplier_accum[3] = 1.0f;
- }
- int miny = y - pixelSize;
- int maxy = y + pixelSize;
- int minx = x - pixelSize;
- int maxx = x + pixelSize;
- miny = max(miny, inputBuffer->getRect()->ymin);
- minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax);
- maxx = min(maxx, inputBuffer->getRect()->xmax);
-
-
- int step = getStep();
- int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR;
-
- float m = this->m_bokehDimension / pixelSize;
- for (int ny = miny; ny < maxy; ny += step) {
- int bufferindex = ((minx - bufferstartx) * COM_NUM_CHANNELS_COLOR) + ((ny - bufferstarty) * COM_NUM_CHANNELS_COLOR * bufferwidth);
- for (int nx = minx; nx < maxx; nx += step) {
- float u = this->m_bokehMidX - (nx - x) * m;
- float v = this->m_bokehMidY - (ny - y) * m;
- this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
- madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
- add_v4_v4(multiplier_accum, bokeh);
- bufferindex += offsetadd;
- }
- }
- output[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
- output[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
- output[2] = color_accum[2] * (1.0f / multiplier_accum[2]);
- output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
- }
- else {
- this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
- }
+ float color_accum[4];
+ float tempBoundingBox[4];
+ float bokeh[4];
+
+ this->m_inputBoundingBoxReader->readSampled(tempBoundingBox, x, y, COM_PS_NEAREST);
+ if (tempBoundingBox[0] > 0.0f) {
+ float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+ const float max_dim = max(this->getWidth(), this->getHeight());
+ int pixelSize = this->m_size * max_dim / 100.0f;
+ zero_v4(color_accum);
+
+ if (pixelSize < 2) {
+ this->m_inputProgram->readSampled(color_accum, x, y, COM_PS_NEAREST);
+ multiplier_accum[0] = 1.0f;
+ multiplier_accum[1] = 1.0f;
+ multiplier_accum[2] = 1.0f;
+ multiplier_accum[3] = 1.0f;
+ }
+ int miny = y - pixelSize;
+ int maxy = y + pixelSize;
+ int minx = x - pixelSize;
+ int maxx = x + pixelSize;
+ miny = max(miny, inputBuffer->getRect()->ymin);
+ minx = max(minx, inputBuffer->getRect()->xmin);
+ maxy = min(maxy, inputBuffer->getRect()->ymax);
+ maxx = min(maxx, inputBuffer->getRect()->xmax);
+
+ int step = getStep();
+ int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR;
+
+ float m = this->m_bokehDimension / pixelSize;
+ for (int ny = miny; ny < maxy; ny += step) {
+ int bufferindex = ((minx - bufferstartx) * COM_NUM_CHANNELS_COLOR) +
+ ((ny - bufferstarty) * COM_NUM_CHANNELS_COLOR * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ float u = this->m_bokehMidX - (nx - x) * m;
+ float v = this->m_bokehMidY - (ny - y) * m;
+ this->m_inputBokehProgram->readSampled(bokeh, u, v, COM_PS_NEAREST);
+ madd_v4_v4v4(color_accum, bokeh, &buffer[bufferindex]);
+ add_v4_v4(multiplier_accum, bokeh);
+ bufferindex += offsetadd;
+ }
+ }
+ output[0] = color_accum[0] * (1.0f / multiplier_accum[0]);
+ output[1] = color_accum[1] * (1.0f / multiplier_accum[1]);
+ output[2] = color_accum[2] * (1.0f / multiplier_accum[2]);
+ output[3] = color_accum[3] * (1.0f / multiplier_accum[3]);
+ }
+ else {
+ this->m_inputProgram->readSampled(output, x, y, COM_PS_NEAREST);
+ }
}
void BokehBlurOperation::deinitExecution()
{
- deinitMutex();
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputBoundingBoxReader = NULL;
+ deinitMutex();
+ this->m_inputProgram = NULL;
+ this->m_inputBokehProgram = NULL;
+ this->m_inputBoundingBoxReader = NULL;
}
-bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- rcti bokehInput;
- const float max_dim = max(this->getWidth(), this->getHeight());
-
- if (this->m_sizeavailable) {
- newInput.xmax = input->xmax + (this->m_size * max_dim / 100.0f);
- newInput.xmin = input->xmin - (this->m_size * max_dim / 100.0f);
- newInput.ymax = input->ymax + (this->m_size * max_dim / 100.0f);
- newInput.ymin = input->ymin - (this->m_size * max_dim / 100.0f);
- }
- else {
- newInput.xmax = input->xmax + (10.0f * max_dim / 100.0f);
- newInput.xmin = input->xmin - (10.0f * max_dim / 100.0f);
- newInput.ymax = input->ymax + (10.0f * max_dim / 100.0f);
- newInput.ymin = input->ymin - (10.0f * max_dim / 100.0f);
- }
-
- NodeOperation *operation = getInputOperation(1);
- bokehInput.xmax = operation->getWidth();
- bokehInput.xmin = 0;
- bokehInput.ymax = operation->getHeight();
- bokehInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
- return true;
- }
- operation = getInputOperation(0);
- if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
- return true;
- }
- operation = getInputOperation(2);
- if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
- return true;
- }
- if (!this->m_sizeavailable) {
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- operation = getInputOperation(3);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output) ) {
- return true;
- }
- }
- return false;
+ rcti newInput;
+ rcti bokehInput;
+ const float max_dim = max(this->getWidth(), this->getHeight());
+
+ if (this->m_sizeavailable) {
+ newInput.xmax = input->xmax + (this->m_size * max_dim / 100.0f);
+ newInput.xmin = input->xmin - (this->m_size * max_dim / 100.0f);
+ newInput.ymax = input->ymax + (this->m_size * max_dim / 100.0f);
+ newInput.ymin = input->ymin - (this->m_size * max_dim / 100.0f);
+ }
+ else {
+ newInput.xmax = input->xmax + (10.0f * max_dim / 100.0f);
+ newInput.xmin = input->xmin - (10.0f * max_dim / 100.0f);
+ newInput.ymax = input->ymax + (10.0f * max_dim / 100.0f);
+ newInput.ymin = input->ymin - (10.0f * max_dim / 100.0f);
+ }
+
+ NodeOperation *operation = getInputOperation(1);
+ bokehInput.xmax = operation->getWidth();
+ bokehInput.xmin = 0;
+ bokehInput.ymax = operation->getHeight();
+ bokehInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output)) {
+ return true;
+ }
+ operation = getInputOperation(0);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
+ return true;
+ }
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+ if (!this->m_sizeavailable) {
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ }
+ return false;
}
void BokehBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL);
- if (!this->m_sizeavailable) {
- updateSize();
- }
- const float max_dim = max(this->getWidth(), this->getHeight());
- cl_int radius = this->m_size * max_dim / 100.0f;
- cl_int step = this->getStep();
-
- device->COM_clAttachMemoryBufferToKernelParameter(kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader);
- device->COM_clAttachMemoryBufferToKernelParameter(kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachMemoryBufferToKernelParameter(kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer);
- clSetKernelArg(kernel, 6, sizeof(cl_int), &radius);
- clSetKernelArg(kernel, 7, sizeof(cl_int), &step);
- device->COM_clAttachSizeToKernelParameter(kernel, 8, this);
-
- device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this);
+ cl_kernel kernel = device->COM_clCreateKernel("bokehBlurKernel", NULL);
+ if (!this->m_sizeavailable) {
+ updateSize();
+ }
+ const float max_dim = max(this->getWidth(), this->getHeight());
+ cl_int radius = this->m_size * max_dim / 100.0f;
+ cl_int step = this->getStep();
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBoundingBoxReader);
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ kernel, 1, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ kernel, 2, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(kernel, 3, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, 5, outputMemoryBuffer);
+ clSetKernelArg(kernel, 6, sizeof(cl_int), &radius);
+ clSetKernelArg(kernel, 7, sizeof(cl_int), &step);
+ device->COM_clAttachSizeToKernelParameter(kernel, 8, this);
+
+ device->COM_clEnqueueRange(kernel, outputMemoryBuffer, 9, this);
}
void BokehBlurOperation::updateSize()
{
- if (!this->m_sizeavailable) {
- float result[4];
- this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST);
- this->m_size = result[0];
- CLAMP(this->m_size, 0.0f, 10.0f);
- this->m_sizeavailable = true;
- }
+ if (!this->m_sizeavailable) {
+ float result[4];
+ this->getInputSocketReader(3)->readSampled(result, 0, 0, COM_PS_NEAREST);
+ this->m_size = result[0];
+ CLAMP(this->m_size, 0.0f, 10.0f);
+ this->m_sizeavailable = true;
+ }
}
void BokehBlurOperation::determineResolution(unsigned int resolution[2],
unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution,
- preferredResolution);
- if (this->m_extend_bounds) {
- const float max_dim = max(resolution[0], resolution[1]);
- resolution[0] += 2 * this->m_size * max_dim / 100.0f;
- resolution[1] += 2 * this->m_size * max_dim / 100.0f;
- }
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ if (this->m_extend_bounds) {
+ const float max_dim = max(resolution[0], resolution[1]);
+ resolution[0] += 2 * this->m_size * max_dim / 100.0f;
+ resolution[1] += 2 * this->m_size * max_dim / 100.0f;
+ }
}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.h b/source/blender/compositor/operations/COM_BokehBlurOperation.h
index ec46adee637..4f594f16cb4 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.h
@@ -23,48 +23,59 @@
#include "COM_QualityStepHelper.h"
class BokehBlurOperation : public NodeOperation, public QualityStepHelper {
-private:
- SocketReader *m_inputProgram;
- SocketReader *m_inputBokehProgram;
- SocketReader *m_inputBoundingBoxReader;
- void updateSize();
- float m_size;
- bool m_sizeavailable;
- float m_bokehMidX;
- float m_bokehMidY;
- float m_bokehDimension;
- bool m_extend_bounds;
-public:
- BokehBlurOperation();
+ private:
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputBokehProgram;
+ SocketReader *m_inputBoundingBoxReader;
+ void updateSize();
+ float m_size;
+ bool m_sizeavailable;
+ float m_bokehMidX;
+ float m_bokehMidY;
+ float m_bokehDimension;
+ bool m_extend_bounds;
- void *initializeTileData(rcti *rect);
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ BokehBlurOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ void *initializeTileData(rcti *rect);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setSize(float size) { this->m_size = size; this->m_sizeavailable = true; }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
+ void setSize(float size)
+ {
+ this->m_size = size;
+ this->m_sizeavailable = true;
+ }
- void setExtendBounds(bool extend_bounds) { this->m_extend_bounds = extend_bounds; }
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
- void determineResolution(unsigned int resolution[2],
- unsigned int preferredResolution[2]);
+ void setExtendBounds(bool extend_bounds)
+ {
+ this->m_extend_bounds = extend_bounds;
+ }
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.cpp b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
index 6d02f5eb64e..3fd9a77d879 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.cpp
@@ -21,99 +21,106 @@
BokehImageOperation::BokehImageOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
- this->m_deleteData = false;
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_deleteData = false;
}
void BokehImageOperation::initExecution()
{
- this->m_center[0] = getWidth() / 2;
- this->m_center[1] = getHeight() / 2;
- this->m_inverseRounding = 1.0f - this->m_data->rounding;
- this->m_circularDistance = getWidth() / 2;
- this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps;
- this->m_flapRadAdd = this->m_data->angle;
- while (this->m_flapRadAdd < 0.0f) {
- this->m_flapRadAdd += (float)(M_PI * 2.0);
- }
- while (this->m_flapRadAdd > (float)M_PI) {
- this->m_flapRadAdd -= (float)(M_PI * 2.0);
- }
+ this->m_center[0] = getWidth() / 2;
+ this->m_center[1] = getHeight() / 2;
+ this->m_inverseRounding = 1.0f - this->m_data->rounding;
+ this->m_circularDistance = getWidth() / 2;
+ this->m_flapRad = (float)(M_PI * 2) / this->m_data->flaps;
+ this->m_flapRadAdd = this->m_data->angle;
+ while (this->m_flapRadAdd < 0.0f) {
+ this->m_flapRadAdd += (float)(M_PI * 2.0);
+ }
+ while (this->m_flapRadAdd > (float)M_PI) {
+ this->m_flapRadAdd -= (float)(M_PI * 2.0);
+ }
}
void BokehImageOperation::detemineStartPointOfFlap(float r[2], int flapNumber, float distance)
{
- r[0] = sinf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[0];
- r[1] = cosf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[1];
+ r[0] = sinf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[0];
+ r[1] = cosf(this->m_flapRad * flapNumber + this->m_flapRadAdd) * distance + this->m_center[1];
}
float BokehImageOperation::isInsideBokeh(float distance, float x, float y)
{
- float insideBokeh = 0.0f;
- const float deltaX = x - this->m_center[0];
- const float deltaY = y - this->m_center[1];
- float closestPoint[2];
- float lineP1[2];
- float lineP2[2];
- float point[2];
- point[0] = x;
- point[1] = y;
+ float insideBokeh = 0.0f;
+ const float deltaX = x - this->m_center[0];
+ const float deltaY = y - this->m_center[1];
+ float closestPoint[2];
+ float lineP1[2];
+ float lineP2[2];
+ float point[2];
+ point[0] = x;
+ point[1] = y;
- const float distanceToCenter = len_v2v2(point, this->m_center);
- const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
- int flapNumber = (int)((bearing - this->m_flapRadAdd) / this->m_flapRad);
+ const float distanceToCenter = len_v2v2(point, this->m_center);
+ const float bearing = (atan2f(deltaX, deltaY) + (float)(M_PI * 2.0));
+ int flapNumber = (int)((bearing - this->m_flapRadAdd) / this->m_flapRad);
- detemineStartPointOfFlap(lineP1, flapNumber, distance);
- detemineStartPointOfFlap(lineP2, flapNumber + 1, distance);
- closest_to_line_v2(closestPoint, point, lineP1, lineP2);
+ detemineStartPointOfFlap(lineP1, flapNumber, distance);
+ detemineStartPointOfFlap(lineP2, flapNumber + 1, distance);
+ closest_to_line_v2(closestPoint, point, lineP1, lineP2);
- const float distanceLineToCenter = len_v2v2(this->m_center, closestPoint);
- const float distanceRoundingToCenter = this->m_inverseRounding * distanceLineToCenter + this->m_data->rounding * distance;
+ const float distanceLineToCenter = len_v2v2(this->m_center, closestPoint);
+ const float distanceRoundingToCenter = this->m_inverseRounding * distanceLineToCenter +
+ this->m_data->rounding * distance;
- const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->m_data->catadioptric;
- if (distanceRoundingToCenter >= distanceToCenter && catadioptricDistanceToCenter <= distanceToCenter) {
- if (distanceRoundingToCenter - distanceToCenter < 1.0f) {
- insideBokeh = (distanceRoundingToCenter - distanceToCenter);
- }
- else if (this->m_data->catadioptric != 0.0f && distanceToCenter - catadioptricDistanceToCenter < 1.0f) {
- insideBokeh = (distanceToCenter - catadioptricDistanceToCenter);
- }
- else {
- insideBokeh = 1.0f;
- }
- }
- return insideBokeh;
+ const float catadioptricDistanceToCenter = distanceRoundingToCenter * this->m_data->catadioptric;
+ if (distanceRoundingToCenter >= distanceToCenter &&
+ catadioptricDistanceToCenter <= distanceToCenter) {
+ if (distanceRoundingToCenter - distanceToCenter < 1.0f) {
+ insideBokeh = (distanceRoundingToCenter - distanceToCenter);
+ }
+ else if (this->m_data->catadioptric != 0.0f &&
+ distanceToCenter - catadioptricDistanceToCenter < 1.0f) {
+ insideBokeh = (distanceToCenter - catadioptricDistanceToCenter);
+ }
+ else {
+ insideBokeh = 1.0f;
+ }
+ }
+ return insideBokeh;
}
-void BokehImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void BokehImageOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- float shift = this->m_data->lensshift;
- float shift2 = shift / 2.0f;
- float distance = this->m_circularDistance;
- float insideBokehMax = isInsideBokeh(distance, x, y);
- float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y);
- float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y);
- if (shift < 0) {
- output[0] = insideBokehMax;
- output[1] = insideBokehMed;
- output[2] = insideBokehMin;
- }
- else {
- output[0] = insideBokehMin;
- output[1] = insideBokehMed;
- output[2] = insideBokehMax;
- }
- output[3] = (insideBokehMax + insideBokehMed + insideBokehMin) / 3.0f;
+ float shift = this->m_data->lensshift;
+ float shift2 = shift / 2.0f;
+ float distance = this->m_circularDistance;
+ float insideBokehMax = isInsideBokeh(distance, x, y);
+ float insideBokehMed = isInsideBokeh(distance - fabsf(shift2 * distance), x, y);
+ float insideBokehMin = isInsideBokeh(distance - fabsf(shift * distance), x, y);
+ if (shift < 0) {
+ output[0] = insideBokehMax;
+ output[1] = insideBokehMed;
+ output[2] = insideBokehMin;
+ }
+ else {
+ output[0] = insideBokehMin;
+ output[1] = insideBokehMed;
+ output[2] = insideBokehMax;
+ }
+ output[3] = (insideBokehMax + insideBokehMed + insideBokehMin) / 3.0f;
}
void BokehImageOperation::deinitExecution()
{
- if (this->m_deleteData) {
- if (this->m_data) {
- delete this->m_data;
- this->m_data = NULL;
- }
- }
+ if (this->m_deleteData) {
+ if (this->m_data) {
+ delete this->m_data;
+ this->m_data = NULL;
+ }
+ }
}
-void BokehImageOperation::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void BokehImageOperation::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- resolution[0] = COM_BLUR_BOKEH_PIXELS;
- resolution[1] = COM_BLUR_BOKEH_PIXELS;
+ resolution[0] = COM_BLUR_BOKEH_PIXELS;
+ resolution[1] = COM_BLUR_BOKEH_PIXELS;
}
diff --git a/source/blender/compositor/operations/COM_BokehImageOperation.h b/source/blender/compositor/operations/COM_BokehImageOperation.h
index 445dea88cb7..58a1e2f85d8 100644
--- a/source/blender/compositor/operations/COM_BokehImageOperation.h
+++ b/source/blender/compositor/operations/COM_BokehImageOperation.h
@@ -47,98 +47,105 @@
* With a simple compare it can be detected if the evaluated pixel is between the outer and inner edge.
*/
class BokehImageOperation : public NodeOperation {
-private:
- /**
- * \brief Settings of the bokeh image
- */
- NodeBokehImage *m_data;
-
- /**
- * \brief precalced center of the image
- */
- float m_center[2];
-
- /**
- * \brief 1.0-rounding
- */
- float m_inverseRounding;
-
- /**
- * \brief distance of a full circle lens
- */
- float m_circularDistance;
-
- /**
- * \brief radius when the first flap starts
- */
- float m_flapRad;
-
- /**
- * \brief radians of a single flap
- */
- float m_flapRadAdd;
-
- /**
- * \brief should the m_data field by deleted when this operation is finished
- */
- bool m_deleteData;
-
- /**
- * \brief determine the coordinate of a flap cornder
- *
- * \param r: result in bokehimage space are stored [x,y]
- * \param flapNumber: the flap number to calculate
- * \param distance: the lens distance is used to simulate lens shifts
- */
- void detemineStartPointOfFlap(float r[2], int flapNumber, float distance);
-
- /**
- * \brief Determine if a coordinate is inside the bokeh image
- *
- * \param distance: the distance that will be used. This parameter is modified a bit to mimic lens shifts
- * \param x: the x coordinate of the pixel to evaluate
- * \param y: the y coordinate of the pixel to evaluate
- * \return float range 0..1 0 is completely outside
- */
- float isInsideBokeh(float distance, float x, float y);
-public:
- BokehImageOperation();
-
- /**
- * \brief the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * \brief Initialize the execution
- */
- void initExecution();
-
- /**
- * \brief Deinitialize the execution
- */
- void deinitExecution();
-
- /**
- * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS, COM_BLUR_BOKEH_PIXELS]
- * \param resolution:
- * \param preferredResolution:
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- /**
- * \brief set the node data
- * \param data:
- */
- void setData(NodeBokehImage *data) { this->m_data = data; }
-
- /**
- * \brief deleteDataOnFinish
- *
- * There are cases that the compositor uses this operation on its own (see defocus node)
- * the deleteDataOnFinish must only be called when the data has been created by the compositor.
- *It should not be called when the data has been created by the node-editor/user.
- */
- void deleteDataOnFinish() { this->m_deleteData = true; }
+ private:
+ /**
+ * \brief Settings of the bokeh image
+ */
+ NodeBokehImage *m_data;
+
+ /**
+ * \brief precalced center of the image
+ */
+ float m_center[2];
+
+ /**
+ * \brief 1.0-rounding
+ */
+ float m_inverseRounding;
+
+ /**
+ * \brief distance of a full circle lens
+ */
+ float m_circularDistance;
+
+ /**
+ * \brief radius when the first flap starts
+ */
+ float m_flapRad;
+
+ /**
+ * \brief radians of a single flap
+ */
+ float m_flapRadAdd;
+
+ /**
+ * \brief should the m_data field by deleted when this operation is finished
+ */
+ bool m_deleteData;
+
+ /**
+ * \brief determine the coordinate of a flap cornder
+ *
+ * \param r: result in bokehimage space are stored [x,y]
+ * \param flapNumber: the flap number to calculate
+ * \param distance: the lens distance is used to simulate lens shifts
+ */
+ void detemineStartPointOfFlap(float r[2], int flapNumber, float distance);
+
+ /**
+ * \brief Determine if a coordinate is inside the bokeh image
+ *
+ * \param distance: the distance that will be used. This parameter is modified a bit to mimic lens shifts
+ * \param x: the x coordinate of the pixel to evaluate
+ * \param y: the y coordinate of the pixel to evaluate
+ * \return float range 0..1 0 is completely outside
+ */
+ float isInsideBokeh(float distance, float x, float y);
+
+ public:
+ BokehImageOperation();
+
+ /**
+ * \brief the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * \brief Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * \brief Deinitialize the execution
+ */
+ void deinitExecution();
+
+ /**
+ * \brief determine the resolution of this operation. currently fixed at [COM_BLUR_BOKEH_PIXELS, COM_BLUR_BOKEH_PIXELS]
+ * \param resolution:
+ * \param preferredResolution:
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ /**
+ * \brief set the node data
+ * \param data:
+ */
+ void setData(NodeBokehImage *data)
+ {
+ this->m_data = data;
+ }
+
+ /**
+ * \brief deleteDataOnFinish
+ *
+ * There are cases that the compositor uses this operation on its own (see defocus node)
+ * the deleteDataOnFinish must only be called when the data has been created by the compositor.
+ *It should not be called when the data has been created by the node-editor/user.
+ */
+ void deleteDataOnFinish()
+ {
+ this->m_deleteData = true;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
index 6328b983489..c5f0108bf5a 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cpp
@@ -22,91 +22,89 @@
BoxMaskOperation::BoxMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
- this->m_cosine = 0.0f;
- this->m_sine = 0.0f;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputMask = NULL;
+ this->m_inputValue = NULL;
+ this->m_cosine = 0.0f;
+ this->m_sine = 0.0f;
}
void BoxMaskOperation::initExecution()
{
- this->m_inputMask = this->getInputSocketReader(0);
- this->m_inputValue = this->getInputSocketReader(1);
- const double rad = (double)this->m_data->rotation;
- this->m_cosine = cos(rad);
- this->m_sine = sin(rad);
- this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
+ this->m_inputMask = this->getInputSocketReader(0);
+ this->m_inputValue = this->getInputSocketReader(1);
+ const double rad = (double)this->m_data->rotation;
+ this->m_cosine = cos(rad);
+ this->m_sine = sin(rad);
+ this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
void BoxMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputMask[4];
- float inputValue[4];
+ float inputMask[4];
+ float inputValue[4];
- float rx = x / this->getWidth();
- float ry = y / this->getHeight();
+ float rx = x / this->getWidth();
+ float ry = y / this->getHeight();
- const float dy = (ry - this->m_data->y) / this->m_aspectRatio;
- const float dx = rx - this->m_data->x;
- rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
- ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
+ const float dy = (ry - this->m_data->y) / this->m_aspectRatio;
+ const float dx = rx - this->m_data->x;
+ rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
+ ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_inputMask->readSampled(inputMask, x, y, sampler);
- this->m_inputValue->readSampled(inputValue, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
+ this->m_inputValue->readSampled(inputValue, x, y, sampler);
- float halfHeight = this->m_data->height / 2.0f;
- float halfWidth = this->m_data->width / 2.0f;
- bool inside = (rx > this->m_data->x - halfWidth &&
- rx < this->m_data->x + halfWidth &&
- ry > this->m_data->y - halfHeight &&
- ry < this->m_data->y + halfHeight);
+ float halfHeight = this->m_data->height / 2.0f;
+ float halfWidth = this->m_data->width / 2.0f;
+ bool inside = (rx > this->m_data->x - halfWidth && rx < this->m_data->x + halfWidth &&
+ ry > this->m_data->y - halfHeight && ry < this->m_data->y + halfHeight);
- switch (this->m_maskType) {
- case CMP_NODE_MASKTYPE_ADD:
- if (inside) {
- output[0] = max(inputMask[0], inputValue[0]);
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- case CMP_NODE_MASKTYPE_SUBTRACT:
- if (inside) {
- output[0] = inputMask[0] - inputValue[0];
- CLAMP(output[0], 0, 1);
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- case CMP_NODE_MASKTYPE_MULTIPLY:
- if (inside) {
- output[0] = inputMask[0] * inputValue[0];
- }
- else {
- output[0] = 0;
- }
- break;
- case CMP_NODE_MASKTYPE_NOT:
- if (inside) {
- if (inputMask[0] > 0.0f) {
- output[0] = 0;
- }
- else {
- output[0] = inputValue[0];
- }
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- }
+ switch (this->m_maskType) {
+ case CMP_NODE_MASKTYPE_ADD:
+ if (inside) {
+ output[0] = max(inputMask[0], inputValue[0]);
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_SUBTRACT:
+ if (inside) {
+ output[0] = inputMask[0] - inputValue[0];
+ CLAMP(output[0], 0, 1);
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_MULTIPLY:
+ if (inside) {
+ output[0] = inputMask[0] * inputValue[0];
+ }
+ else {
+ output[0] = 0;
+ }
+ break;
+ case CMP_NODE_MASKTYPE_NOT:
+ if (inside) {
+ if (inputMask[0] > 0.0f) {
+ output[0] = 0;
+ }
+ else {
+ output[0] = inputValue[0];
+ }
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ }
}
void BoxMaskOperation::deinitExecution()
{
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = NULL;
+ this->m_inputValue = NULL;
}
diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.h b/source/blender/compositor/operations/COM_BoxMaskOperation.h
index f5134de7211..f770922ee7c 100644
--- a/source/blender/compositor/operations/COM_BoxMaskOperation.h
+++ b/source/blender/compositor/operations/COM_BoxMaskOperation.h
@@ -20,42 +20,47 @@
#define __COM_BOXMASKOPERATION_H__
#include "COM_NodeOperation.h"
-
class BoxMaskOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputMask;
- SocketReader *m_inputValue;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputMask;
+ SocketReader *m_inputValue;
- float m_sine;
- float m_cosine;
- float m_aspectRatio;
- int m_maskType;
+ float m_sine;
+ float m_cosine;
+ float m_aspectRatio;
+ int m_maskType;
- NodeBoxMask *m_data;
-public:
- BoxMaskOperation();
+ NodeBoxMask *m_data;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ BoxMaskOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setData(NodeBoxMask *data) { this->m_data = data; }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setMaskType(int maskType) { this->m_maskType = maskType; }
+ void setData(NodeBoxMask *data)
+ {
+ this->m_data = data;
+ }
+ void setMaskType(int maskType)
+ {
+ this->m_maskType = maskType;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.cpp b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
index dedea363163..81df85daf28 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.cpp
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.cpp
@@ -20,68 +20,71 @@
BrightnessOperation::BrightnessOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
- this->m_use_premultiply = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
+ this->m_use_premultiply = false;
}
void BrightnessOperation::setUsePremultiply(bool use_premultiply)
{
- this->m_use_premultiply = use_premultiply;
+ this->m_use_premultiply = use_premultiply;
}
void BrightnessOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- this->m_inputBrightnessProgram = this->getInputSocketReader(1);
- this->m_inputContrastProgram = this->getInputSocketReader(2);
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputBrightnessProgram = this->getInputSocketReader(1);
+ this->m_inputContrastProgram = this->getInputSocketReader(2);
}
-void BrightnessOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void BrightnessOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue[4];
- float a, b;
- float inputBrightness[4];
- float inputContrast[4];
- this->m_inputProgram->readSampled(inputValue, x, y, sampler);
- this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
- this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler);
- float brightness = inputBrightness[0];
- float contrast = inputContrast[0];
- brightness /= 100.0f;
- float delta = contrast / 200.0f;
- a = 1.0f - delta * 2.0f;
- /*
- * The algorithm is by Werner D. Streidt
- * (http://visca.com/ffactory/archives/5-99/msg00021.html)
- * Extracted of OpenCV demhist.c
- */
- if (contrast > 0) {
- a = 1.0f / a;
- b = a * (brightness - delta);
- }
- else {
- delta *= -1;
- b = a * (brightness + delta);
- }
- if (this->m_use_premultiply) {
- premul_to_straight_v4(inputValue);
- }
- output[0] = a * inputValue[0] + b;
- output[1] = a * inputValue[1] + b;
- output[2] = a * inputValue[2] + b;
- output[3] = inputValue[3];
- if (this->m_use_premultiply) {
- straight_to_premul_v4(output);
- }
+ float inputValue[4];
+ float a, b;
+ float inputBrightness[4];
+ float inputContrast[4];
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler);
+ this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler);
+ float brightness = inputBrightness[0];
+ float contrast = inputContrast[0];
+ brightness /= 100.0f;
+ float delta = contrast / 200.0f;
+ a = 1.0f - delta * 2.0f;
+ /*
+ * The algorithm is by Werner D. Streidt
+ * (http://visca.com/ffactory/archives/5-99/msg00021.html)
+ * Extracted of OpenCV demhist.c
+ */
+ if (contrast > 0) {
+ a = 1.0f / a;
+ b = a * (brightness - delta);
+ }
+ else {
+ delta *= -1;
+ b = a * (brightness + delta);
+ }
+ if (this->m_use_premultiply) {
+ premul_to_straight_v4(inputValue);
+ }
+ output[0] = a * inputValue[0] + b;
+ output[1] = a * inputValue[1] + b;
+ output[2] = a * inputValue[2] + b;
+ output[3] = inputValue[3];
+ if (this->m_use_premultiply) {
+ straight_to_premul_v4(output);
+ }
}
void BrightnessOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputBrightnessProgram = NULL;
- this->m_inputContrastProgram = NULL;
+ this->m_inputProgram = NULL;
+ this->m_inputBrightnessProgram = NULL;
+ this->m_inputContrastProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_BrightnessOperation.h b/source/blender/compositor/operations/COM_BrightnessOperation.h
index 45aa7be48f3..df6b3ef7b6e 100644
--- a/source/blender/compositor/operations/COM_BrightnessOperation.h
+++ b/source/blender/compositor/operations/COM_BrightnessOperation.h
@@ -20,36 +20,35 @@
#define __COM_BRIGHTNESSOPERATION_H__
#include "COM_NodeOperation.h"
-
class BrightnessOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- SocketReader *m_inputBrightnessProgram;
- SocketReader *m_inputContrastProgram;
-
- bool m_use_premultiply;
-
-public:
- BrightnessOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setUsePremultiply(bool use_premultiply);
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputBrightnessProgram;
+ SocketReader *m_inputContrastProgram;
+
+ bool m_use_premultiply;
+
+ public:
+ BrightnessOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setUsePremultiply(bool use_premultiply);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index 2bc3efc60e4..5d01154bbda 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -26,103 +26,104 @@ extern "C" {
CalculateMeanOperation::CalculateMeanOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_imageReader = NULL;
- this->m_iscalculated = false;
- this->m_setting = 1;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_imageReader = NULL;
+ this->m_iscalculated = false;
+ this->m_setting = 1;
+ this->setComplex(true);
}
void CalculateMeanOperation::initExecution()
{
- this->m_imageReader = this->getInputSocketReader(0);
- this->m_iscalculated = false;
- NodeOperation::initMutex();
+ this->m_imageReader = this->getInputSocketReader(0);
+ this->m_iscalculated = false;
+ NodeOperation::initMutex();
}
-void CalculateMeanOperation::executePixel(float output[4],
- int /*x*/, int /*y*/,
- void * /*data*/)
+void CalculateMeanOperation::executePixel(float output[4], int /*x*/, int /*y*/, void * /*data*/)
{
- output[0] = this->m_result;
+ output[0] = this->m_result;
}
void CalculateMeanOperation::deinitExecution()
{
- this->m_imageReader = NULL;
- NodeOperation::deinitMutex();
+ this->m_imageReader = NULL;
+ NodeOperation::deinitMutex();
}
-bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool CalculateMeanOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti imageInput;
- if (this->m_iscalculated) {
- return false;
- }
- NodeOperation *operation = getInputOperation(0);
- imageInput.xmax = operation->getWidth();
- imageInput.xmin = 0;
- imageInput.ymax = operation->getHeight();
- imageInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
- return true;
- }
- return false;
+ rcti imageInput;
+ if (this->m_iscalculated) {
+ return false;
+ }
+ NodeOperation *operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output)) {
+ return true;
+ }
+ return false;
}
void *CalculateMeanOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (!this->m_iscalculated) {
- MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
- calculateMean(tile);
- this->m_iscalculated = true;
- }
- unlockMutex();
- return NULL;
+ lockMutex();
+ if (!this->m_iscalculated) {
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
+ calculateMean(tile);
+ this->m_iscalculated = true;
+ }
+ unlockMutex();
+ return NULL;
}
void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
{
- this->m_result = 0.0f;
- float *buffer = tile->getBuffer();
- int size = tile->getWidth() * tile->getHeight();
- int pixels = 0;
- float sum = 0.0f;
- for (int i = 0, offset = 0; i < size; i++, offset += 4) {
- if (buffer[offset + 3] > 0) {
- pixels++;
+ this->m_result = 0.0f;
+ float *buffer = tile->getBuffer();
+ int size = tile->getWidth() * tile->getHeight();
+ int pixels = 0;
+ float sum = 0.0f;
+ for (int i = 0, offset = 0; i < size; i++, offset += 4) {
+ if (buffer[offset + 3] > 0) {
+ pixels++;
- switch (this->m_setting) {
- case 1:
- {
- sum += IMB_colormanagement_get_luminance(&buffer[offset]);
- break;
- }
- case 2:
- {
- sum += buffer[offset];
- break;
- }
- case 3:
- {
- sum += buffer[offset + 1];
- break;
- }
- case 4:
- {
- sum += buffer[offset + 2];
- break;
- }
- case 5:
- {
- float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
- sum += yuv[0];
- break;
- }
- }
- }
- }
- this->m_result = sum / pixels;
+ switch (this->m_setting) {
+ case 1: {
+ sum += IMB_colormanagement_get_luminance(&buffer[offset]);
+ break;
+ }
+ case 2: {
+ sum += buffer[offset];
+ break;
+ }
+ case 3: {
+ sum += buffer[offset + 1];
+ break;
+ }
+ case 4: {
+ sum += buffer[offset + 2];
+ break;
+ }
+ case 5: {
+ float yuv[3];
+ rgb_to_yuv(buffer[offset],
+ buffer[offset + 1],
+ buffer[offset + 2],
+ &yuv[0],
+ &yuv[1],
+ &yuv[2],
+ BLI_YUV_ITU_BT709);
+ sum += yuv[0];
+ break;
+ }
+ }
+ }
+ }
+ this->m_result = sum / pixels;
}
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.h b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
index 54c09007dc6..38d68b2a6fd 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.h
@@ -26,40 +26,45 @@
* \ingroup operation
*/
class CalculateMeanOperation : public NodeOperation {
-protected:
- /**
- * \brief Cached reference to the reader
- */
- SocketReader *m_imageReader;
+ protected:
+ /**
+ * \brief Cached reference to the reader
+ */
+ SocketReader *m_imageReader;
- bool m_iscalculated;
- float m_result;
- int m_setting;
+ bool m_iscalculated;
+ float m_result;
+ int m_setting;
-public:
- CalculateMeanOperation();
+ public:
+ CalculateMeanOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void setSetting(int setting) { this->m_setting = setting; }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void setSetting(int setting)
+ {
+ this->m_setting = setting;
+ }
-protected:
- void calculateMean(MemoryBuffer *tile);
+ protected:
+ void calculateMean(MemoryBuffer *tile);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 7fa1929889c..dfe1a936c9c 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -24,75 +24,83 @@ extern "C" {
#include "IMB_colormanagement.h"
}
-CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : CalculateMeanOperation()
+CalculateStandardDeviationOperation::CalculateStandardDeviationOperation()
+ : CalculateMeanOperation()
{
- /* pass */
+ /* pass */
}
void CalculateStandardDeviationOperation::executePixel(float output[4],
- int /*x*/, int /*y*/,
+ int /*x*/,
+ int /*y*/,
void * /*data*/)
{
- output[0] = this->m_standardDeviation;
+ output[0] = this->m_standardDeviation;
}
void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (!this->m_iscalculated) {
- MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
- CalculateMeanOperation::calculateMean(tile);
- this->m_standardDeviation = 0.0f;
- float *buffer = tile->getBuffer();
- int size = tile->getWidth() * tile->getHeight();
- int pixels = 0;
- float sum = 0.0f;
- float mean = this->m_result;
- for (int i = 0, offset = 0; i < size; i++, offset += 4) {
- if (buffer[offset + 3] > 0) {
- pixels++;
+ lockMutex();
+ if (!this->m_iscalculated) {
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
+ CalculateMeanOperation::calculateMean(tile);
+ this->m_standardDeviation = 0.0f;
+ float *buffer = tile->getBuffer();
+ int size = tile->getWidth() * tile->getHeight();
+ int pixels = 0;
+ float sum = 0.0f;
+ float mean = this->m_result;
+ for (int i = 0, offset = 0; i < size; i++, offset += 4) {
+ if (buffer[offset + 3] > 0) {
+ pixels++;
- switch (this->m_setting) {
- case 1: /* rgb combined */
- {
- float value = IMB_colormanagement_get_luminance(&buffer[offset]);
- sum += (value - mean) * (value - mean);
- break;
- }
- case 2: /* red */
- {
- float value = buffer[offset];
- sum += value;
- sum += (value - mean) * (value - mean);
- break;
- }
- case 3: /* green */
- {
- float value = buffer[offset + 1];
- sum += value;
- sum += (value - mean) * (value - mean);
- break;
- }
- case 4: /* blue */
- {
- float value = buffer[offset + 2];
- sum += value;
- sum += (value - mean) * (value - mean);
- break;
- }
- case 5: /* luminance */
- {
- float yuv[3];
- rgb_to_yuv(buffer[offset], buffer[offset + 1], buffer[offset + 2], &yuv[0], &yuv[1], &yuv[2], BLI_YUV_ITU_BT709);
- sum += (yuv[0] - mean) * (yuv[0] - mean);
- break;
- }
- }
- }
- }
- this->m_standardDeviation = sqrt(sum / (float)(pixels - 1));
- this->m_iscalculated = true;
- }
- unlockMutex();
- return NULL;
+ switch (this->m_setting) {
+ case 1: /* rgb combined */
+ {
+ float value = IMB_colormanagement_get_luminance(&buffer[offset]);
+ sum += (value - mean) * (value - mean);
+ break;
+ }
+ case 2: /* red */
+ {
+ float value = buffer[offset];
+ sum += value;
+ sum += (value - mean) * (value - mean);
+ break;
+ }
+ case 3: /* green */
+ {
+ float value = buffer[offset + 1];
+ sum += value;
+ sum += (value - mean) * (value - mean);
+ break;
+ }
+ case 4: /* blue */
+ {
+ float value = buffer[offset + 2];
+ sum += value;
+ sum += (value - mean) * (value - mean);
+ break;
+ }
+ case 5: /* luminance */
+ {
+ float yuv[3];
+ rgb_to_yuv(buffer[offset],
+ buffer[offset + 1],
+ buffer[offset + 2],
+ &yuv[0],
+ &yuv[1],
+ &yuv[2],
+ BLI_YUV_ITU_BT709);
+ sum += (yuv[0] - mean) * (yuv[0] - mean);
+ break;
+ }
+ }
+ }
+ }
+ this->m_standardDeviation = sqrt(sum / (float)(pixels - 1));
+ this->m_iscalculated = true;
+ }
+ unlockMutex();
+ return NULL;
}
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
index bc0bd669ebc..3f5c0896221 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.h
@@ -26,18 +26,17 @@
* \ingroup operation
*/
class CalculateStandardDeviationOperation : public CalculateMeanOperation {
-protected:
- float m_standardDeviation;
+ protected:
+ float m_standardDeviation;
-public:
- CalculateStandardDeviationOperation();
+ public:
+ CalculateStandardDeviationOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- void *initializeTileData(rcti *rect);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+ void *initializeTileData(rcti *rect);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
index 7481a3bebb4..a2554cd60de 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.cpp
@@ -20,44 +20,49 @@
ChangeHSVOperation::ChangeHSVOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputOperation = NULL;
}
void ChangeHSVOperation::initExecution()
{
- this->m_inputOperation = getInputSocketReader(0);
- this->m_hueOperation = getInputSocketReader(1);
- this->m_saturationOperation = getInputSocketReader(2);
- this->m_valueOperation = getInputSocketReader(3);
+ this->m_inputOperation = getInputSocketReader(0);
+ this->m_hueOperation = getInputSocketReader(1);
+ this->m_saturationOperation = getInputSocketReader(2);
+ this->m_valueOperation = getInputSocketReader(3);
}
void ChangeHSVOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_hueOperation = NULL;
- this->m_saturationOperation = NULL;
- this->m_valueOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_hueOperation = NULL;
+ this->m_saturationOperation = NULL;
+ this->m_valueOperation = NULL;
}
-void ChangeHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ChangeHSVOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float hue[4], saturation[4], value[4];
+ float inputColor1[4];
+ float hue[4], saturation[4], value[4];
- this->m_inputOperation->readSampled(inputColor1, x, y, sampler);
- this->m_hueOperation->readSampled(hue, x, y, sampler);
- this->m_saturationOperation->readSampled(saturation, x, y, sampler);
- this->m_valueOperation->readSampled(value, x, y, sampler);
+ this->m_inputOperation->readSampled(inputColor1, x, y, sampler);
+ this->m_hueOperation->readSampled(hue, x, y, sampler);
+ this->m_saturationOperation->readSampled(saturation, x, y, sampler);
+ this->m_valueOperation->readSampled(value, x, y, sampler);
- output[0] = inputColor1[0] + (hue[0] - 0.5f);
- if (output[0] > 1.0f) output[0] -= 1.0f;
- else if (output[0] < 0.0f) output[0] += 1.0f;
- output[1] = inputColor1[1] * saturation[0];
- output[2] = inputColor1[2] * value[0];
- output[3] = inputColor1[3];
+ output[0] = inputColor1[0] + (hue[0] - 0.5f);
+ if (output[0] > 1.0f)
+ output[0] -= 1.0f;
+ else if (output[0] < 0.0f)
+ output[0] += 1.0f;
+ output[1] = inputColor1[1] * saturation[0];
+ output[2] = inputColor1[2] * value[0];
+ output[3] = inputColor1[3];
}
diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
index 80855cb73a9..3898345f922 100644
--- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h
+++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h
@@ -20,31 +20,29 @@
#define __COM_CHANGEHSVOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ChangeHSVOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
- SocketReader *m_hueOperation;
- SocketReader *m_saturationOperation;
- SocketReader *m_valueOperation;
-
-public:
- /**
- * Default constructor
- */
- ChangeHSVOperation();
+ private:
+ SocketReader *m_inputOperation;
+ SocketReader *m_hueOperation;
+ SocketReader *m_saturationOperation;
+ SocketReader *m_valueOperation;
- void initExecution();
- void deinitExecution();
+ public:
+ /**
+ * Default constructor
+ */
+ ChangeHSVOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void initExecution();
+ void deinitExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
index 1e3808a80cc..cbd46ea71f8 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp
@@ -21,102 +21,100 @@
ChannelMatteOperation::ChannelMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = NULL;
}
void ChannelMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_limit_range = this->m_limit_max - this->m_limit_min;
+ this->m_limit_range = this->m_limit_max - this->m_limit_min;
- switch (this->m_limit_method) {
- /* SINGLE */
- case 0:
- {
- /* 123 / RGB / HSV / YUV / YCC */
- const int matte_channel = this->m_matte_channel - 1;
- const int limit_channel = this->m_limit_channel - 1;
- this->m_ids[0] = matte_channel;
- this->m_ids[1] = limit_channel;
- this->m_ids[2] = limit_channel;
- break;
- }
- /* MAX */
- case 1:
- {
- switch (this->m_matte_channel) {
- case 1:
- {
- this->m_ids[0] = 0;
- this->m_ids[1] = 1;
- this->m_ids[2] = 2;
- break;
- }
- case 2:
- {
- this->m_ids[0] = 1;
- this->m_ids[1] = 0;
- this->m_ids[2] = 2;
- break;
- }
- case 3:
- {
- this->m_ids[0] = 2;
- this->m_ids[1] = 0;
- this->m_ids[2] = 1;
- break;
- }
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
+ switch (this->m_limit_method) {
+ /* SINGLE */
+ case 0: {
+ /* 123 / RGB / HSV / YUV / YCC */
+ const int matte_channel = this->m_matte_channel - 1;
+ const int limit_channel = this->m_limit_channel - 1;
+ this->m_ids[0] = matte_channel;
+ this->m_ids[1] = limit_channel;
+ this->m_ids[2] = limit_channel;
+ break;
+ }
+ /* MAX */
+ case 1: {
+ switch (this->m_matte_channel) {
+ case 1: {
+ this->m_ids[0] = 0;
+ this->m_ids[1] = 1;
+ this->m_ids[2] = 2;
+ break;
+ }
+ case 2: {
+ this->m_ids[0] = 1;
+ this->m_ids[1] = 0;
+ this->m_ids[2] = 2;
+ break;
+ }
+ case 3: {
+ this->m_ids[0] = 2;
+ this->m_ids[1] = 0;
+ this->m_ids[2] = 1;
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ default:
+ break;
+ }
}
void ChannelMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = NULL;
}
-void ChannelMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ChannelMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inColor[4];
- float alpha;
+ float inColor[4];
+ float alpha;
- const float limit_max = this->m_limit_max;
- const float limit_min = this->m_limit_min;
- const float limit_range = this->m_limit_range;
+ const float limit_max = this->m_limit_max;
+ const float limit_min = this->m_limit_min;
+ const float limit_range = this->m_limit_range;
- this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
- /* matte operation */
- alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
+ /* matte operation */
+ alpha = inColor[this->m_ids[0]] - max(inColor[this->m_ids[1]], inColor[this->m_ids[2]]);
- /* flip because 0.0 is transparent, not 1.0 */
- alpha = 1.0f - alpha;
+ /* flip because 0.0 is transparent, not 1.0 */
+ alpha = 1.0f - alpha;
- /* test range */
- if (alpha > limit_max) {
- alpha = inColor[3]; /*whatever it was prior */
- }
- else if (alpha < limit_min) {
- alpha = 0.0f;
- }
- else { /*blend */
- alpha = (alpha - limit_min) / limit_range;
- }
+ /* test range */
+ if (alpha > limit_max) {
+ alpha = inColor[3]; /*whatever it was prior */
+ }
+ else if (alpha < limit_min) {
+ alpha = 0.0f;
+ }
+ else { /*blend */
+ alpha = (alpha - limit_min) / limit_range;
+ }
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
- /* don't make something that was more transparent less transparent */
- output[0] = min(alpha, inColor[3]);
+ /* don't make something that was more transparent less transparent */
+ output[0] = min(alpha, inColor[3]);
}
diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
index 152dd78a6b3..ad88b41cc91 100644
--- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h
@@ -20,54 +20,54 @@
#define __COM_CHANNELMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ChannelMatteOperation : public NodeOperation {
-private:
- SocketReader *m_inputImageProgram;
+ private:
+ SocketReader *m_inputImageProgram;
+
+ /* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */
+ int m_matte_channel; /* node->custom2 */
+ int m_limit_method; /* node->algorithm */
+ int m_limit_channel; /* node->channel */
+ float m_limit_max; /* node->storage->t1 */
+ float m_limit_min; /* node->storage->t2 */
- /* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */
- int m_matte_channel; /* node->custom2 */
- int m_limit_method; /* node->algorithm */
- int m_limit_channel; /* node->channel */
- float m_limit_max; /* node->storage->t1 */
- float m_limit_min; /* node->storage->t2 */
+ float m_limit_range;
- float m_limit_range;
+ /** ids to use for the operations (max and simple)
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ * the simple operation is using:
+ * alpha = in[ids[0]] - in[ids[1]]
+ * but to use the same formula and operation for both we do:
+ * ids[2] = ids[1]
+ * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
+ */
+ int m_ids[3];
- /** ids to use for the operations (max and simple)
- * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
- * the simple operation is using:
- * alpha = in[ids[0]] - in[ids[1]]
- * but to use the same formula and operation for both we do:
- * ids[2] = ids[1]
- * alpha = in[ids[0]] - max(in[ids[1]], in[ids[2]])
- */
- int m_ids[3];
-public:
- /**
- * Default constructor
- */
- ChannelMatteOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ ChannelMatteOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setSettings(NodeChroma *nodeChroma, const int custom2)
- {
- this->m_limit_max = nodeChroma->t1;
- this->m_limit_min = nodeChroma->t2;
- this->m_limit_method = nodeChroma->algorithm;
- this->m_limit_channel = nodeChroma->channel;
- this->m_matte_channel = custom2;
- }
+ void setSettings(NodeChroma *nodeChroma, const int custom2)
+ {
+ this->m_limit_max = nodeChroma->t1;
+ this->m_limit_min = nodeChroma->t2;
+ this->m_limit_method = nodeChroma->algorithm;
+ this->m_limit_channel = nodeChroma->channel;
+ this->m_matte_channel = custom2;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index 05a184a4b58..62dc74d2092 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -21,87 +21,90 @@
ChromaMatteOperation::ChromaMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
void ChromaMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_inputKeyProgram = this->getInputSocketReader(1);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputKeyProgram = this->getInputSocketReader(1);
}
void ChromaMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
-void ChromaMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ChromaMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inKey[4];
- float inImage[4];
-
- const float acceptance = this->m_settings->t1; /* in radians */
- const float cutoff = this->m_settings->t2; /* in radians */
- const float gain = this->m_settings->fstrength;
-
- float x_angle, z_angle, alpha;
- float theta, beta;
- float kfg;
-
- this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
- this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
-
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
-
- /* Algorithm from book "Video Demistified," does not include the spill reduction part */
- /* find theta, the angle that the color space should be rotated based on key */
-
- /* rescale to -1.0..1.0 */
- // inImage[0] = (inImage[0] * 2.0f) - 1.0f; // UNUSED
- inImage[1] = (inImage[1] * 2.0f) - 1.0f;
- inImage[2] = (inImage[2] * 2.0f) - 1.0f;
-
- // inKey[0] = (inKey[0] * 2.0f) - 1.0f; // UNUSED
- inKey[1] = (inKey[1] * 2.0f) - 1.0f;
- inKey[2] = (inKey[2] * 2.0f) - 1.0f;
-
- theta = atan2(inKey[2], inKey[1]);
-
- /*rotate the cb and cr into x/z space */
- x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
- z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
-
- /*if within the acceptance angle */
- /* if kfg is <0 then the pixel is outside of the key color */
- kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
-
- if (kfg > 0.0f) { /* found a pixel that is within key color */
- alpha = 1.0f - (kfg / gain);
-
- beta = atan2(z_angle, x_angle);
-
- /* if beta is within the cutoff angle */
- if (fabsf(beta) < (cutoff / 2.0f)) {
- alpha = 0.0f;
- }
-
- /* don't make something that was more transparent less transparent */
- if (alpha < inImage[3]) {
- output[0] = alpha;
- }
- else {
- output[0] = inImage[3];
- }
- }
- else { /*pixel is outside key color */
- output[0] = inImage[3]; /* make pixel just as transparent as it was before */
- }
+ float inKey[4];
+ float inImage[4];
+
+ const float acceptance = this->m_settings->t1; /* in radians */
+ const float cutoff = this->m_settings->t2; /* in radians */
+ const float gain = this->m_settings->fstrength;
+
+ float x_angle, z_angle, alpha;
+ float theta, beta;
+ float kfg;
+
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /* Algorithm from book "Video Demistified," does not include the spill reduction part */
+ /* find theta, the angle that the color space should be rotated based on key */
+
+ /* rescale to -1.0..1.0 */
+ // inImage[0] = (inImage[0] * 2.0f) - 1.0f; // UNUSED
+ inImage[1] = (inImage[1] * 2.0f) - 1.0f;
+ inImage[2] = (inImage[2] * 2.0f) - 1.0f;
+
+ // inKey[0] = (inKey[0] * 2.0f) - 1.0f; // UNUSED
+ inKey[1] = (inKey[1] * 2.0f) - 1.0f;
+ inKey[2] = (inKey[2] * 2.0f) - 1.0f;
+
+ theta = atan2(inKey[2], inKey[1]);
+
+ /*rotate the cb and cr into x/z space */
+ x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
+ z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
+
+ /*if within the acceptance angle */
+ /* if kfg is <0 then the pixel is outside of the key color */
+ kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
+
+ if (kfg > 0.0f) { /* found a pixel that is within key color */
+ alpha = 1.0f - (kfg / gain);
+
+ beta = atan2(z_angle, x_angle);
+
+ /* if beta is within the cutoff angle */
+ if (fabsf(beta) < (cutoff / 2.0f)) {
+ alpha = 0.0f;
+ }
+
+ /* don't make something that was more transparent less transparent */
+ if (alpha < inImage[3]) {
+ output[0] = alpha;
+ }
+ else {
+ output[0] = inImage[3];
+ }
+ }
+ else { /*pixel is outside key color */
+ output[0] = inImage[3]; /* make pixel just as transparent as it was before */
+ }
}
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
index 7782ed7e1fa..58da839823d 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h
@@ -20,30 +20,33 @@
#define __COM_CHROMAMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ChromaMatteOperation : public NodeOperation {
-private:
- NodeChroma *m_settings;
- SocketReader *m_inputImageProgram;
- SocketReader *m_inputKeyProgram;
-public:
- /**
- * Default constructor
- */
- ChromaMatteOperation();
+ private:
+ NodeChroma *m_settings;
+ SocketReader *m_inputImageProgram;
+ SocketReader *m_inputKeyProgram;
+
+ public:
+ /**
+ * Default constructor
+ */
+ ChromaMatteOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; }
+ void setSettings(NodeChroma *nodeChroma)
+ {
+ this->m_settings = nodeChroma;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
index 8debf01417e..f957186a652 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp
@@ -21,51 +21,60 @@
inline float colorbalance_cdl(float in, float offset, float power, float slope)
{
- float x = in * slope + offset;
+ float x = in * slope + offset;
- /* prevent NaN */
- if (x < 0.0f) x = 0.0f;
+ /* prevent NaN */
+ if (x < 0.0f)
+ x = 0.0f;
- return powf(x, power);
+ return powf(x, power);
}
ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
- this->setResolutionInputSocketIndex(1);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputValueOperation = NULL;
+ this->m_inputColorOperation = NULL;
+ this->setResolutionInputSocketIndex(1);
}
void ColorBalanceASCCDLOperation::initExecution()
{
- this->m_inputValueOperation = this->getInputSocketReader(0);
- this->m_inputColorOperation = this->getInputSocketReader(1);
+ this->m_inputValueOperation = this->getInputSocketReader(0);
+ this->m_inputColorOperation = this->getInputSocketReader(1);
}
-void ColorBalanceASCCDLOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorBalanceASCCDLOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- float value[4];
+ float inputColor[4];
+ float value[4];
- this->m_inputValueOperation->readSampled(value, x, y, sampler);
- this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
- float fac = value[0];
- fac = min(1.0f, fac);
- const float mfac = 1.0f - fac;
-
- output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_offset[0], this->m_power[0], this->m_slope[0]);
- output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]);
- output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]);
- output[3] = inputColor[3];
+ float fac = value[0];
+ fac = min(1.0f, fac);
+ const float mfac = 1.0f - fac;
+ output[0] = mfac * inputColor[0] +
+ fac * colorbalance_cdl(
+ inputColor[0], this->m_offset[0], this->m_power[0], this->m_slope[0]);
+ output[1] = mfac * inputColor[1] +
+ fac * colorbalance_cdl(
+ inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]);
+ output[2] = mfac * inputColor[2] +
+ fac * colorbalance_cdl(
+ inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]);
+ output[3] = inputColor[3];
}
void ColorBalanceASCCDLOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = NULL;
+ this->m_inputColorOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index 1ce0ec71538..fd1d51a293b 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -25,40 +25,49 @@
* it assumes we are in sRGB color space.
*/
class ColorBalanceASCCDLOperation : public NodeOperation {
-protected:
- /**
- * Prefetched reference to the inputProgram
- */
- SocketReader *m_inputValueOperation;
- SocketReader *m_inputColorOperation;
+ protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *m_inputValueOperation;
+ SocketReader *m_inputColorOperation;
- float m_offset[3];
- float m_power[3];
- float m_slope[3];
+ float m_offset[3];
+ float m_power[3];
+ float m_slope[3];
-public:
- /**
- * Default constructor
- */
- ColorBalanceASCCDLOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ ColorBalanceASCCDLOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setOffset(float offset[3]) { copy_v3_v3(this->m_offset, offset); }
- void setPower(float power[3]) { copy_v3_v3(this->m_power, power); }
- void setSlope(float slope[3]) { copy_v3_v3(this->m_slope, slope); }
+ void setOffset(float offset[3])
+ {
+ copy_v3_v3(this->m_offset, offset);
+ }
+ void setPower(float power[3])
+ {
+ copy_v3_v3(this->m_power, power);
+ }
+ void setSlope(float slope[3])
+ {
+ copy_v3_v3(this->m_slope, slope);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
index 5b048dfe405..48807e9218d 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cpp
@@ -19,58 +19,66 @@
#include "COM_ColorBalanceLGGOperation.h"
#include "BLI_math.h"
-
inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float gain)
{
- /* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
- * but best keep it this way, sice testing for durian shows a similar calculation
- * without lin/srgb conversions gives bad results (over-saturated shadows) with colors
- * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
- float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
+ /* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
+ * but best keep it this way, sice testing for durian shows a similar calculation
+ * without lin/srgb conversions gives bad results (over-saturated shadows) with colors
+ * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+ float x = (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
- /* prevent NaN */
- if (x < 0.0f) x = 0.0f;
+ /* prevent NaN */
+ if (x < 0.0f)
+ x = 0.0f;
- return powf(srgb_to_linearrgb(x), gamma_inv);
+ return powf(srgb_to_linearrgb(x), gamma_inv);
}
ColorBalanceLGGOperation::ColorBalanceLGGOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
- this->setResolutionInputSocketIndex(1);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputValueOperation = NULL;
+ this->m_inputColorOperation = NULL;
+ this->setResolutionInputSocketIndex(1);
}
void ColorBalanceLGGOperation::initExecution()
{
- this->m_inputValueOperation = this->getInputSocketReader(0);
- this->m_inputColorOperation = this->getInputSocketReader(1);
+ this->m_inputValueOperation = this->getInputSocketReader(0);
+ this->m_inputColorOperation = this->getInputSocketReader(1);
}
-void ColorBalanceLGGOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorBalanceLGGOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- float value[4];
-
- this->m_inputValueOperation->readSampled(value, x, y, sampler);
- this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
+ float inputColor[4];
+ float value[4];
- float fac = value[0];
- fac = min(1.0f, fac);
- const float mfac = 1.0f - fac;
+ this->m_inputValueOperation->readSampled(value, x, y, sampler);
+ this->m_inputColorOperation->readSampled(inputColor, x, y, sampler);
- output[0] = mfac * inputColor[0] + fac * colorbalance_lgg(inputColor[0], this->m_lift[0], this->m_gamma_inv[0], this->m_gain[0]);
- output[1] = mfac * inputColor[1] + fac * colorbalance_lgg(inputColor[1], this->m_lift[1], this->m_gamma_inv[1], this->m_gain[1]);
- output[2] = mfac * inputColor[2] + fac * colorbalance_lgg(inputColor[2], this->m_lift[2], this->m_gamma_inv[2], this->m_gain[2]);
- output[3] = inputColor[3];
+ float fac = value[0];
+ fac = min(1.0f, fac);
+ const float mfac = 1.0f - fac;
+ output[0] = mfac * inputColor[0] +
+ fac * colorbalance_lgg(
+ inputColor[0], this->m_lift[0], this->m_gamma_inv[0], this->m_gain[0]);
+ output[1] = mfac * inputColor[1] +
+ fac * colorbalance_lgg(
+ inputColor[1], this->m_lift[1], this->m_gamma_inv[1], this->m_gain[1]);
+ output[2] = mfac * inputColor[2] +
+ fac * colorbalance_lgg(
+ inputColor[2], this->m_lift[2], this->m_gamma_inv[2], this->m_gain[2]);
+ output[3] = inputColor[3];
}
void ColorBalanceLGGOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColorOperation = NULL;
+ this->m_inputValueOperation = NULL;
+ this->m_inputColorOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index 2a96f7fdf01..a2d4b4cd13a 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -20,46 +20,54 @@
#define __COM_COLORBALANCELGGOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ColorBalanceLGGOperation : public NodeOperation {
-protected:
- /**
- * Prefetched reference to the inputProgram
- */
- SocketReader *m_inputValueOperation;
- SocketReader *m_inputColorOperation;
+ protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *m_inputValueOperation;
+ SocketReader *m_inputColorOperation;
- float m_gain[3];
- float m_lift[3];
- float m_gamma_inv[3];
+ float m_gain[3];
+ float m_lift[3];
+ float m_gamma_inv[3];
-public:
- /**
- * Default constructor
- */
- ColorBalanceLGGOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ ColorBalanceLGGOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setGain(const float gain[3]) { copy_v3_v3(this->m_gain, gain); }
- void setLift(const float lift[3]) { copy_v3_v3(this->m_lift, lift); }
- void setGammaInv(const float gamma_inv[3]) { copy_v3_v3(this->m_gamma_inv, gamma_inv); }
+ void setGain(const float gain[3])
+ {
+ copy_v3_v3(this->m_gain, gain);
+ }
+ void setLift(const float lift[3])
+ {
+ copy_v3_v3(this->m_lift, lift);
+ }
+ void setGammaInv(const float gamma_inv[3])
+ {
+ copy_v3_v3(this->m_gamma_inv, gamma_inv);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 821f1cbb44e..a90a3e234d8 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -25,118 +25,130 @@ extern "C" {
ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputImage = NULL;
- this->m_inputMask = NULL;
- this->m_redChannelEnabled = true;
- this->m_greenChannelEnabled = true;
- this->m_blueChannelEnabled = true;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputImage = NULL;
+ this->m_inputMask = NULL;
+ this->m_redChannelEnabled = true;
+ this->m_greenChannelEnabled = true;
+ this->m_blueChannelEnabled = true;
}
void ColorCorrectionOperation::initExecution()
{
- this->m_inputImage = this->getInputSocketReader(0);
- this->m_inputMask = this->getInputSocketReader(1);
+ this->m_inputImage = this->getInputSocketReader(0);
+ this->m_inputMask = this->getInputSocketReader(1);
}
-void ColorCorrectionOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorCorrectionOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputImageColor[4];
- float inputMask[4];
- this->m_inputImage->readSampled(inputImageColor, x, y, sampler);
- this->m_inputMask->readSampled(inputMask, x, y, sampler);
-
- float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
- float contrast = this->m_data->master.contrast;
- float saturation = this->m_data->master.saturation;
- float gamma = this->m_data->master.gamma;
- float gain = this->m_data->master.gain;
- float lift = this->m_data->master.lift;
- float r, g, b;
-
- float value = inputMask[0];
- value = min(1.0f, value);
- const float mvalue = 1.0f - value;
-
- float levelShadows = 0.0;
- float levelMidtones = 0.0;
- float levelHighlights = 0.0;
+ float inputImageColor[4];
+ float inputMask[4];
+ this->m_inputImage->readSampled(inputImageColor, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
+
+ float level = (inputImageColor[0] + inputImageColor[1] + inputImageColor[2]) / 3.0f;
+ float contrast = this->m_data->master.contrast;
+ float saturation = this->m_data->master.saturation;
+ float gamma = this->m_data->master.gamma;
+ float gain = this->m_data->master.gain;
+ float lift = this->m_data->master.lift;
+ float r, g, b;
+
+ float value = inputMask[0];
+ value = min(1.0f, value);
+ const float mvalue = 1.0f - value;
+
+ float levelShadows = 0.0;
+ float levelMidtones = 0.0;
+ float levelHighlights = 0.0;
#define MARGIN 0.10f
#define MARGIN_DIV (0.5f / MARGIN)
- if (level < this->m_data->startmidtones - MARGIN) {
- levelShadows = 1.0f;
- }
- else if (level < this->m_data->startmidtones + MARGIN) {
- levelMidtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f;
- levelShadows = 1.0f - levelMidtones;
- }
- else if (level < this->m_data->endmidtones - MARGIN) {
- levelMidtones = 1.0f;
- }
- else if (level < this->m_data->endmidtones + MARGIN) {
- levelHighlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f;
- levelMidtones = 1.0f - levelHighlights;
- }
- else {
- levelHighlights = 1.0f;
- }
+ if (level < this->m_data->startmidtones - MARGIN) {
+ levelShadows = 1.0f;
+ }
+ else if (level < this->m_data->startmidtones + MARGIN) {
+ levelMidtones = ((level - this->m_data->startmidtones) * MARGIN_DIV) + 0.5f;
+ levelShadows = 1.0f - levelMidtones;
+ }
+ else if (level < this->m_data->endmidtones - MARGIN) {
+ levelMidtones = 1.0f;
+ }
+ else if (level < this->m_data->endmidtones + MARGIN) {
+ levelHighlights = ((level - this->m_data->endmidtones) * MARGIN_DIV) + 0.5f;
+ levelMidtones = 1.0f - levelHighlights;
+ }
+ else {
+ levelHighlights = 1.0f;
+ }
#undef MARGIN
#undef MARGIN_DIV
- contrast *= (levelShadows * this->m_data->shadows.contrast) + (levelMidtones * this->m_data->midtones.contrast) + (levelHighlights * this->m_data->highlights.contrast);
- saturation *= (levelShadows * this->m_data->shadows.saturation) + (levelMidtones * this->m_data->midtones.saturation) + (levelHighlights * this->m_data->highlights.saturation);
- gamma *= (levelShadows * this->m_data->shadows.gamma) + (levelMidtones * this->m_data->midtones.gamma) + (levelHighlights * this->m_data->highlights.gamma);
- gain *= (levelShadows * this->m_data->shadows.gain) + (levelMidtones * this->m_data->midtones.gain) + (levelHighlights * this->m_data->highlights.gain);
- lift += (levelShadows * this->m_data->shadows.lift) + (levelMidtones * this->m_data->midtones.lift) + (levelHighlights * this->m_data->highlights.lift);
-
- float invgamma = 1.0f / gamma;
- float luma = IMB_colormanagement_get_luminance(inputImageColor);
-
- r = inputImageColor[0];
- g = inputImageColor[1];
- b = inputImageColor[2];
-
- r = (luma + saturation * (r - luma));
- g = (luma + saturation * (g - luma));
- b = (luma + saturation * (b - luma));
-
- r = 0.5f + ((r - 0.5f) * contrast);
- g = 0.5f + ((g - 0.5f) * contrast);
- b = 0.5f + ((b - 0.5f) * contrast);
-
- r = powf(r * gain + lift, invgamma);
- g = powf(g * gain + lift, invgamma);
- b = powf(b * gain + lift, invgamma);
-
-
- // mix with mask
- r = mvalue * inputImageColor[0] + value * r;
- g = mvalue * inputImageColor[1] + value * g;
- b = mvalue * inputImageColor[2] + value * b;
-
- if (this->m_redChannelEnabled) {
- output[0] = r;
- }
- else {
- output[0] = inputImageColor[0];
- }
- if (this->m_greenChannelEnabled) {
- output[1] = g;
- }
- else {
- output[1] = inputImageColor[1];
- }
- if (this->m_blueChannelEnabled) {
- output[2] = b;
- }
- else {
- output[2] = inputImageColor[2];
- }
- output[3] = inputImageColor[3];
+ contrast *= (levelShadows * this->m_data->shadows.contrast) +
+ (levelMidtones * this->m_data->midtones.contrast) +
+ (levelHighlights * this->m_data->highlights.contrast);
+ saturation *= (levelShadows * this->m_data->shadows.saturation) +
+ (levelMidtones * this->m_data->midtones.saturation) +
+ (levelHighlights * this->m_data->highlights.saturation);
+ gamma *= (levelShadows * this->m_data->shadows.gamma) +
+ (levelMidtones * this->m_data->midtones.gamma) +
+ (levelHighlights * this->m_data->highlights.gamma);
+ gain *= (levelShadows * this->m_data->shadows.gain) +
+ (levelMidtones * this->m_data->midtones.gain) +
+ (levelHighlights * this->m_data->highlights.gain);
+ lift += (levelShadows * this->m_data->shadows.lift) +
+ (levelMidtones * this->m_data->midtones.lift) +
+ (levelHighlights * this->m_data->highlights.lift);
+
+ float invgamma = 1.0f / gamma;
+ float luma = IMB_colormanagement_get_luminance(inputImageColor);
+
+ r = inputImageColor[0];
+ g = inputImageColor[1];
+ b = inputImageColor[2];
+
+ r = (luma + saturation * (r - luma));
+ g = (luma + saturation * (g - luma));
+ b = (luma + saturation * (b - luma));
+
+ r = 0.5f + ((r - 0.5f) * contrast);
+ g = 0.5f + ((g - 0.5f) * contrast);
+ b = 0.5f + ((b - 0.5f) * contrast);
+
+ r = powf(r * gain + lift, invgamma);
+ g = powf(g * gain + lift, invgamma);
+ b = powf(b * gain + lift, invgamma);
+
+ // mix with mask
+ r = mvalue * inputImageColor[0] + value * r;
+ g = mvalue * inputImageColor[1] + value * g;
+ b = mvalue * inputImageColor[2] + value * b;
+
+ if (this->m_redChannelEnabled) {
+ output[0] = r;
+ }
+ else {
+ output[0] = inputImageColor[0];
+ }
+ if (this->m_greenChannelEnabled) {
+ output[1] = g;
+ }
+ else {
+ output[1] = inputImageColor[1];
+ }
+ if (this->m_blueChannelEnabled) {
+ output[2] = b;
+ }
+ else {
+ output[2] = inputImageColor[2];
+ }
+ output[3] = inputImageColor[3];
}
void ColorCorrectionOperation::deinitExecution()
{
- this->m_inputImage = NULL;
- this->m_inputMask = NULL;
+ this->m_inputImage = NULL;
+ this->m_inputMask = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
index 7bc85aa6f3e..ec9632acc7c 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.h
@@ -20,41 +20,52 @@
#define __COM_COLORCORRECTIONOPERATION_H__
#include "COM_NodeOperation.h"
-
class ColorCorrectionOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputImage;
- SocketReader *m_inputMask;
- NodeColorCorrection *m_data;
-
- bool m_redChannelEnabled;
- bool m_greenChannelEnabled;
- bool m_blueChannelEnabled;
-
-public:
- ColorCorrectionOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setData(NodeColorCorrection *data) { this->m_data = data; }
- void setRedChannelEnabled(bool enabled) { this->m_redChannelEnabled = enabled; }
- void setGreenChannelEnabled(bool enabled) { this->m_greenChannelEnabled = enabled; }
- void setBlueChannelEnabled(bool enabled) { this->m_blueChannelEnabled = enabled; }
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputImage;
+ SocketReader *m_inputMask;
+ NodeColorCorrection *m_data;
+
+ bool m_redChannelEnabled;
+ bool m_greenChannelEnabled;
+ bool m_blueChannelEnabled;
+
+ public:
+ ColorCorrectionOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setData(NodeColorCorrection *data)
+ {
+ this->m_data = data;
+ }
+ void setRedChannelEnabled(bool enabled)
+ {
+ this->m_redChannelEnabled = enabled;
+ }
+ void setGreenChannelEnabled(bool enabled)
+ {
+ this->m_greenChannelEnabled = enabled;
+ }
+ void setBlueChannelEnabled(bool enabled)
+ {
+ this->m_blueChannelEnabled = enabled;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
index 51fbb4ebde4..e25ef49cf28 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.cpp
@@ -21,136 +21,138 @@
#ifdef __cplusplus
extern "C" {
#endif
-# include "BKE_colortools.h"
+#include "BKE_colortools.h"
#ifdef __cplusplus
}
-#include "MEM_guardedalloc.h"
+# include "MEM_guardedalloc.h"
#endif
ColorCurveOperation::ColorCurveOperation() : CurveBaseOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
-
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputBlackProgram = NULL;
- this->m_inputWhiteProgram = NULL;
-
- this->setResolutionInputSocketIndex(1);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->m_inputFacProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputBlackProgram = NULL;
+ this->m_inputWhiteProgram = NULL;
+
+ this->setResolutionInputSocketIndex(1);
}
void ColorCurveOperation::initExecution()
{
- CurveBaseOperation::initExecution();
- this->m_inputFacProgram = this->getInputSocketReader(0);
- this->m_inputImageProgram = this->getInputSocketReader(1);
- this->m_inputBlackProgram = this->getInputSocketReader(2);
- this->m_inputWhiteProgram = this->getInputSocketReader(3);
-
- curvemapping_premultiply(this->m_curveMapping, 0);
+ CurveBaseOperation::initExecution();
+ this->m_inputFacProgram = this->getInputSocketReader(0);
+ this->m_inputImageProgram = this->getInputSocketReader(1);
+ this->m_inputBlackProgram = this->getInputSocketReader(2);
+ this->m_inputWhiteProgram = this->getInputSocketReader(3);
+ curvemapping_premultiply(this->m_curveMapping, 0);
}
-void ColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorCurveOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- CurveMapping *cumap = this->m_curveMapping;
-
- float fac[4];
- float image[4];
-
- /* local versions of cumap->black, cumap->white, cumap->bwmul */
- float black[4];
- float white[4];
- float bwmul[3];
-
- this->m_inputBlackProgram->readSampled(black, x, y, sampler);
- this->m_inputWhiteProgram->readSampled(white, x, y, sampler);
-
- /* get our own local bwmul value,
- * since we can't be threadsafe and use cumap->bwmul & friends */
- curvemapping_set_black_white_ex(black, white, bwmul);
-
- this->m_inputFacProgram->readSampled(fac, x, y, sampler);
- this->m_inputImageProgram->readSampled(image, x, y, sampler);
-
- if (*fac >= 1.0f) {
- curvemapping_evaluate_premulRGBF_ex(cumap, output, image,
- black, bwmul);
- }
- else if (*fac <= 0.0f) {
- copy_v3_v3(output, image);
- }
- else {
- float col[4];
- curvemapping_evaluate_premulRGBF_ex(cumap, col, image,
- black, bwmul);
- interp_v3_v3v3(output, image, col, *fac);
- }
- output[3] = image[3];
+ CurveMapping *cumap = this->m_curveMapping;
+
+ float fac[4];
+ float image[4];
+
+ /* local versions of cumap->black, cumap->white, cumap->bwmul */
+ float black[4];
+ float white[4];
+ float bwmul[3];
+
+ this->m_inputBlackProgram->readSampled(black, x, y, sampler);
+ this->m_inputWhiteProgram->readSampled(white, x, y, sampler);
+
+ /* get our own local bwmul value,
+ * since we can't be threadsafe and use cumap->bwmul & friends */
+ curvemapping_set_black_white_ex(black, white, bwmul);
+
+ this->m_inputFacProgram->readSampled(fac, x, y, sampler);
+ this->m_inputImageProgram->readSampled(image, x, y, sampler);
+
+ if (*fac >= 1.0f) {
+ curvemapping_evaluate_premulRGBF_ex(cumap, output, image, black, bwmul);
+ }
+ else if (*fac <= 0.0f) {
+ copy_v3_v3(output, image);
+ }
+ else {
+ float col[4];
+ curvemapping_evaluate_premulRGBF_ex(cumap, col, image, black, bwmul);
+ interp_v3_v3v3(output, image, col, *fac);
+ }
+ output[3] = image[3];
}
void ColorCurveOperation::deinitExecution()
{
- CurveBaseOperation::deinitExecution();
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputBlackProgram = NULL;
- this->m_inputWhiteProgram = NULL;
+ CurveBaseOperation::deinitExecution();
+ this->m_inputFacProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputBlackProgram = NULL;
+ this->m_inputWhiteProgram = NULL;
}
-
// Constant level curve mapping
ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() : CurveBaseOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
+ this->m_inputFacProgram = NULL;
+ this->m_inputImageProgram = NULL;
- this->setResolutionInputSocketIndex(1);
+ this->setResolutionInputSocketIndex(1);
}
void ConstantLevelColorCurveOperation::initExecution()
{
- CurveBaseOperation::initExecution();
- this->m_inputFacProgram = this->getInputSocketReader(0);
- this->m_inputImageProgram = this->getInputSocketReader(1);
+ CurveBaseOperation::initExecution();
+ this->m_inputFacProgram = this->getInputSocketReader(0);
+ this->m_inputImageProgram = this->getInputSocketReader(1);
- curvemapping_premultiply(this->m_curveMapping, 0);
+ curvemapping_premultiply(this->m_curveMapping, 0);
- curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white);
+ curvemapping_set_black_white(this->m_curveMapping, this->m_black, this->m_white);
}
-void ConstantLevelColorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConstantLevelColorCurveOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float fac[4];
- float image[4];
-
- this->m_inputFacProgram->readSampled(fac, x, y, sampler);
- this->m_inputImageProgram->readSampled(image, x, y, sampler);
-
- if (*fac >= 1.0f) {
- curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
- }
- else if (*fac <= 0.0f) {
- copy_v3_v3(output, image);
- }
- else {
- float col[4];
- curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image);
- interp_v3_v3v3(output, image, col, *fac);
- }
- output[3] = image[3];
+ float fac[4];
+ float image[4];
+
+ this->m_inputFacProgram->readSampled(fac, x, y, sampler);
+ this->m_inputImageProgram->readSampled(image, x, y, sampler);
+
+ if (*fac >= 1.0f) {
+ curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, image);
+ }
+ else if (*fac <= 0.0f) {
+ copy_v3_v3(output, image);
+ }
+ else {
+ float col[4];
+ curvemapping_evaluate_premulRGBF(this->m_curveMapping, col, image);
+ interp_v3_v3v3(output, image, col, *fac);
+ }
+ output[3] = image[3];
}
void ConstantLevelColorCurveOperation::deinitExecution()
{
- CurveBaseOperation::deinitExecution();
- this->m_inputFacProgram = NULL;
- this->m_inputImageProgram = NULL;
+ CurveBaseOperation::deinitExecution();
+ this->m_inputFacProgram = NULL;
+ this->m_inputImageProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ColorCurveOperation.h b/source/blender/compositor/operations/COM_ColorCurveOperation.h
index a1f07fedb50..1d6a9185732 100644
--- a/source/blender/compositor/operations/COM_ColorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_ColorCurveOperation.h
@@ -23,63 +23,70 @@
#include "COM_CurveBaseOperation.h"
class ColorCurveOperation : public CurveBaseOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputFacProgram;
- SocketReader *m_inputImageProgram;
- SocketReader *m_inputBlackProgram;
- SocketReader *m_inputWhiteProgram;
-public:
- ColorCurveOperation();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputFacProgram;
+ SocketReader *m_inputImageProgram;
+ SocketReader *m_inputBlackProgram;
+ SocketReader *m_inputWhiteProgram;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ ColorCurveOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
class ConstantLevelColorCurveOperation : public CurveBaseOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputFacProgram;
- SocketReader *m_inputImageProgram;
- float m_black[3];
- float m_white[3];
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputFacProgram;
+ SocketReader *m_inputImageProgram;
+ float m_black[3];
+ float m_white[3];
-public:
- ConstantLevelColorCurveOperation();
+ public:
+ ConstantLevelColorCurveOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setBlackLevel(float black[3]) { copy_v3_v3(this->m_black, black); }
- void setWhiteLevel(float white[3]) { copy_v3_v3(this->m_white, white); }
+ void setBlackLevel(float black[3])
+ {
+ copy_v3_v3(this->m_black, black);
+ }
+ void setWhiteLevel(float white[3])
+ {
+ copy_v3_v3(this->m_white, white);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
index fbc8eef0ec9..90b7f4a63b5 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp
@@ -21,61 +21,61 @@
ColorMatteOperation::ColorMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
void ColorMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_inputKeyProgram = this->getInputSocketReader(1);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputKeyProgram = this->getInputSocketReader(1);
}
void ColorMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
-void ColorMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inColor[4];
- float inKey[4];
+ float inColor[4];
+ float inKey[4];
- const float hue = this->m_settings->t1;
- const float sat = this->m_settings->t2;
- const float val = this->m_settings->t3;
+ const float hue = this->m_settings->t1;
+ const float sat = this->m_settings->t2;
+ const float val = this->m_settings->t3;
- float h_wrap;
+ float h_wrap;
- this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
- this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
+ if (
+ /* do hue last because it needs to wrap, and does some more checks */
- if (
- /* do hue last because it needs to wrap, and does some more checks */
+ /* sat */ (fabsf(inColor[1] - inKey[1]) < sat) &&
+ /* val */ (fabsf(inColor[2] - inKey[2]) < val) &&
- /* sat */ (fabsf(inColor[1] - inKey[1]) < sat) &&
- /* val */ (fabsf(inColor[2] - inKey[2]) < val) &&
+ /* multiply by 2 because it wraps on both sides of the hue,
+ * otherwise 0.5 would key all hue's */
- /* multiply by 2 because it wraps on both sides of the hue,
- * otherwise 0.5 would key all hue's */
+ /* hue */ ((h_wrap = 2.0f * fabsf(inColor[0] - inKey[0])) < hue || (2.0f - h_wrap) < hue)) {
+ output[0] = 0.0f; /* make transparent */
+ }
- /* hue */ ((h_wrap = 2.0f * fabsf(inColor[0] - inKey[0])) < hue || (2.0f - h_wrap) < hue)
- )
- {
- output[0] = 0.0f; /* make transparent */
- }
-
- else { /*pixel is outside key color */
- output[0] = inColor[3]; /* make pixel just as transparent as it was before */
- }
+ else { /*pixel is outside key color */
+ output[0] = inColor[3]; /* make pixel just as transparent as it was before */
+ }
}
diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h
index 5fe92292382..7e8a0e295e1 100644
--- a/source/blender/compositor/operations/COM_ColorMatteOperation.h
+++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h
@@ -20,30 +20,33 @@
#define __COM_COLORMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ColorMatteOperation : public NodeOperation {
-private:
- NodeChroma *m_settings;
- SocketReader *m_inputImageProgram;
- SocketReader *m_inputKeyProgram;
-public:
- /**
- * Default constructor
- */
- ColorMatteOperation();
+ private:
+ NodeChroma *m_settings;
+ SocketReader *m_inputImageProgram;
+ SocketReader *m_inputKeyProgram;
+
+ public:
+ /**
+ * Default constructor
+ */
+ ColorMatteOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; }
+ void setSettings(NodeChroma *nodeChroma)
+ {
+ this->m_settings = nodeChroma;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
index 238c22c426f..f2c153c5d30 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp
@@ -21,33 +21,36 @@
#ifdef __cplusplus
extern "C" {
#endif
-# include "BKE_colorband.h"
+#include "BKE_colorband.h"
#ifdef __cplusplus
}
#endif
ColorRampOperation::ColorRampOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
- this->m_colorBand = NULL;
+ this->m_inputProgram = NULL;
+ this->m_colorBand = NULL;
}
void ColorRampOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void ColorRampOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorRampOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float values[4];
+ float values[4];
- this->m_inputProgram->readSampled(values, x, y, sampler);
- BKE_colorband_evaluate(this->m_colorBand, values[0], output);
+ this->m_inputProgram->readSampled(values, x, y, sampler);
+ BKE_colorband_evaluate(this->m_colorBand, values[0], output);
}
void ColorRampOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.h b/source/blender/compositor/operations/COM_ColorRampOperation.h
index 9e313e9d439..3e2acda1d10 100644
--- a/source/blender/compositor/operations/COM_ColorRampOperation.h
+++ b/source/blender/compositor/operations/COM_ColorRampOperation.h
@@ -22,32 +22,34 @@
#include "DNA_texture_types.h"
class ColorRampOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- ColorBand *m_colorBand;
-public:
- ColorRampOperation();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ ColorBand *m_colorBand;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ ColorRampOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setColorBand(ColorBand *colorBand) {
- this->m_colorBand = colorBand;
- }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setColorBand(ColorBand *colorBand)
+ {
+ this->m_colorBand = colorBand;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
index 656ec1a7439..99ab6105934 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp
@@ -22,90 +22,96 @@
ColorSpillOperation::ColorSpillOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addInputSocket(COM_DT_VALUE);
- addOutputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_VALUE);
+ addOutputSocket(COM_DT_COLOR);
- this->m_inputImageReader = NULL;
- this->m_inputFacReader = NULL;
- this->m_spillChannel = 1; // GREEN
- this->m_spillMethod = 0;
+ this->m_inputImageReader = NULL;
+ this->m_inputFacReader = NULL;
+ this->m_spillChannel = 1; // GREEN
+ this->m_spillMethod = 0;
}
void ColorSpillOperation::initExecution()
{
- this->m_inputImageReader = this->getInputSocketReader(0);
- this->m_inputFacReader = this->getInputSocketReader(1);
- if (this->m_spillChannel == 0) {
- this->m_rmut = -1.0f;
- this->m_gmut = 1.0f;
- this->m_bmut = 1.0f;
- this->m_channel2 = 1;
- this->m_channel3 = 2;
- if (this->m_settings->unspill == 0) {
- this->m_settings->uspillr = 1.0f;
- this->m_settings->uspillg = 0.0f;
- this->m_settings->uspillb = 0.0f;
- }
- }
- else if (this->m_spillChannel == 1) {
- this->m_rmut = 1.0f;
- this->m_gmut = -1.0f;
- this->m_bmut = 1.0f;
- this->m_channel2 = 0;
- this->m_channel3 = 2;
- if (this->m_settings->unspill == 0) {
- this->m_settings->uspillr = 0.0f;
- this->m_settings->uspillg = 1.0f;
- this->m_settings->uspillb = 0.0f;
- }
- }
- else {
- this->m_rmut = 1.0f;
- this->m_gmut = 1.0f;
- this->m_bmut = -1.0f;
+ this->m_inputImageReader = this->getInputSocketReader(0);
+ this->m_inputFacReader = this->getInputSocketReader(1);
+ if (this->m_spillChannel == 0) {
+ this->m_rmut = -1.0f;
+ this->m_gmut = 1.0f;
+ this->m_bmut = 1.0f;
+ this->m_channel2 = 1;
+ this->m_channel3 = 2;
+ if (this->m_settings->unspill == 0) {
+ this->m_settings->uspillr = 1.0f;
+ this->m_settings->uspillg = 0.0f;
+ this->m_settings->uspillb = 0.0f;
+ }
+ }
+ else if (this->m_spillChannel == 1) {
+ this->m_rmut = 1.0f;
+ this->m_gmut = -1.0f;
+ this->m_bmut = 1.0f;
+ this->m_channel2 = 0;
+ this->m_channel3 = 2;
+ if (this->m_settings->unspill == 0) {
+ this->m_settings->uspillr = 0.0f;
+ this->m_settings->uspillg = 1.0f;
+ this->m_settings->uspillb = 0.0f;
+ }
+ }
+ else {
+ this->m_rmut = 1.0f;
+ this->m_gmut = 1.0f;
+ this->m_bmut = -1.0f;
- this->m_channel2 = 0;
- this->m_channel3 = 1;
- if (this->m_settings->unspill == 0) {
- this->m_settings->uspillr = 0.0f;
- this->m_settings->uspillg = 0.0f;
- this->m_settings->uspillb = 1.0f;
- }
- }
+ this->m_channel2 = 0;
+ this->m_channel3 = 1;
+ if (this->m_settings->unspill == 0) {
+ this->m_settings->uspillr = 0.0f;
+ this->m_settings->uspillg = 0.0f;
+ this->m_settings->uspillb = 1.0f;
+ }
+ }
}
void ColorSpillOperation::deinitExecution()
{
- this->m_inputImageReader = NULL;
- this->m_inputFacReader = NULL;
+ this->m_inputImageReader = NULL;
+ this->m_inputFacReader = NULL;
}
-void ColorSpillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ColorSpillOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float fac[4];
- float input[4];
- this->m_inputFacReader->readSampled(fac, x, y, sampler);
- this->m_inputImageReader->readSampled(input, x, y, sampler);
- float rfac = min(1.0f, fac[0]);
- float map;
+ float fac[4];
+ float input[4];
+ this->m_inputFacReader->readSampled(fac, x, y, sampler);
+ this->m_inputImageReader->readSampled(input, x, y, sampler);
+ float rfac = min(1.0f, fac[0]);
+ float map;
- switch (this->m_spillMethod) {
- case 0: /* simple */
- map = rfac * (input[this->m_spillChannel] - (this->m_settings->limscale * input[this->m_settings->limchan]));
- break;
- default: /* average */
- map = rfac * (input[this->m_spillChannel] - (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3])));
- break;
- }
+ switch (this->m_spillMethod) {
+ case 0: /* simple */
+ map = rfac * (input[this->m_spillChannel] -
+ (this->m_settings->limscale * input[this->m_settings->limchan]));
+ break;
+ default: /* average */
+ map = rfac *
+ (input[this->m_spillChannel] -
+ (this->m_settings->limscale * AVG(input[this->m_channel2], input[this->m_channel3])));
+ break;
+ }
- if (map > 0.0f) {
- output[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map);
- output[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map);
- output[2] = input[2] + this->m_bmut * (this->m_settings->uspillb * map);
- output[3] = input[3];
- }
- else {
- copy_v4_v4(output, input);
- }
+ if (map > 0.0f) {
+ output[0] = input[0] + this->m_rmut * (this->m_settings->uspillr * map);
+ output[1] = input[1] + this->m_gmut * (this->m_settings->uspillg * map);
+ output[2] = input[2] + this->m_bmut * (this->m_settings->uspillb * map);
+ output[3] = input[3];
+ }
+ else {
+ copy_v4_v4(output, input);
+ }
}
diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h
index 6682abdc4ec..73f4f5b045d 100644
--- a/source/blender/compositor/operations/COM_ColorSpillOperation.h
+++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h
@@ -25,34 +25,44 @@
* it assumes we are in sRGB color space.
*/
class ColorSpillOperation : public NodeOperation {
-protected:
- NodeColorspill *m_settings;
- SocketReader *m_inputImageReader;
- SocketReader *m_inputFacReader;
- int m_spillChannel;
- int m_spillMethod;
- int m_channel2;
- int m_channel3;
- float m_rmut, m_gmut, m_bmut;
-public:
- /**
- * Default constructor
- */
- ColorSpillOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
-
- void setSettings(NodeColorspill *nodeColorSpill) { this->m_settings = nodeColorSpill; }
- void setSpillChannel(int channel) { this->m_spillChannel = channel; }
- void setSpillMethod(int method) { this->m_spillMethod = method; }
-
- float calculateMapValue(float fac, float *input);
+ protected:
+ NodeColorspill *m_settings;
+ SocketReader *m_inputImageReader;
+ SocketReader *m_inputFacReader;
+ int m_spillChannel;
+ int m_spillMethod;
+ int m_channel2;
+ int m_channel3;
+ float m_rmut, m_gmut, m_bmut;
+
+ public:
+ /**
+ * Default constructor
+ */
+ ColorSpillOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeColorspill *nodeColorSpill)
+ {
+ this->m_settings = nodeColorSpill;
+ }
+ void setSpillChannel(int channel)
+ {
+ this->m_spillChannel = channel;
+ }
+ void setSpillMethod(int method)
+ {
+ this->m_spillMethod = method;
+ }
+
+ float calculateMapValue(float fac, float *input);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.cpp b/source/blender/compositor/operations/COM_CompositorOperation.cpp
index 7d124e41a45..018b1662e0f 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.cpp
+++ b/source/blender/compositor/operations/COM_CompositorOperation.cpp
@@ -22,215 +22,220 @@
#include "BKE_image.h"
extern "C" {
-# include "BLI_threads.h"
-# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
-# include "RE_render_ext.h"
-# include "MEM_guardedalloc.h"
-# include "render_types.h"
+#include "BLI_threads.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
+#include "MEM_guardedalloc.h"
+#include "render_types.h"
}
#include "PIL_time.h"
-
CompositorOperation::CompositorOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
-
- this->setRenderData(NULL);
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
-
- this->m_useAlphaInput = false;
- this->m_active = false;
-
- this->m_scene = NULL;
- this->m_sceneName[0] = '\0';
- this->m_viewName = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+
+ this->setRenderData(NULL);
+ this->m_outputBuffer = NULL;
+ this->m_depthBuffer = NULL;
+ this->m_imageInput = NULL;
+ this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
+
+ this->m_useAlphaInput = false;
+ this->m_active = false;
+
+ this->m_scene = NULL;
+ this->m_sceneName[0] = '\0';
+ this->m_viewName = NULL;
}
void CompositorOperation::initExecution()
{
- if (!this->m_active)
- return;
-
- // When initializing the tree during initial load the width and height can be zero.
- this->m_imageInput = getInputSocketReader(0);
- this->m_alphaInput = getInputSocketReader(1);
- this->m_depthInput = getInputSocketReader(2);
- if (this->getWidth() * this->getHeight() != 0) {
- this->m_outputBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation");
- }
- if (this->m_depthInput != NULL) {
- this->m_depthBuffer = (float *) MEM_callocN(this->getWidth() * this->getHeight() * sizeof(float), "CompositorOperation");
- }
+ if (!this->m_active)
+ return;
+
+ // When initializing the tree during initial load the width and height can be zero.
+ this->m_imageInput = getInputSocketReader(0);
+ this->m_alphaInput = getInputSocketReader(1);
+ this->m_depthInput = getInputSocketReader(2);
+ if (this->getWidth() * this->getHeight() != 0) {
+ this->m_outputBuffer = (float *)MEM_callocN(
+ this->getWidth() * this->getHeight() * 4 * sizeof(float), "CompositorOperation");
+ }
+ if (this->m_depthInput != NULL) {
+ this->m_depthBuffer = (float *)MEM_callocN(
+ this->getWidth() * this->getHeight() * sizeof(float), "CompositorOperation");
+ }
}
void CompositorOperation::deinitExecution()
{
- if (!this->m_active)
- return;
-
- if (!isBreaked()) {
- Render *re = RE_GetSceneRender(this->m_scene);
- RenderResult *rr = RE_AcquireResultWrite(re);
-
- if (rr) {
- RenderView *rv = RE_RenderViewGetByName(rr, this->m_viewName);
-
- if (rv->rectf != NULL) {
- MEM_freeN(rv->rectf);
- }
- rv->rectf = this->m_outputBuffer;
- if (rv->rectz != NULL) {
- MEM_freeN(rv->rectz);
- }
- rv->rectz = this->m_depthBuffer;
- rr->have_combined = true;
- }
- else {
- if (this->m_outputBuffer) {
- MEM_freeN(this->m_outputBuffer);
- }
- if (this->m_depthBuffer) {
- MEM_freeN(this->m_depthBuffer);
- }
- }
-
- if (re) {
- RE_ReleaseResult(re);
- re = NULL;
- }
-
- BLI_thread_lock(LOCK_DRAW_IMAGE);
- BKE_image_signal(G.main, BKE_image_verify_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
- BLI_thread_unlock(LOCK_DRAW_IMAGE);
- }
- else {
- if (this->m_outputBuffer) {
- MEM_freeN(this->m_outputBuffer);
- }
- if (this->m_depthBuffer) {
- MEM_freeN(this->m_depthBuffer);
- }
- }
-
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
+ if (!this->m_active)
+ return;
+
+ if (!isBreaked()) {
+ Render *re = RE_GetSceneRender(this->m_scene);
+ RenderResult *rr = RE_AcquireResultWrite(re);
+
+ if (rr) {
+ RenderView *rv = RE_RenderViewGetByName(rr, this->m_viewName);
+
+ if (rv->rectf != NULL) {
+ MEM_freeN(rv->rectf);
+ }
+ rv->rectf = this->m_outputBuffer;
+ if (rv->rectz != NULL) {
+ MEM_freeN(rv->rectz);
+ }
+ rv->rectz = this->m_depthBuffer;
+ rr->have_combined = true;
+ }
+ else {
+ if (this->m_outputBuffer) {
+ MEM_freeN(this->m_outputBuffer);
+ }
+ if (this->m_depthBuffer) {
+ MEM_freeN(this->m_depthBuffer);
+ }
+ }
+
+ if (re) {
+ RE_ReleaseResult(re);
+ re = NULL;
+ }
+
+ BLI_thread_lock(LOCK_DRAW_IMAGE);
+ BKE_image_signal(G.main,
+ BKE_image_verify_viewer(G.main, IMA_TYPE_R_RESULT, "Render Result"),
+ NULL,
+ IMA_SIGNAL_FREE);
+ BLI_thread_unlock(LOCK_DRAW_IMAGE);
+ }
+ else {
+ if (this->m_outputBuffer) {
+ MEM_freeN(this->m_outputBuffer);
+ }
+ if (this->m_depthBuffer) {
+ MEM_freeN(this->m_depthBuffer);
+ }
+ }
+
+ this->m_outputBuffer = NULL;
+ this->m_depthBuffer = NULL;
+ this->m_imageInput = NULL;
+ this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
}
-
void CompositorOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- float color[8]; // 7 is enough
- float *buffer = this->m_outputBuffer;
- float *zbuffer = this->m_depthBuffer;
-
- if (!buffer) return;
- int x1 = rect->xmin;
- int y1 = rect->ymin;
- int x2 = rect->xmax;
- int y2 = rect->ymax;
- int offset = (y1 * this->getWidth() + x1);
- int add = (this->getWidth() - (x2 - x1));
- int offset4 = offset * COM_NUM_CHANNELS_COLOR;
- int x;
- int y;
- bool breaked = false;
- int dx = 0, dy = 0;
+ float color[8]; // 7 is enough
+ float *buffer = this->m_outputBuffer;
+ float *zbuffer = this->m_depthBuffer;
+
+ if (!buffer)
+ return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1 * this->getWidth() + x1);
+ int add = (this->getWidth() - (x2 - x1));
+ int offset4 = offset * COM_NUM_CHANNELS_COLOR;
+ int x;
+ int y;
+ bool breaked = false;
+ int dx = 0, dy = 0;
#if 0
- const RenderData *rd = this->m_rd;
-
- if (rd->mode & R_BORDER && rd->mode & R_CROP) {
- /**
- * When using cropped render result, need to re-position area of interest,
- * so it'll natch bounds of render border within frame. By default, canvas
- * will be centered between full frame and cropped frame, so we use such
- * scheme to map cropped coordinates to full-frame coordinates
- *
- * ^ Y
- * | Width
- * +------------------------------------------------+
- * | |
- * | |
- * | Centered canvas, we map coordinate from it |
- * | +------------------+ |
- * | | | | H
- * | | | | e
- * | +------------------+ . Center | | i
- * | | | | | | g
- * | | | | | | h
- * | |....dx.... +------|-----------+ | t
- * | | . dy | |
- * | +------------------+ |
- * | Render border, we map coordinates to it |
- * | | X
- * +------------------------------------------------+---->
- * Full frame
- */
-
- int full_width = rd->xsch * rd->size / 100;
- int full_height = rd->ysch * rd->size / 100;
-
- dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
- dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
- }
+ const RenderData *rd = this->m_rd;
+
+ if (rd->mode & R_BORDER && rd->mode & R_CROP) {
+ /**
+ * When using cropped render result, need to re-position area of interest,
+ * so it'll natch bounds of render border within frame. By default, canvas
+ * will be centered between full frame and cropped frame, so we use such
+ * scheme to map cropped coordinates to full-frame coordinates
+ *
+ * ^ Y
+ * | Width
+ * +------------------------------------------------+
+ * | |
+ * | |
+ * | Centered canvas, we map coordinate from it |
+ * | +------------------+ |
+ * | | | | H
+ * | | | | e
+ * | +------------------+ . Center | | i
+ * | | | | | | g
+ * | | | | | | h
+ * | |....dx.... +------|-----------+ | t
+ * | | . dy | |
+ * | +------------------+ |
+ * | Render border, we map coordinates to it |
+ * | | X
+ * +------------------------------------------------+---->
+ * Full frame
+ */
+
+ int full_width = rd->xsch * rd->size / 100;
+ int full_height = rd->ysch * rd->size / 100;
+
+ dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
+ dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
+ }
#endif
- for (y = y1; y < y2 && (!breaked); y++) {
- for (x = x1; x < x2 && (!breaked); x++) {
- int input_x = x + dx, input_y = y + dy;
-
- this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- if (this->m_useAlphaInput) {
- this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
- }
-
- copy_v4_v4(buffer + offset4, color);
-
- this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
- zbuffer[offset] = color[0];
- offset4 += COM_NUM_CHANNELS_COLOR;
- offset++;
- if (isBreaked()) {
- breaked = true;
- }
- }
- offset += add;
- offset4 += add * COM_NUM_CHANNELS_COLOR;
- }
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2 && (!breaked); x++) {
+ int input_x = x + dx, input_y = y + dy;
+
+ this->m_imageInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+ if (this->m_useAlphaInput) {
+ this->m_alphaInput->readSampled(&(color[3]), input_x, input_y, COM_PS_NEAREST);
+ }
+
+ copy_v4_v4(buffer + offset4, color);
+
+ this->m_depthInput->readSampled(color, input_x, input_y, COM_PS_NEAREST);
+ zbuffer[offset] = color[0];
+ offset4 += COM_NUM_CHANNELS_COLOR;
+ offset++;
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ offset += add;
+ offset4 += add * COM_NUM_CHANNELS_COLOR;
+ }
}
-void CompositorOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void CompositorOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- int width = this->m_rd->xsch * this->m_rd->size / 100;
- int height = this->m_rd->ysch * this->m_rd->size / 100;
-
- // check actual render resolution with cropping it may differ with cropped border.rendering
- // FIX for: [31777] Border Crop gives black (easy)
- Render *re = RE_GetSceneRender(this->m_scene);
- if (re) {
- RenderResult *rr = RE_AcquireResultRead(re);
- if (rr) {
- width = rr->rectx;
- height = rr->recty;
- }
- RE_ReleaseResult(re);
- }
-
- preferredResolution[0] = width;
- preferredResolution[1] = height;
-
- NodeOperation::determineResolution(resolution, preferredResolution);
-
- resolution[0] = width;
- resolution[1] = height;
+ int width = this->m_rd->xsch * this->m_rd->size / 100;
+ int height = this->m_rd->ysch * this->m_rd->size / 100;
+
+ // check actual render resolution with cropping it may differ with cropped border.rendering
+ // FIX for: [31777] Border Crop gives black (easy)
+ Render *re = RE_GetSceneRender(this->m_scene);
+ if (re) {
+ RenderResult *rr = RE_AcquireResultRead(re);
+ if (rr) {
+ width = rr->rectx;
+ height = rr->recty;
+ }
+ RE_ReleaseResult(re);
+ }
+
+ preferredResolution[0] = width;
+ preferredResolution[1] = height;
+
+ NodeOperation::determineResolution(resolution, preferredResolution);
+
+ resolution[0] = width;
+ resolution[1] = height;
}
diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h
index 3d195bd3c6c..d24fc49059c 100644
--- a/source/blender/compositor/operations/COM_CompositorOperation.h
+++ b/source/blender/compositor/operations/COM_CompositorOperation.h
@@ -28,71 +28,99 @@ struct Scene;
* \brief Compositor output operation
*/
class CompositorOperation : public NodeOperation {
-private:
- const struct Scene *m_scene;
- /**
- * \brief Scene name, used for getting the render output, includes 'SC' prefix.
- */
- char m_sceneName[MAX_ID_NAME];
+ private:
+ const struct Scene *m_scene;
+ /**
+ * \brief Scene name, used for getting the render output, includes 'SC' prefix.
+ */
+ char m_sceneName[MAX_ID_NAME];
- /**
- * \brief local reference to the scene
- */
- const RenderData *m_rd;
+ /**
+ * \brief local reference to the scene
+ */
+ const RenderData *m_rd;
- /**
- * \brief reference to the output float buffer
- */
- float *m_outputBuffer;
+ /**
+ * \brief reference to the output float buffer
+ */
+ float *m_outputBuffer;
- /**
- * \brief reference to the output depth float buffer
- */
- float *m_depthBuffer;
+ /**
+ * \brief reference to the output depth float buffer
+ */
+ float *m_depthBuffer;
- /**
- * \brief local reference to the input image operation
- */
- SocketReader *m_imageInput;
+ /**
+ * \brief local reference to the input image operation
+ */
+ SocketReader *m_imageInput;
- /**
- * \brief local reference to the input alpha operation
- */
- SocketReader *m_alphaInput;
+ /**
+ * \brief local reference to the input alpha operation
+ */
+ SocketReader *m_alphaInput;
- /**
- * \brief local reference to the depth operation
- */
- SocketReader *m_depthInput;
+ /**
+ * \brief local reference to the depth operation
+ */
+ SocketReader *m_depthInput;
- /**
- * \brief Ignore any alpha input
- */
- bool m_useAlphaInput;
+ /**
+ * \brief Ignore any alpha input
+ */
+ bool m_useAlphaInput;
- /**
- * \brief operation is active for calculating final compo result
- */
- bool m_active;
+ /**
+ * \brief operation is active for calculating final compo result
+ */
+ bool m_active;
- /**
- * \brief View name, used for multiview
- */
- const char *m_viewName;
-public:
- CompositorOperation();
- bool isActiveCompositorOutput() const { return this->m_active; }
- void executeRegion(rcti *rect, unsigned int tileNumber);
- void setScene(const struct Scene *scene) { m_scene = scene; }
- void setSceneName(const char *sceneName) { BLI_strncpy(this->m_sceneName, sceneName, sizeof(this->m_sceneName)); }
- void setViewName(const char *viewName) { this->m_viewName = viewName; }
- void setRenderData(const RenderData *rd) { this->m_rd = rd; }
- bool isOutputOperation(bool /*rendering*/) const { return this->isActiveCompositorOutput(); }
- void initExecution();
- void deinitExecution();
- CompositorPriority getRenderPriority() const { return COM_PRIORITY_MEDIUM; }
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void setUseAlphaInput(bool value) { this->m_useAlphaInput = value; }
- void setActive(bool active) { this->m_active = active; }
+ /**
+ * \brief View name, used for multiview
+ */
+ const char *m_viewName;
+
+ public:
+ CompositorOperation();
+ bool isActiveCompositorOutput() const
+ {
+ return this->m_active;
+ }
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ void setScene(const struct Scene *scene)
+ {
+ m_scene = scene;
+ }
+ void setSceneName(const char *sceneName)
+ {
+ BLI_strncpy(this->m_sceneName, sceneName, sizeof(this->m_sceneName));
+ }
+ void setViewName(const char *viewName)
+ {
+ this->m_viewName = viewName;
+ }
+ void setRenderData(const RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+ bool isOutputOperation(bool /*rendering*/) const
+ {
+ return this->isActiveCompositorOutput();
+ }
+ void initExecution();
+ void deinitExecution();
+ CompositorPriority getRenderPriority() const
+ {
+ return COM_PRIORITY_MEDIUM;
+ }
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void setUseAlphaInput(bool value)
+ {
+ this->m_useAlphaInput = value;
+ }
+ void setActive(bool active)
+ {
+ this->m_active = active;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
index 3b04bc41367..59a605a77c9 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.cpp
@@ -19,29 +19,33 @@
#include "COM_ConvertColorProfileOperation.h"
extern "C" {
-# include "IMB_imbuf.h"
+#include "IMB_imbuf.h"
}
ConvertColorProfileOperation::ConvertColorProfileOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
- this->m_predivided = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputOperation = NULL;
+ this->m_predivided = false;
}
void ConvertColorProfileOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
-void ConvertColorProfileOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorProfileOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float color[4];
- this->m_inputOperation->readSampled(color, x, y, sampler);
- IMB_buffer_float_from_float(output, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0);
+ float color[4];
+ this->m_inputOperation->readSampled(color, x, y, sampler);
+ IMB_buffer_float_from_float(
+ output, color, 4, this->m_toProfile, this->m_fromProfile, this->m_predivided, 1, 1, 0, 0);
}
void ConvertColorProfileOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
index 86e6971c528..7cc39a47dd0 100644
--- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h
@@ -20,55 +20,64 @@
#define __COM_CONVERTCOLORPROFILEOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertColorProfileOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputOperation;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputOperation;
+
+ /**
+ * \brief color profile where to convert from
+ */
+ int m_fromProfile;
- /**
- * \brief color profile where to convert from
- */
- int m_fromProfile;
+ /**
+ * \brief color profile where to convert to
+ */
+ int m_toProfile;
- /**
- * \brief color profile where to convert to
- */
- int m_toProfile;
+ /**
+ * \brief is color predivided
+ */
+ bool m_predivided;
- /**
- * \brief is color predivided
- */
- bool m_predivided;
-public:
- /**
- * Default constructor
- */
- ConvertColorProfileOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ ConvertColorProfileOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setFromColorProfile(int colorProfile) { this->m_fromProfile = colorProfile; }
- void setToColorProfile(int colorProfile) { this->m_toProfile = colorProfile; }
- void setPredivided(bool predivided) { this->m_predivided = predivided; }
+ void setFromColorProfile(int colorProfile)
+ {
+ this->m_fromProfile = colorProfile;
+ }
+ void setToColorProfile(int colorProfile)
+ {
+ this->m_toProfile = colorProfile;
+ }
+ void setPredivided(bool predivided)
+ {
+ this->m_predivided = predivided;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
index c0c9c413c8b..7b63d3ef3cb 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
@@ -23,81 +23,91 @@
ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
- this->m_fStop = 128.0f;
- this->m_cameraObject = NULL;
- this->m_maxRadius = 32.0f;
- this->m_blurPostOperation = NULL;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputOperation = NULL;
+ this->m_fStop = 128.0f;
+ this->m_cameraObject = NULL;
+ this->m_maxRadius = 32.0f;
+ this->m_blurPostOperation = NULL;
}
float ConvertDepthToRadiusOperation::determineFocalDistance()
{
- if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
- Camera *camera = (Camera *)this->m_cameraObject->data;
- this->m_cam_lens = camera->lens;
- return BKE_camera_object_dof_distance(this->m_cameraObject);
- }
- else {
- return 10.0f;
- }
+ if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
+ Camera *camera = (Camera *)this->m_cameraObject->data;
+ this->m_cam_lens = camera->lens;
+ return BKE_camera_object_dof_distance(this->m_cameraObject);
+ }
+ else {
+ return 10.0f;
+ }
}
void ConvertDepthToRadiusOperation::initExecution()
{
- float cam_sensor = DEFAULT_SENSOR_WIDTH;
- Camera *camera = NULL;
+ float cam_sensor = DEFAULT_SENSOR_WIDTH;
+ Camera *camera = NULL;
- if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
- camera = (Camera *)this->m_cameraObject->data;
- cam_sensor = BKE_camera_sensor_size(camera->sensor_fit, camera->sensor_x, camera->sensor_y);
- }
+ if (this->m_cameraObject && this->m_cameraObject->type == OB_CAMERA) {
+ camera = (Camera *)this->m_cameraObject->data;
+ cam_sensor = BKE_camera_sensor_size(camera->sensor_fit, camera->sensor_x, camera->sensor_y);
+ }
- this->m_inputOperation = this->getInputSocketReader(0);
- float focalDistance = determineFocalDistance();
- if (focalDistance == 0.0f) focalDistance = 1e10f; /* if the dof is 0.0 then set it to be far away */
- this->m_inverseFocalDistance = 1.0f / focalDistance;
- this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight());
- this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
- const float minsz = min(getWidth(), getHeight());
- this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens); // <- == aspect * min(img->x, img->y) / tan(0.5f * fov);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ float focalDistance = determineFocalDistance();
+ if (focalDistance == 0.0f)
+ focalDistance = 1e10f; /* if the dof is 0.0 then set it to be far away */
+ this->m_inverseFocalDistance = 1.0f / focalDistance;
+ this->m_aspect = (this->getWidth() > this->getHeight()) ?
+ (this->getHeight() / (float)this->getWidth()) :
+ (this->getWidth() / (float)this->getHeight());
+ this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop;
+ const float minsz = min(getWidth(), getHeight());
+ this->m_dof_sp = minsz /
+ ((cam_sensor / 2.0f) /
+ this->m_cam_lens); // <- == aspect * min(img->x, img->y) / tan(0.5f * fov);
- if (this->m_blurPostOperation) {
- m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
- }
+ if (this->m_blurPostOperation) {
+ m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
+ }
}
-void ConvertDepthToRadiusOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertDepthToRadiusOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue[4];
- float z;
- float radius;
- this->m_inputOperation->readSampled(inputValue, x, y, sampler);
- z = inputValue[0];
- if (z != 0.0f) {
- float iZ = (1.0f / z);
+ float inputValue[4];
+ float z;
+ float radius;
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
+ z = inputValue[0];
+ if (z != 0.0f) {
+ float iZ = (1.0f / z);
- // bug #6656 part 2b, do not rescale
+ // bug #6656 part 2b, do not rescale
#if 0
- bcrad = 0.5f * fabs(aperture * (dof_sp * (cam_invfdist - iZ) - 1.0f));
- // scale crad back to original maximum and blend
- crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);
+ bcrad = 0.5f * fabs(aperture * (dof_sp * (cam_invfdist - iZ) - 1.0f));
+ // scale crad back to original maximum and blend
+ crad->rect[px] = bcrad + wts->rect[px] * (scf * crad->rect[px] - bcrad);
#endif
- radius = 0.5f * fabsf(this->m_aperture * (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
- // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
- if (radius < 0.0f) radius = 0.0f;
- if (radius > this->m_maxRadius) {
- radius = this->m_maxRadius;
- }
- output[0] = radius;
- }
- else {
- output[0] = 0.0f;
- }
+ radius = 0.5f * fabsf(this->m_aperture *
+ (this->m_dof_sp * (this->m_inverseFocalDistance - iZ) - 1.0f));
+ // 'bug' #6615, limit minimum radius to 1 pixel, not really a solution, but somewhat mitigates the problem
+ if (radius < 0.0f)
+ radius = 0.0f;
+ if (radius > this->m_maxRadius) {
+ radius = this->m_maxRadius;
+ }
+ output[0] = radius;
+ }
+ else {
+ output[0] = 0.0f;
+ }
}
void ConvertDepthToRadiusOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
index 2611c082a05..f375d6efb8f 100644
--- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h
@@ -26,47 +26,59 @@
* it assumes we are in sRGB color space.
*/
class ConvertDepthToRadiusOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputOperation;
- float m_fStop;
- float m_aspect;
- float m_maxRadius;
- float m_inverseFocalDistance;
- float m_aperture;
- float m_cam_lens;
- float m_dof_sp;
- Object *m_cameraObject;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputOperation;
+ float m_fStop;
+ float m_aspect;
+ float m_maxRadius;
+ float m_inverseFocalDistance;
+ float m_aperture;
+ float m_cam_lens;
+ float m_dof_sp;
+ Object *m_cameraObject;
- FastGaussianBlurValueOperation *m_blurPostOperation;
-public:
- /**
- * Default constructor
- */
- ConvertDepthToRadiusOperation();
+ FastGaussianBlurValueOperation *m_blurPostOperation;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Default constructor
+ */
+ ConvertDepthToRadiusOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setfStop(float fStop) { this->m_fStop = fStop; }
- void setMaxRadius(float maxRadius) { this->m_maxRadius = maxRadius; }
- void setCameraObject(Object *camera) { this->m_cameraObject = camera; }
- float determineFocalDistance();
- void setPostBlur(FastGaussianBlurValueOperation *operation) { this->m_blurPostOperation = operation; }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ void setfStop(float fStop)
+ {
+ this->m_fStop = fStop;
+ }
+ void setMaxRadius(float maxRadius)
+ {
+ this->m_maxRadius = maxRadius;
+ }
+ void setCameraObject(Object *camera)
+ {
+ this->m_cameraObject = camera;
+ }
+ float determineFocalDistance();
+ void setPostBlur(FastGaussianBlurValueOperation *operation)
+ {
+ this->m_blurPostOperation = operation;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 5c32ac7e48e..6caccb89046 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -24,406 +24,459 @@ extern "C" {
ConvertBaseOperation::ConvertBaseOperation()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
void ConvertBaseOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertBaseOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
-
/* ******** Value to Color ******** */
ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertValueToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertValueToColorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float value;
- this->m_inputOperation->readSampled(&value, x, y, sampler);
- output[0] = output[1] = output[2] = value;
- output[3] = 1.0f;
+ float value;
+ this->m_inputOperation->readSampled(&value, x, y, sampler);
+ output[0] = output[1] = output[2] = value;
+ output[3] = 1.0f;
}
-
/* ******** Color to Value ******** */
ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertColorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToValueOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}
-
/* ******** Color to BW ******** */
ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertColorToBWOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToBWOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- output[0] = IMB_colormanagement_get_luminance(inputColor);
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ output[0] = IMB_colormanagement_get_luminance(inputColor);
}
-
/* ******** Color to Vector ******** */
ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VECTOR);
}
-void ConvertColorToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertColorToVectorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float color[4];
- this->m_inputOperation->readSampled(color, x, y, sampler);
- copy_v3_v3(output, color);}
-
+ float color[4];
+ this->m_inputOperation->readSampled(color, x, y, sampler);
+ copy_v3_v3(output, color);
+}
/* ******** Value to Vector ******** */
ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VECTOR);
}
-void ConvertValueToVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertValueToVectorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float value;
- this->m_inputOperation->readSampled(&value, x, y, sampler);
- output[0] = output[1] = output[2] = value;
+ float value;
+ this->m_inputOperation->readSampled(&value, x, y, sampler);
+ output[0] = output[1] = output[2] = value;
}
-
/* ******** Vector to Color ******** */
ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_VECTOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertVectorToColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertVectorToColorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- this->m_inputOperation->readSampled(output, x, y, sampler);
- output[3] = 1.0f;
+ this->m_inputOperation->readSampled(output, x, y, sampler);
+ output[3] = 1.0f;
}
-
/* ******** Vector to Value ******** */
ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_VECTOR);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VALUE);
}
-void ConvertVectorToValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertVectorToValueOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float input[4];
- this->m_inputOperation->readSampled(input, x, y, sampler);
- output[0] = (input[0] + input[1] + input[2]) / 3.0f;
+ float input[4];
+ this->m_inputOperation->readSampled(input, x, y, sampler);
+ output[0] = (input[0] + input[1] + input[2]) / 3.0f;
}
-
/* ******** RGB to YCC ******** */
ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
void ConvertRGBToYCCOperation::setMode(int mode)
{
- switch (mode) {
- case 0:
- this->m_mode = BLI_YCC_ITU_BT601;
- break;
- case 2:
- this->m_mode = BLI_YCC_JFIF_0_255;
- break;
- case 1:
- default:
- this->m_mode = BLI_YCC_ITU_BT709;
- break;
- }
+ switch (mode) {
+ case 0:
+ this->m_mode = BLI_YCC_ITU_BT601;
+ break;
+ case 2:
+ this->m_mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 1:
+ default:
+ this->m_mode = BLI_YCC_ITU_BT709;
+ break;
+ }
}
-void ConvertRGBToYCCOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- float color[3];
+ float inputColor[4];
+ float color[3];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ rgb_to_ycc(
+ inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
- /* divided by 255 to normalize for viewing in */
- /* R,G,B --> Y,Cb,Cr */
- mul_v3_v3fl(output, color, 1.0f / 255.0f);
- output[3] = inputColor[3];
+ /* divided by 255 to normalize for viewing in */
+ /* R,G,B --> Y,Cb,Cr */
+ mul_v3_v3fl(output, color, 1.0f / 255.0f);
+ output[3] = inputColor[3];
}
/* ******** YCC to RGB ******** */
ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
void ConvertYCCToRGBOperation::setMode(int mode)
{
- switch (mode) {
- case 0:
- this->m_mode = BLI_YCC_ITU_BT601;
- break;
- case 2:
- this->m_mode = BLI_YCC_JFIF_0_255;
- break;
- case 1:
- default:
- this->m_mode = BLI_YCC_ITU_BT709;
- break;
- }
+ switch (mode) {
+ case 0:
+ this->m_mode = BLI_YCC_ITU_BT601;
+ break;
+ case 2:
+ this->m_mode = BLI_YCC_JFIF_0_255;
+ break;
+ case 1:
+ default:
+ this->m_mode = BLI_YCC_ITU_BT709;
+ break;
+ }
+}
+
+void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+
+ /* need to un-normalize the data */
+ /* R,G,B --> Y,Cb,Cr */
+ mul_v3_fl(inputColor, 255.0f);
+
+ ycc_to_rgb(inputColor[0],
+ inputColor[1],
+ inputColor[2],
+ &output[0],
+ &output[1],
+ &output[2],
+ this->m_mode);
+ output[3] = inputColor[3];
}
-void ConvertYCCToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
-{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
-
- /* need to un-normalize the data */
- /* R,G,B --> Y,Cb,Cr */
- mul_v3_fl(inputColor, 255.0f);
-
- ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], this->m_mode);
- output[3] = inputColor[3];
-}
-
-
/* ******** RGB to YUV ******** */
ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertRGBToYUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToYUVOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], BLI_YUV_ITU_BT709);
- output[3] = inputColor[3];
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ rgb_to_yuv(inputColor[0],
+ inputColor[1],
+ inputColor[2],
+ &output[0],
+ &output[1],
+ &output[2],
+ BLI_YUV_ITU_BT709);
+ output[3] = inputColor[3];
}
-
/* ******** YUV to RGB ******** */
ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertYUVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertYUVToRGBOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], BLI_YUV_ITU_BT709);
- output[3] = inputColor[3];
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ yuv_to_rgb(inputColor[0],
+ inputColor[1],
+ inputColor[2],
+ &output[0],
+ &output[1],
+ &output[2],
+ BLI_YUV_ITU_BT709);
+ output[3] = inputColor[3];
}
-
/* ******** RGB to HSV ******** */
ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertRGBToHSVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertRGBToHSVOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- rgb_to_hsv_v(inputColor, output);
- output[3] = inputColor[3];
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ rgb_to_hsv_v(inputColor, output);
+ output[3] = inputColor[3];
}
-
/* ******** HSV to RGB ******** */
ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertHSVToRGBOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertHSVToRGBOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputOperation->readSampled(inputColor, x, y, sampler);
- hsv_to_rgb_v(inputColor, output);
- output[0] = max_ff(output[0], 0.0f);
- output[1] = max_ff(output[1], 0.0f);
- output[2] = max_ff(output[2], 0.0f);
- output[3] = inputColor[3];
+ float inputColor[4];
+ this->m_inputOperation->readSampled(inputColor, x, y, sampler);
+ hsv_to_rgb_v(inputColor, output);
+ output[0] = max_ff(output[0], 0.0f);
+ output[1] = max_ff(output[1], 0.0f);
+ output[2] = max_ff(output[2], 0.0f);
+ output[3] = inputColor[3];
}
-
/* ******** Premul to Straight ******** */
ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertPremulToStraightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertPremulToStraightOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue[4];
- float alpha;
+ float inputValue[4];
+ float alpha;
- this->m_inputOperation->readSampled(inputValue, x, y, sampler);
- alpha = inputValue[3];
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
+ alpha = inputValue[3];
- if (fabsf(alpha) < 1e-5f) {
- zero_v3(output);
- }
- else {
- mul_v3_v3fl(output, inputValue, 1.0f / alpha);
- }
+ if (fabsf(alpha) < 1e-5f) {
+ zero_v3(output);
+ }
+ else {
+ mul_v3_v3fl(output, inputValue, 1.0f / alpha);
+ }
- /* never touches the alpha */
- output[3] = alpha;
+ /* never touches the alpha */
+ output[3] = alpha;
}
-
/* ******** Straight to Premul ******** */
ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
-void ConvertStraightToPremulOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue[4];
- float alpha;
+ float inputValue[4];
+ float alpha;
- this->m_inputOperation->readSampled(inputValue, x, y, sampler);
- alpha = inputValue[3];
+ this->m_inputOperation->readSampled(inputValue, x, y, sampler);
+ alpha = inputValue[3];
- mul_v3_v3fl(output, inputValue, alpha);
+ mul_v3_v3fl(output, inputValue, alpha);
- /* never touches the alpha */
- output[3] = alpha;
+ /* never touches the alpha */
+ output[3] = alpha;
}
-
/* ******** Separate Channels ******** */
SeparateChannelOperation::SeparateChannelOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputOperation = NULL;
}
void SeparateChannelOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
void SeparateChannelOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
-
-void SeparateChannelOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void SeparateChannelOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float input[4];
- this->m_inputOperation->readSampled(input, x, y, sampler);
- output[0] = input[this->m_channel];
+ float input[4];
+ this->m_inputOperation->readSampled(input, x, y, sampler);
+ output[0] = input[this->m_channel];
}
-
/* ******** Combine Channels ******** */
CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputChannel1Operation = NULL;
- this->m_inputChannel2Operation = NULL;
- this->m_inputChannel3Operation = NULL;
- this->m_inputChannel4Operation = NULL;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputChannel1Operation = NULL;
+ this->m_inputChannel2Operation = NULL;
+ this->m_inputChannel3Operation = NULL;
+ this->m_inputChannel4Operation = NULL;
}
void CombineChannelsOperation::initExecution()
{
- this->m_inputChannel1Operation = this->getInputSocketReader(0);
- this->m_inputChannel2Operation = this->getInputSocketReader(1);
- this->m_inputChannel3Operation = this->getInputSocketReader(2);
- this->m_inputChannel4Operation = this->getInputSocketReader(3);
+ this->m_inputChannel1Operation = this->getInputSocketReader(0);
+ this->m_inputChannel2Operation = this->getInputSocketReader(1);
+ this->m_inputChannel3Operation = this->getInputSocketReader(2);
+ this->m_inputChannel4Operation = this->getInputSocketReader(3);
}
void CombineChannelsOperation::deinitExecution()
{
- this->m_inputChannel1Operation = NULL;
- this->m_inputChannel2Operation = NULL;
- this->m_inputChannel3Operation = NULL;
- this->m_inputChannel4Operation = NULL;
-}
-
-
-void CombineChannelsOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
-{
- float input[4];
- if (this->m_inputChannel1Operation) {
- this->m_inputChannel1Operation->readSampled(input, x, y, sampler);
- output[0] = input[0];
- }
- if (this->m_inputChannel2Operation) {
- this->m_inputChannel2Operation->readSampled(input, x, y, sampler);
- output[1] = input[0];
- }
- if (this->m_inputChannel3Operation) {
- this->m_inputChannel3Operation->readSampled(input, x, y, sampler);
- output[2] = input[0];
- }
- if (this->m_inputChannel4Operation) {
- this->m_inputChannel4Operation->readSampled(input, x, y, sampler);
- output[3] = input[0];
- }
+ this->m_inputChannel1Operation = NULL;
+ this->m_inputChannel2Operation = NULL;
+ this->m_inputChannel3Operation = NULL;
+ this->m_inputChannel4Operation = NULL;
+}
+
+void CombineChannelsOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float input[4];
+ if (this->m_inputChannel1Operation) {
+ this->m_inputChannel1Operation->readSampled(input, x, y, sampler);
+ output[0] = input[0];
+ }
+ if (this->m_inputChannel2Operation) {
+ this->m_inputChannel2Operation->readSampled(input, x, y, sampler);
+ output[1] = input[0];
+ }
+ if (this->m_inputChannel3Operation) {
+ this->m_inputChannel3Operation->readSampled(input, x, y, sampler);
+ output[2] = input[0];
+ }
+ if (this->m_inputChannel4Operation) {
+ this->m_inputChannel4Operation->readSampled(input, x, y, sampler);
+ output[3] = input[0];
+ }
}
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h
index f738879b572..a4cf05372a5 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertOperation.h
@@ -21,178 +21,167 @@
#include "COM_NodeOperation.h"
-
class ConvertBaseOperation : public NodeOperation {
-protected:
- SocketReader *m_inputOperation;
+ protected:
+ SocketReader *m_inputOperation;
-public:
- ConvertBaseOperation();
+ public:
+ ConvertBaseOperation();
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
};
-
class ConvertValueToColorOperation : public ConvertBaseOperation {
-public:
- ConvertValueToColorOperation();
+ public:
+ ConvertValueToColorOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertColorToValueOperation : public ConvertBaseOperation {
-public:
- ConvertColorToValueOperation();
+ public:
+ ConvertColorToValueOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertColorToBWOperation : public ConvertBaseOperation {
-public:
- ConvertColorToBWOperation();
+ public:
+ ConvertColorToBWOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertColorToVectorOperation : public ConvertBaseOperation {
-public:
- ConvertColorToVectorOperation();
+ public:
+ ConvertColorToVectorOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertValueToVectorOperation : public ConvertBaseOperation {
-public:
- ConvertValueToVectorOperation();
+ public:
+ ConvertValueToVectorOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertVectorToColorOperation : public ConvertBaseOperation {
-public:
- ConvertVectorToColorOperation();
+ public:
+ ConvertVectorToColorOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertVectorToValueOperation : public ConvertBaseOperation {
-public:
- ConvertVectorToValueOperation();
+ public:
+ ConvertVectorToValueOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertRGBToYCCOperation : public ConvertBaseOperation {
-private:
- /** YCbCr mode (Jpeg, ITU601, ITU709) */
- int m_mode;
-public:
- ConvertRGBToYCCOperation();
+ private:
+ /** YCbCr mode (Jpeg, ITU601, ITU709) */
+ int m_mode;
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ ConvertRGBToYCCOperation();
- /** Set the YCC mode */
- void setMode(int mode);
-};
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /** Set the YCC mode */
+ void setMode(int mode);
+};
class ConvertYCCToRGBOperation : public ConvertBaseOperation {
-private:
- /** YCbCr mode (Jpeg, ITU601, ITU709) */
- int m_mode;
-public:
- ConvertYCCToRGBOperation();
+ private:
+ /** YCbCr mode (Jpeg, ITU601, ITU709) */
+ int m_mode;
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ ConvertYCCToRGBOperation();
- /** Set the YCC mode */
- void setMode(int mode);
-};
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /** Set the YCC mode */
+ void setMode(int mode);
+};
class ConvertRGBToYUVOperation : public ConvertBaseOperation {
-public:
- ConvertRGBToYUVOperation();
+ public:
+ ConvertRGBToYUVOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertYUVToRGBOperation : public ConvertBaseOperation {
-public:
- ConvertYUVToRGBOperation();
+ public:
+ ConvertYUVToRGBOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertRGBToHSVOperation : public ConvertBaseOperation {
-public:
- ConvertRGBToHSVOperation();
+ public:
+ ConvertRGBToHSVOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertHSVToRGBOperation : public ConvertBaseOperation {
-public:
- ConvertHSVToRGBOperation();
+ public:
+ ConvertHSVToRGBOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertPremulToStraightOperation : public ConvertBaseOperation {
-public:
- ConvertPremulToStraightOperation();
+ public:
+ ConvertPremulToStraightOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class ConvertStraightToPremulOperation : public ConvertBaseOperation {
-public:
- ConvertStraightToPremulOperation();
+ public:
+ ConvertStraightToPremulOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
-
class SeparateChannelOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
- int m_channel;
-public:
- SeparateChannelOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ private:
+ SocketReader *m_inputOperation;
+ int m_channel;
- void initExecution();
- void deinitExecution();
+ public:
+ SeparateChannelOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void setChannel(int channel) { this->m_channel = channel; }
-};
+ void initExecution();
+ void deinitExecution();
+ void setChannel(int channel)
+ {
+ this->m_channel = channel;
+ }
+};
class CombineChannelsOperation : public NodeOperation {
-private:
- SocketReader *m_inputChannel1Operation;
- SocketReader *m_inputChannel2Operation;
- SocketReader *m_inputChannel3Operation;
- SocketReader *m_inputChannel4Operation;
-public:
- CombineChannelsOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
+ private:
+ SocketReader *m_inputChannel1Operation;
+ SocketReader *m_inputChannel2Operation;
+ SocketReader *m_inputChannel3Operation;
+ SocketReader *m_inputChannel4Operation;
+
+ public:
+ CombineChannelsOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
index b79fea5bfd9..1439c7abb45 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cpp
@@ -21,79 +21,79 @@
ConvolutionEdgeFilterOperation::ConvolutionEdgeFilterOperation() : ConvolutionFilterOperation()
{
- /* pass */
+ /* pass */
}
void ConvolutionEdgeFilterOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- float in1[4], in2[4], res1[4] = {0.0}, res2[4] = {0.0};
-
- int x1 = x - 1;
- int x2 = x;
- int x3 = x + 1;
- int y1 = y - 1;
- int y2 = y;
- int y3 = y + 1;
- CLAMP(x1, 0, getWidth() - 1);
- CLAMP(x2, 0, getWidth() - 1);
- CLAMP(x3, 0, getWidth() - 1);
- CLAMP(y1, 0, getHeight() - 1);
- CLAMP(y2, 0, getHeight() - 1);
- CLAMP(y3, 0, getHeight() - 1);
-
- float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
- float mval = 1.0f - value[0];
-
- this->m_inputOperation->read(in1, x1, y1, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[0]);
- madd_v3_v3fl(res2, in1, this->m_filter[0]);
-
- this->m_inputOperation->read(in1, x2, y1, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[1]);
- madd_v3_v3fl(res2, in1, this->m_filter[3]);
-
- this->m_inputOperation->read(in1, x3, y1, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[2]);
- madd_v3_v3fl(res2, in1, this->m_filter[6]);
-
- this->m_inputOperation->read(in1, x1, y2, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[3]);
- madd_v3_v3fl(res2, in1, this->m_filter[1]);
-
- this->m_inputOperation->read(in2, x2, y2, NULL);
- madd_v3_v3fl(res1, in2, this->m_filter[4]);
- madd_v3_v3fl(res2, in2, this->m_filter[4]);
-
- this->m_inputOperation->read(in1, x3, y2, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[5]);
- madd_v3_v3fl(res2, in1, this->m_filter[7]);
-
- this->m_inputOperation->read(in1, x1, y3, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[6]);
- madd_v3_v3fl(res2, in1, this->m_filter[2]);
-
- this->m_inputOperation->read(in1, x2, y3, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[7]);
- madd_v3_v3fl(res2, in1, this->m_filter[5]);
-
- this->m_inputOperation->read(in1, x3, y3, NULL);
- madd_v3_v3fl(res1, in1, this->m_filter[8]);
- madd_v3_v3fl(res2, in1, this->m_filter[8]);
-
- output[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
- output[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
- output[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
-
- output[0] = output[0] * value[0] + in2[0] * mval;
- output[1] = output[1] * value[0] + in2[1] * mval;
- output[2] = output[2] * value[0] + in2[2] * mval;
-
- output[3] = in2[3];
-
- /* Make sure we don't return negative color. */
- output[0] = max(output[0], 0.0f);
- output[1] = max(output[1], 0.0f);
- output[2] = max(output[2], 0.0f);
- output[3] = max(output[3], 0.0f);
+ float in1[4], in2[4], res1[4] = {0.0}, res2[4] = {0.0};
+
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
+
+ float value[4];
+ this->m_inputValueOperation->read(value, x2, y2, NULL);
+ float mval = 1.0f - value[0];
+
+ this->m_inputOperation->read(in1, x1, y1, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[0]);
+ madd_v3_v3fl(res2, in1, this->m_filter[0]);
+
+ this->m_inputOperation->read(in1, x2, y1, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[1]);
+ madd_v3_v3fl(res2, in1, this->m_filter[3]);
+
+ this->m_inputOperation->read(in1, x3, y1, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[2]);
+ madd_v3_v3fl(res2, in1, this->m_filter[6]);
+
+ this->m_inputOperation->read(in1, x1, y2, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[3]);
+ madd_v3_v3fl(res2, in1, this->m_filter[1]);
+
+ this->m_inputOperation->read(in2, x2, y2, NULL);
+ madd_v3_v3fl(res1, in2, this->m_filter[4]);
+ madd_v3_v3fl(res2, in2, this->m_filter[4]);
+
+ this->m_inputOperation->read(in1, x3, y2, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[5]);
+ madd_v3_v3fl(res2, in1, this->m_filter[7]);
+
+ this->m_inputOperation->read(in1, x1, y3, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[6]);
+ madd_v3_v3fl(res2, in1, this->m_filter[2]);
+
+ this->m_inputOperation->read(in1, x2, y3, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[7]);
+ madd_v3_v3fl(res2, in1, this->m_filter[5]);
+
+ this->m_inputOperation->read(in1, x3, y3, NULL);
+ madd_v3_v3fl(res1, in1, this->m_filter[8]);
+ madd_v3_v3fl(res2, in1, this->m_filter[8]);
+
+ output[0] = sqrt(res1[0] * res1[0] + res2[0] * res2[0]);
+ output[1] = sqrt(res1[1] * res1[1] + res2[1] * res2[1]);
+ output[2] = sqrt(res1[2] * res1[2] + res2[2] * res2[2]);
+
+ output[0] = output[0] * value[0] + in2[0] * mval;
+ output[1] = output[1] * value[0] + in2[1] * mval;
+ output[2] = output[2] * value[0] + in2[2] * mval;
+
+ output[3] = in2[3];
+
+ /* Make sure we don't return negative color. */
+ output[0] = max(output[0], 0.0f);
+ output[1] = max(output[1], 0.0f);
+ output[2] = max(output[2], 0.0f);
+ output[3] = max(output[3], 0.0f);
}
diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
index 58073e08acf..17509b018bf 100644
--- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.h
@@ -22,9 +22,9 @@
#include "COM_ConvolutionFilterOperation.h"
class ConvolutionEdgeFilterOperation : public ConvolutionFilterOperation {
-public:
- ConvolutionEdgeFilterOperation();
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ ConvolutionEdgeFilterOperation();
+ void executePixel(float output[4], int x, int y, void *data);
};
#endif
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
index bc1ecf2bd80..3f47bfda618 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cpp
@@ -24,102 +24,103 @@
ConvolutionFilterOperation::ConvolutionFilterOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->setComplex(true);
}
void ConvolutionFilterOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputValueOperation = this->getInputSocketReader(1);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputValueOperation = this->getInputSocketReader(1);
}
-void ConvolutionFilterOperation::set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
+void ConvolutionFilterOperation::set3x3Filter(
+ float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9)
{
- this->m_filter[0] = f1;
- this->m_filter[1] = f2;
- this->m_filter[2] = f3;
- this->m_filter[3] = f4;
- this->m_filter[4] = f5;
- this->m_filter[5] = f6;
- this->m_filter[6] = f7;
- this->m_filter[7] = f8;
- this->m_filter[8] = f9;
- this->m_filterHeight = 3;
- this->m_filterWidth = 3;
+ this->m_filter[0] = f1;
+ this->m_filter[1] = f2;
+ this->m_filter[2] = f3;
+ this->m_filter[3] = f4;
+ this->m_filter[4] = f5;
+ this->m_filter[5] = f6;
+ this->m_filter[6] = f7;
+ this->m_filter[7] = f8;
+ this->m_filter[8] = f9;
+ this->m_filterHeight = 3;
+ this->m_filterWidth = 3;
}
void ConvolutionFilterOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputValueOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputValueOperation = NULL;
}
-
void ConvolutionFilterOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- float in1[4];
- float in2[4];
- int x1 = x - 1;
- int x2 = x;
- int x3 = x + 1;
- int y1 = y - 1;
- int y2 = y;
- int y3 = y + 1;
- CLAMP(x1, 0, getWidth() - 1);
- CLAMP(x2, 0, getWidth() - 1);
- CLAMP(x3, 0, getWidth() - 1);
- CLAMP(y1, 0, getHeight() - 1);
- CLAMP(y2, 0, getHeight() - 1);
- CLAMP(y3, 0, getHeight() - 1);
- float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
- const float mval = 1.0f - value[0];
+ float in1[4];
+ float in2[4];
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
+ float value[4];
+ this->m_inputValueOperation->read(value, x2, y2, NULL);
+ const float mval = 1.0f - value[0];
- zero_v4(output);
- this->m_inputOperation->read(in1, x1, y1, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[0]);
- this->m_inputOperation->read(in1, x2, y1, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[1]);
- this->m_inputOperation->read(in1, x3, y1, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[2]);
- this->m_inputOperation->read(in1, x1, y2, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[3]);
- this->m_inputOperation->read(in2, x2, y2, NULL);
- madd_v4_v4fl(output, in2, this->m_filter[4]);
- this->m_inputOperation->read(in1, x3, y2, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[5]);
- this->m_inputOperation->read(in1, x1, y3, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[6]);
- this->m_inputOperation->read(in1, x2, y3, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[7]);
- this->m_inputOperation->read(in1, x3, y3, NULL);
- madd_v4_v4fl(output, in1, this->m_filter[8]);
+ zero_v4(output);
+ this->m_inputOperation->read(in1, x1, y1, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[0]);
+ this->m_inputOperation->read(in1, x2, y1, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[1]);
+ this->m_inputOperation->read(in1, x3, y1, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[2]);
+ this->m_inputOperation->read(in1, x1, y2, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[3]);
+ this->m_inputOperation->read(in2, x2, y2, NULL);
+ madd_v4_v4fl(output, in2, this->m_filter[4]);
+ this->m_inputOperation->read(in1, x3, y2, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[5]);
+ this->m_inputOperation->read(in1, x1, y3, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[6]);
+ this->m_inputOperation->read(in1, x2, y3, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[7]);
+ this->m_inputOperation->read(in1, x3, y3, NULL);
+ madd_v4_v4fl(output, in1, this->m_filter[8]);
- output[0] = output[0] * value[0] + in2[0] * mval;
- output[1] = output[1] * value[0] + in2[1] * mval;
- output[2] = output[2] * value[0] + in2[2] * mval;
- output[3] = output[3] * value[0] + in2[3] * mval;
+ output[0] = output[0] * value[0] + in2[0] * mval;
+ output[1] = output[1] * value[0] + in2[1] * mval;
+ output[2] = output[2] * value[0] + in2[2] * mval;
+ output[3] = output[3] * value[0] + in2[3] * mval;
- /* Make sure we don't return negative color. */
- output[0] = max(output[0], 0.0f);
- output[1] = max(output[1], 0.0f);
- output[2] = max(output[2], 0.0f);
- output[3] = max(output[3], 0.0f);
+ /* Make sure we don't return negative color. */
+ output[0] = max(output[0], 0.0f);
+ output[1] = max(output[1], 0.0f);
+ output[2] = max(output[2], 0.0f);
+ output[3] = max(output[3], 0.0f);
}
-bool ConvolutionFilterOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ConvolutionFilterOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- int addx = (this->m_filterWidth - 1) / 2 + 1;
- int addy = (this->m_filterHeight - 1) / 2 + 1;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
+ rcti newInput;
+ int addx = (this->m_filterWidth - 1) / 2 + 1;
+ int addy = (this->m_filterHeight - 1) / 2 + 1;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
index 5342e2a7fa8..78db5a5ae9d 100644
--- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
+++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.h
@@ -22,23 +22,26 @@
#include "COM_NodeOperation.h"
class ConvolutionFilterOperation : public NodeOperation {
-private:
- int m_filterWidth;
- int m_filterHeight;
+ private:
+ int m_filterWidth;
+ int m_filterHeight;
-protected:
- SocketReader *m_inputOperation;
- SocketReader *m_inputValueOperation;
- float m_filter[9];
+ protected:
+ SocketReader *m_inputOperation;
+ SocketReader *m_inputValueOperation;
+ float m_filter[9];
-public:
- ConvolutionFilterOperation();
- void set3x3Filter(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ ConvolutionFilterOperation();
+ void set3x3Filter(
+ float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixel(float output[4], int x, int y, void *data);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp
index 2a78dc3a1f9..fbbe8706e11 100644
--- a/source/blender/compositor/operations/COM_CropOperation.cpp
+++ b/source/blender/compositor/operations/COM_CropOperation.cpp
@@ -21,105 +21,111 @@
CropBaseOperation::CropBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputOperation = NULL;
- this->m_settings = NULL;
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputOperation = NULL;
+ this->m_settings = NULL;
}
void CropBaseOperation::updateArea()
{
- SocketReader *inputReference = this->getInputSocketReader(0);
- float width = inputReference->getWidth();
- float height = inputReference->getHeight();
- NodeTwoXYs local_settings = *this->m_settings;
+ SocketReader *inputReference = this->getInputSocketReader(0);
+ float width = inputReference->getWidth();
+ float height = inputReference->getHeight();
+ NodeTwoXYs local_settings = *this->m_settings;
- if (width > 0.0f && height > 0.0f) {
- if (this->m_relative) {
- local_settings.x1 = width * local_settings.fac_x1;
- local_settings.x2 = width * local_settings.fac_x2;
- local_settings.y1 = height * local_settings.fac_y1;
- local_settings.y2 = height * local_settings.fac_y2;
- }
- if (width <= local_settings.x1 + 1)
- local_settings.x1 = width - 1;
- if (height <= local_settings.y1 + 1)
- local_settings.y1 = height - 1;
- if (width <= local_settings.x2 + 1)
- local_settings.x2 = width - 1;
- if (height <= local_settings.y2 + 1)
- local_settings.y2 = height - 1;
+ if (width > 0.0f && height > 0.0f) {
+ if (this->m_relative) {
+ local_settings.x1 = width * local_settings.fac_x1;
+ local_settings.x2 = width * local_settings.fac_x2;
+ local_settings.y1 = height * local_settings.fac_y1;
+ local_settings.y2 = height * local_settings.fac_y2;
+ }
+ if (width <= local_settings.x1 + 1)
+ local_settings.x1 = width - 1;
+ if (height <= local_settings.y1 + 1)
+ local_settings.y1 = height - 1;
+ if (width <= local_settings.x2 + 1)
+ local_settings.x2 = width - 1;
+ if (height <= local_settings.y2 + 1)
+ local_settings.y2 = height - 1;
- this->m_xmax = max(local_settings.x1, local_settings.x2) + 1;
- this->m_xmin = min(local_settings.x1, local_settings.x2);
- this->m_ymax = max(local_settings.y1, local_settings.y2) + 1;
- this->m_ymin = min(local_settings.y1, local_settings.y2);
- }
- else {
- this->m_xmax = 0;
- this->m_xmin = 0;
- this->m_ymax = 0;
- this->m_ymin = 0;
- }
+ this->m_xmax = max(local_settings.x1, local_settings.x2) + 1;
+ this->m_xmin = min(local_settings.x1, local_settings.x2);
+ this->m_ymax = max(local_settings.y1, local_settings.y2) + 1;
+ this->m_ymin = min(local_settings.y1, local_settings.y2);
+ }
+ else {
+ this->m_xmax = 0;
+ this->m_xmin = 0;
+ this->m_ymax = 0;
+ this->m_ymin = 0;
+ }
}
void CropBaseOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- updateArea();
+ this->m_inputOperation = this->getInputSocketReader(0);
+ updateArea();
}
void CropBaseOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
CropOperation::CropOperation() : CropBaseOperation()
{
- /* pass */
+ /* pass */
}
void CropOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) {
- this->m_inputOperation->readSampled(output, x, y, sampler);
- }
- else {
- zero_v4(output);
- }
+ if ((x < this->m_xmax && x >= this->m_xmin) && (y < this->m_ymax && y >= this->m_ymin)) {
+ this->m_inputOperation->readSampled(output, x, y, sampler);
+ }
+ else {
+ zero_v4(output);
+ }
}
CropImageOperation::CropImageOperation() : CropBaseOperation()
{
- /* pass */
+ /* pass */
}
-bool CropImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool CropImageOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = input->xmax + this->m_xmin;
- newInput.xmin = input->xmin + this->m_xmin;
- newInput.ymax = input->ymax + this->m_ymin;
- newInput.ymin = input->ymin + this->m_ymin;
+ newInput.xmax = input->xmax + this->m_xmin;
+ newInput.xmin = input->xmin + this->m_xmin;
+ newInput.ymax = input->ymax + this->m_ymin;
+ newInput.ymin = input->ymin + this->m_ymin;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-void CropImageOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void CropImageOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- updateArea();
- resolution[0] = this->m_xmax - this->m_xmin;
- resolution[1] = this->m_ymax - this->m_ymin;
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ updateArea();
+ resolution[0] = this->m_xmax - this->m_xmin;
+ resolution[1] = this->m_ymax - this->m_ymin;
}
-void CropImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void CropImageOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
- this->m_inputOperation->readSampled(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
- }
- else {
- zero_v4(output);
- }
+ if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
+ this->m_inputOperation->readSampled(output, (x + this->m_xmin), (y + this->m_ymin), sampler);
+ }
+ else {
+ zero_v4(output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h
index 06863f6fd0c..36c18d29e92 100644
--- a/source/blender/compositor/operations/COM_CropOperation.h
+++ b/source/blender/compositor/operations/COM_CropOperation.h
@@ -22,38 +22,46 @@
#include "COM_NodeOperation.h"
class CropBaseOperation : public NodeOperation {
-protected:
- SocketReader *m_inputOperation;
- NodeTwoXYs *m_settings;
- bool m_relative;
- int m_xmax;
- int m_xmin;
- int m_ymax;
- int m_ymin;
+ protected:
+ SocketReader *m_inputOperation;
+ NodeTwoXYs *m_settings;
+ bool m_relative;
+ int m_xmax;
+ int m_xmin;
+ int m_ymax;
+ int m_ymin;
- void updateArea();
-public:
- CropBaseOperation();
- void initExecution();
- void deinitExecution();
- void setCropSettings(NodeTwoXYs *settings) { this->m_settings = settings; }
- void setRelative(bool rel) { this->m_relative = rel; }
+ void updateArea();
+
+ public:
+ CropBaseOperation();
+ void initExecution();
+ void deinitExecution();
+ void setCropSettings(NodeTwoXYs *settings)
+ {
+ this->m_settings = settings;
+ }
+ void setRelative(bool rel)
+ {
+ this->m_relative = rel;
+ }
};
class CropOperation : public CropBaseOperation {
-private:
-public:
- CropOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ private:
+ public:
+ CropOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class CropImageOperation : public CropBaseOperation {
-private:
-public:
- CropImageOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
+ private:
+ public:
+ CropImageOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
index bd1c9b31d75..085db6a9dea 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.cpp
@@ -20,54 +20,51 @@
CryptomatteOperation::CryptomatteOperation(size_t num_inputs) : NodeOperation()
{
- for (size_t i = 0; i < num_inputs; i++) {
- this->addInputSocket(COM_DT_COLOR);
- }
- inputs.resize(num_inputs);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
+ for (size_t i = 0; i < num_inputs; i++) {
+ this->addInputSocket(COM_DT_COLOR);
+ }
+ inputs.resize(num_inputs);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
}
void CryptomatteOperation::initExecution()
{
- for (size_t i = 0; i < inputs.size(); i++) {
- inputs[i] = this->getInputSocketReader(i);
- }
+ for (size_t i = 0; i < inputs.size(); i++) {
+ inputs[i] = this->getInputSocketReader(i);
+ }
}
void CryptomatteOperation::addObjectIndex(float objectIndex)
{
- if (objectIndex != 0.0f) {
- m_objectIndex.push_back(objectIndex);
- }
+ if (objectIndex != 0.0f) {
+ m_objectIndex.push_back(objectIndex);
+ }
}
-void CryptomatteOperation::executePixel(float output[4],
- int x,
- int y,
- void *data)
+void CryptomatteOperation::executePixel(float output[4], int x, int y, void *data)
{
- float input[4];
- output[0] = output[1] = output[2] = output[3] = 0.0f;
- for (size_t i = 0; i < inputs.size(); i++) {
- inputs[i]->read(input, x, y, data);
- if (i == 0) {
- /* Write the frontmost object as false color for picking. */
- output[0] = input[0];
- uint32_t m3hash;
- ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
- /* Since the red channel is likely to be out of display range,
- * setting green and blue gives more meaningful images. */
- output[1] = ((float) ((m3hash << 8)) / (float) UINT32_MAX);
- output[2] = ((float) ((m3hash << 16)) / (float) UINT32_MAX);
- }
- for (size_t i = 0; i < m_objectIndex.size(); i++) {
- if (m_objectIndex[i] == input[0]) {
- output[3] += input[1];
- }
- if (m_objectIndex[i] == input[2]) {
- output[3] += input[3];
- }
- }
- }
+ float input[4];
+ output[0] = output[1] = output[2] = output[3] = 0.0f;
+ for (size_t i = 0; i < inputs.size(); i++) {
+ inputs[i]->read(input, x, y, data);
+ if (i == 0) {
+ /* Write the frontmost object as false color for picking. */
+ output[0] = input[0];
+ uint32_t m3hash;
+ ::memcpy(&m3hash, &input[0], sizeof(uint32_t));
+ /* Since the red channel is likely to be out of display range,
+ * setting green and blue gives more meaningful images. */
+ output[1] = ((float)((m3hash << 8)) / (float)UINT32_MAX);
+ output[2] = ((float)((m3hash << 16)) / (float)UINT32_MAX);
+ }
+ for (size_t i = 0; i < m_objectIndex.size(); i++) {
+ if (m_objectIndex[i] == input[0]) {
+ output[3] += input[1];
+ }
+ if (m_objectIndex[i] == input[2]) {
+ output[3] += input[3];
+ }
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_CryptomatteOperation.h b/source/blender/compositor/operations/COM_CryptomatteOperation.h
index 63d566c553f..459d8b65f12 100644
--- a/source/blender/compositor/operations/COM_CryptomatteOperation.h
+++ b/source/blender/compositor/operations/COM_CryptomatteOperation.h
@@ -20,19 +20,18 @@
#define __COM_CRYPTOMATTEOPERATION_H__
#include "COM_NodeOperation.h"
-
class CryptomatteOperation : public NodeOperation {
-private:
- std::vector<float> m_objectIndex;
-public:
- std::vector<SocketReader *> inputs;
+ private:
+ std::vector<float> m_objectIndex;
- CryptomatteOperation(size_t num_inputs = 6);
+ public:
+ std::vector<SocketReader *> inputs;
- void initExecution();
- void executePixel(float output[4], int x, int y, void *data);
+ CryptomatteOperation(size_t num_inputs = 6);
- void addObjectIndex(float objectIndex);
+ void initExecution();
+ void executePixel(float output[4], int x, int y, void *data);
+ void addObjectIndex(float objectIndex);
};
#endif
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
index fe83e75442f..d84af71d8d8 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.cpp
@@ -21,41 +21,41 @@
#ifdef __cplusplus
extern "C" {
#endif
-# include "BKE_colortools.h"
+#include "BKE_colortools.h"
#ifdef __cplusplus
}
#endif
CurveBaseOperation::CurveBaseOperation() : NodeOperation()
{
- this->m_curveMapping = NULL;
+ this->m_curveMapping = NULL;
}
CurveBaseOperation::~CurveBaseOperation()
{
- if (this->m_curveMapping) {
- curvemapping_free(this->m_curveMapping);
- this->m_curveMapping = NULL;
- }
+ if (this->m_curveMapping) {
+ curvemapping_free(this->m_curveMapping);
+ this->m_curveMapping = NULL;
+ }
}
void CurveBaseOperation::initExecution()
{
- curvemapping_initialize(this->m_curveMapping);
+ curvemapping_initialize(this->m_curveMapping);
}
void CurveBaseOperation::deinitExecution()
{
- if (this->m_curveMapping) {
- curvemapping_free(this->m_curveMapping);
- this->m_curveMapping = NULL;
- }
+ if (this->m_curveMapping) {
+ curvemapping_free(this->m_curveMapping);
+ this->m_curveMapping = NULL;
+ }
}
void CurveBaseOperation::setCurveMapping(CurveMapping *mapping)
{
- /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */
- if (this->m_curveMapping) {
- curvemapping_free(this->m_curveMapping);
- }
- this->m_curveMapping = curvemapping_copy(mapping);
+ /* duplicate the curve to avoid glitches while drawing, see bug [#32374] */
+ if (this->m_curveMapping) {
+ curvemapping_free(this->m_curveMapping);
+ }
+ this->m_curveMapping = curvemapping_copy(mapping);
}
diff --git a/source/blender/compositor/operations/COM_CurveBaseOperation.h b/source/blender/compositor/operations/COM_CurveBaseOperation.h
index 71d5e4a67da..f42ce3c366f 100644
--- a/source/blender/compositor/operations/COM_CurveBaseOperation.h
+++ b/source/blender/compositor/operations/COM_CurveBaseOperation.h
@@ -22,21 +22,22 @@
#include "DNA_color_types.h"
class CurveBaseOperation : public NodeOperation {
-protected:
- /**
- * Cached reference to the inputProgram
- */
- CurveMapping *m_curveMapping;
-public:
- CurveBaseOperation();
- ~CurveBaseOperation();
+ protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ CurveMapping *m_curveMapping;
- /**
- * Initialize the execution
- */
- void initExecution();
- void deinitExecution();
+ public:
+ CurveBaseOperation();
+ ~CurveBaseOperation();
- void setCurveMapping(CurveMapping *mapping);
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+ void deinitExecution();
+
+ void setCurveMapping(CurveMapping *mapping);
};
#endif
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 0ac96ac89e9..807450040de 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -24,114 +24,120 @@
DespeckleOperation::DespeckleOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->setComplex(true);
}
void DespeckleOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputValueOperation = this->getInputSocketReader(1);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputValueOperation = this->getInputSocketReader(1);
}
void DespeckleOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputValueOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputValueOperation = NULL;
}
BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold)
{
- return ((fabsf(a[0] - b[0]) > threshold) ||
- (fabsf(a[1] - b[1]) > threshold) ||
- (fabsf(a[2] - b[2]) > threshold));
+ return ((fabsf(a[0] - b[0]) > threshold) || (fabsf(a[1] - b[1]) > threshold) ||
+ (fabsf(a[2] - b[2]) > threshold));
}
void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- float w = 0.0f;
- float color_org[4];
- float color_mid[4];
- float color_mid_ok[4];
- float in1[4];
- int x1 = x - 1;
- int x2 = x;
- int x3 = x + 1;
- int y1 = y - 1;
- int y2 = y;
- int y3 = y + 1;
- CLAMP(x1, 0, getWidth() - 1);
- CLAMP(x2, 0, getWidth() - 1);
- CLAMP(x3, 0, getWidth() - 1);
- CLAMP(y1, 0, getHeight() - 1);
- CLAMP(y2, 0, getHeight() - 1);
- CLAMP(y3, 0, getHeight() - 1);
- float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
- //const float mval = 1.0f - value[0];
-
-
- this->m_inputOperation->read(color_org, x2, y2, NULL);
+ float w = 0.0f;
+ float color_org[4];
+ float color_mid[4];
+ float color_mid_ok[4];
+ float in1[4];
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
+ float value[4];
+ this->m_inputValueOperation->read(value, x2, y2, NULL);
+ //const float mval = 1.0f - value[0];
+
+ this->m_inputOperation->read(color_org, x2, y2, NULL);
#define TOT_DIV_ONE 1.0f
#define TOT_DIV_CNR (float)M_SQRT1_2
-#define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4)
-
-#define COLOR_ADD(fac) \
-{ \
- madd_v4_v4fl(color_mid, in1, fac); \
- if (color_diff(in1, color_org, this->m_threshold)) { \
- w += fac; \
- madd_v4_v4fl(color_mid_ok, in1, fac); \
- } \
-}
-
- zero_v4(color_mid);
- zero_v4(color_mid_ok);
-
- this->m_inputOperation->read(in1, x1, y1, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y1, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y1, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x1, y2, NULL); COLOR_ADD(TOT_DIV_ONE)
+#define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4)
+
+#define COLOR_ADD(fac) \
+ { \
+ madd_v4_v4fl(color_mid, in1, fac); \
+ if (color_diff(in1, color_org, this->m_threshold)) { \
+ w += fac; \
+ madd_v4_v4fl(color_mid_ok, in1, fac); \
+ } \
+ }
+
+ zero_v4(color_mid);
+ zero_v4(color_mid_ok);
+
+ this->m_inputOperation->read(in1, x1, y1, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x2, y1, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x3, y1, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x1, y2, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
#if 0
- this->m_inputOperation->read(in2, x2, y2, NULL);
- madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
+ this->m_inputOperation->read(in2, x2, y2, NULL);
+ madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
#endif
- this->m_inputOperation->read(in1, x3, y2, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x1, y3, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y3, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y3, NULL); COLOR_ADD(TOT_DIV_CNR)
-
- mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
- //mul_v4_fl(color_mid, 1.0f / w);
-
- if ((w != 0.0f) &&
- ((w / WTOT) > (this->m_threshold_neighbor)) &&
- color_diff(color_mid, color_org, this->m_threshold))
- {
- mul_v4_fl(color_mid_ok, 1.0f / w);
- interp_v4_v4v4(output, color_org, color_mid_ok, value[0]);
- }
- else {
- copy_v4_v4(output, color_org);
- }
+ this->m_inputOperation->read(in1, x3, y2, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x1, y3, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x2, y3, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x3, y3, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+
+ mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
+ //mul_v4_fl(color_mid, 1.0f / w);
+
+ if ((w != 0.0f) && ((w / WTOT) > (this->m_threshold_neighbor)) &&
+ color_diff(color_mid, color_org, this->m_threshold)) {
+ mul_v4_fl(color_mid_ok, 1.0f / w);
+ interp_v4_v4v4(output, color_org, color_mid_ok, value[0]);
+ }
+ else {
+ copy_v4_v4(output, color_org);
+ }
}
-bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- int addx = 2; //(this->m_filterWidth - 1) / 2 + 1;
- int addy = 2; //(this->m_filterHeight - 1) / 2 + 1;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+ int addx = 2; //(this->m_filterWidth - 1) / 2 + 1;
+ int addy = 2; //(this->m_filterHeight - 1) / 2 + 1;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.h b/source/blender/compositor/operations/COM_DespeckleOperation.h
index 4a4aac41c32..280948b7fbe 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.h
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.h
@@ -21,27 +21,35 @@
#include "COM_NodeOperation.h"
class DespeckleOperation : public NodeOperation {
-private:
- float m_threshold;
- float m_threshold_neighbor;
-
- // int m_filterWidth;
- // int m_filterHeight;
-
-protected:
- SocketReader *m_inputOperation;
- SocketReader *m_inputValueOperation;
-
-public:
- DespeckleOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], int x, int y, void *data);
-
- void setThreshold(float threshold) { this->m_threshold = threshold; }
- void setThresholdNeighbor(float threshold) { this->m_threshold_neighbor = threshold; }
-
- void initExecution();
- void deinitExecution();
+ private:
+ float m_threshold;
+ float m_threshold_neighbor;
+
+ // int m_filterWidth;
+ // int m_filterHeight;
+
+ protected:
+ SocketReader *m_inputOperation;
+ SocketReader *m_inputValueOperation;
+
+ public:
+ DespeckleOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixel(float output[4], int x, int y, void *data);
+
+ void setThreshold(float threshold)
+ {
+ this->m_threshold = threshold;
+ }
+ void setThresholdNeighbor(float threshold)
+ {
+ this->m_threshold_neighbor = threshold;
+ }
+
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
index cb4feaf4918..ea3526eb7e0 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp
@@ -21,63 +21,65 @@
DifferenceMatteOperation::DifferenceMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImage1Program = NULL;
- this->m_inputImage2Program = NULL;
+ this->m_inputImage1Program = NULL;
+ this->m_inputImage2Program = NULL;
}
void DifferenceMatteOperation::initExecution()
{
- this->m_inputImage1Program = this->getInputSocketReader(0);
- this->m_inputImage2Program = this->getInputSocketReader(1);
+ this->m_inputImage1Program = this->getInputSocketReader(0);
+ this->m_inputImage2Program = this->getInputSocketReader(1);
}
void DifferenceMatteOperation::deinitExecution()
{
- this->m_inputImage1Program = NULL;
- this->m_inputImage2Program = NULL;
+ this->m_inputImage1Program = NULL;
+ this->m_inputImage2Program = NULL;
}
-void DifferenceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void DifferenceMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inColor1[4];
- float inColor2[4];
+ float inColor1[4];
+ float inColor2[4];
- const float tolerance = this->m_settings->t1;
- const float falloff = this->m_settings->t2;
- float difference;
- float alpha;
+ const float tolerance = this->m_settings->t1;
+ const float falloff = this->m_settings->t2;
+ float difference;
+ float alpha;
- this->m_inputImage1Program->readSampled(inColor1, x, y, sampler);
- this->m_inputImage2Program->readSampled(inColor2, x, y, sampler);
+ this->m_inputImage1Program->readSampled(inColor1, x, y, sampler);
+ this->m_inputImage2Program->readSampled(inColor2, x, y, sampler);
- difference = (fabsf(inColor2[0] - inColor1[0]) +
- fabsf(inColor2[1] - inColor1[1]) +
- fabsf(inColor2[2] - inColor1[2]));
+ difference = (fabsf(inColor2[0] - inColor1[0]) + fabsf(inColor2[1] - inColor1[1]) +
+ fabsf(inColor2[2] - inColor1[2]));
- /* average together the distances */
- difference = difference / 3.0f;
+ /* average together the distances */
+ difference = difference / 3.0f;
- /* make 100% transparent */
- if (difference <= tolerance) {
- output[0] = 0.0f;
- }
- /*in the falloff region, make partially transparent */
- else if (difference <= falloff + tolerance) {
- difference = difference - tolerance;
- alpha = difference / falloff;
- /*only change if more transparent than before */
- if (alpha < inColor1[3]) {
- output[0] = alpha;
- }
- else { /* leave as before */
- output[0] = inColor1[3];
- }
- }
- else {
- /* foreground object */
- output[0] = inColor1[3];
- }
+ /* make 100% transparent */
+ if (difference <= tolerance) {
+ output[0] = 0.0f;
+ }
+ /*in the falloff region, make partially transparent */
+ else if (difference <= falloff + tolerance) {
+ difference = difference - tolerance;
+ alpha = difference / falloff;
+ /*only change if more transparent than before */
+ if (alpha < inColor1[3]) {
+ output[0] = alpha;
+ }
+ else { /* leave as before */
+ output[0] = inColor1[3];
+ }
+ }
+ else {
+ /* foreground object */
+ output[0] = inColor1[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
index 09f77a3d793..e96e212e511 100644
--- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h
@@ -20,30 +20,33 @@
#define __COM_DIFFERENCEMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class DifferenceMatteOperation : public NodeOperation {
-private:
- NodeChroma *m_settings;
- SocketReader *m_inputImage1Program;
- SocketReader *m_inputImage2Program;
-public:
- /**
- * Default constructor
- */
- DifferenceMatteOperation();
+ private:
+ NodeChroma *m_settings;
+ SocketReader *m_inputImage1Program;
+ SocketReader *m_inputImage2Program;
+
+ public:
+ /**
+ * Default constructor
+ */
+ DifferenceMatteOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; }
+ void setSettings(NodeChroma *nodeChroma)
+ {
+ this->m_settings = nodeChroma;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
index 2e2888052b2..7cf1086dca1 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp
@@ -25,532 +25,544 @@
// DilateErode Distance Threshold
DilateErodeThresholdOperation::DilateErodeThresholdOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->setComplex(true);
- this->m_inputProgram = NULL;
- this->m_inset = 0.0f;
- this->m__switch = 0.5f;
- this->m_distance = 0.0f;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
+ this->m_inset = 0.0f;
+ this->m__switch = 0.5f;
+ this->m_distance = 0.0f;
}
void DilateErodeThresholdOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- if (this->m_distance < 0.0f) {
- this->m_scope = -this->m_distance + this->m_inset;
- }
- else {
- if (this->m_inset * 2 > this->m_distance) {
- this->m_scope = max(this->m_inset * 2 - this->m_distance, this->m_distance);
- }
- else {
- this->m_scope = this->m_distance;
- }
- }
- if (this->m_scope < 3) {
- this->m_scope = 3;
- }
+ this->m_inputProgram = this->getInputSocketReader(0);
+ if (this->m_distance < 0.0f) {
+ this->m_scope = -this->m_distance + this->m_inset;
+ }
+ else {
+ if (this->m_inset * 2 > this->m_distance) {
+ this->m_scope = max(this->m_inset * 2 - this->m_distance, this->m_distance);
+ }
+ else {
+ this->m_scope = this->m_distance;
+ }
+ }
+ if (this->m_scope < 3) {
+ this->m_scope = 3;
+ }
}
void *DilateErodeThresholdOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
- return buffer;
+ void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ return buffer;
}
void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y, void *data)
{
- float inputValue[4];
- const float sw = this->m__switch;
- const float distance = this->m_distance;
- float pixelvalue;
- const float rd = this->m_scope * this->m_scope;
- const float inset = this->m_inset;
- float mindist = rd * 2;
-
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- rcti *rect = inputBuffer->getRect();
- const int minx = max(x - this->m_scope, rect->xmin);
- const int miny = max(y - this->m_scope, rect->ymin);
- const int maxx = min(x + this->m_scope, rect->xmax);
- const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_rcti_size_x(rect);
- int offset;
-
- inputBuffer->read(inputValue, x, y);
- if (inputValue[0] > sw) {
- for (int yi = miny; yi < maxy; yi++) {
- const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
- for (int xi = minx; xi < maxx; xi++) {
- if (buffer[offset] < sw) {
- const float dx = xi - x;
- const float dis = dx * dx + dy * dy;
- mindist = min(mindist, dis);
- }
- offset ++;
- }
- }
- pixelvalue = -sqrtf(mindist);
- }
- else {
- for (int yi = miny; yi < maxy; yi++) {
- const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
- for (int xi = minx; xi < maxx; xi++) {
- if (buffer[offset] > sw) {
- const float dx = xi - x;
- const float dis = dx * dx + dy * dy;
- mindist = min(mindist, dis);
- }
- offset ++;
- }
- }
- pixelvalue = sqrtf(mindist);
- }
-
- if (distance > 0.0f) {
- const float delta = distance - pixelvalue;
- if (delta >= 0.0f) {
- if (delta >= inset) {
- output[0] = 1.0f;
- }
- else {
- output[0] = delta / inset;
- }
- }
- else {
- output[0] = 0.0f;
- }
- }
- else {
- const float delta = -distance + pixelvalue;
- if (delta < 0.0f) {
- if (delta < -inset) {
- output[0] = 1.0f;
- }
- else {
- output[0] = (-delta) / inset;
- }
- }
- else {
- output[0] = 0.0f;
- }
- }
+ float inputValue[4];
+ const float sw = this->m__switch;
+ const float distance = this->m_distance;
+ float pixelvalue;
+ const float rd = this->m_scope * this->m_scope;
+ const float inset = this->m_inset;
+ float mindist = rd * 2;
+
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ rcti *rect = inputBuffer->getRect();
+ const int minx = max(x - this->m_scope, rect->xmin);
+ const int miny = max(y - this->m_scope, rect->ymin);
+ const int maxx = min(x + this->m_scope, rect->xmax);
+ const int maxy = min(y + this->m_scope, rect->ymax);
+ const int bufferWidth = BLI_rcti_size_x(rect);
+ int offset;
+
+ inputBuffer->read(inputValue, x, y);
+ if (inputValue[0] > sw) {
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ for (int xi = minx; xi < maxx; xi++) {
+ if (buffer[offset] < sw) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
+ mindist = min(mindist, dis);
+ }
+ offset++;
+ }
+ }
+ pixelvalue = -sqrtf(mindist);
+ }
+ else {
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ for (int xi = minx; xi < maxx; xi++) {
+ if (buffer[offset] > sw) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
+ mindist = min(mindist, dis);
+ }
+ offset++;
+ }
+ }
+ pixelvalue = sqrtf(mindist);
+ }
+
+ if (distance > 0.0f) {
+ const float delta = distance - pixelvalue;
+ if (delta >= 0.0f) {
+ if (delta >= inset) {
+ output[0] = 1.0f;
+ }
+ else {
+ output[0] = delta / inset;
+ }
+ }
+ else {
+ output[0] = 0.0f;
+ }
+ }
+ else {
+ const float delta = -distance + pixelvalue;
+ if (delta < 0.0f) {
+ if (delta < -inset) {
+ output[0] = 1.0f;
+ }
+ else {
+ output[0] = (-delta) / inset;
+ }
+ }
+ else {
+ output[0] = 0.0f;
+ }
+ }
}
void DilateErodeThresholdOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
-bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = input->xmax + this->m_scope;
- newInput.xmin = input->xmin - this->m_scope;
- newInput.ymax = input->ymax + this->m_scope;
- newInput.ymin = input->ymin - this->m_scope;
+ newInput.xmax = input->xmax + this->m_scope;
+ newInput.xmin = input->xmin - this->m_scope;
+ newInput.ymax = input->ymax + this->m_scope;
+ newInput.ymin = input->ymin - this->m_scope;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// Dilate Distance
DilateDistanceOperation::DilateDistanceOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->setComplex(true);
- this->m_inputProgram = NULL;
- this->m_distance = 0.0f;
- this->setOpenCL(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
+ this->m_distance = 0.0f;
+ this->setOpenCL(true);
}
void DilateDistanceOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- this->m_scope = this->m_distance;
- if (this->m_scope < 3) {
- this->m_scope = 3;
- }
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_scope = this->m_distance;
+ if (this->m_scope < 3) {
+ this->m_scope = 3;
+ }
}
void *DilateDistanceOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
- return buffer;
+ void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ return buffer;
}
void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *data)
{
- const float distance = this->m_distance;
- const float mindist = distance * distance;
-
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- rcti *rect = inputBuffer->getRect();
- const int minx = max(x - this->m_scope, rect->xmin);
- const int miny = max(y - this->m_scope, rect->ymin);
- const int maxx = min(x + this->m_scope, rect->xmax);
- const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_rcti_size_x(rect);
- int offset;
-
- float value = 0.0f;
-
- for (int yi = miny; yi < maxy; yi++) {
- const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
- for (int xi = minx; xi < maxx; xi++) {
- const float dx = xi - x;
- const float dis = dx * dx + dy * dy;
- if (dis <= mindist) {
- value = max(buffer[offset], value);
- }
- offset ++;
- }
- }
- output[0] = value;
+ const float distance = this->m_distance;
+ const float mindist = distance * distance;
+
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ rcti *rect = inputBuffer->getRect();
+ const int minx = max(x - this->m_scope, rect->xmin);
+ const int miny = max(y - this->m_scope, rect->ymin);
+ const int maxx = min(x + this->m_scope, rect->xmax);
+ const int maxy = min(y + this->m_scope, rect->ymax);
+ const int bufferWidth = BLI_rcti_size_x(rect);
+ int offset;
+
+ float value = 0.0f;
+
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ for (int xi = minx; xi < maxx; xi++) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
+ if (dis <= mindist) {
+ value = max(buffer[offset], value);
+ }
+ offset++;
+ }
+ }
+ output[0] = value;
}
void DilateDistanceOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
-bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DilateDistanceOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = input->xmax + this->m_scope;
- newInput.xmin = input->xmin - this->m_scope;
- newInput.ymax = input->ymax + this->m_scope;
- newInput.ymin = input->ymin - this->m_scope;
+ newInput.xmax = input->xmax + this->m_scope;
+ newInput.xmin = input->xmin - this->m_scope;
+ newInput.ymax = input->ymax + this->m_scope;
+ newInput.ymin = input->ymin - this->m_scope;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void DilateDistanceOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL);
-
- cl_int distanceSquared = this->m_distance * this->m_distance;
- cl_int scope = this->m_scope;
-
- device->COM_clAttachMemoryBufferToKernelParameter(dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer);
- clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope);
- clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared);
- device->COM_clAttachSizeToKernelParameter(dilateKernel, 6, this);
- device->COM_clEnqueueRange(dilateKernel, outputMemoryBuffer, 7, this);
+ cl_kernel dilateKernel = device->COM_clCreateKernel("dilateKernel", NULL);
+
+ cl_int distanceSquared = this->m_distance * this->m_distance;
+ cl_int scope = this->m_scope;
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ dilateKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(dilateKernel, 1, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(dilateKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(dilateKernel, 4, sizeof(cl_int), &scope);
+ clSetKernelArg(dilateKernel, 5, sizeof(cl_int), &distanceSquared);
+ device->COM_clAttachSizeToKernelParameter(dilateKernel, 6, this);
+ device->COM_clEnqueueRange(dilateKernel, outputMemoryBuffer, 7, this);
}
// Erode Distance
ErodeDistanceOperation::ErodeDistanceOperation() : DilateDistanceOperation()
{
- /* pass */
+ /* pass */
}
void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *data)
{
- const float distance = this->m_distance;
- const float mindist = distance * distance;
-
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- rcti *rect = inputBuffer->getRect();
- const int minx = max(x - this->m_scope, rect->xmin);
- const int miny = max(y - this->m_scope, rect->ymin);
- const int maxx = min(x + this->m_scope, rect->xmax);
- const int maxy = min(y + this->m_scope, rect->ymax);
- const int bufferWidth = BLI_rcti_size_x(rect);
- int offset;
-
- float value = 1.0f;
-
- for (int yi = miny; yi < maxy; yi++) {
- const float dy = yi - y;
- offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
- for (int xi = minx; xi < maxx; xi++) {
- const float dx = xi - x;
- const float dis = dx * dx + dy * dy;
- if (dis <= mindist) {
- value = min(buffer[offset], value);
- }
- offset ++;
- }
- }
- output[0] = value;
+ const float distance = this->m_distance;
+ const float mindist = distance * distance;
+
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ rcti *rect = inputBuffer->getRect();
+ const int minx = max(x - this->m_scope, rect->xmin);
+ const int miny = max(y - this->m_scope, rect->ymin);
+ const int maxx = min(x + this->m_scope, rect->xmax);
+ const int maxy = min(y + this->m_scope, rect->ymax);
+ const int bufferWidth = BLI_rcti_size_x(rect);
+ int offset;
+
+ float value = 1.0f;
+
+ for (int yi = miny; yi < maxy; yi++) {
+ const float dy = yi - y;
+ offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
+ for (int xi = minx; xi < maxx; xi++) {
+ const float dx = xi - x;
+ const float dis = dx * dx + dy * dy;
+ if (dis <= mindist) {
+ value = min(buffer[offset], value);
+ }
+ offset++;
+ }
+ }
+ output[0] = value;
}
void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL);
-
- cl_int distanceSquared = this->m_distance * this->m_distance;
- cl_int scope = this->m_scope;
-
- device->COM_clAttachMemoryBufferToKernelParameter(erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer);
- clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope);
- clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared);
- device->COM_clAttachSizeToKernelParameter(erodeKernel, 6, this);
- device->COM_clEnqueueRange(erodeKernel, outputMemoryBuffer, 7, this);
+ cl_kernel erodeKernel = device->COM_clCreateKernel("erodeKernel", NULL);
+
+ cl_int distanceSquared = this->m_distance * this->m_distance;
+ cl_int scope = this->m_scope;
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ erodeKernel, 0, 2, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(erodeKernel, 1, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(erodeKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(erodeKernel, 4, sizeof(cl_int), &scope);
+ clSetKernelArg(erodeKernel, 5, sizeof(cl_int), &distanceSquared);
+ device->COM_clAttachSizeToKernelParameter(erodeKernel, 6, this);
+ device->COM_clEnqueueRange(erodeKernel, outputMemoryBuffer, 7, this);
}
// Dilate step
DilateStepOperation::DilateStepOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->setComplex(true);
- this->m_inputProgram = NULL;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
}
void DilateStepOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-
// small helper to pass data from initializeTileData to executePixel
typedef struct tile_info {
- rcti rect;
- int width;
- float *buffer;
+ rcti rect;
+ int width;
+ float *buffer;
} tile_info;
static tile_info *create_cache(int xmin, int xmax, int ymin, int ymax)
{
- tile_info *result = (tile_info *)MEM_mallocN(sizeof(tile_info), "dilate erode tile");
- result->rect.xmin = xmin;
- result->rect.xmax = xmax;
- result->rect.ymin = ymin;
- result->rect.ymax = ymax;
- result->width = xmax - xmin;
- result->buffer = (float *)MEM_callocN(sizeof(float) * (ymax - ymin) * result->width, "dilate erode cache");
- return result;
+ tile_info *result = (tile_info *)MEM_mallocN(sizeof(tile_info), "dilate erode tile");
+ result->rect.xmin = xmin;
+ result->rect.xmax = xmax;
+ result->rect.ymin = ymin;
+ result->rect.ymax = ymax;
+ result->width = xmax - xmin;
+ result->buffer = (float *)MEM_callocN(sizeof(float) * (ymax - ymin) * result->width,
+ "dilate erode cache");
+ return result;
}
void *DilateStepOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
- int x, y, i;
- int width = tile->getWidth();
- int height = tile->getHeight();
- float *buffer = tile->getBuffer();
-
- int half_window = this->m_iterations;
- int window = half_window * 2 + 1;
-
- int xmin = max(0, rect->xmin - half_window);
- int ymin = max(0, rect->ymin - half_window);
- int xmax = min(width, rect->xmax + half_window);
- int ymax = min(height, rect->ymax + half_window);
-
- int bwidth = rect->xmax - rect->xmin;
- int bheight = rect->ymax - rect->ymin;
-
- // Note: Cache buffer has original tilesize width, but new height.
- // We have to calculate the additional rows in the first pass,
- // to have valid data available for the second pass.
- tile_info *result = create_cache(rect->xmin, rect->xmax, ymin, ymax);
- float *rectf = result->buffer;
-
- // temp holds maxima for every step in the algorithm, buf holds a
- // single row or column of input values, padded with FLT_MAX's to
- // simplify the logic.
- float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
- float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window), "dilate erode buf");
-
- // The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
- // first pass, horizontal dilate/erode
- for (y = ymin; y < ymax; y++) {
- for (x = 0; x < bwidth + 5 * half_window; x++) {
- buf[x] = -FLT_MAX;
- }
- for (x = xmin; x < xmax; ++x) {
- buf[x - rect->xmin + window - 1] = buffer[(y * width + x)];
- }
-
- for (i = 0; i < (bwidth + 3 * half_window) / window; i++) {
- int start = (i + 1) * window - 1;
-
- temp[window - 1] = buf[start];
- for (x = 1; x < window; x++) {
- temp[window - 1 - x] = max(temp[window - x], buf[start - x]);
- temp[window - 1 + x] = max(temp[window + x - 2], buf[start + x]);
- }
-
- start = half_window + (i - 1) * window + 1;
- for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
- rectf[bwidth * (y - ymin) + (start + x)] = max(temp[x], temp[x + window - 1]);
- }
- }
- }
-
- // second pass, vertical dilate/erode
- for (x = 0; x < bwidth; x++) {
- for (y = 0; y < bheight + 5 * half_window; y++) {
- buf[y] = -FLT_MAX;
- }
- for (y = ymin; y < ymax; y++) {
- buf[y - rect->ymin + window - 1] = rectf[(y - ymin) * bwidth + x];
- }
-
- for (i = 0; i < (bheight + 3 * half_window) / window; i++) {
- int start = (i + 1) * window - 1;
-
- temp[window - 1] = buf[start];
- for (y = 1; y < window; y++) {
- temp[window - 1 - y] = max(temp[window - y], buf[start - y]);
- temp[window - 1 + y] = max(temp[window + y - 2], buf[start + y]);
- }
-
- start = half_window + (i - 1) * window + 1;
- for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
- rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = max(temp[y], temp[y + window - 1]);
- }
- }
- }
-
- MEM_freeN(temp);
- MEM_freeN(buf);
-
- return result;
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+ int x, y, i;
+ int width = tile->getWidth();
+ int height = tile->getHeight();
+ float *buffer = tile->getBuffer();
+
+ int half_window = this->m_iterations;
+ int window = half_window * 2 + 1;
+
+ int xmin = max(0, rect->xmin - half_window);
+ int ymin = max(0, rect->ymin - half_window);
+ int xmax = min(width, rect->xmax + half_window);
+ int ymax = min(height, rect->ymax + half_window);
+
+ int bwidth = rect->xmax - rect->xmin;
+ int bheight = rect->ymax - rect->ymin;
+
+ // Note: Cache buffer has original tilesize width, but new height.
+ // We have to calculate the additional rows in the first pass,
+ // to have valid data available for the second pass.
+ tile_info *result = create_cache(rect->xmin, rect->xmax, ymin, ymax);
+ float *rectf = result->buffer;
+
+ // temp holds maxima for every step in the algorithm, buf holds a
+ // single row or column of input values, padded with FLT_MAX's to
+ // simplify the logic.
+ float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
+ float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window),
+ "dilate erode buf");
+
+ // The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
+ // first pass, horizontal dilate/erode
+ for (y = ymin; y < ymax; y++) {
+ for (x = 0; x < bwidth + 5 * half_window; x++) {
+ buf[x] = -FLT_MAX;
+ }
+ for (x = xmin; x < xmax; ++x) {
+ buf[x - rect->xmin + window - 1] = buffer[(y * width + x)];
+ }
+
+ for (i = 0; i < (bwidth + 3 * half_window) / window; i++) {
+ int start = (i + 1) * window - 1;
+
+ temp[window - 1] = buf[start];
+ for (x = 1; x < window; x++) {
+ temp[window - 1 - x] = max(temp[window - x], buf[start - x]);
+ temp[window - 1 + x] = max(temp[window + x - 2], buf[start + x]);
+ }
+
+ start = half_window + (i - 1) * window + 1;
+ for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
+ rectf[bwidth * (y - ymin) + (start + x)] = max(temp[x], temp[x + window - 1]);
+ }
+ }
+ }
+
+ // second pass, vertical dilate/erode
+ for (x = 0; x < bwidth; x++) {
+ for (y = 0; y < bheight + 5 * half_window; y++) {
+ buf[y] = -FLT_MAX;
+ }
+ for (y = ymin; y < ymax; y++) {
+ buf[y - rect->ymin + window - 1] = rectf[(y - ymin) * bwidth + x];
+ }
+
+ for (i = 0; i < (bheight + 3 * half_window) / window; i++) {
+ int start = (i + 1) * window - 1;
+
+ temp[window - 1] = buf[start];
+ for (y = 1; y < window; y++) {
+ temp[window - 1 - y] = max(temp[window - y], buf[start - y]);
+ temp[window - 1 + y] = max(temp[window + y - 2], buf[start + y]);
+ }
+
+ start = half_window + (i - 1) * window + 1;
+ for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
+ rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = max(temp[y], temp[y + window - 1]);
+ }
+ }
+ }
+
+ MEM_freeN(temp);
+ MEM_freeN(buf);
+
+ return result;
}
-
void DilateStepOperation::executePixel(float output[4], int x, int y, void *data)
{
- tile_info *tile = (tile_info *)data;
- int nx = x - tile->rect.xmin;
- int ny = y - tile->rect.ymin;
- output[0] = tile->buffer[tile->width * ny + nx];
+ tile_info *tile = (tile_info *)data;
+ int nx = x - tile->rect.xmin;
+ int ny = y - tile->rect.ymin;
+ output[0] = tile->buffer[tile->width * ny + nx];
}
void DilateStepOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
void DilateStepOperation::deinitializeTileData(rcti * /*rect*/, void *data)
{
- tile_info *tile = (tile_info *)data;
- MEM_freeN(tile->buffer);
- MEM_freeN(tile);
+ tile_info *tile = (tile_info *)data;
+ MEM_freeN(tile->buffer);
+ MEM_freeN(tile);
}
-bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DilateStepOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- int it = this->m_iterations;
- newInput.xmax = input->xmax + it;
- newInput.xmin = input->xmin - it;
- newInput.ymax = input->ymax + it;
- newInput.ymin = input->ymin - it;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+ int it = this->m_iterations;
+ newInput.xmax = input->xmax + it;
+ newInput.xmin = input->xmin - it;
+ newInput.ymax = input->ymax + it;
+ newInput.ymin = input->ymin - it;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
// Erode step
ErodeStepOperation::ErodeStepOperation() : DilateStepOperation()
{
- /* pass */
+ /* pass */
}
void *ErodeStepOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
- int x, y, i;
- int width = tile->getWidth();
- int height = tile->getHeight();
- float *buffer = tile->getBuffer();
-
- int half_window = this->m_iterations;
- int window = half_window * 2 + 1;
-
- int xmin = max(0, rect->xmin - half_window);
- int ymin = max(0, rect->ymin - half_window);
- int xmax = min(width, rect->xmax + half_window);
- int ymax = min(height, rect->ymax + half_window);
-
- int bwidth = rect->xmax - rect->xmin;
- int bheight = rect->ymax - rect->ymin;
-
- // Note: Cache buffer has original tilesize width, but new height.
- // We have to calculate the additional rows in the first pass,
- // to have valid data available for the second pass.
- tile_info *result = create_cache(rect->xmin, rect->xmax, ymin, ymax);
- float *rectf = result->buffer;
-
- // temp holds maxima for every step in the algorithm, buf holds a
- // single row or column of input values, padded with FLT_MAX's to
- // simplify the logic.
- float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
- float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window), "dilate erode buf");
-
- // The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
- // first pass, horizontal dilate/erode
- for (y = ymin; y < ymax; y++) {
- for (x = 0; x < bwidth + 5 * half_window; x++) {
- buf[x] = FLT_MAX;
- }
- for (x = xmin; x < xmax; ++x) {
- buf[x - rect->xmin + window - 1] = buffer[(y * width + x)];
- }
-
- for (i = 0; i < (bwidth + 3 * half_window) / window; i++) {
- int start = (i + 1) * window - 1;
-
- temp[window - 1] = buf[start];
- for (x = 1; x < window; x++) {
- temp[window - 1 - x] = min(temp[window - x], buf[start - x]);
- temp[window - 1 + x] = min(temp[window + x - 2], buf[start + x]);
- }
-
- start = half_window + (i - 1) * window + 1;
- for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
- rectf[bwidth * (y - ymin) + (start + x)] = min(temp[x], temp[x + window - 1]);
- }
- }
- }
-
- // second pass, vertical dilate/erode
- for (x = 0; x < bwidth; x++) {
- for (y = 0; y < bheight + 5 * half_window; y++) {
- buf[y] = FLT_MAX;
- }
- for (y = ymin; y < ymax; y++) {
- buf[y - rect->ymin + window - 1] = rectf[(y - ymin) * bwidth + x];
- }
-
- for (i = 0; i < (bheight + 3 * half_window) / window; i++) {
- int start = (i + 1) * window - 1;
-
- temp[window - 1] = buf[start];
- for (y = 1; y < window; y++) {
- temp[window - 1 - y] = min(temp[window - y], buf[start - y]);
- temp[window - 1 + y] = min(temp[window + y - 2], buf[start + y]);
- }
-
- start = half_window + (i - 1) * window + 1;
- for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
- rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = min(temp[y], temp[y + window - 1]);
- }
- }
- }
-
- MEM_freeN(temp);
- MEM_freeN(buf);
-
- return result;
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+ int x, y, i;
+ int width = tile->getWidth();
+ int height = tile->getHeight();
+ float *buffer = tile->getBuffer();
+
+ int half_window = this->m_iterations;
+ int window = half_window * 2 + 1;
+
+ int xmin = max(0, rect->xmin - half_window);
+ int ymin = max(0, rect->ymin - half_window);
+ int xmax = min(width, rect->xmax + half_window);
+ int ymax = min(height, rect->ymax + half_window);
+
+ int bwidth = rect->xmax - rect->xmin;
+ int bheight = rect->ymax - rect->ymin;
+
+ // Note: Cache buffer has original tilesize width, but new height.
+ // We have to calculate the additional rows in the first pass,
+ // to have valid data available for the second pass.
+ tile_info *result = create_cache(rect->xmin, rect->xmax, ymin, ymax);
+ float *rectf = result->buffer;
+
+ // temp holds maxima for every step in the algorithm, buf holds a
+ // single row or column of input values, padded with FLT_MAX's to
+ // simplify the logic.
+ float *temp = (float *)MEM_mallocN(sizeof(float) * (2 * window - 1), "dilate erode temp");
+ float *buf = (float *)MEM_mallocN(sizeof(float) * (max(bwidth, bheight) + 5 * half_window),
+ "dilate erode buf");
+
+ // The following is based on the van Herk/Gil-Werman algorithm for morphology operations.
+ // first pass, horizontal dilate/erode
+ for (y = ymin; y < ymax; y++) {
+ for (x = 0; x < bwidth + 5 * half_window; x++) {
+ buf[x] = FLT_MAX;
+ }
+ for (x = xmin; x < xmax; ++x) {
+ buf[x - rect->xmin + window - 1] = buffer[(y * width + x)];
+ }
+
+ for (i = 0; i < (bwidth + 3 * half_window) / window; i++) {
+ int start = (i + 1) * window - 1;
+
+ temp[window - 1] = buf[start];
+ for (x = 1; x < window; x++) {
+ temp[window - 1 - x] = min(temp[window - x], buf[start - x]);
+ temp[window - 1 + x] = min(temp[window + x - 2], buf[start + x]);
+ }
+
+ start = half_window + (i - 1) * window + 1;
+ for (x = -min(0, start); x < window - max(0, start + window - bwidth); x++) {
+ rectf[bwidth * (y - ymin) + (start + x)] = min(temp[x], temp[x + window - 1]);
+ }
+ }
+ }
+
+ // second pass, vertical dilate/erode
+ for (x = 0; x < bwidth; x++) {
+ for (y = 0; y < bheight + 5 * half_window; y++) {
+ buf[y] = FLT_MAX;
+ }
+ for (y = ymin; y < ymax; y++) {
+ buf[y - rect->ymin + window - 1] = rectf[(y - ymin) * bwidth + x];
+ }
+
+ for (i = 0; i < (bheight + 3 * half_window) / window; i++) {
+ int start = (i + 1) * window - 1;
+
+ temp[window - 1] = buf[start];
+ for (y = 1; y < window; y++) {
+ temp[window - 1 - y] = min(temp[window - y], buf[start - y]);
+ temp[window - 1 + y] = min(temp[window + y - 2], buf[start + y]);
+ }
+
+ start = half_window + (i - 1) * window + 1;
+ for (y = -min(0, start); y < window - max(0, start + window - bheight); y++) {
+ rectf[bwidth * (y + start + (rect->ymin - ymin)) + x] = min(temp[y], temp[y + window - 1]);
+ }
+ }
+ }
+
+ MEM_freeN(temp);
+ MEM_freeN(buf);
+
+ return result;
}
diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.h b/source/blender/compositor/operations/COM_DilateErodeOperation.h
index 7aa71c80999..bd7e0938c58 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.h
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.h
@@ -20,140 +20,165 @@
#define __COM_DILATEERODEOPERATION_H__
#include "COM_NodeOperation.h"
-
class DilateErodeThresholdOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
-
- float m_distance;
- float m__switch;
- float m_inset;
-
- /**
- * determines the area of interest to track pixels
- * keep this one as small as possible for speed gain.
- */
- int m_scope;
-public:
- DilateErodeThresholdOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setDistance(float distance) { this->m_distance = distance; }
- void setSwitch(float sw) { this->m__switch = sw; }
- void setInset(float inset) { this->m_inset = inset; }
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+
+ float m_distance;
+ float m__switch;
+ float m_inset;
+
+ /**
+ * determines the area of interest to track pixels
+ * keep this one as small as possible for speed gain.
+ */
+ int m_scope;
+
+ public:
+ DilateErodeThresholdOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setDistance(float distance)
+ {
+ this->m_distance = distance;
+ }
+ void setSwitch(float sw)
+ {
+ this->m__switch = sw;
+ }
+ void setInset(float inset)
+ {
+ this->m_inset = inset;
+ }
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
class DilateDistanceOperation : public NodeOperation {
-private:
-protected:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- float m_distance;
- int m_scope;
-public:
- DilateDistanceOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setDistance(float distance) { this->m_distance = distance; }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
+ private:
+ protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ float m_distance;
+ int m_scope;
+
+ public:
+ DilateDistanceOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setDistance(float distance)
+ {
+ this->m_distance = distance;
+ }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
class ErodeDistanceOperation : public DilateDistanceOperation {
-public:
- ErodeDistanceOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
+ public:
+ ErodeDistanceOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
class DilateStepOperation : public NodeOperation {
-protected:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
-
- int m_iterations;
-
-public:
- DilateStepOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
- void deinitializeTileData(rcti *rect, void *data);
-
- void setIterations(int iterations) { this->m_iterations = iterations; }
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+
+ int m_iterations;
+
+ public:
+ DilateStepOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ void deinitializeTileData(rcti *rect, void *data);
+
+ void setIterations(int iterations)
+ {
+ this->m_iterations = iterations;
+ }
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
class ErodeStepOperation : public DilateStepOperation {
-public:
- ErodeStepOperation();
+ public:
+ ErodeStepOperation();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
};
#endif
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index a9f9ec9f091..59a397ab32d 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -20,122 +20,127 @@
#include "BLI_math.h"
#include "COM_OpenCLDevice.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
DirectionalBlurOperation::DirectionalBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
- this->setOpenCL(true);
- this->m_inputProgram = NULL;
+ this->setOpenCL(true);
+ this->m_inputProgram = NULL;
}
void DirectionalBlurOperation::initExecution()
{
- this->m_inputProgram = getInputSocketReader(0);
- QualityStepHelper::initExecution(COM_QH_INCREASE);
- const float angle = this->m_data->angle;
- const float zoom = this->m_data->zoom;
- const float spin = this->m_data->spin;
- const float iterations = this->m_data->iter;
- const float distance = this->m_data->distance;
- const float center_x = this->m_data->center_x;
- const float center_y = this->m_data->center_y;
- const float width = getWidth();
- const float height = getHeight();
-
- const float a = angle;
- const float itsc = 1.0f / powf(2.0f, (float)iterations);
- float D;
-
- D = distance * sqrtf(width * width + height * height);
- this->m_center_x_pix = center_x * width;
- this->m_center_y_pix = center_y * height;
-
- this->m_tx = itsc * D * cosf(a);
- this->m_ty = -itsc * D * sinf(a);
- this->m_sc = itsc * zoom;
- this->m_rot = itsc * spin;
-
+ this->m_inputProgram = getInputSocketReader(0);
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
+ const float angle = this->m_data->angle;
+ const float zoom = this->m_data->zoom;
+ const float spin = this->m_data->spin;
+ const float iterations = this->m_data->iter;
+ const float distance = this->m_data->distance;
+ const float center_x = this->m_data->center_x;
+ const float center_y = this->m_data->center_y;
+ const float width = getWidth();
+ const float height = getHeight();
+
+ const float a = angle;
+ const float itsc = 1.0f / powf(2.0f, (float)iterations);
+ float D;
+
+ D = distance * sqrtf(width * width + height * height);
+ this->m_center_x_pix = center_x * width;
+ this->m_center_y_pix = center_y * height;
+
+ this->m_tx = itsc * D * cosf(a);
+ this->m_ty = -itsc * D * sinf(a);
+ this->m_sc = itsc * zoom;
+ this->m_rot = itsc * spin;
}
void DirectionalBlurOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- const int iterations = pow(2.0f, this->m_data->iter);
- float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
- float ltx = this->m_tx;
- float lty = this->m_ty;
- float lsc = this->m_sc;
- float lrot = this->m_rot;
- /* blur the image */
- for (int i = 0; i < iterations; ++i) {
- const float cs = cosf(lrot), ss = sinf(lrot);
- const float isc = 1.0f / (1.0f + lsc);
-
- const float v = isc * (y - this->m_center_y_pix) + lty;
- const float u = isc * (x - this->m_center_x_pix) + ltx;
-
- this->m_inputProgram->readSampled(col,
- cs * u + ss * v + this->m_center_x_pix,
- cs * v - ss * u + this->m_center_y_pix,
- COM_PS_BILINEAR);
-
- add_v4_v4(col2, col);
-
- /* double transformations */
- ltx += this->m_tx;
- lty += this->m_ty;
- lrot += this->m_rot;
- lsc += this->m_sc;
- }
-
- mul_v4_v4fl(output, col2, 1.0f / (iterations + 1));
+ const int iterations = pow(2.0f, this->m_data->iter);
+ float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float col2[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ this->m_inputProgram->readSampled(col2, x, y, COM_PS_BILINEAR);
+ float ltx = this->m_tx;
+ float lty = this->m_ty;
+ float lsc = this->m_sc;
+ float lrot = this->m_rot;
+ /* blur the image */
+ for (int i = 0; i < iterations; ++i) {
+ const float cs = cosf(lrot), ss = sinf(lrot);
+ const float isc = 1.0f / (1.0f + lsc);
+
+ const float v = isc * (y - this->m_center_y_pix) + lty;
+ const float u = isc * (x - this->m_center_x_pix) + ltx;
+
+ this->m_inputProgram->readSampled(col,
+ cs * u + ss * v + this->m_center_x_pix,
+ cs * v - ss * u + this->m_center_y_pix,
+ COM_PS_BILINEAR);
+
+ add_v4_v4(col2, col);
+
+ /* double transformations */
+ ltx += this->m_tx;
+ lty += this->m_ty;
+ lrot += this->m_rot;
+ lsc += this->m_sc;
+ }
+
+ mul_v4_v4fl(output, col2, 1.0f / (iterations + 1));
}
void DirectionalBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> * /*clKernelsToCleanUp*/)
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL);
-
- cl_int iterations = pow(2.0f, this->m_data->iter);
- cl_float2 ltxy = {{this->m_tx, this->m_ty}};
- cl_float2 centerpix = {{this->m_center_x_pix, this->m_center_y_pix}};
- cl_float lsc = this->m_sc;
- cl_float lrot = this->m_rot;
-
- device->COM_clAttachMemoryBufferToKernelParameter(directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(directionalBlurKernel, 1, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(directionalBlurKernel, 2, outputMemoryBuffer);
- clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations);
- clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc);
- clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot);
- clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), &ltxy);
- clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), &centerpix);
-
- device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this);
+ cl_kernel directionalBlurKernel = device->COM_clCreateKernel("directionalBlurKernel", NULL);
+
+ cl_int iterations = pow(2.0f, this->m_data->iter);
+ cl_float2 ltxy = {{this->m_tx, this->m_ty}};
+ cl_float2 centerpix = {{this->m_center_x_pix, this->m_center_y_pix}};
+ cl_float lsc = this->m_sc;
+ cl_float lrot = this->m_rot;
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ directionalBlurKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(
+ directionalBlurKernel, 1, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(
+ directionalBlurKernel, 2, outputMemoryBuffer);
+ clSetKernelArg(directionalBlurKernel, 3, sizeof(cl_int), &iterations);
+ clSetKernelArg(directionalBlurKernel, 4, sizeof(cl_float), &lsc);
+ clSetKernelArg(directionalBlurKernel, 5, sizeof(cl_float), &lrot);
+ clSetKernelArg(directionalBlurKernel, 6, sizeof(cl_float2), &ltxy);
+ clSetKernelArg(directionalBlurKernel, 7, sizeof(cl_float2), &centerpix);
+
+ device->COM_clEnqueueRange(directionalBlurKernel, outputMemoryBuffer, 8, this);
}
-
void DirectionalBlurOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
-bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool DirectionalBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
index fa224407d08..f8b7bab010b 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.h
@@ -22,40 +22,46 @@
#include "COM_QualityStepHelper.h"
class DirectionalBlurOperation : public NodeOperation, public QualityStepHelper {
-private:
- SocketReader *m_inputProgram;
- NodeDBlurData *m_data;
+ private:
+ SocketReader *m_inputProgram;
+ NodeDBlurData *m_data;
- float m_center_x_pix, m_center_y_pix;
- float m_tx, m_ty;
- float m_sc, m_rot;
+ float m_center_x_pix, m_center_y_pix;
+ float m_tx, m_ty;
+ float m_sc, m_rot;
-public:
- DirectionalBlurOperation();
+ public:
+ DirectionalBlurOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- void setData(NodeDBlurData *data) { this->m_data = data; }
-
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
+ void setData(NodeDBlurData *data)
+ {
+ this->m_data = data;
+ }
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
index b44123196f8..3efc566cb4e 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp
@@ -22,168 +22,174 @@
DisplaceOperation::DisplaceOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VECTOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
-
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+
+ this->m_inputColorProgram = NULL;
+ this->m_inputVectorProgram = NULL;
+ this->m_inputScaleXProgram = NULL;
+ this->m_inputScaleYProgram = NULL;
}
void DisplaceOperation::initExecution()
{
- this->m_inputColorProgram = this->getInputSocketReader(0);
- this->m_inputVectorProgram = this->getInputSocketReader(1);
- this->m_inputScaleXProgram = this->getInputSocketReader(2);
- this->m_inputScaleYProgram = this->getInputSocketReader(3);
+ this->m_inputColorProgram = this->getInputSocketReader(0);
+ this->m_inputVectorProgram = this->getInputSocketReader(1);
+ this->m_inputScaleXProgram = this->getInputSocketReader(2);
+ this->m_inputScaleYProgram = this->getInputSocketReader(3);
- this->m_width_x4 = this->getWidth() * 4;
- this->m_height_x4 = this->getHeight() * 4;
+ this->m_width_x4 = this->getWidth() * 4;
+ this->m_height_x4 = this->getHeight() * 4;
}
-void DisplaceOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void DisplaceOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- float xy[2] = { x, y };
- float uv[2], deriv[2][2];
-
- pixelTransform(xy, uv, deriv);
- if (is_zero_v2(deriv[0]) && is_zero_v2(deriv[1])) {
- this->m_inputColorProgram->readSampled(output, uv[0], uv[1], COM_PS_BILINEAR);
- }
- else {
- /* EWA filtering (without nearest it gets blurry with NO distortion) */
- this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
- }
+ float xy[2] = {x, y};
+ float uv[2], deriv[2][2];
+
+ pixelTransform(xy, uv, deriv);
+ if (is_zero_v2(deriv[0]) && is_zero_v2(deriv[1])) {
+ this->m_inputColorProgram->readSampled(output, uv[0], uv[1], COM_PS_BILINEAR);
+ }
+ else {
+ /* EWA filtering (without nearest it gets blurry with NO distortion) */
+ this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
+ }
}
-bool DisplaceOperation::read_displacement(float x, float y, float xscale, float yscale, const float origin[2], float &r_u, float &r_v)
+bool DisplaceOperation::read_displacement(
+ float x, float y, float xscale, float yscale, const float origin[2], float &r_u, float &r_v)
{
- float width = m_inputVectorProgram->getWidth();
- float height = m_inputVectorProgram->getHeight();
- if (x < 0.0f || x >= width || y < 0.0f || y >= height) {
- r_u = 0.0f;
- r_v = 0.0f;
- return false;
- }
- else {
- float col[4];
- m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
- r_u = origin[0] - col[0] * xscale;
- r_v = origin[1] - col[1] * yscale;
- return true;
- }
+ float width = m_inputVectorProgram->getWidth();
+ float height = m_inputVectorProgram->getHeight();
+ if (x < 0.0f || x >= width || y < 0.0f || y >= height) {
+ r_u = 0.0f;
+ r_v = 0.0f;
+ return false;
+ }
+ else {
+ float col[4];
+ m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR);
+ r_u = origin[0] - col[0] * xscale;
+ r_v = origin[1] - col[1] * yscale;
+ return true;
+ }
}
void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2])
{
- float col[4];
- float uv[2]; /* temporary variables for derivative estimation */
- int num;
-
- m_inputScaleXProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
- float xs = col[0];
- m_inputScaleYProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
- float ys = col[0];
- /* clamp x and y displacement to triple image resolution -
- * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
- CLAMP(xs, -m_width_x4, m_width_x4);
- CLAMP(ys, -m_height_x4, m_height_x4);
-
- /* displaced pixel in uv coords, for image sampling */
- read_displacement(xy[0], xy[1], xs, ys, xy, r_uv[0], r_uv[1]);
-
- /* Estimate partial derivatives using 1-pixel offsets */
- const float epsilon[2] = { 1.0f, 1.0f };
-
- zero_v2(r_deriv[0]);
- zero_v2(r_deriv[1]);
-
- num = 0;
- if (read_displacement(xy[0] + epsilon[0], xy[1], xs, ys, xy, uv[0], uv[1])) {
- r_deriv[0][0] += uv[0] - r_uv[0];
- r_deriv[1][0] += uv[1] - r_uv[1];
- ++num;
- }
- if (read_displacement(xy[0] - epsilon[0], xy[1], xs, ys, xy, uv[0], uv[1])) {
- r_deriv[0][0] += r_uv[0] - uv[0];
- r_deriv[1][0] += r_uv[1] - uv[1];
- ++num;
- }
- if (num > 0) {
- float numinv = 1.0f / (float)num;
- r_deriv[0][0] *= numinv;
- r_deriv[1][0] *= numinv;
- }
-
- num = 0;
- if (read_displacement(xy[0], xy[1] + epsilon[1], xs, ys, xy, uv[0], uv[1])) {
- r_deriv[0][1] += uv[0] - r_uv[0];
- r_deriv[1][1] += uv[1] - r_uv[1];
- ++num;
- }
- if (read_displacement(xy[0], xy[1] - epsilon[1], xs, ys, xy, uv[0], uv[1])) {
- r_deriv[0][1] += r_uv[0] - uv[0];
- r_deriv[1][1] += r_uv[1] - uv[1];
- ++num;
- }
- if (num > 0) {
- float numinv = 1.0f / (float)num;
- r_deriv[0][1] *= numinv;
- r_deriv[1][1] *= numinv;
- }
+ float col[4];
+ float uv[2]; /* temporary variables for derivative estimation */
+ int num;
+
+ m_inputScaleXProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
+ float xs = col[0];
+ m_inputScaleYProgram->readSampled(col, xy[0], xy[1], COM_PS_NEAREST);
+ float ys = col[0];
+ /* clamp x and y displacement to triple image resolution -
+ * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
+ CLAMP(xs, -m_width_x4, m_width_x4);
+ CLAMP(ys, -m_height_x4, m_height_x4);
+
+ /* displaced pixel in uv coords, for image sampling */
+ read_displacement(xy[0], xy[1], xs, ys, xy, r_uv[0], r_uv[1]);
+
+ /* Estimate partial derivatives using 1-pixel offsets */
+ const float epsilon[2] = {1.0f, 1.0f};
+
+ zero_v2(r_deriv[0]);
+ zero_v2(r_deriv[1]);
+
+ num = 0;
+ if (read_displacement(xy[0] + epsilon[0], xy[1], xs, ys, xy, uv[0], uv[1])) {
+ r_deriv[0][0] += uv[0] - r_uv[0];
+ r_deriv[1][0] += uv[1] - r_uv[1];
+ ++num;
+ }
+ if (read_displacement(xy[0] - epsilon[0], xy[1], xs, ys, xy, uv[0], uv[1])) {
+ r_deriv[0][0] += r_uv[0] - uv[0];
+ r_deriv[1][0] += r_uv[1] - uv[1];
+ ++num;
+ }
+ if (num > 0) {
+ float numinv = 1.0f / (float)num;
+ r_deriv[0][0] *= numinv;
+ r_deriv[1][0] *= numinv;
+ }
+
+ num = 0;
+ if (read_displacement(xy[0], xy[1] + epsilon[1], xs, ys, xy, uv[0], uv[1])) {
+ r_deriv[0][1] += uv[0] - r_uv[0];
+ r_deriv[1][1] += uv[1] - r_uv[1];
+ ++num;
+ }
+ if (read_displacement(xy[0], xy[1] - epsilon[1], xs, ys, xy, uv[0], uv[1])) {
+ r_deriv[0][1] += r_uv[0] - uv[0];
+ r_deriv[1][1] += r_uv[1] - uv[1];
+ ++num;
+ }
+ if (num > 0) {
+ float numinv = 1.0f / (float)num;
+ r_deriv[0][1] *= numinv;
+ r_deriv[1][1] *= numinv;
+ }
}
void DisplaceOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = NULL;
+ this->m_inputVectorProgram = NULL;
+ this->m_inputScaleXProgram = NULL;
+ this->m_inputScaleYProgram = NULL;
}
-bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DisplaceOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti colorInput;
- rcti vectorInput;
- NodeOperation *operation = NULL;
-
- /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
- /* image */
- operation = getInputOperation(0);
- colorInput.xmax = operation->getWidth();
- colorInput.xmin = 0;
- colorInput.ymax = operation->getHeight();
- colorInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
- return true;
- }
-
- /* vector */
- operation = getInputOperation(1);
- vectorInput.xmax = input->xmax + 1;
- vectorInput.xmin = input->xmin - 1;
- vectorInput.ymax = input->ymax + 1;
- vectorInput.ymin = input->ymin - 1;
- if (operation->determineDependingAreaOfInterest(&vectorInput, readOperation, output)) {
- return true;
- }
-
- /* scale x */
- operation = getInputOperation(2);
- if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
- return true;
- }
-
- /* scale y */
- operation = getInputOperation(3);
- if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
- return true;
- }
-
- return false;
+ rcti colorInput;
+ rcti vectorInput;
+ NodeOperation *operation = NULL;
+
+ /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
+ /* image */
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* vector */
+ operation = getInputOperation(1);
+ vectorInput.xmax = input->xmax + 1;
+ vectorInput.xmin = input->xmin - 1;
+ vectorInput.ymax = input->ymax + 1;
+ vectorInput.ymin = input->ymin - 1;
+ if (operation->determineDependingAreaOfInterest(&vectorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* scale x */
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ /* scale y */
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ return false;
}
diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.h b/source/blender/compositor/operations/COM_DisplaceOperation.h
index da652975a1d..4e44572fcf2 100644
--- a/source/blender/compositor/operations/COM_DisplaceOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceOperation.h
@@ -20,46 +20,48 @@
#define __COM_DISPLACEOPERATION_H__
#include "COM_NodeOperation.h"
-
class DisplaceOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputColorProgram;
- SocketReader *m_inputVectorProgram;
- SocketReader *m_inputScaleXProgram;
- SocketReader *m_inputScaleYProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputColorProgram;
+ SocketReader *m_inputVectorProgram;
+ SocketReader *m_inputScaleXProgram;
+ SocketReader *m_inputScaleYProgram;
- float m_width_x4;
- float m_height_x4;
+ float m_width_x4;
+ float m_height_x4;
-public:
- DisplaceOperation();
+ public:
+ DisplaceOperation();
- /**
- * we need a 2x2 differential filter for Vector Input and full buffer for the image
- */
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /**
+ * we need a 2x2 differential filter for Vector Input and full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2]);
+ void pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2]);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
-private:
- bool read_displacement(float x, float y, float xscale, float yscale, const float origin[2], float &r_u, float &r_v);
+ private:
+ bool read_displacement(
+ float x, float y, float xscale, float yscale, const float origin[2], float &r_u, float &r_v);
};
#endif
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
index e6edbfcf6e0..32eb5679d9d 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.cpp
@@ -22,106 +22,110 @@
DisplaceSimpleOperation::DisplaceSimpleOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VECTOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
-
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->m_inputColorProgram = NULL;
+ this->m_inputVectorProgram = NULL;
+ this->m_inputScaleXProgram = NULL;
+ this->m_inputScaleYProgram = NULL;
}
void DisplaceSimpleOperation::initExecution()
{
- this->m_inputColorProgram = this->getInputSocketReader(0);
- this->m_inputVectorProgram = this->getInputSocketReader(1);
- this->m_inputScaleXProgram = this->getInputSocketReader(2);
- this->m_inputScaleYProgram = this->getInputSocketReader(3);
+ this->m_inputColorProgram = this->getInputSocketReader(0);
+ this->m_inputVectorProgram = this->getInputSocketReader(1);
+ this->m_inputScaleXProgram = this->getInputSocketReader(2);
+ this->m_inputScaleYProgram = this->getInputSocketReader(3);
- this->m_width_x4 = this->getWidth() * 4;
- this->m_height_x4 = this->getHeight() * 4;
+ this->m_width_x4 = this->getWidth() * 4;
+ this->m_height_x4 = this->getHeight() * 4;
}
-
/* minimum distance (in pixels) a pixel has to be displaced
* in order to take effect */
// #define DISPLACE_EPSILON 0.01f
-void DisplaceSimpleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void DisplaceSimpleOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inVector[4];
- float inScale[4];
-
- float p_dx, p_dy; /* main displacement in pixel space */
- float u, v;
-
- this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler);
- float xs = inScale[0];
- this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler);
- float ys = inScale[0];
-
- /* clamp x and y displacement to triple image resolution -
- * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
- CLAMP(xs, -this->m_width_x4, this->m_width_x4);
- CLAMP(ys, -this->m_height_x4, this->m_height_x4);
-
- this->m_inputVectorProgram->readSampled(inVector, x, y, sampler);
- p_dx = inVector[0] * xs;
- p_dy = inVector[1] * ys;
-
- /* displaced pixel in uv coords, for image sampling */
- /* clamp nodes to avoid glitches */
- u = x - p_dx + 0.5f;
- v = y - p_dy + 0.5f;
- CLAMP(u, 0.0f, this->getWidth() - 1.0f);
- CLAMP(v, 0.0f, this->getHeight() - 1.0f);
-
- this->m_inputColorProgram->readSampled(output, u, v, sampler);
+ float inVector[4];
+ float inScale[4];
+
+ float p_dx, p_dy; /* main displacement in pixel space */
+ float u, v;
+
+ this->m_inputScaleXProgram->readSampled(inScale, x, y, sampler);
+ float xs = inScale[0];
+ this->m_inputScaleYProgram->readSampled(inScale, x, y, sampler);
+ float ys = inScale[0];
+
+ /* clamp x and y displacement to triple image resolution -
+ * to prevent hangs from huge values mistakenly plugged in eg. z buffers */
+ CLAMP(xs, -this->m_width_x4, this->m_width_x4);
+ CLAMP(ys, -this->m_height_x4, this->m_height_x4);
+
+ this->m_inputVectorProgram->readSampled(inVector, x, y, sampler);
+ p_dx = inVector[0] * xs;
+ p_dy = inVector[1] * ys;
+
+ /* displaced pixel in uv coords, for image sampling */
+ /* clamp nodes to avoid glitches */
+ u = x - p_dx + 0.5f;
+ v = y - p_dy + 0.5f;
+ CLAMP(u, 0.0f, this->getWidth() - 1.0f);
+ CLAMP(v, 0.0f, this->getHeight() - 1.0f);
+
+ this->m_inputColorProgram->readSampled(output, u, v, sampler);
}
void DisplaceSimpleOperation::deinitExecution()
{
- this->m_inputColorProgram = NULL;
- this->m_inputVectorProgram = NULL;
- this->m_inputScaleXProgram = NULL;
- this->m_inputScaleYProgram = NULL;
+ this->m_inputColorProgram = NULL;
+ this->m_inputVectorProgram = NULL;
+ this->m_inputScaleXProgram = NULL;
+ this->m_inputScaleYProgram = NULL;
}
-bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DisplaceSimpleOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti colorInput;
- NodeOperation *operation = NULL;
-
- /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
- /* image */
- operation = getInputOperation(0);
- colorInput.xmax = operation->getWidth();
- colorInput.xmin = 0;
- colorInput.ymax = operation->getHeight();
- colorInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
- return true;
- }
-
- /* vector */
- if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
- return true;
- }
-
- /* scale x */
- operation = getInputOperation(2);
- if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
- return true;
- }
-
- /* scale y */
- operation = getInputOperation(3);
- if (operation->determineDependingAreaOfInterest(input, readOperation, output) ) {
- return true;
- }
-
- return false;
+ rcti colorInput;
+ NodeOperation *operation = NULL;
+
+ /* the vector buffer only needs a 2x2 buffer. The image needs whole buffer */
+ /* image */
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ /* vector */
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ /* scale x */
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ /* scale y */
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+
+ return false;
}
diff --git a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
index c3e20b4b816..6d4d6047137 100644
--- a/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
+++ b/source/blender/compositor/operations/COM_DisplaceSimpleOperation.h
@@ -20,41 +20,42 @@
#define __COM_DISPLACESIMPLEOPERATION_H__
#include "COM_NodeOperation.h"
-
class DisplaceSimpleOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputColorProgram;
- SocketReader *m_inputVectorProgram;
- SocketReader *m_inputScaleXProgram;
- SocketReader *m_inputScaleYProgram;
-
- float m_width_x4;
- float m_height_x4;
-
-public:
- DisplaceSimpleOperation();
-
- /**
- * we need a full buffer for the image
- */
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputColorProgram;
+ SocketReader *m_inputVectorProgram;
+ SocketReader *m_inputScaleXProgram;
+ SocketReader *m_inputScaleYProgram;
+
+ float m_width_x4;
+ float m_height_x4;
+
+ public:
+ DisplaceSimpleOperation();
+
+ /**
+ * we need a full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
index 98b49022639..ff337455658 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp
@@ -21,69 +21,72 @@
DistanceRGBMatteOperation::DistanceRGBMatteOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
void DistanceRGBMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_inputKeyProgram = this->getInputSocketReader(1);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputKeyProgram = this->getInputSocketReader(1);
}
void DistanceRGBMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
float DistanceRGBMatteOperation::calculateDistance(float key[4], float image[4])
{
- return len_v3v3(key, image);
+ return len_v3v3(key, image);
}
-void DistanceRGBMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void DistanceRGBMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inKey[4];
- float inImage[4];
+ float inKey[4];
+ float inImage[4];
- const float tolerance = this->m_settings->t1;
- const float falloff = this->m_settings->t2;
+ const float tolerance = this->m_settings->t1;
+ const float falloff = this->m_settings->t2;
- float distance;
- float alpha;
+ float distance;
+ float alpha;
- this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
- this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
- distance = this->calculateDistance(inKey, inImage);
+ distance = this->calculateDistance(inKey, inImage);
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
- /*make 100% transparent */
- if (distance < tolerance) {
- output[0] = 0.0f;
- }
- /*in the falloff region, make partially transparent */
- else if (distance < falloff + tolerance) {
- distance = distance - tolerance;
- alpha = distance / falloff;
- /*only change if more transparent than before */
- if (alpha < inImage[3]) {
- output[0] = alpha;
- }
- else { /* leave as before */
- output[0] = inImage[3];
- }
- }
- else {
- /* leave as before */
- output[0] = inImage[3];
- }
+ /*make 100% transparent */
+ if (distance < tolerance) {
+ output[0] = 0.0f;
+ }
+ /*in the falloff region, make partially transparent */
+ else if (distance < falloff + tolerance) {
+ distance = distance - tolerance;
+ alpha = distance / falloff;
+ /*only change if more transparent than before */
+ if (alpha < inImage[3]) {
+ output[0] = alpha;
+ }
+ else { /* leave as before */
+ output[0] = inImage[3];
+ }
+ }
+ else {
+ /* leave as before */
+ output[0] = inImage[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
index 418e7fd47d6..c64c6da8d24 100644
--- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.h
@@ -20,33 +20,35 @@
#define __COM_DISTANCERGBMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class DistanceRGBMatteOperation : public NodeOperation {
-protected:
- NodeChroma *m_settings;
- SocketReader *m_inputImageProgram;
- SocketReader *m_inputKeyProgram;
-
- virtual float calculateDistance(float key[4], float image[4]);
-
-public:
- /**
- * Default constructor
- */
- DistanceRGBMatteOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
-
- void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; }
+ protected:
+ NodeChroma *m_settings;
+ SocketReader *m_inputImageProgram;
+ SocketReader *m_inputKeyProgram;
+
+ virtual float calculateDistance(float key[4], float image[4]);
+
+ public:
+ /**
+ * Default constructor
+ */
+ DistanceRGBMatteOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setSettings(NodeChroma *nodeChroma)
+ {
+ this->m_settings = nodeChroma;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
index cc063d27fb5..6ad1a7e440a 100644
--- a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.cpp
@@ -21,11 +21,11 @@
DistanceYCCMatteOperation::DistanceYCCMatteOperation() : DistanceRGBMatteOperation()
{
- /* pass */
+ /* pass */
}
float DistanceYCCMatteOperation::calculateDistance(float key[4], float image[4])
{
- /* only measure the second 2 values */
- return len_v2v2(key + 1, image + 1);
+ /* only measure the second 2 values */
+ return len_v2v2(key + 1, image + 1);
}
diff --git a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
index 9c3d9680a1f..48880fb2b59 100644
--- a/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
+++ b/source/blender/compositor/operations/COM_DistanceYCCMatteOperation.h
@@ -21,20 +21,18 @@
#include "COM_MixOperation.h"
#include "COM_DistanceRGBMatteOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class DistanceYCCMatteOperation : public DistanceRGBMatteOperation {
-protected:
- virtual float calculateDistance(float key[4], float image[4]);
-
-public:
- /**
- * Default constructor
- */
- DistanceYCCMatteOperation();
+ protected:
+ virtual float calculateDistance(float key[4], float image[4]);
+ public:
+ /**
+ * Default constructor
+ */
+ DistanceYCCMatteOperation();
};
#endif
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.cpp b/source/blender/compositor/operations/COM_DotproductOperation.cpp
index 67e1276121f..da6ce510a25 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.cpp
+++ b/source/blender/compositor/operations/COM_DotproductOperation.cpp
@@ -20,32 +20,35 @@
DotproductOperation::DotproductOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VECTOR);
- this->addInputSocket(COM_DT_VECTOR);
- this->addOutputSocket(COM_DT_VALUE);
- this->setResolutionInputSocketIndex(0);
- this->m_input1Operation = NULL;
- this->m_input2Operation = NULL;
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setResolutionInputSocketIndex(0);
+ this->m_input1Operation = NULL;
+ this->m_input2Operation = NULL;
}
void DotproductOperation::initExecution()
{
- this->m_input1Operation = this->getInputSocketReader(0);
- this->m_input2Operation = this->getInputSocketReader(1);
+ this->m_input1Operation = this->getInputSocketReader(0);
+ this->m_input2Operation = this->getInputSocketReader(1);
}
void DotproductOperation::deinitExecution()
{
- this->m_input1Operation = NULL;
- this->m_input2Operation = NULL;
+ this->m_input1Operation = NULL;
+ this->m_input2Operation = NULL;
}
/** \todo: current implementation is the inverse of a dotproduct. not 'logically' correct
*/
-void DotproductOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void DotproductOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float input1[4];
- float input2[4];
- this->m_input1Operation->readSampled(input1, x, y, sampler);
- this->m_input2Operation->readSampled(input2, x, y, sampler);
- output[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]);
+ float input1[4];
+ float input2[4];
+ this->m_input1Operation->readSampled(input1, x, y, sampler);
+ this->m_input2Operation->readSampled(input2, x, y, sampler);
+ output[0] = -(input1[0] * input2[0] + input1[1] * input2[1] + input1[2] * input2[2]);
}
diff --git a/source/blender/compositor/operations/COM_DotproductOperation.h b/source/blender/compositor/operations/COM_DotproductOperation.h
index a568e909f17..9ef9753f4c9 100644
--- a/source/blender/compositor/operations/COM_DotproductOperation.h
+++ b/source/blender/compositor/operations/COM_DotproductOperation.h
@@ -22,16 +22,16 @@
#include "COM_NodeOperation.h"
class DotproductOperation : public NodeOperation {
-private:
- SocketReader *m_input1Operation;
- SocketReader *m_input2Operation;
-public:
- DotproductOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ private:
+ SocketReader *m_input1Operation;
+ SocketReader *m_input2Operation;
- void initExecution();
- void deinitExecution();
+ public:
+ DotproductOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
index 5e514796edb..34f0d2cb760 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp
@@ -24,1280 +24,1353 @@
#include "MEM_guardedalloc.h"
// this part has been copied from the double edge mask
-static void do_adjacentKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
+static void do_adjacentKeepBorders(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize)
{
- int x;
- unsigned int isz = 0; // inner edge size
- unsigned int osz = 0; // outer edge size
- unsigned int gsz = 0; // gradient fill area size
- /* Test the four corners */
- /* upper left corner */
- x = t - rw + 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* upper right corner */
- x = t;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* lower left corner */
- x = 0;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel above, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* lower right corner */
- x = rw - 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel above, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
+ int x;
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x = t - rw + 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* upper right corner */
+ x = t;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* lower left corner */
+ x = 0;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel above, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* lower right corner */
+ x = rw - 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel above, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
- /* Test the TOP row of pixels in buffer, except corners */
- for (x = t - 1; x >= (t - rw) + 2; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel to the right, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel to the right, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- /* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw - 2; x; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel to the right, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
- /* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or above, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for (x = rw - 2; x; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel to the right, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- /* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t - rw; x > rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or above, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for (x = t - rw; x > rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- rsize[0] = isz; // fill in our return sizes for edges + fill
- rsize[1] = osz;
- rsize[2] = gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
-static void do_adjacentBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
+static void do_adjacentBleedBorders(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize)
{
- int x;
- unsigned int isz = 0; // inner edge size
- unsigned int osz = 0; // outer edge size
- unsigned int gsz = 0; // gradient fill area size
- /* Test the four corners */
- /* upper left corner */
- x = t - rw + 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* upper right corner */
- x = t;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* lower left corner */
- x = 0;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel above, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty above or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* lower right corner */
- x = rw - 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel above, or to the left, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* Test the TOP row of pixels in buffer, except corners */
- for (x = t - 1; x >= (t - rw) + 2; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel to the left, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ int x;
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x = t - rw + 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] ||
+ !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* upper right corner */
+ x = t;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x - 1] && lomask[x - 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] ||
+ !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* lower left corner */
+ x = 0;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel above, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty above or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* lower right corner */
+ x = rw - 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel above, or to the left, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x + rw] && lomask[x + rw]) || (!limask[x - 1] && lomask[x - 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel to the left, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] ||
+ !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- /* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw - 2; x; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel to the left, or to the right, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
- /* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or above, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for (x = rw - 2; x; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel to the left, or to the right, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - 1] && lomask[x - 1]) || (!limask[x + 1] && lomask[x + 1])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] ||
+ !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- /* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t - rw; x > rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if pixel underneath, or above, are empty in the inner mask,
- // but filled in the outer mask
- if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for (x = t - rw; x > rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if pixel underneath, or above, are empty in the inner mask,
+ // but filled in the outer mask
+ if ((!limask[x - rw] && lomask[x - rw]) || (!limask[x + rw] && lomask[x + rw])) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- rsize[0] = isz; // fill in our return sizes for edges + fill
- rsize[1] = osz;
- rsize[2] = gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
-static void do_allKeepBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
+static void do_allKeepBorders(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize)
{
- int x;
- unsigned int isz = 0; // inner edge size
- unsigned int osz = 0; // outer edge size
- unsigned int gsz = 0; // gradient fill area size
- /* Test the four corners */
- /* upper left corner */
- x = t - rw + 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if the inner mask is empty underneath or to the right
- if (!limask[x - rw] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* upper right corner */
- x = t;
- // test if inner mask is filled
- if (limask[x]) {
- // test if the inner mask is empty underneath or to the left
- if (!limask[x - rw] || !limask[x - 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* lower left corner */
- x = 0;
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty above or to the right
- if (!limask[x + rw] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- /* lower right corner */
- x = rw - 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty above or to the left
- if (!limask[x + rw] || !limask[x - 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
+ int x;
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x = t - rw + 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if the inner mask is empty underneath or to the right
+ if (!limask[x - rw] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* upper right corner */
+ x = t;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if the inner mask is empty underneath or to the left
+ if (!limask[x - rw] || !limask[x - 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* lower left corner */
+ x = 0;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty above or to the right
+ if (!limask[x + rw] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ /* lower right corner */
+ x = rw - 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty above or to the left
+ if (!limask[x + rw] || !limask[x - 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
- /* Test the TOP row of pixels in buffer, except corners */
- for (x = t - 1; x >= (t - rw) + 2; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty to the left or to the right
- if (!limask[x - 1] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if (!limask[x - 1] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- /* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw - 2; x; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty to the left or to the right
- if (!limask[x - 1] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
- /* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty underneath or above
- if (!limask[x - rw] || !limask[x + rw]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for (x = rw - 2; x; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if (!limask[x - 1] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty underneath or above
+ if (!limask[x - rw] || !limask[x + rw]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- /* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t - rw; x > rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty underneath or above
- if (!limask[x - rw] || !limask[x + rw]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- }
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for (x = t - rw; x > rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty underneath or above
+ if (!limask[x - rw] || !limask[x + rw]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ }
- rsize[0] = isz; // fill in our return sizes for edges + fill
- rsize[1] = osz;
- rsize[2] = gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
-static void do_allBleedBorders(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize)
+static void do_allBleedBorders(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize)
{
- int x;
- unsigned int isz = 0; // inner edge size
- unsigned int osz = 0; // outer edge size
- unsigned int gsz = 0; // gradient fill area size
- /* Test the four corners */
- /* upper left corner */
- x = t - rw + 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if the inner mask is empty underneath or to the right
- if (!limask[x - rw] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* upper right corner */
- x = t;
- // test if inner mask is filled
- if (limask[x]) {
- // test if the inner mask is empty underneath or to the left
- if (!limask[x - rw] || !limask[x - 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* lower left corner */
- x = 0;
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty above or to the right
- if (!limask[x + rw] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x + rw] || !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* lower right corner */
- x = rw - 1;
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty above or to the left
- if (!limask[x + rw] || !limask[x - 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x + rw] || !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- /* Test the TOP row of pixels in buffer, except corners */
- for (x = t - 1; x >= (t - rw) + 2; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty to the left or to the right
- if (!limask[x - 1] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ int x;
+ unsigned int isz = 0; // inner edge size
+ unsigned int osz = 0; // outer edge size
+ unsigned int gsz = 0; // gradient fill area size
+ /* Test the four corners */
+ /* upper left corner */
+ x = t - rw + 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if the inner mask is empty underneath or to the right
+ if (!limask[x - rw] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] ||
+ !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* upper right corner */
+ x = t;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if the inner mask is empty underneath or to the left
+ if (!limask[x - rw] || !limask[x - 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x - 1]) { // test if outer mask is empty above or to the left
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* lower left corner */
+ x = 0;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty above or to the right
+ if (!limask[x + rw] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x + rw] ||
+ !lomask[x + 1]) { // test if outer mask is empty underneath or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* lower right corner */
+ x = rw - 1;
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty above or to the left
+ if (!limask[x + rw] || !limask[x - 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x + rw] ||
+ !lomask[x - 1]) { // test if outer mask is empty underneath or to the left
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ /* Test the TOP row of pixels in buffer, except corners */
+ for (x = t - 1; x >= (t - rw) + 2; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if (!limask[x - 1] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] ||
+ !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- /* Test the BOTTOM row of pixels in buffer, except corners */
- for (x = rw - 2; x; x--) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty to the left or to the right
- if (!limask[x - 1] || !limask[x + 1]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - 1] || !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
- /* Test the LEFT edge of pixels in buffer, except corners */
- for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty underneath or above
- if (!limask[x - rw] || !limask[x + rw]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ /* Test the BOTTOM row of pixels in buffer, except corners */
+ for (x = rw - 2; x; x--) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty to the left or to the right
+ if (!limask[x - 1] || !limask[x + 1]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - 1] ||
+ !lomask[x + 1]) { // test if outer mask is empty to the left or to the right
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
+ /* Test the LEFT edge of pixels in buffer, except corners */
+ for (x = t - (rw << 1) + 1; x >= rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty underneath or above
+ if (!limask[x - rw] || !limask[x + rw]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- /* Test the RIGHT edge of pixels in buffer, except corners */
- for (x = t - rw; x > rw; x -= rw) {
- // test if inner mask is filled
- if (limask[x]) {
- // test if inner mask is empty underneath or above
- if (!limask[x - rw] || !limask[x + rw]) {
- isz++; // increment inner edge size
- lres[x] = 4; // flag pixel as inner edge
- }
- else {
- res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
- }
- }
- else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
- if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
- osz++; // increment outer edge size
- lres[x] = 3; // flag pixel as outer edge
- }
- else {
- gsz++; // increment the gradient pixel count
- lres[x] = 2; // flag pixel as gradient
- }
- }
- }
+ /* Test the RIGHT edge of pixels in buffer, except corners */
+ for (x = t - rw; x > rw; x -= rw) {
+ // test if inner mask is filled
+ if (limask[x]) {
+ // test if inner mask is empty underneath or above
+ if (!limask[x - rw] || !limask[x + rw]) {
+ isz++; // increment inner edge size
+ lres[x] = 4; // flag pixel as inner edge
+ }
+ else {
+ res[x] = 1.0f; // pixel is just part of inner mask, and it's not an edge
+ }
+ }
+ else if (lomask[x]) { // inner mask was empty, test if outer mask is filled
+ if (!lomask[x - rw] || !lomask[x + rw]) { // test if outer mask is empty underneath or above
+ osz++; // increment outer edge size
+ lres[x] = 3; // flag pixel as outer edge
+ }
+ else {
+ gsz++; // increment the gradient pixel count
+ lres[x] = 2; // flag pixel as gradient
+ }
+ }
+ }
- rsize[0] = isz; // fill in our return sizes for edges + fill
- rsize[1] = osz;
- rsize[2] = gsz;
+ rsize[0] = isz; // fill in our return sizes for edges + fill
+ rsize[1] = osz;
+ rsize[2] = gsz;
}
-static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
+static void do_allEdgeDetection(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize,
+ unsigned int in_isz,
+ unsigned int in_osz,
+ unsigned int in_gsz)
{
- int x; // x = pixel loop counter
- int a; // a = pixel loop counter
- int dx; // dx = delta x
- int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
- int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
- int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
- int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
- /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
- for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
- a = x - 2;
- pix_prevRow = a + rw;
- pix_nextRow = a - rw;
- pix_prevCol = a + 1;
- pix_nextCol = a - 1;
- while (a > dx - 2) {
- if (!limask[a]) { // if the inner mask is empty
- if (lomask[a]) { // if the outer mask is full
- /*
- * Next we test all 4 directions around the current pixel: next/prev/up/down
- * The test ensures that the outer mask is empty and that the inner mask
- * is also empty. If both conditions are true for any one of the 4 adjacent pixels
- * then the current pixel is counted as being a true outer edge pixel.
- */
- if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
- (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
- (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
- (!lomask[pix_prevRow] && !limask[pix_prevRow]))
- {
- in_osz++; // increment the outer boundary pixel count
- lres[a] = 3; // flag pixel as part of outer edge
- }
- else { // it's not a boundary pixel, but it is a gradient pixel
- in_gsz++; // increment the gradient pixel count
- lres[a] = 2; // flag pixel as gradient
- }
- }
+ int x; // x = pixel loop counter
+ int a; // a = pixel loop counter
+ int dx; // dx = delta x
+ int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
+ int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
+ int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
+ int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
+ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
+ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
+ a = x - 2;
+ pix_prevRow = a + rw;
+ pix_nextRow = a - rw;
+ pix_prevCol = a + 1;
+ pix_nextCol = a - 1;
+ while (a > dx - 2) {
+ if (!limask[a]) { // if the inner mask is empty
+ if (lomask[a]) { // if the outer mask is full
+ /*
+ * Next we test all 4 directions around the current pixel: next/prev/up/down
+ * The test ensures that the outer mask is empty and that the inner mask
+ * is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ * then the current pixel is counted as being a true outer edge pixel.
+ */
+ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
+ (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
+ (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
+ (!lomask[pix_prevRow] && !limask[pix_prevRow])) {
+ in_osz++; // increment the outer boundary pixel count
+ lres[a] = 3; // flag pixel as part of outer edge
+ }
+ else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a] = 2; // flag pixel as gradient
+ }
+ }
+ }
+ else {
+ if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] ||
+ !limask[pix_prevRow]) {
+ in_isz++; // increment the inner boundary pixel count
+ lres[a] = 4; // flag pixel as part of inner edge
+ }
+ else {
+ res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
+ }
+ }
+ a--;
+ pix_prevRow--;
+ pix_nextRow--;
+ pix_prevCol--;
+ pix_nextCol--;
+ }
+ }
- }
- else {
- if (!limask[pix_nextCol] || !limask[pix_prevCol] || !limask[pix_nextRow] || !limask[pix_prevRow]) {
- in_isz++; // increment the inner boundary pixel count
- lres[a] = 4; // flag pixel as part of inner edge
- }
- else {
- res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
- }
- }
- a--;
- pix_prevRow--;
- pix_nextRow--;
- pix_prevCol--;
- pix_nextCol--;
- }
- }
-
- rsize[0] = in_isz; // fill in our return sizes for edges + fill
- rsize[1] = in_osz;
- rsize[2] = in_gsz;
+ rsize[0] = in_isz; // fill in our return sizes for edges + fill
+ rsize[1] = in_osz;
+ rsize[2] = in_gsz;
}
-static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned int *limask, unsigned int *lomask, unsigned int *lres, float *res, unsigned int *rsize, unsigned int in_isz, unsigned int in_osz, unsigned int in_gsz)
+static void do_adjacentEdgeDetection(unsigned int t,
+ unsigned int rw,
+ unsigned int *limask,
+ unsigned int *lomask,
+ unsigned int *lres,
+ float *res,
+ unsigned int *rsize,
+ unsigned int in_isz,
+ unsigned int in_osz,
+ unsigned int in_gsz)
{
- int x; // x = pixel loop counter
- int a; // a = pixel loop counter
- int dx; // dx = delta x
- int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
- int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
- int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
- int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
- /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
- for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
- a = x - 2;
- pix_prevRow = a + rw;
- pix_nextRow = a - rw;
- pix_prevCol = a + 1;
- pix_nextCol = a - 1;
- while (a > dx - 2) {
- if (!limask[a]) { // if the inner mask is empty
- if (lomask[a]) { // if the outer mask is full
- /*
- * Next we test all 4 directions around the current pixel: next/prev/up/down
- * The test ensures that the outer mask is empty and that the inner mask
- * is also empty. If both conditions are true for any one of the 4 adjacent pixels
- * then the current pixel is counted as being a true outer edge pixel.
- */
- if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
- (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
- (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
- (!lomask[pix_prevRow] && !limask[pix_prevRow]))
- {
- in_osz++; // increment the outer boundary pixel count
- lres[a] = 3; // flag pixel as part of outer edge
- }
- else { // it's not a boundary pixel, but it is a gradient pixel
- in_gsz++; // increment the gradient pixel count
- lres[a] = 2; // flag pixel as gradient
- }
- }
-
- }
- else {
- if ((!limask[pix_nextCol] && lomask[pix_nextCol]) ||
- (!limask[pix_prevCol] && lomask[pix_prevCol]) ||
- (!limask[pix_nextRow] && lomask[pix_nextRow]) ||
- (!limask[pix_prevRow] && lomask[pix_prevRow]))
- {
- in_isz++; // increment the inner boundary pixel count
- lres[a] = 4; // flag pixel as part of inner edge
- }
- else {
- res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
- }
- }
- a--;
- pix_prevRow--; // advance all four "surrounding" pixel pointers
- pix_nextRow--;
- pix_prevCol--;
- pix_nextCol--;
- }
- }
+ int x; // x = pixel loop counter
+ int a; // a = pixel loop counter
+ int dx; // dx = delta x
+ int pix_prevRow; // pix_prevRow = pixel one row behind the one we are testing in a loop
+ int pix_nextRow; // pix_nextRow = pixel one row in front of the one we are testing in a loop
+ int pix_prevCol; // pix_prevCol = pixel one column behind the one we are testing in a loop
+ int pix_nextCol; // pix_nextCol = pixel one column in front of the one we are testing in a loop
+ /* Test all rows between the FIRST and LAST rows, excluding left and right edges */
+ for (x = (t - rw) + 1, dx = x - (rw - 2); dx > rw; x -= rw, dx -= rw) {
+ a = x - 2;
+ pix_prevRow = a + rw;
+ pix_nextRow = a - rw;
+ pix_prevCol = a + 1;
+ pix_nextCol = a - 1;
+ while (a > dx - 2) {
+ if (!limask[a]) { // if the inner mask is empty
+ if (lomask[a]) { // if the outer mask is full
+ /*
+ * Next we test all 4 directions around the current pixel: next/prev/up/down
+ * The test ensures that the outer mask is empty and that the inner mask
+ * is also empty. If both conditions are true for any one of the 4 adjacent pixels
+ * then the current pixel is counted as being a true outer edge pixel.
+ */
+ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) ||
+ (!lomask[pix_prevCol] && !limask[pix_prevCol]) ||
+ (!lomask[pix_nextRow] && !limask[pix_nextRow]) ||
+ (!lomask[pix_prevRow] && !limask[pix_prevRow])) {
+ in_osz++; // increment the outer boundary pixel count
+ lres[a] = 3; // flag pixel as part of outer edge
+ }
+ else { // it's not a boundary pixel, but it is a gradient pixel
+ in_gsz++; // increment the gradient pixel count
+ lres[a] = 2; // flag pixel as gradient
+ }
+ }
+ }
+ else {
+ if ((!limask[pix_nextCol] && lomask[pix_nextCol]) ||
+ (!limask[pix_prevCol] && lomask[pix_prevCol]) ||
+ (!limask[pix_nextRow] && lomask[pix_nextRow]) ||
+ (!limask[pix_prevRow] && lomask[pix_prevRow])) {
+ in_isz++; // increment the inner boundary pixel count
+ lres[a] = 4; // flag pixel as part of inner edge
+ }
+ else {
+ res[a] = 1.0f; // pixel is part of inner mask, but not at an edge
+ }
+ }
+ a--;
+ pix_prevRow--; // advance all four "surrounding" pixel pointers
+ pix_nextRow--;
+ pix_prevCol--;
+ pix_nextCol--;
+ }
+ }
- rsize[0] = in_isz; // fill in our return sizes for edges + fill
- rsize[1] = in_osz;
- rsize[2] = in_gsz;
+ rsize[0] = in_isz; // fill in our return sizes for edges + fill
+ rsize[1] = in_osz;
+ rsize[2] = in_gsz;
}
-static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigned int *lres, float *res, unsigned short *gbuf, unsigned int *innerEdgeOffset, unsigned int *outerEdgeOffset, unsigned int isz, unsigned int gsz)
+static void do_createEdgeLocationBuffer(unsigned int t,
+ unsigned int rw,
+ unsigned int *lres,
+ float *res,
+ unsigned short *gbuf,
+ unsigned int *innerEdgeOffset,
+ unsigned int *outerEdgeOffset,
+ unsigned int isz,
+ unsigned int gsz)
{
- int x; // x = pixel loop counter
- int a; // a = temporary pixel index buffer loop counter
- unsigned int ud; // ud = unscaled edge distance
- unsigned int dmin; // dmin = minimum edge distance
-
- unsigned int rsl; // long used for finding fast 1.0/sqrt
- unsigned int gradientFillOffset;
- unsigned int innerAccum = 0; // for looping inner edge pixel indexes, represents current position from offset
- unsigned int outerAccum = 0; // for looping outer edge pixel indexes, represents current position from offset
- unsigned int gradientAccum = 0; // for looping gradient pixel indexes, represents current position from offset
- /*
- * Here we compute the size of buffer needed to hold (row,col) coordinates
- * for each pixel previously determined to be either gradient, inner edge,
- * or outer edge.
- *
- * Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even
- * though gbuf[] is declared as (unsigned short *) (2 bytes) because we don't
- * store the pixel indexes, we only store x,y location of pixel in buffer.
- *
- * This does make the assumption that x and y can fit in 16 unsigned bits
- * so if Blender starts doing renders greater than 65536 in either direction
- * this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes
- * per flagged pixel.
- *
- * In general, the buffer on-screen:
- *
- * Example: 9 by 9 pixel block
- *
- * . = pixel non-white in both outer and inner mask
- * o = pixel white in outer, but not inner mask, adjacent to "." pixel
- * g = pixel white in outer, but not inner mask, not adjacent to "." pixel
- * i = pixel white in inner mask, adjacent to "g" or "." pixel
- * F = pixel white in inner mask, only adjacent to other pixels white in the inner mask
- *
- *
- * ......... <----- pixel #80
- * ..oooo...
- * .oggggo..
- * .oggiggo.
- * .ogiFigo.
- * .oggiggo.
- * .oggggo..
- * ..oooo...
- * pixel #00 -----> .........
- *
- * gsz = 18 (18 "g" pixels above)
- * isz = 4 (4 "i" pixels above)
- * osz = 18 (18 "o" pixels above)
- *
- *
- * The memory in gbuf[] after filling will look like this:
- *
- * gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels)
- * / / /
- * / / /
- * |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y)
- * +--------------------------------> <----------------> <------------------------> <----------------+
- * |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes
- * +--------------------------------> <----------------> <------------------------> <----------------+
- * |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel
- * / / /
- * / / /
- * / / /
- * +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+
- *
- *
- * Ultimately we do need the pixel's memory buffer index to set the output
- * pixel color, but it's faster to reconstruct the memory buffer location
- * each iteration of the final gradient calculation than it is to deconstruct
- * a memory location into x,y pairs each round.
- */
+ int x; // x = pixel loop counter
+ int a; // a = temporary pixel index buffer loop counter
+ unsigned int ud; // ud = unscaled edge distance
+ unsigned int dmin; // dmin = minimum edge distance
+ unsigned int rsl; // long used for finding fast 1.0/sqrt
+ unsigned int gradientFillOffset;
+ unsigned int innerAccum =
+ 0; // for looping inner edge pixel indexes, represents current position from offset
+ unsigned int outerAccum =
+ 0; // for looping outer edge pixel indexes, represents current position from offset
+ unsigned int gradientAccum =
+ 0; // for looping gradient pixel indexes, represents current position from offset
+ /*
+ * Here we compute the size of buffer needed to hold (row,col) coordinates
+ * for each pixel previously determined to be either gradient, inner edge,
+ * or outer edge.
+ *
+ * Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even
+ * though gbuf[] is declared as (unsigned short *) (2 bytes) because we don't
+ * store the pixel indexes, we only store x,y location of pixel in buffer.
+ *
+ * This does make the assumption that x and y can fit in 16 unsigned bits
+ * so if Blender starts doing renders greater than 65536 in either direction
+ * this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes
+ * per flagged pixel.
+ *
+ * In general, the buffer on-screen:
+ *
+ * Example: 9 by 9 pixel block
+ *
+ * . = pixel non-white in both outer and inner mask
+ * o = pixel white in outer, but not inner mask, adjacent to "." pixel
+ * g = pixel white in outer, but not inner mask, not adjacent to "." pixel
+ * i = pixel white in inner mask, adjacent to "g" or "." pixel
+ * F = pixel white in inner mask, only adjacent to other pixels white in the inner mask
+ *
+ *
+ * ......... <----- pixel #80
+ * ..oooo...
+ * .oggggo..
+ * .oggiggo.
+ * .ogiFigo.
+ * .oggiggo.
+ * .oggggo..
+ * ..oooo...
+ * pixel #00 -----> .........
+ *
+ * gsz = 18 (18 "g" pixels above)
+ * isz = 4 (4 "i" pixels above)
+ * osz = 18 (18 "o" pixels above)
+ *
+ *
+ * The memory in gbuf[] after filling will look like this:
+ *
+ * gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels)
+ * / / /
+ * / / /
+ * |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y)
+ * +--------------------------------> <----------------> <------------------------> <----------------+
+ * |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes
+ * +--------------------------------> <----------------> <------------------------> <----------------+
+ * |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel
+ * / / /
+ * / / /
+ * / / /
+ * +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+
+ *
+ *
+ * Ultimately we do need the pixel's memory buffer index to set the output
+ * pixel color, but it's faster to reconstruct the memory buffer location
+ * each iteration of the final gradient calculation than it is to deconstruct
+ * a memory location into x,y pairs each round.
+ */
- gradientFillOffset = 0; // since there are likely "more" of these, put it first. :)
- *innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes
- *outerEdgeOffset = (*innerEdgeOffset) + isz; // set start of outer edge indexes
- /* set the accumulators to correct positions */ // set up some accumulator variables for loops
- gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
- innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
- outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
- //uses dmin=row, rsl=col
- for (x = 0, dmin = 0; x < t; x += rw, dmin++) {
- for (rsl = 0; rsl < rw; rsl++) {
- a = x + rsl;
- if (lres[a] == 2) { // it is a gradient pixel flagged by 2
- ud = gradientAccum << 1; // double the index to reach correct unsigned short location
- gbuf[ud] = dmin; // insert pixel's row into gradient pixel location buffer
- gbuf[ud + 1] = rsl; // insert pixel's column into gradient pixel location buffer
- gradientAccum++; // increment gradient index buffer pointer
- }
- else if (lres[a] == 3) { // it is an outer edge pixel flagged by 3
- ud = outerAccum << 1; // double the index to reach correct unsigned short location
- gbuf[ud] = dmin; // insert pixel's row into outer edge pixel location buffer
- gbuf[ud + 1] = rsl; // insert pixel's column into outer edge pixel location buffer
- outerAccum++; // increment outer edge index buffer pointer
- res[a] = 0.0f; // set output pixel intensity now since it won't change later
- }
- else if (lres[a] == 4) { // it is an inner edge pixel flagged by 4
- ud = innerAccum << 1; // double int index to reach correct unsigned short location
- gbuf[ud] = dmin; // insert pixel's row into inner edge pixel location buffer
- gbuf[ud + 1] = rsl; // insert pixel's column into inner edge pixel location buffer
- innerAccum++; // increment inner edge index buffer pointer
- res[a] = 1.0f; // set output pixel intensity now since it won't change later
- }
- }
- }
-
+ gradientFillOffset = 0; // since there are likely "more" of these, put it first. :)
+ *innerEdgeOffset = gradientFillOffset + gsz; // set start of inner edge indexes
+ *outerEdgeOffset = (*innerEdgeOffset) + isz; // set start of outer edge indexes
+ /* set the accumulators to correct positions */ // set up some accumulator variables for loops
+ gradientAccum = gradientFillOffset; // each accumulator variable starts at its respective
+ innerAccum = *innerEdgeOffset; // section's offset so when we start filling, each
+ outerAccum = *outerEdgeOffset; // section fills up it's allocated space in gbuf
+ //uses dmin=row, rsl=col
+ for (x = 0, dmin = 0; x < t; x += rw, dmin++) {
+ for (rsl = 0; rsl < rw; rsl++) {
+ a = x + rsl;
+ if (lres[a] == 2) { // it is a gradient pixel flagged by 2
+ ud = gradientAccum << 1; // double the index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into gradient pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into gradient pixel location buffer
+ gradientAccum++; // increment gradient index buffer pointer
+ }
+ else if (lres[a] == 3) { // it is an outer edge pixel flagged by 3
+ ud = outerAccum << 1; // double the index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into outer edge pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into outer edge pixel location buffer
+ outerAccum++; // increment outer edge index buffer pointer
+ res[a] = 0.0f; // set output pixel intensity now since it won't change later
+ }
+ else if (lres[a] == 4) { // it is an inner edge pixel flagged by 4
+ ud = innerAccum << 1; // double int index to reach correct unsigned short location
+ gbuf[ud] = dmin; // insert pixel's row into inner edge pixel location buffer
+ gbuf[ud + 1] = rsl; // insert pixel's column into inner edge pixel location buffer
+ innerAccum++; // increment inner edge index buffer pointer
+ res[a] = 1.0f; // set output pixel intensity now since it won't change later
+ }
+ }
+ }
}
-static void do_fillGradientBuffer(unsigned int rw, float *res, unsigned short *gbuf, unsigned int isz, unsigned int osz, unsigned int gsz, unsigned int innerEdgeOffset, unsigned int outerEdgeOffset)
+static void do_fillGradientBuffer(unsigned int rw,
+ float *res,
+ unsigned short *gbuf,
+ unsigned int isz,
+ unsigned int osz,
+ unsigned int gsz,
+ unsigned int innerEdgeOffset,
+ unsigned int outerEdgeOffset)
{
- int x; // x = pixel loop counter
- int a; // a = temporary pixel index buffer loop counter
- int fsz; // size of the frame
- unsigned int rsl; // long used for finding fast 1.0/sqrt
- float rsf; // float used for finding fast 1.0/sqrt
- const float rsopf = 1.5f; // constant float used for finding fast 1.0/sqrt
-
- unsigned int gradientFillOffset;
- unsigned int t;
- unsigned int ud; // ud = unscaled edge distance
- unsigned int dmin; // dmin = minimum edge distance
- float odist; // odist = current outer edge distance
- float idist; // idist = current inner edge distance
- int dx; // dx = X-delta (used for distance proportion calculation)
- int dy; // dy = Y-delta (used for distance proportion calculation)
+ int x; // x = pixel loop counter
+ int a; // a = temporary pixel index buffer loop counter
+ int fsz; // size of the frame
+ unsigned int rsl; // long used for finding fast 1.0/sqrt
+ float rsf; // float used for finding fast 1.0/sqrt
+ const float rsopf = 1.5f; // constant float used for finding fast 1.0/sqrt
- /*
- * The general algorithm used to color each gradient pixel is:
- *
- * 1.) Loop through all gradient pixels.
- * A.) For each gradient pixel:
- * a.) Loop though all outside edge pixels, looking for closest one
- * to the gradient pixel we are in.
- * b.) Loop through all inside edge pixels, looking for closest one
- * to the gradient pixel we are in.
- * c.) Find proportion of distance from gradient pixel to inside edge
- * pixel compared to sum of distance to inside edge and distance to
- * outside edge.
- *
- * In an image where:
- * . = blank (black) pixels, not covered by inner mask or outer mask
- * + = desired gradient pixels, covered only by outer mask
- * * = white full mask pixels, covered by at least inner mask
- *
- * ...............................
- * ...............+++++++++++.....
- * ...+O++++++..++++++++++++++....
- * ..+++\++++++++++++++++++++.....
- * .+++++G+++++++++*******+++.....
- * .+++++|+++++++*********+++.....
- * .++***I****************+++.....
- * .++*******************+++......
- * .+++*****************+++.......
- * ..+++***************+++........
- * ....+++**********+++...........
- * ......++++++++++++.............
- * ...............................
- *
- * O = outside edge pixel
- * \
- * G = gradient pixel
- * |
- * I = inside edge pixel
- *
- * __
- * *note that IO does not need to be a straight line, in fact
- * many cases can arise where straight lines do not work
- * correctly.
- *
- * __ __ __
- * d.) Pixel color is assigned as |GO| / ( |GI| + |GO| )
- *
- * The implementation does not compute distance, but the reciprocal of the
- * distance. This is done to avoid having to compute a square root, as a
- * reciprocal square root can be computed faster. Therefore, the code computes
- * pixel color as |GI| / (|GI| + |GO|). Since these are reciprocals, GI serves the
- * purpose of GO for the proportion calculation.
- *
- * For the purposes of the minimum distance comparisons, we only check
- * the sums-of-squares against eachother, since they are in the same
- * mathematical sort-order as if we did go ahead and take square roots
- *
- * Loop through all gradient pixels.
- */
+ unsigned int gradientFillOffset;
+ unsigned int t;
+ unsigned int ud; // ud = unscaled edge distance
+ unsigned int dmin; // dmin = minimum edge distance
+ float odist; // odist = current outer edge distance
+ float idist; // idist = current inner edge distance
+ int dx; // dx = X-delta (used for distance proportion calculation)
+ int dy; // dy = Y-delta (used for distance proportion calculation)
- for (x = gsz - 1; x >= 0; x--) {
- gradientFillOffset = x << 1;
- t = gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x]
- fsz = gbuf[gradientFillOffset + 1]; // calculate row of pixel indexed by gbuf[x]
- dmin = 0xffffffff; // reset min distance to edge pixel
- for (a = outerEdgeOffset + osz - 1; a >= outerEdgeOffset; a--) { // loop through all outer edge buffer pixels
- ud = a << 1;
- dy = t - gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row
- dx = fsz - gbuf[ud + 1]; // set dy to gradient pixel row - outer edge pixel column
- ud = dx * dx + dy * dy; // compute sum of squares
- if (ud < dmin) { // if our new sum of squares is less than the current minimum
- dmin = ud; // set a new minimum equal to the new lower value
- }
- }
- odist = (float)(dmin); // cast outer min to a float
- rsf = odist * 0.5f; //
- rsl = *(unsigned int *)&odist; // use some peculiar properties of the way bits are stored
- rsl = 0x5f3759df - (rsl >> 1); // in floats vs. unsigned ints to compute an approximate
- odist = *(float *)&rsl; // reciprocal square root
- odist = odist * (rsopf - (rsf * odist * odist)); // -- ** this line can be iterated for more accuracy ** --
- dmin = 0xffffffff; // reset min distance to edge pixel
- for (a = innerEdgeOffset + isz - 1; a >= innerEdgeOffset; a--) { // loop through all inside edge pixels
- ud = a << 1;
- dy = t - gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel
- dx = fsz - gbuf[ud + 1]; // compute delta in X from gradient pixel to inside edge pixel
- ud = dx * dx + dy * dy; // compute sum of squares
- if (ud < dmin) { // if our new sum of squares is less than the current minimum we've found
- dmin = ud; // set a new minimum equal to the new lower value
- }
- }
- idist = (float)(dmin); // cast inner min to a float
- rsf = idist * 0.5f; //
- rsl = *(unsigned int *)&idist; //
- rsl = 0x5f3759df - (rsl >> 1); // see notes above
- idist = *(float *)&rsl; //
- idist = idist * (rsopf - (rsf * idist * idist)); //
- /*
- * Note once again that since we are using reciprocals of distance values our
- * proportion is already the correct intensity, and does not need to be
- * subtracted from 1.0 like it would have if we used real distances.
- */
+ /*
+ * The general algorithm used to color each gradient pixel is:
+ *
+ * 1.) Loop through all gradient pixels.
+ * A.) For each gradient pixel:
+ * a.) Loop though all outside edge pixels, looking for closest one
+ * to the gradient pixel we are in.
+ * b.) Loop through all inside edge pixels, looking for closest one
+ * to the gradient pixel we are in.
+ * c.) Find proportion of distance from gradient pixel to inside edge
+ * pixel compared to sum of distance to inside edge and distance to
+ * outside edge.
+ *
+ * In an image where:
+ * . = blank (black) pixels, not covered by inner mask or outer mask
+ * + = desired gradient pixels, covered only by outer mask
+ * * = white full mask pixels, covered by at least inner mask
+ *
+ * ...............................
+ * ...............+++++++++++.....
+ * ...+O++++++..++++++++++++++....
+ * ..+++\++++++++++++++++++++.....
+ * .+++++G+++++++++*******+++.....
+ * .+++++|+++++++*********+++.....
+ * .++***I****************+++.....
+ * .++*******************+++......
+ * .+++*****************+++.......
+ * ..+++***************+++........
+ * ....+++**********+++...........
+ * ......++++++++++++.............
+ * ...............................
+ *
+ * O = outside edge pixel
+ * \
+ * G = gradient pixel
+ * |
+ * I = inside edge pixel
+ *
+ * __
+ * *note that IO does not need to be a straight line, in fact
+ * many cases can arise where straight lines do not work
+ * correctly.
+ *
+ * __ __ __
+ * d.) Pixel color is assigned as |GO| / ( |GI| + |GO| )
+ *
+ * The implementation does not compute distance, but the reciprocal of the
+ * distance. This is done to avoid having to compute a square root, as a
+ * reciprocal square root can be computed faster. Therefore, the code computes
+ * pixel color as |GI| / (|GI| + |GO|). Since these are reciprocals, GI serves the
+ * purpose of GO for the proportion calculation.
+ *
+ * For the purposes of the minimum distance comparisons, we only check
+ * the sums-of-squares against eachother, since they are in the same
+ * mathematical sort-order as if we did go ahead and take square roots
+ *
+ * Loop through all gradient pixels.
+ */
- /*
- * Here we reconstruct the pixel's memory location in the CompBuf by
- * Pixel Index = Pixel Column + ( Pixel Row * Row Width )
- */
- res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] = (idist / (idist + odist)); //set intensity
- }
+ for (x = gsz - 1; x >= 0; x--) {
+ gradientFillOffset = x << 1;
+ t = gbuf[gradientFillOffset]; // calculate column of pixel indexed by gbuf[x]
+ fsz = gbuf[gradientFillOffset + 1]; // calculate row of pixel indexed by gbuf[x]
+ dmin = 0xffffffff; // reset min distance to edge pixel
+ for (a = outerEdgeOffset + osz - 1; a >= outerEdgeOffset;
+ a--) { // loop through all outer edge buffer pixels
+ ud = a << 1;
+ dy = t - gbuf[ud]; // set dx to gradient pixel column - outer edge pixel row
+ dx = fsz - gbuf[ud + 1]; // set dy to gradient pixel row - outer edge pixel column
+ ud = dx * dx + dy * dy; // compute sum of squares
+ if (ud < dmin) { // if our new sum of squares is less than the current minimum
+ dmin = ud; // set a new minimum equal to the new lower value
+ }
+ }
+ odist = (float)(dmin); // cast outer min to a float
+ rsf = odist * 0.5f; //
+ rsl = *(unsigned int *)&odist; // use some peculiar properties of the way bits are stored
+ rsl = 0x5f3759df - (rsl >> 1); // in floats vs. unsigned ints to compute an approximate
+ odist = *(float *)&rsl; // reciprocal square root
+ odist = odist * (rsopf - (rsf * odist *
+ odist)); // -- ** this line can be iterated for more accuracy ** --
+ dmin = 0xffffffff; // reset min distance to edge pixel
+ for (a = innerEdgeOffset + isz - 1; a >= innerEdgeOffset;
+ a--) { // loop through all inside edge pixels
+ ud = a << 1;
+ dy = t - gbuf[ud]; // compute delta in Y from gradient pixel to inside edge pixel
+ dx = fsz - gbuf[ud + 1]; // compute delta in X from gradient pixel to inside edge pixel
+ ud = dx * dx + dy * dy; // compute sum of squares
+ if (ud < dmin) { // if our new sum of squares is less than the current minimum we've found
+ dmin = ud; // set a new minimum equal to the new lower value
+ }
+ }
+ idist = (float)(dmin); // cast inner min to a float
+ rsf = idist * 0.5f; //
+ rsl = *(unsigned int *)&idist; //
+ rsl = 0x5f3759df - (rsl >> 1); // see notes above
+ idist = *(float *)&rsl; //
+ idist = idist * (rsopf - (rsf * idist * idist)); //
+ /*
+ * Note once again that since we are using reciprocals of distance values our
+ * proportion is already the correct intensity, and does not need to be
+ * subtracted from 1.0 like it would have if we used real distances.
+ */
+ /*
+ * Here we reconstruct the pixel's memory location in the CompBuf by
+ * Pixel Index = Pixel Column + ( Pixel Row * Row Width )
+ */
+ res[gbuf[gradientFillOffset + 1] + (gbuf[gradientFillOffset] * rw)] =
+ (idist / (idist + odist)); //set intensity
+ }
}
// end of copy
void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float *res)
{
- unsigned int *lres; // lres = unsigned int pointer to output pixel buffer (for bit operations)
- unsigned int *limask; // limask = unsigned int pointer to inner mask (for bit operations)
- unsigned int *lomask; // lomask = unsigned int pointer to outer mask (for bit operations)
-
- int rw; // rw = pixel row width
- int t; // t = total number of pixels in buffer - 1 (used for loop starts)
- int fsz; // size of the frame
+ unsigned int *lres; // lres = unsigned int pointer to output pixel buffer (for bit operations)
+ unsigned int *limask; // limask = unsigned int pointer to inner mask (for bit operations)
+ unsigned int *lomask; // lomask = unsigned int pointer to outer mask (for bit operations)
- unsigned int isz = 0; // size (in pixels) of inside edge pixel index buffer
- unsigned int osz = 0; // size (in pixels) of outside edge pixel index buffer
- unsigned int gsz = 0; // size (in pixels) of gradient pixel index buffer
- unsigned int rsize[3]; // size storage to pass to helper functions
- unsigned int innerEdgeOffset = 0; // offset into final buffer where inner edge pixel indexes start
- unsigned int outerEdgeOffset = 0; // offset into final buffer where outer edge pixel indexes start
+ int rw; // rw = pixel row width
+ int t; // t = total number of pixels in buffer - 1 (used for loop starts)
+ int fsz; // size of the frame
- unsigned short *gbuf; // gradient/inner/outer pixel location index buffer
+ unsigned int isz = 0; // size (in pixels) of inside edge pixel index buffer
+ unsigned int osz = 0; // size (in pixels) of outside edge pixel index buffer
+ unsigned int gsz = 0; // size (in pixels) of gradient pixel index buffer
+ unsigned int rsize[3]; // size storage to pass to helper functions
+ unsigned int innerEdgeOffset =
+ 0; // offset into final buffer where inner edge pixel indexes start
+ unsigned int outerEdgeOffset =
+ 0; // offset into final buffer where outer edge pixel indexes start
- if (true) { // if both input sockets have some data coming in...
+ unsigned short *gbuf; // gradient/inner/outer pixel location index buffer
- rw = this->getWidth(); // width of a row of pixels
- t = (rw * this->getHeight()) - 1; // determine size of the frame
- memset(res, 0, sizeof(float) * (t + 1)); // clear output buffer (not all pixels will be written later)
+ if (true) { // if both input sockets have some data coming in...
- lres = (unsigned int *)res; // unsigned int pointer to output buffer (for bit level ops)
- limask = (unsigned int *)imask; // unsigned int pointer to input mask (for bit level ops)
- lomask = (unsigned int *)omask; // unsigned int pointer to output mask (for bit level ops)
+ rw = this->getWidth(); // width of a row of pixels
+ t = (rw * this->getHeight()) - 1; // determine size of the frame
+ memset(res,
+ 0,
+ sizeof(float) * (t + 1)); // clear output buffer (not all pixels will be written later)
+ lres = (unsigned int *)res; // unsigned int pointer to output buffer (for bit level ops)
+ limask = (unsigned int *)imask; // unsigned int pointer to input mask (for bit level ops)
+ lomask = (unsigned int *)omask; // unsigned int pointer to output mask (for bit level ops)
- /*
- * The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the
- * LEFT and RIGHT edges (excluding the corner pixels), and all OTHER rows.
- * This allows for quick computation of outer edge pixels where
- * a screen edge pixel is marked to be gradient.
- *
- * The pixel type (gradient vs inner-edge vs outer-edge) tests change
- * depending on the user selected "Inner Edge Mode" and the user selected
- * "Buffer Edge Mode" on the node's GUI. There are 4 sets of basically the
- * same algorithm:
- *
- * 1.) Inner Edge -> Adjacent Only
- * Buffer Edge -> Keep Inside
- *
- * 2.) Inner Edge -> Adjacent Only
- * Buffer Edge -> Bleed Out
- *
- * 3.) Inner Edge -> All
- * Buffer Edge -> Keep Inside
- *
- * 4.) Inner Edge -> All
- * Buffer Edge -> Bleed Out
- *
- * Each version has slightly different criteria for detecting an edge pixel.
- */
- if (this->m_adjecentOnly) { // if "adjacent only" inner edge mode is turned on
- if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on
- do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize);
- }
- else { // "bleed out" buffer edge mode is turned on
- do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize);
- }
- // set up inner edge, outer edge, and gradient buffer sizes after border pass
- isz = rsize[0];
- osz = rsize[1];
- gsz = rsize[2];
- // detect edges in all non-border pixels in the buffer
- do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
- }
- else { // "all" inner edge mode is turned on
- if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on
- do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize);
- }
- else { // "bleed out" buffer edge mode is turned on
- do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize);
- }
- // set up inner edge, outer edge, and gradient buffer sizes after border pass
- isz = rsize[0];
- osz = rsize[1];
- gsz = rsize[2];
- // detect edges in all non-border pixels in the buffer
- do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
- }
+ /*
+ * The whole buffer is broken up into 4 parts. The four CORNERS, the FIRST and LAST rows, the
+ * LEFT and RIGHT edges (excluding the corner pixels), and all OTHER rows.
+ * This allows for quick computation of outer edge pixels where
+ * a screen edge pixel is marked to be gradient.
+ *
+ * The pixel type (gradient vs inner-edge vs outer-edge) tests change
+ * depending on the user selected "Inner Edge Mode" and the user selected
+ * "Buffer Edge Mode" on the node's GUI. There are 4 sets of basically the
+ * same algorithm:
+ *
+ * 1.) Inner Edge -> Adjacent Only
+ * Buffer Edge -> Keep Inside
+ *
+ * 2.) Inner Edge -> Adjacent Only
+ * Buffer Edge -> Bleed Out
+ *
+ * 3.) Inner Edge -> All
+ * Buffer Edge -> Keep Inside
+ *
+ * 4.) Inner Edge -> All
+ * Buffer Edge -> Bleed Out
+ *
+ * Each version has slightly different criteria for detecting an edge pixel.
+ */
+ if (this->m_adjecentOnly) { // if "adjacent only" inner edge mode is turned on
+ if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_adjacentKeepBorders(t, rw, limask, lomask, lres, res, rsize);
+ }
+ else { // "bleed out" buffer edge mode is turned on
+ do_adjacentBleedBorders(t, rw, limask, lomask, lres, res, rsize);
+ }
+ // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ isz = rsize[0];
+ osz = rsize[1];
+ gsz = rsize[2];
+ // detect edges in all non-border pixels in the buffer
+ do_adjacentEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
+ }
+ else { // "all" inner edge mode is turned on
+ if (this->m_keepInside) { // if "keep inside" buffer edge mode is turned on
+ do_allKeepBorders(t, rw, limask, lomask, lres, res, rsize);
+ }
+ else { // "bleed out" buffer edge mode is turned on
+ do_allBleedBorders(t, rw, limask, lomask, lres, res, rsize);
+ }
+ // set up inner edge, outer edge, and gradient buffer sizes after border pass
+ isz = rsize[0];
+ osz = rsize[1];
+ gsz = rsize[2];
+ // detect edges in all non-border pixels in the buffer
+ do_allEdgeDetection(t, rw, limask, lomask, lres, res, rsize, isz, osz, gsz);
+ }
- // set edge and gradient buffer sizes once again...
- // the sizes in rsize[] may have been modified
- // by the do_*EdgeDetection() function.
- isz = rsize[0];
- osz = rsize[1];
- gsz = rsize[2];
+ // set edge and gradient buffer sizes once again...
+ // the sizes in rsize[] may have been modified
+ // by the do_*EdgeDetection() function.
+ isz = rsize[0];
+ osz = rsize[1];
+ gsz = rsize[2];
- // calculate size of pixel index buffer needed
- fsz = gsz + isz + osz;
- // allocate edge/gradient pixel index buffer
- gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM");
+ // calculate size of pixel index buffer needed
+ fsz = gsz + isz + osz;
+ // allocate edge/gradient pixel index buffer
+ gbuf = (unsigned short *)MEM_callocN(sizeof(unsigned short) * fsz * 2, "DEM");
- do_createEdgeLocationBuffer(t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz);
- do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset);
+ do_createEdgeLocationBuffer(
+ t, rw, lres, res, gbuf, &innerEdgeOffset, &outerEdgeOffset, isz, gsz);
+ do_fillGradientBuffer(rw, res, gbuf, isz, osz, gsz, innerEdgeOffset, outerEdgeOffset);
- // free the gradient index buffer
- MEM_freeN(gbuf);
- }
+ // free the gradient index buffer
+ MEM_freeN(gbuf);
+ }
}
DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputInnerMask = NULL;
- this->m_inputOuterMask = NULL;
- this->m_adjecentOnly = false;
- this->m_keepInside = false;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputInnerMask = NULL;
+ this->m_inputOuterMask = NULL;
+ this->m_adjecentOnly = false;
+ this->m_keepInside = false;
+ this->setComplex(true);
}
-bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- if (this->m_cachedInstance == NULL) {
- rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
- else {
- return false;
- }
+ if (this->m_cachedInstance == NULL) {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+ else {
+ return false;
+ }
}
void DoubleEdgeMaskOperation::initExecution()
{
- this->m_inputInnerMask = this->getInputSocketReader(0);
- this->m_inputOuterMask = this->getInputSocketReader(1);
- initMutex();
- this->m_cachedInstance = NULL;
+ this->m_inputInnerMask = this->getInputSocketReader(0);
+ this->m_inputOuterMask = this->getInputSocketReader(1);
+ initMutex();
+ this->m_cachedInstance = NULL;
}
void *DoubleEdgeMaskOperation::initializeTileData(rcti *rect)
{
- if (this->m_cachedInstance)
- return this->m_cachedInstance;
+ if (this->m_cachedInstance)
+ return this->m_cachedInstance;
- lockMutex();
- if (this->m_cachedInstance == NULL) {
- MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect);
- MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect);
- float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(), __func__);
- float *imask = innerMask->getBuffer();
- float *omask = outerMask->getBuffer();
- doDoubleEdgeMask(imask, omask, data);
- this->m_cachedInstance = data;
- }
- unlockMutex();
- return this->m_cachedInstance;
+ lockMutex();
+ if (this->m_cachedInstance == NULL) {
+ MemoryBuffer *innerMask = (MemoryBuffer *)this->m_inputInnerMask->initializeTileData(rect);
+ MemoryBuffer *outerMask = (MemoryBuffer *)this->m_inputOuterMask->initializeTileData(rect);
+ float *data = (float *)MEM_mallocN(sizeof(float) * this->getWidth() * this->getHeight(),
+ __func__);
+ float *imask = innerMask->getBuffer();
+ float *omask = outerMask->getBuffer();
+ doDoubleEdgeMask(imask, omask, data);
+ this->m_cachedInstance = data;
+ }
+ unlockMutex();
+ return this->m_cachedInstance;
}
void DoubleEdgeMaskOperation::executePixel(float output[4], int x, int y, void *data)
{
- float *buffer = (float *)data;
- int index = (y * this->getWidth() + x);
- output[0] = buffer[index];
+ float *buffer = (float *)data;
+ int index = (y * this->getWidth() + x);
+ output[0] = buffer[index];
}
void DoubleEdgeMaskOperation::deinitExecution()
{
- this->m_inputInnerMask = NULL;
- this->m_inputOuterMask = NULL;
- deinitMutex();
- if (this->m_cachedInstance) {
- MEM_freeN(this->m_cachedInstance);
- this->m_cachedInstance = NULL;
- }
+ this->m_inputInnerMask = NULL;
+ this->m_inputOuterMask = NULL;
+ deinitMutex();
+ if (this->m_cachedInstance) {
+ MEM_freeN(this->m_cachedInstance);
+ this->m_cachedInstance = NULL;
+ }
}
diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
index 2bb3761805b..40cfa370cb7 100644
--- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
+++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.h
@@ -20,41 +20,49 @@
#define __COM_DOUBLEEDGEMASKOPERATION_H__
#include "COM_NodeOperation.h"
-
class DoubleEdgeMaskOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputOuterMask;
- SocketReader *m_inputInnerMask;
- bool m_adjecentOnly;
- bool m_keepInside;
- float *m_cachedInstance;
-public:
- DoubleEdgeMaskOperation();
-
- void doDoubleEdgeMask(float *inner, float *outer, float *res);
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void setAdjecentOnly(bool adjecentOnly) { this->m_adjecentOnly = adjecentOnly; }
- void setKeepInside(bool keepInside) { this->m_keepInside = keepInside; }
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputOuterMask;
+ SocketReader *m_inputInnerMask;
+ bool m_adjecentOnly;
+ bool m_keepInside;
+ float *m_cachedInstance;
+
+ public:
+ DoubleEdgeMaskOperation();
+
+ void doDoubleEdgeMask(float *inner, float *outer, float *res);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void setAdjecentOnly(bool adjecentOnly)
+ {
+ this->m_adjecentOnly = adjecentOnly;
+ }
+ void setKeepInside(bool keepInside)
+ {
+ this->m_keepInside = keepInside;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
index d7c0339c0d1..0dc42b3457f 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cpp
@@ -22,95 +22,98 @@
EllipseMaskOperation::EllipseMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
- this->m_cosine = 0.0f;
- this->m_sine = 0.0f;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputMask = NULL;
+ this->m_inputValue = NULL;
+ this->m_cosine = 0.0f;
+ this->m_sine = 0.0f;
}
void EllipseMaskOperation::initExecution()
{
- this->m_inputMask = this->getInputSocketReader(0);
- this->m_inputValue = this->getInputSocketReader(1);
- const double rad = (double)this->m_data->rotation;
- this->m_cosine = cos(rad);
- this->m_sine = sin(rad);
- this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
+ this->m_inputMask = this->getInputSocketReader(0);
+ this->m_inputValue = this->getInputSocketReader(1);
+ const double rad = (double)this->m_data->rotation;
+ this->m_cosine = cos(rad);
+ this->m_sine = sin(rad);
+ this->m_aspectRatio = ((float)this->getWidth()) / this->getHeight();
}
-void EllipseMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void EllipseMaskOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputMask[4];
- float inputValue[4];
+ float inputMask[4];
+ float inputValue[4];
- float rx = x / this->getWidth();
- float ry = y / this->getHeight();
+ float rx = x / this->getWidth();
+ float ry = y / this->getHeight();
- const float dy = (ry - this->m_data->y) / this->m_aspectRatio;
- const float dx = rx - this->m_data->x;
- rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
- ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
+ const float dy = (ry - this->m_data->y) / this->m_aspectRatio;
+ const float dx = rx - this->m_data->x;
+ rx = this->m_data->x + (this->m_cosine * dx + this->m_sine * dy);
+ ry = this->m_data->y + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_inputMask->readSampled(inputMask, x, y, sampler);
- this->m_inputValue->readSampled(inputValue, x, y, sampler);
+ this->m_inputMask->readSampled(inputMask, x, y, sampler);
+ this->m_inputValue->readSampled(inputValue, x, y, sampler);
- const float halfHeight = (this->m_data->height) / 2.0f;
- const float halfWidth = this->m_data->width / 2.0f;
- float sx = rx - this->m_data->x;
- sx *= sx;
- const float tx = halfWidth * halfWidth;
- float sy = ry - this->m_data->y;
- sy *= sy;
- const float ty = halfHeight * halfHeight;
+ const float halfHeight = (this->m_data->height) / 2.0f;
+ const float halfWidth = this->m_data->width / 2.0f;
+ float sx = rx - this->m_data->x;
+ sx *= sx;
+ const float tx = halfWidth * halfWidth;
+ float sy = ry - this->m_data->y;
+ sy *= sy;
+ const float ty = halfHeight * halfHeight;
- bool inside = ((sx / tx) + (sy / ty)) < 1.0f;
+ bool inside = ((sx / tx) + (sy / ty)) < 1.0f;
- switch (this->m_maskType) {
- case CMP_NODE_MASKTYPE_ADD:
- if (inside) {
- output[0] = max(inputMask[0], inputValue[0]);
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- case CMP_NODE_MASKTYPE_SUBTRACT:
- if (inside) {
- output[0] = inputMask[0] - inputValue[0];
- CLAMP(output[0], 0, 1);
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- case CMP_NODE_MASKTYPE_MULTIPLY:
- if (inside) {
- output[0] = inputMask[0] * inputValue[0];
- }
- else {
- output[0] = 0;
- }
- break;
- case CMP_NODE_MASKTYPE_NOT:
- if (inside) {
- if (inputMask[0] > 0.0f) {
- output[0] = 0;
- }
- else {
- output[0] = inputValue[0];
- }
- }
- else {
- output[0] = inputMask[0];
- }
- break;
- }
+ switch (this->m_maskType) {
+ case CMP_NODE_MASKTYPE_ADD:
+ if (inside) {
+ output[0] = max(inputMask[0], inputValue[0]);
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_SUBTRACT:
+ if (inside) {
+ output[0] = inputMask[0] - inputValue[0];
+ CLAMP(output[0], 0, 1);
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ case CMP_NODE_MASKTYPE_MULTIPLY:
+ if (inside) {
+ output[0] = inputMask[0] * inputValue[0];
+ }
+ else {
+ output[0] = 0;
+ }
+ break;
+ case CMP_NODE_MASKTYPE_NOT:
+ if (inside) {
+ if (inputMask[0] > 0.0f) {
+ output[0] = 0;
+ }
+ else {
+ output[0] = inputValue[0];
+ }
+ }
+ else {
+ output[0] = inputMask[0];
+ }
+ break;
+ }
}
void EllipseMaskOperation::deinitExecution()
{
- this->m_inputMask = NULL;
- this->m_inputValue = NULL;
+ this->m_inputMask = NULL;
+ this->m_inputValue = NULL;
}
diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.h b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
index 6f5b6e3e25d..b73a35a5452 100644
--- a/source/blender/compositor/operations/COM_EllipseMaskOperation.h
+++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.h
@@ -20,42 +20,47 @@
#define __COM_ELLIPSEMASKOPERATION_H__
#include "COM_NodeOperation.h"
-
class EllipseMaskOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputMask;
- SocketReader *m_inputValue;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputMask;
+ SocketReader *m_inputValue;
- float m_sine;
- float m_cosine;
- float m_aspectRatio;
- int m_maskType;
+ float m_sine;
+ float m_cosine;
+ float m_aspectRatio;
+ int m_maskType;
- NodeEllipseMask *m_data;
-public:
- EllipseMaskOperation();
+ NodeEllipseMask *m_data;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ EllipseMaskOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setData(NodeEllipseMask *data) { this->m_data = data; }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setMaskType(int maskType) { this->m_maskType = maskType; }
+ void setData(NodeEllipseMask *data)
+ {
+ this->m_data = data;
+ }
+ void setMaskType(int maskType)
+ {
+ this->m_maskType = maskType;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index c7c0fd8e447..e375b2fe45b 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -24,297 +24,310 @@
FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_iirgaus = NULL;
+ this->m_iirgaus = NULL;
}
void FastGaussianBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *newData = (MemoryBuffer *)data;
- newData->read(output, x, y);
+ MemoryBuffer *newData = (MemoryBuffer *)data;
+ newData->read(output, x, y);
}
-bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool FastGaussianBlurOperation::determineDependingAreaOfInterest(
+ rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
-
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- else {
- if (this->m_iirgaus) {
- return false;
- }
- else {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ else {
+ if (this->m_iirgaus) {
+ return false;
+ }
+ else {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
void FastGaussianBlurOperation::initExecution()
{
- BlurBaseOperation::initExecution();
- BlurBaseOperation::initMutex();
+ BlurBaseOperation::initExecution();
+ BlurBaseOperation::initMutex();
}
void FastGaussianBlurOperation::deinitExecution()
{
- if (this->m_iirgaus) {
- delete this->m_iirgaus;
- this->m_iirgaus = NULL;
- }
- BlurBaseOperation::deinitMutex();
+ if (this->m_iirgaus) {
+ delete this->m_iirgaus;
+ this->m_iirgaus = NULL;
+ }
+ BlurBaseOperation::deinitMutex();
}
void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (!this->m_iirgaus) {
- MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
- MemoryBuffer *copy = newBuf->duplicate();
- updateSize();
-
- int c;
- this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
- this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
-
- if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
- IIR_gauss(copy, this->m_sx, c, 3);
- }
- else {
- if (this->m_sx > 0.0f) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
- IIR_gauss(copy, this->m_sx, c, 1);
- }
- if (this->m_sy > 0.0f) {
- for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
- IIR_gauss(copy, this->m_sy, c, 2);
- }
- }
- this->m_iirgaus = copy;
- }
- unlockMutex();
- return this->m_iirgaus;
+ lockMutex();
+ if (!this->m_iirgaus) {
+ MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
+ MemoryBuffer *copy = newBuf->duplicate();
+ updateSize();
+
+ int c;
+ this->m_sx = this->m_data.sizex * this->m_size / 2.0f;
+ this->m_sy = this->m_data.sizey * this->m_size / 2.0f;
+
+ if ((this->m_sx == this->m_sy) && (this->m_sx > 0.0f)) {
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ IIR_gauss(copy, this->m_sx, c, 3);
+ }
+ else {
+ if (this->m_sx > 0.0f) {
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ IIR_gauss(copy, this->m_sx, c, 1);
+ }
+ if (this->m_sy > 0.0f) {
+ for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c)
+ IIR_gauss(copy, this->m_sy, c, 2);
+ }
+ }
+ this->m_iirgaus = copy;
+ }
+ unlockMutex();
+ return this->m_iirgaus;
}
-void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy)
+void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
+ float sigma,
+ unsigned int chan,
+ unsigned int xy)
{
- double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3];
- double *X, *Y, *W;
- const unsigned int src_width = src->getWidth();
- const unsigned int src_height = src->getHeight();
- unsigned int x, y, sz;
- unsigned int i;
- float *buffer = src->getBuffer();
- const unsigned int num_channels = src->get_num_channels();
-
- // <0.5 not valid, though can have a possibly useful sort of sharpening effect
- if (sigma < 0.5f) return;
-
- if ((xy < 1) || (xy > 3)) xy = 3;
-
- // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
- // so just skipping blur along faulty direction if src's def is below that limit!
- if (src_width < 3) xy &= ~1;
- if (src_height < 3) xy &= ~2;
- if (xy < 1) return;
-
- // see "Recursive Gabor Filtering" by Young/VanVliet
- // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
- if (sigma >= 3.556f)
- q = 0.9804f * (sigma - 3.556f) + 2.5091f;
- else // sigma >= 0.5
- q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
- q2 = q * q;
- sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
- // no gabor filtering here, so no complex multiplies, just the regular coefs.
- // all negated here, so as not to have to recalc Triggs/Sdika matrix
- cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
- cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
- // 0 & 3 unchanged
- cf[3] = q2 * q / sc;
- cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
-
- // Triggs/Sdika border corrections,
- // it seems to work, not entirely sure if it is actually totally correct,
- // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
- // found one other implementation by Cristoph Lampert,
- // but neither seem to be quite the same, result seems to be ok so far anyway.
- // Extra scale factor here to not have to do it in filter,
- // though maybe this had something to with the precision errors
- sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3]));
- tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]);
- tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1]));
- tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
- tsM[3] = sc * (cf[1] + cf[3] * cf[2]);
- tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1]));
- tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]);
- tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]);
- tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] - cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]);
- tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
-
-#define YVV(L) \
-{ \
- W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \
- W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \
- W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \
- for (i = 3; i < L; i++) { \
- W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \
- } \
- tsu[0] = W[L - 1] - X[L - 1]; \
- tsu[1] = W[L - 2] - X[L - 1]; \
- tsu[2] = W[L - 3] - X[L - 1]; \
- tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \
- tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \
- tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \
- Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \
- Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \
- Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \
- /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \
- for (i = L - 4; i != UINT_MAX; i--) { \
- Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \
- } \
-} (void)0
-
- // intermediate buffers
- sz = max(src_width, src_height);
- X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
- Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
- W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
- if (xy & 1) { // H
- int offset;
- for (y = 0; y < src_height; ++y) {
- const int yx = y * src_width;
- offset = yx * num_channels + chan;
- for (x = 0; x < src_width; ++x) {
- X[x] = buffer[offset];
- offset += num_channels;
- }
- YVV(src_width);
- offset = yx * num_channels + chan;
- for (x = 0; x < src_width; ++x) {
- buffer[offset] = Y[x];
- offset += num_channels;
- }
- }
- }
- if (xy & 2) { // V
- int offset;
- const int add = src_width * num_channels;
-
- for (x = 0; x < src_width; ++x) {
- offset = x * num_channels + chan;
- for (y = 0; y < src_height; ++y) {
- X[y] = buffer[offset];
- offset += add;
- }
- YVV(src_height);
- offset = x * num_channels + chan;
- for (y = 0; y < src_height; ++y) {
- buffer[offset] = Y[y];
- offset += add;
- }
- }
- }
-
- MEM_freeN(X);
- MEM_freeN(W);
- MEM_freeN(Y);
+ double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3];
+ double *X, *Y, *W;
+ const unsigned int src_width = src->getWidth();
+ const unsigned int src_height = src->getHeight();
+ unsigned int x, y, sz;
+ unsigned int i;
+ float *buffer = src->getBuffer();
+ const unsigned int num_channels = src->get_num_channels();
+
+ // <0.5 not valid, though can have a possibly useful sort of sharpening effect
+ if (sigma < 0.5f)
+ return;
+
+ if ((xy < 1) || (xy > 3))
+ xy = 3;
+
+ // XXX The YVV macro defined below explicitly expects sources of at least 3x3 pixels,
+ // so just skipping blur along faulty direction if src's def is below that limit!
+ if (src_width < 3)
+ xy &= ~1;
+ if (src_height < 3)
+ xy &= ~2;
+ if (xy < 1)
+ return;
+
+ // see "Recursive Gabor Filtering" by Young/VanVliet
+ // all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
+ if (sigma >= 3.556f)
+ q = 0.9804f * (sigma - 3.556f) + 2.5091f;
+ else // sigma >= 0.5
+ q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
+ q2 = q * q;
+ sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
+ // no gabor filtering here, so no complex multiplies, just the regular coefs.
+ // all negated here, so as not to have to recalc Triggs/Sdika matrix
+ cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
+ cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
+ // 0 & 3 unchanged
+ cf[3] = q2 * q / sc;
+ cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
+
+ // Triggs/Sdika border corrections,
+ // it seems to work, not entirely sure if it is actually totally correct,
+ // Besides J.M.Geusebroek's anigauss.c (see http://www.science.uva.nl/~mark),
+ // found one other implementation by Cristoph Lampert,
+ // but neither seem to be quite the same, result seems to be ok so far anyway.
+ // Extra scale factor here to not have to do it in filter,
+ // though maybe this had something to with the precision errors
+ sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) *
+ (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3]));
+ tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]);
+ tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1]));
+ tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
+ tsM[3] = sc * (cf[1] + cf[3] * cf[2]);
+ tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1]));
+ tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]);
+ tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]);
+ tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] -
+ cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]);
+ tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
+
+#define YVV(L) \
+ { \
+ W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \
+ for (i = 3; i < L; i++) { \
+ W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \
+ } \
+ tsu[0] = W[L - 1] - X[L - 1]; \
+ tsu[1] = W[L - 2] - X[L - 1]; \
+ tsu[2] = W[L - 3] - X[L - 1]; \
+ tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \
+ tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \
+ tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \
+ Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \
+ Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \
+ Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \
+ /* 'i != UINT_MAX' is really 'i >= 0', but necessary for unsigned int wrapping */ \
+ for (i = L - 4; i != UINT_MAX; i--) { \
+ Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \
+ } \
+ } \
+ (void)0
+
+ // intermediate buffers
+ sz = max(src_width, src_height);
+ X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
+ Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
+ W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
+ if (xy & 1) { // H
+ int offset;
+ for (y = 0; y < src_height; ++y) {
+ const int yx = y * src_width;
+ offset = yx * num_channels + chan;
+ for (x = 0; x < src_width; ++x) {
+ X[x] = buffer[offset];
+ offset += num_channels;
+ }
+ YVV(src_width);
+ offset = yx * num_channels + chan;
+ for (x = 0; x < src_width; ++x) {
+ buffer[offset] = Y[x];
+ offset += num_channels;
+ }
+ }
+ }
+ if (xy & 2) { // V
+ int offset;
+ const int add = src_width * num_channels;
+
+ for (x = 0; x < src_width; ++x) {
+ offset = x * num_channels + chan;
+ for (y = 0; y < src_height; ++y) {
+ X[y] = buffer[offset];
+ offset += add;
+ }
+ YVV(src_height);
+ offset = x * num_channels + chan;
+ for (y = 0; y < src_height; ++y) {
+ buffer[offset] = Y[y];
+ offset += add;
+ }
+ }
+ }
+
+ MEM_freeN(X);
+ MEM_freeN(W);
+ MEM_freeN(Y);
#undef YVV
-
}
-
///
FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_iirgaus = NULL;
- this->m_inputprogram = NULL;
- this->m_sigma = 1.0f;
- this->m_overlay = 0;
- setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_iirgaus = NULL;
+ this->m_inputprogram = NULL;
+ this->m_sigma = 1.0f;
+ this->m_overlay = 0;
+ setComplex(true);
}
void FastGaussianBlurValueOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *newData = (MemoryBuffer *)data;
- newData->read(output, x, y);
+ MemoryBuffer *newData = (MemoryBuffer *)data;
+ newData->read(output, x, y);
}
-bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest(
+ rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
-
- if (this->m_iirgaus) {
- return false;
- }
- else {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+
+ if (this->m_iirgaus) {
+ return false;
+ }
+ else {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void FastGaussianBlurValueOperation::initExecution()
{
- this->m_inputprogram = getInputSocketReader(0);
- initMutex();
+ this->m_inputprogram = getInputSocketReader(0);
+ initMutex();
}
void FastGaussianBlurValueOperation::deinitExecution()
{
- if (this->m_iirgaus) {
- delete this->m_iirgaus;
- this->m_iirgaus = NULL;
- }
- deinitMutex();
+ if (this->m_iirgaus) {
+ delete this->m_iirgaus;
+ this->m_iirgaus = NULL;
+ }
+ deinitMutex();
}
void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (!this->m_iirgaus) {
- MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);
- MemoryBuffer *copy = newBuf->duplicate();
- FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);
-
- if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
- float *src = newBuf->getBuffer();
- float *dst = copy->getBuffer();
- for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {
- if (*src < *dst) {
- *dst = *src;
- }
- }
- }
- else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
- float *src = newBuf->getBuffer();
- float *dst = copy->getBuffer();
- for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {
- if (*src > *dst) {
- *dst = *src;
- }
- }
- }
-
-// newBuf->
-
- this->m_iirgaus = copy;
- }
- unlockMutex();
- return this->m_iirgaus;
+ lockMutex();
+ if (!this->m_iirgaus) {
+ MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);
+ MemoryBuffer *copy = newBuf->duplicate();
+ FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);
+
+ if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {
+ float *src = newBuf->getBuffer();
+ float *dst = copy->getBuffer();
+ for (int i = copy->getWidth() * copy->getHeight(); i != 0;
+ i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {
+ if (*src < *dst) {
+ *dst = *src;
+ }
+ }
+ }
+ else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) {
+ float *src = newBuf->getBuffer();
+ float *dst = copy->getBuffer();
+ for (int i = copy->getWidth() * copy->getHeight(); i != 0;
+ i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) {
+ if (*src > *dst) {
+ *dst = *src;
+ }
+ }
+ }
+
+ // newBuf->
+
+ this->m_iirgaus = copy;
+ }
+ unlockMutex();
+ return this->m_iirgaus;
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index b31e88a545d..22f9a6f9cf2 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -23,50 +23,62 @@
#include "DNA_node_types.h"
class FastGaussianBlurOperation : public BlurBaseOperation {
-private:
- float m_sx;
- float m_sy;
- MemoryBuffer *m_iirgaus;
-public:
- FastGaussianBlurOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], int x, int y, void *data);
+ private:
+ float m_sx;
+ float m_sy;
+ MemoryBuffer *m_iirgaus;
- static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy);
- void *initializeTileData(rcti *rect);
- void deinitExecution();
- void initExecution();
+ public:
+ FastGaussianBlurOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixel(float output[4], int x, int y, void *data);
+
+ static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy);
+ void *initializeTileData(rcti *rect);
+ void deinitExecution();
+ void initExecution();
};
enum {
- FAST_GAUSS_OVERLAY_MIN = -1,
- FAST_GAUSS_OVERLAY_NONE = 0,
- FAST_GAUSS_OVERLAY_MAX = 1,
+ FAST_GAUSS_OVERLAY_MIN = -1,
+ FAST_GAUSS_OVERLAY_NONE = 0,
+ FAST_GAUSS_OVERLAY_MAX = 1,
};
class FastGaussianBlurValueOperation : public NodeOperation {
-private:
- float m_sigma;
- MemoryBuffer *m_iirgaus;
- SocketReader *m_inputprogram;
+ private:
+ float m_sigma;
+ MemoryBuffer *m_iirgaus;
+ SocketReader *m_inputprogram;
+
+ /**
+ * -1: re-mix with darker
+ * 0: do nothing
+ * 1 re-mix with lighter */
+ int m_overlay;
- /**
- * -1: re-mix with darker
- * 0: do nothing
- * 1 re-mix with lighter */
- int m_overlay;
-public:
- FastGaussianBlurValueOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ FastGaussianBlurValueOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixel(float output[4], int x, int y, void *data);
- void *initializeTileData(rcti *rect);
- void deinitExecution();
- void initExecution();
- void setSigma(float sigma) { this->m_sigma = sigma; }
+ void *initializeTileData(rcti *rect);
+ void deinitExecution();
+ void initExecution();
+ void setSigma(float sigma)
+ {
+ this->m_sigma = sigma;
+ }
- /* used for DOF blurring ZBuffer */
- void setOverlay(int overlay) { this->m_overlay = overlay; }
+ /* used for DOF blurring ZBuffer */
+ void setOverlay(int overlay)
+ {
+ this->m_overlay = overlay;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_FlipOperation.cpp b/source/blender/compositor/operations/COM_FlipOperation.cpp
index 913704bdfc0..57b686986b7 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.cpp
+++ b/source/blender/compositor/operations/COM_FlipOperation.cpp
@@ -20,54 +20,55 @@
FlipOperation::FlipOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_flipX = true;
- this->m_flipY = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_flipX = true;
+ this->m_flipY = false;
}
void FlipOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
void FlipOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
-
void FlipOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float nx = this->m_flipX ? ((int)this->getWidth() - 1) - x : x;
- float ny = this->m_flipY ? ((int)this->getHeight() - 1) - y : y;
+ float nx = this->m_flipX ? ((int)this->getWidth() - 1) - x : x;
+ float ny = this->m_flipY ? ((int)this->getHeight() - 1) - y : y;
- this->m_inputOperation->readSampled(output, nx, ny, sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, sampler);
}
-bool FlipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool FlipOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- if (this->m_flipX) {
- const int w = (int)this->getWidth() - 1;
- newInput.xmax = (w - input->xmin) + 1;
- newInput.xmin = (w - input->xmax) - 1;
- }
- else {
- newInput.xmin = input->xmin;
- newInput.xmax = input->xmax;
- }
- if (this->m_flipY) {
- const int h = (int)this->getHeight() - 1;
- newInput.ymax = (h - input->ymin) + 1;
- newInput.ymin = (h - input->ymax) - 1;
- }
- else {
- newInput.ymin = input->ymin;
- newInput.ymax = input->ymax;
- }
+ if (this->m_flipX) {
+ const int w = (int)this->getWidth() - 1;
+ newInput.xmax = (w - input->xmin) + 1;
+ newInput.xmin = (w - input->xmax) - 1;
+ }
+ else {
+ newInput.xmin = input->xmin;
+ newInput.xmax = input->xmax;
+ }
+ if (this->m_flipY) {
+ const int h = (int)this->getHeight() - 1;
+ newInput.ymax = (h - input->ymin) + 1;
+ newInput.ymin = (h - input->ymax) - 1;
+ }
+ else {
+ newInput.ymin = input->ymin;
+ newInput.ymax = input->ymax;
+ }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_FlipOperation.h b/source/blender/compositor/operations/COM_FlipOperation.h
index 1564daf5469..2d00c50dc8a 100644
--- a/source/blender/compositor/operations/COM_FlipOperation.h
+++ b/source/blender/compositor/operations/COM_FlipOperation.h
@@ -22,19 +22,28 @@
#include "COM_NodeOperation.h"
class FlipOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
- bool m_flipX;
- bool m_flipY;
-public:
- FlipOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ private:
+ SocketReader *m_inputOperation;
+ bool m_flipX;
+ bool m_flipY;
- void initExecution();
- void deinitExecution();
- void setFlipX(bool flipX) { this->m_flipX = flipX; }
- void setFlipY(bool flipY) { this->m_flipY = flipY; }
+ public:
+ FlipOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+ void setFlipX(bool flipX)
+ {
+ this->m_flipX = flipX;
+ }
+ void setFlipY(bool flipY)
+ {
+ this->m_flipY = flipY;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index 8828553b4fd..36272c05774 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -21,78 +21,84 @@
GammaCorrectOperation::GammaCorrectOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
}
void GammaCorrectOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void GammaCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void GammaCorrectOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputProgram->readSampled(inputColor, x, y, sampler);
- if (inputColor[3] > 0.0f) {
- inputColor[0] /= inputColor[3];
- inputColor[1] /= inputColor[3];
- inputColor[2] /= inputColor[3];
- }
+ float inputColor[4];
+ this->m_inputProgram->readSampled(inputColor, x, y, sampler);
+ if (inputColor[3] > 0.0f) {
+ inputColor[0] /= inputColor[3];
+ inputColor[1] /= inputColor[3];
+ inputColor[2] /= inputColor[3];
+ }
- /* check for negative to avoid nan's */
- output[0] = inputColor[0] > 0.0f ? inputColor[0] * inputColor[0] : 0.0f;
- output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f;
- output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f;
- output[3] = inputColor[3];
+ /* check for negative to avoid nan's */
+ output[0] = inputColor[0] > 0.0f ? inputColor[0] * inputColor[0] : 0.0f;
+ output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f;
+ output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f;
+ output[3] = inputColor[3];
- if (inputColor[3] > 0.0f) {
- output[0] *= inputColor[3];
- output[1] *= inputColor[3];
- output[2] *= inputColor[3];
- }
+ if (inputColor[3] > 0.0f) {
+ output[0] *= inputColor[3];
+ output[1] *= inputColor[3];
+ output[2] *= inputColor[3];
+ }
}
void GammaCorrectOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
GammaUncorrectOperation::GammaUncorrectOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
}
void GammaUncorrectOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void GammaUncorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void GammaUncorrectOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor[4];
- this->m_inputProgram->readSampled(inputColor, x, y, sampler);
+ float inputColor[4];
+ this->m_inputProgram->readSampled(inputColor, x, y, sampler);
- if (inputColor[3] > 0.0f) {
- inputColor[0] /= inputColor[3];
- inputColor[1] /= inputColor[3];
- inputColor[2] /= inputColor[3];
- }
+ if (inputColor[3] > 0.0f) {
+ inputColor[0] /= inputColor[3];
+ inputColor[1] /= inputColor[3];
+ inputColor[2] /= inputColor[3];
+ }
- output[0] = inputColor[0] > 0.0f ? sqrtf(inputColor[0]) : 0.0f;
- output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f;
- output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f;
- output[3] = inputColor[3];
+ output[0] = inputColor[0] > 0.0f ? sqrtf(inputColor[0]) : 0.0f;
+ output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f;
+ output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f;
+ output[3] = inputColor[3];
- if (inputColor[3] > 0.0f) {
- output[0] *= inputColor[3];
- output[1] *= inputColor[3];
- output[2] *= inputColor[3];
- }
+ if (inputColor[3] > 0.0f) {
+ output[0] *= inputColor[3];
+ output[1] *= inputColor[3];
+ output[2] *= inputColor[3];
+ }
}
void GammaUncorrectOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.h b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
index f982a3f7b18..26e31df880f 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.h
@@ -20,57 +20,56 @@
#define __COM_GAMMACORRECTOPERATION_H__
#include "COM_NodeOperation.h"
-
class GammaCorrectOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
-public:
- GammaCorrectOperation();
+ public:
+ GammaCorrectOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
class GammaUncorrectOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
-public:
- GammaUncorrectOperation();
+ public:
+ GammaUncorrectOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_GammaOperation.cpp b/source/blender/compositor/operations/COM_GammaOperation.cpp
index 614daebfed6..ee6b42c349f 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaOperation.cpp
@@ -21,36 +21,36 @@
GammaOperation::GammaOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
- this->m_inputGammaProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
+ this->m_inputGammaProgram = NULL;
}
void GammaOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- this->m_inputGammaProgram = this->getInputSocketReader(1);
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputGammaProgram = this->getInputSocketReader(1);
}
void GammaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputValue[4];
- float inputGamma[4];
+ float inputValue[4];
+ float inputGamma[4];
- this->m_inputProgram->readSampled(inputValue, x, y, sampler);
- this->m_inputGammaProgram->readSampled(inputGamma, x, y, sampler);
- const float gamma = inputGamma[0];
- /* check for negative to avoid nan's */
- output[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0];
- output[1] = inputValue[1] > 0.0f ? powf(inputValue[1], gamma) : inputValue[1];
- output[2] = inputValue[2] > 0.0f ? powf(inputValue[2], gamma) : inputValue[2];
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputGammaProgram->readSampled(inputGamma, x, y, sampler);
+ const float gamma = inputGamma[0];
+ /* check for negative to avoid nan's */
+ output[0] = inputValue[0] > 0.0f ? powf(inputValue[0], gamma) : inputValue[0];
+ output[1] = inputValue[1] > 0.0f ? powf(inputValue[1], gamma) : inputValue[1];
+ output[2] = inputValue[2] > 0.0f ? powf(inputValue[2], gamma) : inputValue[2];
- output[3] = inputValue[3];
+ output[3] = inputValue[3];
}
void GammaOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputGammaProgram = NULL;
+ this->m_inputProgram = NULL;
+ this->m_inputGammaProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_GammaOperation.h b/source/blender/compositor/operations/COM_GammaOperation.h
index 0ec96cfccee..ba0b84db931 100644
--- a/source/blender/compositor/operations/COM_GammaOperation.h
+++ b/source/blender/compositor/operations/COM_GammaOperation.h
@@ -20,31 +20,30 @@
#define __COM_GAMMAOPERATION_H__
#include "COM_NodeOperation.h"
-
class GammaOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- SocketReader *m_inputGammaProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputGammaProgram;
-public:
- GammaOperation();
+ public:
+ GammaOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index f9a548e1498..c6239dba604 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -21,168 +21,171 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
- this->m_gausstab = NULL;
- this->m_filtersize = 0;
- this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
+ this->m_gausstab = NULL;
+ this->m_filtersize = 0;
+ this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
void *GaussianAlphaXBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianAlphaXBlurOperation::initExecution()
{
- /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
+ /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data.sizex, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_sizeavailable) {
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
void GaussianAlphaXBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizex, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_gausstab == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ }
- if (this->m_distbuf_inv == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizex, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_distbuf_inv == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
BLI_INLINE float finv_test(const float f, const bool test)
{
- return (LIKELY(test == false)) ? f : 1.0f - f;
+ return (LIKELY(test == false)) ? f : 1.0f - f;
}
void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- const bool do_invert = this->m_do_subtract;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int xmin = max_ii(x - m_filtersize, rect.xmin);
- int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
- int ymin = max_ii(y, rect.ymin);
-
- /* *** this is the main part which is different to 'GaussianXBlurOperation' *** */
- int step = getStep();
- int bufferindex = ((xmin - bufferstartx)) + ((ymin - bufferstarty) * bufferwidth);
-
- /* gauss */
- float alpha_accum = 0.0f;
- float multiplier_accum = 0.0f;
-
- /* dilate */
- float value_max = finv_test(buffer[(x) + (y * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
- float distfacinv_max = 1.0f; /* 0 to 1 */
-
- for (int nx = xmin; nx < xmax; nx += step) {
- const int index = (nx - x) + this->m_filtersize;
- float value = finv_test(buffer[bufferindex], do_invert);
- float multiplier;
-
- /* gauss */
- {
- multiplier = this->m_gausstab[index];
- alpha_accum += value * multiplier;
- multiplier_accum += multiplier;
- }
-
- /* dilate - find most extreme color */
- if (value > value_max) {
- multiplier = this->m_distbuf_inv[index];
- value *= multiplier;
- if (value > value_max) {
- value_max = value;
- distfacinv_max = multiplier;
- }
- }
- bufferindex += step;
- }
-
- /* blend between the max value and gauss blue - gives nice feather */
- const float value_blur = alpha_accum / multiplier_accum;
- const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
- output[0] = finv_test(value_final, do_invert);
+ const bool do_invert = this->m_do_subtract;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x - m_filtersize, rect.xmin);
+ int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
+ int ymin = max_ii(y, rect.ymin);
+
+ /* *** this is the main part which is different to 'GaussianXBlurOperation' *** */
+ int step = getStep();
+ int bufferindex = ((xmin - bufferstartx)) + ((ymin - bufferstarty) * bufferwidth);
+
+ /* gauss */
+ float alpha_accum = 0.0f;
+ float multiplier_accum = 0.0f;
+
+ /* dilate */
+ float value_max = finv_test(
+ buffer[(x) + (y * bufferwidth)],
+ do_invert); /* init with the current color to avoid unneeded lookups */
+ float distfacinv_max = 1.0f; /* 0 to 1 */
+
+ for (int nx = xmin; nx < xmax; nx += step) {
+ const int index = (nx - x) + this->m_filtersize;
+ float value = finv_test(buffer[bufferindex], do_invert);
+ float multiplier;
+
+ /* gauss */
+ {
+ multiplier = this->m_gausstab[index];
+ alpha_accum += value * multiplier;
+ multiplier_accum += multiplier;
+ }
+
+ /* dilate - find most extreme color */
+ if (value > value_max) {
+ multiplier = this->m_distbuf_inv[index];
+ value *= multiplier;
+ if (value > value_max) {
+ value_max = value;
+ distfacinv_max = multiplier;
+ }
+ }
+ bufferindex += step;
+ }
+
+ /* blend between the max value and gauss blue - gives nice feather */
+ const float value_blur = alpha_accum / multiplier_accum;
+ const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
+ output[0] = finv_test(value_final, do_invert);
}
void GaussianAlphaXBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
- if (this->m_distbuf_inv) {
- MEM_freeN(this->m_distbuf_inv);
- this->m_distbuf_inv = NULL;
- }
+ if (this->m_distbuf_inv) {
+ MEM_freeN(this->m_distbuf_inv);
+ this->m_distbuf_inv = NULL;
+ }
- deinitMutex();
+ deinitMutex();
}
-bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianAlphaXBlurOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
+ rcti newInput;
#if 0 /* until we add size input */
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
-
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- else
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ else
#endif
- {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax + this->m_filtersize + 1;
- newInput.xmin = input->xmin - this->m_filtersize - 1;
- newInput.ymax = input->ymax;
- newInput.ymin = input->ymin;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmax = input->xmax + this->m_filtersize + 1;
+ newInput.xmin = input->xmin - this->m_filtersize - 1;
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
index 530fccad60c..4d249778f53 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
@@ -22,38 +22,47 @@
#include "COM_BlurBaseOperation.h"
class GaussianAlphaXBlurOperation : public BlurBaseOperation {
-private:
- float *m_gausstab;
- float *m_distbuf_inv;
- int m_falloff; /* falloff for distbuf_inv */
- bool m_do_subtract;
- int m_filtersize;
- void updateGauss();
-public:
- GaussianAlphaXBlurOperation();
-
- /**
- * \brief the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * \brief initialize the execution
- */
- void initExecution();
-
- /**
- * \brief Deinitialize the execution
- */
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- /**
- * Set subtract for Dilate/Erode functionality
- */
- void setSubtract(bool subtract) { this->m_do_subtract = subtract; }
- void setFalloff(int falloff) { this->m_falloff = falloff; }
+ private:
+ float *m_gausstab;
+ float *m_distbuf_inv;
+ int m_falloff; /* falloff for distbuf_inv */
+ bool m_do_subtract;
+ int m_filtersize;
+ void updateGauss();
+
+ public:
+ GaussianAlphaXBlurOperation();
+
+ /**
+ * \brief the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * \brief initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * \brief Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ /**
+ * Set subtract for Dilate/Erode functionality
+ */
+ void setSubtract(bool subtract)
+ {
+ this->m_do_subtract = subtract;
+ }
+ void setFalloff(int falloff)
+ {
+ this->m_falloff = falloff;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 058718c6a97..37109b4a03e 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -21,169 +21,171 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
- this->m_gausstab = NULL;
- this->m_filtersize = 0;
- this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
+ this->m_gausstab = NULL;
+ this->m_filtersize = 0;
+ this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
void *GaussianAlphaYBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianAlphaYBlurOperation::initExecution()
{
- /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
+ /* BlurBaseOperation::initExecution(); */ /* until we suppoer size input - comment this */
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_sizeavailable) {
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
void GaussianAlphaYBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_gausstab == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
- }
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ }
- if (this->m_distbuf_inv == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_distbuf_inv == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
- }
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
+ }
}
BLI_INLINE float finv_test(const float f, const bool test)
{
- return (LIKELY(test == false)) ? f : 1.0f - f;
+ return (LIKELY(test == false)) ? f : 1.0f - f;
}
void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- const bool do_invert = this->m_do_subtract;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int xmin = max_ii(x, rect.xmin);
- int ymin = max_ii(y - m_filtersize, rect.ymin);
- int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
-
- /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
- int step = getStep();
-
- /* gauss */
- float alpha_accum = 0.0f;
- float multiplier_accum = 0.0f;
-
- /* dilate */
- float value_max = finv_test(buffer[(x) + (y * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
- float distfacinv_max = 1.0f; /* 0 to 1 */
-
- for (int ny = ymin; ny < ymax; ny += step) {
- int bufferindex = ((xmin - bufferstartx)) + ((ny - bufferstarty) * bufferwidth);
-
- const int index = (ny - y) + this->m_filtersize;
- float value = finv_test(buffer[bufferindex], do_invert);
- float multiplier;
-
- /* gauss */
- {
- multiplier = this->m_gausstab[index];
- alpha_accum += value * multiplier;
- multiplier_accum += multiplier;
- }
-
- /* dilate - find most extreme color */
- if (value > value_max) {
- multiplier = this->m_distbuf_inv[index];
- value *= multiplier;
- if (value > value_max) {
- value_max = value;
- distfacinv_max = multiplier;
- }
- }
-
- }
-
- /* blend between the max value and gauss blue - gives nice feather */
- const float value_blur = alpha_accum / multiplier_accum;
- const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
- output[0] = finv_test(value_final, do_invert);
+ const bool do_invert = this->m_do_subtract;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x, rect.xmin);
+ int ymin = max_ii(y - m_filtersize, rect.ymin);
+ int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
+
+ /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
+ int step = getStep();
+
+ /* gauss */
+ float alpha_accum = 0.0f;
+ float multiplier_accum = 0.0f;
+
+ /* dilate */
+ float value_max = finv_test(
+ buffer[(x) + (y * bufferwidth)],
+ do_invert); /* init with the current color to avoid unneeded lookups */
+ float distfacinv_max = 1.0f; /* 0 to 1 */
+
+ for (int ny = ymin; ny < ymax; ny += step) {
+ int bufferindex = ((xmin - bufferstartx)) + ((ny - bufferstarty) * bufferwidth);
+
+ const int index = (ny - y) + this->m_filtersize;
+ float value = finv_test(buffer[bufferindex], do_invert);
+ float multiplier;
+
+ /* gauss */
+ {
+ multiplier = this->m_gausstab[index];
+ alpha_accum += value * multiplier;
+ multiplier_accum += multiplier;
+ }
+
+ /* dilate - find most extreme color */
+ if (value > value_max) {
+ multiplier = this->m_distbuf_inv[index];
+ value *= multiplier;
+ if (value > value_max) {
+ value_max = value;
+ distfacinv_max = multiplier;
+ }
+ }
+ }
+
+ /* blend between the max value and gauss blue - gives nice feather */
+ const float value_blur = alpha_accum / multiplier_accum;
+ const float value_final = (value_max * distfacinv_max) + (value_blur * (1.0f - distfacinv_max));
+ output[0] = finv_test(value_final, do_invert);
}
void GaussianAlphaYBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
- if (this->m_distbuf_inv) {
- MEM_freeN(this->m_distbuf_inv);
- this->m_distbuf_inv = NULL;
- }
+ if (this->m_distbuf_inv) {
+ MEM_freeN(this->m_distbuf_inv);
+ this->m_distbuf_inv = NULL;
+ }
- deinitMutex();
+ deinitMutex();
}
-bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
+ rcti newInput;
#if 0 /* until we add size input */
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
-
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- else
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ else
#endif
- {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax;
- newInput.xmin = input->xmin;
- newInput.ymax = input->ymax + this->m_filtersize + 1;
- newInput.ymin = input->ymin - this->m_filtersize - 1;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmax = input->xmax;
+ newInput.xmin = input->xmin;
+ newInput.ymax = input->ymax + this->m_filtersize + 1;
+ newInput.ymin = input->ymin - this->m_filtersize - 1;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
index cf3670f90ad..d31534455bc 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
@@ -22,38 +22,47 @@
#include "COM_BlurBaseOperation.h"
class GaussianAlphaYBlurOperation : public BlurBaseOperation {
-private:
- float *m_gausstab;
- float *m_distbuf_inv;
- bool m_do_subtract;
- int m_falloff;
- int m_filtersize;
- void updateGauss();
-public:
- GaussianAlphaYBlurOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * \brief initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- /**
- * Set subtract for Dilate/Erode functionality
- */
- void setSubtract(bool subtract) { this->m_do_subtract = subtract; }
- void setFalloff(int falloff) { this->m_falloff = falloff; }
+ private:
+ float *m_gausstab;
+ float *m_distbuf_inv;
+ bool m_do_subtract;
+ int m_falloff;
+ int m_filtersize;
+ void updateGauss();
+
+ public:
+ GaussianAlphaYBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * \brief initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ /**
+ * Set subtract for Dilate/Erode functionality
+ */
+ void setSubtract(bool subtract)
+ {
+ this->m_do_subtract = subtract;
+ }
+ void setFalloff(int falloff)
+ {
+ this->m_falloff = falloff;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 40a6f52c7a6..88c4ff7d935 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -20,333 +20,336 @@
#include "BLI_math.h"
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = NULL;
}
void *GaussianBokehBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianBokehBlurOperation::initExecution()
{
- BlurBaseOperation::initExecution();
+ BlurBaseOperation::initExecution();
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- updateGauss();
- }
+ if (this->m_sizeavailable) {
+ updateGauss();
+ }
}
void GaussianBokehBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- float radxf;
- float radyf;
- int n;
- float *dgauss;
- float *ddgauss;
- int j, i;
- const float width = this->getWidth();
- const float height = this->getHeight();
- if (!this->m_sizeavailable) {
- updateSize();
- }
- radxf = this->m_size * (float)this->m_data.sizex;
- CLAMP(radxf, 0.0f, width / 2.0f);
-
- /* vertical */
- radyf = this->m_size * (float)this->m_data.sizey;
- CLAMP(radyf, 0.0f, height / 2.0f);
-
- this->m_radx = ceil(radxf);
- this->m_rady = ceil(radyf);
-
- int ddwidth = 2 * this->m_radx + 1;
- int ddheight = 2 * this->m_rady + 1;
- n = ddwidth * ddheight;
-
- /* create a full filter image */
- ddgauss = (float *)MEM_mallocN(sizeof(float) * n, __func__);
- dgauss = ddgauss;
- float sum = 0.0f;
- float facx = (radxf > 0.0f ? 1.0f / radxf : 0.0f);
- float facy = (radyf > 0.0f ? 1.0f / radyf : 0.0f);
- for (j = -this->m_rady; j <= this->m_rady; j++) {
- for (i = -this->m_radx; i <= this->m_radx; i++, dgauss++) {
- float fj = (float)j * facy;
- float fi = (float)i * facx;
- float dist = sqrt(fj * fj + fi * fi);
- *dgauss = RE_filter_value(this->m_data.filtertype, dist);
-
- sum += *dgauss;
- }
- }
-
- if (sum > 0.0f) {
- /* normalize */
- float norm = 1.0f / sum;
- for (j = n - 1; j >= 0; j--)
- ddgauss[j] *= norm;
- }
- else {
- int center = m_rady * ddwidth + m_radx;
- ddgauss[center] = 1.0f;
- }
-
- this->m_gausstab = ddgauss;
- }
+ if (this->m_gausstab == NULL) {
+ float radxf;
+ float radyf;
+ int n;
+ float *dgauss;
+ float *ddgauss;
+ int j, i;
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ if (!this->m_sizeavailable) {
+ updateSize();
+ }
+ radxf = this->m_size * (float)this->m_data.sizex;
+ CLAMP(radxf, 0.0f, width / 2.0f);
+
+ /* vertical */
+ radyf = this->m_size * (float)this->m_data.sizey;
+ CLAMP(radyf, 0.0f, height / 2.0f);
+
+ this->m_radx = ceil(radxf);
+ this->m_rady = ceil(radyf);
+
+ int ddwidth = 2 * this->m_radx + 1;
+ int ddheight = 2 * this->m_rady + 1;
+ n = ddwidth * ddheight;
+
+ /* create a full filter image */
+ ddgauss = (float *)MEM_mallocN(sizeof(float) * n, __func__);
+ dgauss = ddgauss;
+ float sum = 0.0f;
+ float facx = (radxf > 0.0f ? 1.0f / radxf : 0.0f);
+ float facy = (radyf > 0.0f ? 1.0f / radyf : 0.0f);
+ for (j = -this->m_rady; j <= this->m_rady; j++) {
+ for (i = -this->m_radx; i <= this->m_radx; i++, dgauss++) {
+ float fj = (float)j * facy;
+ float fi = (float)i * facx;
+ float dist = sqrt(fj * fj + fi * fi);
+ *dgauss = RE_filter_value(this->m_data.filtertype, dist);
+
+ sum += *dgauss;
+ }
+ }
+
+ if (sum > 0.0f) {
+ /* normalize */
+ float norm = 1.0f / sum;
+ for (j = n - 1; j >= 0; j--)
+ ddgauss[j] *= norm;
+ }
+ else {
+ int center = m_rady * ddwidth + m_radx;
+ ddgauss[center] = 1.0f;
+ }
+
+ this->m_gausstab = ddgauss;
+ }
}
void GaussianBokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float tempColor[4];
- tempColor[0] = 0;
- tempColor[1] = 0;
- tempColor[2] = 0;
- tempColor[3] = 0;
- float multiplier_accum = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int ymin = max_ii(y - this->m_rady, rect.ymin);
- int ymax = min_ii(y + this->m_rady + 1, rect.ymax);
- int xmin = max_ii(x - this->m_radx, rect.xmin);
- int xmax = min_ii(x + this->m_radx + 1, rect.xmax);
-
- int index;
- int step = QualityStepHelper::getStep();
- int offsetadd = QualityStepHelper::getOffsetAdd();
- const int addConst = (xmin - x + this->m_radx);
- const int mulConst = (this->m_radx * 2 + 1);
- for (int ny = ymin; ny < ymax; ny += step) {
- index = ((ny - y) + this->m_rady) * mulConst + addConst;
- int bufferindex = ((xmin - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
- for (int nx = xmin; nx < xmax; nx += step) {
- const float multiplier = this->m_gausstab[index];
- madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier);
- multiplier_accum += multiplier;
- index += step;
- bufferindex += offsetadd;
- }
- }
-
- mul_v4_v4fl(output, tempColor, 1.0f / multiplier_accum);
+ float tempColor[4];
+ tempColor[0] = 0;
+ tempColor[1] = 0;
+ tempColor[2] = 0;
+ tempColor[3] = 0;
+ float multiplier_accum = 0;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int ymin = max_ii(y - this->m_rady, rect.ymin);
+ int ymax = min_ii(y + this->m_rady + 1, rect.ymax);
+ int xmin = max_ii(x - this->m_radx, rect.xmin);
+ int xmax = min_ii(x + this->m_radx + 1, rect.xmax);
+
+ int index;
+ int step = QualityStepHelper::getStep();
+ int offsetadd = QualityStepHelper::getOffsetAdd();
+ const int addConst = (xmin - x + this->m_radx);
+ const int mulConst = (this->m_radx * 2 + 1);
+ for (int ny = ymin; ny < ymax; ny += step) {
+ index = ((ny - y) + this->m_rady) * mulConst + addConst;
+ int bufferindex = ((xmin - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = xmin; nx < xmax; nx += step) {
+ const float multiplier = this->m_gausstab[index];
+ madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplier);
+ multiplier_accum += multiplier;
+ index += step;
+ bufferindex += offsetadd;
+ }
+ }
+
+ mul_v4_v4fl(output, tempColor, 1.0f / multiplier_accum);
}
void GaussianBokehBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
- deinitMutex();
+ deinitMutex();
}
-bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- NodeOperation *operation = this->getInputOperation(1);
-
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- else {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmin = 0;
- newInput.ymin = 0;
- newInput.xmax = this->getWidth();
- newInput.ymax = this->getHeight();
- }
- else {
- int addx = this->m_radx;
- int addy = this->m_rady;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
-
- }
- return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ rcti newInput;
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation *operation = this->getInputOperation(1);
+
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ else {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmin = 0;
+ newInput.ymin = 0;
+ newInput.xmax = this->getWidth();
+ newInput.ymax = this->getHeight();
+ }
+ else {
+ int addx = this->m_radx;
+ int addy = this->m_rady;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+ }
+ return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
// reference image
GaussianBlurReferenceOperation::GaussianBlurReferenceOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_maintabs = NULL;
+ this->m_maintabs = NULL;
}
void *GaussianBlurReferenceOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- return buffer;
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ return buffer;
}
void GaussianBlurReferenceOperation::initExecution()
{
- BlurBaseOperation::initExecution();
- // setup gaustab
- this->m_data.image_in_width = this->getWidth();
- this->m_data.image_in_height = this->getHeight();
- if (this->m_data.relative) {
- switch (this->m_data.aspect) {
- case CMP_NODE_BLUR_ASPECT_NONE:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
- break;
- case CMP_NODE_BLUR_ASPECT_Y:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
- break;
- case CMP_NODE_BLUR_ASPECT_X:
- this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
- this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
- break;
- }
- }
-
-
- /* horizontal */
- m_filtersizex = (float)this->m_data.sizex;
- int imgx = getWidth() / 2;
- if (m_filtersizex > imgx)
- m_filtersizex = imgx;
- else if (m_filtersizex < 1)
- m_filtersizex = 1;
- m_radx = (float)m_filtersizex;
-
- /* vertical */
- m_filtersizey = (float)this->m_data.sizey;
- int imgy = getHeight() / 2;
- if (m_filtersizey > imgy)
- m_filtersizey = imgy;
- else if (m_filtersizey < 1)
- m_filtersizey = 1;
- m_rady = (float)m_filtersizey;
- updateGauss();
+ BlurBaseOperation::initExecution();
+ // setup gaustab
+ this->m_data.image_in_width = this->getWidth();
+ this->m_data.image_in_height = this->getHeight();
+ if (this->m_data.relative) {
+ switch (this->m_data.aspect) {
+ case CMP_NODE_BLUR_ASPECT_NONE:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
+ break;
+ case CMP_NODE_BLUR_ASPECT_Y:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_width);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_width);
+ break;
+ case CMP_NODE_BLUR_ASPECT_X:
+ this->m_data.sizex = (int)(this->m_data.percentx * 0.01f * this->m_data.image_in_height);
+ this->m_data.sizey = (int)(this->m_data.percenty * 0.01f * this->m_data.image_in_height);
+ break;
+ }
+ }
+
+ /* horizontal */
+ m_filtersizex = (float)this->m_data.sizex;
+ int imgx = getWidth() / 2;
+ if (m_filtersizex > imgx)
+ m_filtersizex = imgx;
+ else if (m_filtersizex < 1)
+ m_filtersizex = 1;
+ m_radx = (float)m_filtersizex;
+
+ /* vertical */
+ m_filtersizey = (float)this->m_data.sizey;
+ int imgy = getHeight() / 2;
+ if (m_filtersizey > imgy)
+ m_filtersizey = imgy;
+ else if (m_filtersizey < 1)
+ m_filtersizey = 1;
+ m_rady = (float)m_filtersizey;
+ updateGauss();
}
void GaussianBlurReferenceOperation::updateGauss()
{
- int i;
- int x = max(m_filtersizex, m_filtersizey);
- m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
- for (i = 0; i < x; i++) {
- m_maintabs[i] = make_gausstab(i + 1, i + 1);
- }
+ int i;
+ int x = max(m_filtersizex, m_filtersizey);
+ m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array");
+ for (i = 0; i < x; i++) {
+ m_maintabs[i] = make_gausstab(i + 1, i + 1);
+ }
}
void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *memorybuffer = (MemoryBuffer *)data;
- float *buffer = memorybuffer->getBuffer();
- float *gausstabx, *gausstabcenty;
- float *gausstaby, *gausstabcentx;
- int i, j;
- float *src;
- float sum, val;
- float rval, gval, bval, aval;
- int imgx = getWidth();
- int imgy = getHeight();
- float tempSize[4];
- this->m_inputSize->read(tempSize, x, y, data);
- float refSize = tempSize[0];
- int refradx = (int)(refSize * m_radx);
- int refrady = (int)(refSize * m_rady);
- if (refradx > m_filtersizex) refradx = m_filtersizex;
- else if (refradx < 1) refradx = 1;
- if (refrady > m_filtersizey) refrady = m_filtersizey;
- else if (refrady < 1) refrady = 1;
-
- if (refradx == 1 && refrady == 1) {
- memorybuffer->readNoCheck(output, x, y);
- }
- else {
- int minxr = x - refradx < 0 ? -x : -refradx;
- int maxxr = x + refradx > imgx ? imgx - x : refradx;
- int minyr = y - refrady < 0 ? -y : -refrady;
- int maxyr = y + refrady > imgy ? imgy - y : refrady;
-
- float *srcd = buffer + COM_NUM_CHANNELS_COLOR * ( (y + minyr) * imgx + x + minxr);
-
- gausstabx = m_maintabs[refradx - 1];
- gausstabcentx = gausstabx + refradx;
- gausstaby = m_maintabs[refrady - 1];
- gausstabcenty = gausstaby + refrady;
-
- sum = gval = rval = bval = aval = 0.0f;
- for (i = minyr; i < maxyr; i++, srcd += COM_NUM_CHANNELS_COLOR * imgx) {
- src = srcd;
- for (j = minxr; j < maxxr; j++, src += COM_NUM_CHANNELS_COLOR) {
-
- val = gausstabcenty[i] * gausstabcentx[j];
- sum += val;
- rval += val * src[0];
- gval += val * src[1];
- bval += val * src[2];
- aval += val * src[3];
- }
- }
- sum = 1.0f / sum;
- output[0] = rval * sum;
- output[1] = gval * sum;
- output[2] = bval * sum;
- output[3] = aval * sum;
- }
-
+ MemoryBuffer *memorybuffer = (MemoryBuffer *)data;
+ float *buffer = memorybuffer->getBuffer();
+ float *gausstabx, *gausstabcenty;
+ float *gausstaby, *gausstabcentx;
+ int i, j;
+ float *src;
+ float sum, val;
+ float rval, gval, bval, aval;
+ int imgx = getWidth();
+ int imgy = getHeight();
+ float tempSize[4];
+ this->m_inputSize->read(tempSize, x, y, data);
+ float refSize = tempSize[0];
+ int refradx = (int)(refSize * m_radx);
+ int refrady = (int)(refSize * m_rady);
+ if (refradx > m_filtersizex)
+ refradx = m_filtersizex;
+ else if (refradx < 1)
+ refradx = 1;
+ if (refrady > m_filtersizey)
+ refrady = m_filtersizey;
+ else if (refrady < 1)
+ refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ memorybuffer->readNoCheck(output, x, y);
+ }
+ else {
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
+
+ float *srcd = buffer + COM_NUM_CHANNELS_COLOR * ((y + minyr) * imgx + x + minxr);
+
+ gausstabx = m_maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = m_maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minyr; i < maxyr; i++, srcd += COM_NUM_CHANNELS_COLOR * imgx) {
+ src = srcd;
+ for (j = minxr; j < maxxr; j++, src += COM_NUM_CHANNELS_COLOR) {
+
+ val = gausstabcenty[i] * gausstabcentx[j];
+ sum += val;
+ rval += val * src[0];
+ gval += val * src[1];
+ bval += val * src[2];
+ aval += val * src[3];
+ }
+ }
+ sum = 1.0f / sum;
+ output[0] = rval * sum;
+ output[1] = gval * sum;
+ output[2] = bval * sum;
+ output[3] = aval * sum;
+ }
}
void GaussianBlurReferenceOperation::deinitExecution()
{
- int x, i;
- x = max(this->m_filtersizex, this->m_filtersizey);
- for (i = 0; i < x; i++) {
- MEM_freeN(this->m_maintabs[i]);
- }
- MEM_freeN(this->m_maintabs);
- BlurBaseOperation::deinitExecution();
+ int x, i;
+ x = max(this->m_filtersizex, this->m_filtersizey);
+ for (i = 0; i < x; i++) {
+ MEM_freeN(this->m_maintabs[i]);
+ }
+ MEM_freeN(this->m_maintabs);
+ BlurBaseOperation::deinitExecution();
}
-bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- NodeOperation *operation = this->getInputOperation(1);
-
- if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
- return true;
- }
- else {
- int addx = this->m_data.sizex + 2;
- int addy = this->m_data.sizey + 2;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ rcti newInput;
+ NodeOperation *operation = this->getInputOperation(1);
+
+ if (operation->determineDependingAreaOfInterest(input, readOperation, output)) {
+ return true;
+ }
+ else {
+ int addx = this->m_data.sizex + 2;
+ int addy = this->m_data.sizey + 2;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
index c3d6d30b694..99e22cf91c3 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.h
@@ -23,53 +23,57 @@
#include "COM_QualityStepHelper.h"
class GaussianBokehBlurOperation : public BlurBaseOperation {
-private:
- float *m_gausstab;
- int m_radx, m_rady;
- void updateGauss();
+ private:
+ float *m_gausstab;
+ int m_radx, m_rady;
+ void updateGauss();
-public:
- GaussianBokehBlurOperation();
- void initExecution();
- void *initializeTileData(rcti *rect);
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ GaussianBokehBlurOperation();
+ void initExecution();
+ void *initializeTileData(rcti *rect);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
class GaussianBlurReferenceOperation : public BlurBaseOperation {
-private:
- float **m_maintabs;
+ private:
+ float **m_maintabs;
- void updateGauss();
- int m_filtersizex;
- int m_filtersizey;
- float m_radx;
- float m_rady;
+ void updateGauss();
+ int m_filtersizex;
+ int m_filtersizey;
+ float m_radx;
+ float m_rady;
-public:
- GaussianBlurReferenceOperation();
- void initExecution();
- void *initializeTileData(rcti *rect);
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ GaussianBlurReferenceOperation();
+ void initExecution();
+ void *initializeTileData(rcti *rect);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index c8c1db24b08..29a50f5350a 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -22,175 +22,187 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = NULL;
#ifdef __SSE2__
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = NULL;
#endif
- this->m_filtersize = 0;
+ this->m_filtersize = 0;
}
void *GaussianXBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianXBlurOperation::initExecution()
{
- BlurBaseOperation::initExecution();
+ BlurBaseOperation::initExecution();
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data.sizex, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_sizeavailable) {
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- /* TODO(sergey): De-duplicate with the case below and Y blur. */
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ /* TODO(sergey): De-duplicate with the case below and Y blur. */
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
- this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
- m_filtersize);
+ this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
#endif
- }
+ }
}
void GaussianXBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizex, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_gausstab == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
- this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
- m_filtersize);
+ this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
#endif
- }
+ }
}
void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float multiplier_accum = 0.0f;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int xmin = max_ii(x - m_filtersize, rect.xmin);
- int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
- int ymin = max_ii(y, rect.ymin);
-
- int step = getStep();
- int offsetadd = getOffsetAdd();
- int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth);
+ float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float multiplier_accum = 0.0f;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x - m_filtersize, rect.xmin);
+ int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
+ int ymin = max_ii(y, rect.ymin);
+
+ int step = getStep();
+ int offsetadd = getOffsetAdd();
+ int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth);
#ifdef __SSE2__
- __m128 accum_r = _mm_load_ps(color_accum);
- for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax; nx += step, index += step) {
- __m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
- reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
- accum_r = _mm_add_ps(accum_r, reg_a);
- multiplier_accum += this->m_gausstab[index];
- bufferindex += offsetadd;
- }
- _mm_store_ps(color_accum, accum_r);
+ __m128 accum_r = _mm_load_ps(color_accum);
+ for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax;
+ nx += step, index += step) {
+ __m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
+ reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
+ accum_r = _mm_add_ps(accum_r, reg_a);
+ multiplier_accum += this->m_gausstab[index];
+ bufferindex += offsetadd;
+ }
+ _mm_store_ps(color_accum, accum_r);
#else
- for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax; nx += step, index += step) {
- const float multiplier = this->m_gausstab[index];
- madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
- multiplier_accum += multiplier;
- bufferindex += offsetadd;
- }
+ for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax;
+ nx += step, index += step) {
+ const float multiplier = this->m_gausstab[index];
+ madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
+ multiplier_accum += multiplier;
+ bufferindex += offsetadd;
+ }
#endif
- mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
+ mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
}
void GaussianXBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel gaussianXBlurOperationKernel = device->COM_clCreateKernel("gaussianXBlurOperationKernel", NULL);
- cl_int filter_size = this->m_filtersize;
-
- cl_mem gausstab = clCreateBuffer(device->getContext(),
- CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
- sizeof(float) * (this->m_filtersize * 2 + 1),
- this->m_gausstab,
- NULL);
-
- device->COM_clAttachMemoryBufferToKernelParameter(gaussianXBlurOperationKernel, 0, 1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(gaussianXBlurOperationKernel, 2, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(gaussianXBlurOperationKernel, 3, outputMemoryBuffer);
- clSetKernelArg(gaussianXBlurOperationKernel, 4, sizeof(cl_int), &filter_size);
- device->COM_clAttachSizeToKernelParameter(gaussianXBlurOperationKernel, 5, this);
- clSetKernelArg(gaussianXBlurOperationKernel, 6, sizeof(cl_mem), &gausstab);
-
- device->COM_clEnqueueRange(gaussianXBlurOperationKernel, outputMemoryBuffer, 7, this);
-
- clReleaseMemObject(gausstab);
+ cl_kernel gaussianXBlurOperationKernel = device->COM_clCreateKernel(
+ "gaussianXBlurOperationKernel", NULL);
+ cl_int filter_size = this->m_filtersize;
+
+ cl_mem gausstab = clCreateBuffer(device->getContext(),
+ CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
+ sizeof(float) * (this->m_filtersize * 2 + 1),
+ this->m_gausstab,
+ NULL);
+
+ device->COM_clAttachMemoryBufferToKernelParameter(gaussianXBlurOperationKernel,
+ 0,
+ 1,
+ clMemToCleanUp,
+ inputMemoryBuffers,
+ this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(
+ gaussianXBlurOperationKernel, 2, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(
+ gaussianXBlurOperationKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(gaussianXBlurOperationKernel, 4, sizeof(cl_int), &filter_size);
+ device->COM_clAttachSizeToKernelParameter(gaussianXBlurOperationKernel, 5, this);
+ clSetKernelArg(gaussianXBlurOperationKernel, 6, sizeof(cl_mem), &gausstab);
+
+ device->COM_clEnqueueRange(gaussianXBlurOperationKernel, outputMemoryBuffer, 7, this);
+
+ clReleaseMemObject(gausstab);
}
void GaussianXBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
#ifdef __SSE2__
- if (this->m_gausstab_sse) {
- MEM_freeN(this->m_gausstab_sse);
- this->m_gausstab_sse = NULL;
- }
+ if (this->m_gausstab_sse) {
+ MEM_freeN(this->m_gausstab_sse);
+ this->m_gausstab_sse = NULL;
+ }
#endif
- deinitMutex();
+ deinitMutex();
}
-bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
-
- if (!this->m_sizeavailable) {
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- }
- {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax + this->m_filtersize + 1;
- newInput.xmin = input->xmin - this->m_filtersize - 1;
- newInput.ymax = input->ymax;
- newInput.ymin = input->ymin;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ rcti newInput;
+
+ if (!this->m_sizeavailable) {
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ }
+ {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmax = input->xmax + this->m_filtersize + 1;
+ newInput.xmin = input->xmin - this->m_filtersize - 1;
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
index ad9d718b86a..3ebe52cfcce 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.h
@@ -22,41 +22,47 @@
#include "COM_BlurBaseOperation.h"
class GaussianXBlurOperation : public BlurBaseOperation {
-private:
- float *m_gausstab;
+ private:
+ float *m_gausstab;
#ifdef __SSE2__
- __m128 *m_gausstab_sse;
+ __m128 *m_gausstab_sse;
#endif
- int m_filtersize;
- void updateGauss();
-public:
- GaussianXBlurOperation();
-
- /**
- * \brief the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
-
- /**
- * \brief initialize the execution
- */
- void initExecution();
-
- /**
- * \brief Deinitialize the execution
- */
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void checkOpenCL() {
- this->setOpenCL(m_data.sizex >= 128);
- }
+ int m_filtersize;
+ void updateGauss();
+
+ public:
+ GaussianXBlurOperation();
+
+ /**
+ * \brief the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
+
+ /**
+ * \brief initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * \brief Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void checkOpenCL()
+ {
+ this->setOpenCL(m_data.sizex >= 128);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index 168dbddf400..500e0fbedc3 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -22,177 +22,187 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
- this->m_gausstab = NULL;
+ this->m_gausstab = NULL;
#ifdef __SSE2__
- this->m_gausstab_sse = NULL;
+ this->m_gausstab_sse = NULL;
#endif
- this->m_filtersize = 0;
+ this->m_filtersize = 0;
}
void *GaussianYBlurOperation::initializeTileData(rcti * /*rect*/)
{
- lockMutex();
- if (!this->m_sizeavailable) {
- updateGauss();
- }
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- unlockMutex();
- return buffer;
+ lockMutex();
+ if (!this->m_sizeavailable) {
+ updateGauss();
+ }
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ unlockMutex();
+ return buffer;
}
void GaussianYBlurOperation::initExecution()
{
- BlurBaseOperation::initExecution();
+ BlurBaseOperation::initExecution();
- initMutex();
+ initMutex();
- if (this->m_sizeavailable) {
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_sizeavailable) {
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
- this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
- m_filtersize);
+ this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
#endif
- }
+ }
}
void GaussianYBlurOperation::updateGauss()
{
- if (this->m_gausstab == NULL) {
- updateSize();
- float rad = max_ff(m_size * m_data.sizey, 0.0f);
- m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+ if (this->m_gausstab == NULL) {
+ updateSize();
+ float rad = max_ff(m_size * m_data.sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
#ifdef __SSE2__
- this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab,
- m_filtersize);
+ this->m_gausstab_sse = BlurBaseOperation::convert_gausstab_sse(this->m_gausstab, m_filtersize);
#endif
- }
+ }
}
void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- float multiplier_accum = 0.0f;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
- int bufferwidth = inputBuffer->getWidth();
- int bufferstartx = inputBuffer->getRect()->xmin;
- int bufferstarty = inputBuffer->getRect()->ymin;
-
- rcti &rect = *inputBuffer->getRect();
- int xmin = max_ii(x, rect.xmin);
- int ymin = max_ii(y - m_filtersize, rect.ymin);
- int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
-
- int index;
- int step = getStep();
- const int bufferIndexx = ((xmin - bufferstartx) * 4);
+ float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ float multiplier_accum = 0.0f;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+ int bufferwidth = inputBuffer->getWidth();
+ int bufferstartx = inputBuffer->getRect()->xmin;
+ int bufferstarty = inputBuffer->getRect()->ymin;
+
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x, rect.xmin);
+ int ymin = max_ii(y - m_filtersize, rect.ymin);
+ int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
+
+ int index;
+ int step = getStep();
+ const int bufferIndexx = ((xmin - bufferstartx) * 4);
#ifdef __SSE2__
- __m128 accum_r = _mm_load_ps(color_accum);
- for (int ny = ymin; ny < ymax; ny += step) {
- index = (ny - y) + this->m_filtersize;
- int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
- const float multiplier = this->m_gausstab[index];
- __m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
- reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
- accum_r = _mm_add_ps(accum_r, reg_a);
- multiplier_accum += multiplier;
- }
- _mm_store_ps(color_accum, accum_r);
+ __m128 accum_r = _mm_load_ps(color_accum);
+ for (int ny = ymin; ny < ymax; ny += step) {
+ index = (ny - y) + this->m_filtersize;
+ int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
+ const float multiplier = this->m_gausstab[index];
+ __m128 reg_a = _mm_load_ps(&buffer[bufferindex]);
+ reg_a = _mm_mul_ps(reg_a, this->m_gausstab_sse[index]);
+ accum_r = _mm_add_ps(accum_r, reg_a);
+ multiplier_accum += multiplier;
+ }
+ _mm_store_ps(color_accum, accum_r);
#else
- for (int ny = ymin; ny < ymax; ny += step) {
- index = (ny - y) + this->m_filtersize;
- int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
- const float multiplier = this->m_gausstab[index];
- madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
- multiplier_accum += multiplier;
- }
+ for (int ny = ymin; ny < ymax; ny += step) {
+ index = (ny - y) + this->m_filtersize;
+ int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth);
+ const float multiplier = this->m_gausstab[index];
+ madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
+ multiplier_accum += multiplier;
+ }
#endif
- mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
+ mul_v4_v4fl(output, color_accum, 1.0f / multiplier_accum);
}
void GaussianYBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel gaussianYBlurOperationKernel = device->COM_clCreateKernel("gaussianYBlurOperationKernel", NULL);
- cl_int filter_size = this->m_filtersize;
-
- cl_mem gausstab = clCreateBuffer(device->getContext(),
- CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
- sizeof(float) * (this->m_filtersize * 2 + 1),
- this->m_gausstab,
- NULL);
-
- device->COM_clAttachMemoryBufferToKernelParameter(gaussianYBlurOperationKernel, 0, 1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(gaussianYBlurOperationKernel, 2, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(gaussianYBlurOperationKernel, 3, outputMemoryBuffer);
- clSetKernelArg(gaussianYBlurOperationKernel, 4, sizeof(cl_int), &filter_size);
- device->COM_clAttachSizeToKernelParameter(gaussianYBlurOperationKernel, 5, this);
- clSetKernelArg(gaussianYBlurOperationKernel, 6, sizeof(cl_mem), &gausstab);
-
- device->COM_clEnqueueRange(gaussianYBlurOperationKernel, outputMemoryBuffer, 7, this);
-
- clReleaseMemObject(gausstab);
+ cl_kernel gaussianYBlurOperationKernel = device->COM_clCreateKernel(
+ "gaussianYBlurOperationKernel", NULL);
+ cl_int filter_size = this->m_filtersize;
+
+ cl_mem gausstab = clCreateBuffer(device->getContext(),
+ CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
+ sizeof(float) * (this->m_filtersize * 2 + 1),
+ this->m_gausstab,
+ NULL);
+
+ device->COM_clAttachMemoryBufferToKernelParameter(gaussianYBlurOperationKernel,
+ 0,
+ 1,
+ clMemToCleanUp,
+ inputMemoryBuffers,
+ this->m_inputProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(
+ gaussianYBlurOperationKernel, 2, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(
+ gaussianYBlurOperationKernel, 3, outputMemoryBuffer);
+ clSetKernelArg(gaussianYBlurOperationKernel, 4, sizeof(cl_int), &filter_size);
+ device->COM_clAttachSizeToKernelParameter(gaussianYBlurOperationKernel, 5, this);
+ clSetKernelArg(gaussianYBlurOperationKernel, 6, sizeof(cl_mem), &gausstab);
+
+ device->COM_clEnqueueRange(gaussianYBlurOperationKernel, outputMemoryBuffer, 7, this);
+
+ clReleaseMemObject(gausstab);
}
void GaussianYBlurOperation::deinitExecution()
{
- BlurBaseOperation::deinitExecution();
+ BlurBaseOperation::deinitExecution();
- if (this->m_gausstab) {
- MEM_freeN(this->m_gausstab);
- this->m_gausstab = NULL;
- }
+ if (this->m_gausstab) {
+ MEM_freeN(this->m_gausstab);
+ this->m_gausstab = NULL;
+ }
#ifdef __SSE2__
- if (this->m_gausstab_sse) {
- MEM_freeN(this->m_gausstab_sse);
- this->m_gausstab_sse = NULL;
- }
+ if (this->m_gausstab_sse) {
+ MEM_freeN(this->m_gausstab_sse);
+ this->m_gausstab_sse = NULL;
+ }
#endif
- deinitMutex();
+ deinitMutex();
}
-bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
-
- if (!m_sizeavailable) {
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
- }
- }
- {
- if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax;
- newInput.xmin = input->xmin;
- newInput.ymax = input->ymax + this->m_filtersize + 1;
- newInput.ymin = input->ymin - this->m_filtersize - 1;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ rcti newInput;
+
+ if (!m_sizeavailable) {
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
+ }
+ {
+ if (this->m_sizeavailable && this->m_gausstab != NULL) {
+ newInput.xmax = input->xmax;
+ newInput.xmin = input->xmin;
+ newInput.ymax = input->ymax + this->m_filtersize + 1;
+ newInput.ymin = input->ymin - this->m_filtersize - 1;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
index 9d4e3d62055..ce8e0a7b781 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.h
@@ -22,41 +22,47 @@
#include "COM_BlurBaseOperation.h"
class GaussianYBlurOperation : public BlurBaseOperation {
-private:
- float *m_gausstab;
+ private:
+ float *m_gausstab;
#ifdef __SSE2__
- __m128 *m_gausstab_sse;
+ __m128 *m_gausstab_sse;
#endif
- int m_filtersize;
- void updateGauss();
-public:
- GaussianYBlurOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- void executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> *clKernelsToCleanUp);
-
- /**
- * \brief initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void checkOpenCL() {
- this->setOpenCL(m_data.sizex >= 128);
- }
+ int m_filtersize;
+ void updateGauss();
+
+ public:
+ GaussianYBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
+
+ /**
+ * \brief initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void checkOpenCL()
+ {
+ this->setOpenCL(m_data.sizex >= 128);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
index 1d98ef65671..593f1eaeefa 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp
@@ -21,47 +21,49 @@
GlareBaseOperation::GlareBaseOperation() : SingleThreadedOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_settings = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_settings = NULL;
}
void GlareBaseOperation::initExecution()
{
- SingleThreadedOperation::initExecution();
- this->m_inputProgram = getInputSocketReader(0);
+ SingleThreadedOperation::initExecution();
+ this->m_inputProgram = getInputSocketReader(0);
}
void GlareBaseOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- SingleThreadedOperation::deinitExecution();
+ this->m_inputProgram = NULL;
+ SingleThreadedOperation::deinitExecution();
}
MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2)
{
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2);
- rcti rect;
- rect.xmin = 0;
- rect.ymin = 0;
- rect.xmax = getWidth();
- rect.ymax = getHeight();
- MemoryBuffer *result = new MemoryBuffer(COM_DT_COLOR, &rect);
- float *data = result->getBuffer();
- this->generateGlare(data, tile, this->m_settings);
- return result;
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect2);
+ rcti rect;
+ rect.xmin = 0;
+ rect.ymin = 0;
+ rect.xmax = getWidth();
+ rect.ymax = getHeight();
+ MemoryBuffer *result = new MemoryBuffer(COM_DT_COLOR, &rect);
+ float *data = result->getBuffer();
+ this->generateGlare(data, tile, this->m_settings);
+ return result;
}
-bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- if (isCached()) {
- return false;
- }
- else {
- rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ if (isCached()) {
+ return false;
+ }
+ else {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.h b/source/blender/compositor/operations/COM_GlareBaseOperation.h
index 3353b087b3b..ba2b9a8f4b8 100644
--- a/source/blender/compositor/operations/COM_GlareBaseOperation.h
+++ b/source/blender/compositor/operations/COM_GlareBaseOperation.h
@@ -22,49 +22,56 @@
#include "COM_SingleThreadedOperation.h"
#include "DNA_node_types.h"
-
/* utility functions used by glare, tonemap and lens distortion */
/* soms macros for color handling */
typedef float fRGB[4];
/* TODO - replace with BLI_math_vector */
/* multiply c2 by color rgb, rgb as separate arguments */
-#define fRGB_rgbmult(c, r, g, b) { c[0] *= (r); c[1] *= (g); c[2] *= (b); } (void)0
-
+#define fRGB_rgbmult(c, r, g, b) \
+ { \
+ c[0] *= (r); \
+ c[1] *= (g); \
+ c[2] *= (b); \
+ } \
+ (void)0
class GlareBaseOperation : public SingleThreadedOperation {
-private:
- /**
- * \brief Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
+ private:
+ /**
+ * \brief Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
- /**
- * \brief settings of the glare node.
- */
- NodeGlare *m_settings;
-public:
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * \brief settings of the glare node.
+ */
+ NodeGlare *m_settings;
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ public:
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setGlareSettings(NodeGlare *settings) {
- this->m_settings = settings;
- }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
-protected:
- GlareBaseOperation();
+ void setGlareSettings(NodeGlare *settings)
+ {
+ this->m_settings = settings;
+ }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- virtual void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) = 0;
+ protected:
+ GlareBaseOperation();
- MemoryBuffer *createMemoryBuffer(rcti *rect);
+ virtual void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) = 0;
+ MemoryBuffer *createMemoryBuffer(rcti *rect);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
index c74c1899daa..e0a2790b318 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp
@@ -28,12 +28,16 @@ typedef float fREAL;
// returns next highest power of 2 of x, as well it's log2 in L2
static unsigned int nextPow2(unsigned int x, unsigned int *L2)
{
- unsigned int pw, x_notpow2 = x & (x - 1);
- *L2 = 0;
- while (x >>= 1) ++(*L2);
- pw = 1 << (*L2);
- if (x_notpow2) { (*L2)++; pw <<= 1; }
- return pw;
+ unsigned int pw, x_notpow2 = x & (x - 1);
+ *L2 = 0;
+ while (x >>= 1)
+ ++(*L2);
+ pw = 1 << (*L2);
+ if (x_notpow2) {
+ (*L2)++;
+ pw <<= 1;
+ }
+ return pw;
}
//------------------------------------------------------------------------------
@@ -42,143 +46,145 @@ static unsigned int nextPow2(unsigned int x, unsigned int *L2)
// use: r = revbin_upd(r, h) where h = N>>1
static unsigned int revbin_upd(unsigned int r, unsigned int h)
{
- while (!((r ^= h) & h)) h >>= 1;
- return r;
+ while (!((r ^= h) & h))
+ h >>= 1;
+ return r;
}
//------------------------------------------------------------------------------
static void FHT(fREAL *data, unsigned int M, unsigned int inverse)
{
- double tt, fc, dc, fs, ds, a = M_PI;
- fREAL t1, t2;
- int n2, bd, bl, istep, k, len = 1 << M, n = 1;
-
- int i, j = 0;
- unsigned int Nh = len >> 1;
- for (i = 1; i < (len - 1); ++i) {
- j = revbin_upd(j, Nh);
- if (j > i) {
- t1 = data[i];
- data[i] = data[j];
- data[j] = t1;
- }
- }
-
- do {
- fREAL *data_n = &data[n];
-
- istep = n << 1;
- for (k = 0; k < len; k += istep) {
- t1 = data_n[k];
- data_n[k] = data[k] - t1;
- data[k] += t1;
- }
-
- n2 = n >> 1;
- if (n > 2) {
- fc = dc = cos(a);
- fs = ds = sqrt(1.0 - fc * fc); //sin(a);
- bd = n - 2;
- for (bl = 1; bl < n2; bl++) {
- fREAL *data_nbd = &data_n[bd];
- fREAL *data_bd = &data[bd];
- for (k = bl; k < len; k += istep) {
- t1 = fc * (double)data_n[k] + fs * (double)data_nbd[k];
- t2 = fs * (double)data_n[k] - fc * (double)data_nbd[k];
- data_n[k] = data[k] - t1;
- data_nbd[k] = data_bd[k] - t2;
- data[k] += t1;
- data_bd[k] += t2;
- }
- tt = fc * dc - fs * ds;
- fs = fs * dc + fc * ds;
- fc = tt;
- bd -= 2;
- }
- }
-
- if (n > 1) {
- for (k = n2; k < len; k += istep) {
- t1 = data_n[k];
- data_n[k] = data[k] - t1;
- data[k] += t1;
- }
- }
-
- n = istep;
- a *= 0.5;
- } while (n < len);
-
- if (inverse) {
- fREAL sc = (fREAL)1 / (fREAL)len;
- for (k = 0; k < len; ++k)
- data[k] *= sc;
- }
+ double tt, fc, dc, fs, ds, a = M_PI;
+ fREAL t1, t2;
+ int n2, bd, bl, istep, k, len = 1 << M, n = 1;
+
+ int i, j = 0;
+ unsigned int Nh = len >> 1;
+ for (i = 1; i < (len - 1); ++i) {
+ j = revbin_upd(j, Nh);
+ if (j > i) {
+ t1 = data[i];
+ data[i] = data[j];
+ data[j] = t1;
+ }
+ }
+
+ do {
+ fREAL *data_n = &data[n];
+
+ istep = n << 1;
+ for (k = 0; k < len; k += istep) {
+ t1 = data_n[k];
+ data_n[k] = data[k] - t1;
+ data[k] += t1;
+ }
+
+ n2 = n >> 1;
+ if (n > 2) {
+ fc = dc = cos(a);
+ fs = ds = sqrt(1.0 - fc * fc); //sin(a);
+ bd = n - 2;
+ for (bl = 1; bl < n2; bl++) {
+ fREAL *data_nbd = &data_n[bd];
+ fREAL *data_bd = &data[bd];
+ for (k = bl; k < len; k += istep) {
+ t1 = fc * (double)data_n[k] + fs * (double)data_nbd[k];
+ t2 = fs * (double)data_n[k] - fc * (double)data_nbd[k];
+ data_n[k] = data[k] - t1;
+ data_nbd[k] = data_bd[k] - t2;
+ data[k] += t1;
+ data_bd[k] += t2;
+ }
+ tt = fc * dc - fs * ds;
+ fs = fs * dc + fc * ds;
+ fc = tt;
+ bd -= 2;
+ }
+ }
+
+ if (n > 1) {
+ for (k = n2; k < len; k += istep) {
+ t1 = data_n[k];
+ data_n[k] = data[k] - t1;
+ data[k] += t1;
+ }
+ }
+
+ n = istep;
+ a *= 0.5;
+ } while (n < len);
+
+ if (inverse) {
+ fREAL sc = (fREAL)1 / (fREAL)len;
+ for (k = 0; k < len; ++k)
+ data[k] *= sc;
+ }
}
//------------------------------------------------------------------------------
/* 2D Fast Hartley Transform, Mx/My -> log2 of width/height,
* nzp -> the row where zero pad data starts,
* inverse -> see above */
-static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My,
- unsigned int nzp, unsigned int inverse)
+static void FHT2D(
+ fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse)
{
- unsigned int i, j, Nx, Ny, maxy;
-
- Nx = 1 << Mx;
- Ny = 1 << My;
-
- // rows (forward transform skips 0 pad data)
- maxy = inverse ? Ny : nzp;
- for (j = 0; j < maxy; ++j)
- FHT(&data[Nx * j], Mx, inverse);
-
- // transpose data
- if (Nx == Ny) { // square
- for (j = 0; j < Ny; ++j)
- for (i = j + 1; i < Nx; ++i) {
- unsigned int op = i + (j << Mx), np = j + (i << My);
- SWAP(fREAL, data[op], data[np]);
- }
- }
- else { // rectangular
- unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My);
- for (i = 0; stm > 0; i++) {
+ unsigned int i, j, Nx, Ny, maxy;
+
+ Nx = 1 << Mx;
+ Ny = 1 << My;
+
+ // rows (forward transform skips 0 pad data)
+ maxy = inverse ? Ny : nzp;
+ for (j = 0; j < maxy; ++j)
+ FHT(&data[Nx * j], Mx, inverse);
+
+ // transpose data
+ if (Nx == Ny) { // square
+ for (j = 0; j < Ny; ++j)
+ for (i = j + 1; i < Nx; ++i) {
+ unsigned int op = i + (j << Mx), np = j + (i << My);
+ SWAP(fREAL, data[op], data[np]);
+ }
+ }
+ else { // rectangular
+ unsigned int k, Nym = Ny - 1, stm = 1 << (Mx + My);
+ for (i = 0; stm > 0; i++) {
#define PRED(k) (((k & Nym) << Mx) + (k >> My))
- for (j = PRED(i); j > i; j = PRED(j)) ;
- if (j < i) continue;
- for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
- SWAP(fREAL, data[j], data[k]);
- }
+ for (j = PRED(i); j > i; j = PRED(j))
+ ;
+ if (j < i)
+ continue;
+ for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
+ SWAP(fREAL, data[j], data[k]);
+ }
#undef PRED
- stm--;
- }
- }
-
- SWAP(unsigned int, Nx, Ny);
- SWAP(unsigned int, Mx, My);
-
- // now columns == transposed rows
- for (j = 0; j < Ny; ++j)
- FHT(&data[Nx * j], Mx, inverse);
-
- // finalize
- for (j = 0; j <= (Ny >> 1); j++) {
- unsigned int jm = (Ny - j) & (Ny - 1);
- unsigned int ji = j << Mx;
- unsigned int jmi = jm << Mx;
- for (i = 0; i <= (Nx >> 1); i++) {
- unsigned int im = (Nx - i) & (Nx - 1);
- fREAL A = data[ji + i];
- fREAL B = data[jmi + i];
- fREAL C = data[ji + im];
- fREAL D = data[jmi + im];
- fREAL E = (fREAL)0.5 * ((A + D) - (B + C));
- data[ji + i] = A - E;
- data[jmi + i] = B + E;
- data[ji + im] = C + E;
- data[jmi + im] = D - E;
- }
- }
-
+ stm--;
+ }
+ }
+
+ SWAP(unsigned int, Nx, Ny);
+ SWAP(unsigned int, Mx, My);
+
+ // now columns == transposed rows
+ for (j = 0; j < Ny; ++j)
+ FHT(&data[Nx * j], Mx, inverse);
+
+ // finalize
+ for (j = 0; j <= (Ny >> 1); j++) {
+ unsigned int jm = (Ny - j) & (Ny - 1);
+ unsigned int ji = j << Mx;
+ unsigned int jmi = jm << Mx;
+ for (i = 0; i <= (Nx >> 1); i++) {
+ unsigned int im = (Nx - i) & (Nx - 1);
+ fREAL A = data[ji + i];
+ fREAL B = data[jmi + i];
+ fREAL C = data[ji + im];
+ fREAL D = data[jmi + im];
+ fREAL E = (fREAL)0.5 * ((A + D) - (B + C));
+ data[ji + i] = A - E;
+ data[jmi + i] = B + E;
+ data[ji + im] = C + E;
+ data[jmi + im] = D - E;
+ }
+ }
}
//------------------------------------------------------------------------------
@@ -186,218 +192,232 @@ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My,
/* 2D convolution calc, d1 *= d2, M/N - > log2 of width/height */
static void fht_convolve(fREAL *d1, fREAL *d2, unsigned int M, unsigned int N)
{
- fREAL a, b;
- unsigned int i, j, k, L, mj, mL;
- unsigned int m = 1 << M, n = 1 << N;
- unsigned int m2 = 1 << (M - 1), n2 = 1 << (N - 1);
- unsigned int mn2 = m << (N - 1);
-
- d1[0] *= d2[0];
- d1[mn2] *= d2[mn2];
- d1[m2] *= d2[m2];
- d1[m2 + mn2] *= d2[m2 + mn2];
- for (i = 1; i < m2; i++) {
- k = m - i;
- a = d1[i] * d2[i] - d1[k] * d2[k];
- b = d1[k] * d2[i] + d1[i] * d2[k];
- d1[i] = (b + a) * (fREAL)0.5;
- d1[k] = (b - a) * (fREAL)0.5;
- a = d1[i + mn2] * d2[i + mn2] - d1[k + mn2] * d2[k + mn2];
- b = d1[k + mn2] * d2[i + mn2] + d1[i + mn2] * d2[k + mn2];
- d1[i + mn2] = (b + a) * (fREAL)0.5;
- d1[k + mn2] = (b - a) * (fREAL)0.5;
- }
- for (j = 1; j < n2; j++) {
- L = n - j;
- mj = j << M;
- mL = L << M;
- a = d1[mj] * d2[mj] - d1[mL] * d2[mL];
- b = d1[mL] * d2[mj] + d1[mj] * d2[mL];
- d1[mj] = (b + a) * (fREAL)0.5;
- d1[mL] = (b - a) * (fREAL)0.5;
- a = d1[m2 + mj] * d2[m2 + mj] - d1[m2 + mL] * d2[m2 + mL];
- b = d1[m2 + mL] * d2[m2 + mj] + d1[m2 + mj] * d2[m2 + mL];
- d1[m2 + mj] = (b + a) * (fREAL)0.5;
- d1[m2 + mL] = (b - a) * (fREAL)0.5;
- }
- for (i = 1; i < m2; i++) {
- k = m - i;
- for (j = 1; j < n2; j++) {
- L = n - j;
- mj = j << M;
- mL = L << M;
- a = d1[i + mj] * d2[i + mj] - d1[k + mL] * d2[k + mL];
- b = d1[k + mL] * d2[i + mj] + d1[i + mj] * d2[k + mL];
- d1[i + mj] = (b + a) * (fREAL)0.5;
- d1[k + mL] = (b - a) * (fREAL)0.5;
- a = d1[i + mL] * d2[i + mL] - d1[k + mj] * d2[k + mj];
- b = d1[k + mj] * d2[i + mL] + d1[i + mL] * d2[k + mj];
- d1[i + mL] = (b + a) * (fREAL)0.5;
- d1[k + mj] = (b - a) * (fREAL)0.5;
- }
- }
+ fREAL a, b;
+ unsigned int i, j, k, L, mj, mL;
+ unsigned int m = 1 << M, n = 1 << N;
+ unsigned int m2 = 1 << (M - 1), n2 = 1 << (N - 1);
+ unsigned int mn2 = m << (N - 1);
+
+ d1[0] *= d2[0];
+ d1[mn2] *= d2[mn2];
+ d1[m2] *= d2[m2];
+ d1[m2 + mn2] *= d2[m2 + mn2];
+ for (i = 1; i < m2; i++) {
+ k = m - i;
+ a = d1[i] * d2[i] - d1[k] * d2[k];
+ b = d1[k] * d2[i] + d1[i] * d2[k];
+ d1[i] = (b + a) * (fREAL)0.5;
+ d1[k] = (b - a) * (fREAL)0.5;
+ a = d1[i + mn2] * d2[i + mn2] - d1[k + mn2] * d2[k + mn2];
+ b = d1[k + mn2] * d2[i + mn2] + d1[i + mn2] * d2[k + mn2];
+ d1[i + mn2] = (b + a) * (fREAL)0.5;
+ d1[k + mn2] = (b - a) * (fREAL)0.5;
+ }
+ for (j = 1; j < n2; j++) {
+ L = n - j;
+ mj = j << M;
+ mL = L << M;
+ a = d1[mj] * d2[mj] - d1[mL] * d2[mL];
+ b = d1[mL] * d2[mj] + d1[mj] * d2[mL];
+ d1[mj] = (b + a) * (fREAL)0.5;
+ d1[mL] = (b - a) * (fREAL)0.5;
+ a = d1[m2 + mj] * d2[m2 + mj] - d1[m2 + mL] * d2[m2 + mL];
+ b = d1[m2 + mL] * d2[m2 + mj] + d1[m2 + mj] * d2[m2 + mL];
+ d1[m2 + mj] = (b + a) * (fREAL)0.5;
+ d1[m2 + mL] = (b - a) * (fREAL)0.5;
+ }
+ for (i = 1; i < m2; i++) {
+ k = m - i;
+ for (j = 1; j < n2; j++) {
+ L = n - j;
+ mj = j << M;
+ mL = L << M;
+ a = d1[i + mj] * d2[i + mj] - d1[k + mL] * d2[k + mL];
+ b = d1[k + mL] * d2[i + mj] + d1[i + mj] * d2[k + mL];
+ d1[i + mj] = (b + a) * (fREAL)0.5;
+ d1[k + mL] = (b - a) * (fREAL)0.5;
+ a = d1[i + mL] * d2[i + mL] - d1[k + mj] * d2[k + mj];
+ b = d1[k + mj] * d2[i + mL] + d1[i + mL] * d2[k + mj];
+ d1[i + mL] = (b + a) * (fREAL)0.5;
+ d1[k + mj] = (b - a) * (fREAL)0.5;
+ }
+ }
}
//------------------------------------------------------------------------------
static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
{
- fREAL *data1, *data2, *fp;
- unsigned int w2, h2, hw, hh, log2_w, log2_h;
- fRGB wt, *colp;
- int x, y, ch;
- int xbl, ybl, nxb, nyb, xbsz, ybsz;
- bool in2done = false;
- const unsigned int kernelWidth = in2->getWidth();
- const unsigned int kernelHeight = in2->getHeight();
- const unsigned int imageWidth = in1->getWidth();
- const unsigned int imageHeight = in1->getHeight();
- float *kernelBuffer = in2->getBuffer();
- float *imageBuffer = in1->getBuffer();
-
- MemoryBuffer *rdst = new MemoryBuffer(COM_DT_COLOR, in1->getRect());
- memset(rdst->getBuffer(), 0, rdst->getWidth() * rdst->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
-
- // convolution result width & height
- w2 = 2 * kernelWidth - 1;
- h2 = 2 * kernelHeight - 1;
- // FFT pow2 required size & log2
- w2 = nextPow2(w2, &log2_w);
- h2 = nextPow2(h2, &log2_h);
-
- // alloc space
- data1 = (fREAL *)MEM_callocN(3 * w2 * h2 * sizeof(fREAL), "convolve_fast FHT data1");
- data2 = (fREAL *)MEM_callocN(w2 * h2 * sizeof(fREAL), "convolve_fast FHT data2");
-
- // normalize convolutor
- wt[0] = wt[1] = wt[2] = 0.0f;
- for (y = 0; y < kernelHeight; y++) {
- colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
- add_v3_v3(wt, colp[x]);
- }
- if (wt[0] != 0.0f) wt[0] = 1.0f / wt[0];
- if (wt[1] != 0.0f) wt[1] = 1.0f / wt[1];
- if (wt[2] != 0.0f) wt[2] = 1.0f / wt[2];
- for (y = 0; y < kernelHeight; y++) {
- colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
- mul_v3_v3(colp[x], wt);
- }
-
- // copy image data, unpacking interleaved RGBA into separate channels
- // only need to calc data1 once
-
- // block add-overlap
- hw = kernelWidth >> 1;
- hh = kernelHeight >> 1;
- xbsz = (w2 + 1) - kernelWidth;
- ybsz = (h2 + 1) - kernelHeight;
- nxb = imageWidth / xbsz;
- if (imageWidth % xbsz) nxb++;
- nyb = imageHeight / ybsz;
- if (imageHeight % ybsz) nyb++;
- for (ybl = 0; ybl < nyb; ybl++) {
- for (xbl = 0; xbl < nxb; xbl++) {
-
- // each channel one by one
- for (ch = 0; ch < 3; ch++) {
- fREAL *data1ch = &data1[ch * w2 * h2];
-
- // only need to calc fht data from in2 once, can re-use for every block
- if (!in2done) {
- // in2, channel ch -> data1
- for (y = 0; y < kernelHeight; y++) {
- fp = &data1ch[y * w2];
- colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < kernelWidth; x++)
- fp[x] = colp[x][ch];
- }
- }
-
- // in1, channel ch -> data2
- memset(data2, 0, w2 * h2 * sizeof(fREAL));
- for (y = 0; y < ybsz; y++) {
- int yy = ybl * ybsz + y;
- if (yy >= imageHeight) continue;
- fp = &data2[y * w2];
- colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < xbsz; x++) {
- int xx = xbl * xbsz + x;
- if (xx >= imageWidth) continue;
- fp[x] = colp[xx][ch];
- }
- }
-
- // forward FHT
- // zero pad data start is different for each == height+1
- if (!in2done) FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0);
- FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0);
-
- // FHT2D transposed data, row/col now swapped
- // convolve & inverse FHT
- fht_convolve(data2, data1ch, log2_h, log2_w);
- FHT2D(data2, log2_h, log2_w, 0, 1);
- // data again transposed, so in order again
-
- // overlap-add result
- for (y = 0; y < (int)h2; y++) {
- const int yy = ybl * ybsz + y - hh;
- if ((yy < 0) || (yy >= imageHeight)) continue;
- fp = &data2[y * w2];
- colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
- for (x = 0; x < (int)w2; x++) {
- const int xx = xbl * xbsz + x - hw;
- if ((xx < 0) || (xx >= imageWidth)) continue;
- colp[xx][ch] += fp[x];
- }
- }
-
- }
- in2done = true;
- }
- }
-
- MEM_freeN(data2);
- MEM_freeN(data1);
- memcpy(dst, rdst->getBuffer(), sizeof(float) * imageWidth * imageHeight * COM_NUM_CHANNELS_COLOR);
- delete(rdst);
+ fREAL *data1, *data2, *fp;
+ unsigned int w2, h2, hw, hh, log2_w, log2_h;
+ fRGB wt, *colp;
+ int x, y, ch;
+ int xbl, ybl, nxb, nyb, xbsz, ybsz;
+ bool in2done = false;
+ const unsigned int kernelWidth = in2->getWidth();
+ const unsigned int kernelHeight = in2->getHeight();
+ const unsigned int imageWidth = in1->getWidth();
+ const unsigned int imageHeight = in1->getHeight();
+ float *kernelBuffer = in2->getBuffer();
+ float *imageBuffer = in1->getBuffer();
+
+ MemoryBuffer *rdst = new MemoryBuffer(COM_DT_COLOR, in1->getRect());
+ memset(rdst->getBuffer(),
+ 0,
+ rdst->getWidth() * rdst->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
+
+ // convolution result width & height
+ w2 = 2 * kernelWidth - 1;
+ h2 = 2 * kernelHeight - 1;
+ // FFT pow2 required size & log2
+ w2 = nextPow2(w2, &log2_w);
+ h2 = nextPow2(h2, &log2_h);
+
+ // alloc space
+ data1 = (fREAL *)MEM_callocN(3 * w2 * h2 * sizeof(fREAL), "convolve_fast FHT data1");
+ data2 = (fREAL *)MEM_callocN(w2 * h2 * sizeof(fREAL), "convolve_fast FHT data2");
+
+ // normalize convolutor
+ wt[0] = wt[1] = wt[2] = 0.0f;
+ for (y = 0; y < kernelHeight; y++) {
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
+ for (x = 0; x < kernelWidth; x++)
+ add_v3_v3(wt, colp[x]);
+ }
+ if (wt[0] != 0.0f)
+ wt[0] = 1.0f / wt[0];
+ if (wt[1] != 0.0f)
+ wt[1] = 1.0f / wt[1];
+ if (wt[2] != 0.0f)
+ wt[2] = 1.0f / wt[2];
+ for (y = 0; y < kernelHeight; y++) {
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
+ for (x = 0; x < kernelWidth; x++)
+ mul_v3_v3(colp[x], wt);
+ }
+
+ // copy image data, unpacking interleaved RGBA into separate channels
+ // only need to calc data1 once
+
+ // block add-overlap
+ hw = kernelWidth >> 1;
+ hh = kernelHeight >> 1;
+ xbsz = (w2 + 1) - kernelWidth;
+ ybsz = (h2 + 1) - kernelHeight;
+ nxb = imageWidth / xbsz;
+ if (imageWidth % xbsz)
+ nxb++;
+ nyb = imageHeight / ybsz;
+ if (imageHeight % ybsz)
+ nyb++;
+ for (ybl = 0; ybl < nyb; ybl++) {
+ for (xbl = 0; xbl < nxb; xbl++) {
+
+ // each channel one by one
+ for (ch = 0; ch < 3; ch++) {
+ fREAL *data1ch = &data1[ch * w2 * h2];
+
+ // only need to calc fht data from in2 once, can re-use for every block
+ if (!in2done) {
+ // in2, channel ch -> data1
+ for (y = 0; y < kernelHeight; y++) {
+ fp = &data1ch[y * w2];
+ colp = (fRGB *)&kernelBuffer[y * kernelWidth * COM_NUM_CHANNELS_COLOR];
+ for (x = 0; x < kernelWidth; x++)
+ fp[x] = colp[x][ch];
+ }
+ }
+
+ // in1, channel ch -> data2
+ memset(data2, 0, w2 * h2 * sizeof(fREAL));
+ for (y = 0; y < ybsz; y++) {
+ int yy = ybl * ybsz + y;
+ if (yy >= imageHeight)
+ continue;
+ fp = &data2[y * w2];
+ colp = (fRGB *)&imageBuffer[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
+ for (x = 0; x < xbsz; x++) {
+ int xx = xbl * xbsz + x;
+ if (xx >= imageWidth)
+ continue;
+ fp[x] = colp[xx][ch];
+ }
+ }
+
+ // forward FHT
+ // zero pad data start is different for each == height+1
+ if (!in2done)
+ FHT2D(data1ch, log2_w, log2_h, kernelHeight + 1, 0);
+ FHT2D(data2, log2_w, log2_h, kernelHeight + 1, 0);
+
+ // FHT2D transposed data, row/col now swapped
+ // convolve & inverse FHT
+ fht_convolve(data2, data1ch, log2_h, log2_w);
+ FHT2D(data2, log2_h, log2_w, 0, 1);
+ // data again transposed, so in order again
+
+ // overlap-add result
+ for (y = 0; y < (int)h2; y++) {
+ const int yy = ybl * ybsz + y - hh;
+ if ((yy < 0) || (yy >= imageHeight))
+ continue;
+ fp = &data2[y * w2];
+ colp = (fRGB *)&rdst->getBuffer()[yy * imageWidth * COM_NUM_CHANNELS_COLOR];
+ for (x = 0; x < (int)w2; x++) {
+ const int xx = xbl * xbsz + x - hw;
+ if ((xx < 0) || (xx >= imageWidth))
+ continue;
+ colp[xx][ch] += fp[x];
+ }
+ }
+ }
+ in2done = true;
+ }
+ }
+
+ MEM_freeN(data2);
+ MEM_freeN(data1);
+ memcpy(
+ dst, rdst->getBuffer(), sizeof(float) * imageWidth * imageHeight * COM_NUM_CHANNELS_COLOR);
+ delete (rdst);
}
-void GlareFogGlowOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+void GlareFogGlowOperation::generateGlare(float *data,
+ MemoryBuffer *inputTile,
+ NodeGlare *settings)
{
- int x, y;
- float scale, u, v, r, w, d;
- fRGB fcol;
- MemoryBuffer *ckrn;
- unsigned int sz = 1 << settings->size;
- const float cs_r = 1.0f, cs_g = 1.0f, cs_b = 1.0f;
-
- // temp. src image
- // make the convolution kernel
- rcti kernelRect;
- BLI_rcti_init(&kernelRect, 0, sz, 0, sz);
- ckrn = new MemoryBuffer(COM_DT_COLOR, &kernelRect);
-
- scale = 0.25f * sqrtf((float)(sz * sz));
-
- for (y = 0; y < sz; ++y) {
- v = 2.0f * (y / (float)sz) - 1.0f;
- for (x = 0; x < sz; ++x) {
- u = 2.0f * (x / (float)sz) - 1.0f;
- r = (u * u + v * v) * scale;
- d = -sqrtf(sqrtf(sqrtf(r))) * 9.0f;
- fcol[0] = expf(d * cs_r);
- fcol[1] = expf(d * cs_g);
- fcol[2] = expf(d * cs_b);
- // linear window good enough here, visual result counts, not scientific analysis
- //w = (1.0f-fabs(u))*(1.0f-fabs(v));
- // actually, Hanning window is ok, cos^2 for some reason is slower
- w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
- mul_v3_fl(fcol, w);
- ckrn->writePixel(x, y, fcol);
- }
- }
-
- convolve(data, inputTile, ckrn);
- delete ckrn;
+ int x, y;
+ float scale, u, v, r, w, d;
+ fRGB fcol;
+ MemoryBuffer *ckrn;
+ unsigned int sz = 1 << settings->size;
+ const float cs_r = 1.0f, cs_g = 1.0f, cs_b = 1.0f;
+
+ // temp. src image
+ // make the convolution kernel
+ rcti kernelRect;
+ BLI_rcti_init(&kernelRect, 0, sz, 0, sz);
+ ckrn = new MemoryBuffer(COM_DT_COLOR, &kernelRect);
+
+ scale = 0.25f * sqrtf((float)(sz * sz));
+
+ for (y = 0; y < sz; ++y) {
+ v = 2.0f * (y / (float)sz) - 1.0f;
+ for (x = 0; x < sz; ++x) {
+ u = 2.0f * (x / (float)sz) - 1.0f;
+ r = (u * u + v * v) * scale;
+ d = -sqrtf(sqrtf(sqrtf(r))) * 9.0f;
+ fcol[0] = expf(d * cs_r);
+ fcol[1] = expf(d * cs_g);
+ fcol[2] = expf(d * cs_b);
+ // linear window good enough here, visual result counts, not scientific analysis
+ //w = (1.0f-fabs(u))*(1.0f-fabs(v));
+ // actually, Hanning window is ok, cos^2 for some reason is slower
+ w = (0.5f + 0.5f * cosf(u * (float)M_PI)) * (0.5f + 0.5f * cosf(v * (float)M_PI));
+ mul_v3_fl(fcol, w);
+ ckrn->writePixel(x, y, fcol);
+ }
+ }
+
+ convolve(data, inputTile, ckrn);
+ delete ckrn;
}
diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
index b209e3d4fc6..45067457778 100644
--- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
+++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.h
@@ -23,9 +23,12 @@
#include "COM_GlareBaseOperation.h"
class GlareFogGlowOperation : public GlareBaseOperation {
-public:
- GlareFogGlowOperation() : GlareBaseOperation() {}
-protected:
- void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+ public:
+ GlareFogGlowOperation() : GlareBaseOperation()
+ {
+ }
+
+ protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
index 852fc6fc6f9..f2bf25327af 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp
@@ -22,104 +22,124 @@
static float smoothMask(float x, float y)
{
- float t;
- x = 2.0f * x - 1.0f;
- y = 2.0f * y - 1.0f;
- if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) {
- return t;
- }
- else {
- return 0.0f;
- }
+ float t;
+ x = 2.0f * x - 1.0f;
+ y = 2.0f * y - 1.0f;
+ if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) {
+ return t;
+ }
+ else {
+ return 0.0f;
+ }
}
void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
{
- const int qt = 1 << settings->quality;
- const float s1 = 4.0f / (float)qt, s2 = 2.0f * s1;
- int x, y, n, p, np;
- fRGB c, tc, cm[64];
- float sc, isc, u, v, sm, s, t, ofs, scalef[64];
- const float cmo = 1.0f - settings->colmod;
+ const int qt = 1 << settings->quality;
+ const float s1 = 4.0f / (float)qt, s2 = 2.0f * s1;
+ int x, y, n, p, np;
+ fRGB c, tc, cm[64];
+ float sc, isc, u, v, sm, s, t, ofs, scalef[64];
+ const float cmo = 1.0f - settings->colmod;
- MemoryBuffer *gbuf = inputTile->duplicate();
- MemoryBuffer *tbuf1 = inputTile->duplicate();
+ MemoryBuffer *gbuf = inputTile->duplicate();
+ MemoryBuffer *tbuf1 = inputTile->duplicate();
- bool breaked = false;
+ bool breaked = false;
- FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
- if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
- if (isBreaked()) breaked = true;
- if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
+ if (!breaked)
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
+ if (isBreaked())
+ breaked = true;
+ if (!breaked)
+ FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
- MemoryBuffer *tbuf2 = tbuf1->duplicate();
+ MemoryBuffer *tbuf2 = tbuf1->duplicate();
- if (isBreaked()) breaked = true;
- if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
- if (isBreaked()) breaked = true;
- if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
- if (isBreaked()) breaked = true;
- if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
+ if (isBreaked())
+ breaked = true;
+ if (!breaked)
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
+ if (isBreaked())
+ breaked = true;
+ if (!breaked)
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
+ if (isBreaked())
+ breaked = true;
+ if (!breaked)
+ FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
- ofs = (settings->iter & 1) ? 0.5f : 0.0f;
- for (x = 0; x < (settings->iter * 4); x++) {
- y = x & 3;
- cm[x][0] = cm[x][1] = cm[x][2] = 1;
- if (y == 1) fRGB_rgbmult(cm[x], 1.0f, cmo, cmo);
- if (y == 2) fRGB_rgbmult(cm[x], cmo, cmo, 1.0f);
- if (y == 3) fRGB_rgbmult(cm[x], cmo, 1.0f, cmo);
- scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4));
- if (x & 1) scalef[x] = -0.99f / scalef[x];
- }
+ ofs = (settings->iter & 1) ? 0.5f : 0.0f;
+ for (x = 0; x < (settings->iter * 4); x++) {
+ y = x & 3;
+ cm[x][0] = cm[x][1] = cm[x][2] = 1;
+ if (y == 1)
+ fRGB_rgbmult(cm[x], 1.0f, cmo, cmo);
+ if (y == 2)
+ fRGB_rgbmult(cm[x], cmo, cmo, 1.0f);
+ if (y == 3)
+ fRGB_rgbmult(cm[x], cmo, 1.0f, cmo);
+ scalef[x] = 2.1f * (1.0f - (x + ofs) / (float)(settings->iter * 4));
+ if (x & 1)
+ scalef[x] = -0.99f / scalef[x];
+ }
- sc = 2.13;
- isc = -0.97;
- for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
- v = ((float)y + 0.5f) / (float)gbuf->getHeight();
- for (x = 0; x < gbuf->getWidth(); x++) {
- u = ((float)x + 0.5f) / (float)gbuf->getWidth();
- s = (u - 0.5f) * sc + 0.5f;
- t = (v - 0.5f) * sc + 0.5f;
- tbuf1->readBilinear(c, s * gbuf->getWidth(), t * gbuf->getHeight());
- sm = smoothMask(s, t);
- mul_v3_fl(c, sm);
- s = (u - 0.5f) * isc + 0.5f;
- t = (v - 0.5f) * isc + 0.5f;
- tbuf2->readBilinear(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
- sm = smoothMask(s, t);
- madd_v3_v3fl(c, tc, sm);
+ sc = 2.13;
+ isc = -0.97;
+ for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
+ v = ((float)y + 0.5f) / (float)gbuf->getHeight();
+ for (x = 0; x < gbuf->getWidth(); x++) {
+ u = ((float)x + 0.5f) / (float)gbuf->getWidth();
+ s = (u - 0.5f) * sc + 0.5f;
+ t = (v - 0.5f) * sc + 0.5f;
+ tbuf1->readBilinear(c, s * gbuf->getWidth(), t * gbuf->getHeight());
+ sm = smoothMask(s, t);
+ mul_v3_fl(c, sm);
+ s = (u - 0.5f) * isc + 0.5f;
+ t = (v - 0.5f) * isc + 0.5f;
+ tbuf2->readBilinear(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
+ sm = smoothMask(s, t);
+ madd_v3_v3fl(c, tc, sm);
- gbuf->writePixel(x, y, c);
- }
- if (isBreaked()) breaked = true;
+ gbuf->writePixel(x, y, c);
+ }
+ if (isBreaked())
+ breaked = true;
+ }
- }
+ memset(tbuf1->getBuffer(),
+ 0,
+ tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
+ for (n = 1; n < settings->iter && (!breaked); n++) {
+ for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
+ v = ((float)y + 0.5f) / (float)gbuf->getHeight();
+ for (x = 0; x < gbuf->getWidth(); x++) {
+ u = ((float)x + 0.5f) / (float)gbuf->getWidth();
+ tc[0] = tc[1] = tc[2] = 0.0f;
+ for (p = 0; p < 4; p++) {
+ np = (n << 2) + p;
+ s = (u - 0.5f) * scalef[np] + 0.5f;
+ t = (v - 0.5f) * scalef[np] + 0.5f;
+ gbuf->readBilinear(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
+ mul_v3_v3(c, cm[np]);
+ sm = smoothMask(s, t) * 0.25f;
+ madd_v3_v3fl(tc, c, sm);
+ }
+ tbuf1->addPixel(x, y, tc);
+ }
+ if (isBreaked())
+ breaked = true;
+ }
+ memcpy(gbuf->getBuffer(),
+ tbuf1->getBuffer(),
+ tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
+ }
+ memcpy(data,
+ gbuf->getBuffer(),
+ gbuf->getWidth() * gbuf->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
- memset(tbuf1->getBuffer(), 0, tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
- for (n = 1; n < settings->iter && (!breaked); n++) {
- for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
- v = ((float)y + 0.5f) / (float)gbuf->getHeight();
- for (x = 0; x < gbuf->getWidth(); x++) {
- u = ((float)x + 0.5f) / (float)gbuf->getWidth();
- tc[0] = tc[1] = tc[2] = 0.0f;
- for (p = 0; p < 4; p++) {
- np = (n << 2) + p;
- s = (u - 0.5f) * scalef[np] + 0.5f;
- t = (v - 0.5f) * scalef[np] + 0.5f;
- gbuf->readBilinear(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
- mul_v3_v3(c, cm[np]);
- sm = smoothMask(s, t) * 0.25f;
- madd_v3_v3fl(tc, c, sm);
- }
- tbuf1->addPixel(x, y, tc);
- }
- if (isBreaked()) breaked = true;
- }
- memcpy(gbuf->getBuffer(), tbuf1->getBuffer(), tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
- }
- memcpy(data, gbuf->getBuffer(), gbuf->getWidth() * gbuf->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
-
- delete gbuf;
- delete tbuf1;
- delete tbuf2;
+ delete gbuf;
+ delete tbuf1;
+ delete tbuf2;
}
diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.h b/source/blender/compositor/operations/COM_GlareGhostOperation.h
index 2844ed5f894..c89c239e4d1 100644
--- a/source/blender/compositor/operations/COM_GlareGhostOperation.h
+++ b/source/blender/compositor/operations/COM_GlareGhostOperation.h
@@ -23,9 +23,12 @@
#include "COM_GlareBaseOperation.h"
class GlareGhostOperation : public GlareBaseOperation {
-public:
- GlareGhostOperation() : GlareBaseOperation() {}
-protected:
- void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+ public:
+ GlareGhostOperation() : GlareBaseOperation()
+ {
+ }
+
+ protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
index f984bdade4d..1ceeba18960 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.cpp
@@ -18,83 +18,85 @@
#include "COM_GlareSimpleStarOperation.h"
-void GlareSimpleStarOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+void GlareSimpleStarOperation::generateGlare(float *data,
+ MemoryBuffer *inputTile,
+ NodeGlare *settings)
{
- int i, x, y, ym, yp, xm, xp;
- float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
- const float f1 = 1.0f - settings->fade;
- const float f2 = (1.0f - f1) * 0.5f;
+ int i, x, y, ym, yp, xm, xp;
+ float c[4] = {0, 0, 0, 0}, tc[4] = {0, 0, 0, 0};
+ const float f1 = 1.0f - settings->fade;
+ const float f2 = (1.0f - f1) * 0.5f;
- MemoryBuffer *tbuf1 = inputTile->duplicate();
- MemoryBuffer *tbuf2 = inputTile->duplicate();
+ MemoryBuffer *tbuf1 = inputTile->duplicate();
+ MemoryBuffer *tbuf2 = inputTile->duplicate();
- bool breaked = false;
- for (i = 0; i < settings->iter && (!breaked); i++) {
-// // (x || x-1, y-1) to (x || x+1, y+1)
-// // F
- for (y = 0; y < this->getHeight() && (!breaked); y++) {
- ym = y - i;
- yp = y + i;
- for (x = 0; x < this->getWidth(); x++) {
- xm = x - i;
- xp = x + i;
- tbuf1->read(c, x, y);
- mul_v3_fl(c, f1);
- tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
- madd_v3_v3fl(c, tc, f2);
- tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
- madd_v3_v3fl(c, tc, f2);
- c[3] = 1.0f;
- tbuf1->writePixel(x, y, c);
+ bool breaked = false;
+ for (i = 0; i < settings->iter && (!breaked); i++) {
+ // // (x || x-1, y-1) to (x || x+1, y+1)
+ // // F
+ for (y = 0; y < this->getHeight() && (!breaked); y++) {
+ ym = y - i;
+ yp = y + i;
+ for (x = 0; x < this->getWidth(); x++) {
+ xm = x - i;
+ xp = x + i;
+ tbuf1->read(c, x, y);
+ mul_v3_fl(c, f1);
+ tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
+ madd_v3_v3fl(c, tc, f2);
+ tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
+ madd_v3_v3fl(c, tc, f2);
+ c[3] = 1.0f;
+ tbuf1->writePixel(x, y, c);
- tbuf2->read(c, x, y);
- mul_v3_fl(c, f1);
- tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
- madd_v3_v3fl(c, tc, f2);
- tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
- madd_v3_v3fl(c, tc, f2);
- c[3] = 1.0f;
- tbuf2->writePixel(x, y, c);
- }
- if (isBreaked()) {
- breaked = true;
- }
- }
-// // B
- for (y = this->getHeight() - 1; y >= 0 && (!breaked); y--) {
- ym = y - i;
- yp = y + i;
- for (x = this->getWidth() - 1; x >= 0; x--) {
- xm = x - i;
- xp = x + i;
- tbuf1->read(c, x, y);
- mul_v3_fl(c, f1);
- tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
- madd_v3_v3fl(c, tc, f2);
- tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
- madd_v3_v3fl(c, tc, f2);
- c[3] = 1.0f;
- tbuf1->writePixel(x, y, c);
+ tbuf2->read(c, x, y);
+ mul_v3_fl(c, f1);
+ tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
+ madd_v3_v3fl(c, tc, f2);
+ tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
+ madd_v3_v3fl(c, tc, f2);
+ c[3] = 1.0f;
+ tbuf2->writePixel(x, y, c);
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ // // B
+ for (y = this->getHeight() - 1; y >= 0 && (!breaked); y--) {
+ ym = y - i;
+ yp = y + i;
+ for (x = this->getWidth() - 1; x >= 0; x--) {
+ xm = x - i;
+ xp = x + i;
+ tbuf1->read(c, x, y);
+ mul_v3_fl(c, f1);
+ tbuf1->read(tc, (settings->star_45 ? xm : x), ym);
+ madd_v3_v3fl(c, tc, f2);
+ tbuf1->read(tc, (settings->star_45 ? xp : x), yp);
+ madd_v3_v3fl(c, tc, f2);
+ c[3] = 1.0f;
+ tbuf1->writePixel(x, y, c);
- tbuf2->read(c, x, y);
- mul_v3_fl(c, f1);
- tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
- madd_v3_v3fl(c, tc, f2);
- tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
- madd_v3_v3fl(c, tc, f2);
- c[3] = 1.0f;
- tbuf2->writePixel(x, y, c);
- }
- if (isBreaked()) {
- breaked = true;
- }
- }
- }
+ tbuf2->read(c, x, y);
+ mul_v3_fl(c, f1);
+ tbuf2->read(tc, xm, (settings->star_45 ? yp : y));
+ madd_v3_v3fl(c, tc, f2);
+ tbuf2->read(tc, xp, (settings->star_45 ? ym : y));
+ madd_v3_v3fl(c, tc, f2);
+ c[3] = 1.0f;
+ tbuf2->writePixel(x, y, c);
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ }
- for (i = 0; i < this->getWidth() * this->getHeight() * 4; i++) {
- data[i] = tbuf1->getBuffer()[i] + tbuf2->getBuffer()[i];
- }
+ for (i = 0; i < this->getWidth() * this->getHeight() * 4; i++) {
+ data[i] = tbuf1->getBuffer()[i] + tbuf2->getBuffer()[i];
+ }
- delete tbuf1;
- delete tbuf2;
+ delete tbuf1;
+ delete tbuf2;
}
diff --git a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
index 3cb66c1212c..a40dfac86ff 100644
--- a/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
+++ b/source/blender/compositor/operations/COM_GlareSimpleStarOperation.h
@@ -23,9 +23,12 @@
#include "COM_GlareBaseOperation.h"
class GlareSimpleStarOperation : public GlareBaseOperation {
-public:
- GlareSimpleStarOperation() : GlareBaseOperation() {}
-protected:
- void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+ public:
+ GlareSimpleStarOperation() : GlareBaseOperation()
+ {
+ }
+
+ protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
index 18be89af75b..cf60a1378b4 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.cpp
@@ -19,74 +19,82 @@
#include "COM_GlareStreaksOperation.h"
#include "BLI_math.h"
-void GlareStreaksOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings)
+void GlareStreaksOperation::generateGlare(float *data,
+ MemoryBuffer *inputTile,
+ NodeGlare *settings)
{
- int x, y, n;
- unsigned int nump = 0;
- float c1[4], c2[4], c3[4], c4[4];
- float a, ang = DEG2RADF(360.0f) / (float)settings->streaks;
+ int x, y, n;
+ unsigned int nump = 0;
+ float c1[4], c2[4], c3[4], c4[4];
+ float a, ang = DEG2RADF(360.0f) / (float)settings->streaks;
- int size = inputTile->getWidth() * inputTile->getHeight();
- int size4 = size * 4;
+ int size = inputTile->getWidth() * inputTile->getHeight();
+ int size4 = size * 4;
- bool breaked = false;
+ bool breaked = false;
- MemoryBuffer *tsrc = inputTile->duplicate();
- MemoryBuffer *tdst = new MemoryBuffer(COM_DT_COLOR, inputTile->getRect());
- tdst->clear();
- memset(data, 0, size4 * sizeof(float));
+ MemoryBuffer *tsrc = inputTile->duplicate();
+ MemoryBuffer *tdst = new MemoryBuffer(COM_DT_COLOR, inputTile->getRect());
+ tdst->clear();
+ memset(data, 0, size4 * sizeof(float));
- for (a = 0.0f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
- const float an = a + settings->angle_ofs;
- const float vx = cos((double)an), vy = sin((double)an);
- for (n = 0; n < settings->iter && (!breaked); ++n) {
- const float p4 = pow(4.0, (double)n);
- const float vxp = vx * p4, vyp = vy * p4;
- const float wt = pow((double)settings->fade, (double)p4);
- const float cmo = 1.0f - (float)pow((double)settings->colmod, (double)n + 1); // colormodulation amount relative to current pass
- float *tdstcol = tdst->getBuffer();
- for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) {
- for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
- // first pass no offset, always same for every pass, exact copy,
- // otherwise results in uneven brightness, only need once
- if (n == 0) tsrc->read(c1, x, y); else c1[0] = c1[1] = c1[2] = 0;
- tsrc->readBilinear(c2, x + vxp, y + vyp);
- tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
- tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);
- // modulate color to look vaguely similar to a color spectrum
- c2[1] *= cmo;
- c2[2] *= cmo;
+ for (a = 0.0f; a < DEG2RADF(360.0f) && (!breaked); a += ang) {
+ const float an = a + settings->angle_ofs;
+ const float vx = cos((double)an), vy = sin((double)an);
+ for (n = 0; n < settings->iter && (!breaked); ++n) {
+ const float p4 = pow(4.0, (double)n);
+ const float vxp = vx * p4, vyp = vy * p4;
+ const float wt = pow((double)settings->fade, (double)p4);
+ const float cmo = 1.0f -
+ (float)pow((double)settings->colmod,
+ (double)n +
+ 1); // colormodulation amount relative to current pass
+ float *tdstcol = tdst->getBuffer();
+ for (y = 0; y < tsrc->getHeight() && (!breaked); ++y) {
+ for (x = 0; x < tsrc->getWidth(); ++x, tdstcol += 4) {
+ // first pass no offset, always same for every pass, exact copy,
+ // otherwise results in uneven brightness, only need once
+ if (n == 0)
+ tsrc->read(c1, x, y);
+ else
+ c1[0] = c1[1] = c1[2] = 0;
+ tsrc->readBilinear(c2, x + vxp, y + vyp);
+ tsrc->readBilinear(c3, x + vxp * 2.0f, y + vyp * 2.0f);
+ tsrc->readBilinear(c4, x + vxp * 3.0f, y + vyp * 3.0f);
+ // modulate color to look vaguely similar to a color spectrum
+ c2[1] *= cmo;
+ c2[2] *= cmo;
- c3[0] *= cmo;
- c3[1] *= cmo;
+ c3[0] *= cmo;
+ c3[1] *= cmo;
- c4[0] *= cmo;
- c4[2] *= cmo;
+ c4[0] *= cmo;
+ c4[2] *= cmo;
- tdstcol[0] = 0.5f * (tdstcol[0] + c1[0] + wt * (c2[0] + wt * (c3[0] + wt * c4[0])));
- tdstcol[1] = 0.5f * (tdstcol[1] + c1[1] + wt * (c2[1] + wt * (c3[1] + wt * c4[1])));
- tdstcol[2] = 0.5f * (tdstcol[2] + c1[2] + wt * (c2[2] + wt * (c3[2] + wt * c4[2])));
- tdstcol[3] = 1.0f;
- }
- if (isBreaked()) {
- breaked = true;
- }
- }
- memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float) * size4);
- }
+ tdstcol[0] = 0.5f * (tdstcol[0] + c1[0] + wt * (c2[0] + wt * (c3[0] + wt * c4[0])));
+ tdstcol[1] = 0.5f * (tdstcol[1] + c1[1] + wt * (c2[1] + wt * (c3[1] + wt * c4[1])));
+ tdstcol[2] = 0.5f * (tdstcol[2] + c1[2] + wt * (c2[2] + wt * (c3[2] + wt * c4[2])));
+ tdstcol[3] = 1.0f;
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ memcpy(tsrc->getBuffer(), tdst->getBuffer(), sizeof(float) * size4);
+ }
- float *sourcebuffer = tsrc->getBuffer();
- float factor = 1.0f / (float)(6 - settings->iter);
- for (int i = 0; i < size4; i += 4) {
- madd_v3_v3fl(&data[i], &sourcebuffer[i], factor);
- data[i + 3] = 1.0f;
- }
+ float *sourcebuffer = tsrc->getBuffer();
+ float factor = 1.0f / (float)(6 - settings->iter);
+ for (int i = 0; i < size4; i += 4) {
+ madd_v3_v3fl(&data[i], &sourcebuffer[i], factor);
+ data[i + 3] = 1.0f;
+ }
- tdst->clear();
- memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float) * size4);
- nump++;
- }
+ tdst->clear();
+ memcpy(tsrc->getBuffer(), inputTile->getBuffer(), sizeof(float) * size4);
+ nump++;
+ }
- delete tsrc;
- delete tdst;
+ delete tsrc;
+ delete tdst;
}
diff --git a/source/blender/compositor/operations/COM_GlareStreaksOperation.h b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
index cb2356123a5..9150b5e4641 100644
--- a/source/blender/compositor/operations/COM_GlareStreaksOperation.h
+++ b/source/blender/compositor/operations/COM_GlareStreaksOperation.h
@@ -23,9 +23,12 @@
#include "COM_GlareBaseOperation.h"
class GlareStreaksOperation : public GlareBaseOperation {
-public:
- GlareStreaksOperation() : GlareBaseOperation() {}
-protected:
- void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
+ public:
+ GlareStreaksOperation() : GlareBaseOperation()
+ {
+ }
+
+ protected:
+ void generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings);
};
#endif
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index 75e0ce57980..142c51122a1 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -25,43 +25,47 @@ extern "C" {
GlareThresholdOperation::GlareThresholdOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
}
-void GlareThresholdOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void GlareThresholdOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- resolution[0] = resolution[0] / (1 << this->m_settings->quality);
- resolution[1] = resolution[1] / (1 << this->m_settings->quality);
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ resolution[0] = resolution[0] / (1 << this->m_settings->quality);
+ resolution[1] = resolution[1] / (1 << this->m_settings->quality);
}
void GlareThresholdOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void GlareThresholdOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void GlareThresholdOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- const float threshold = this->m_settings->threshold;
+ const float threshold = this->m_settings->threshold;
- this->m_inputProgram->readSampled(output, x, y, sampler);
- if (IMB_colormanagement_get_luminance(output) >= threshold) {
- output[0] -= threshold;
- output[1] -= threshold;
- output[2] -= threshold;
+ this->m_inputProgram->readSampled(output, x, y, sampler);
+ if (IMB_colormanagement_get_luminance(output) >= threshold) {
+ output[0] -= threshold;
+ output[1] -= threshold;
+ output[2] -= threshold;
- output[0] = max(output[0], 0.0f);
- output[1] = max(output[1], 0.0f);
- output[2] = max(output[2], 0.0f);
- }
- else {
- zero_v3(output);
- }
+ output[0] = max(output[0], 0.0f);
+ output[1] = max(output[1], 0.0f);
+ output[2] = max(output[2], 0.0f);
+ }
+ else {
+ zero_v3(output);
+ }
}
void GlareThresholdOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.h b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
index 2a38783511f..385111cdf0b 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.h
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.h
@@ -22,38 +22,40 @@
#include "DNA_light_types.h"
class GlareThresholdOperation : public NodeOperation {
-private:
- /**
- * \brief Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
-
- /**
- * \brief settings of the glare node.
- */
- NodeGlare *m_settings;
-public:
- GlareThresholdOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setGlareSettings(NodeGlare *settings) {
- this->m_settings = settings;
- }
-
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ private:
+ /**
+ * \brief Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+
+ /**
+ * \brief settings of the glare node.
+ */
+ NodeGlare *m_settings;
+
+ public:
+ GlareThresholdOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setGlareSettings(NodeGlare *settings)
+ {
+ this->m_settings = settings;
+ }
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
#endif
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
index 02497725d46..61ad4248fb0 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.cpp
@@ -23,53 +23,56 @@
#ifdef __cplusplus
extern "C" {
#endif
-# include "BKE_colortools.h"
+#include "BKE_colortools.h"
#ifdef __cplusplus
}
#endif
HueSaturationValueCorrectOperation::HueSaturationValueCorrectOperation() : CurveBaseOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
void HueSaturationValueCorrectOperation::initExecution()
{
- CurveBaseOperation::initExecution();
- this->m_inputProgram = this->getInputSocketReader(0);
+ CurveBaseOperation::initExecution();
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void HueSaturationValueCorrectOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void HueSaturationValueCorrectOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float hsv[4], f;
+ float hsv[4], f;
- this->m_inputProgram->readSampled(hsv, x, y, sampler);
+ this->m_inputProgram->readSampled(hsv, x, y, sampler);
- /* adjust hue, scaling returned default 0.5 up to 1 */
- f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
- hsv[0] += f - 0.5f;
+ /* adjust hue, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->m_curveMapping, 0, hsv[0]);
+ hsv[0] += f - 0.5f;
- /* adjust saturation, scaling returned default 0.5 up to 1 */
- f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
- hsv[1] *= (f * 2.0f);
+ /* adjust saturation, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->m_curveMapping, 1, hsv[0]);
+ hsv[1] *= (f * 2.0f);
- /* adjust value, scaling returned default 0.5 up to 1 */
- f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
- hsv[2] *= (f * 2.0f);
+ /* adjust value, scaling returned default 0.5 up to 1 */
+ f = curvemapping_evaluateF(this->m_curveMapping, 2, hsv[0]);
+ hsv[2] *= (f * 2.0f);
- hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
- CLAMP(hsv[1], 0.0f, 1.0f);
+ hsv[0] = hsv[0] - floorf(hsv[0]); /* mod 1.0 */
+ CLAMP(hsv[1], 0.0f, 1.0f);
- output[0] = hsv[0];
- output[1] = hsv[1];
- output[2] = hsv[2];
- output[3] = hsv[3];
+ output[0] = hsv[0];
+ output[1] = hsv[1];
+ output[2] = hsv[2];
+ output[3] = hsv[3];
}
void HueSaturationValueCorrectOperation::deinitExecution()
{
- CurveBaseOperation::deinitExecution();
- this->m_inputProgram = NULL;
+ CurveBaseOperation::deinitExecution();
+ this->m_inputProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
index 9d8b6e0aa7b..3e212b96521 100644
--- a/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
+++ b/source/blender/compositor/operations/COM_HueSaturationValueCorrectOperation.h
@@ -22,28 +22,28 @@
#include "COM_CurveBaseOperation.h"
class HueSaturationValueCorrectOperation : public CurveBaseOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
-public:
- HueSaturationValueCorrectOperation();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ HueSaturationValueCorrectOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index ce24cfcca79..ef321157320 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -20,25 +20,22 @@
IDMaskOperation::IDMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->setComplex(true);
}
void *IDMaskOperation::initializeTileData(rcti *rect)
{
- void *buffer = getInputOperation(0)->initializeTileData(rect);
- return buffer;
+ void *buffer = getInputOperation(0)->initializeTileData(rect);
+ return buffer;
}
-void IDMaskOperation::executePixel(float output[4],
- int x,
- int y,
- void *data)
+void IDMaskOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *input_buffer = (MemoryBuffer *)data;
- const int buffer_width = input_buffer->getWidth();
- float *buffer = input_buffer->getBuffer();
- int buffer_index = (y * buffer_width + x);
- output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f;
+ MemoryBuffer *input_buffer = (MemoryBuffer *)data;
+ const int buffer_width = input_buffer->getWidth();
+ float *buffer = input_buffer->getBuffer();
+ int buffer_index = (y * buffer_width + x);
+ output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f;
}
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index f2ca267e80a..b3a40106b9d 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -20,17 +20,19 @@
#define __COM_IDMASKOPERATION_H__
#include "COM_NodeOperation.h"
-
class IDMaskOperation : public NodeOperation {
-private:
- float m_objectIndex;
-public:
- IDMaskOperation();
+ private:
+ float m_objectIndex;
- void *initializeTileData(rcti *rect);
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ IDMaskOperation();
- void setObjectIndex(float objectIndex) { this->m_objectIndex = objectIndex; }
+ void *initializeTileData(rcti *rect);
+ void executePixel(float output[4], int x, int y, void *data);
+ void setObjectIndex(float objectIndex)
+ {
+ this->m_objectIndex = objectIndex;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ImageOperation.cpp b/source/blender/compositor/operations/COM_ImageOperation.cpp
index efdd71f7f26..bf9ad441803 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_ImageOperation.cpp
@@ -25,173 +25,180 @@
#include "BLI_math.h"
extern "C" {
-# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
-# include "RE_render_ext.h"
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
-# include "IMB_colormanagement.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
}
BaseImageOperation::BaseImageOperation() : NodeOperation()
{
- this->m_image = NULL;
- this->m_buffer = NULL;
- this->m_imageFloatBuffer = NULL;
- this->m_imageByteBuffer = NULL;
- this->m_imageUser = NULL;
- this->m_imagewidth = 0;
- this->m_imageheight = 0;
- this->m_framenumber = 0;
- this->m_depthBuffer = NULL;
- this->m_numberOfChannels = 0;
- this->m_rd = NULL;
- this->m_viewName = NULL;
+ this->m_image = NULL;
+ this->m_buffer = NULL;
+ this->m_imageFloatBuffer = NULL;
+ this->m_imageByteBuffer = NULL;
+ this->m_imageUser = NULL;
+ this->m_imagewidth = 0;
+ this->m_imageheight = 0;
+ this->m_framenumber = 0;
+ this->m_depthBuffer = NULL;
+ this->m_numberOfChannels = 0;
+ this->m_rd = NULL;
+ this->m_viewName = NULL;
}
ImageOperation::ImageOperation() : BaseImageOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
ImageAlphaOperation::ImageAlphaOperation() : BaseImageOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
}
ImageDepthOperation::ImageDepthOperation() : BaseImageOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
}
ImBuf *BaseImageOperation::getImBuf()
{
- ImBuf *ibuf;
- ImageUser iuser = *this->m_imageUser;
-
- if (this->m_image == NULL)
- return NULL;
-
- /* local changes to the original ImageUser */
- if (BKE_image_is_multilayer(this->m_image) == false)
- iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
-
- ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, NULL);
- if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
- BKE_image_release_ibuf(this->m_image, ibuf, NULL);
- return NULL;
- }
- return ibuf;
+ ImBuf *ibuf;
+ ImageUser iuser = *this->m_imageUser;
+
+ if (this->m_image == NULL)
+ return NULL;
+
+ /* local changes to the original ImageUser */
+ if (BKE_image_is_multilayer(this->m_image) == false)
+ iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
+
+ ibuf = BKE_image_acquire_ibuf(this->m_image, &iuser, NULL);
+ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
+ BKE_image_release_ibuf(this->m_image, ibuf, NULL);
+ return NULL;
+ }
+ return ibuf;
}
-
void BaseImageOperation::initExecution()
{
- ImBuf *stackbuf = getImBuf();
- this->m_buffer = stackbuf;
- if (stackbuf) {
- this->m_imageFloatBuffer = stackbuf->rect_float;
- this->m_imageByteBuffer = stackbuf->rect;
- this->m_depthBuffer = stackbuf->zbuf_float;
- this->m_imagewidth = stackbuf->x;
- this->m_imageheight = stackbuf->y;
- this->m_numberOfChannels = stackbuf->channels;
- }
+ ImBuf *stackbuf = getImBuf();
+ this->m_buffer = stackbuf;
+ if (stackbuf) {
+ this->m_imageFloatBuffer = stackbuf->rect_float;
+ this->m_imageByteBuffer = stackbuf->rect;
+ this->m_depthBuffer = stackbuf->zbuf_float;
+ this->m_imagewidth = stackbuf->x;
+ this->m_imageheight = stackbuf->y;
+ this->m_numberOfChannels = stackbuf->channels;
+ }
}
void BaseImageOperation::deinitExecution()
{
- this->m_imageFloatBuffer = NULL;
- this->m_imageByteBuffer = NULL;
- BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL);
+ this->m_imageFloatBuffer = NULL;
+ this->m_imageByteBuffer = NULL;
+ BKE_image_release_ibuf(this->m_image, this->m_buffer, NULL);
}
-void BaseImageOperation::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void BaseImageOperation::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- ImBuf *stackbuf = getImBuf();
+ ImBuf *stackbuf = getImBuf();
- resolution[0] = 0;
- resolution[1] = 0;
+ resolution[0] = 0;
+ resolution[1] = 0;
- if (stackbuf) {
- resolution[0] = stackbuf->x;
- resolution[1] = stackbuf->y;
- }
+ if (stackbuf) {
+ resolution[0] = stackbuf->x;
+ resolution[1] = stackbuf->y;
+ }
- BKE_image_release_ibuf(this->m_image, stackbuf, NULL);
+ BKE_image_release_ibuf(this->m_image, stackbuf, NULL);
}
-static void sampleImageAtLocation(ImBuf *ibuf, float x, float y, PixelSampler sampler, bool make_linear_rgb, float color[4])
+static void sampleImageAtLocation(
+ ImBuf *ibuf, float x, float y, PixelSampler sampler, bool make_linear_rgb, float color[4])
{
- if (ibuf->rect_float) {
- switch (sampler) {
- case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, NULL, color, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, NULL, color, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, NULL, color, x, y);
- break;
- }
- }
- else {
- unsigned char byte_color[4];
- switch (sampler) {
- case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
- break;
- }
- rgba_uchar_to_float(color, byte_color);
- if (make_linear_rgb) {
- IMB_colormanagement_colorspace_to_scene_linear_v4(color, false, ibuf->rect_colorspace);
- }
- }
+ if (ibuf->rect_float) {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ nearest_interpolation_color(ibuf, NULL, color, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(ibuf, NULL, color, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(ibuf, NULL, color, x, y);
+ break;
+ }
+ }
+ else {
+ unsigned char byte_color[4];
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ nearest_interpolation_color(ibuf, byte_color, NULL, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(ibuf, byte_color, NULL, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(ibuf, byte_color, NULL, x, y);
+ break;
+ }
+ rgba_uchar_to_float(color, byte_color);
+ if (make_linear_rgb) {
+ IMB_colormanagement_colorspace_to_scene_linear_v4(color, false, ibuf->rect_colorspace);
+ }
+ }
}
void ImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- int ix = x, iy = y;
- if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
- zero_v4(output);
- }
- else if (ix < 0 || iy < 0 || ix >= this->m_buffer->x || iy >= this->m_buffer->y) {
- zero_v4(output);
- }
- else {
- sampleImageAtLocation(this->m_buffer, x, y, sampler, true, output);
- }
+ int ix = x, iy = y;
+ if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
+ zero_v4(output);
+ }
+ else if (ix < 0 || iy < 0 || ix >= this->m_buffer->x || iy >= this->m_buffer->y) {
+ zero_v4(output);
+ }
+ else {
+ sampleImageAtLocation(this->m_buffer, x, y, sampler, true, output);
+ }
}
-void ImageAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ImageAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float tempcolor[4];
-
- if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
- output[0] = 0.0f;
- }
- else {
- tempcolor[3] = 1.0f;
- sampleImageAtLocation(this->m_buffer, x, y, sampler, false, tempcolor);
- output[0] = tempcolor[3];
- }
+ float tempcolor[4];
+
+ if (this->m_imageFloatBuffer == NULL && this->m_imageByteBuffer == NULL) {
+ output[0] = 0.0f;
+ }
+ else {
+ tempcolor[3] = 1.0f;
+ sampleImageAtLocation(this->m_buffer, x, y, sampler, false, tempcolor);
+ output[0] = tempcolor[3];
+ }
}
-void ImageDepthOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void ImageDepthOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- if (this->m_depthBuffer == NULL) {
- output[0] = 0.0f;
- }
- else {
- if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
- output[0] = 0.0f;
- else {
- int offset = y * this->m_width + x;
- output[0] = this->m_depthBuffer[offset];
- }
- }
+ if (this->m_depthBuffer == NULL) {
+ output[0] = 0.0f;
+ }
+ else {
+ if (x < 0 || y < 0 || x >= this->getWidth() || y >= this->getHeight())
+ output[0] = 0.0f;
+ else {
+ int offset = y * this->m_width + x;
+ output[0] = this->m_depthBuffer[offset];
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_ImageOperation.h b/source/blender/compositor/operations/COM_ImageOperation.h
index 350c24bfafb..e03173dca8d 100644
--- a/source/blender/compositor/operations/COM_ImageOperation.h
+++ b/source/blender/compositor/operations/COM_ImageOperation.h
@@ -16,7 +16,6 @@
* Copyright 2011, Blender Foundation.
*/
-
#ifndef __COM_IMAGEOPERATION_H__
#define __COM_IMAGEOPERATION_H__
@@ -24,70 +23,84 @@
#include "BLI_listbase.h"
#include "BKE_image.h"
extern "C" {
-# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
-# include "RE_render_ext.h"
-# include "MEM_guardedalloc.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
+#include "MEM_guardedalloc.h"
}
/**
* \brief Base class for all image operations
*/
class BaseImageOperation : public NodeOperation {
-protected:
- ImBuf *m_buffer;
- Image *m_image;
- ImageUser *m_imageUser;
- float *m_imageFloatBuffer;
- unsigned int *m_imageByteBuffer;
- float *m_depthBuffer;
- int m_imageheight;
- int m_imagewidth;
- int m_framenumber;
- int m_numberOfChannels;
- const RenderData *m_rd;
- const char *m_viewName;
-
- BaseImageOperation();
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ protected:
+ ImBuf *m_buffer;
+ Image *m_image;
+ ImageUser *m_imageUser;
+ float *m_imageFloatBuffer;
+ unsigned int *m_imageByteBuffer;
+ float *m_depthBuffer;
+ int m_imageheight;
+ int m_imagewidth;
+ int m_framenumber;
+ int m_numberOfChannels;
+ const RenderData *m_rd;
+ const char *m_viewName;
- virtual ImBuf *getImBuf();
+ BaseImageOperation();
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-public:
+ virtual ImBuf *getImBuf();
- void initExecution();
- void deinitExecution();
- void setImage(Image *image) { this->m_image = image; }
- void setImageUser(ImageUser *imageuser) { this->m_imageUser = imageuser; }
- void setRenderData(const RenderData *rd) { this->m_rd = rd; }
- void setViewName(const char *viewName) { this->m_viewName = viewName; }
- void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
+ public:
+ void initExecution();
+ void deinitExecution();
+ void setImage(Image *image)
+ {
+ this->m_image = image;
+ }
+ void setImageUser(ImageUser *imageuser)
+ {
+ this->m_imageUser = imageuser;
+ }
+ void setRenderData(const RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+ void setViewName(const char *viewName)
+ {
+ this->m_viewName = viewName;
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
};
class ImageOperation : public BaseImageOperation {
-public:
- /**
- * Constructor
- */
- ImageOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Constructor
+ */
+ ImageOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ImageAlphaOperation : public BaseImageOperation {
-public:
- /**
- * Constructor
- */
- ImageAlphaOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Constructor
+ */
+ ImageAlphaOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ImageDepthOperation : public BaseImageOperation {
-public:
- /**
- * Constructor
- */
- ImageDepthOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Constructor
+ */
+ ImageDepthOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp
index e0f99d1916d..86d566834e6 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.cpp
+++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp
@@ -23,260 +23,259 @@
#include "BLI_math.h"
-#define ASSERT_XY_RANGE(x, y) \
- BLI_assert(x >= 0 && x < this->getWidth() && \
- y >= 0 && y < this->getHeight())
-
+#define ASSERT_XY_RANGE(x, y) \
+ BLI_assert(x >= 0 && x < this->getWidth() && y >= 0 && y < this->getHeight())
// Inpaint (simple convolve using average of known pixels)
InpaintSimpleOperation::InpaintSimpleOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->m_inputImageProgram = NULL;
- this->m_pixelorder = NULL;
- this->m_manhatten_distance = NULL;
- this->m_cached_buffer = NULL;
- this->m_cached_buffer_ready = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->m_inputImageProgram = NULL;
+ this->m_pixelorder = NULL;
+ this->m_manhatten_distance = NULL;
+ this->m_cached_buffer = NULL;
+ this->m_cached_buffer_ready = false;
}
void InpaintSimpleOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_pixelorder = NULL;
- this->m_manhatten_distance = NULL;
- this->m_cached_buffer = NULL;
- this->m_cached_buffer_ready = false;
+ this->m_pixelorder = NULL;
+ this->m_manhatten_distance = NULL;
+ this->m_cached_buffer = NULL;
+ this->m_cached_buffer_ready = false;
- this->initMutex();
+ this->initMutex();
}
void InpaintSimpleOperation::clamp_xy(int &x, int &y)
{
- int width = this->getWidth();
- int height = this->getHeight();
-
- if (x < 0) {
- x = 0;
- }
- else if (x >= width) {
- x = width - 1;
- }
-
- if (y < 0) {
- y = 0;
- }
- else if (y >= height) {
- y = height - 1;
- }
+ int width = this->getWidth();
+ int height = this->getHeight();
+
+ if (x < 0) {
+ x = 0;
+ }
+ else if (x >= width) {
+ x = width - 1;
+ }
+
+ if (y < 0) {
+ y = 0;
+ }
+ else if (y >= height) {
+ y = height - 1;
+ }
}
float *InpaintSimpleOperation::get_pixel(int x, int y)
{
- int width = this->getWidth();
+ int width = this->getWidth();
- ASSERT_XY_RANGE(x, y);
+ ASSERT_XY_RANGE(x, y);
- return &this->m_cached_buffer[
- y * width * COM_NUM_CHANNELS_COLOR +
- x * COM_NUM_CHANNELS_COLOR];
+ return &this->m_cached_buffer[y * width * COM_NUM_CHANNELS_COLOR + x * COM_NUM_CHANNELS_COLOR];
}
int InpaintSimpleOperation::mdist(int x, int y)
{
- int width = this->getWidth();
+ int width = this->getWidth();
- ASSERT_XY_RANGE(x, y);
+ ASSERT_XY_RANGE(x, y);
- return this->m_manhatten_distance[y * width + x];
+ return this->m_manhatten_distance[y * width + x];
}
-bool InpaintSimpleOperation::next_pixel(int &x, int &y, int & curr, int iters)
+bool InpaintSimpleOperation::next_pixel(int &x, int &y, int &curr, int iters)
{
- int width = this->getWidth();
+ int width = this->getWidth();
- if (curr >= this->m_area_size) {
- return false;
- }
+ if (curr >= this->m_area_size) {
+ return false;
+ }
- int r = this->m_pixelorder[curr++];
+ int r = this->m_pixelorder[curr++];
- x = r % width;
- y = r / width;
+ x = r % width;
+ y = r / width;
- if (this->mdist(x, y) > iters) {
- return false;
- }
+ if (this->mdist(x, y) > iters) {
+ return false;
+ }
- return true;
+ return true;
}
void InpaintSimpleOperation::calc_manhatten_distance()
{
- int width = this->getWidth();
- int height = this->getHeight();
- short *m = this->m_manhatten_distance = (short *)MEM_mallocN(sizeof(short) * width * height, __func__);
- int *offsets;
-
- offsets = (int *)MEM_callocN(sizeof(int) * (width + height + 1), "InpaintSimpleOperation offsets");
-
- for (int j = 0; j < height; j++) {
- for (int i = 0; i < width; i++) {
- int r = 0;
- /* no need to clamp here */
- if (this->get_pixel(i, j)[3] < 1.0f) {
- r = width + height;
- if (i > 0)
- r = min_ii(r, m[j * width + i - 1] + 1);
- if (j > 0)
- r = min_ii(r, m[(j - 1) * width + i] + 1);
- }
- m[j * width + i] = r;
- }
- }
-
- for (int j = height - 1; j >= 0; j--) {
- for (int i = width - 1; i >= 0; i--) {
- int r = m[j * width + i];
-
- if (i + 1 < width)
- r = min_ii(r, m[j * width + i + 1] + 1);
- if (j + 1 < height)
- r = min_ii(r, m[(j + 1) * width + i] + 1);
-
- m[j * width + i] = r;
-
- offsets[r]++;
- }
- }
-
- offsets[0] = 0;
-
- for (int i = 1; i < width + height + 1; i++) {
- offsets[i] += offsets[i - 1];
- }
-
- this->m_area_size = offsets[width + height];
- this->m_pixelorder = (int *)MEM_mallocN(sizeof(int) * this->m_area_size, __func__);
-
- for (int i = 0; i < width * height; i++) {
- if (m[i] > 0) {
- this->m_pixelorder[offsets[m[i] - 1]++] = i;
- }
- }
-
- MEM_freeN(offsets);
+ int width = this->getWidth();
+ int height = this->getHeight();
+ short *m = this->m_manhatten_distance = (short *)MEM_mallocN(sizeof(short) * width * height,
+ __func__);
+ int *offsets;
+
+ offsets = (int *)MEM_callocN(sizeof(int) * (width + height + 1),
+ "InpaintSimpleOperation offsets");
+
+ for (int j = 0; j < height; j++) {
+ for (int i = 0; i < width; i++) {
+ int r = 0;
+ /* no need to clamp here */
+ if (this->get_pixel(i, j)[3] < 1.0f) {
+ r = width + height;
+ if (i > 0)
+ r = min_ii(r, m[j * width + i - 1] + 1);
+ if (j > 0)
+ r = min_ii(r, m[(j - 1) * width + i] + 1);
+ }
+ m[j * width + i] = r;
+ }
+ }
+
+ for (int j = height - 1; j >= 0; j--) {
+ for (int i = width - 1; i >= 0; i--) {
+ int r = m[j * width + i];
+
+ if (i + 1 < width)
+ r = min_ii(r, m[j * width + i + 1] + 1);
+ if (j + 1 < height)
+ r = min_ii(r, m[(j + 1) * width + i] + 1);
+
+ m[j * width + i] = r;
+
+ offsets[r]++;
+ }
+ }
+
+ offsets[0] = 0;
+
+ for (int i = 1; i < width + height + 1; i++) {
+ offsets[i] += offsets[i - 1];
+ }
+
+ this->m_area_size = offsets[width + height];
+ this->m_pixelorder = (int *)MEM_mallocN(sizeof(int) * this->m_area_size, __func__);
+
+ for (int i = 0; i < width * height; i++) {
+ if (m[i] > 0) {
+ this->m_pixelorder[offsets[m[i] - 1]++] = i;
+ }
+ }
+
+ MEM_freeN(offsets);
}
void InpaintSimpleOperation::pix_step(int x, int y)
{
- const int d = this->mdist(x, y);
- float pix[3] = {0.0f, 0.0f, 0.0f};
- float pix_divider = 0.0f;
-
- for (int dx = -1; dx <= 1; dx++) {
- for (int dy = -1; dy <= 1; dy++) {
- /* changing to both != 0 gives dithering artifacts */
- if (dx != 0 || dy != 0) {
- int x_ofs = x + dx;
- int y_ofs = y + dy;
-
- this->clamp_xy(x_ofs, y_ofs);
-
- if (this->mdist(x_ofs, y_ofs) < d) {
-
- float weight;
-
- if (dx == 0 || dy == 0) {
- weight = 1.0f;
- }
- else {
- weight = M_SQRT1_2; /* 1.0f / sqrt(2) */
- }
-
- madd_v3_v3fl(pix, this->get_pixel(x_ofs, y_ofs), weight);
- pix_divider += weight;
- }
- }
- }
- }
-
- float *output = this->get_pixel(x, y);
- if (pix_divider != 0.0f) {
- mul_v3_fl(pix, 1.0f / pix_divider);
- /* use existing pixels alpha to blend into */
- interp_v3_v3v3(output, pix, output, output[3]);
- output[3] = 1.0f;
- }
+ const int d = this->mdist(x, y);
+ float pix[3] = {0.0f, 0.0f, 0.0f};
+ float pix_divider = 0.0f;
+
+ for (int dx = -1; dx <= 1; dx++) {
+ for (int dy = -1; dy <= 1; dy++) {
+ /* changing to both != 0 gives dithering artifacts */
+ if (dx != 0 || dy != 0) {
+ int x_ofs = x + dx;
+ int y_ofs = y + dy;
+
+ this->clamp_xy(x_ofs, y_ofs);
+
+ if (this->mdist(x_ofs, y_ofs) < d) {
+
+ float weight;
+
+ if (dx == 0 || dy == 0) {
+ weight = 1.0f;
+ }
+ else {
+ weight = M_SQRT1_2; /* 1.0f / sqrt(2) */
+ }
+
+ madd_v3_v3fl(pix, this->get_pixel(x_ofs, y_ofs), weight);
+ pix_divider += weight;
+ }
+ }
+ }
+ }
+
+ float *output = this->get_pixel(x, y);
+ if (pix_divider != 0.0f) {
+ mul_v3_fl(pix, 1.0f / pix_divider);
+ /* use existing pixels alpha to blend into */
+ interp_v3_v3v3(output, pix, output, output[3]);
+ output[3] = 1.0f;
+ }
}
void *InpaintSimpleOperation::initializeTileData(rcti *rect)
{
- if (this->m_cached_buffer_ready) {
- return this->m_cached_buffer;
- }
- lockMutex();
- if (!this->m_cached_buffer_ready) {
- MemoryBuffer *buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
- this->m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer());
-
- this->calc_manhatten_distance();
-
- int curr = 0;
- int x, y;
-
-
- while (this->next_pixel(x, y, curr, this->m_iterations)) {
- this->pix_step(x, y);
- }
- this->m_cached_buffer_ready = true;
- }
-
- unlockMutex();
- return this->m_cached_buffer;
+ if (this->m_cached_buffer_ready) {
+ return this->m_cached_buffer;
+ }
+ lockMutex();
+ if (!this->m_cached_buffer_ready) {
+ MemoryBuffer *buf = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
+ this->m_cached_buffer = (float *)MEM_dupallocN(buf->getBuffer());
+
+ this->calc_manhatten_distance();
+
+ int curr = 0;
+ int x, y;
+
+ while (this->next_pixel(x, y, curr, this->m_iterations)) {
+ this->pix_step(x, y);
+ }
+ this->m_cached_buffer_ready = true;
+ }
+
+ unlockMutex();
+ return this->m_cached_buffer;
}
void InpaintSimpleOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- this->clamp_xy(x, y);
- copy_v4_v4(output, this->get_pixel(x, y));
+ this->clamp_xy(x, y);
+ copy_v4_v4(output, this->get_pixel(x, y));
}
void InpaintSimpleOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->deinitMutex();
- if (this->m_cached_buffer) {
- MEM_freeN(this->m_cached_buffer);
- this->m_cached_buffer = NULL;
- }
-
- if (this->m_pixelorder) {
- MEM_freeN(this->m_pixelorder);
- this->m_pixelorder = NULL;
- }
-
- if (this->m_manhatten_distance) {
- MEM_freeN(this->m_manhatten_distance);
- this->m_manhatten_distance = NULL;
- }
- this->m_cached_buffer_ready = false;
+ this->m_inputImageProgram = NULL;
+ this->deinitMutex();
+ if (this->m_cached_buffer) {
+ MEM_freeN(this->m_cached_buffer);
+ this->m_cached_buffer = NULL;
+ }
+
+ if (this->m_pixelorder) {
+ MEM_freeN(this->m_pixelorder);
+ this->m_pixelorder = NULL;
+ }
+
+ if (this->m_manhatten_distance) {
+ MEM_freeN(this->m_manhatten_distance);
+ this->m_manhatten_distance = NULL;
+ }
+ this->m_cached_buffer_ready = false;
}
-bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- if (this->m_cached_buffer_ready) {
- return false;
- }
- else {
- rcti newInput;
-
- newInput.xmax = getWidth();
- newInput.xmin = 0;
- newInput.ymax = getHeight();
- newInput.ymin = 0;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
+ if (this->m_cached_buffer_ready) {
+ return false;
+ }
+ else {
+ rcti newInput;
+
+ newInput.xmax = getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = getHeight();
+ newInput.ymin = 0;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
}
diff --git a/source/blender/compositor/operations/COM_InpaintOperation.h b/source/blender/compositor/operations/COM_InpaintOperation.h
index 3bad383f51e..2fef7c590ea 100644
--- a/source/blender/compositor/operations/COM_InpaintOperation.h
+++ b/source/blender/compositor/operations/COM_InpaintOperation.h
@@ -21,51 +21,56 @@
#include "COM_NodeOperation.h"
class InpaintSimpleOperation : public NodeOperation {
-protected:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputImageProgram;
+ protected:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputImageProgram;
- int m_iterations;
+ int m_iterations;
- float *m_cached_buffer;
- bool m_cached_buffer_ready;
+ float *m_cached_buffer;
+ bool m_cached_buffer_ready;
- int *m_pixelorder;
- int m_area_size;
- short *m_manhatten_distance;
-public:
- InpaintSimpleOperation();
+ int *m_pixelorder;
+ int m_area_size;
+ short *m_manhatten_distance;
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ InpaintSimpleOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setIterations(int iterations) { this->m_iterations = iterations; }
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void setIterations(int iterations)
+ {
+ this->m_iterations = iterations;
+ }
-private:
- void calc_manhatten_distance();
- void clamp_xy(int &x, int &y);
- float *get_pixel(int x, int y);
- int mdist(int x, int y);
- bool next_pixel(int &x, int &y, int &curr, int iters);
- void pix_step(int x, int y);
-};
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ private:
+ void calc_manhatten_distance();
+ void clamp_xy(int &x, int &y);
+ float *get_pixel(int x, int y);
+ int mdist(int x, int y);
+ bool next_pixel(int &x, int &y, int &curr, int iters);
+ void pix_step(int x, int y);
+};
#endif
diff --git a/source/blender/compositor/operations/COM_InvertOperation.cpp b/source/blender/compositor/operations/COM_InvertOperation.cpp
index 17b86fba076..632dbdbfa4e 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_InvertOperation.cpp
@@ -20,49 +20,48 @@
InvertOperation::InvertOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueProgram = NULL;
- this->m_inputColorProgram = NULL;
- this->m_color = true;
- this->m_alpha = false;
- setResolutionInputSocketIndex(1);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputValueProgram = NULL;
+ this->m_inputColorProgram = NULL;
+ this->m_color = true;
+ this->m_alpha = false;
+ setResolutionInputSocketIndex(1);
}
void InvertOperation::initExecution()
{
- this->m_inputValueProgram = this->getInputSocketReader(0);
- this->m_inputColorProgram = this->getInputSocketReader(1);
+ this->m_inputValueProgram = this->getInputSocketReader(0);
+ this->m_inputColorProgram = this->getInputSocketReader(1);
}
void InvertOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputValue[4];
- float inputColor[4];
- this->m_inputValueProgram->readSampled(inputValue, x, y, sampler);
- this->m_inputColorProgram->readSampled(inputColor, x, y, sampler);
+ float inputValue[4];
+ float inputColor[4];
+ this->m_inputValueProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputColorProgram->readSampled(inputColor, x, y, sampler);
- const float value = inputValue[0];
- const float invertedValue = 1.0f - value;
+ const float value = inputValue[0];
+ const float invertedValue = 1.0f - value;
- if (this->m_color) {
- output[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue;
- output[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue;
- output[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue;
- }
- else {
- copy_v3_v3(output, inputColor);
- }
-
- if (this->m_alpha)
- output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
- else
- output[3] = inputColor[3];
+ if (this->m_color) {
+ output[0] = (1.0f - inputColor[0]) * value + inputColor[0] * invertedValue;
+ output[1] = (1.0f - inputColor[1]) * value + inputColor[1] * invertedValue;
+ output[2] = (1.0f - inputColor[2]) * value + inputColor[2] * invertedValue;
+ }
+ else {
+ copy_v3_v3(output, inputColor);
+ }
+ if (this->m_alpha)
+ output[3] = (1.0f - inputColor[3]) * value + inputColor[3] * invertedValue;
+ else
+ output[3] = inputColor[3];
}
void InvertOperation::deinitExecution()
{
- this->m_inputValueProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputValueProgram = NULL;
+ this->m_inputColorProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_InvertOperation.h b/source/blender/compositor/operations/COM_InvertOperation.h
index a5d2d498641..39161455a76 100644
--- a/source/blender/compositor/operations/COM_InvertOperation.h
+++ b/source/blender/compositor/operations/COM_InvertOperation.h
@@ -20,37 +20,42 @@
#define __COM_INVERTOPERATION_H__
#include "COM_NodeOperation.h"
-
class InvertOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputValueProgram;
- SocketReader *m_inputColorProgram;
-
- bool m_alpha;
- bool m_color;
-
-public:
- InvertOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void setColor(bool color) { this->m_color = color; }
- void setAlpha(bool alpha) { this->m_alpha = alpha; }
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputValueProgram;
+ SocketReader *m_inputColorProgram;
+
+ bool m_alpha;
+ bool m_color;
+
+ public:
+ InvertOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void setColor(bool color)
+ {
+ this->m_color = color;
+ }
+ void setAlpha(bool alpha)
+ {
+ this->m_alpha = alpha;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
index 71386c20886..300d122589f 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
@@ -25,70 +25,71 @@
KeyingBlurOperation::KeyingBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
- this->m_size = 0;
- this->m_axis = BLUR_AXIS_X;
+ this->m_size = 0;
+ this->m_axis = BLUR_AXIS_X;
- this->setComplex(true);
+ this->setComplex(true);
}
void *KeyingBlurOperation::initializeTileData(rcti *rect)
{
- void *buffer = getInputOperation(0)->initializeTileData(rect);
+ void *buffer = getInputOperation(0)->initializeTileData(rect);
- return buffer;
+ return buffer;
}
void KeyingBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- const int bufferWidth = inputBuffer->getWidth();
- float *buffer = inputBuffer->getBuffer();
- int count = 0;
- float average = 0.0f;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ const int bufferWidth = inputBuffer->getWidth();
+ float *buffer = inputBuffer->getBuffer();
+ int count = 0;
+ float average = 0.0f;
- if (this->m_axis == 0) {
- const int start = max(0, x - this->m_size + 1),
- end = min(bufferWidth, x + this->m_size);
- for (int cx = start; cx < end; ++cx) {
- int bufferIndex = (y * bufferWidth + cx);
- average += buffer[bufferIndex];
- count++;
- }
- }
- else {
- const int start = max(0, y - this->m_size + 1),
- end = min(inputBuffer->getHeight(), y + this->m_size);
- for (int cy = start; cy < end; ++cy) {
- int bufferIndex = (cy * bufferWidth + x);
- average += buffer[bufferIndex];
- count++;
- }
- }
+ if (this->m_axis == 0) {
+ const int start = max(0, x - this->m_size + 1), end = min(bufferWidth, x + this->m_size);
+ for (int cx = start; cx < end; ++cx) {
+ int bufferIndex = (y * bufferWidth + cx);
+ average += buffer[bufferIndex];
+ count++;
+ }
+ }
+ else {
+ const int start = max(0, y - this->m_size + 1),
+ end = min(inputBuffer->getHeight(), y + this->m_size);
+ for (int cy = start; cy < end; ++cy) {
+ int bufferIndex = (cy * bufferWidth + x);
+ average += buffer[bufferIndex];
+ count++;
+ }
+ }
- average /= (float) count;
+ average /= (float)count;
- output[0] = average;
+ output[0] = average;
}
-bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- if (this->m_axis == BLUR_AXIS_X) {
- newInput.xmin = input->xmin - this->m_size;
- newInput.ymin = input->ymin;
- newInput.xmax = input->xmax + this->m_size;
- newInput.ymax = input->ymax;
- }
- else {
- newInput.xmin = input->xmin;
- newInput.ymin = input->ymin - this->m_size;
- newInput.xmax = input->xmax;
- newInput.ymax = input->ymax + this->m_size;
- }
+ if (this->m_axis == BLUR_AXIS_X) {
+ newInput.xmin = input->xmin - this->m_size;
+ newInput.ymin = input->ymin;
+ newInput.xmax = input->xmax + this->m_size;
+ newInput.ymax = input->ymax;
+ }
+ else {
+ newInput.xmin = input->xmin;
+ newInput.ymin = input->ymin - this->m_size;
+ newInput.xmax = input->xmax;
+ newInput.ymax = input->ymax + this->m_size;
+ }
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
index 76360d7fd6b..0e45f1c32b8 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
@@ -25,26 +25,34 @@
* Class with implementation of blurring for keying node
*/
class KeyingBlurOperation : public NodeOperation {
-protected:
- int m_size;
- int m_axis;
-
-public:
- enum BlurAxis {
- BLUR_AXIS_X = 0,
- BLUR_AXIS_Y = 1,
- };
-
- KeyingBlurOperation();
-
- void setSize(int value) {this->m_size = value;}
- void setAxis(int value) {this->m_axis = value;}
-
- void *initializeTileData(rcti *rect);
-
- void executePixel(float output[4], int x, int y, void *data);
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ protected:
+ int m_size;
+ int m_axis;
+
+ public:
+ enum BlurAxis {
+ BLUR_AXIS_X = 0,
+ BLUR_AXIS_Y = 1,
+ };
+
+ KeyingBlurOperation();
+
+ void setSize(int value)
+ {
+ this->m_size = value;
+ }
+ void setAxis(int value)
+ {
+ this->m_axis = value;
+ }
+
+ void *initializeTileData(rcti *rect);
+
+ void executePixel(float output[4], int x, int y, void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
index f4600c753ba..89fa8a8d303 100644
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.cpp
@@ -25,99 +25,100 @@
KeyingClipOperation::KeyingClipOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
- this->m_kernelRadius = 3;
- this->m_kernelTolerance = 0.1f;
+ this->m_kernelRadius = 3;
+ this->m_kernelTolerance = 0.1f;
- this->m_clipBlack = 0.0f;
- this->m_clipWhite = 1.0f;
+ this->m_clipBlack = 0.0f;
+ this->m_clipWhite = 1.0f;
- this->m_isEdgeMatte = false;
+ this->m_isEdgeMatte = false;
- this->setComplex(true);
+ this->setComplex(true);
}
void *KeyingClipOperation::initializeTileData(rcti *rect)
{
- void *buffer = getInputOperation(0)->initializeTileData(rect);
+ void *buffer = getInputOperation(0)->initializeTileData(rect);
- return buffer;
+ return buffer;
}
void KeyingClipOperation::executePixel(float output[4], int x, int y, void *data)
{
- const int delta = this->m_kernelRadius;
- const float tolerance = this->m_kernelTolerance;
-
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- float *buffer = inputBuffer->getBuffer();
-
- int bufferWidth = inputBuffer->getWidth();
- int bufferHeight = inputBuffer->getHeight();
-
- float value = buffer[(y * bufferWidth + x)];
-
- bool ok = false;
- int start_x = max_ff(0, x - delta + 1),
- start_y = max_ff(0, y - delta + 1),
- end_x = min_ff(x + delta - 1, bufferWidth - 1),
- end_y = min_ff(y + delta - 1, bufferHeight - 1);
-
- int count = 0, totalCount = (end_x - start_x + 1) * (end_y - start_y + 1) - 1;
- int thresholdCount = ceil((float) totalCount * 0.9f);
-
- if (delta == 0) {
- ok = true;
- }
-
- for (int cx = start_x; ok == false && cx <= end_x; ++cx) {
- for (int cy = start_y; ok == false && cy <= end_y; ++cy) {
- if (UNLIKELY(cx == x && cy == y)) {
- continue;
- }
-
- int bufferIndex = (cy * bufferWidth + cx);
- float currentValue = buffer[bufferIndex];
-
- if (fabsf(currentValue - value) < tolerance) {
- count++;
- if (count >= thresholdCount) {
- ok = true;
- }
- }
- }
- }
-
- if (this->m_isEdgeMatte) {
- if (ok)
- output[0] = 0.0f;
- else
- output[0] = 1.0f;
- }
- else {
- output[0] = value;
-
- if (ok) {
- if (output[0] < this->m_clipBlack)
- output[0] = 0.0f;
- else if (output[0] >= this->m_clipWhite)
- output[0] = 1.0f;
- else
- output[0] = (output[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack);
- }
- }
+ const int delta = this->m_kernelRadius;
+ const float tolerance = this->m_kernelTolerance;
+
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ float *buffer = inputBuffer->getBuffer();
+
+ int bufferWidth = inputBuffer->getWidth();
+ int bufferHeight = inputBuffer->getHeight();
+
+ float value = buffer[(y * bufferWidth + x)];
+
+ bool ok = false;
+ int start_x = max_ff(0, x - delta + 1), start_y = max_ff(0, y - delta + 1),
+ end_x = min_ff(x + delta - 1, bufferWidth - 1),
+ end_y = min_ff(y + delta - 1, bufferHeight - 1);
+
+ int count = 0, totalCount = (end_x - start_x + 1) * (end_y - start_y + 1) - 1;
+ int thresholdCount = ceil((float)totalCount * 0.9f);
+
+ if (delta == 0) {
+ ok = true;
+ }
+
+ for (int cx = start_x; ok == false && cx <= end_x; ++cx) {
+ for (int cy = start_y; ok == false && cy <= end_y; ++cy) {
+ if (UNLIKELY(cx == x && cy == y)) {
+ continue;
+ }
+
+ int bufferIndex = (cy * bufferWidth + cx);
+ float currentValue = buffer[bufferIndex];
+
+ if (fabsf(currentValue - value) < tolerance) {
+ count++;
+ if (count >= thresholdCount) {
+ ok = true;
+ }
+ }
+ }
+ }
+
+ if (this->m_isEdgeMatte) {
+ if (ok)
+ output[0] = 0.0f;
+ else
+ output[0] = 1.0f;
+ }
+ else {
+ output[0] = value;
+
+ if (ok) {
+ if (output[0] < this->m_clipBlack)
+ output[0] = 0.0f;
+ else if (output[0] >= this->m_clipWhite)
+ output[0] = 1.0f;
+ else
+ output[0] = (output[0] - this->m_clipBlack) / (this->m_clipWhite - this->m_clipBlack);
+ }
+ }
}
-bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool KeyingClipOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmin = input->xmin - this->m_kernelRadius;
- newInput.ymin = input->ymin - this->m_kernelRadius;
- newInput.xmax = input->xmax + this->m_kernelRadius;
- newInput.ymax = input->ymax + this->m_kernelRadius;
+ newInput.xmin = input->xmin - this->m_kernelRadius;
+ newInput.ymin = input->ymin - this->m_kernelRadius;
+ newInput.xmax = input->xmax + this->m_kernelRadius;
+ newInput.ymax = input->ymax + this->m_kernelRadius;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h
index 6f8922c0124..8237c443cf2 100644
--- a/source/blender/compositor/operations/COM_KeyingClipOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h
@@ -25,30 +25,48 @@
* Class with implementation of black/white clipping for keying node
*/
class KeyingClipOperation : public NodeOperation {
-protected:
- float m_clipBlack;
- float m_clipWhite;
+ protected:
+ float m_clipBlack;
+ float m_clipWhite;
- int m_kernelRadius;
- float m_kernelTolerance;
+ int m_kernelRadius;
+ float m_kernelTolerance;
- bool m_isEdgeMatte;
-public:
- KeyingClipOperation();
+ bool m_isEdgeMatte;
- void setClipBlack(float value) {this->m_clipBlack = value;}
- void setClipWhite(float value) {this->m_clipWhite = value;}
+ public:
+ KeyingClipOperation();
- void setKernelRadius(int value) {this->m_kernelRadius = value;}
- void setKernelTolerance(float value) {this->m_kernelTolerance = value;}
+ void setClipBlack(float value)
+ {
+ this->m_clipBlack = value;
+ }
+ void setClipWhite(float value)
+ {
+ this->m_clipWhite = value;
+ }
- void setIsEdgeMatte(bool value) {this->m_isEdgeMatte = value;}
+ void setKernelRadius(int value)
+ {
+ this->m_kernelRadius = value;
+ }
+ void setKernelTolerance(float value)
+ {
+ this->m_kernelTolerance = value;
+ }
- void *initializeTileData(rcti *rect);
+ void setIsEdgeMatte(bool value)
+ {
+ this->m_isEdgeMatte = value;
+ }
- void executePixel(float output[4], int x, int y, void *data);
+ void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void executePixel(float output[4], int x, int y, void *data);
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
index 9b3e89dc1f7..a1ba49a69b2 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -25,53 +25,57 @@
KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
- this->m_despillFactor = 0.5f;
- this->m_colorBalance = 0.5f;
+ this->m_despillFactor = 0.5f;
+ this->m_colorBalance = 0.5f;
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = NULL;
+ this->m_screenReader = NULL;
}
void KeyingDespillOperation::initExecution()
{
- this->m_pixelReader = this->getInputSocketReader(0);
- this->m_screenReader = this->getInputSocketReader(1);
+ this->m_pixelReader = this->getInputSocketReader(0);
+ this->m_screenReader = this->getInputSocketReader(1);
}
void KeyingDespillOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = NULL;
+ this->m_screenReader = NULL;
}
-void KeyingDespillOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void KeyingDespillOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float pixelColor[4];
- float screenColor[4];
+ float pixelColor[4];
+ float screenColor[4];
- this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
- this->m_screenReader->readSampled(screenColor, x, y, sampler);
+ this->m_pixelReader->readSampled(pixelColor, x, y, sampler);
+ this->m_screenReader->readSampled(screenColor, x, y, sampler);
- const int screen_primary_channel = max_axis_v3(screenColor);
- const int other_1 = (screen_primary_channel + 1) % 3;
- const int other_2 = (screen_primary_channel + 2) % 3;
+ const int screen_primary_channel = max_axis_v3(screenColor);
+ const int other_1 = (screen_primary_channel + 1) % 3;
+ const int other_2 = (screen_primary_channel + 2) % 3;
- const int min_channel = min(other_1, other_2);
- const int max_channel = max(other_1, other_2);
+ const int min_channel = min(other_1, other_2);
+ const int max_channel = max(other_1, other_2);
- float average_value, amount;
+ float average_value, amount;
- average_value = this->m_colorBalance * pixelColor[min_channel] + (1.0f - this->m_colorBalance) * pixelColor[max_channel];
- amount = (pixelColor[screen_primary_channel] - average_value);
+ average_value = this->m_colorBalance * pixelColor[min_channel] +
+ (1.0f - this->m_colorBalance) * pixelColor[max_channel];
+ amount = (pixelColor[screen_primary_channel] - average_value);
- copy_v4_v4(output, pixelColor);
+ copy_v4_v4(output, pixelColor);
- const float amount_despill = this->m_despillFactor * amount;
- if (amount_despill > 0.0f) {
- output[screen_primary_channel] = pixelColor[screen_primary_channel] - amount_despill;
- }
+ const float amount_despill = this->m_despillFactor * amount;
+ if (amount_despill > 0.0f) {
+ output[screen_primary_channel] = pixelColor[screen_primary_channel] - amount_despill;
+ }
}
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
index 13f15c12d0c..eb43a478e50 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
@@ -25,22 +25,28 @@
* Class with implementation of keying despill node
*/
class KeyingDespillOperation : public NodeOperation {
-protected:
- SocketReader *m_pixelReader;
- SocketReader *m_screenReader;
- float m_despillFactor;
- float m_colorBalance;
-
-public:
- KeyingDespillOperation();
-
- void initExecution();
- void deinitExecution();
-
- void setDespillFactor(float value) {this->m_despillFactor = value;}
- void setColorBalance(float value) {this->m_colorBalance = value;}
-
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ protected:
+ SocketReader *m_pixelReader;
+ SocketReader *m_screenReader;
+ float m_despillFactor;
+ float m_colorBalance;
+
+ public:
+ KeyingDespillOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void setDespillFactor(float value)
+ {
+ this->m_despillFactor = value;
+ }
+ void setColorBalance(float value)
+ {
+ this->m_colorBalance = value;
+ }
+
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index 53bb696866a..50562143ce6 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -23,83 +23,87 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-static float get_pixel_saturation(const float pixelColor[4], float screen_balance, int primary_channel)
+static float get_pixel_saturation(const float pixelColor[4],
+ float screen_balance,
+ int primary_channel)
{
- const int other_1 = (primary_channel + 1) % 3;
- const int other_2 = (primary_channel + 2) % 3;
+ const int other_1 = (primary_channel + 1) % 3;
+ const int other_2 = (primary_channel + 2) % 3;
- const int min_channel = min(other_1, other_2);
- const int max_channel = max(other_1, other_2);
+ const int min_channel = min(other_1, other_2);
+ const int max_channel = max(other_1, other_2);
- const float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
+ const float val = screen_balance * pixelColor[min_channel] +
+ (1.0f - screen_balance) * pixelColor[max_channel];
- return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
+ return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
}
KeyingOperation::KeyingOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_VALUE);
- this->m_screenBalance = 0.5f;
+ this->m_screenBalance = 0.5f;
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = NULL;
+ this->m_screenReader = NULL;
}
void KeyingOperation::initExecution()
{
- this->m_pixelReader = this->getInputSocketReader(0);
- this->m_screenReader = this->getInputSocketReader(1);
+ this->m_pixelReader = this->getInputSocketReader(0);
+ this->m_screenReader = this->getInputSocketReader(1);
}
void KeyingOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
- this->m_screenReader = NULL;
+ this->m_pixelReader = NULL;
+ this->m_screenReader = NULL;
}
void KeyingOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float pixel_color[4];
- float screen_color[4];
-
- this->m_pixelReader->readSampled(pixel_color, x, y, sampler);
- this->m_screenReader->readSampled(screen_color, x, y, sampler);
-
- const int primary_channel = max_axis_v3(screen_color);
- const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]);
-
- if (min_pixel_color > 1.0f) {
- /* overexposure doesn't happen on screen itself and usually happens
- * on light sources in the shot, this need to be checked separately
- * because saturation and falloff calculation is based on the fact
- * that pixels are not overexposed
- */
- output[0] = 1.0f;
- }
- else {
- float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel);
- float screen_saturation = get_pixel_saturation(screen_color, this->m_screenBalance, primary_channel);
-
- if (saturation < 0) {
- /* means main channel of pixel is different from screen,
- * assume this is completely a foreground
- */
- output[0] = 1.0f;
- }
- else if (saturation >= screen_saturation) {
- /* matched main channels and higher saturation on pixel
- * is treated as completely background
- */
- output[0] = 0.0f;
- }
- else {
- /* nice alpha falloff on edges */
- float distance = 1.0f - saturation / screen_saturation;
-
- output[0] = distance;
- }
- }
+ float pixel_color[4];
+ float screen_color[4];
+
+ this->m_pixelReader->readSampled(pixel_color, x, y, sampler);
+ this->m_screenReader->readSampled(screen_color, x, y, sampler);
+
+ const int primary_channel = max_axis_v3(screen_color);
+ const float min_pixel_color = min_fff(pixel_color[0], pixel_color[1], pixel_color[2]);
+
+ if (min_pixel_color > 1.0f) {
+ /* overexposure doesn't happen on screen itself and usually happens
+ * on light sources in the shot, this need to be checked separately
+ * because saturation and falloff calculation is based on the fact
+ * that pixels are not overexposed
+ */
+ output[0] = 1.0f;
+ }
+ else {
+ float saturation = get_pixel_saturation(pixel_color, this->m_screenBalance, primary_channel);
+ float screen_saturation = get_pixel_saturation(
+ screen_color, this->m_screenBalance, primary_channel);
+
+ if (saturation < 0) {
+ /* means main channel of pixel is different from screen,
+ * assume this is completely a foreground
+ */
+ output[0] = 1.0f;
+ }
+ else if (saturation >= screen_saturation) {
+ /* matched main channels and higher saturation on pixel
+ * is treated as completely background
+ */
+ output[0] = 0.0f;
+ }
+ else {
+ /* nice alpha falloff on edges */
+ float distance = 1.0f - saturation / screen_saturation;
+
+ output[0] = distance;
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h
index 194d6eb0027..81d23e76b2a 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingOperation.h
@@ -16,7 +16,6 @@
* Copyright 2012, Blender Foundation.
*/
-
#ifndef __COM_KEYINGOPERATION_H__
#define __COM_KEYINGOPERATION_H__
@@ -30,21 +29,24 @@
* Class with implementation of keying node
*/
class KeyingOperation : public NodeOperation {
-protected:
- SocketReader *m_pixelReader;
- SocketReader *m_screenReader;
+ protected:
+ SocketReader *m_pixelReader;
+ SocketReader *m_screenReader;
- float m_screenBalance;
+ float m_screenBalance;
-public:
- KeyingOperation();
+ public:
+ KeyingOperation();
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setScreenBalance(float value) {this->m_screenBalance = value;}
+ void setScreenBalance(float value)
+ {
+ this->m_screenBalance = value;
+ }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
index 6e5d40c6621..03a6bf6a7dd 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
@@ -25,306 +25,313 @@
#include "BLI_math_color.h"
extern "C" {
-# include "BKE_movieclip.h"
-# include "BKE_tracking.h"
+#include "BKE_movieclip.h"
+#include "BKE_tracking.h"
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
}
KeyingScreenOperation::KeyingScreenOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
- this->m_movieClip = NULL;
- this->m_framenumber = 0;
- this->m_trackingObject[0] = 0;
- setComplex(true);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_movieClip = NULL;
+ this->m_framenumber = 0;
+ this->m_trackingObject[0] = 0;
+ setComplex(true);
}
void KeyingScreenOperation::initExecution()
{
- initMutex();
- this->m_cachedTriangulation = NULL;
+ initMutex();
+ this->m_cachedTriangulation = NULL;
}
void KeyingScreenOperation::deinitExecution()
{
- if (this->m_cachedTriangulation) {
- TriangulationData *triangulation = this->m_cachedTriangulation;
+ if (this->m_cachedTriangulation) {
+ TriangulationData *triangulation = this->m_cachedTriangulation;
- if (triangulation->triangulated_points)
- MEM_freeN(triangulation->triangulated_points);
+ if (triangulation->triangulated_points)
+ MEM_freeN(triangulation->triangulated_points);
- if (triangulation->triangles)
- MEM_freeN(triangulation->triangles);
+ if (triangulation->triangles)
+ MEM_freeN(triangulation->triangles);
- if (triangulation->triangles_AABB)
- MEM_freeN(triangulation->triangles_AABB);
+ if (triangulation->triangles_AABB)
+ MEM_freeN(triangulation->triangles_AABB);
- MEM_freeN(this->m_cachedTriangulation);
+ MEM_freeN(this->m_cachedTriangulation);
- this->m_cachedTriangulation = NULL;
- }
+ this->m_cachedTriangulation = NULL;
+ }
}
KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTriangulation()
{
- MovieClipUser user = {0};
- TriangulationData *triangulation;
- MovieTracking *tracking = &this->m_movieClip->tracking;
- MovieTrackingTrack *track;
- VoronoiSite *sites, *site;
- ImBuf *ibuf;
- ListBase *tracksbase;
- ListBase edges = {NULL, NULL};
- int sites_total;
- int i;
- int width = this->getWidth();
- int height = this->getHeight();
- int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber);
+ MovieClipUser user = {0};
+ TriangulationData *triangulation;
+ MovieTracking *tracking = &this->m_movieClip->tracking;
+ MovieTrackingTrack *track;
+ VoronoiSite *sites, *site;
+ ImBuf *ibuf;
+ ListBase *tracksbase;
+ ListBase edges = {NULL, NULL};
+ int sites_total;
+ int i;
+ int width = this->getWidth();
+ int height = this->getHeight();
+ int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber);
+
+ if (this->m_trackingObject[0]) {
+ MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
+
+ if (!object)
+ return NULL;
+
+ tracksbase = BKE_tracking_object_get_tracks(tracking, object);
+ }
+ else
+ tracksbase = BKE_tracking_get_active_tracks(tracking);
+
+ /* count sites */
+ for (track = (MovieTrackingTrack *)tracksbase->first, sites_total = 0; track;
+ track = track->next) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
+ float pos[2];
+
+ if (marker->flag & MARKER_DISABLED)
+ continue;
+
+ add_v2_v2v2(pos, marker->pos, track->offset);
+
+ if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) {
+ continue;
+ }
+
+ sites_total++;
+ }
+
+ if (!sites_total)
+ return NULL;
+
+ BKE_movieclip_user_set_frame(&user, clip_frame);
+ ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
+
+ if (!ibuf)
+ return NULL;
+
+ triangulation = (TriangulationData *)MEM_callocN(sizeof(TriangulationData),
+ "keying screen triangulation data");
+
+ sites = (VoronoiSite *)MEM_callocN(sizeof(VoronoiSite) * sites_total,
+ "keyingscreen voronoi sites");
+ track = (MovieTrackingTrack *)tracksbase->first;
+ for (track = (MovieTrackingTrack *)tracksbase->first, site = sites; track; track = track->next) {
+ MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
+ ImBuf *pattern_ibuf;
+ int j;
+ float pos[2];
+
+ if (marker->flag & MARKER_DISABLED)
+ continue;
+
+ add_v2_v2v2(pos, marker->pos, track->offset);
+
+ if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) || !IN_RANGE_INCL(pos[1], 0.0f, 1.0f)) {
+ continue;
+ }
+
+ pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, true, false);
+
+ zero_v3(site->color);
+
+ if (pattern_ibuf) {
+ for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
+ if (pattern_ibuf->rect_float) {
+ add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
+ }
+ else {
+ unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
+
+ site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
+ site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
+ site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
+ }
+ }
+
+ mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
+ IMB_freeImBuf(pattern_ibuf);
+ }
+
+ site->co[0] = pos[0] * width;
+ site->co[1] = pos[1] * height;
+
+ site++;
+ }
+
+ IMB_freeImBuf(ibuf);
+
+ BLI_voronoi_compute(sites, sites_total, width, height, &edges);
- if (this->m_trackingObject[0]) {
- MovieTrackingObject *object = BKE_tracking_object_get_named(tracking, this->m_trackingObject);
-
- if (!object)
- return NULL;
-
- tracksbase = BKE_tracking_object_get_tracks(tracking, object);
- }
- else
- tracksbase = BKE_tracking_get_active_tracks(tracking);
-
- /* count sites */
- for (track = (MovieTrackingTrack *) tracksbase->first, sites_total = 0; track; track = track->next) {
- MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
- float pos[2];
+ BLI_voronoi_triangulate(sites,
+ sites_total,
+ &edges,
+ width,
+ height,
+ &triangulation->triangulated_points,
+ &triangulation->triangulated_points_total,
+ &triangulation->triangles,
+ &triangulation->triangles_total);
- if (marker->flag & MARKER_DISABLED)
- continue;
+ MEM_freeN(sites);
+ BLI_freelistN(&edges);
- add_v2_v2v2(pos, marker->pos, track->offset);
+ if (triangulation->triangles_total) {
+ rcti *rect;
+ rect = triangulation->triangles_AABB = (rcti *)MEM_callocN(
+ sizeof(rcti) * triangulation->triangles_total, "voronoi triangulation AABB");
- if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) ||
- !IN_RANGE_INCL(pos[1], 0.0f, 1.0f))
- {
- continue;
- }
+ for (i = 0; i < triangulation->triangles_total; i++, rect++) {
+ int *triangle = triangulation->triangles[i];
+ VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]],
+ *b = &triangulation->triangulated_points[triangle[1]],
+ *c = &triangulation->triangulated_points[triangle[2]];
- sites_total++;
- }
+ float min[2], max[2];
- if (!sites_total)
- return NULL;
+ INIT_MINMAX2(min, max);
- BKE_movieclip_user_set_frame(&user, clip_frame);
- ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, &user);
+ minmax_v2v2_v2(min, max, a->co);
+ minmax_v2v2_v2(min, max, b->co);
+ minmax_v2v2_v2(min, max, c->co);
- if (!ibuf)
- return NULL;
+ rect->xmin = (int)min[0];
+ rect->ymin = (int)min[1];
- triangulation = (TriangulationData *) MEM_callocN(sizeof(TriangulationData), "keying screen triangulation data");
+ rect->xmax = (int)max[0] + 1;
+ rect->ymax = (int)max[1] + 1;
+ }
+ }
- sites = (VoronoiSite *) MEM_callocN(sizeof(VoronoiSite) * sites_total, "keyingscreen voronoi sites");
- track = (MovieTrackingTrack *) tracksbase->first;
- for (track = (MovieTrackingTrack *) tracksbase->first, site = sites; track; track = track->next) {
- MovieTrackingMarker *marker = BKE_tracking_marker_get(track, clip_frame);
- ImBuf *pattern_ibuf;
- int j;
- float pos[2];
-
- if (marker->flag & MARKER_DISABLED)
- continue;
-
- add_v2_v2v2(pos, marker->pos, track->offset);
-
- if (!IN_RANGE_INCL(pos[0], 0.0f, 1.0f) ||
- !IN_RANGE_INCL(pos[1], 0.0f, 1.0f))
- {
- continue;
- }
-
- pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, true, false);
-
- zero_v3(site->color);
-
- if (pattern_ibuf) {
- for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
- if (pattern_ibuf->rect_float) {
- add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
- }
- else {
- unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
-
- site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
- site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
- site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
- }
- }
-
- mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
- IMB_freeImBuf(pattern_ibuf);
- }
-
- site->co[0] = pos[0] * width;
- site->co[1] = pos[1] * height;
-
- site++;
- }
-
- IMB_freeImBuf(ibuf);
-
- BLI_voronoi_compute(sites, sites_total, width, height, &edges);
-
- BLI_voronoi_triangulate(sites, sites_total, &edges, width, height,
- &triangulation->triangulated_points, &triangulation->triangulated_points_total,
- &triangulation->triangles, &triangulation->triangles_total);
-
- MEM_freeN(sites);
- BLI_freelistN(&edges);
-
- if (triangulation->triangles_total) {
- rcti *rect;
- rect = triangulation->triangles_AABB =
- (rcti *) MEM_callocN(sizeof(rcti) * triangulation->triangles_total, "voronoi triangulation AABB");
-
- for (i = 0; i < triangulation->triangles_total; i++, rect++) {
- int *triangle = triangulation->triangles[i];
- VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]],
- *b = &triangulation->triangulated_points[triangle[1]],
- *c = &triangulation->triangulated_points[triangle[2]];
-
- float min[2], max[2];
-
- INIT_MINMAX2(min, max);
-
- minmax_v2v2_v2(min, max, a->co);
- minmax_v2v2_v2(min, max, b->co);
- minmax_v2v2_v2(min, max, c->co);
-
- rect->xmin = (int)min[0];
- rect->ymin = (int)min[1];
-
- rect->xmax = (int)max[0] + 1;
- rect->ymax = (int)max[1] + 1;
- }
- }
-
- return triangulation;
+ return triangulation;
}
void *KeyingScreenOperation::initializeTileData(rcti *rect)
{
- TileData *tile_data;
- TriangulationData *triangulation;
- int triangles_allocated = 0;
- int chunk_size = 20;
- int i;
-
- if (this->m_movieClip == NULL)
- return NULL;
-
- if (!this->m_cachedTriangulation) {
- lockMutex();
- if (this->m_cachedTriangulation == NULL) {
- this->m_cachedTriangulation = buildVoronoiTriangulation();
- }
- unlockMutex();
- }
-
- triangulation = this->m_cachedTriangulation;
-
- if (!triangulation)
- return NULL;
-
- tile_data = (TileData *) MEM_callocN(sizeof(TileData), "keying screen tile data");
-
- for (i = 0; i < triangulation->triangles_total; i++) {
- if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], NULL)) {
- tile_data->triangles_total++;
-
- if (tile_data->triangles_total > triangles_allocated) {
- if (!tile_data->triangles) {
- tile_data->triangles = (int *) MEM_mallocN(sizeof(int) * chunk_size,
- "keying screen tile triangles chunk");
- }
- else {
- tile_data->triangles = (int *) MEM_reallocN(tile_data->triangles,
- sizeof(int) * (triangles_allocated + chunk_size));
- }
-
- triangles_allocated += chunk_size;
- }
-
- tile_data->triangles[tile_data->triangles_total - 1] = i;
- }
- }
-
- return tile_data;
+ TileData *tile_data;
+ TriangulationData *triangulation;
+ int triangles_allocated = 0;
+ int chunk_size = 20;
+ int i;
+
+ if (this->m_movieClip == NULL)
+ return NULL;
+
+ if (!this->m_cachedTriangulation) {
+ lockMutex();
+ if (this->m_cachedTriangulation == NULL) {
+ this->m_cachedTriangulation = buildVoronoiTriangulation();
+ }
+ unlockMutex();
+ }
+
+ triangulation = this->m_cachedTriangulation;
+
+ if (!triangulation)
+ return NULL;
+
+ tile_data = (TileData *)MEM_callocN(sizeof(TileData), "keying screen tile data");
+
+ for (i = 0; i < triangulation->triangles_total; i++) {
+ if (BLI_rcti_isect(rect, &triangulation->triangles_AABB[i], NULL)) {
+ tile_data->triangles_total++;
+
+ if (tile_data->triangles_total > triangles_allocated) {
+ if (!tile_data->triangles) {
+ tile_data->triangles = (int *)MEM_mallocN(sizeof(int) * chunk_size,
+ "keying screen tile triangles chunk");
+ }
+ else {
+ tile_data->triangles = (int *)MEM_reallocN(
+ tile_data->triangles, sizeof(int) * (triangles_allocated + chunk_size));
+ }
+
+ triangles_allocated += chunk_size;
+ }
+
+ tile_data->triangles[tile_data->triangles_total - 1] = i;
+ }
+ }
+
+ return tile_data;
}
void KeyingScreenOperation::deinitializeTileData(rcti * /*rect*/, void *data)
{
- TileData *tile_data = (TileData *) data;
+ TileData *tile_data = (TileData *)data;
- if (tile_data->triangles) {
- MEM_freeN(tile_data->triangles);
- }
+ if (tile_data->triangles) {
+ MEM_freeN(tile_data->triangles);
+ }
- MEM_freeN(tile_data);
+ MEM_freeN(tile_data);
}
-void KeyingScreenOperation::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void KeyingScreenOperation::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- resolution[0] = 0;
- resolution[1] = 0;
+ resolution[0] = 0;
+ resolution[1] = 0;
- if (this->m_movieClip) {
- MovieClipUser user = {0};
- int width, height;
- int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber);
+ if (this->m_movieClip) {
+ MovieClipUser user = {0};
+ int width, height;
+ int clip_frame = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
+ this->m_framenumber);
- BKE_movieclip_user_set_frame(&user, clip_frame);
- BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
+ BKE_movieclip_user_set_frame(&user, clip_frame);
+ BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
- resolution[0] = width;
- resolution[1] = height;
- }
+ resolution[0] = width;
+ resolution[1] = height;
+ }
}
void KeyingScreenOperation::executePixel(float output[4], int x, int y, void *data)
{
- output[0] = 0.0f;
- output[1] = 0.0f;
- output[2] = 0.0f;
- output[3] = 1.0f;
-
- if (this->m_movieClip && data) {
- TriangulationData *triangulation = this->m_cachedTriangulation;
- TileData *tile_data = (TileData *) data;
- int i;
- float co[2] = {(float) x, (float) y};
-
- for (i = 0; i < tile_data->triangles_total; i++) {
- int triangle_idx = tile_data->triangles[i];
- rcti *rect = &triangulation->triangles_AABB[triangle_idx];
-
- if (IN_RANGE_INCL(x, rect->xmin, rect->xmax) && IN_RANGE_INCL(y, rect->ymin, rect->ymax)) {
- int *triangle = triangulation->triangles[triangle_idx];
- VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]],
- *b = &triangulation->triangulated_points[triangle[1]],
- *c = &triangulation->triangulated_points[triangle[2]];
- float w[3];
-
- if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) {
- if (barycentric_inside_triangle_v2(w)) {
- output[0] = a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2];
- output[1] = a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2];
- output[2] = a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2];
-
- break;
- }
- }
- }
- }
- }
+ output[0] = 0.0f;
+ output[1] = 0.0f;
+ output[2] = 0.0f;
+ output[3] = 1.0f;
+
+ if (this->m_movieClip && data) {
+ TriangulationData *triangulation = this->m_cachedTriangulation;
+ TileData *tile_data = (TileData *)data;
+ int i;
+ float co[2] = {(float)x, (float)y};
+
+ for (i = 0; i < tile_data->triangles_total; i++) {
+ int triangle_idx = tile_data->triangles[i];
+ rcti *rect = &triangulation->triangles_AABB[triangle_idx];
+
+ if (IN_RANGE_INCL(x, rect->xmin, rect->xmax) && IN_RANGE_INCL(y, rect->ymin, rect->ymax)) {
+ int *triangle = triangulation->triangles[triangle_idx];
+ VoronoiTriangulationPoint *a = &triangulation->triangulated_points[triangle[0]],
+ *b = &triangulation->triangulated_points[triangle[1]],
+ *c = &triangulation->triangulated_points[triangle[2]];
+ float w[3];
+
+ if (barycentric_coords_v2(a->co, b->co, c->co, co, w)) {
+ if (barycentric_inside_triangle_v2(w)) {
+ output[0] = a->color[0] * w[0] + b->color[0] * w[1] + c->color[0] * w[2];
+ output[1] = a->color[1] * w[0] + b->color[1] * w[1] + c->color[1] * w[2];
+ output[2] = a->color[2] * w[0] + b->color[2] * w[1] + c->color[2] * w[2];
+
+ break;
+ }
+ }
+ }
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_KeyingScreenOperation.h b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
index e11905fbfac..860a358e79d 100644
--- a/source/blender/compositor/operations/COM_KeyingScreenOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingScreenOperation.h
@@ -16,7 +16,6 @@
* Copyright 2012, Blender Foundation.
*/
-
#ifndef __COM_KEYINGSCREENOPERATION_H__
#define __COM_KEYINGSCREENOPERATION_H__
@@ -30,52 +29,61 @@
#include "BLI_string.h"
extern "C" {
-# include "BLI_voronoi_2d.h"
+#include "BLI_voronoi_2d.h"
}
/**
* Class with implementation of green screen gradient rasterization
*/
class KeyingScreenOperation : public NodeOperation {
-protected:
- typedef struct TriangulationData {
- VoronoiTriangulationPoint *triangulated_points;
- int (*triangles)[3];
- int triangulated_points_total, triangles_total;
- rcti *triangles_AABB;
- } TriangulationData;
-
- typedef struct TileData {
- int *triangles;
- int triangles_total;
- } TileData;
-
- MovieClip *m_movieClip;
- int m_framenumber;
- TriangulationData *m_cachedTriangulation;
- char m_trackingObject[64];
-
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- TriangulationData *buildVoronoiTriangulation();
-
-public:
- KeyingScreenOperation();
-
- void initExecution();
- void deinitExecution();
-
- void *initializeTileData(rcti *rect);
- void deinitializeTileData(rcti *rect, void *data);
-
- void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
- void setTrackingObject(const char *object) { BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject)); }
- void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
-
- void executePixel(float output[4], int x, int y, void *data);
+ protected:
+ typedef struct TriangulationData {
+ VoronoiTriangulationPoint *triangulated_points;
+ int (*triangles)[3];
+ int triangulated_points_total, triangles_total;
+ rcti *triangles_AABB;
+ } TriangulationData;
+
+ typedef struct TileData {
+ int *triangles;
+ int triangles_total;
+ } TileData;
+
+ MovieClip *m_movieClip;
+ int m_framenumber;
+ TriangulationData *m_cachedTriangulation;
+ char m_trackingObject[64];
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ TriangulationData *buildVoronoiTriangulation();
+
+ public:
+ KeyingScreenOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
+
+ void setMovieClip(MovieClip *clip)
+ {
+ this->m_movieClip = clip;
+ }
+ void setTrackingObject(const char *object)
+ {
+ BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
+
+ void executePixel(float output[4], int x, int y, void *data);
};
#endif
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
index 4b98da47f43..30ad954e0bc 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp
@@ -25,52 +25,55 @@ extern "C" {
LuminanceMatteOperation::LuminanceMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = NULL;
}
void LuminanceMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
}
void LuminanceMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
+ this->m_inputImageProgram = NULL;
}
-void LuminanceMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void LuminanceMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inColor[4];
- this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
+ float inColor[4];
+ this->m_inputImageProgram->readSampled(inColor, x, y, sampler);
- const float high = this->m_settings->t1;
- const float low = this->m_settings->t2;
- const float luminance = IMB_colormanagement_get_luminance(inColor);
+ const float high = this->m_settings->t1;
+ const float low = this->m_settings->t2;
+ const float luminance = IMB_colormanagement_get_luminance(inColor);
- float alpha;
+ float alpha;
- /* one line thread-friend algorithm:
- * output[0] = min(inputValue[3], min(1.0f, max(0.0f, ((luminance - low) / (high - low))));
- */
+ /* one line thread-friend algorithm:
+ * output[0] = min(inputValue[3], min(1.0f, max(0.0f, ((luminance - low) / (high - low))));
+ */
- /* test range */
- if (luminance > high) {
- alpha = 1.0f;
- }
- else if (luminance < low) {
- alpha = 0.0f;
- }
- else { /*blend */
- alpha = (luminance - low) / (high - low);
- }
+ /* test range */
+ if (luminance > high) {
+ alpha = 1.0f;
+ }
+ else if (luminance < low) {
+ alpha = 0.0f;
+ }
+ else { /*blend */
+ alpha = (luminance - low) / (high - low);
+ }
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
- /* don't make something that was more transparent less transparent */
- output[0] = min_ff(alpha, inColor[3]);
+ /* don't make something that was more transparent less transparent */
+ output[0] = min_ff(alpha, inColor[3]);
}
diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
index 890fa6ee3b3..2df7847f7ff 100644
--- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
+++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h
@@ -20,29 +20,32 @@
#define __COM_LUMINANCEMATTEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class LuminanceMatteOperation : public NodeOperation {
-private:
- NodeChroma *m_settings;
- SocketReader *m_inputImageProgram;
-public:
- /**
- * Default constructor
- */
- LuminanceMatteOperation();
+ private:
+ NodeChroma *m_settings;
+ SocketReader *m_inputImageProgram;
+
+ public:
+ /**
+ * Default constructor
+ */
+ LuminanceMatteOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void setSettings(NodeChroma *nodeChroma) { this->m_settings = nodeChroma; }
+ void setSettings(NodeChroma *nodeChroma)
+ {
+ this->m_settings = nodeChroma;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.cpp b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
index e32158132d7..489f0dabdaf 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.cpp
@@ -20,78 +20,81 @@
MapRangeOperation::MapRangeOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
- this->m_useClamp = false;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputOperation = NULL;
+ this->m_useClamp = false;
}
void MapRangeOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_sourceMinOperation = this->getInputSocketReader(1);
- this->m_sourceMaxOperation = this->getInputSocketReader(2);
- this->m_destMinOperation = this->getInputSocketReader(3);
- this->m_destMaxOperation = this->getInputSocketReader(4);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_sourceMinOperation = this->getInputSocketReader(1);
+ this->m_sourceMaxOperation = this->getInputSocketReader(2);
+ this->m_destMinOperation = this->getInputSocketReader(3);
+ this->m_destMaxOperation = this->getInputSocketReader(4);
}
/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
#define BLENDER_ZMAX 10000.0f
-void MapRangeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MapRangeOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputs[8]; /* includes the 5 inputs + 3 pads */
- float value;
- float source_min, source_max;
- float dest_min, dest_max;
+ float inputs[8]; /* includes the 5 inputs + 3 pads */
+ float value;
+ float source_min, source_max;
+ float dest_min, dest_max;
- this->m_inputOperation->readSampled(inputs, x, y, sampler);
- this->m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler);
- this->m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler);
- this->m_destMinOperation->readSampled(inputs + 3, x, y, sampler);
- this->m_destMaxOperation->readSampled(inputs + 4, x, y, sampler);
+ this->m_inputOperation->readSampled(inputs, x, y, sampler);
+ this->m_sourceMinOperation->readSampled(inputs + 1, x, y, sampler);
+ this->m_sourceMaxOperation->readSampled(inputs + 2, x, y, sampler);
+ this->m_destMinOperation->readSampled(inputs + 3, x, y, sampler);
+ this->m_destMaxOperation->readSampled(inputs + 4, x, y, sampler);
- value = inputs[0];
- source_min = inputs[1];
- source_max = inputs[2];
- dest_min = inputs[3];
- dest_max = inputs[4];
+ value = inputs[0];
+ source_min = inputs[1];
+ source_max = inputs[2];
+ dest_min = inputs[3];
+ dest_max = inputs[4];
- if (fabsf(source_max - source_min) < 1e-6f) {
- output[0] = 0.0f;
- return;
- }
+ if (fabsf(source_max - source_min) < 1e-6f) {
+ output[0] = 0.0f;
+ return;
+ }
- if (value >= -BLENDER_ZMAX && value <= BLENDER_ZMAX) {
- value = (value - source_min) / (source_max - source_min);
- value = dest_min + value * (dest_max - dest_min);
- }
- else if (value > BLENDER_ZMAX)
- value = dest_max;
- else
- value = dest_min;
+ if (value >= -BLENDER_ZMAX && value <= BLENDER_ZMAX) {
+ value = (value - source_min) / (source_max - source_min);
+ value = dest_min + value * (dest_max - dest_min);
+ }
+ else if (value > BLENDER_ZMAX)
+ value = dest_max;
+ else
+ value = dest_min;
- if (this->m_useClamp) {
- if (dest_max > dest_min) {
- CLAMP(value, dest_min, dest_max);
- }
- else {
- CLAMP(value, dest_max, dest_min);
- }
- }
+ if (this->m_useClamp) {
+ if (dest_max > dest_min) {
+ CLAMP(value, dest_min, dest_max);
+ }
+ else {
+ CLAMP(value, dest_max, dest_min);
+ }
+ }
- output[0] = value;
+ output[0] = value;
}
void MapRangeOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_sourceMinOperation = NULL;
- this->m_sourceMaxOperation = NULL;
- this->m_destMinOperation = NULL;
- this->m_destMaxOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_sourceMinOperation = NULL;
+ this->m_sourceMaxOperation = NULL;
+ this->m_destMinOperation = NULL;
+ this->m_destMaxOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_MapRangeOperation.h b/source/blender/compositor/operations/COM_MapRangeOperation.h
index 7b3d51a1896..55b5cc7453c 100644
--- a/source/blender/compositor/operations/COM_MapRangeOperation.h
+++ b/source/blender/compositor/operations/COM_MapRangeOperation.h
@@ -26,42 +26,45 @@
* it assumes we are in sRGB color space.
*/
class MapRangeOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputOperation;
- SocketReader *m_sourceMinOperation;
- SocketReader *m_sourceMaxOperation;
- SocketReader *m_destMinOperation;
- SocketReader *m_destMaxOperation;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputOperation;
+ SocketReader *m_sourceMinOperation;
+ SocketReader *m_sourceMaxOperation;
+ SocketReader *m_destMinOperation;
+ SocketReader *m_destMaxOperation;
- bool m_useClamp;
-public:
- /**
- * Default constructor
- */
- MapRangeOperation();
+ bool m_useClamp;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Default constructor
+ */
+ MapRangeOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Clamp the output
- */
- void setUseClamp(bool value) { this->m_useClamp = value; }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ /**
+ * Clamp the output
+ */
+ void setUseClamp(bool value)
+ {
+ this->m_useClamp = value;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 3dbf4db5280..98b5b650cb9 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -21,153 +21,164 @@
MapUVOperation::MapUVOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addInputSocket(COM_DT_VECTOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_alpha = 0.0f;
- this->setComplex(true);
- setResolutionInputSocketIndex(1);
-
- this->m_inputUVProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_alpha = 0.0f;
+ this->setComplex(true);
+ setResolutionInputSocketIndex(1);
+
+ this->m_inputUVProgram = NULL;
+ this->m_inputColorProgram = NULL;
}
void MapUVOperation::initExecution()
{
- this->m_inputColorProgram = this->getInputSocketReader(0);
- this->m_inputUVProgram = this->getInputSocketReader(1);
+ this->m_inputColorProgram = this->getInputSocketReader(0);
+ this->m_inputUVProgram = this->getInputSocketReader(1);
}
-void MapUVOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void MapUVOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- float xy[2] = { x, y };
- float uv[2], deriv[2][2], alpha;
-
- pixelTransform(xy, uv, deriv, alpha);
- if (alpha == 0.0f) {
- zero_v4(output);
- return;
- }
-
- /* EWA filtering */
- this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
-
- /* UV to alpha threshold */
- const float threshold = this->m_alpha * 0.05f;
- /* XXX alpha threshold is used to fade out pixels on boundaries with invalid derivatives.
- * this calculation is not very well defined, should be looked into if it becomes a problem ...
- */
- float du = len_v2(deriv[0]);
- float dv = len_v2(deriv[1]);
- float factor = 1.0f - threshold * (du / m_inputColorProgram->getWidth() + dv / m_inputColorProgram->getHeight());
- if (factor < 0.0f) alpha = 0.0f;
- else alpha *= factor;
-
- /* "premul" */
- if (alpha < 1.0f) {
- mul_v4_fl(output, alpha);
- }
+ float xy[2] = {x, y};
+ float uv[2], deriv[2][2], alpha;
+
+ pixelTransform(xy, uv, deriv, alpha);
+ if (alpha == 0.0f) {
+ zero_v4(output);
+ return;
+ }
+
+ /* EWA filtering */
+ this->m_inputColorProgram->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
+
+ /* UV to alpha threshold */
+ const float threshold = this->m_alpha * 0.05f;
+ /* XXX alpha threshold is used to fade out pixels on boundaries with invalid derivatives.
+ * this calculation is not very well defined, should be looked into if it becomes a problem ...
+ */
+ float du = len_v2(deriv[0]);
+ float dv = len_v2(deriv[1]);
+ float factor = 1.0f - threshold * (du / m_inputColorProgram->getWidth() +
+ dv / m_inputColorProgram->getHeight());
+ if (factor < 0.0f)
+ alpha = 0.0f;
+ else
+ alpha *= factor;
+
+ /* "premul" */
+ if (alpha < 1.0f) {
+ mul_v4_fl(output, alpha);
+ }
}
bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_alpha)
{
- float width = m_inputUVProgram->getWidth();
- float height = m_inputUVProgram->getHeight();
- if (x < 0.0f || x >= width || y < 0.0f || y >= height) {
- r_u = 0.0f;
- r_v = 0.0f;
- r_alpha = 0.0f;
- return false;
- }
- else {
- float vector[3];
- m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
- r_u = vector[0] * m_inputColorProgram->getWidth();
- r_v = vector[1] * m_inputColorProgram->getHeight();
- r_alpha = vector[2];
- return true;
- }
+ float width = m_inputUVProgram->getWidth();
+ float height = m_inputUVProgram->getHeight();
+ if (x < 0.0f || x >= width || y < 0.0f || y >= height) {
+ r_u = 0.0f;
+ r_v = 0.0f;
+ r_alpha = 0.0f;
+ return false;
+ }
+ else {
+ float vector[3];
+ m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR);
+ r_u = vector[0] * m_inputColorProgram->getWidth();
+ r_v = vector[1] * m_inputColorProgram->getHeight();
+ r_alpha = vector[2];
+ return true;
+ }
}
-void MapUVOperation::pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2], float &r_alpha)
+void MapUVOperation::pixelTransform(const float xy[2],
+ float r_uv[2],
+ float r_deriv[2][2],
+ float &r_alpha)
{
- float uv[2], alpha; /* temporary variables for derivative estimation */
- int num;
-
- read_uv(xy[0], xy[1], r_uv[0], r_uv[1], r_alpha);
-
- /* Estimate partial derivatives using 1-pixel offsets */
- const float epsilon[2] = { 1.0f, 1.0f };
-
- zero_v2(r_deriv[0]);
- zero_v2(r_deriv[1]);
-
- num = 0;
- if (read_uv(xy[0] + epsilon[0], xy[1], uv[0], uv[1], alpha)) {
- r_deriv[0][0] += uv[0] - r_uv[0];
- r_deriv[1][0] += uv[1] - r_uv[1];
- ++num;
- }
- if (read_uv(xy[0] - epsilon[0], xy[1], uv[0], uv[1], alpha)) {
- r_deriv[0][0] += r_uv[0] - uv[0];
- r_deriv[1][0] += r_uv[1] - uv[1];
- ++num;
- }
- if (num > 0) {
- float numinv = 1.0f / (float)num;
- r_deriv[0][0] *= numinv;
- r_deriv[1][0] *= numinv;
- }
-
- num = 0;
- if (read_uv(xy[0], xy[1] + epsilon[1], uv[0], uv[1], alpha)) {
- r_deriv[0][1] += uv[0] - r_uv[0];
- r_deriv[1][1] += uv[1] - r_uv[1];
- ++num;
- }
- if (read_uv(xy[0], xy[1] - epsilon[1], uv[0], uv[1], alpha)) {
- r_deriv[0][1] += r_uv[0] - uv[0];
- r_deriv[1][1] += r_uv[1] - uv[1];
- ++num;
- }
- if (num > 0) {
- float numinv = 1.0f / (float)num;
- r_deriv[0][1] *= numinv;
- r_deriv[1][1] *= numinv;
- }
+ float uv[2], alpha; /* temporary variables for derivative estimation */
+ int num;
+
+ read_uv(xy[0], xy[1], r_uv[0], r_uv[1], r_alpha);
+
+ /* Estimate partial derivatives using 1-pixel offsets */
+ const float epsilon[2] = {1.0f, 1.0f};
+
+ zero_v2(r_deriv[0]);
+ zero_v2(r_deriv[1]);
+
+ num = 0;
+ if (read_uv(xy[0] + epsilon[0], xy[1], uv[0], uv[1], alpha)) {
+ r_deriv[0][0] += uv[0] - r_uv[0];
+ r_deriv[1][0] += uv[1] - r_uv[1];
+ ++num;
+ }
+ if (read_uv(xy[0] - epsilon[0], xy[1], uv[0], uv[1], alpha)) {
+ r_deriv[0][0] += r_uv[0] - uv[0];
+ r_deriv[1][0] += r_uv[1] - uv[1];
+ ++num;
+ }
+ if (num > 0) {
+ float numinv = 1.0f / (float)num;
+ r_deriv[0][0] *= numinv;
+ r_deriv[1][0] *= numinv;
+ }
+
+ num = 0;
+ if (read_uv(xy[0], xy[1] + epsilon[1], uv[0], uv[1], alpha)) {
+ r_deriv[0][1] += uv[0] - r_uv[0];
+ r_deriv[1][1] += uv[1] - r_uv[1];
+ ++num;
+ }
+ if (read_uv(xy[0], xy[1] - epsilon[1], uv[0], uv[1], alpha)) {
+ r_deriv[0][1] += r_uv[0] - uv[0];
+ r_deriv[1][1] += r_uv[1] - uv[1];
+ ++num;
+ }
+ if (num > 0) {
+ float numinv = 1.0f / (float)num;
+ r_deriv[0][1] *= numinv;
+ r_deriv[1][1] *= numinv;
+ }
}
void MapUVOperation::deinitExecution()
{
- this->m_inputUVProgram = NULL;
- this->m_inputColorProgram = NULL;
+ this->m_inputUVProgram = NULL;
+ this->m_inputColorProgram = NULL;
}
-bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool MapUVOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti colorInput;
- rcti uvInput;
- NodeOperation *operation = NULL;
-
- /* the uv buffer only needs a 3x3 buffer. The image needs whole buffer */
-
- operation = getInputOperation(0);
- colorInput.xmax = operation->getWidth();
- colorInput.xmin = 0;
- colorInput.ymax = operation->getHeight();
- colorInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
- return true;
- }
-
- operation = getInputOperation(1);
- uvInput.xmax = input->xmax + 1;
- uvInput.xmin = input->xmin - 1;
- uvInput.ymax = input->ymax + 1;
- uvInput.ymin = input->ymin - 1;
- if (operation->determineDependingAreaOfInterest(&uvInput, readOperation, output)) {
- return true;
- }
-
- return false;
+ rcti colorInput;
+ rcti uvInput;
+ NodeOperation *operation = NULL;
+
+ /* the uv buffer only needs a 3x3 buffer. The image needs whole buffer */
+
+ operation = getInputOperation(0);
+ colorInput.xmax = operation->getWidth();
+ colorInput.xmin = 0;
+ colorInput.ymax = operation->getHeight();
+ colorInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&colorInput, readOperation, output)) {
+ return true;
+ }
+
+ operation = getInputOperation(1);
+ uvInput.xmax = input->xmax + 1;
+ uvInput.xmin = input->xmin - 1;
+ uvInput.ymax = input->ymax + 1;
+ uvInput.ymin = input->ymin - 1;
+ if (operation->determineDependingAreaOfInterest(&uvInput, readOperation, output)) {
+ return true;
+ }
+
+ return false;
}
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.h b/source/blender/compositor/operations/COM_MapUVOperation.h
index b2235d4de25..64e17b180b4 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.h
+++ b/source/blender/compositor/operations/COM_MapUVOperation.h
@@ -20,46 +20,50 @@
#define __COM_MAPUVOPERATION_H__
#include "COM_NodeOperation.h"
-
class MapUVOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputUVProgram;
- SocketReader *m_inputColorProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputUVProgram;
+ SocketReader *m_inputColorProgram;
- float m_alpha;
+ float m_alpha;
-public:
- MapUVOperation();
+ public:
+ MapUVOperation();
- /**
- * we need a 3x3 differential filter for UV Input and full buffer for the image
- */
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /**
+ * we need a 3x3 differential filter for UV Input and full buffer for the image
+ */
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2], float &r_alpha);
+ void pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2], float &r_alpha);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setAlpha(float alpha) { this->m_alpha = alpha; }
+ void setAlpha(float alpha)
+ {
+ this->m_alpha = alpha;
+ }
-private:
- bool read_uv(float x, float y, float &r_u, float &r_v, float &r_alpha);
+ private:
+ bool read_uv(float x, float y, float &r_u, float &r_v, float &r_alpha);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.cpp b/source/blender/compositor/operations/COM_MapValueOperation.cpp
index e8731c0f146..d99a68a5e00 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapValueOperation.cpp
@@ -20,33 +20,36 @@
MapValueOperation::MapValueOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputOperation = NULL;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputOperation = NULL;
}
void MapValueOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
-void MapValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MapValueOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float src[4];
- this->m_inputOperation->readSampled(src, x, y, sampler);
- TexMapping *texmap = this->m_settings;
- float value = (src[0] + texmap->loc[0]) * texmap->size[0];
- if (texmap->flag & TEXMAP_CLIP_MIN)
- if (value < texmap->min[0])
- value = texmap->min[0];
- if (texmap->flag & TEXMAP_CLIP_MAX)
- if (value > texmap->max[0])
- value = texmap->max[0];
+ float src[4];
+ this->m_inputOperation->readSampled(src, x, y, sampler);
+ TexMapping *texmap = this->m_settings;
+ float value = (src[0] + texmap->loc[0]) * texmap->size[0];
+ if (texmap->flag & TEXMAP_CLIP_MIN)
+ if (value < texmap->min[0])
+ value = texmap->min[0];
+ if (texmap->flag & TEXMAP_CLIP_MAX)
+ if (value > texmap->max[0])
+ value = texmap->max[0];
- output[0] = value;
+ output[0] = value;
}
void MapValueOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h
index dfea3703d24..81071d78cd7 100644
--- a/source/blender/compositor/operations/COM_MapValueOperation.h
+++ b/source/blender/compositor/operations/COM_MapValueOperation.h
@@ -26,37 +26,40 @@
* it assumes we are in sRGB color space.
*/
class MapValueOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputOperation;
- TexMapping *m_settings;
-public:
- /**
- * Default constructor
- */
- MapValueOperation();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputOperation;
+ TexMapping *m_settings;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ /**
+ * Default constructor
+ */
+ MapValueOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * \brief set the TexMapping settings
- */
- void setSettings(TexMapping *settings) { this->m_settings = settings; }
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ /**
+ * \brief set the TexMapping settings
+ */
+ void setSettings(TexMapping *settings)
+ {
+ this->m_settings = settings;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp
index d2603978ac8..6f146d9e1e6 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_MaskOperation.cpp
@@ -24,129 +24,138 @@
#include "BLI_math.h"
extern "C" {
-# include "BKE_mask.h"
+#include "BKE_mask.h"
}
MaskOperation::MaskOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
- this->m_mask = NULL;
- this->m_maskWidth = 0;
- this->m_maskHeight = 0;
- this->m_maskWidthInv = 0.0f;
- this->m_maskHeightInv = 0.0f;
- this->m_frame_shutter = 0.0f;
- this->m_frame_number = 0;
- this->m_rasterMaskHandleTot = 1;
- memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles));
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_mask = NULL;
+ this->m_maskWidth = 0;
+ this->m_maskHeight = 0;
+ this->m_maskWidthInv = 0.0f;
+ this->m_maskHeightInv = 0.0f;
+ this->m_frame_shutter = 0.0f;
+ this->m_frame_number = 0;
+ this->m_rasterMaskHandleTot = 1;
+ memset(this->m_rasterMaskHandles, 0, sizeof(this->m_rasterMaskHandles));
}
void MaskOperation::initExecution()
{
- if (this->m_mask && this->m_rasterMaskHandles[0] == NULL) {
- if (this->m_rasterMaskHandleTot == 1) {
- this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
-
- BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[0], this->m_mask,
- this->m_maskWidth, this->m_maskHeight,
- true, true, this->m_do_feather);
- }
- else {
- /* make a throw away copy of the mask */
- const float frame = (float)this->m_frame_number - this->m_frame_shutter;
- const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
- float frame_iter = frame;
-
- Mask *mask_temp;
-
- mask_temp = BKE_mask_copy_nolib(this->m_mask);
-
- /* trick so we can get unkeyed edits to display */
- {
- MaskLayer *masklay;
- MaskLayerShape *masklay_shape;
-
- for (masklay = (MaskLayer *)mask_temp->masklayers.first;
- masklay;
- masklay = masklay->next)
- {
- masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, this->m_frame_number);
- BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
- }
- }
-
- for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
- this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
-
- /* re-eval frame info */
- BKE_mask_evaluate(mask_temp, frame_iter, true);
-
- BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i], mask_temp,
- this->m_maskWidth, this->m_maskHeight,
- true, true, this->m_do_feather);
-
- frame_iter += frame_step;
- }
-
- BKE_mask_free(mask_temp);
- MEM_freeN(mask_temp);
- }
- }
+ if (this->m_mask && this->m_rasterMaskHandles[0] == NULL) {
+ if (this->m_rasterMaskHandleTot == 1) {
+ this->m_rasterMaskHandles[0] = BKE_maskrasterize_handle_new();
+
+ BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[0],
+ this->m_mask,
+ this->m_maskWidth,
+ this->m_maskHeight,
+ true,
+ true,
+ this->m_do_feather);
+ }
+ else {
+ /* make a throw away copy of the mask */
+ const float frame = (float)this->m_frame_number - this->m_frame_shutter;
+ const float frame_step = (this->m_frame_shutter * 2.0f) / this->m_rasterMaskHandleTot;
+ float frame_iter = frame;
+
+ Mask *mask_temp;
+
+ mask_temp = BKE_mask_copy_nolib(this->m_mask);
+
+ /* trick so we can get unkeyed edits to display */
+ {
+ MaskLayer *masklay;
+ MaskLayerShape *masklay_shape;
+
+ for (masklay = (MaskLayer *)mask_temp->masklayers.first; masklay;
+ masklay = masklay->next) {
+ masklay_shape = BKE_mask_layer_shape_verify_frame(masklay, this->m_frame_number);
+ BKE_mask_layer_shape_from_mask(masklay, masklay_shape);
+ }
+ }
+
+ for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
+ this->m_rasterMaskHandles[i] = BKE_maskrasterize_handle_new();
+
+ /* re-eval frame info */
+ BKE_mask_evaluate(mask_temp, frame_iter, true);
+
+ BKE_maskrasterize_handle_init(this->m_rasterMaskHandles[i],
+ mask_temp,
+ this->m_maskWidth,
+ this->m_maskHeight,
+ true,
+ true,
+ this->m_do_feather);
+
+ frame_iter += frame_step;
+ }
+
+ BKE_mask_free(mask_temp);
+ MEM_freeN(mask_temp);
+ }
+ }
}
void MaskOperation::deinitExecution()
{
- for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
- if (this->m_rasterMaskHandles[i]) {
- BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]);
- this->m_rasterMaskHandles[i] = NULL;
- }
- }
+ for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
+ if (this->m_rasterMaskHandles[i]) {
+ BKE_maskrasterize_handle_free(this->m_rasterMaskHandles[i]);
+ this->m_rasterMaskHandles[i] = NULL;
+ }
+ }
}
-void MaskOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void MaskOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- if (this->m_maskWidth == 0 || this->m_maskHeight == 0) {
- NodeOperation::determineResolution(resolution, preferredResolution);
- }
- else {
- unsigned int nr[2];
+ if (this->m_maskWidth == 0 || this->m_maskHeight == 0) {
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ }
+ else {
+ unsigned int nr[2];
- nr[0] = this->m_maskWidth;
- nr[1] = this->m_maskHeight;
+ nr[0] = this->m_maskWidth;
+ nr[1] = this->m_maskHeight;
- NodeOperation::determineResolution(resolution, nr);
+ NodeOperation::determineResolution(resolution, nr);
- resolution[0] = this->m_maskWidth;
- resolution[1] = this->m_maskHeight;
- }
+ resolution[0] = this->m_maskWidth;
+ resolution[1] = this->m_maskHeight;
+ }
}
-void MaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void MaskOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- const float xy[2] = {
- (x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
- (y * this->m_maskHeightInv) + this->m_mask_px_ofs[1]};
-
- if (this->m_rasterMaskHandleTot == 1) {
- if (this->m_rasterMaskHandles[0]) {
- output[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[0], xy);
- }
- else {
- output[0] = 0.0f;
- }
- }
- else {
- /* incase loop below fails */
- output[0] = 0.0f;
-
- for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
- if (this->m_rasterMaskHandles[i]) {
- output[0] += BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[i], xy);
- }
- }
-
- /* until we get better falloff */
- output[0] /= this->m_rasterMaskHandleTot;
- }
+ const float xy[2] = {(x * this->m_maskWidthInv) + this->m_mask_px_ofs[0],
+ (y * this->m_maskHeightInv) + this->m_mask_px_ofs[1]};
+
+ if (this->m_rasterMaskHandleTot == 1) {
+ if (this->m_rasterMaskHandles[0]) {
+ output[0] = BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[0], xy);
+ }
+ else {
+ output[0] = 0.0f;
+ }
+ }
+ else {
+ /* incase loop below fails */
+ output[0] = 0.0f;
+
+ for (unsigned int i = 0; i < this->m_rasterMaskHandleTot; i++) {
+ if (this->m_rasterMaskHandles[i]) {
+ output[0] += BKE_maskrasterize_handle_sample(this->m_rasterMaskHandles[i], xy);
+ }
+ }
+
+ /* until we get better falloff */
+ output[0] /= this->m_rasterMaskHandleTot;
+ }
}
diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h
index 643705e0535..531d6ef1b08 100644
--- a/source/blender/compositor/operations/COM_MaskOperation.h
+++ b/source/blender/compositor/operations/COM_MaskOperation.h
@@ -19,7 +19,6 @@
#ifndef __COM_MASKOPERATION_H__
#define __COM_MASKOPERATION_H__
-
#include "COM_NodeOperation.h"
#include "DNA_mask_types.h"
#include "BLI_listbase.h"
@@ -29,57 +28,71 @@
* Class with implementation of mask rasterization
*/
class MaskOperation : public NodeOperation {
-protected:
- Mask *m_mask;
-
- /* note, these are used more like aspect,
- * but they _do_ impact on mask detail */
- int m_maskWidth;
- int m_maskHeight;
- float m_maskWidthInv; /* 1 / m_maskWidth */
- float m_maskHeightInv; /* 1 / m_maskHeight */
- float m_mask_px_ofs[2];
-
- float m_frame_shutter;
- int m_frame_number;
-
- bool m_do_feather;
-
- struct MaskRasterHandle *m_rasterMaskHandles[CMP_NODE_MASK_MBLUR_SAMPLES_MAX];
- unsigned int m_rasterMaskHandleTot;
-
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
-public:
- MaskOperation();
-
- void initExecution();
- void deinitExecution();
-
-
- void setMask(Mask *mask) { this->m_mask = mask; }
- void setMaskWidth(int width)
- {
- this->m_maskWidth = width;
- this->m_maskWidthInv = 1.0f / (float)width;
- this->m_mask_px_ofs[0] = this->m_maskWidthInv * 0.5f;
- }
- void setMaskHeight(int height)
- {
- this->m_maskHeight = height;
- this->m_maskHeightInv = 1.0f / (float)height;
- this->m_mask_px_ofs[1] = this->m_maskHeightInv * 0.5f;
- }
- void setFramenumber(int frame_number) { this->m_frame_number = frame_number; }
- void setFeather(bool feather) { this->m_do_feather = feather; }
-
- void setMotionBlurSamples(int samples) { this->m_rasterMaskHandleTot = min(max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX); }
- void setMotionBlurShutter(float shutter) { this->m_frame_shutter = shutter; }
-
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ protected:
+ Mask *m_mask;
+
+ /* note, these are used more like aspect,
+ * but they _do_ impact on mask detail */
+ int m_maskWidth;
+ int m_maskHeight;
+ float m_maskWidthInv; /* 1 / m_maskWidth */
+ float m_maskHeightInv; /* 1 / m_maskHeight */
+ float m_mask_px_ofs[2];
+
+ float m_frame_shutter;
+ int m_frame_number;
+
+ bool m_do_feather;
+
+ struct MaskRasterHandle *m_rasterMaskHandles[CMP_NODE_MASK_MBLUR_SAMPLES_MAX];
+ unsigned int m_rasterMaskHandleTot;
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ public:
+ MaskOperation();
+
+ void initExecution();
+ void deinitExecution();
+
+ void setMask(Mask *mask)
+ {
+ this->m_mask = mask;
+ }
+ void setMaskWidth(int width)
+ {
+ this->m_maskWidth = width;
+ this->m_maskWidthInv = 1.0f / (float)width;
+ this->m_mask_px_ofs[0] = this->m_maskWidthInv * 0.5f;
+ }
+ void setMaskHeight(int height)
+ {
+ this->m_maskHeight = height;
+ this->m_maskHeightInv = 1.0f / (float)height;
+ this->m_mask_px_ofs[1] = this->m_maskHeightInv * 0.5f;
+ }
+ void setFramenumber(int frame_number)
+ {
+ this->m_frame_number = frame_number;
+ }
+ void setFeather(bool feather)
+ {
+ this->m_do_feather = feather;
+ }
+
+ void setMotionBlurSamples(int samples)
+ {
+ this->m_rasterMaskHandleTot = min(max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX);
+ }
+ void setMotionBlurShutter(float shutter)
+ {
+ this->m_frame_shutter = shutter;
+ }
+
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 5bcb71a8dfc..b3251d32005 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -23,379 +23,448 @@ extern "C" {
MathBaseOperation::MathBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_inputValue1Operation = NULL;
- this->m_inputValue2Operation = NULL;
- this->m_useClamp = false;
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_inputValue1Operation = NULL;
+ this->m_inputValue2Operation = NULL;
+ this->m_useClamp = false;
}
void MathBaseOperation::initExecution()
{
- this->m_inputValue1Operation = this->getInputSocketReader(0);
- this->m_inputValue2Operation = this->getInputSocketReader(1);
+ this->m_inputValue1Operation = this->getInputSocketReader(0);
+ this->m_inputValue2Operation = this->getInputSocketReader(1);
}
-
void MathBaseOperation::deinitExecution()
{
- this->m_inputValue1Operation = NULL;
- this->m_inputValue2Operation = NULL;
+ this->m_inputValue1Operation = NULL;
+ this->m_inputValue2Operation = NULL;
}
-void MathBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void MathBaseOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperationInput *socket;
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
-
- socket = this->getInputSocket(0);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(0);
- }
- else {
- this->setResolutionInputSocketIndex(1);
- }
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperationInput *socket;
+ unsigned int tempPreferredResolution[2] = {0, 0};
+ unsigned int tempResolution[2];
+
+ socket = this->getInputSocket(0);
+ socket->determineResolution(tempResolution, tempPreferredResolution);
+ if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
+ this->setResolutionInputSocketIndex(0);
+ }
+ else {
+ this->setResolutionInputSocketIndex(1);
+ }
+ NodeOperation::determineResolution(resolution, preferredResolution);
}
void MathBaseOperation::clampIfNeeded(float *color)
{
- if (this->m_useClamp) {
- CLAMP(color[0], 0.0f, 1.0f);
- }
+ if (this->m_useClamp) {
+ CLAMP(color[0], 0.0f, 1.0f);
+ }
}
void MathAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = inputValue1[0] + inputValue2[0];
+ output[0] = inputValue1[0] + inputValue2[0];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathSubtractOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = inputValue1[0] - inputValue2[0];
+ output[0] = inputValue1[0] - inputValue2[0];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathMultiplyOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = inputValue1[0] * inputValue2[0];
+ output[0] = inputValue1[0] * inputValue2[0];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathDivideOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue2[0] == 0) /* We don't want to divide by zero. */
- output[0] = 0.0;
- else
- output[0] = inputValue1[0] / inputValue2[0];
+ if (inputValue2[0] == 0) /* We don't want to divide by zero. */
+ output[0] = 0.0;
+ else
+ output[0] = inputValue1[0] / inputValue2[0];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathSineOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = sin(inputValue1[0]);
+ output[0] = sin(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathCosineOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = cos(inputValue1[0]);
+ output[0] = cos(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathTangentOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = tan(inputValue1[0]);
+ output[0] = tan(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathArcSineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathArcSineOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
- output[0] = asin(inputValue1[0]);
- else
- output[0] = 0.0;
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
+ output[0] = asin(inputValue1[0]);
+ else
+ output[0] = 0.0;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathArcCosineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathArcCosineOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
- output[0] = acos(inputValue1[0]);
- else
- output[0] = 0.0;
+ if (inputValue1[0] <= 1 && inputValue1[0] >= -1)
+ output[0] = acos(inputValue1[0]);
+ else
+ output[0] = 0.0;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathArcTangentOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathArcTangentOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = atan(inputValue1[0]);
+ output[0] = atan(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathPowerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathPowerOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
-
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
-
- if (inputValue1[0] >= 0) {
- output[0] = pow(inputValue1[0], inputValue2[0]);
- }
- else {
- float y_mod_1 = fmod(inputValue2[0], 1);
- /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
- if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
- output[0] = pow(inputValue1[0], floorf(inputValue2[0] + 0.5f));
- }
- else {
- output[0] = 0.0;
- }
- }
-
- clampIfNeeded(output);
+ float inputValue1[4];
+ float inputValue2[4];
+
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+
+ if (inputValue1[0] >= 0) {
+ output[0] = pow(inputValue1[0], inputValue2[0]);
+ }
+ else {
+ float y_mod_1 = fmod(inputValue2[0], 1);
+ /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
+ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
+ output[0] = pow(inputValue1[0], floorf(inputValue2[0] + 0.5f));
+ }
+ else {
+ output[0] = 0.0;
+ }
+ }
+
+ clampIfNeeded(output);
}
-void MathLogarithmOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathLogarithmOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue1[0] > 0 && inputValue2[0] > 0)
- output[0] = log(inputValue1[0]) / log(inputValue2[0]);
- else
- output[0] = 0.0;
+ if (inputValue1[0] > 0 && inputValue2[0] > 0)
+ output[0] = log(inputValue1[0]) / log(inputValue2[0]);
+ else
+ output[0] = 0.0;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathMinimumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathMinimumOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = min(inputValue1[0], inputValue2[0]);
+ output[0] = min(inputValue1[0], inputValue2[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathMaximumOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathMaximumOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = max(inputValue1[0], inputValue2[0]);
+ output[0] = max(inputValue1[0], inputValue2[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathRoundOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathRoundOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = round(inputValue1[0]);
+ output[0] = round(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathLessThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathLessThanOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
+ output[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathGreaterThanOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathGreaterThanOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
+ output[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathModuloOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathModuloOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- if (inputValue2[0] == 0)
- output[0] = 0.0;
- else
- output[0] = fmod(inputValue1[0], inputValue2[0]);
+ if (inputValue2[0] == 0)
+ output[0] = 0.0;
+ else
+ output[0] = fmod(inputValue1[0], inputValue2[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathAbsoluteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
+ float inputValue1[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- output[0] = fabs(inputValue1[0]);
+ output[0] = fabs(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathArcTan2Operation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathArcTan2Operation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
- float inputValue2[4];
+ float inputValue1[4];
+ float inputValue2[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue2Operation->readSampled(inputValue2, x, y, sampler);
- output[0] = atan2(inputValue1[0], inputValue2[0]);
+ output[0] = atan2(inputValue1[0], inputValue2[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathFloorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathFloorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
+ float inputValue1[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- output[0] = floor(inputValue1[0]);
+ output[0] = floor(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathCeilOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathCeilOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
+ float inputValue1[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- output[0] = ceil(inputValue1[0]);
+ output[0] = ceil(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathFractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathFractOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
+ float inputValue1[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- output[0] = inputValue1[0] - floor(inputValue1[0]);
+ output[0] = inputValue1[0] - floor(inputValue1[0]);
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
-void MathSqrtOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MathSqrtOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputValue1[4];
+ float inputValue1[4];
- this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
+ this->m_inputValue1Operation->readSampled(inputValue1, x, y, sampler);
- if (inputValue1[0] > 0)
- output[0] = sqrt(inputValue1[0]);
- else
- output[0] = 0.0f;
+ if (inputValue1[0] > 0)
+ output[0] = sqrt(inputValue1[0]);
+ else
+ output[0] = 0.0f;
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h
index 7306a166e87..7c11ea8f45b 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.h
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.h
@@ -20,179 +20,230 @@
#define __COM_MATHBASEOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class MathBaseOperation : public NodeOperation {
-protected:
- /**
- * Prefetched reference to the inputProgram
- */
- SocketReader *m_inputValue1Operation;
- SocketReader *m_inputValue2Operation;
-
- bool m_useClamp;
-
-protected:
- /**
- * Default constructor
- */
- MathBaseOperation();
-
- void clampIfNeeded(float color[4]);
-public:
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) = 0;
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- /**
- * Determine resolution
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- void setUseClamp(bool value) { this->m_useClamp = value; }
+ protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *m_inputValue1Operation;
+ SocketReader *m_inputValue2Operation;
+
+ bool m_useClamp;
+
+ protected:
+ /**
+ * Default constructor
+ */
+ MathBaseOperation();
+
+ void clampIfNeeded(float color[4]);
+
+ public:
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) = 0;
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ /**
+ * Determine resolution
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ void setUseClamp(bool value)
+ {
+ this->m_useClamp = value;
+ }
};
class MathAddOperation : public MathBaseOperation {
-public:
- MathAddOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathAddOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathSubtractOperation : public MathBaseOperation {
-public:
- MathSubtractOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathSubtractOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMultiplyOperation : public MathBaseOperation {
-public:
- MathMultiplyOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathMultiplyOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathDivideOperation : public MathBaseOperation {
-public:
- MathDivideOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathDivideOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathSineOperation : public MathBaseOperation {
-public:
- MathSineOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathSineOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathCosineOperation : public MathBaseOperation {
-public:
- MathCosineOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathCosineOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathTangentOperation : public MathBaseOperation {
-public:
- MathTangentOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathTangentOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcSineOperation : public MathBaseOperation {
-public:
- MathArcSineOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathArcSineOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcCosineOperation : public MathBaseOperation {
-public:
- MathArcCosineOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathArcCosineOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcTangentOperation : public MathBaseOperation {
-public:
- MathArcTangentOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathArcTangentOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathPowerOperation : public MathBaseOperation {
-public:
- MathPowerOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathPowerOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathLogarithmOperation : public MathBaseOperation {
-public:
- MathLogarithmOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathLogarithmOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMinimumOperation : public MathBaseOperation {
-public:
- MathMinimumOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathMinimumOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathMaximumOperation : public MathBaseOperation {
-public:
- MathMaximumOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathMaximumOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathRoundOperation : public MathBaseOperation {
-public:
- MathRoundOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathRoundOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathLessThanOperation : public MathBaseOperation {
-public:
- MathLessThanOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathLessThanOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathGreaterThanOperation : public MathBaseOperation {
-public:
- MathGreaterThanOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathGreaterThanOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathModuloOperation : public MathBaseOperation {
-public:
- MathModuloOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathModuloOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathAbsoluteOperation : public MathBaseOperation {
-public:
- MathAbsoluteOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathAbsoluteOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathArcTan2Operation : public MathBaseOperation {
-public:
- MathArcTan2Operation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathArcTan2Operation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathFloorOperation : public MathBaseOperation {
-public:
- MathFloorOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathFloorOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathCeilOperation : public MathBaseOperation {
-public:
- MathCeilOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathCeilOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathFractOperation : public MathBaseOperation {
-public:
- MathFractOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathFractOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MathSqrtOperation : public MathBaseOperation {
-public:
- MathSqrtOperation() : MathBaseOperation() {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MathSqrtOperation() : MathBaseOperation()
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MixOperation.cpp b/source/blender/compositor/operations/COM_MixOperation.cpp
index abde0fa5547..8e09586aaa8 100644
--- a/source/blender/compositor/operations/COM_MixOperation.cpp
+++ b/source/blender/compositor/operations/COM_MixOperation.cpp
@@ -19,818 +19,882 @@
#include "COM_MixOperation.h"
extern "C" {
-# include "BLI_math.h"
+#include "BLI_math.h"
}
/* ******** Mix Base Operation ******** */
MixBaseOperation::MixBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_inputValueOperation = NULL;
- this->m_inputColor1Operation = NULL;
- this->m_inputColor2Operation = NULL;
- this->setUseValueAlphaMultiply(false);
- this->setUseClamp(false);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputValueOperation = NULL;
+ this->m_inputColor1Operation = NULL;
+ this->m_inputColor2Operation = NULL;
+ this->setUseValueAlphaMultiply(false);
+ this->setUseClamp(false);
}
void MixBaseOperation::initExecution()
{
- this->m_inputValueOperation = this->getInputSocketReader(0);
- this->m_inputColor1Operation = this->getInputSocketReader(1);
- this->m_inputColor2Operation = this->getInputSocketReader(2);
+ this->m_inputValueOperation = this->getInputSocketReader(0);
+ this->m_inputColor1Operation = this->getInputSocketReader(1);
+ this->m_inputColor2Operation = this->getInputSocketReader(2);
}
void MixBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
-
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
-
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
- output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
- output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
- output[3] = inputColor1[3];
-}
-
-void MixBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
-{
- NodeOperationInput *socket;
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
-
- socket = this->getInputSocket(1);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(1);
- }
- else {
- socket = this->getInputSocket(2);
- socket->determineResolution(tempResolution, tempPreferredResolution);
- if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
- this->setResolutionInputSocketIndex(2);
- }
- else {
- this->setResolutionInputSocketIndex(0);
- }
- }
- NodeOperation::determineResolution(resolution, preferredResolution);
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
+ output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
+ output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
+ output[3] = inputColor1[3];
+}
+
+void MixBaseOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
+{
+ NodeOperationInput *socket;
+ unsigned int tempPreferredResolution[2] = {0, 0};
+ unsigned int tempResolution[2];
+
+ socket = this->getInputSocket(1);
+ socket->determineResolution(tempResolution, tempPreferredResolution);
+ if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
+ this->setResolutionInputSocketIndex(1);
+ }
+ else {
+ socket = this->getInputSocket(2);
+ socket->determineResolution(tempResolution, tempPreferredResolution);
+ if ((tempResolution[0] != 0) && (tempResolution[1] != 0)) {
+ this->setResolutionInputSocketIndex(2);
+ }
+ else {
+ this->setResolutionInputSocketIndex(0);
+ }
+ }
+ NodeOperation::determineResolution(resolution, preferredResolution);
}
void MixBaseOperation::deinitExecution()
{
- this->m_inputValueOperation = NULL;
- this->m_inputColor1Operation = NULL;
- this->m_inputColor2Operation = NULL;
+ this->m_inputValueOperation = NULL;
+ this->m_inputColor1Operation = NULL;
+ this->m_inputColor2Operation = NULL;
}
/* ******** Mix Add Operation ******** */
MixAddOperation::MixAddOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
void MixAddOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- output[0] = inputColor1[0] + value * inputColor2[0];
- output[1] = inputColor1[1] + value * inputColor2[1];
- output[2] = inputColor1[2] + value * inputColor2[2];
- output[3] = inputColor1[3];
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ output[0] = inputColor1[0] + value * inputColor2[0];
+ output[1] = inputColor1[1] + value * inputColor2[1];
+ output[2] = inputColor1[2] + value * inputColor2[2];
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Blend Operation ******** */
MixBlendOperation::MixBlendOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixBlendOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixBlendOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
- float value;
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float value;
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- value = inputValue[0];
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
- output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
- output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
- output[3] = inputColor1[3];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ output[0] = valuem * (inputColor1[0]) + value * (inputColor2[0]);
+ output[1] = valuem * (inputColor1[1]) + value * (inputColor2[1]);
+ output[2] = valuem * (inputColor1[2]) + value * (inputColor2[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Burn Operation ******** */
MixBurnOperation::MixBurnOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
void MixBurnOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
- float tmp;
-
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
-
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
-
- tmp = valuem + value * inputColor2[0];
- if (tmp <= 0.0f)
- output[0] = 0.0f;
- else {
- tmp = 1.0f - (1.0f - inputColor1[0]) / tmp;
- if (tmp < 0.0f)
- output[0] = 0.0f;
- else if (tmp > 1.0f)
- output[0] = 1.0f;
- else
- output[0] = tmp;
- }
-
- tmp = valuem + value * inputColor2[1];
- if (tmp <= 0.0f)
- output[1] = 0.0f;
- else {
- tmp = 1.0f - (1.0f - inputColor1[1]) / tmp;
- if (tmp < 0.0f)
- output[1] = 0.0f;
- else if (tmp > 1.0f)
- output[1] = 1.0f;
- else
- output[1] = tmp;
- }
-
- tmp = valuem + value * inputColor2[2];
- if (tmp <= 0.0f)
- output[2] = 0.0f;
- else {
- tmp = 1.0f - (1.0f - inputColor1[2]) / tmp;
- if (tmp < 0.0f)
- output[2] = 0.0f;
- else if (tmp > 1.0f)
- output[2] = 1.0f;
- else
- output[2] = tmp;
- }
-
- output[3] = inputColor1[3];
-
- clampIfNeeded(output);
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float tmp;
+
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+
+ tmp = valuem + value * inputColor2[0];
+ if (tmp <= 0.0f)
+ output[0] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[0]) / tmp;
+ if (tmp < 0.0f)
+ output[0] = 0.0f;
+ else if (tmp > 1.0f)
+ output[0] = 1.0f;
+ else
+ output[0] = tmp;
+ }
+
+ tmp = valuem + value * inputColor2[1];
+ if (tmp <= 0.0f)
+ output[1] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[1]) / tmp;
+ if (tmp < 0.0f)
+ output[1] = 0.0f;
+ else if (tmp > 1.0f)
+ output[1] = 1.0f;
+ else
+ output[1] = tmp;
+ }
+
+ tmp = valuem + value * inputColor2[2];
+ if (tmp <= 0.0f)
+ output[2] = 0.0f;
+ else {
+ tmp = 1.0f - (1.0f - inputColor1[2]) / tmp;
+ if (tmp < 0.0f)
+ output[2] = 0.0f;
+ else if (tmp > 1.0f)
+ output[2] = 1.0f;
+ else
+ output[2] = tmp;
+ }
+
+ output[3] = inputColor1[3];
+
+ clampIfNeeded(output);
}
/* ******** Mix Color Operation ******** */
MixColorOperation::MixColorOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixColorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
- float colH, colS, colV;
- rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- if (colS != 0.0f) {
- float rH, rS, rV;
- float tmpr, tmpg, tmpb;
- rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb);
- output[0] = (valuem * inputColor1[0]) + (value * tmpr);
- output[1] = (valuem * inputColor1[1]) + (value * tmpg);
- output[2] = (valuem * inputColor1[2]) + (value * tmpb);
- }
- else {
- copy_v3_v3(output, inputColor1);
- }
- output[3] = inputColor1[3];
+ float colH, colS, colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ if (colS != 0.0f) {
+ float rH, rS, rV;
+ float tmpr, tmpg, tmpb;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb);
+ output[0] = (valuem * inputColor1[0]) + (value * tmpr);
+ output[1] = (valuem * inputColor1[1]) + (value * tmpg);
+ output[2] = (valuem * inputColor1[2]) + (value * tmpb);
+ }
+ else {
+ copy_v3_v3(output, inputColor1);
+ }
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Darken Operation ******** */
MixDarkenOperation::MixDarkenOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixDarkenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixDarkenOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- output[0] = min_ff(inputColor1[0], inputColor2[0]) * value + inputColor1[0] * valuem;
- output[1] = min_ff(inputColor1[1], inputColor2[1]) * value + inputColor1[1] * valuem;
- output[2] = min_ff(inputColor1[2], inputColor2[2]) * value + inputColor1[2] * valuem;
- output[3] = inputColor1[3];
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ output[0] = min_ff(inputColor1[0], inputColor2[0]) * value + inputColor1[0] * valuem;
+ output[1] = min_ff(inputColor1[1], inputColor2[1]) * value + inputColor1[1] * valuem;
+ output[2] = min_ff(inputColor1[2], inputColor2[2]) * value + inputColor1[2] * valuem;
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Difference Operation ******** */
MixDifferenceOperation::MixDifferenceOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixDifferenceOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixDifferenceOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- output[0] = valuem * inputColor1[0] + value * fabsf(inputColor1[0] - inputColor2[0]);
- output[1] = valuem * inputColor1[1] + value * fabsf(inputColor1[1] - inputColor2[1]);
- output[2] = valuem * inputColor1[2] + value * fabsf(inputColor1[2] - inputColor2[2]);
- output[3] = inputColor1[3];
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ output[0] = valuem * inputColor1[0] + value * fabsf(inputColor1[0] - inputColor2[0]);
+ output[1] = valuem * inputColor1[1] + value * fabsf(inputColor1[1] - inputColor2[1]);
+ output[2] = valuem * inputColor1[2] + value * fabsf(inputColor1[2] - inputColor2[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Difference Operation ******** */
MixDivideOperation::MixDivideOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixDivideOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixDivideOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
- if (inputColor2[0] != 0.0f)
- output[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0];
- else
- output[0] = 0.0f;
- if (inputColor2[1] != 0.0f)
- output[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1];
- else
- output[1] = 0.0f;
- if (inputColor2[2] != 0.0f)
- output[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2];
- else
- output[2] = 0.0f;
+ if (inputColor2[0] != 0.0f)
+ output[0] = valuem * (inputColor1[0]) + value * (inputColor1[0]) / inputColor2[0];
+ else
+ output[0] = 0.0f;
+ if (inputColor2[1] != 0.0f)
+ output[1] = valuem * (inputColor1[1]) + value * (inputColor1[1]) / inputColor2[1];
+ else
+ output[1] = 0.0f;
+ if (inputColor2[2] != 0.0f)
+ output[2] = valuem * (inputColor1[2]) + value * (inputColor1[2]) / inputColor2[2];
+ else
+ output[2] = 0.0f;
- output[3] = inputColor1[3];
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Dodge Operation ******** */
MixDodgeOperation::MixDodgeOperation() : MixBaseOperation()
{
- /* pass */
-}
-
-void MixDodgeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
-{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
- float tmp;
-
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
-
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
-
- if (inputColor1[0] != 0.0f) {
- tmp = 1.0f - value * inputColor2[0];
- if (tmp <= 0.0f)
- output[0] = 1.0f;
- else {
- tmp = inputColor1[0] / tmp;
- if (tmp > 1.0f)
- output[0] = 1.0f;
- else
- output[0] = tmp;
- }
- }
- else
- output[0] = 0.0f;
-
- if (inputColor1[1] != 0.0f) {
- tmp = 1.0f - value * inputColor2[1];
- if (tmp <= 0.0f)
- output[1] = 1.0f;
- else {
- tmp = inputColor1[1] / tmp;
- if (tmp > 1.0f)
- output[1] = 1.0f;
- else
- output[1] = tmp;
- }
- }
- else
- output[1] = 0.0f;
-
- if (inputColor1[2] != 0.0f) {
- tmp = 1.0f - value * inputColor2[2];
- if (tmp <= 0.0f)
- output[2] = 1.0f;
- else {
- tmp = inputColor1[2] / tmp;
- if (tmp > 1.0f)
- output[2] = 1.0f;
- else
- output[2] = tmp;
- }
- }
- else
- output[2] = 0.0f;
-
- output[3] = inputColor1[3];
-
- clampIfNeeded(output);
+ /* pass */
+}
+
+void MixDodgeOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float tmp;
+
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+
+ if (inputColor1[0] != 0.0f) {
+ tmp = 1.0f - value * inputColor2[0];
+ if (tmp <= 0.0f)
+ output[0] = 1.0f;
+ else {
+ tmp = inputColor1[0] / tmp;
+ if (tmp > 1.0f)
+ output[0] = 1.0f;
+ else
+ output[0] = tmp;
+ }
+ }
+ else
+ output[0] = 0.0f;
+
+ if (inputColor1[1] != 0.0f) {
+ tmp = 1.0f - value * inputColor2[1];
+ if (tmp <= 0.0f)
+ output[1] = 1.0f;
+ else {
+ tmp = inputColor1[1] / tmp;
+ if (tmp > 1.0f)
+ output[1] = 1.0f;
+ else
+ output[1] = tmp;
+ }
+ }
+ else
+ output[1] = 0.0f;
+
+ if (inputColor1[2] != 0.0f) {
+ tmp = 1.0f - value * inputColor2[2];
+ if (tmp <= 0.0f)
+ output[2] = 1.0f;
+ else {
+ tmp = inputColor1[2] / tmp;
+ if (tmp > 1.0f)
+ output[2] = 1.0f;
+ else
+ output[2] = tmp;
+ }
+ }
+ else
+ output[2] = 0.0f;
+
+ output[3] = inputColor1[3];
+
+ clampIfNeeded(output);
}
/* ******** Mix Glare Operation ******** */
MixGlareOperation::MixGlareOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixGlareOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixGlareOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
- float value;
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+ float value;
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- value = inputValue[0];
- float mf = 2.0f - 2.0f * fabsf(value - 0.5f);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ value = inputValue[0];
+ float mf = 2.0f - 2.0f * fabsf(value - 0.5f);
- if (inputColor1[0] < 0.0f) inputColor1[0] = 0.0f;
- if (inputColor1[1] < 0.0f) inputColor1[1] = 0.0f;
- if (inputColor1[2] < 0.0f) inputColor1[2] = 0.0f;
+ if (inputColor1[0] < 0.0f)
+ inputColor1[0] = 0.0f;
+ if (inputColor1[1] < 0.0f)
+ inputColor1[1] = 0.0f;
+ if (inputColor1[2] < 0.0f)
+ inputColor1[2] = 0.0f;
- output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
- output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
- output[2] = mf * max(inputColor1[2] + value * (inputColor2[2] - inputColor1[2]), 0.0f);
- output[3] = inputColor1[3];
+ output[0] = mf * max(inputColor1[0] + value * (inputColor2[0] - inputColor1[0]), 0.0f);
+ output[1] = mf * max(inputColor1[1] + value * (inputColor2[1] - inputColor1[1]), 0.0f);
+ output[2] = mf * max(inputColor1[2] + value * (inputColor2[2] - inputColor1[2]), 0.0f);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Hue Operation ******** */
MixHueOperation::MixHueOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
void MixHueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
-
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
-
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
-
- float colH, colS, colV;
- rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- if (colS != 0.0f) {
- float rH, rS, rV;
- float tmpr, tmpg, tmpb;
- rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb);
- output[0] = valuem * (inputColor1[0]) + value * tmpr;
- output[1] = valuem * (inputColor1[1]) + value * tmpg;
- output[2] = valuem * (inputColor1[2]) + value * tmpb;
- }
- else {
- copy_v3_v3(output, inputColor1);
- }
- output[3] = inputColor1[3];
-
- clampIfNeeded(output);
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+
+ float colH, colS, colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ if (colS != 0.0f) {
+ float rH, rS, rV;
+ float tmpr, tmpg, tmpb;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb);
+ output[0] = valuem * (inputColor1[0]) + value * tmpr;
+ output[1] = valuem * (inputColor1[1]) + value * tmpg;
+ output[2] = valuem * (inputColor1[2]) + value * tmpb;
+ }
+ else {
+ copy_v3_v3(output, inputColor1);
+ }
+ output[3] = inputColor1[3];
+
+ clampIfNeeded(output);
}
/* ******** Mix Lighten Operation ******** */
MixLightenOperation::MixLightenOperation() : MixBaseOperation()
{
- /* pass */
-}
-
-void MixLightenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
-{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
-
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
-
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float tmp;
- tmp = value * inputColor2[0];
- if (tmp > inputColor1[0]) output[0] = tmp;
- else output[0] = inputColor1[0];
- tmp = value * inputColor2[1];
- if (tmp > inputColor1[1]) output[1] = tmp;
- else output[1] = inputColor1[1];
- tmp = value * inputColor2[2];
- if (tmp > inputColor1[2]) output[2] = tmp;
- else output[2] = inputColor1[2];
- output[3] = inputColor1[3];
-
- clampIfNeeded(output);
+ /* pass */
+}
+
+void MixLightenOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
+
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float tmp;
+ tmp = value * inputColor2[0];
+ if (tmp > inputColor1[0])
+ output[0] = tmp;
+ else
+ output[0] = inputColor1[0];
+ tmp = value * inputColor2[1];
+ if (tmp > inputColor1[1])
+ output[1] = tmp;
+ else
+ output[1] = inputColor1[1];
+ tmp = value * inputColor2[2];
+ if (tmp > inputColor1[2])
+ output[2] = tmp;
+ else
+ output[2] = inputColor1[2];
+ output[3] = inputColor1[3];
+
+ clampIfNeeded(output);
}
/* ******** Mix Linear Light Operation ******** */
MixLinearLightOperation::MixLinearLightOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixLinearLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixLinearLightOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- if (inputColor2[0] > 0.5f)
- output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f));
- else
- output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f);
- if (inputColor2[1] > 0.5f)
- output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f));
- else
- output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f);
- if (inputColor2[2] > 0.5f)
- output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f));
- else
- output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f);
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ if (inputColor2[0] > 0.5f)
+ output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0] - 0.5f));
+ else
+ output[0] = inputColor1[0] + value * (2.0f * (inputColor2[0]) - 1.0f);
+ if (inputColor2[1] > 0.5f)
+ output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1] - 0.5f));
+ else
+ output[1] = inputColor1[1] + value * (2.0f * (inputColor2[1]) - 1.0f);
+ if (inputColor2[2] > 0.5f)
+ output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2] - 0.5f));
+ else
+ output[2] = inputColor1[2] + value * (2.0f * (inputColor2[2]) - 1.0f);
- output[3] = inputColor1[3];
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Multiply Operation ******** */
MixMultiplyOperation::MixMultiplyOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixMultiplyOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixMultiplyOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- output[0] = inputColor1[0] * (valuem + value * inputColor2[0]);
- output[1] = inputColor1[1] * (valuem + value * inputColor2[1]);
- output[2] = inputColor1[2] * (valuem + value * inputColor2[2]);
- output[3] = inputColor1[3];
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ output[0] = inputColor1[0] * (valuem + value * inputColor2[0]);
+ output[1] = inputColor1[1] * (valuem + value * inputColor2[1]);
+ output[2] = inputColor1[2] * (valuem + value * inputColor2[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Ovelray Operation ******** */
MixOverlayOperation::MixOverlayOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixOverlayOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixOverlayOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
- float valuem = 1.0f - value;
+ float valuem = 1.0f - value;
- if (inputColor1[0] < 0.5f) {
- output[0] = inputColor1[0] * (valuem + 2.0f * value * inputColor2[0]);
- }
- else {
- output[0] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
- }
- if (inputColor1[1] < 0.5f) {
- output[1] = inputColor1[1] * (valuem + 2.0f * value * inputColor2[1]);
- }
- else {
- output[1] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
- }
- if (inputColor1[2] < 0.5f) {
- output[2] = inputColor1[2] * (valuem + 2.0f * value * inputColor2[2]);
- }
- else {
- output[2] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
- }
- output[3] = inputColor1[3];
+ if (inputColor1[0] < 0.5f) {
+ output[0] = inputColor1[0] * (valuem + 2.0f * value * inputColor2[0]);
+ }
+ else {
+ output[0] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
+ }
+ if (inputColor1[1] < 0.5f) {
+ output[1] = inputColor1[1] * (valuem + 2.0f * value * inputColor2[1]);
+ }
+ else {
+ output[1] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
+ }
+ if (inputColor1[2] < 0.5f) {
+ output[2] = inputColor1[2] * (valuem + 2.0f * value * inputColor2[2]);
+ }
+ else {
+ output[2] = 1.0f - (valuem + 2.0f * value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
+ }
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Saturation Operation ******** */
MixSaturationOperation::MixSaturationOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixSaturationOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixSaturationOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
- float rH, rS, rV;
- rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- if (rS != 0.0f) {
- float colH, colS, colV;
- rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- hsv_to_rgb(rH, (valuem * rS + value * colS), rV, &output[0], &output[1], &output[2]);
- }
- else {
- copy_v3_v3(output, inputColor1);
- }
+ float rH, rS, rV;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ if (rS != 0.0f) {
+ float colH, colS, colV;
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ hsv_to_rgb(rH, (valuem * rS + value * colS), rV, &output[0], &output[1], &output[2]);
+ }
+ else {
+ copy_v3_v3(output, inputColor1);
+ }
- output[3] = inputColor1[3];
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Screen Operation ******** */
MixScreenOperation::MixScreenOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixScreenOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixScreenOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
- output[0] = 1.0f - (valuem + value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
- output[1] = 1.0f - (valuem + value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
- output[2] = 1.0f - (valuem + value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
- output[3] = inputColor1[3];
+ output[0] = 1.0f - (valuem + value * (1.0f - inputColor2[0])) * (1.0f - inputColor1[0]);
+ output[1] = 1.0f - (valuem + value * (1.0f - inputColor2[1])) * (1.0f - inputColor1[1]);
+ output[2] = 1.0f - (valuem + value * (1.0f - inputColor2[2])) * (1.0f - inputColor1[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Soft Light Operation ******** */
MixSoftLightOperation::MixSoftLightOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixSoftLightOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) \
+void MixSoftLightOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
- float scr, scg, scb;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
+ float scr, scg, scb;
- /* first calculate non-fac based Screen mix */
- scr = 1.0f - (1.0f - inputColor2[0]) * (1.0f - inputColor1[0]);
- scg = 1.0f - (1.0f - inputColor2[1]) * (1.0f - inputColor1[1]);
- scb = 1.0f - (1.0f - inputColor2[2]) * (1.0f - inputColor1[2]);
+ /* first calculate non-fac based Screen mix */
+ scr = 1.0f - (1.0f - inputColor2[0]) * (1.0f - inputColor1[0]);
+ scg = 1.0f - (1.0f - inputColor2[1]) * (1.0f - inputColor1[1]);
+ scb = 1.0f - (1.0f - inputColor2[2]) * (1.0f - inputColor1[2]);
- output[0] = valuem * (inputColor1[0]) + value * (((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) + (inputColor1[0] * scr));
- output[1] = valuem * (inputColor1[1]) + value * (((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) + (inputColor1[1] * scg));
- output[2] = valuem * (inputColor1[2]) + value * (((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) + (inputColor1[2] * scb));
- output[3] = inputColor1[3];
+ output[0] = valuem * (inputColor1[0]) +
+ value * (((1.0f - inputColor1[0]) * inputColor2[0] * (inputColor1[0])) +
+ (inputColor1[0] * scr));
+ output[1] = valuem * (inputColor1[1]) +
+ value * (((1.0f - inputColor1[1]) * inputColor2[1] * (inputColor1[1])) +
+ (inputColor1[1] * scg));
+ output[2] = valuem * (inputColor1[2]) +
+ value * (((1.0f - inputColor1[2]) * inputColor2[2] * (inputColor1[2])) +
+ (inputColor1[2] * scb));
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Subtract Operation ******** */
MixSubtractOperation::MixSubtractOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixSubtractOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixSubtractOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- output[0] = inputColor1[0] - value * (inputColor2[0]);
- output[1] = inputColor1[1] - value * (inputColor2[1]);
- output[2] = inputColor1[2] - value * (inputColor2[2]);
- output[3] = inputColor1[3];
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ output[0] = inputColor1[0] - value * (inputColor2[0]);
+ output[1] = inputColor1[1] - value * (inputColor2[1]);
+ output[2] = inputColor1[2] - value * (inputColor2[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
/* ******** Mix Value Operation ******** */
MixValueOperation::MixValueOperation() : MixBaseOperation()
{
- /* pass */
+ /* pass */
}
-void MixValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MixValueOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inputColor1[4];
- float inputColor2[4];
- float inputValue[4];
+ float inputColor1[4];
+ float inputColor2[4];
+ float inputValue[4];
- this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
- this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
- this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
+ this->m_inputValueOperation->readSampled(inputValue, x, y, sampler);
+ this->m_inputColor1Operation->readSampled(inputColor1, x, y, sampler);
+ this->m_inputColor2Operation->readSampled(inputColor2, x, y, sampler);
- float value = inputValue[0];
- if (this->useValueAlphaMultiply()) {
- value *= inputColor2[3];
- }
- float valuem = 1.0f - value;
+ float value = inputValue[0];
+ if (this->useValueAlphaMultiply()) {
+ value *= inputColor2[3];
+ }
+ float valuem = 1.0f - value;
- float rH, rS, rV;
- float colH, colS, colV;
- rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
- rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
- hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &output[0], &output[1], &output[2]);
- output[3] = inputColor1[3];
+ float rH, rS, rV;
+ float colH, colS, colV;
+ rgb_to_hsv(inputColor1[0], inputColor1[1], inputColor1[2], &rH, &rS, &rV);
+ rgb_to_hsv(inputColor2[0], inputColor2[1], inputColor2[2], &colH, &colS, &colV);
+ hsv_to_rgb(rH, rS, (valuem * rV + value * colV), &output[0], &output[1], &output[2]);
+ output[3] = inputColor1[3];
- clampIfNeeded(output);
+ clampIfNeeded(output);
}
diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h
index c724a54c9a4..6ea55a3edfd 100644
--- a/source/blender/compositor/operations/COM_MixOperation.h
+++ b/source/blender/compositor/operations/COM_MixOperation.h
@@ -20,174 +20,181 @@
#define __COM_MIXOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* All this programs converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class MixBaseOperation : public NodeOperation {
-protected:
- /**
- * Prefetched reference to the inputProgram
- */
- SocketReader *m_inputValueOperation;
- SocketReader *m_inputColor1Operation;
- SocketReader *m_inputColor2Operation;
- bool m_valueAlphaMultiply;
- bool m_useClamp;
-
- inline void clampIfNeeded(float color[4])
- {
- if (m_useClamp) {
- CLAMP(color[0], 0.0f, 1.0f);
- CLAMP(color[1], 0.0f, 1.0f);
- CLAMP(color[2], 0.0f, 1.0f);
- CLAMP(color[3], 0.0f, 1.0f);
- }
- }
-
-public:
- /**
- * Default constructor
- */
- MixBaseOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
-
- void setUseValueAlphaMultiply(const bool value) { this->m_valueAlphaMultiply = value; }
- inline bool useValueAlphaMultiply() { return this->m_valueAlphaMultiply; }
- void setUseClamp(bool value) { this->m_useClamp = value; }
+ protected:
+ /**
+ * Prefetched reference to the inputProgram
+ */
+ SocketReader *m_inputValueOperation;
+ SocketReader *m_inputColor1Operation;
+ SocketReader *m_inputColor2Operation;
+ bool m_valueAlphaMultiply;
+ bool m_useClamp;
+
+ inline void clampIfNeeded(float color[4])
+ {
+ if (m_useClamp) {
+ CLAMP(color[0], 0.0f, 1.0f);
+ CLAMP(color[1], 0.0f, 1.0f);
+ CLAMP(color[2], 0.0f, 1.0f);
+ CLAMP(color[3], 0.0f, 1.0f);
+ }
+ }
+
+ public:
+ /**
+ * Default constructor
+ */
+ MixBaseOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ void setUseValueAlphaMultiply(const bool value)
+ {
+ this->m_valueAlphaMultiply = value;
+ }
+ inline bool useValueAlphaMultiply()
+ {
+ return this->m_valueAlphaMultiply;
+ }
+ void setUseClamp(bool value)
+ {
+ this->m_useClamp = value;
+ }
};
class MixAddOperation : public MixBaseOperation {
-public:
- MixAddOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixAddOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixBlendOperation : public MixBaseOperation {
-public:
- MixBlendOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixBlendOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixBurnOperation : public MixBaseOperation {
-public:
- MixBurnOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixBurnOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixColorOperation : public MixBaseOperation {
-public:
- MixColorOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixColorOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDarkenOperation : public MixBaseOperation {
-public:
- MixDarkenOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixDarkenOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDifferenceOperation : public MixBaseOperation {
-public:
- MixDifferenceOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixDifferenceOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDivideOperation : public MixBaseOperation {
-public:
- MixDivideOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixDivideOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixDodgeOperation : public MixBaseOperation {
-public:
- MixDodgeOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixDodgeOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixGlareOperation : public MixBaseOperation {
-public:
- MixGlareOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixGlareOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixHueOperation : public MixBaseOperation {
-public:
- MixHueOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixHueOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixLightenOperation : public MixBaseOperation {
-public:
- MixLightenOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixLightenOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixLinearLightOperation : public MixBaseOperation {
-public:
- MixLinearLightOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixLinearLightOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixMultiplyOperation : public MixBaseOperation {
-public:
- MixMultiplyOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixMultiplyOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixOverlayOperation : public MixBaseOperation {
-public:
- MixOverlayOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixOverlayOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSaturationOperation : public MixBaseOperation {
-public:
- MixSaturationOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixSaturationOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixScreenOperation : public MixBaseOperation {
-public:
- MixScreenOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixScreenOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSoftLightOperation : public MixBaseOperation {
-public:
- MixSoftLightOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixSoftLightOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixSubtractOperation : public MixBaseOperation {
-public:
- MixSubtractOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixSubtractOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MixValueOperation : public MixBaseOperation {
-public:
- MixValueOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MixValueOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
index db91a8beb1a..967fa7ad653 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp
@@ -18,68 +18,65 @@
#include "COM_MovieClipAttributeOperation.h"
extern "C" {
-# include "BKE_tracking.h"
-# include "BKE_movieclip.h"
+#include "BKE_tracking.h"
+#include "BKE_movieclip.h"
}
MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
- this->m_framenumber = 0;
- this->m_attribute = MCA_X;
- this->m_invert = false;
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_framenumber = 0;
+ this->m_attribute = MCA_X;
+ this->m_invert = false;
}
void MovieClipAttributeOperation::initExecution()
{
- if (this->m_clip == NULL) {
- return;
- }
- float loc[2], scale, angle;
- loc[0] = 0.0f;
- loc[1] = 0.0f;
- scale = 1.0f;
- angle = 0.0f;
- int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(
- this->m_clip, this->m_framenumber);
- BKE_tracking_stabilization_data_get(this->m_clip,
- clip_framenr,
- getWidth(), getHeight(),
- loc, &scale, &angle);
- switch (this->m_attribute) {
- case MCA_SCALE:
- this->m_value = scale;
- break;
- case MCA_ANGLE:
- this->m_value = angle;
- break;
- case MCA_X:
- this->m_value = loc[0];
- break;
- case MCA_Y:
- this->m_value = loc[1];
- break;
- }
- if (this->m_invert) {
- if (this->m_attribute != MCA_SCALE) {
- this->m_value = -this->m_value;
- }
- else {
- this->m_value = 1.0f / this->m_value;
- }
- }
+ if (this->m_clip == NULL) {
+ return;
+ }
+ float loc[2], scale, angle;
+ loc[0] = 0.0f;
+ loc[1] = 0.0f;
+ scale = 1.0f;
+ angle = 0.0f;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_clip, this->m_framenumber);
+ BKE_tracking_stabilization_data_get(
+ this->m_clip, clip_framenr, getWidth(), getHeight(), loc, &scale, &angle);
+ switch (this->m_attribute) {
+ case MCA_SCALE:
+ this->m_value = scale;
+ break;
+ case MCA_ANGLE:
+ this->m_value = angle;
+ break;
+ case MCA_X:
+ this->m_value = loc[0];
+ break;
+ case MCA_Y:
+ this->m_value = loc[1];
+ break;
+ }
+ if (this->m_invert) {
+ if (this->m_attribute != MCA_SCALE) {
+ this->m_value = -this->m_value;
+ }
+ else {
+ this->m_value = 1.0f / this->m_value;
+ }
+ }
}
void MovieClipAttributeOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
+ float /*x*/,
+ float /*y*/,
PixelSampler /*sampler*/)
{
- output[0] = this->m_value;
+ output[0] = this->m_value;
}
-void MovieClipAttributeOperation::determineResolution(
- unsigned int resolution[2],
- unsigned int preferredResolution[2])
+void MovieClipAttributeOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
index a73167352d3..8a95293b470 100644
--- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h
@@ -22,40 +22,52 @@
#include "DNA_movieclip_types.h"
typedef enum MovieClipAttribute {
- MCA_SCALE,
- MCA_X,
- MCA_Y,
- MCA_ANGLE,
+ MCA_SCALE,
+ MCA_X,
+ MCA_Y,
+ MCA_ANGLE,
} MovieClipAttribute;
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class MovieClipAttributeOperation : public NodeOperation {
-private:
- MovieClip *m_clip;
- float m_value;
- int m_framenumber;
- bool m_invert;
- MovieClipAttribute m_attribute;
+ private:
+ MovieClip *m_clip;
+ float m_value;
+ int m_framenumber;
+ bool m_invert;
+ MovieClipAttribute m_attribute;
-public:
- /**
- * Default constructor
- */
- MovieClipAttributeOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ MovieClipAttributeOperation();
- void initExecution();
+ void initExecution();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void setMovieClip(MovieClip *clip) { this->m_clip = clip; }
- void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
- void setAttribute(MovieClipAttribute attribute) { this->m_attribute = attribute; }
- void setInvert(bool invert) { this->m_invert = invert; }
+ void setMovieClip(MovieClip *clip)
+ {
+ this->m_clip = clip;
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
+ void setAttribute(MovieClipAttribute attribute)
+ {
+ this->m_attribute = attribute;
+ }
+ void setInvert(bool invert)
+ {
+ this->m_invert = invert;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.cpp b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
index 1f4b947daa5..ce7973fdc99 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.cpp
@@ -21,106 +21,113 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
extern "C" {
-# include "BKE_movieclip.h"
-# include "IMB_imbuf.h"
+#include "BKE_movieclip.h"
+#include "IMB_imbuf.h"
}
#include "BKE_image.h"
MovieClipBaseOperation::MovieClipBaseOperation() : NodeOperation()
{
- this->m_movieClip = NULL;
- this->m_movieClipBuffer = NULL;
- this->m_movieClipUser = NULL;
- this->m_movieClipwidth = 0;
- this->m_movieClipheight = 0;
- this->m_framenumber = 0;
+ this->m_movieClip = NULL;
+ this->m_movieClipBuffer = NULL;
+ this->m_movieClipUser = NULL;
+ this->m_movieClipwidth = 0;
+ this->m_movieClipheight = 0;
+ this->m_framenumber = 0;
}
-
void MovieClipBaseOperation::initExecution()
{
- if (this->m_movieClip) {
- BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber);
- ImBuf *ibuf;
-
- if (this->m_cacheFrame)
- ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser);
- else
- ibuf = BKE_movieclip_get_ibuf_flag(this->m_movieClip, this->m_movieClipUser, this->m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
-
- if (ibuf) {
- this->m_movieClipBuffer = ibuf;
- if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) {
- IMB_float_from_rect(ibuf);
- ibuf->userflags &= ~IB_RECT_INVALID;
- }
- }
- }
+ if (this->m_movieClip) {
+ BKE_movieclip_user_set_frame(this->m_movieClipUser, this->m_framenumber);
+ ImBuf *ibuf;
+
+ if (this->m_cacheFrame)
+ ibuf = BKE_movieclip_get_ibuf(this->m_movieClip, this->m_movieClipUser);
+ else
+ ibuf = BKE_movieclip_get_ibuf_flag(
+ this->m_movieClip, this->m_movieClipUser, this->m_movieClip->flag, MOVIECLIP_CACHE_SKIP);
+
+ if (ibuf) {
+ this->m_movieClipBuffer = ibuf;
+ if (ibuf->rect_float == NULL || ibuf->userflags & IB_RECT_INVALID) {
+ IMB_float_from_rect(ibuf);
+ ibuf->userflags &= ~IB_RECT_INVALID;
+ }
+ }
+ }
}
void MovieClipBaseOperation::deinitExecution()
{
- if (this->m_movieClipBuffer) {
- IMB_freeImBuf(this->m_movieClipBuffer);
+ if (this->m_movieClipBuffer) {
+ IMB_freeImBuf(this->m_movieClipBuffer);
- this->m_movieClipBuffer = NULL;
- }
+ this->m_movieClipBuffer = NULL;
+ }
}
-void MovieClipBaseOperation::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void MovieClipBaseOperation::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- resolution[0] = 0;
- resolution[1] = 0;
+ resolution[0] = 0;
+ resolution[1] = 0;
- if (this->m_movieClip) {
- int width, height;
+ if (this->m_movieClip) {
+ int width, height;
- BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height);
+ BKE_movieclip_get_size(this->m_movieClip, this->m_movieClipUser, &width, &height);
- resolution[0] = width;
- resolution[1] = height;
- }
+ resolution[0] = width;
+ resolution[1] = height;
+ }
}
-void MovieClipBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MovieClipBaseOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- ImBuf *ibuf = this->m_movieClipBuffer;
-
- if (ibuf == NULL) {
- zero_v4(output);
- }
- else if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
- /* Happens for multilayer exr, i.e. */
- zero_v4(output);
- }
- else {
- switch (sampler) {
- case COM_PS_NEAREST:
- nearest_interpolation_color(ibuf, NULL, output, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(ibuf, NULL, output, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(ibuf, NULL, output, x, y);
- break;
- }
- }
+ ImBuf *ibuf = this->m_movieClipBuffer;
+
+ if (ibuf == NULL) {
+ zero_v4(output);
+ }
+ else if (ibuf->rect == NULL && ibuf->rect_float == NULL) {
+ /* Happens for multilayer exr, i.e. */
+ zero_v4(output);
+ }
+ else {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ nearest_interpolation_color(ibuf, NULL, output, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(ibuf, NULL, output, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(ibuf, NULL, output, x, y);
+ break;
+ }
+ }
}
MovieClipOperation::MovieClipOperation() : MovieClipBaseOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
MovieClipAlphaOperation::MovieClipAlphaOperation() : MovieClipBaseOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
}
-void MovieClipAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MovieClipAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float result[4];
- MovieClipBaseOperation::executePixelSampled(result, x, y, sampler);
- output[0] = result[3];
+ float result[4];
+ MovieClipBaseOperation::executePixelSampled(result, x, y, sampler);
+ output[0] = result[3];
}
diff --git a/source/blender/compositor/operations/COM_MovieClipOperation.h b/source/blender/compositor/operations/COM_MovieClipOperation.h
index caadb1e0a40..8d2dd99afc0 100644
--- a/source/blender/compositor/operations/COM_MovieClipOperation.h
+++ b/source/blender/compositor/operations/COM_MovieClipOperation.h
@@ -16,7 +16,6 @@
* Copyright 2011, Blender Foundation.
*/
-
#ifndef __COM_MOVIECLIPOPERATION_H__
#define __COM_MOVIECLIPOPERATION_H__
@@ -29,42 +28,54 @@
* Base class for movie clip
*/
class MovieClipBaseOperation : public NodeOperation {
-protected:
- MovieClip *m_movieClip;
- MovieClipUser *m_movieClipUser;
- ImBuf *m_movieClipBuffer;
- int m_movieClipheight;
- int m_movieClipwidth;
- int m_framenumber;
- bool m_cacheFrame;
+ protected:
+ MovieClip *m_movieClip;
+ MovieClipUser *m_movieClipUser;
+ ImBuf *m_movieClipBuffer;
+ int m_movieClipheight;
+ int m_movieClipwidth;
+ int m_framenumber;
+ bool m_cacheFrame;
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-public:
- MovieClipBaseOperation();
+ public:
+ MovieClipBaseOperation();
- void initExecution();
- void deinitExecution();
- void setMovieClip(MovieClip *image) { this->m_movieClip = image; }
- void setMovieClipUser(MovieClipUser *imageuser) { this->m_movieClipUser = imageuser; }
- void setCacheFrame(bool value) { this->m_cacheFrame = value; }
+ void initExecution();
+ void deinitExecution();
+ void setMovieClip(MovieClip *image)
+ {
+ this->m_movieClip = image;
+ }
+ void setMovieClipUser(MovieClipUser *imageuser)
+ {
+ this->m_movieClipUser = imageuser;
+ }
+ void setCacheFrame(bool value)
+ {
+ this->m_cacheFrame = value;
+ }
- void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MovieClipOperation : public MovieClipBaseOperation {
-public:
- MovieClipOperation();
+ public:
+ MovieClipOperation();
};
class MovieClipAlphaOperation : public MovieClipBaseOperation {
-public:
- MovieClipAlphaOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MovieClipAlphaOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index e8dc6f41110..be354ba5a12 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -19,72 +19,64 @@
#include "COM_MovieDistortionOperation.h"
extern "C" {
-# include "BKE_tracking.h"
-# include "BKE_movieclip.h"
-# include "BLI_linklist.h"
+#include "BKE_tracking.h"
+#include "BKE_movieclip.h"
+#include "BLI_linklist.h"
}
-
MovieDistortionOperation::MovieDistortionOperation(bool distortion) : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_movieClip = NULL;
- this->m_apply = distortion;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_movieClip = NULL;
+ this->m_apply = distortion;
}
void MovieDistortionOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- if (this->m_movieClip) {
- MovieTracking *tracking = &this->m_movieClip->tracking;
- MovieClipUser clipUser = {0};
- int calibration_width, calibration_height;
-
- BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber);
- BKE_movieclip_get_size(this->m_movieClip,
- &clipUser,
- &calibration_width,
- &calibration_height);
-
- float delta[2];
- rcti full_frame;
- full_frame.xmin = full_frame.ymin = 0;
- full_frame.xmax = this->m_width;
- full_frame.ymax = this->m_height;
- BKE_tracking_max_distortion_delta_across_bound(tracking,
- &full_frame,
- !this->m_apply,
- delta);
-
- /* 5 is just in case we didn't hit real max of distortion in
- * BKE_tracking_max_undistortion_delta_across_bound
- */
- m_margin[0] = delta[0] + 5;
- m_margin[1] = delta[1] + 5;
-
- this->m_distortion = BKE_tracking_distortion_new(tracking,
- calibration_width,
- calibration_height);
- this->m_calibration_width = calibration_width;
- this->m_calibration_height = calibration_height;
- this->m_pixel_aspect = tracking->camera.pixel_aspect;
- }
- else {
- m_margin[0] = m_margin[1] = 0;
- this->m_distortion = NULL;
- }
+ this->m_inputOperation = this->getInputSocketReader(0);
+ if (this->m_movieClip) {
+ MovieTracking *tracking = &this->m_movieClip->tracking;
+ MovieClipUser clipUser = {0};
+ int calibration_width, calibration_height;
+
+ BKE_movieclip_user_set_frame(&clipUser, this->m_framenumber);
+ BKE_movieclip_get_size(this->m_movieClip, &clipUser, &calibration_width, &calibration_height);
+
+ float delta[2];
+ rcti full_frame;
+ full_frame.xmin = full_frame.ymin = 0;
+ full_frame.xmax = this->m_width;
+ full_frame.ymax = this->m_height;
+ BKE_tracking_max_distortion_delta_across_bound(tracking, &full_frame, !this->m_apply, delta);
+
+ /* 5 is just in case we didn't hit real max of distortion in
+ * BKE_tracking_max_undistortion_delta_across_bound
+ */
+ m_margin[0] = delta[0] + 5;
+ m_margin[1] = delta[1] + 5;
+
+ this->m_distortion = BKE_tracking_distortion_new(
+ tracking, calibration_width, calibration_height);
+ this->m_calibration_width = calibration_width;
+ this->m_calibration_height = calibration_height;
+ this->m_pixel_aspect = tracking->camera.pixel_aspect;
+ }
+ else {
+ m_margin[0] = m_margin[1] = 0;
+ this->m_distortion = NULL;
+ }
}
void MovieDistortionOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_movieClip = NULL;
- if (this->m_distortion != NULL) {
- BKE_tracking_distortion_free(this->m_distortion);
- }
+ this->m_inputOperation = NULL;
+ this->m_movieClip = NULL;
+ if (this->m_distortion != NULL) {
+ BKE_tracking_distortion_free(this->m_distortion);
+ }
}
void MovieDistortionOperation::executePixelSampled(float output[4],
@@ -92,47 +84,44 @@ void MovieDistortionOperation::executePixelSampled(float output[4],
float y,
PixelSampler /*sampler*/)
{
- if (this->m_distortion != NULL) {
- /* float overscan = 0.0f; */
- const float pixel_aspect = this->m_pixel_aspect;
- const float w = (float)this->m_width /* / (1 + overscan) */;
- const float h = (float)this->m_height /* / (1 + overscan) */;
- const float aspx = w / (float)this->m_calibration_width;
- const float aspy = h / (float)this->m_calibration_height;
- float in[2];
- float out[2];
-
- in[0] = (x /* - 0.5 * overscan * w */) / aspx;
- in[1] = (y /* - 0.5 * overscan * h */) / aspy / pixel_aspect;
-
- if (this->m_apply) {
- BKE_tracking_distortion_undistort_v2(this->m_distortion, in, out);
- }
- else {
- BKE_tracking_distortion_distort_v2(this->m_distortion, in, out);
- }
-
- float u = out[0] * aspx /* + 0.5 * overscan * w */,
- v = (out[1] * aspy /* + 0.5 * overscan * h */) * pixel_aspect;
-
- this->m_inputOperation->readSampled(output, u, v, COM_PS_BILINEAR);
- }
- else {
- this->m_inputOperation->readSampled(output, x, y, COM_PS_BILINEAR);
- }
+ if (this->m_distortion != NULL) {
+ /* float overscan = 0.0f; */
+ const float pixel_aspect = this->m_pixel_aspect;
+ const float w = (float)this->m_width /* / (1 + overscan) */;
+ const float h = (float)this->m_height /* / (1 + overscan) */;
+ const float aspx = w / (float)this->m_calibration_width;
+ const float aspy = h / (float)this->m_calibration_height;
+ float in[2];
+ float out[2];
+
+ in[0] = (x /* - 0.5 * overscan * w */) / aspx;
+ in[1] = (y /* - 0.5 * overscan * h */) / aspy / pixel_aspect;
+
+ if (this->m_apply) {
+ BKE_tracking_distortion_undistort_v2(this->m_distortion, in, out);
+ }
+ else {
+ BKE_tracking_distortion_distort_v2(this->m_distortion, in, out);
+ }
+
+ float u = out[0] * aspx /* + 0.5 * overscan * w */,
+ v = (out[1] * aspy /* + 0.5 * overscan * h */) * pixel_aspect;
+
+ this->m_inputOperation->readSampled(output, u, v, COM_PS_BILINEAR);
+ }
+ else {
+ this->m_inputOperation->readSampled(output, x, y, COM_PS_BILINEAR);
+ }
}
-bool MovieDistortionOperation::determineDependingAreaOfInterest(
- rcti *input,
- ReadBufferOperation *readOperation,
- rcti *output)
+bool MovieDistortionOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- newInput.xmin = input->xmin - m_margin[0];
- newInput.ymin = input->ymin - m_margin[1];
- newInput.xmax = input->xmax + m_margin[0];
- newInput.ymax = input->ymax + m_margin[1];
- return NodeOperation::determineDependingAreaOfInterest(&newInput,
- readOperation,
- output);
+ rcti newInput;
+ newInput.xmin = input->xmin - m_margin[0];
+ newInput.ymin = input->ymin - m_margin[1];
+ newInput.xmax = input->xmax + m_margin[0];
+ newInput.ymax = input->ymax + m_margin[1];
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.h b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
index 89c242bf505..3ca9fe16b1e 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.h
@@ -24,38 +24,41 @@
#include "MEM_guardedalloc.h"
extern "C" {
-# include "BKE_tracking.h"
+#include "BKE_tracking.h"
}
class MovieDistortionOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
- MovieClip *m_movieClip;
- int m_margin[2];
-
-protected:
- bool m_apply;
- int m_framenumber;
-
- struct MovieDistortion *m_distortion;
- int m_calibration_width, m_calibration_height;
- float m_pixel_aspect;
-
-public:
- MovieDistortionOperation(bool distortion);
- void executePixelSampled(float output[4],
- float x, float y,
- PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
-
- void setMovieClip(MovieClip *clip) { this->m_movieClip = clip; }
- void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
- bool determineDependingAreaOfInterest(rcti *input,
- ReadBufferOperation *readOperation,
- rcti *output);
+ private:
+ SocketReader *m_inputOperation;
+ MovieClip *m_movieClip;
+ int m_margin[2];
+ protected:
+ bool m_apply;
+ int m_framenumber;
+
+ struct MovieDistortion *m_distortion;
+ int m_calibration_width, m_calibration_height;
+ float m_pixel_aspect;
+
+ public:
+ MovieDistortionOperation(bool distortion);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+
+ void setMovieClip(MovieClip *clip)
+ {
+ this->m_movieClip = clip;
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
index 34c6478d149..14542f1e65a 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.cpp
@@ -18,96 +18,108 @@
#include "COM_MultilayerImageOperation.h"
extern "C" {
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
}
MultilayerBaseOperation::MultilayerBaseOperation(int passindex, int view) : BaseImageOperation()
{
- this->m_passId = passindex;
- this->m_view = view;
+ this->m_passId = passindex;
+ this->m_view = view;
}
ImBuf *MultilayerBaseOperation::getImBuf()
{
- /* temporarily changes the view to get the right ImBuf */
- int view = this->m_imageUser->view;
+ /* temporarily changes the view to get the right ImBuf */
+ int view = this->m_imageUser->view;
- this->m_imageUser->view = this->m_view;
- this->m_imageUser->pass = this->m_passId;
+ this->m_imageUser->view = this->m_view;
+ this->m_imageUser->pass = this->m_passId;
- if (BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser)) {
- ImBuf *ibuf = BaseImageOperation::getImBuf();
- this->m_imageUser->view = view;
- return ibuf;
- }
+ if (BKE_image_multilayer_index(this->m_image->rr, this->m_imageUser)) {
+ ImBuf *ibuf = BaseImageOperation::getImBuf();
+ this->m_imageUser->view = view;
+ return ibuf;
+ }
- this->m_imageUser->view = view;
- return NULL;
+ this->m_imageUser->view = view;
+ return NULL;
}
-void MultilayerColorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void MultilayerColorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- if (this->m_imageFloatBuffer == NULL) {
- zero_v4(output);
- }
- else {
- if (this->m_numberOfChannels == 4) {
- switch (sampler) {
- case COM_PS_NEAREST:
- nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
- break;
- case COM_PS_BILINEAR:
- bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
- break;
- case COM_PS_BICUBIC:
- bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
- break;
- }
- }
- else {
- int yi = y;
- int xi = x;
- if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight())
- zero_v4(output);
- else {
- int offset = (yi * this->getWidth() + xi) * 3;
- copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
- }
- }
- }
+ if (this->m_imageFloatBuffer == NULL) {
+ zero_v4(output);
+ }
+ else {
+ if (this->m_numberOfChannels == 4) {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ nearest_interpolation_color(this->m_buffer, NULL, output, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ bilinear_interpolation_color(this->m_buffer, NULL, output, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ bicubic_interpolation_color(this->m_buffer, NULL, output, x, y);
+ break;
+ }
+ }
+ else {
+ int yi = y;
+ int xi = x;
+ if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
+ (unsigned int)yi >= this->getHeight())
+ zero_v4(output);
+ else {
+ int offset = (yi * this->getWidth() + xi) * 3;
+ copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
+ }
+ }
+ }
}
-void MultilayerValueOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void MultilayerValueOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- if (this->m_imageFloatBuffer == NULL) {
- output[0] = 0.0f;
- }
- else {
- int yi = y;
- int xi = x;
- if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight())
- output[0] = 0.0f;
- else {
- float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
- output[0] = result;
- }
- }
+ if (this->m_imageFloatBuffer == NULL) {
+ output[0] = 0.0f;
+ }
+ else {
+ int yi = y;
+ int xi = x;
+ if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
+ (unsigned int)yi >= this->getHeight())
+ output[0] = 0.0f;
+ else {
+ float result = this->m_imageFloatBuffer[yi * this->getWidth() + xi];
+ output[0] = result;
+ }
+ }
}
-void MultilayerVectorOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void MultilayerVectorOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- if (this->m_imageFloatBuffer == NULL) {
- output[0] = 0.0f;
- }
- else {
- int yi = y;
- int xi = x;
- if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() || (unsigned int)yi >= this->getHeight())
- output[0] = 0.0f;
- else {
- int offset = (yi * this->getWidth() + xi) * 3;
- copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
- }
- }
+ if (this->m_imageFloatBuffer == NULL) {
+ output[0] = 0.0f;
+ }
+ else {
+ int yi = y;
+ int xi = x;
+ if (xi < 0 || yi < 0 || (unsigned int)xi >= this->getWidth() ||
+ (unsigned int)yi >= this->getHeight())
+ output[0] = 0.0f;
+ else {
+ int offset = (yi * this->getWidth() + xi) * 3;
+ copy_v3_v3(output, &this->m_imageFloatBuffer[offset]);
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_MultilayerImageOperation.h b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
index 948301e2be4..10c475ced4d 100644
--- a/source/blender/compositor/operations/COM_MultilayerImageOperation.h
+++ b/source/blender/compositor/operations/COM_MultilayerImageOperation.h
@@ -16,49 +16,56 @@
* Copyright 2011, Blender Foundation.
*/
-
#ifndef __COM_MULTILAYERIMAGEOPERATION_H__
#define __COM_MULTILAYERIMAGEOPERATION_H__
#include "COM_ImageOperation.h"
class MultilayerBaseOperation : public BaseImageOperation {
-private:
- int m_passId;
- int m_view;
- RenderLayer *m_renderlayer;
-protected:
- ImBuf *getImBuf();
-public:
- /**
- * Constructor
- */
- MultilayerBaseOperation(int passindex, int view);
- void setRenderLayer(RenderLayer *renderlayer) { this->m_renderlayer = renderlayer; }
+ private:
+ int m_passId;
+ int m_view;
+ RenderLayer *m_renderlayer;
+
+ protected:
+ ImBuf *getImBuf();
+
+ public:
+ /**
+ * Constructor
+ */
+ MultilayerBaseOperation(int passindex, int view);
+ void setRenderLayer(RenderLayer *renderlayer)
+ {
+ this->m_renderlayer = renderlayer;
+ }
};
class MultilayerColorOperation : public MultilayerBaseOperation {
-public:
- MultilayerColorOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view) {
- this->addOutputSocket(COM_DT_COLOR);
- }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MultilayerColorOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view)
+ {
+ this->addOutputSocket(COM_DT_COLOR);
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MultilayerValueOperation : public MultilayerBaseOperation {
-public:
- MultilayerValueOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view) {
- this->addOutputSocket(COM_DT_VALUE);
- }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MultilayerValueOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view)
+ {
+ this->addOutputSocket(COM_DT_VALUE);
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class MultilayerVectorOperation : public MultilayerBaseOperation {
-public:
- MultilayerVectorOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view) {
- this->addOutputSocket(COM_DT_VECTOR);
- }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ MultilayerVectorOperation(int passindex, int view) : MultilayerBaseOperation(passindex, view)
+ {
+ this->addOutputSocket(COM_DT_VECTOR);
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.cpp b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
index b32bb42ca62..703ffbe3999 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.cpp
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.cpp
@@ -20,58 +20,61 @@
NormalizeOperation::NormalizeOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_VALUE);
- this->m_imageReader = NULL;
- this->m_cachedInstance = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_imageReader = NULL;
+ this->m_cachedInstance = NULL;
+ this->setComplex(true);
}
void NormalizeOperation::initExecution()
{
- this->m_imageReader = this->getInputSocketReader(0);
- NodeOperation::initMutex();
+ this->m_imageReader = this->getInputSocketReader(0);
+ NodeOperation::initMutex();
}
void NormalizeOperation::executePixel(float output[4], int x, int y, void *data)
{
- /* using generic two floats struct to store x: min y: mult */
- NodeTwoFloats *minmult = (NodeTwoFloats *)data;
+ /* using generic two floats struct to store x: min y: mult */
+ NodeTwoFloats *minmult = (NodeTwoFloats *)data;
- this->m_imageReader->read(output, x, y, NULL);
+ this->m_imageReader->read(output, x, y, NULL);
- output[0] = (output[0] - minmult->x) * minmult->y;
+ output[0] = (output[0] - minmult->x) * minmult->y;
- /* clamp infinities */
- if (output[0] > 1.0f)
- output[0] = 1.0f;
- else if (output[0] < 0.0f)
- output[0] = 0.0f;
+ /* clamp infinities */
+ if (output[0] > 1.0f)
+ output[0] = 1.0f;
+ else if (output[0] < 0.0f)
+ output[0] = 0.0f;
}
void NormalizeOperation::deinitExecution()
{
- this->m_imageReader = NULL;
- if (this->m_cachedInstance) {
- delete this->m_cachedInstance;
- }
- NodeOperation::deinitMutex();
+ this->m_imageReader = NULL;
+ if (this->m_cachedInstance) {
+ delete this->m_cachedInstance;
+ }
+ NodeOperation::deinitMutex();
}
-bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti imageInput;
- if (this->m_cachedInstance) return false;
-
- NodeOperation *operation = getInputOperation(0);
- imageInput.xmax = operation->getWidth();
- imageInput.xmin = 0;
- imageInput.ymax = operation->getHeight();
- imageInput.ymin = 0;
-
- if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
- return true;
- }
- return false;
+ rcti imageInput;
+ if (this->m_cachedInstance)
+ return false;
+
+ NodeOperation *operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output)) {
+ return true;
+ }
+ return false;
}
/* The code below assumes all data is inside range +- this, and that input buffer is single channel */
@@ -79,43 +82,43 @@ bool NormalizeOperation::determineDependingAreaOfInterest(rcti * /*input*/, Read
void *NormalizeOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (this->m_cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
- /* using generic two floats struct to store x: min y: mult */
- NodeTwoFloats *minmult = new NodeTwoFloats();
-
- float *buffer = tile->getBuffer();
- int p = tile->getWidth() * tile->getHeight();
- float *bc = buffer;
-
- float minv = 1.0f + BLENDER_ZMAX;
- float maxv = -1.0f - BLENDER_ZMAX;
-
- float value;
- while (p--) {
- value = bc[0];
- if ((value > maxv) && (value <= BLENDER_ZMAX)) {
- maxv = value;
- }
- if ((value < minv) && (value >= -BLENDER_ZMAX)) {
- minv = value;
- }
- bc ++;
- }
-
- minmult->x = minv;
- /* The rare case of flat buffer would cause a divide by 0 */
- minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.0f);
-
- this->m_cachedInstance = minmult;
- }
-
- unlockMutex();
- return this->m_cachedInstance;
+ lockMutex();
+ if (this->m_cachedInstance == NULL) {
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
+ /* using generic two floats struct to store x: min y: mult */
+ NodeTwoFloats *minmult = new NodeTwoFloats();
+
+ float *buffer = tile->getBuffer();
+ int p = tile->getWidth() * tile->getHeight();
+ float *bc = buffer;
+
+ float minv = 1.0f + BLENDER_ZMAX;
+ float maxv = -1.0f - BLENDER_ZMAX;
+
+ float value;
+ while (p--) {
+ value = bc[0];
+ if ((value > maxv) && (value <= BLENDER_ZMAX)) {
+ maxv = value;
+ }
+ if ((value < minv) && (value >= -BLENDER_ZMAX)) {
+ minv = value;
+ }
+ bc++;
+ }
+
+ minmult->x = minv;
+ /* The rare case of flat buffer would cause a divide by 0 */
+ minmult->y = ((maxv != minv) ? 1.0f / (maxv - minv) : 0.0f);
+
+ this->m_cachedInstance = minmult;
+ }
+
+ unlockMutex();
+ return this->m_cachedInstance;
}
void NormalizeOperation::deinitializeTileData(rcti * /*rect*/, void * /*data*/)
{
- /* pass */
+ /* pass */
}
diff --git a/source/blender/compositor/operations/COM_NormalizeOperation.h b/source/blender/compositor/operations/COM_NormalizeOperation.h
index e7803fe3dee..a38e79bb0ab 100644
--- a/source/blender/compositor/operations/COM_NormalizeOperation.h
+++ b/source/blender/compositor/operations/COM_NormalizeOperation.h
@@ -26,41 +26,42 @@
* \ingroup operation
*/
class NormalizeOperation : public NodeOperation {
-protected:
- /**
- * \brief Cached reference to the reader
- */
- SocketReader *m_imageReader;
+ protected:
+ /**
+ * \brief Cached reference to the reader
+ */
+ SocketReader *m_imageReader;
- /**
- * \brief temporarily cache of the execution storage
- * it stores x->min and y->mult
- */
- NodeTwoFloats *m_cachedInstance;
+ /**
+ * \brief temporarily cache of the execution storage
+ * it stores x->min and y->mult
+ */
+ NodeTwoFloats *m_cachedInstance;
-public:
- NormalizeOperation();
+ public:
+ NormalizeOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void *initializeTileData(rcti *rect);
- void deinitializeTileData(rcti *rect, void *data);
+ void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
index 1a2d5a052cd..62ba896f38e 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cpp
@@ -42,274 +42,327 @@ extern "C" {
/************************************ OpenEXR Singlelayer Multiview *****************************************/
OutputOpenExrSingleLayerMultiViewOperation::OutputOpenExrSingleLayerMultiViewOperation(
- const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
- const char *viewName)
- : OutputSingleLayerOperation(rd, tree, datatype, format, path, viewSettings, displaySettings, viewName)
+ const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName)
+ : OutputSingleLayerOperation(
+ rd, tree, datatype, format, path, viewSettings, displaySettings, viewName)
{
}
void *OutputOpenExrSingleLayerMultiViewOperation::get_handle(const char *filename)
{
- size_t width = this->getWidth();
- size_t height = this->getHeight();
- SceneRenderView *srv;
+ size_t width = this->getWidth();
+ size_t height = this->getHeight();
+ SceneRenderView *srv;
- if (width != 0 && height != 0) {
- void *exrhandle;
+ if (width != 0 && height != 0) {
+ void *exrhandle;
- exrhandle = IMB_exr_get_handle_name(filename);
+ exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
- return exrhandle;
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ return exrhandle;
- IMB_exr_clear_channels(exrhandle);
+ IMB_exr_clear_channels(exrhandle);
- for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
- continue;
+ for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
+ if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
+ continue;
- IMB_exr_add_view(exrhandle, srv->name);
- add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, false, NULL);
- }
+ IMB_exr_add_view(exrhandle, srv->name);
+ add_exr_channels(exrhandle, NULL, this->m_datatype, srv->name, width, false, NULL);
+ }
- BLI_make_existing_file(filename);
+ BLI_make_existing_file(filename);
- /* prepare the file with all the channels */
+ /* prepare the file with all the channels */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_format->exr_codec, NULL) == 0) {
- printf("Error Writing Singlelayer Multiview Openexr\n");
- IMB_exr_close(exrhandle);
- }
- else {
- IMB_exr_clear_channels(exrhandle);
- return exrhandle;
- }
- }
- return NULL;
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_format->exr_codec, NULL) ==
+ 0) {
+ printf("Error Writing Singlelayer Multiview Openexr\n");
+ IMB_exr_close(exrhandle);
+ }
+ else {
+ IMB_exr_clear_channels(exrhandle);
+ return exrhandle;
+ }
+ }
+ return NULL;
}
void OutputOpenExrSingleLayerMultiViewOperation::deinitExecution()
{
- unsigned int width = this->getWidth();
- unsigned int height = this->getHeight();
-
- if (width != 0 && height != 0) {
- void *exrhandle;
- char filename[FILE_MAX];
-
- BKE_image_path_from_imtype(
- filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_OPENEXR,
- (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
-
- exrhandle = this->get_handle(filename);
- add_exr_channels(exrhandle, NULL, this->m_datatype, this->m_viewName, width,
- this->m_format->depth == R_IMF_CHAN_DEPTH_16, this->m_outputBuffer);
-
- /* memory can only be freed after we write all views to the file */
- this->m_outputBuffer = NULL;
- this->m_imageInput = NULL;
-
- /* ready to close the file */
- if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
- IMB_exr_write_channels(exrhandle);
-
- /* free buffer memory for all the views */
- free_exr_channels(exrhandle, this->m_rd, NULL, this->m_datatype);
-
- /* remove exr handle and data */
- IMB_exr_close(exrhandle);
- }
- }
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
+
+ if (width != 0 && height != 0) {
+ void *exrhandle;
+ char filename[FILE_MAX];
+
+ BKE_image_path_from_imtype(filename,
+ this->m_path,
+ BKE_main_blendfile_path_from_global(),
+ this->m_rd->cfra,
+ R_IMF_IMTYPE_OPENEXR,
+ (this->m_rd->scemode & R_EXTENSION) != 0,
+ true,
+ NULL);
+
+ exrhandle = this->get_handle(filename);
+ add_exr_channels(exrhandle,
+ NULL,
+ this->m_datatype,
+ this->m_viewName,
+ width,
+ this->m_format->depth == R_IMF_CHAN_DEPTH_16,
+ this->m_outputBuffer);
+
+ /* memory can only be freed after we write all views to the file */
+ this->m_outputBuffer = NULL;
+ this->m_imageInput = NULL;
+
+ /* ready to close the file */
+ if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
+ IMB_exr_write_channels(exrhandle);
+
+ /* free buffer memory for all the views */
+ free_exr_channels(exrhandle, this->m_rd, NULL, this->m_datatype);
+
+ /* remove exr handle and data */
+ IMB_exr_close(exrhandle);
+ }
+ }
}
/************************************ OpenEXR Multilayer Multiview *****************************************/
OutputOpenExrMultiLayerMultiViewOperation::OutputOpenExrMultiLayerMultiViewOperation(
- const RenderData *rd, const bNodeTree *tree, const char *path,
- char exr_codec, bool exr_half_float, const char *viewName)
+ const RenderData *rd,
+ const bNodeTree *tree,
+ const char *path,
+ char exr_codec,
+ bool exr_half_float,
+ const char *viewName)
: OutputOpenExrMultiLayerOperation(rd, tree, path, exr_codec, exr_half_float, viewName)
{
}
void *OutputOpenExrMultiLayerMultiViewOperation::get_handle(const char *filename)
{
- unsigned int width = this->getWidth();
- unsigned int height = this->getHeight();
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
- if (width != 0 && height != 0) {
+ if (width != 0 && height != 0) {
- void *exrhandle;
- SceneRenderView *srv;
+ void *exrhandle;
+ SceneRenderView *srv;
- /* get a new global handle */
- exrhandle = IMB_exr_get_handle_name(filename);
+ /* get a new global handle */
+ exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
- return exrhandle;
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ return exrhandle;
- IMB_exr_clear_channels(exrhandle);
+ IMB_exr_clear_channels(exrhandle);
- /* check renderdata for amount of views */
- for (srv = (SceneRenderView *) this->m_rd->views.first; srv; srv = srv->next) {
+ /* check renderdata for amount of views */
+ for (srv = (SceneRenderView *)this->m_rd->views.first; srv; srv = srv->next) {
- if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
- continue;
+ if (BKE_scene_multiview_is_render_view_active(this->m_rd, srv) == false)
+ continue;
- IMB_exr_add_view(exrhandle, srv->name);
+ IMB_exr_add_view(exrhandle, srv->name);
- for (unsigned int i = 0; i < this->m_layers.size(); ++i)
- add_exr_channels(exrhandle, this->m_layers[i].name, this->m_layers[i].datatype,
- srv->name, width, this->m_exr_half_float, NULL);
- }
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i)
+ add_exr_channels(exrhandle,
+ this->m_layers[i].name,
+ this->m_layers[i].datatype,
+ srv->name,
+ width,
+ this->m_exr_half_float,
+ NULL);
+ }
- BLI_make_existing_file(filename);
+ BLI_make_existing_file(filename);
- /* prepare the file with all the channels for the header */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL) == 0) {
- printf("Error Writing Multilayer Multiview Openexr\n");
- IMB_exr_close(exrhandle);
- }
- else {
- IMB_exr_clear_channels(exrhandle);
- return exrhandle;
- }
- }
- return NULL;
+ /* prepare the file with all the channels for the header */
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL) == 0) {
+ printf("Error Writing Multilayer Multiview Openexr\n");
+ IMB_exr_close(exrhandle);
+ }
+ else {
+ IMB_exr_clear_channels(exrhandle);
+ return exrhandle;
+ }
+ }
+ return NULL;
}
void OutputOpenExrMultiLayerMultiViewOperation::deinitExecution()
{
- unsigned int width = this->getWidth();
- unsigned int height = this->getHeight();
-
- if (width != 0 && height != 0) {
- void *exrhandle;
- char filename[FILE_MAX];
-
- BKE_image_path_from_imtype(
- filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
- (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
-
- exrhandle = this->get_handle(filename);
-
- for (unsigned int i = 0; i < this->m_layers.size(); ++i)
- add_exr_channels(exrhandle, this->m_layers[i].name, this->m_layers[i].datatype, this->m_viewName,
- width, this->m_exr_half_float, this->m_layers[i].outputBuffer);
-
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- /* memory can only be freed after we write all views to the file */
- this->m_layers[i].outputBuffer = NULL;
- this->m_layers[i].imageInput = NULL;
- }
-
- /* ready to close the file */
- if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
- IMB_exr_write_channels(exrhandle);
-
- /* free buffer memory for all the views */
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- free_exr_channels(exrhandle, this->m_rd, this->m_layers[i].name, this->m_layers[i].datatype);
- }
-
- IMB_exr_close(exrhandle);
- }
- }
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
+
+ if (width != 0 && height != 0) {
+ void *exrhandle;
+ char filename[FILE_MAX];
+
+ BKE_image_path_from_imtype(filename,
+ this->m_path,
+ BKE_main_blendfile_path_from_global(),
+ this->m_rd->cfra,
+ R_IMF_IMTYPE_MULTILAYER,
+ (this->m_rd->scemode & R_EXTENSION) != 0,
+ true,
+ NULL);
+
+ exrhandle = this->get_handle(filename);
+
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i)
+ add_exr_channels(exrhandle,
+ this->m_layers[i].name,
+ this->m_layers[i].datatype,
+ this->m_viewName,
+ width,
+ this->m_exr_half_float,
+ this->m_layers[i].outputBuffer);
+
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ /* memory can only be freed after we write all views to the file */
+ this->m_layers[i].outputBuffer = NULL;
+ this->m_layers[i].imageInput = NULL;
+ }
+
+ /* ready to close the file */
+ if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
+ IMB_exr_write_channels(exrhandle);
+
+ /* free buffer memory for all the views */
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ free_exr_channels(
+ exrhandle, this->m_rd, this->m_layers[i].name, this->m_layers[i].datatype);
+ }
+
+ IMB_exr_close(exrhandle);
+ }
+ }
}
-
/******************************** Stereo3D ******************************/
-OutputStereoOperation::OutputStereoOperation(
- const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
- const char *name, const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings,
- const char *viewName)
- : OutputSingleLayerOperation(rd, tree, datatype, format, path, viewSettings, displaySettings, viewName)
+OutputStereoOperation::OutputStereoOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const char *name,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName)
+ : OutputSingleLayerOperation(
+ rd, tree, datatype, format, path, viewSettings, displaySettings, viewName)
{
- BLI_strncpy(this->m_name, name, sizeof(this->m_name));
- this->m_channels = get_datatype_size(datatype);
+ BLI_strncpy(this->m_name, name, sizeof(this->m_name));
+ this->m_channels = get_datatype_size(datatype);
}
void *OutputStereoOperation::get_handle(const char *filename)
{
- size_t width = this->getWidth();
- size_t height = this->getHeight();
- const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- size_t i;
+ size_t width = this->getWidth();
+ size_t height = this->getHeight();
+ const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+ size_t i;
- if (width != 0 && height != 0) {
- void *exrhandle;
+ if (width != 0 && height != 0) {
+ void *exrhandle;
- exrhandle = IMB_exr_get_handle_name(filename);
+ exrhandle = IMB_exr_get_handle_name(filename);
- if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
- return exrhandle;
+ if (!BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName))
+ return exrhandle;
- IMB_exr_clear_channels(exrhandle);
+ IMB_exr_clear_channels(exrhandle);
- for (i = 0; i < 2; i++)
- IMB_exr_add_view(exrhandle, names[i]);
+ for (i = 0; i < 2; i++)
+ IMB_exr_add_view(exrhandle, names[i]);
- return exrhandle;
- }
- return NULL;
+ return exrhandle;
+ }
+ return NULL;
}
void OutputStereoOperation::deinitExecution()
{
- unsigned int width = this->getWidth();
- unsigned int height = this->getHeight();
-
- if (width != 0 && height != 0) {
- void *exrhandle;
-
- exrhandle = this->get_handle(this->m_path);
- float *buf = this->m_outputBuffer;
-
- /* populate single EXR channel with view data */
- IMB_exr_add_channel(exrhandle, NULL, this->m_name, this->m_viewName, 1, this->m_channels * width * height, buf,
- this->m_format->depth == R_IMF_CHAN_DEPTH_16);
-
- this->m_imageInput = NULL;
- this->m_outputBuffer = NULL;
-
- /* create stereo ibuf */
- if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
- ImBuf *ibuf[3] = {NULL};
- const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
- char filename[FILE_MAX];
- int i;
-
- /* get rectf from EXR */
- for (i = 0; i < 2; i++) {
- float *rectf = IMB_exr_channel_rect(exrhandle, NULL, this->m_name, names[i]);
- ibuf[i] = IMB_allocImBuf(width, height, this->m_format->planes, 0);
-
- ibuf[i]->channels = this->m_channels;
- ibuf[i]->rect_float = rectf;
- ibuf[i]->mall |= IB_rectfloat;
- ibuf[i]->dither = this->m_rd->dither_intensity;
-
- /* do colormanagement in the individual views, so it doesn't need to do in the stereo */
- IMB_colormanagement_imbuf_for_write(ibuf[i], true, false, this->m_viewSettings,
- this->m_displaySettings, this->m_format);
- IMB_prepare_write_ImBuf(IMB_isfloat(ibuf[i]), ibuf[i]);
- }
-
- /* create stereo buffer */
- ibuf[2] = IMB_stereo3d_ImBuf(this->m_format, ibuf[0], ibuf[1]);
-
- BKE_image_path_from_imformat(
- filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format,
- (this->m_rd->scemode & R_EXTENSION) != 0, true, NULL);
-
- BKE_imbuf_write(ibuf[2], filename, this->m_format);
-
- /* imbuf knows which rects are not part of ibuf */
- for (i = 0; i < 3; i++)
- IMB_freeImBuf(ibuf[i]);
-
- IMB_exr_close(exrhandle);
- }
- }
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
+
+ if (width != 0 && height != 0) {
+ void *exrhandle;
+
+ exrhandle = this->get_handle(this->m_path);
+ float *buf = this->m_outputBuffer;
+
+ /* populate single EXR channel with view data */
+ IMB_exr_add_channel(exrhandle,
+ NULL,
+ this->m_name,
+ this->m_viewName,
+ 1,
+ this->m_channels * width * height,
+ buf,
+ this->m_format->depth == R_IMF_CHAN_DEPTH_16);
+
+ this->m_imageInput = NULL;
+ this->m_outputBuffer = NULL;
+
+ /* create stereo ibuf */
+ if (BKE_scene_multiview_is_render_view_last(this->m_rd, this->m_viewName)) {
+ ImBuf *ibuf[3] = {NULL};
+ const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
+ char filename[FILE_MAX];
+ int i;
+
+ /* get rectf from EXR */
+ for (i = 0; i < 2; i++) {
+ float *rectf = IMB_exr_channel_rect(exrhandle, NULL, this->m_name, names[i]);
+ ibuf[i] = IMB_allocImBuf(width, height, this->m_format->planes, 0);
+
+ ibuf[i]->channels = this->m_channels;
+ ibuf[i]->rect_float = rectf;
+ ibuf[i]->mall |= IB_rectfloat;
+ ibuf[i]->dither = this->m_rd->dither_intensity;
+
+ /* do colormanagement in the individual views, so it doesn't need to do in the stereo */
+ IMB_colormanagement_imbuf_for_write(
+ ibuf[i], true, false, this->m_viewSettings, this->m_displaySettings, this->m_format);
+ IMB_prepare_write_ImBuf(IMB_isfloat(ibuf[i]), ibuf[i]);
+ }
+
+ /* create stereo buffer */
+ ibuf[2] = IMB_stereo3d_ImBuf(this->m_format, ibuf[0], ibuf[1]);
+
+ BKE_image_path_from_imformat(filename,
+ this->m_path,
+ BKE_main_blendfile_path_from_global(),
+ this->m_rd->cfra,
+ this->m_format,
+ (this->m_rd->scemode & R_EXTENSION) != 0,
+ true,
+ NULL);
+
+ BKE_imbuf_write(ibuf[2], filename, this->m_format);
+
+ /* imbuf knows which rects are not part of ibuf */
+ for (i = 0; i < 3; i++)
+ IMB_freeImBuf(ibuf[i]);
+
+ IMB_exr_close(exrhandle);
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
index a3bcaac2835..036468f9472 100644
--- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.h
@@ -28,40 +28,53 @@
#include "intern/openexr/openexr_multi.h"
class OutputOpenExrSingleLayerMultiViewOperation : public OutputSingleLayerOperation {
-private:
-public:
- OutputOpenExrSingleLayerMultiViewOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype,
- ImageFormatData *format, const char *path,
- const ColorManagedViewSettings *viewSettings,
- const ColorManagedDisplaySettings *displaySettings,
- const char *viewName);
+ private:
+ public:
+ OutputOpenExrSingleLayerMultiViewOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName);
- void *get_handle(const char *filename);
- void deinitExecution();
+ void *get_handle(const char *filename);
+ void deinitExecution();
};
/* Writes inputs into OpenEXR multilayer channels. */
class OutputOpenExrMultiLayerMultiViewOperation : public OutputOpenExrMultiLayerOperation {
-private:
-public:
- OutputOpenExrMultiLayerMultiViewOperation(const RenderData *rd, const bNodeTree *tree, const char *path,
- char exr_codec, bool exr_half_float, const char *viewName);
+ private:
+ public:
+ OutputOpenExrMultiLayerMultiViewOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ const char *path,
+ char exr_codec,
+ bool exr_half_float,
+ const char *viewName);
- void *get_handle(const char *filename);
- void deinitExecution();
+ void *get_handle(const char *filename);
+ void deinitExecution();
};
class OutputStereoOperation : public OutputSingleLayerOperation {
-private:
- char m_name[FILE_MAX];
- size_t m_channels;
-public:
- OutputStereoOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype,
- struct ImageFormatData *format, const char *path, const char *name,
- const ColorManagedViewSettings *viewSettings,
- const ColorManagedDisplaySettings *displaySettings, const char *viewName);
- void *get_handle(const char *filename);
- void deinitExecution();
+ private:
+ char m_name[FILE_MAX];
+ size_t m_channels;
+
+ public:
+ OutputStereoOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ struct ImageFormatData *format,
+ const char *path,
+ const char *name,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName);
+ void *get_handle(const char *filename);
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
index 9da3d15883c..f83ce478bd5 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp
@@ -32,279 +32,340 @@
#include "DNA_color_types.h"
extern "C" {
-# include "MEM_guardedalloc.h"
-# include "IMB_imbuf.h"
-# include "IMB_colormanagement.h"
-# include "IMB_imbuf_types.h"
+#include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
+#include "IMB_colormanagement.h"
+#include "IMB_imbuf_types.h"
}
-void add_exr_channels(void *exrhandle, const char *layerName, const DataType datatype,
- const char *viewName, const size_t width, bool use_half_float, float *buf)
+void add_exr_channels(void *exrhandle,
+ const char *layerName,
+ const DataType datatype,
+ const char *viewName,
+ const size_t width,
+ bool use_half_float,
+ float *buf)
{
- /* create channels */
- switch (datatype) {
- case COM_DT_VALUE:
- IMB_exr_add_channel(exrhandle, layerName, "V", viewName, 1, width, buf ? buf : NULL, use_half_float);
- break;
- case COM_DT_VECTOR:
- IMB_exr_add_channel(exrhandle, layerName, "X", viewName, 3, 3 * width, buf ? buf : NULL, use_half_float);
- IMB_exr_add_channel(exrhandle, layerName, "Y", viewName, 3, 3 * width, buf ? buf + 1 : NULL, use_half_float);
- IMB_exr_add_channel(exrhandle, layerName, "Z", viewName, 3, 3 * width, buf ? buf + 2 : NULL, use_half_float);
- break;
- case COM_DT_COLOR:
- IMB_exr_add_channel(exrhandle, layerName, "R", viewName, 4, 4 * width, buf ? buf : NULL, use_half_float);
- IMB_exr_add_channel(exrhandle, layerName, "G", viewName, 4, 4 * width, buf ? buf + 1 : NULL, use_half_float);
- IMB_exr_add_channel(exrhandle, layerName, "B", viewName, 4, 4 * width, buf ? buf + 2 : NULL, use_half_float);
- IMB_exr_add_channel(exrhandle, layerName, "A", viewName, 4, 4 * width, buf ? buf + 3 : NULL, use_half_float);
- break;
- default:
- break;
- }
+ /* create channels */
+ switch (datatype) {
+ case COM_DT_VALUE:
+ IMB_exr_add_channel(
+ exrhandle, layerName, "V", viewName, 1, width, buf ? buf : NULL, use_half_float);
+ break;
+ case COM_DT_VECTOR:
+ IMB_exr_add_channel(
+ exrhandle, layerName, "X", viewName, 3, 3 * width, buf ? buf : NULL, use_half_float);
+ IMB_exr_add_channel(
+ exrhandle, layerName, "Y", viewName, 3, 3 * width, buf ? buf + 1 : NULL, use_half_float);
+ IMB_exr_add_channel(
+ exrhandle, layerName, "Z", viewName, 3, 3 * width, buf ? buf + 2 : NULL, use_half_float);
+ break;
+ case COM_DT_COLOR:
+ IMB_exr_add_channel(
+ exrhandle, layerName, "R", viewName, 4, 4 * width, buf ? buf : NULL, use_half_float);
+ IMB_exr_add_channel(
+ exrhandle, layerName, "G", viewName, 4, 4 * width, buf ? buf + 1 : NULL, use_half_float);
+ IMB_exr_add_channel(
+ exrhandle, layerName, "B", viewName, 4, 4 * width, buf ? buf + 2 : NULL, use_half_float);
+ IMB_exr_add_channel(
+ exrhandle, layerName, "A", viewName, 4, 4 * width, buf ? buf + 3 : NULL, use_half_float);
+ break;
+ default:
+ break;
+ }
}
-void free_exr_channels(void *exrhandle, const RenderData *rd, const char *layerName, const DataType datatype)
+void free_exr_channels(void *exrhandle,
+ const RenderData *rd,
+ const char *layerName,
+ const DataType datatype)
{
- SceneRenderView *srv;
-
- /* check renderdata for amount of views */
- for (srv = (SceneRenderView *) rd->views.first; srv; srv = srv->next) {
- float *rect = NULL;
-
- if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
- continue;
-
- /* the pointer is stored in the first channel of each datatype */
- switch (datatype) {
- case COM_DT_VALUE:
- rect = IMB_exr_channel_rect(exrhandle, layerName, "V", srv->name);
- break;
- case COM_DT_VECTOR:
- rect = IMB_exr_channel_rect(exrhandle, layerName, "X", srv->name);
- break;
- case COM_DT_COLOR:
- rect = IMB_exr_channel_rect(exrhandle, layerName, "R", srv->name);
- break;
- default:
- break;
- }
- if (rect)
- MEM_freeN(rect);
- }
+ SceneRenderView *srv;
+
+ /* check renderdata for amount of views */
+ for (srv = (SceneRenderView *)rd->views.first; srv; srv = srv->next) {
+ float *rect = NULL;
+
+ if (BKE_scene_multiview_is_render_view_active(rd, srv) == false)
+ continue;
+
+ /* the pointer is stored in the first channel of each datatype */
+ switch (datatype) {
+ case COM_DT_VALUE:
+ rect = IMB_exr_channel_rect(exrhandle, layerName, "V", srv->name);
+ break;
+ case COM_DT_VECTOR:
+ rect = IMB_exr_channel_rect(exrhandle, layerName, "X", srv->name);
+ break;
+ case COM_DT_COLOR:
+ rect = IMB_exr_channel_rect(exrhandle, layerName, "R", srv->name);
+ break;
+ default:
+ break;
+ }
+ if (rect)
+ MEM_freeN(rect);
+ }
}
int get_datatype_size(DataType datatype)
{
- switch (datatype) {
- case COM_DT_VALUE: return 1;
- case COM_DT_VECTOR: return 3;
- case COM_DT_COLOR: return 4;
- default: return 0;
- }
+ switch (datatype) {
+ case COM_DT_VALUE:
+ return 1;
+ case COM_DT_VECTOR:
+ return 3;
+ case COM_DT_COLOR:
+ return 4;
+ default:
+ return 0;
+ }
}
static float *init_buffer(unsigned int width, unsigned int height, DataType datatype)
{
- // When initializing the tree during initial load the width and height can be zero.
- if (width != 0 && height != 0) {
- int size = get_datatype_size(datatype);
- return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
- }
- else
- return NULL;
+ // When initializing the tree during initial load the width and height can be zero.
+ if (width != 0 && height != 0) {
+ int size = get_datatype_size(datatype);
+ return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer");
+ }
+ else
+ return NULL;
}
-static void write_buffer_rect(rcti *rect, const bNodeTree *tree,
- SocketReader *reader, float *buffer, unsigned int width, DataType datatype)
+static void write_buffer_rect(rcti *rect,
+ const bNodeTree *tree,
+ SocketReader *reader,
+ float *buffer,
+ unsigned int width,
+ DataType datatype)
{
- float color[4];
- int i, size = get_datatype_size(datatype);
-
- if (!buffer) return;
- int x1 = rect->xmin;
- int y1 = rect->ymin;
- int x2 = rect->xmax;
- int y2 = rect->ymax;
- int offset = (y1 * width + x1) * size;
- int x;
- int y;
- bool breaked = false;
-
- for (y = y1; y < y2 && (!breaked); y++) {
- for (x = x1; x < x2 && (!breaked); x++) {
- reader->readSampled(color, x, y, COM_PS_NEAREST);
-
- for (i = 0; i < size; ++i)
- buffer[offset + i] = color[i];
- offset += size;
-
- if (tree->test_break && tree->test_break(tree->tbh))
- breaked = true;
- }
- offset += (width - (x2 - x1)) * size;
- }
+ float color[4];
+ int i, size = get_datatype_size(datatype);
+
+ if (!buffer)
+ return;
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int offset = (y1 * width + x1) * size;
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2 && (!breaked); x++) {
+ reader->readSampled(color, x, y, COM_PS_NEAREST);
+
+ for (i = 0; i < size; ++i)
+ buffer[offset + i] = color[i];
+ offset += size;
+
+ if (tree->test_break && tree->test_break(tree->tbh))
+ breaked = true;
+ }
+ offset += (width - (x2 - x1)) * size;
+ }
}
-
OutputSingleLayerOperation::OutputSingleLayerOperation(
- const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings, const char *viewName)
+ const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName)
{
- this->m_rd = rd;
- this->m_tree = tree;
+ this->m_rd = rd;
+ this->m_tree = tree;
- this->addInputSocket(datatype);
+ this->addInputSocket(datatype);
- this->m_outputBuffer = NULL;
- this->m_datatype = datatype;
- this->m_imageInput = NULL;
+ this->m_outputBuffer = NULL;
+ this->m_datatype = datatype;
+ this->m_imageInput = NULL;
- this->m_format = format;
- BLI_strncpy(this->m_path, path, sizeof(this->m_path));
+ this->m_format = format;
+ BLI_strncpy(this->m_path, path, sizeof(this->m_path));
- this->m_viewSettings = viewSettings;
- this->m_displaySettings = displaySettings;
- this->m_viewName = viewName;
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
+ this->m_viewName = viewName;
}
void OutputSingleLayerOperation::initExecution()
{
- this->m_imageInput = getInputSocketReader(0);
- this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype);
+ this->m_imageInput = getInputSocketReader(0);
+ this->m_outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_datatype);
}
void OutputSingleLayerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- write_buffer_rect(rect, this->m_tree, this->m_imageInput, this->m_outputBuffer, this->getWidth(), this->m_datatype);
+ write_buffer_rect(rect,
+ this->m_tree,
+ this->m_imageInput,
+ this->m_outputBuffer,
+ this->getWidth(),
+ this->m_datatype);
}
void OutputSingleLayerOperation::deinitExecution()
{
- if (this->getWidth() * this->getHeight() != 0) {
-
- int size = get_datatype_size(this->m_datatype);
- ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), this->m_format->planes, 0);
- char filename[FILE_MAX];
- const char *suffix;
-
- ibuf->channels = size;
- ibuf->rect_float = this->m_outputBuffer;
- ibuf->mall |= IB_rectfloat;
- ibuf->dither = this->m_rd->dither_intensity;
-
- IMB_colormanagement_imbuf_for_write(ibuf, true, false, m_viewSettings, m_displaySettings,
- this->m_format);
-
- suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
-
- BKE_image_path_from_imformat(
- filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, this->m_format,
- (this->m_rd->scemode & R_EXTENSION) != 0, true, suffix);
-
- if (0 == BKE_imbuf_write(ibuf, filename, this->m_format))
- printf("Cannot save Node File Output to %s\n", filename);
- else
- printf("Saved: %s\n", filename);
-
- IMB_freeImBuf(ibuf);
- }
- this->m_outputBuffer = NULL;
- this->m_imageInput = NULL;
+ if (this->getWidth() * this->getHeight() != 0) {
+
+ int size = get_datatype_size(this->m_datatype);
+ ImBuf *ibuf = IMB_allocImBuf(this->getWidth(), this->getHeight(), this->m_format->planes, 0);
+ char filename[FILE_MAX];
+ const char *suffix;
+
+ ibuf->channels = size;
+ ibuf->rect_float = this->m_outputBuffer;
+ ibuf->mall |= IB_rectfloat;
+ ibuf->dither = this->m_rd->dither_intensity;
+
+ IMB_colormanagement_imbuf_for_write(
+ ibuf, true, false, m_viewSettings, m_displaySettings, this->m_format);
+
+ suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
+
+ BKE_image_path_from_imformat(filename,
+ this->m_path,
+ BKE_main_blendfile_path_from_global(),
+ this->m_rd->cfra,
+ this->m_format,
+ (this->m_rd->scemode & R_EXTENSION) != 0,
+ true,
+ suffix);
+
+ if (0 == BKE_imbuf_write(ibuf, filename, this->m_format))
+ printf("Cannot save Node File Output to %s\n", filename);
+ else
+ printf("Saved: %s\n", filename);
+
+ IMB_freeImBuf(ibuf);
+ }
+ this->m_outputBuffer = NULL;
+ this->m_imageInput = NULL;
}
/******************************* MultiLayer *******************************/
OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_, bool use_layer_)
{
- BLI_strncpy(this->name, name_, sizeof(this->name));
- this->datatype = datatype_;
- this->use_layer = use_layer_;
+ BLI_strncpy(this->name, name_, sizeof(this->name));
+ this->datatype = datatype_;
+ this->use_layer = use_layer_;
- /* these are created in initExecution */
- this->outputBuffer = 0;
- this->imageInput = 0;
+ /* these are created in initExecution */
+ this->outputBuffer = 0;
+ this->imageInput = 0;
}
-OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(
- const RenderData *rd, const bNodeTree *tree, const char *path,
- char exr_codec, bool exr_half_float, const char *viewName)
+OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ const char *path,
+ char exr_codec,
+ bool exr_half_float,
+ const char *viewName)
{
- this->m_rd = rd;
- this->m_tree = tree;
+ this->m_rd = rd;
+ this->m_tree = tree;
- BLI_strncpy(this->m_path, path, sizeof(this->m_path));
- this->m_exr_codec = exr_codec;
- this->m_exr_half_float = exr_half_float;
- this->m_viewName = viewName;
+ BLI_strncpy(this->m_path, path, sizeof(this->m_path));
+ this->m_exr_codec = exr_codec;
+ this->m_exr_half_float = exr_half_float;
+ this->m_viewName = viewName;
}
-void OutputOpenExrMultiLayerOperation::add_layer(const char *name, DataType datatype, bool use_layer)
+void OutputOpenExrMultiLayerOperation::add_layer(const char *name,
+ DataType datatype,
+ bool use_layer)
{
- this->addInputSocket(datatype);
- this->m_layers.push_back(OutputOpenExrLayer(name, datatype, use_layer));
+ this->addInputSocket(datatype);
+ this->m_layers.push_back(OutputOpenExrLayer(name, datatype, use_layer));
}
void OutputOpenExrMultiLayerOperation::initExecution()
{
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- if (this->m_layers[i].use_layer) {
- SocketReader *reader = getInputSocketReader(i);
- this->m_layers[i].imageInput = reader;
- this->m_layers[i].outputBuffer = init_buffer(this->getWidth(), this->getHeight(), this->m_layers[i].datatype);
- }
- }
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ if (this->m_layers[i].use_layer) {
+ SocketReader *reader = getInputSocketReader(i);
+ this->m_layers[i].imageInput = reader;
+ this->m_layers[i].outputBuffer = init_buffer(
+ this->getWidth(), this->getHeight(), this->m_layers[i].datatype);
+ }
+ }
}
void OutputOpenExrMultiLayerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- OutputOpenExrLayer &layer = this->m_layers[i];
- if (layer.imageInput)
- write_buffer_rect(rect, this->m_tree, layer.imageInput, layer.outputBuffer, this->getWidth(), layer.datatype);
- }
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ OutputOpenExrLayer &layer = this->m_layers[i];
+ if (layer.imageInput)
+ write_buffer_rect(rect,
+ this->m_tree,
+ layer.imageInput,
+ layer.outputBuffer,
+ this->getWidth(),
+ layer.datatype);
+ }
}
void OutputOpenExrMultiLayerOperation::deinitExecution()
{
- unsigned int width = this->getWidth();
- unsigned int height = this->getHeight();
- if (width != 0 && height != 0) {
- char filename[FILE_MAX];
- const char *suffix;
- void *exrhandle = IMB_exr_get_handle();
-
- suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
- BKE_image_path_from_imtype(
- filename, this->m_path, BKE_main_blendfile_path_from_global(), this->m_rd->cfra, R_IMF_IMTYPE_MULTILAYER,
- (this->m_rd->scemode & R_EXTENSION) != 0, true, suffix);
- BLI_make_existing_file(filename);
-
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- OutputOpenExrLayer &layer = this->m_layers[i];
- if (!layer.imageInput)
- continue; /* skip unconnected sockets */
-
- add_exr_channels(exrhandle, this->m_layers[i].name, this->m_layers[i].datatype, "", width,
- this->m_exr_half_float, this->m_layers[i].outputBuffer);
- }
-
- /* when the filename has no permissions, this can fail */
- if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL)) {
- IMB_exr_write_channels(exrhandle);
- }
- else {
- /* TODO, get the error from openexr's exception */
- /* XXX nice way to do report? */
- printf("Error Writing Render Result, see console\n");
- }
-
- IMB_exr_close(exrhandle);
- for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
- if (this->m_layers[i].outputBuffer) {
- MEM_freeN(this->m_layers[i].outputBuffer);
- this->m_layers[i].outputBuffer = NULL;
- }
-
- this->m_layers[i].imageInput = NULL;
- }
- }
+ unsigned int width = this->getWidth();
+ unsigned int height = this->getHeight();
+ if (width != 0 && height != 0) {
+ char filename[FILE_MAX];
+ const char *suffix;
+ void *exrhandle = IMB_exr_get_handle();
+
+ suffix = BKE_scene_multiview_view_suffix_get(this->m_rd, this->m_viewName);
+ BKE_image_path_from_imtype(filename,
+ this->m_path,
+ BKE_main_blendfile_path_from_global(),
+ this->m_rd->cfra,
+ R_IMF_IMTYPE_MULTILAYER,
+ (this->m_rd->scemode & R_EXTENSION) != 0,
+ true,
+ suffix);
+ BLI_make_existing_file(filename);
+
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ OutputOpenExrLayer &layer = this->m_layers[i];
+ if (!layer.imageInput)
+ continue; /* skip unconnected sockets */
+
+ add_exr_channels(exrhandle,
+ this->m_layers[i].name,
+ this->m_layers[i].datatype,
+ "",
+ width,
+ this->m_exr_half_float,
+ this->m_layers[i].outputBuffer);
+ }
+
+ /* when the filename has no permissions, this can fail */
+ if (IMB_exr_begin_write(exrhandle, filename, width, height, this->m_exr_codec, NULL)) {
+ IMB_exr_write_channels(exrhandle);
+ }
+ else {
+ /* TODO, get the error from openexr's exception */
+ /* XXX nice way to do report? */
+ printf("Error Writing Render Result, see console\n");
+ }
+
+ IMB_exr_close(exrhandle);
+ for (unsigned int i = 0; i < this->m_layers.size(); ++i) {
+ if (this->m_layers[i].outputBuffer) {
+ MEM_freeN(this->m_layers[i].outputBuffer);
+ this->m_layers[i].outputBuffer = NULL;
+ }
+
+ this->m_layers[i].imageInput = NULL;
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.h b/source/blender/compositor/operations/COM_OutputFileOperation.h
index de256e25ce0..3ffba6b374e 100644
--- a/source/blender/compositor/operations/COM_OutputFileOperation.h
+++ b/source/blender/compositor/operations/COM_OutputFileOperation.h
@@ -29,79 +29,116 @@
/* Writes the image to a single-layer file. */
class OutputSingleLayerOperation : public NodeOperation {
-protected:
- const RenderData *m_rd;
- const bNodeTree *m_tree;
-
- ImageFormatData *m_format;
- char m_path[FILE_MAX];
-
- float *m_outputBuffer;
- DataType m_datatype;
- SocketReader *m_imageInput;
-
- const ColorManagedViewSettings *m_viewSettings;
- const ColorManagedDisplaySettings *m_displaySettings;
-
- const char *m_viewName;
-public:
- OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path,
- const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings, const char *viewName);
-
- void executeRegion(rcti *rect, unsigned int tileNumber);
- bool isOutputOperation(bool /*rendering*/) const { return true; }
- void initExecution();
- void deinitExecution();
- CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
-
- bool isFileOutputOperation() const { return true; }
+ protected:
+ const RenderData *m_rd;
+ const bNodeTree *m_tree;
+
+ ImageFormatData *m_format;
+ char m_path[FILE_MAX];
+
+ float *m_outputBuffer;
+ DataType m_datatype;
+ SocketReader *m_imageInput;
+
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
+
+ const char *m_viewName;
+
+ public:
+ OutputSingleLayerOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ DataType datatype,
+ ImageFormatData *format,
+ const char *path,
+ const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings,
+ const char *viewName);
+
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ bool isOutputOperation(bool /*rendering*/) const
+ {
+ return true;
+ }
+ void initExecution();
+ void deinitExecution();
+ CompositorPriority getRenderPriority() const
+ {
+ return COM_PRIORITY_LOW;
+ }
+
+ bool isFileOutputOperation() const
+ {
+ return true;
+ }
};
/* extra info for OpenEXR layers */
struct OutputOpenExrLayer {
- OutputOpenExrLayer(const char *name, DataType datatype, bool use_layer);
+ OutputOpenExrLayer(const char *name, DataType datatype, bool use_layer);
- char name[EXR_TOT_MAXNAME - 2];
- DataType datatype;
- bool use_layer;
+ char name[EXR_TOT_MAXNAME - 2];
+ DataType datatype;
+ bool use_layer;
- /* internals */
- float *outputBuffer;
- SocketReader *imageInput;
+ /* internals */
+ float *outputBuffer;
+ SocketReader *imageInput;
};
/* Writes inputs into OpenEXR multilayer channels. */
class OutputOpenExrMultiLayerOperation : public NodeOperation {
-protected:
- typedef std::vector<OutputOpenExrLayer> LayerList;
-
- const RenderData *m_rd;
- const bNodeTree *m_tree;
-
- char m_path[FILE_MAX];
- char m_exr_codec;
- bool m_exr_half_float;
- LayerList m_layers;
- const char *m_viewName;
-
-public:
- OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path,
- char exr_codec, bool exr_half_float, const char *viewName);
-
- void add_layer(const char *name, DataType datatype, bool use_layer);
-
- void executeRegion(rcti *rect, unsigned int tileNumber);
- bool isOutputOperation(bool /*rendering*/) const { return true; }
- void initExecution();
- void deinitExecution();
- CompositorPriority getRenderPriority() const { return COM_PRIORITY_LOW; }
-
- bool isFileOutputOperation() const { return true; }
+ protected:
+ typedef std::vector<OutputOpenExrLayer> LayerList;
+
+ const RenderData *m_rd;
+ const bNodeTree *m_tree;
+
+ char m_path[FILE_MAX];
+ char m_exr_codec;
+ bool m_exr_half_float;
+ LayerList m_layers;
+ const char *m_viewName;
+
+ public:
+ OutputOpenExrMultiLayerOperation(const RenderData *rd,
+ const bNodeTree *tree,
+ const char *path,
+ char exr_codec,
+ bool exr_half_float,
+ const char *viewName);
+
+ void add_layer(const char *name, DataType datatype, bool use_layer);
+
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ bool isOutputOperation(bool /*rendering*/) const
+ {
+ return true;
+ }
+ void initExecution();
+ void deinitExecution();
+ CompositorPriority getRenderPriority() const
+ {
+ return COM_PRIORITY_LOW;
+ }
+
+ bool isFileOutputOperation() const
+ {
+ return true;
+ }
};
-void add_exr_channels(void *exrhandle, const char *layerName, const DataType datatype, const char *viewName,
- const size_t width, bool use_half_float, float *buf);
-void free_exr_channels(void *exrhandle, const RenderData *rd, const char *layerName, const DataType datatype);
+void add_exr_channels(void *exrhandle,
+ const char *layerName,
+ const DataType datatype,
+ const char *viewName,
+ const size_t width,
+ bool use_half_float,
+ float *buf);
+void free_exr_channels(void *exrhandle,
+ const RenderData *rd,
+ const char *layerName,
+ const DataType datatype);
int get_datatype_size(DataType datatype);
#endif
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp
index e047f8a38de..18e691d3c34 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.cpp
+++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp
@@ -20,25 +20,28 @@
PixelateOperation::PixelateOperation(DataType datatype) : NodeOperation()
{
- this->addInputSocket(datatype);
- this->addOutputSocket(datatype);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
+ this->addInputSocket(datatype);
+ this->addOutputSocket(datatype);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
}
void PixelateOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputOperation = this->getInputSocketReader(0);
}
void PixelateOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
-void PixelateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void PixelateOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float nx = round(x);
- float ny = round(y);
- this->m_inputOperation->readSampled(output, nx, ny, sampler);
+ float nx = round(x);
+ float ny = round(y);
+ this->m_inputOperation->readSampled(output, nx, ny, sampler);
}
diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h
index f9846cec2f6..86aab26ee00 100644
--- a/source/blender/compositor/operations/COM_PixelateOperation.h
+++ b/source/blender/compositor/operations/COM_PixelateOperation.h
@@ -29,36 +29,37 @@
* This operation will remove the sub-pixel accuracy
*/
class PixelateOperation : public NodeOperation {
-private:
- /**
- * \brief cached reference to the input operation
- */
- SocketReader *m_inputOperation;
-public:
- /**
- * \brief PixelateOperation
- * \param dataType: the datatype to create this operator for (saves datatype conversions)
- */
- PixelateOperation(DataType dataType);
+ private:
+ /**
+ * \brief cached reference to the input operation
+ */
+ SocketReader *m_inputOperation;
- /**
- * \brief initialization of the execution
- */
- void initExecution();
+ public:
+ /**
+ * \brief PixelateOperation
+ * \param dataType: the datatype to create this operator for (saves datatype conversions)
+ */
+ PixelateOperation(DataType dataType);
- /**
- * \brief de-initialization of the execution
- */
- void deinitExecution();
+ /**
+ * \brief initialization of the execution
+ */
+ void initExecution();
- /**
- * \brief executePixel
- * \param output: result
- * \param x: x-coordinate
- * \param y: y-coordinate
- * \param sampler: sampler
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * \brief de-initialization of the execution
+ */
+ void deinitExecution();
+
+ /**
+ * \brief executePixel
+ * \param output: result
+ * \param x: x-coordinate
+ * \param y: y-coordinate
+ * \param sampler: sampler
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
index c1dae48d1c6..54d5d6e97a5 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.cpp
@@ -25,192 +25,194 @@
#include "BLI_math_color.h"
extern "C" {
-# include "BKE_node.h"
+#include "BKE_node.h"
}
static bool check_corners(float corners[4][2])
{
- int i, next, prev;
- float cross = 0.0f;
+ int i, next, prev;
+ float cross = 0.0f;
- for (i = 0; i < 4; i++) {
- float v1[2], v2[2], cur_cross;
+ for (i = 0; i < 4; i++) {
+ float v1[2], v2[2], cur_cross;
- next = (i + 1) % 4;
- prev = (4 + i - 1) % 4;
+ next = (i + 1) % 4;
+ prev = (4 + i - 1) % 4;
- sub_v2_v2v2(v1, corners[i], corners[prev]);
- sub_v2_v2v2(v2, corners[next], corners[i]);
+ sub_v2_v2v2(v1, corners[i], corners[prev]);
+ sub_v2_v2v2(v2, corners[next], corners[i]);
- cur_cross = cross_v2v2(v1, v2);
- if (fabsf(cur_cross) <= FLT_EPSILON)
- return false;
+ cur_cross = cross_v2v2(v1, v2);
+ if (fabsf(cur_cross) <= FLT_EPSILON)
+ return false;
- if (cross == 0.0f)
- cross = cur_cross;
- else if (cross * cur_cross < 0.0f)
- return false;
- }
+ if (cross == 0.0f)
+ cross = cur_cross;
+ else if (cross * cur_cross < 0.0f)
+ return false;
+ }
- return true;
+ return true;
}
static void readCornersFromSockets(rcti *rect, SocketReader *readers[4], float corners[4][2])
{
- for (int i = 0; i < 4; ++i) {
- float result[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- readers[i]->readSampled(result, rect->xmin, rect->ymin, COM_PS_NEAREST);
- corners[i][0] = result[0];
- corners[i][1] = result[1];
- }
-
- /* convexity check:
- * concave corners need to be prevented, otherwise
- * BKE_tracking_homography_between_two_quads will freeze
- */
- if (!check_corners(corners)) {
- /* simply revert to default corners
- * there could be a more elegant solution,
- * this prevents freezing at least.
- */
- corners[0][0] = 0.0f; corners[0][1] = 0.0f;
- corners[1][0] = 1.0f; corners[1][1] = 0.0f;
- corners[2][0] = 1.0f; corners[2][1] = 1.0f;
- corners[3][0] = 0.0f; corners[3][1] = 1.0f;
- }
+ for (int i = 0; i < 4; ++i) {
+ float result[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ readers[i]->readSampled(result, rect->xmin, rect->ymin, COM_PS_NEAREST);
+ corners[i][0] = result[0];
+ corners[i][1] = result[1];
+ }
+
+ /* convexity check:
+ * concave corners need to be prevented, otherwise
+ * BKE_tracking_homography_between_two_quads will freeze
+ */
+ if (!check_corners(corners)) {
+ /* simply revert to default corners
+ * there could be a more elegant solution,
+ * this prevents freezing at least.
+ */
+ corners[0][0] = 0.0f;
+ corners[0][1] = 0.0f;
+ corners[1][0] = 1.0f;
+ corners[1][1] = 0.0f;
+ corners[2][0] = 1.0f;
+ corners[2][1] = 1.0f;
+ corners[3][0] = 0.0f;
+ corners[3][1] = 1.0f;
+ }
}
-
/* ******** PlaneCornerPinMaskOperation ******** */
-PlaneCornerPinMaskOperation::PlaneCornerPinMaskOperation() :
- PlaneDistortMaskOperation(),
- m_corners_ready(false)
+PlaneCornerPinMaskOperation::PlaneCornerPinMaskOperation()
+ : PlaneDistortMaskOperation(), m_corners_ready(false)
{
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
-
- /* XXX this is stupid: we need to make this "complex",
- * so we can use the initializeTileData function
- * to read corners from input sockets ...
- */
- setComplex(true);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+
+ /* XXX this is stupid: we need to make this "complex",
+ * so we can use the initializeTileData function
+ * to read corners from input sockets ...
+ */
+ setComplex(true);
}
void PlaneCornerPinMaskOperation::initExecution()
{
- PlaneDistortMaskOperation::initExecution();
+ PlaneDistortMaskOperation::initExecution();
- initMutex();
+ initMutex();
}
void PlaneCornerPinMaskOperation::deinitExecution()
{
- PlaneDistortMaskOperation::deinitExecution();
+ PlaneDistortMaskOperation::deinitExecution();
- deinitMutex();
+ deinitMutex();
}
void *PlaneCornerPinMaskOperation::initializeTileData(rcti *rect)
{
- void *data = PlaneDistortMaskOperation::initializeTileData(rect);
-
- /* get corner values once, by reading inputs at (0,0)
- * XXX this assumes invariable values (no image inputs),
- * we don't have a nice generic system for that yet
- */
- lockMutex();
- if (!m_corners_ready) {
- SocketReader *readers[4] = { getInputSocketReader(0),
- getInputSocketReader(1),
- getInputSocketReader(2),
- getInputSocketReader(3) };
- float corners[4][2];
- readCornersFromSockets(rect, readers, corners);
- calculateCorners(corners, true, 0);
-
- m_corners_ready = true;
- }
- unlockMutex();
-
- return data;
+ void *data = PlaneDistortMaskOperation::initializeTileData(rect);
+
+ /* get corner values once, by reading inputs at (0,0)
+ * XXX this assumes invariable values (no image inputs),
+ * we don't have a nice generic system for that yet
+ */
+ lockMutex();
+ if (!m_corners_ready) {
+ SocketReader *readers[4] = {getInputSocketReader(0),
+ getInputSocketReader(1),
+ getInputSocketReader(2),
+ getInputSocketReader(3)};
+ float corners[4][2];
+ readCornersFromSockets(rect, readers, corners);
+ calculateCorners(corners, true, 0);
+
+ m_corners_ready = true;
+ }
+ unlockMutex();
+
+ return data;
}
-void PlaneCornerPinMaskOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void PlaneCornerPinMaskOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
-
/* ******** PlaneCornerPinWarpImageOperation ******** */
-PlaneCornerPinWarpImageOperation::PlaneCornerPinWarpImageOperation() :
- PlaneDistortWarpImageOperation(),
- m_corners_ready(false)
+PlaneCornerPinWarpImageOperation::PlaneCornerPinWarpImageOperation()
+ : PlaneDistortWarpImageOperation(), m_corners_ready(false)
{
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
- addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
+ addInputSocket(COM_DT_VECTOR);
}
void PlaneCornerPinWarpImageOperation::initExecution()
{
- PlaneDistortWarpImageOperation::initExecution();
+ PlaneDistortWarpImageOperation::initExecution();
- initMutex();
+ initMutex();
}
void PlaneCornerPinWarpImageOperation::deinitExecution()
{
- PlaneDistortWarpImageOperation::deinitExecution();
+ PlaneDistortWarpImageOperation::deinitExecution();
- deinitMutex();
+ deinitMutex();
}
void *PlaneCornerPinWarpImageOperation::initializeTileData(rcti *rect)
{
- void *data = PlaneDistortWarpImageOperation::initializeTileData(rect);
-
- /* get corner values once, by reading inputs at (0,0)
- * XXX this assumes invariable values (no image inputs),
- * we don't have a nice generic system for that yet
- */
- lockMutex();
- if (!m_corners_ready) {
- /* corner sockets start at index 1 */
- SocketReader *readers[4] = { getInputSocketReader(1),
- getInputSocketReader(2),
- getInputSocketReader(3),
- getInputSocketReader(4) };
- float corners[4][2];
- readCornersFromSockets(rect, readers, corners);
- calculateCorners(corners, true, 0);
-
- m_corners_ready = true;
- }
- unlockMutex();
-
- return data;
+ void *data = PlaneDistortWarpImageOperation::initializeTileData(rect);
+
+ /* get corner values once, by reading inputs at (0,0)
+ * XXX this assumes invariable values (no image inputs),
+ * we don't have a nice generic system for that yet
+ */
+ lockMutex();
+ if (!m_corners_ready) {
+ /* corner sockets start at index 1 */
+ SocketReader *readers[4] = {getInputSocketReader(1),
+ getInputSocketReader(2),
+ getInputSocketReader(3),
+ getInputSocketReader(4)};
+ float corners[4][2];
+ readCornersFromSockets(rect, readers, corners);
+ calculateCorners(corners, true, 0);
+
+ m_corners_ready = true;
+ }
+ unlockMutex();
+
+ return data;
}
-bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool PlaneCornerPinWarpImageOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- for (int i = 0; i < 4; ++i)
- if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output))
- return true;
-
- /* XXX this is bad, but unavoidable with the current design:
- * we don't know the actual corners and matrix at this point,
- * so all we can do is get the full input image
- */
- output->xmin = 0;
- output->ymin = 0;
- output->xmax = getInputOperation(0)->getWidth();
- output->ymax = getInputOperation(0)->getHeight();
- return true;
-// return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(input, readOperation, output);
+ for (int i = 0; i < 4; ++i)
+ if (getInputOperation(i + 1)->determineDependingAreaOfInterest(input, readOperation, output))
+ return true;
+
+ /* XXX this is bad, but unavoidable with the current design:
+ * we don't know the actual corners and matrix at this point,
+ * so all we can do is get the full input image
+ */
+ output->xmin = 0;
+ output->ymin = 0;
+ output->xmax = getInputOperation(0)->getWidth();
+ output->ymax = getInputOperation(0)->getHeight();
+ return true;
+ // return PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(input, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
index fc22d00c0f2..444616e13f2 100644
--- a/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneCornerPinOperation.h
@@ -28,36 +28,36 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
-
class PlaneCornerPinMaskOperation : public PlaneDistortMaskOperation {
-private:
- bool m_corners_ready;
+ private:
+ bool m_corners_ready;
-public:
- PlaneCornerPinMaskOperation();
+ public:
+ PlaneCornerPinMaskOperation();
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
};
-
class PlaneCornerPinWarpImageOperation : public PlaneDistortWarpImageOperation {
-private:
- bool m_corners_ready;
+ private:
+ bool m_corners_ready;
-public:
- PlaneCornerPinWarpImageOperation();
+ public:
+ PlaneCornerPinWarpImageOperation();
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
index c7f60d0dac2..ef7dfbd4116 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.cpp
@@ -35,200 +35,196 @@ extern "C" {
BLI_INLINE void warpCoord(float x, float y, float matrix[3][3], float uv[2], float deriv[2][2])
{
- float vec[3] = {x, y, 1.0f};
- mul_m3_v3(matrix, vec);
- uv[0] = vec[0] / vec[2];
- uv[1] = vec[1] / vec[2];
-
- deriv[0][0] = (matrix[0][0] - matrix[0][2] * uv[0]) / vec[2];
- deriv[1][0] = (matrix[0][1] - matrix[0][2] * uv[1]) / vec[2];
- deriv[0][1] = (matrix[1][0] - matrix[1][2] * uv[0]) / vec[2];
- deriv[1][1] = (matrix[1][1] - matrix[1][2] * uv[1]) / vec[2];
+ float vec[3] = {x, y, 1.0f};
+ mul_m3_v3(matrix, vec);
+ uv[0] = vec[0] / vec[2];
+ uv[1] = vec[1] / vec[2];
+
+ deriv[0][0] = (matrix[0][0] - matrix[0][2] * uv[0]) / vec[2];
+ deriv[1][0] = (matrix[0][1] - matrix[0][2] * uv[1]) / vec[2];
+ deriv[0][1] = (matrix[1][0] - matrix[1][2] * uv[0]) / vec[2];
+ deriv[1][1] = (matrix[1][1] - matrix[1][2] * uv[1]) / vec[2];
}
-PlaneDistortWarpImageOperation::PlaneDistortWarpImageOperation() :
- NodeOperation()
+PlaneDistortWarpImageOperation::PlaneDistortWarpImageOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_pixelReader = NULL;
- this->m_motion_blur_samples = 1;
- this->m_motion_blur_shutter = 0.5f;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_pixelReader = NULL;
+ this->m_motion_blur_samples = 1;
+ this->m_motion_blur_shutter = 0.5f;
+ this->setComplex(true);
}
void PlaneDistortWarpImageOperation::calculateCorners(const float corners[4][2],
bool normalized,
int sample)
{
- BLI_assert(sample < this->m_motion_blur_samples);
- const int width = this->m_pixelReader->getWidth();
- const int height = this->m_pixelReader->getHeight();
- float frame_corners[4][2] = {{0.0f, 0.0f},
- {(float) width, 0.0f},
- {(float) width, (float) height},
- {0.0f, (float) height}};
- MotionSample *sample_data = &this->m_samples[sample];
- if (normalized) {
- for (int i = 0; i < 4; i++) {
- sample_data->frameSpaceCorners[i][0] = corners[i][0] * this->getWidth();
- sample_data->frameSpaceCorners[i][1] = corners[i][1] * this->getHeight();
- }
- }
- else {
- for (int i = 0; i < 4; i++) {
- sample_data->frameSpaceCorners[i][0] = corners[i][0];
- sample_data->frameSpaceCorners[i][1] = corners[i][1];
- }
- }
- BKE_tracking_homography_between_two_quads(sample_data->frameSpaceCorners,
- frame_corners,
- sample_data->perspectiveMatrix);
+ BLI_assert(sample < this->m_motion_blur_samples);
+ const int width = this->m_pixelReader->getWidth();
+ const int height = this->m_pixelReader->getHeight();
+ float frame_corners[4][2] = {
+ {0.0f, 0.0f}, {(float)width, 0.0f}, {(float)width, (float)height}, {0.0f, (float)height}};
+ MotionSample *sample_data = &this->m_samples[sample];
+ if (normalized) {
+ for (int i = 0; i < 4; i++) {
+ sample_data->frameSpaceCorners[i][0] = corners[i][0] * this->getWidth();
+ sample_data->frameSpaceCorners[i][1] = corners[i][1] * this->getHeight();
+ }
+ }
+ else {
+ for (int i = 0; i < 4; i++) {
+ sample_data->frameSpaceCorners[i][0] = corners[i][0];
+ sample_data->frameSpaceCorners[i][1] = corners[i][1];
+ }
+ }
+ BKE_tracking_homography_between_two_quads(
+ sample_data->frameSpaceCorners, frame_corners, sample_data->perspectiveMatrix);
}
void PlaneDistortWarpImageOperation::initExecution()
{
- this->m_pixelReader = this->getInputSocketReader(0);
+ this->m_pixelReader = this->getInputSocketReader(0);
}
void PlaneDistortWarpImageOperation::deinitExecution()
{
- this->m_pixelReader = NULL;
+ this->m_pixelReader = NULL;
}
-void PlaneDistortWarpImageOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void PlaneDistortWarpImageOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- float uv[2];
- float deriv[2][2];
- if (this->m_motion_blur_samples == 1) {
- warpCoord(x, y, this->m_samples[0].perspectiveMatrix, uv, deriv);
- m_pixelReader->readFiltered(output,
- uv[0], uv[1],
- deriv[0], deriv[1]);
- }
- else {
- zero_v4(output);
- for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
- float color[4];
- warpCoord(x, y, this->m_samples[sample].perspectiveMatrix, uv, deriv);
- m_pixelReader->readFiltered(color,
- uv[0], uv[1],
- deriv[0], deriv[1]);
- add_v4_v4(output, color);
- }
- mul_v4_fl(output, 1.0f / (float)this->m_motion_blur_samples);
- }
+ float uv[2];
+ float deriv[2][2];
+ if (this->m_motion_blur_samples == 1) {
+ warpCoord(x, y, this->m_samples[0].perspectiveMatrix, uv, deriv);
+ m_pixelReader->readFiltered(output, uv[0], uv[1], deriv[0], deriv[1]);
+ }
+ else {
+ zero_v4(output);
+ for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
+ float color[4];
+ warpCoord(x, y, this->m_samples[sample].perspectiveMatrix, uv, deriv);
+ m_pixelReader->readFiltered(color, uv[0], uv[1], deriv[0], deriv[1]);
+ add_v4_v4(output, color);
+ }
+ mul_v4_fl(output, 1.0f / (float)this->m_motion_blur_samples);
+ }
}
-bool PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool PlaneDistortWarpImageOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- float min[2], max[2];
- INIT_MINMAX2(min, max);
-
- for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
- float UVs[4][2];
- float deriv[2][2];
- MotionSample *sample_data = &this->m_samples[sample];
- /* TODO(sergey): figure out proper way to do this. */
- warpCoord(input->xmin - 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[0], deriv);
- warpCoord(input->xmax + 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[1], deriv);
- warpCoord(input->xmax + 2, input->ymax + 2, sample_data->perspectiveMatrix, UVs[2], deriv);
- warpCoord(input->xmin - 2, input->ymax + 2, sample_data->perspectiveMatrix, UVs[3], deriv);
- for (int i = 0; i < 4; i++) {
- minmax_v2v2_v2(min, max, UVs[i]);
- }
- }
-
- rcti newInput;
-
- newInput.xmin = min[0] - 1;
- newInput.ymin = min[1] - 1;
- newInput.xmax = max[0] + 1;
- newInput.ymax = max[1] + 1;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ float min[2], max[2];
+ INIT_MINMAX2(min, max);
+
+ for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
+ float UVs[4][2];
+ float deriv[2][2];
+ MotionSample *sample_data = &this->m_samples[sample];
+ /* TODO(sergey): figure out proper way to do this. */
+ warpCoord(input->xmin - 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[0], deriv);
+ warpCoord(input->xmax + 2, input->ymin - 2, sample_data->perspectiveMatrix, UVs[1], deriv);
+ warpCoord(input->xmax + 2, input->ymax + 2, sample_data->perspectiveMatrix, UVs[2], deriv);
+ warpCoord(input->xmin - 2, input->ymax + 2, sample_data->perspectiveMatrix, UVs[3], deriv);
+ for (int i = 0; i < 4; i++) {
+ minmax_v2v2_v2(min, max, UVs[i]);
+ }
+ }
+
+ rcti newInput;
+
+ newInput.xmin = min[0] - 1;
+ newInput.ymin = min[1] - 1;
+ newInput.xmax = max[0] + 1;
+ newInput.ymax = max[1] + 1;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-
/* ******** PlaneDistort Mask ******** */
-PlaneDistortMaskOperation::PlaneDistortMaskOperation() :
- NodeOperation()
+PlaneDistortMaskOperation::PlaneDistortMaskOperation() : NodeOperation()
{
- addOutputSocket(COM_DT_VALUE);
+ addOutputSocket(COM_DT_VALUE);
- /* Currently hardcoded to 8 samples. */
- m_osa = 8;
- this->m_motion_blur_samples = 1;
- this->m_motion_blur_shutter = 0.5f;
+ /* Currently hardcoded to 8 samples. */
+ m_osa = 8;
+ this->m_motion_blur_samples = 1;
+ this->m_motion_blur_shutter = 0.5f;
}
void PlaneDistortMaskOperation::calculateCorners(const float corners[4][2],
bool normalized,
int sample)
{
- BLI_assert(sample < this->m_motion_blur_samples);
- MotionSample *sample_data = &this->m_samples[sample];
- if (normalized) {
- for (int i = 0; i < 4; i++) {
- sample_data->frameSpaceCorners[i][0] = corners[i][0] * this->getWidth();
- sample_data->frameSpaceCorners[i][1] = corners[i][1] * this->getHeight();
- }
- }
- else {
- for (int i = 0; i < 4; i++) {
- sample_data->frameSpaceCorners[i][0] = corners[i][0];
- sample_data->frameSpaceCorners[i][1] = corners[i][1];
- }
- }
+ BLI_assert(sample < this->m_motion_blur_samples);
+ MotionSample *sample_data = &this->m_samples[sample];
+ if (normalized) {
+ for (int i = 0; i < 4; i++) {
+ sample_data->frameSpaceCorners[i][0] = corners[i][0] * this->getWidth();
+ sample_data->frameSpaceCorners[i][1] = corners[i][1] * this->getHeight();
+ }
+ }
+ else {
+ for (int i = 0; i < 4; i++) {
+ sample_data->frameSpaceCorners[i][0] = corners[i][0];
+ sample_data->frameSpaceCorners[i][1] = corners[i][1];
+ }
+ }
}
void PlaneDistortMaskOperation::initExecution()
{
- BLI_jitter_init(m_jitter, m_osa);
+ BLI_jitter_init(m_jitter, m_osa);
}
-void PlaneDistortMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void PlaneDistortMaskOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- float point[2];
- int inside_counter = 0;
- if (this->m_motion_blur_samples == 1) {
- MotionSample *sample_data = &this->m_samples[0];
- for (int sample = 0; sample < this->m_osa; sample++) {
- point[0] = x + this->m_jitter[sample][0];
- point[1] = y + this->m_jitter[sample][1];
- if (isect_point_tri_v2(point, sample_data->frameSpaceCorners[0],
- sample_data->frameSpaceCorners[1],
- sample_data->frameSpaceCorners[2]) ||
- isect_point_tri_v2(point, sample_data->frameSpaceCorners[0],
- sample_data->frameSpaceCorners[2],
- sample_data->frameSpaceCorners[3]))
- {
- inside_counter++;
- }
- }
- output[0] = (float)inside_counter / this->m_osa;
- }
- else {
- for (int motion_sample = 0;
- motion_sample < this->m_motion_blur_samples;
- ++motion_sample)
- {
- MotionSample *sample_data = &this->m_samples[motion_sample];
- for (int osa_sample = 0; osa_sample < this->m_osa; ++osa_sample) {
- point[0] = x + this->m_jitter[osa_sample][0];
- point[1] = y + this->m_jitter[osa_sample][1];
- if (isect_point_tri_v2(point, sample_data->frameSpaceCorners[0],
- sample_data->frameSpaceCorners[1],
- sample_data->frameSpaceCorners[2]) ||
- isect_point_tri_v2(point, sample_data->frameSpaceCorners[0],
- sample_data->frameSpaceCorners[2],
- sample_data->frameSpaceCorners[3]))
- {
- inside_counter++;
- }
- }
- }
- output[0] = (float)inside_counter / (this->m_osa * this->m_motion_blur_samples);
- }
+ float point[2];
+ int inside_counter = 0;
+ if (this->m_motion_blur_samples == 1) {
+ MotionSample *sample_data = &this->m_samples[0];
+ for (int sample = 0; sample < this->m_osa; sample++) {
+ point[0] = x + this->m_jitter[sample][0];
+ point[1] = y + this->m_jitter[sample][1];
+ if (isect_point_tri_v2(point,
+ sample_data->frameSpaceCorners[0],
+ sample_data->frameSpaceCorners[1],
+ sample_data->frameSpaceCorners[2]) ||
+ isect_point_tri_v2(point,
+ sample_data->frameSpaceCorners[0],
+ sample_data->frameSpaceCorners[2],
+ sample_data->frameSpaceCorners[3])) {
+ inside_counter++;
+ }
+ }
+ output[0] = (float)inside_counter / this->m_osa;
+ }
+ else {
+ for (int motion_sample = 0; motion_sample < this->m_motion_blur_samples; ++motion_sample) {
+ MotionSample *sample_data = &this->m_samples[motion_sample];
+ for (int osa_sample = 0; osa_sample < this->m_osa; ++osa_sample) {
+ point[0] = x + this->m_jitter[osa_sample][0];
+ point[1] = y + this->m_jitter[osa_sample][1];
+ if (isect_point_tri_v2(point,
+ sample_data->frameSpaceCorners[0],
+ sample_data->frameSpaceCorners[1],
+ sample_data->frameSpaceCorners[2]) ||
+ isect_point_tri_v2(point,
+ sample_data->frameSpaceCorners[0],
+ sample_data->frameSpaceCorners[2],
+ sample_data->frameSpaceCorners[3])) {
+ inside_counter++;
+ }
+ }
+ }
+ output[0] = (float)inside_counter / (this->m_osa * this->m_motion_blur_samples);
+ }
}
diff --git a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
index 216f4ed969d..35e7745cb5d 100644
--- a/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneDistortCommonOperation.h
@@ -32,69 +32,70 @@
#define PLANE_DISTORT_MAX_SAMPLES 64
class PlaneDistortWarpImageOperation : public NodeOperation {
-protected:
- struct MotionSample {
- float frameSpaceCorners[4][2]; /* Corners coordinates in pixel space. */
- float perspectiveMatrix[3][3];
- };
- SocketReader *m_pixelReader;
- MotionSample m_samples[PLANE_DISTORT_MAX_SAMPLES];
- int m_motion_blur_samples;
- float m_motion_blur_shutter;
-
-public:
- PlaneDistortWarpImageOperation();
-
- void calculateCorners(const float corners[4][2],
- bool normalized,
- int sample);
-
- void initExecution();
- void deinitExecution();
-
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void setMotionBlurSamples(int samples) {
- BLI_assert(samples <= PLANE_DISTORT_MAX_SAMPLES);
- this->m_motion_blur_samples = samples;
- }
- void setMotionBlurShutter(float shutter) {
- this->m_motion_blur_shutter = shutter;
- }
+ protected:
+ struct MotionSample {
+ float frameSpaceCorners[4][2]; /* Corners coordinates in pixel space. */
+ float perspectiveMatrix[3][3];
+ };
+ SocketReader *m_pixelReader;
+ MotionSample m_samples[PLANE_DISTORT_MAX_SAMPLES];
+ int m_motion_blur_samples;
+ float m_motion_blur_shutter;
+
+ public:
+ PlaneDistortWarpImageOperation();
+
+ void calculateCorners(const float corners[4][2], bool normalized, int sample);
+
+ void initExecution();
+ void deinitExecution();
+
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void setMotionBlurSamples(int samples)
+ {
+ BLI_assert(samples <= PLANE_DISTORT_MAX_SAMPLES);
+ this->m_motion_blur_samples = samples;
+ }
+ void setMotionBlurShutter(float shutter)
+ {
+ this->m_motion_blur_shutter = shutter;
+ }
};
-
class PlaneDistortMaskOperation : public NodeOperation {
-protected:
- struct MotionSample {
- float frameSpaceCorners[4][2]; /* Corners coordinates in pixel space. */
- };
- int m_osa;
- MotionSample m_samples[PLANE_DISTORT_MAX_SAMPLES];
- float m_jitter[32][2];
- int m_motion_blur_samples;
- float m_motion_blur_shutter;
-
-public:
- PlaneDistortMaskOperation();
-
- void calculateCorners(const float corners[4][2],
- bool normalized,
- int sample);
-
- void initExecution();
-
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void setMotionBlurSamples(int samples) {
- BLI_assert(samples <= PLANE_DISTORT_MAX_SAMPLES);
- this->m_motion_blur_samples = samples;
- }
- void setMotionBlurShutter(float shutter) {
- this->m_motion_blur_shutter = shutter;
- }
+ protected:
+ struct MotionSample {
+ float frameSpaceCorners[4][2]; /* Corners coordinates in pixel space. */
+ };
+ int m_osa;
+ MotionSample m_samples[PLANE_DISTORT_MAX_SAMPLES];
+ float m_jitter[32][2];
+ int m_motion_blur_samples;
+ float m_motion_blur_shutter;
+
+ public:
+ PlaneDistortMaskOperation();
+
+ void calculateCorners(const float corners[4][2], bool normalized, int sample);
+
+ void initExecution();
+
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void setMotionBlurSamples(int samples)
+ {
+ BLI_assert(samples <= PLANE_DISTORT_MAX_SAMPLES);
+ this->m_motion_blur_samples = samples;
+ }
+ void setMotionBlurShutter(float shutter)
+ {
+ this->m_motion_blur_shutter = shutter;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
index b134bc9ef9e..76ecabb8c8b 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.cpp
@@ -26,103 +26,99 @@
#include "BLI_math_color.h"
extern "C" {
-# include "BKE_movieclip.h"
-# include "BKE_node.h"
-# include "BKE_tracking.h"
+#include "BKE_movieclip.h"
+#include "BKE_node.h"
+#include "BKE_tracking.h"
}
/* ******** PlaneTrackCommon ******** */
PlaneTrackCommon::PlaneTrackCommon()
{
- this->m_movieClip = NULL;
- this->m_framenumber = 0;
- this->m_trackingObjectName[0] = '\0';
- this->m_planeTrackName[0] = '\0';
+ this->m_movieClip = NULL;
+ this->m_framenumber = 0;
+ this->m_trackingObjectName[0] = '\0';
+ this->m_planeTrackName[0] = '\0';
}
void PlaneTrackCommon::readCornersFromTrack(float corners[4][2], float frame)
{
- MovieTracking *tracking;
- MovieTrackingObject *object;
-
- if (!this->m_movieClip)
- return;
-
- tracking = &this->m_movieClip->tracking;
-
- object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
- if (object) {
- MovieTrackingPlaneTrack *plane_track;
- plane_track = BKE_tracking_plane_track_get_named(tracking, object, this->m_planeTrackName);
- if (plane_track) {
- float clip_framenr =
- BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
- frame);
- BKE_tracking_plane_marker_get_subframe_corners(plane_track,
- clip_framenr,
- corners);
- }
- }
+ MovieTracking *tracking;
+ MovieTrackingObject *object;
+
+ if (!this->m_movieClip)
+ return;
+
+ tracking = &this->m_movieClip->tracking;
+
+ object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
+ if (object) {
+ MovieTrackingPlaneTrack *plane_track;
+ plane_track = BKE_tracking_plane_track_get_named(tracking, object, this->m_planeTrackName);
+ if (plane_track) {
+ float clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, frame);
+ BKE_tracking_plane_marker_get_subframe_corners(plane_track, clip_framenr, corners);
+ }
+ }
}
-void PlaneTrackCommon::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void PlaneTrackCommon::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- resolution[0] = 0;
- resolution[1] = 0;
-
- if (this->m_movieClip) {
- int width, height;
- MovieClipUser user = {0};
- BKE_movieclip_user_set_frame(&user, this->m_framenumber);
- BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
- resolution[0] = width;
- resolution[1] = height;
- }
+ resolution[0] = 0;
+ resolution[1] = 0;
+
+ if (this->m_movieClip) {
+ int width, height;
+ MovieClipUser user = {0};
+ BKE_movieclip_user_set_frame(&user, this->m_framenumber);
+ BKE_movieclip_get_size(this->m_movieClip, &user, &width, &height);
+ resolution[0] = width;
+ resolution[1] = height;
+ }
}
-
/* ******** PlaneTrackMaskOperation ******** */
void PlaneTrackMaskOperation::initExecution()
{
- PlaneDistortMaskOperation::initExecution();
- float corners[4][2];
- if (this->m_motion_blur_samples == 1) {
- readCornersFromTrack(corners, this->m_framenumber);
- calculateCorners(corners, true, 0);
- }
- else {
- const float frame = (float)this->m_framenumber - this->m_motion_blur_shutter;
- const float frame_step = (this->m_motion_blur_shutter * 2.0f) / this->m_motion_blur_samples;
- float frame_iter = frame;
- for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
- readCornersFromTrack(corners, frame_iter);
- calculateCorners(corners, true, sample);
- frame_iter += frame_step;
- }
- }
+ PlaneDistortMaskOperation::initExecution();
+ float corners[4][2];
+ if (this->m_motion_blur_samples == 1) {
+ readCornersFromTrack(corners, this->m_framenumber);
+ calculateCorners(corners, true, 0);
+ }
+ else {
+ const float frame = (float)this->m_framenumber - this->m_motion_blur_shutter;
+ const float frame_step = (this->m_motion_blur_shutter * 2.0f) / this->m_motion_blur_samples;
+ float frame_iter = frame;
+ for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
+ readCornersFromTrack(corners, frame_iter);
+ calculateCorners(corners, true, sample);
+ frame_iter += frame_step;
+ }
+ }
}
/* ******** PlaneTrackWarpImageOperation ******** */
void PlaneTrackWarpImageOperation::initExecution()
{
- PlaneDistortWarpImageOperation::initExecution();
- /* TODO(sergey): De-duplicate with mask operation. */
- float corners[4][2];
- if (this->m_motion_blur_samples == 1) {
- readCornersFromTrack(corners, this->m_framenumber);
- calculateCorners(corners, true, 0);
- }
- else {
- const float frame = (float)this->m_framenumber - this->m_motion_blur_shutter;
- const float frame_step = (this->m_motion_blur_shutter * 2.0f) / this->m_motion_blur_samples;
- float frame_iter = frame;
- for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
- readCornersFromTrack(corners, frame_iter);
- calculateCorners(corners, true, sample);
- frame_iter += frame_step;
- }
- }
+ PlaneDistortWarpImageOperation::initExecution();
+ /* TODO(sergey): De-duplicate with mask operation. */
+ float corners[4][2];
+ if (this->m_motion_blur_samples == 1) {
+ readCornersFromTrack(corners, this->m_framenumber);
+ calculateCorners(corners, true, 0);
+ }
+ else {
+ const float frame = (float)this->m_framenumber - this->m_motion_blur_shutter;
+ const float frame_step = (this->m_motion_blur_shutter * 2.0f) / this->m_motion_blur_samples;
+ float frame_iter = frame;
+ for (int sample = 0; sample < this->m_motion_blur_samples; ++sample) {
+ readCornersFromTrack(corners, frame_iter);
+ calculateCorners(corners, true, sample);
+ frame_iter += frame_step;
+ }
+ }
}
diff --git a/source/blender/compositor/operations/COM_PlaneTrackOperation.h b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
index 217f6dc92c1..875c8ce8fa0 100644
--- a/source/blender/compositor/operations/COM_PlaneTrackOperation.h
+++ b/source/blender/compositor/operations/COM_PlaneTrackOperation.h
@@ -30,62 +30,71 @@
#include "BLI_string.h"
class PlaneTrackCommon {
-protected:
- MovieClip *m_movieClip;
- int m_framenumber;
- char m_trackingObjectName[64];
- char m_planeTrackName[64];
-
- /* note: this class is not an operation itself (to prevent virtual inheritance issues)
- * implementation classes must make wrappers to use these methods, see below.
- */
- void readCornersFromTrack(float corners[4][2], float frame);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
-public:
- PlaneTrackCommon();
-
- void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
- void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); }
- void setPlaneTrackName(char *plane_track) { BLI_strncpy(this->m_planeTrackName, plane_track, sizeof(this->m_planeTrackName)); }
- void setFramenumber(int framenumber) { this->m_framenumber = framenumber; }
+ protected:
+ MovieClip *m_movieClip;
+ int m_framenumber;
+ char m_trackingObjectName[64];
+ char m_planeTrackName[64];
+
+ /* note: this class is not an operation itself (to prevent virtual inheritance issues)
+ * implementation classes must make wrappers to use these methods, see below.
+ */
+ void readCornersFromTrack(float corners[4][2], float frame);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ public:
+ PlaneTrackCommon();
+
+ void setMovieClip(MovieClip *clip)
+ {
+ this->m_movieClip = clip;
+ }
+ void setTrackingObject(char *object)
+ {
+ BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));
+ }
+ void setPlaneTrackName(char *plane_track)
+ {
+ BLI_strncpy(this->m_planeTrackName, plane_track, sizeof(this->m_planeTrackName));
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
};
-
class PlaneTrackMaskOperation : public PlaneDistortMaskOperation, public PlaneTrackCommon {
-public:
- PlaneTrackMaskOperation() :
- PlaneDistortMaskOperation(),
- PlaneTrackCommon()
- {}
+ public:
+ PlaneTrackMaskOperation() : PlaneDistortMaskOperation(), PlaneTrackCommon()
+ {
+ }
- void initExecution();
+ void initExecution();
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
- {
- PlaneTrackCommon::determineResolution(resolution, preferredResolution);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+ {
+ PlaneTrackCommon::determineResolution(resolution, preferredResolution);
- unsigned int temp[2];
- NodeOperation::determineResolution(temp, resolution);
- }
+ unsigned int temp[2];
+ NodeOperation::determineResolution(temp, resolution);
+ }
};
-
-class PlaneTrackWarpImageOperation : public PlaneDistortWarpImageOperation, public PlaneTrackCommon {
-public:
- PlaneTrackWarpImageOperation() :
- PlaneDistortWarpImageOperation(),
- PlaneTrackCommon()
- {}
-
- void initExecution();
-
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
- {
- PlaneTrackCommon::determineResolution(resolution, preferredResolution);
- unsigned int temp[2];
- NodeOperation::determineResolution(temp, resolution);
- }
+class PlaneTrackWarpImageOperation : public PlaneDistortWarpImageOperation,
+ public PlaneTrackCommon {
+ public:
+ PlaneTrackWarpImageOperation() : PlaneDistortWarpImageOperation(), PlaneTrackCommon()
+ {
+ }
+
+ void initExecution();
+
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+ {
+ PlaneTrackCommon::determineResolution(resolution, preferredResolution);
+ unsigned int temp[2];
+ NodeOperation::determineResolution(temp, resolution);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.cpp b/source/blender/compositor/operations/COM_PreviewOperation.cpp
index 22215131ce1..cd2bb3b2928 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.cpp
+++ b/source/blender/compositor/operations/COM_PreviewOperation.cpp
@@ -27,118 +27,123 @@
#include "COM_defines.h"
#include "BLI_math.h"
extern "C" {
-# include "MEM_guardedalloc.h"
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
-# include "IMB_colormanagement.h"
-# include "BKE_node.h"
+#include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
+#include "BKE_node.h"
}
-
-PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings) : NodeOperation()
+PreviewOperation::PreviewOperation(const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings)
+ : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->m_preview = NULL;
- this->m_outputBuffer = NULL;
- this->m_input = NULL;
- this->m_divider = 1.0f;
- this->m_viewSettings = viewSettings;
- this->m_displaySettings = displaySettings;
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->m_preview = NULL;
+ this->m_outputBuffer = NULL;
+ this->m_input = NULL;
+ this->m_divider = 1.0f;
+ this->m_viewSettings = viewSettings;
+ this->m_displaySettings = displaySettings;
}
void PreviewOperation::verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key)
{
- /* Size (0, 0) ensures the preview rect is not allocated in advance,
- * this is set later in initExecution once the resolution is determined.
- */
- this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, true);
+ /* Size (0, 0) ensures the preview rect is not allocated in advance,
+ * this is set later in initExecution once the resolution is determined.
+ */
+ this->m_preview = BKE_node_preview_verify(previews, key, 0, 0, true);
}
void PreviewOperation::initExecution()
{
- this->m_input = getInputSocketReader(0);
-
- if (this->getWidth() == (unsigned int)this->m_preview->xsize &&
- this->getHeight() == (unsigned int)this->m_preview->ysize)
- {
- this->m_outputBuffer = this->m_preview->rect;
- }
-
- if (this->m_outputBuffer == NULL) {
- this->m_outputBuffer = (unsigned char *)MEM_callocN(sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation");
- if (this->m_preview->rect) {
- MEM_freeN(this->m_preview->rect);
- }
- this->m_preview->xsize = getWidth();
- this->m_preview->ysize = getHeight();
- this->m_preview->rect = this->m_outputBuffer;
- }
+ this->m_input = getInputSocketReader(0);
+
+ if (this->getWidth() == (unsigned int)this->m_preview->xsize &&
+ this->getHeight() == (unsigned int)this->m_preview->ysize) {
+ this->m_outputBuffer = this->m_preview->rect;
+ }
+
+ if (this->m_outputBuffer == NULL) {
+ this->m_outputBuffer = (unsigned char *)MEM_callocN(
+ sizeof(unsigned char) * 4 * getWidth() * getHeight(), "PreviewOperation");
+ if (this->m_preview->rect) {
+ MEM_freeN(this->m_preview->rect);
+ }
+ this->m_preview->xsize = getWidth();
+ this->m_preview->ysize = getHeight();
+ this->m_preview->rect = this->m_outputBuffer;
+ }
}
void PreviewOperation::deinitExecution()
{
- this->m_outputBuffer = NULL;
- this->m_input = NULL;
+ this->m_outputBuffer = NULL;
+ this->m_input = NULL;
}
void PreviewOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- int offset;
- float color[4];
- struct ColormanageProcessor *cm_processor;
-
- cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings, this->m_displaySettings);
-
- for (int y = rect->ymin; y < rect->ymax; y++) {
- offset = (y * getWidth() + rect->xmin) * 4;
- for (int x = rect->xmin; x < rect->xmax; x++) {
- float rx = floor(x / this->m_divider);
- float ry = floor(y / this->m_divider);
-
- color[0] = 0.0f;
- color[1] = 0.0f;
- color[2] = 0.0f;
- color[3] = 1.0f;
- this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST);
- IMB_colormanagement_processor_apply_v4(cm_processor, color);
- rgba_float_to_uchar(this->m_outputBuffer + offset, color);
- offset += 4;
- }
- }
-
- IMB_colormanagement_processor_free(cm_processor);
+ int offset;
+ float color[4];
+ struct ColormanageProcessor *cm_processor;
+
+ cm_processor = IMB_colormanagement_display_processor_new(this->m_viewSettings,
+ this->m_displaySettings);
+
+ for (int y = rect->ymin; y < rect->ymax; y++) {
+ offset = (y * getWidth() + rect->xmin) * 4;
+ for (int x = rect->xmin; x < rect->xmax; x++) {
+ float rx = floor(x / this->m_divider);
+ float ry = floor(y / this->m_divider);
+
+ color[0] = 0.0f;
+ color[1] = 0.0f;
+ color[2] = 0.0f;
+ color[3] = 1.0f;
+ this->m_input->readSampled(color, rx, ry, COM_PS_NEAREST);
+ IMB_colormanagement_processor_apply_v4(cm_processor, color);
+ rgba_float_to_uchar(this->m_outputBuffer + offset, color);
+ offset += 4;
+ }
+ }
+
+ IMB_colormanagement_processor_free(cm_processor);
}
-bool PreviewOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool PreviewOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmin = input->xmin / this->m_divider;
- newInput.xmax = input->xmax / this->m_divider;
- newInput.ymin = input->ymin / this->m_divider;
- newInput.ymax = input->ymax / this->m_divider;
+ newInput.xmin = input->xmin / this->m_divider;
+ newInput.xmax = input->xmax / this->m_divider;
+ newInput.ymin = input->ymin / this->m_divider;
+ newInput.ymax = input->ymax / this->m_divider;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-void PreviewOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void PreviewOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- int width = resolution[0];
- int height = resolution[1];
- this->m_divider = 0.0f;
- if (width > height) {
- this->m_divider = COM_PREVIEW_SIZE / (width - 1);
- }
- else {
- this->m_divider = COM_PREVIEW_SIZE / (height - 1);
- }
- width = width * this->m_divider;
- height = height * this->m_divider;
-
- resolution[0] = width;
- resolution[1] = height;
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ int width = resolution[0];
+ int height = resolution[1];
+ this->m_divider = 0.0f;
+ if (width > height) {
+ this->m_divider = COM_PREVIEW_SIZE / (width - 1);
+ }
+ else {
+ this->m_divider = COM_PREVIEW_SIZE / (height - 1);
+ }
+ width = width * this->m_divider;
+ height = height * this->m_divider;
+
+ resolution[0] = width;
+ resolution[1] = height;
}
CompositorPriority PreviewOperation::getRenderPriority() const
{
- return COM_PRIORITY_LOW;
+ return COM_PRIORITY_LOW;
}
diff --git a/source/blender/compositor/operations/COM_PreviewOperation.h b/source/blender/compositor/operations/COM_PreviewOperation.h
index 76b03b09731..6560db727a8 100644
--- a/source/blender/compositor/operations/COM_PreviewOperation.h
+++ b/source/blender/compositor/operations/COM_PreviewOperation.h
@@ -25,31 +25,40 @@
#include "BKE_global.h"
class PreviewOperation : public NodeOperation {
-protected:
- unsigned char *m_outputBuffer;
+ protected:
+ unsigned char *m_outputBuffer;
- /**
- * \brief holds reference to the SDNA bNode, where this nodes will render the preview image for
- */
- bNodePreview *m_preview;
- SocketReader *m_input;
- float m_divider;
+ /**
+ * \brief holds reference to the SDNA bNode, where this nodes will render the preview image for
+ */
+ bNodePreview *m_preview;
+ SocketReader *m_input;
+ float m_divider;
- const ColorManagedViewSettings *m_viewSettings;
- const ColorManagedDisplaySettings *m_displaySettings;
-public:
- PreviewOperation(const ColorManagedViewSettings *viewSettings, const ColorManagedDisplaySettings *displaySettings);
- void verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key);
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
- bool isOutputOperation(bool /*rendering*/) const { return !G.background; }
- void initExecution();
- void deinitExecution();
- CompositorPriority getRenderPriority() const;
+ public:
+ PreviewOperation(const ColorManagedViewSettings *viewSettings,
+ const ColorManagedDisplaySettings *displaySettings);
+ void verifyPreview(bNodeInstanceHash *previews, bNodeInstanceKey key);
- void executeRegion(rcti *rect, unsigned int tileNumber);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- bool isPreviewOperation() const { return true; }
+ bool isOutputOperation(bool /*rendering*/) const
+ {
+ return !G.background;
+ }
+ void initExecution();
+ void deinitExecution();
+ CompositorPriority getRenderPriority() const;
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ bool isPreviewOperation() const
+ {
+ return true;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index fa02f0f3356..40299d33306 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -22,87 +22,91 @@
ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->m_inputProgram = NULL;
- this->m_dispersionAvailable = false;
- this->m_dispersion = 0.0f;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
+ this->m_dispersionAvailable = false;
+ this->m_dispersion = 0.0f;
}
void ProjectorLensDistortionOperation::initExecution()
{
- this->initMutex();
- this->m_inputProgram = this->getInputSocketReader(0);
+ this->initMutex();
+ this->m_inputProgram = this->getInputSocketReader(0);
}
void *ProjectorLensDistortionOperation::initializeTileData(rcti * /*rect*/)
{
- updateDispersion();
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
- return buffer;
+ updateDispersion();
+ void *buffer = this->m_inputProgram->initializeTileData(NULL);
+ return buffer;
}
void ProjectorLensDistortionOperation::executePixel(float output[4], int x, int y, void *data)
{
- float inputValue[4];
- const float height = this->getHeight();
- const float width = this->getWidth();
- const float v = (y + 0.5f) / height;
- const float u = (x + 0.5f) / width;
- MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
- inputBuffer->readBilinear(inputValue, (u * width + this->m_kr2) - 0.5f, v * height - 0.5f);
- output[0] = inputValue[0];
- inputBuffer->read(inputValue, x, y);
- output[1] = inputValue[1];
- inputBuffer->readBilinear(inputValue, (u * width - this->m_kr2) - 0.5f, v * height - 0.5f);
- output[2] = inputValue[2];
- output[3] = 1.0f;
+ float inputValue[4];
+ const float height = this->getHeight();
+ const float width = this->getWidth();
+ const float v = (y + 0.5f) / height;
+ const float u = (x + 0.5f) / width;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
+ inputBuffer->readBilinear(inputValue, (u * width + this->m_kr2) - 0.5f, v * height - 0.5f);
+ output[0] = inputValue[0];
+ inputBuffer->read(inputValue, x, y);
+ output[1] = inputValue[1];
+ inputBuffer->readBilinear(inputValue, (u * width - this->m_kr2) - 0.5f, v * height - 0.5f);
+ output[2] = inputValue[2];
+ output[3] = 1.0f;
}
void ProjectorLensDistortionOperation::deinitExecution()
{
- this->deinitMutex();
- this->m_inputProgram = NULL;
+ this->deinitMutex();
+ this->m_inputProgram = NULL;
}
-bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- if (this->m_dispersionAvailable) {
- newInput.ymax = input->ymax;
- newInput.ymin = input->ymin;
- newInput.xmin = input->xmin - this->m_kr2 - 2;
- newInput.xmax = input->xmax + this->m_kr2 + 2;
- }
- else {
- rcti dispInput;
- BLI_rcti_init(&dispInput, 0, 5, 0, 5);
- if (this->getInputOperation(1)->determineDependingAreaOfInterest(&dispInput, readOperation, output)) {
- return true;
- }
- newInput.xmin = input->xmin - 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */
- newInput.ymin = input->ymin;
- newInput.ymax = input->ymax;
- newInput.xmax = input->xmax + 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */
- }
- if (this->getInputOperation(0)->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
- return true;
- }
- return false;
+ rcti newInput;
+ if (this->m_dispersionAvailable) {
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ newInput.xmin = input->xmin - this->m_kr2 - 2;
+ newInput.xmax = input->xmax + this->m_kr2 + 2;
+ }
+ else {
+ rcti dispInput;
+ BLI_rcti_init(&dispInput, 0, 5, 0, 5);
+ if (this->getInputOperation(1)->determineDependingAreaOfInterest(
+ &dispInput, readOperation, output)) {
+ return true;
+ }
+ newInput.xmin = input->xmin - 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */
+ newInput.ymin = input->ymin;
+ newInput.ymax = input->ymax;
+ newInput.xmax = input->xmax + 7; /* (0.25f * 20 * 1) + 2 == worse case dispersion */
+ }
+ if (this->getInputOperation(0)->determineDependingAreaOfInterest(
+ &newInput, readOperation, output)) {
+ return true;
+ }
+ return false;
}
void ProjectorLensDistortionOperation::updateDispersion()
{
- if (this->m_dispersionAvailable) return;
- this->lockMutex();
- if (!this->m_dispersionAvailable) {
- float result[4];
- this->getInputSocketReader(1)->readSampled(result, 1, 1, COM_PS_NEAREST);
- this->m_dispersion = result[0];
- this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
- this->m_kr2 = this->m_kr * 20;
- this->m_dispersionAvailable = true;
- }
- this->unlockMutex();
+ if (this->m_dispersionAvailable)
+ return;
+ this->lockMutex();
+ if (!this->m_dispersionAvailable) {
+ float result[4];
+ this->getInputSocketReader(1)->readSampled(result, 1, 1, COM_PS_NEAREST);
+ this->m_dispersion = result[0];
+ this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f);
+ this->m_kr2 = this->m_kr * 20;
+ this->m_dispersionAvailable = true;
+ }
+ this->unlockMutex();
}
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
index b37bd2ab182..3574f40e3bb 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -22,38 +22,40 @@
#include "DNA_node_types.h"
class ProjectorLensDistortionOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
- float m_dispersion;
- bool m_dispersionAvailable;
+ float m_dispersion;
+ bool m_dispersionAvailable;
- float m_kr, m_kr2;
-public:
- ProjectorLensDistortionOperation();
+ float m_kr, m_kr2;
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ ProjectorLensDistortionOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void updateDispersion();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void updateDispersion();
};
#endif
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.cpp b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
index f7af97bb80a..3eb8d528f7a 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.cpp
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.cpp
@@ -20,47 +20,47 @@
QualityStepHelper::QualityStepHelper()
{
- this->m_quality = COM_QUALITY_HIGH;
- this->m_step = 1;
- this->m_offsetadd = 4;
+ this->m_quality = COM_QUALITY_HIGH;
+ this->m_step = 1;
+ this->m_offsetadd = 4;
}
void QualityStepHelper::initExecution(QualityHelper helper)
{
- switch (helper) {
- case COM_QH_INCREASE:
- switch (this->m_quality) {
- case COM_QUALITY_HIGH:
- default:
- this->m_step = 1;
- this->m_offsetadd = 1;
- break;
- case COM_QUALITY_MEDIUM:
- this->m_step = 2;
- this->m_offsetadd = 2;
- break;
- case COM_QUALITY_LOW:
- this->m_step = 3;
- this->m_offsetadd = 3;
- break;
- }
- break;
- case COM_QH_MULTIPLY:
- switch (this->m_quality) {
- case COM_QUALITY_HIGH:
- default:
- this->m_step = 1;
- this->m_offsetadd = 4;
- break;
- case COM_QUALITY_MEDIUM:
- this->m_step = 2;
- this->m_offsetadd = 8;
- break;
- case COM_QUALITY_LOW:
- this->m_step = 4;
- this->m_offsetadd = 16;
- break;
- }
- break;
- }
+ switch (helper) {
+ case COM_QH_INCREASE:
+ switch (this->m_quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->m_step = 1;
+ this->m_offsetadd = 1;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->m_step = 2;
+ this->m_offsetadd = 2;
+ break;
+ case COM_QUALITY_LOW:
+ this->m_step = 3;
+ this->m_offsetadd = 3;
+ break;
+ }
+ break;
+ case COM_QH_MULTIPLY:
+ switch (this->m_quality) {
+ case COM_QUALITY_HIGH:
+ default:
+ this->m_step = 1;
+ this->m_offsetadd = 4;
+ break;
+ case COM_QUALITY_MEDIUM:
+ this->m_step = 2;
+ this->m_offsetadd = 8;
+ break;
+ case COM_QUALITY_LOW:
+ this->m_step = 4;
+ this->m_offsetadd = 16;
+ break;
+ }
+ break;
+ }
}
diff --git a/source/blender/compositor/operations/COM_QualityStepHelper.h b/source/blender/compositor/operations/COM_QualityStepHelper.h
index 9cc971f1fe0..0814f5cdb4c 100644
--- a/source/blender/compositor/operations/COM_QualityStepHelper.h
+++ b/source/blender/compositor/operations/COM_QualityStepHelper.h
@@ -21,29 +21,37 @@
#include "COM_defines.h"
typedef enum QualityHelper {
- COM_QH_INCREASE,
- COM_QH_MULTIPLY,
+ COM_QH_INCREASE,
+ COM_QH_MULTIPLY,
} QualityHelper;
-class QualityStepHelper {
-private:
- CompositorQuality m_quality;
- int m_step;
- int m_offsetadd;
-
-protected:
- /**
- * Initialize the execution
- */
- void initExecution(QualityHelper helper);
-
- inline int getStep() const { return this->m_step; }
- inline int getOffsetAdd() const { return this->m_offsetadd; }
-
-public:
- QualityStepHelper();
-
-
- void setQuality(CompositorQuality quality) { this->m_quality = quality; }
+class QualityStepHelper {
+ private:
+ CompositorQuality m_quality;
+ int m_step;
+ int m_offsetadd;
+
+ protected:
+ /**
+ * Initialize the execution
+ */
+ void initExecution(QualityHelper helper);
+
+ inline int getStep() const
+ {
+ return this->m_step;
+ }
+ inline int getOffsetAdd() const
+ {
+ return this->m_offsetadd;
+ }
+
+ public:
+ QualityStepHelper();
+
+ void setQuality(CompositorQuality quality)
+ {
+ this->m_quality = quality;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
index 0901fe418f8..70aaab560cd 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.cpp
@@ -22,102 +22,112 @@
ReadBufferOperation::ReadBufferOperation(DataType datatype) : NodeOperation()
{
- this->addOutputSocket(datatype);
- this->m_single_value = false;
- this->m_offset = 0;
- this->m_buffer = NULL;
+ this->addOutputSocket(datatype);
+ this->m_single_value = false;
+ this->m_offset = 0;
+ this->m_buffer = NULL;
}
void *ReadBufferOperation::initializeTileData(rcti * /*rect*/)
{
- return m_buffer;
+ return m_buffer;
}
-void ReadBufferOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void ReadBufferOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- if (this->m_memoryProxy != NULL) {
- WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
- operation->determineResolution(resolution, preferredResolution);
- operation->setResolution(resolution);
+ if (this->m_memoryProxy != NULL) {
+ WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
+ operation->determineResolution(resolution, preferredResolution);
+ operation->setResolution(resolution);
- /// \todo: may not occur!, but does with blur node
- if (this->m_memoryProxy->getExecutor()) {
- this->m_memoryProxy->getExecutor()->setResolution(resolution);
- }
+ /// \todo: may not occur!, but does with blur node
+ if (this->m_memoryProxy->getExecutor()) {
+ this->m_memoryProxy->getExecutor()->setResolution(resolution);
+ }
- m_single_value = operation->isSingleValue();
- }
+ m_single_value = operation->isSingleValue();
+ }
}
-void ReadBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ReadBufferOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- if (m_single_value) {
- /* write buffer has a single value stored at (0,0) */
- m_buffer->read(output, 0, 0);
- }
- else {
- switch (sampler) {
- case COM_PS_NEAREST:
- m_buffer->read(output, x, y);
- break;
- case COM_PS_BILINEAR:
- default:
- m_buffer->readBilinear(output, x, y);
- break;
- case COM_PS_BICUBIC:
- m_buffer->readBilinear(output, x, y);
- break;
- }
- }
+ if (m_single_value) {
+ /* write buffer has a single value stored at (0,0) */
+ m_buffer->read(output, 0, 0);
+ }
+ else {
+ switch (sampler) {
+ case COM_PS_NEAREST:
+ m_buffer->read(output, x, y);
+ break;
+ case COM_PS_BILINEAR:
+ default:
+ m_buffer->readBilinear(output, x, y);
+ break;
+ case COM_PS_BICUBIC:
+ m_buffer->readBilinear(output, x, y);
+ break;
+ }
+ }
}
-void ReadBufferOperation::executePixelExtend(float output[4], float x, float y, PixelSampler sampler,
- MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
+void ReadBufferOperation::executePixelExtend(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler,
+ MemoryBufferExtend extend_x,
+ MemoryBufferExtend extend_y)
{
- if (m_single_value) {
- /* write buffer has a single value stored at (0,0) */
- m_buffer->read(output, 0, 0);
- }
- else if (sampler == COM_PS_NEAREST) {
- m_buffer->read(output, x, y, extend_x, extend_y);
- }
- else {
- m_buffer->readBilinear(output, x, y, extend_x, extend_y);
- }
+ if (m_single_value) {
+ /* write buffer has a single value stored at (0,0) */
+ m_buffer->read(output, 0, 0);
+ }
+ else if (sampler == COM_PS_NEAREST) {
+ m_buffer->read(output, x, y, extend_x, extend_y);
+ }
+ else {
+ m_buffer->readBilinear(output, x, y, extend_x, extend_y);
+ }
}
-void ReadBufferOperation::executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2])
+void ReadBufferOperation::executePixelFiltered(
+ float output[4], float x, float y, float dx[2], float dy[2])
{
- if (m_single_value) {
- /* write buffer has a single value stored at (0,0) */
- m_buffer->read(output, 0, 0);
- }
- else {
- const float uv[2] = { x, y };
- const float deriv[2][2] = { {dx[0], dx[1]}, {dy[0], dy[1]} };
- m_buffer->readEWA(output, uv, deriv);
- }
+ if (m_single_value) {
+ /* write buffer has a single value stored at (0,0) */
+ m_buffer->read(output, 0, 0);
+ }
+ else {
+ const float uv[2] = {x, y};
+ const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
+ m_buffer->readEWA(output, uv, deriv);
+ }
}
-bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ReadBufferOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- if (this == readOperation) {
- BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
- return true;
- }
- return false;
+ if (this == readOperation) {
+ BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
+ return true;
+ }
+ return false;
}
void ReadBufferOperation::readResolutionFromWriteBuffer()
{
- if (this->m_memoryProxy != NULL) {
- WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
- this->setWidth(operation->getWidth());
- this->setHeight(operation->getHeight());
- }
+ if (this->m_memoryProxy != NULL) {
+ WriteBufferOperation *operation = this->m_memoryProxy->getWriteBufferOperation();
+ this->setWidth(operation->getWidth());
+ this->setHeight(operation->getHeight());
+ }
}
void ReadBufferOperation::updateMemoryBuffer()
{
- this->m_buffer = this->getMemoryProxy()->getBuffer();
-
+ this->m_buffer = this->getMemoryProxy()->getBuffer();
}
diff --git a/source/blender/compositor/operations/COM_ReadBufferOperation.h b/source/blender/compositor/operations/COM_ReadBufferOperation.h
index cd15bb12b28..fee6555c3a9 100644
--- a/source/blender/compositor/operations/COM_ReadBufferOperation.h
+++ b/source/blender/compositor/operations/COM_ReadBufferOperation.h
@@ -24,29 +24,54 @@
#include "COM_MemoryBuffer.h"
class ReadBufferOperation : public NodeOperation {
-private:
- MemoryProxy *m_memoryProxy;
- bool m_single_value; /* single value stored in buffer, copied from associated write operation */
- unsigned int m_offset;
- MemoryBuffer *m_buffer;
-public:
- ReadBufferOperation(DataType datetype);
- void setMemoryProxy(MemoryProxy *memoryProxy) { this->m_memoryProxy = memoryProxy; }
- MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ private:
+ MemoryProxy *m_memoryProxy;
+ bool m_single_value; /* single value stored in buffer, copied from associated write operation */
+ unsigned int m_offset;
+ MemoryBuffer *m_buffer;
- void *initializeTileData(rcti *rect);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void executePixelExtend(float output[4], float x, float y, PixelSampler sampler,
- MemoryBufferExtend extend_x, MemoryBufferExtend extend_y);
- void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]);
- bool isReadBufferOperation() const { return true; }
- void setOffset(unsigned int offset) { this->m_offset = offset; }
- unsigned int getOffset() const { return this->m_offset; }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers) { return memoryBuffers[this->m_offset]; }
- void readResolutionFromWriteBuffer();
- void updateMemoryBuffer();
+ public:
+ ReadBufferOperation(DataType datetype);
+ void setMemoryProxy(MemoryProxy *memoryProxy)
+ {
+ this->m_memoryProxy = memoryProxy;
+ }
+ MemoryProxy *getMemoryProxy()
+ {
+ return this->m_memoryProxy;
+ }
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ void *initializeTileData(rcti *rect);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelExtend(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler,
+ MemoryBufferExtend extend_x,
+ MemoryBufferExtend extend_y);
+ void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]);
+ bool isReadBufferOperation() const
+ {
+ return true;
+ }
+ void setOffset(unsigned int offset)
+ {
+ this->m_offset = offset;
+ }
+ unsigned int getOffset() const
+ {
+ return this->m_offset;
+ }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ MemoryBuffer *getInputMemoryBuffer(MemoryBuffer **memoryBuffers)
+ {
+ return memoryBuffers[this->m_offset];
+ }
+ void readResolutionFromWriteBuffer();
+ void updateMemoryBuffer();
};
#endif
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
index 060cf7ae91e..0ebb60cff18 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp
@@ -23,223 +23,236 @@
#include "DNA_scene_types.h"
extern "C" {
-# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
-# include "RE_render_ext.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
}
/* ******** Render Layers Base Prog ******** */
-RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elementsize) : NodeOperation(), m_passName(passName)
+RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elementsize)
+ : NodeOperation(), m_passName(passName)
{
- this->setScene(NULL);
- this->m_inputBuffer = NULL;
- this->m_elementsize = elementsize;
- this->m_rd = NULL;
+ this->setScene(NULL);
+ this->m_inputBuffer = NULL;
+ this->m_elementsize = elementsize;
+ this->m_rd = NULL;
- this->addOutputSocket(type);
+ this->addOutputSocket(type);
}
-
void RenderLayersProg::initExecution()
{
- Scene *scene = this->getScene();
- Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
- RenderResult *rr = NULL;
-
- if (re)
- rr = RE_AcquireResultRead(re);
-
- if (rr) {
- ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
- if (view_layer) {
-
- RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
- if (rl) {
- this->m_inputBuffer = RE_RenderLayerGetPass(rl, this->m_passName.c_str(), this->m_viewName);
- }
- }
- }
- if (re) {
- RE_ReleaseResult(re);
- re = NULL;
- }
+ Scene *scene = this->getScene();
+ Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
+ RenderResult *rr = NULL;
+
+ if (re)
+ rr = RE_AcquireResultRead(re);
+
+ if (rr) {
+ ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
+ if (view_layer) {
+
+ RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
+ if (rl) {
+ this->m_inputBuffer = RE_RenderLayerGetPass(
+ rl, this->m_passName.c_str(), this->m_viewName);
+ }
+ }
+ }
+ if (re) {
+ RE_ReleaseResult(re);
+ re = NULL;
+ }
}
void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
{
- unsigned int offset;
- int width = this->getWidth(), height = this->getHeight();
-
- int ix = x, iy = y;
- if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
- if (this->m_elementsize == 1)
- output[0] = 0.0f;
- else if (this->m_elementsize == 3)
- zero_v3(output);
- else
- zero_v4(output);
- return;
- }
-
- switch (sampler) {
- case COM_PS_NEAREST: {
- offset = (iy * width + ix) * this->m_elementsize;
-
- if (this->m_elementsize == 1)
- output[0] = this->m_inputBuffer[offset];
- else if (this->m_elementsize == 3)
- copy_v3_v3(output, &this->m_inputBuffer[offset]);
- else
- copy_v4_v4(output, &this->m_inputBuffer[offset]);
- break;
- }
-
- case COM_PS_BILINEAR:
- BLI_bilinear_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
- break;
-
- case COM_PS_BICUBIC:
- BLI_bicubic_interpolation_fl(this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
- break;
- }
+ unsigned int offset;
+ int width = this->getWidth(), height = this->getHeight();
+
+ int ix = x, iy = y;
+ if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
+ if (this->m_elementsize == 1)
+ output[0] = 0.0f;
+ else if (this->m_elementsize == 3)
+ zero_v3(output);
+ else
+ zero_v4(output);
+ return;
+ }
+
+ switch (sampler) {
+ case COM_PS_NEAREST: {
+ offset = (iy * width + ix) * this->m_elementsize;
+
+ if (this->m_elementsize == 1)
+ output[0] = this->m_inputBuffer[offset];
+ else if (this->m_elementsize == 3)
+ copy_v3_v3(output, &this->m_inputBuffer[offset]);
+ else
+ copy_v4_v4(output, &this->m_inputBuffer[offset]);
+ break;
+ }
+
+ case COM_PS_BILINEAR:
+ BLI_bilinear_interpolation_fl(
+ this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+ break;
+
+ case COM_PS_BICUBIC:
+ BLI_bicubic_interpolation_fl(
+ this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
+ break;
+ }
}
void RenderLayersProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
#if 0
- const RenderData *rd = this->m_rd;
+ const RenderData *rd = this->m_rd;
- int dx = 0, dy = 0;
+ int dx = 0, dy = 0;
- if (rd->mode & R_BORDER && rd->mode & R_CROP) {
- /* see comment in executeRegion describing coordinate mapping,
- * here it simply goes other way around
- */
- int full_width = rd->xsch * rd->size / 100;
- int full_height = rd->ysch * rd->size / 100;
+ if (rd->mode & R_BORDER && rd->mode & R_CROP) {
+ /* see comment in executeRegion describing coordinate mapping,
+ * here it simply goes other way around
+ */
+ int full_width = rd->xsch * rd->size / 100;
+ int full_height = rd->ysch * rd->size / 100;
- dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
- dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
- }
+ dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
+ dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
+ }
- int ix = x - dx;
- int iy = y - dy;
+ int ix = x - dx;
+ int iy = y - dy;
#endif
#ifndef NDEBUG
- {
- const DataType data_type = this->getOutputSocket()->getDataType();
- int actual_element_size = this->m_elementsize;
- int expected_element_size;
- if (data_type == COM_DT_VALUE) {
- expected_element_size = 1;
- }
- else if (data_type == COM_DT_VECTOR) {
- expected_element_size = 3;
- }
- else if (data_type == COM_DT_COLOR) {
- expected_element_size = 4;
- }
- else {
- expected_element_size = 0;
- BLI_assert(!"Something horribly wrong just happened");
- }
- BLI_assert(expected_element_size == actual_element_size);
- }
+ {
+ const DataType data_type = this->getOutputSocket()->getDataType();
+ int actual_element_size = this->m_elementsize;
+ int expected_element_size;
+ if (data_type == COM_DT_VALUE) {
+ expected_element_size = 1;
+ }
+ else if (data_type == COM_DT_VECTOR) {
+ expected_element_size = 3;
+ }
+ else if (data_type == COM_DT_COLOR) {
+ expected_element_size = 4;
+ }
+ else {
+ expected_element_size = 0;
+ BLI_assert(!"Something horribly wrong just happened");
+ }
+ BLI_assert(expected_element_size == actual_element_size);
+ }
#endif
- if (this->m_inputBuffer == NULL) {
- int elemsize = this->m_elementsize;
- if (elemsize == 1) {
- output[0] = 0.0f;
- }
- else if (elemsize == 3) {
- zero_v3(output);
- }
- else {
- BLI_assert(elemsize == 4);
- zero_v4(output);
- }
- }
- else {
- doInterpolation(output, x, y, sampler);
- }
+ if (this->m_inputBuffer == NULL) {
+ int elemsize = this->m_elementsize;
+ if (elemsize == 1) {
+ output[0] = 0.0f;
+ }
+ else if (elemsize == 3) {
+ zero_v3(output);
+ }
+ else {
+ BLI_assert(elemsize == 4);
+ zero_v4(output);
+ }
+ }
+ else {
+ doInterpolation(output, x, y, sampler);
+ }
}
void RenderLayersProg::deinitExecution()
{
- this->m_inputBuffer = NULL;
+ this->m_inputBuffer = NULL;
}
-void RenderLayersProg::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void RenderLayersProg::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- Scene *sce = this->getScene();
- Render *re = (sce) ? RE_GetSceneRender(sce) : NULL;
- RenderResult *rr = NULL;
-
- resolution[0] = 0;
- resolution[1] = 0;
-
- if (re)
- rr = RE_AcquireResultRead(re);
-
- if (rr) {
- ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
- if (view_layer) {
- RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
- if (rl) {
- resolution[0] = rl->rectx;
- resolution[1] = rl->recty;
- }
- }
- }
-
- if (re)
- RE_ReleaseResult(re);
-
+ Scene *sce = this->getScene();
+ Render *re = (sce) ? RE_GetSceneRender(sce) : NULL;
+ RenderResult *rr = NULL;
+
+ resolution[0] = 0;
+ resolution[1] = 0;
+
+ if (re)
+ rr = RE_AcquireResultRead(re);
+
+ if (rr) {
+ ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
+ if (view_layer) {
+ RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
+ if (rl) {
+ resolution[0] = rl->rectx;
+ resolution[1] = rl->recty;
+ }
+ }
+ }
+
+ if (re)
+ RE_ReleaseResult(re);
}
/* ******** Render Layers AO Operation ******** */
-void RenderLayersAOOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void RenderLayersAOOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float *inputBuffer = this->getInputBuffer();
- if (inputBuffer == NULL) {
- zero_v3(output);
- }
- else {
- doInterpolation(output, x, y, sampler);
- }
- output[3] = 1.0f;
+ float *inputBuffer = this->getInputBuffer();
+ if (inputBuffer == NULL) {
+ zero_v3(output);
+ }
+ else {
+ doInterpolation(output, x, y, sampler);
+ }
+ output[3] = 1.0f;
}
/* ******** Render Layers Alpha Operation ******** */
-void RenderLayersAlphaProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void RenderLayersAlphaProg::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float *inputBuffer = this->getInputBuffer();
-
- if (inputBuffer == NULL) {
- output[0] = 0.0f;
- }
- else {
- float temp[4];
- doInterpolation(temp, x, y, sampler);
- output[0] = temp[3];
- }
+ float *inputBuffer = this->getInputBuffer();
+
+ if (inputBuffer == NULL) {
+ output[0] = 0.0f;
+ }
+ else {
+ float temp[4];
+ doInterpolation(temp, x, y, sampler);
+ output[0] = temp[3];
+ }
}
/* ******** Render Layers Depth Operation ******** */
-void RenderLayersDepthProg::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void RenderLayersDepthProg::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- int ix = x;
- int iy = y;
- float *inputBuffer = this->getInputBuffer();
-
- if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() || iy >= (int)this->getHeight() ) {
- output[0] = 10e10f;
- }
- else {
- unsigned int offset = (iy * this->getWidth() + ix);
- output[0] = inputBuffer[offset];
- }
+ int ix = x;
+ int iy = y;
+ float *inputBuffer = this->getInputBuffer();
+
+ if (inputBuffer == NULL || ix < 0 || iy < 0 || ix >= (int)this->getWidth() ||
+ iy >= (int)this->getHeight()) {
+ output[0] = 10e10f;
+ }
+ else {
+ unsigned int offset = (iy * this->getWidth() + ix);
+ output[0] = inputBuffer[offset];
+ }
}
diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h
index bce3b40b353..5aa7e879760 100644
--- a/source/blender/compositor/operations/COM_RenderLayersProg.h
+++ b/source/blender/compositor/operations/COM_RenderLayersProg.h
@@ -16,7 +16,6 @@
* Copyright 2011, Blender Foundation.
*/
-
#ifndef __COM_RENDERLAYERSPROG_H__
#define __COM_RENDERLAYERSPROG_H__
@@ -25,8 +24,8 @@
#include "BLI_listbase.h"
#include "BKE_image.h"
extern "C" {
-# include "RE_pipeline.h"
-# include "MEM_guardedalloc.h"
+#include "RE_pipeline.h"
+#include "MEM_guardedalloc.h"
}
/**
@@ -35,91 +34,122 @@ extern "C" {
* \todo: rename to operation.
*/
class RenderLayersProg : public NodeOperation {
-protected:
- /**
- * Reference to the scene object.
- */
- Scene *m_scene;
-
- /**
- * layerId of the layer where this operation needs to get its data from
- */
- short m_layerId;
-
- /**
- * viewName of the view to use (unless another view is specified by the node
- */
- const char *m_viewName;
-
- /**
- * cached instance to the float buffer inside the layer
- */
- float *m_inputBuffer;
-
- /**
- * renderpass where this operation needs to get its data from
- */
- std::string m_passName;
-
- int m_elementsize;
-
- /**
- * \brief render data used for active rendering
- */
- const RenderData *m_rd;
-
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- /**
- * retrieve the reference to the float buffer of the renderer.
- */
- inline float *getInputBuffer() { return this->m_inputBuffer; }
-
- void doInterpolation(float output[4], float x, float y, PixelSampler sampler);
-public:
- /**
- * Constructor
- */
- RenderLayersProg(const char *passName, DataType type, int elementsize);
- /**
- * setter for the scene field. Will be called from
- * \see RenderLayerNode to set the actual scene where
- * the data will be retrieved from.
- */
- void setScene(Scene *scene) { this->m_scene = scene; }
- Scene *getScene() { return this->m_scene; }
- void setRenderData(const RenderData *rd) { this->m_rd = rd; }
- void setLayerId(short layerId) { this->m_layerId = layerId; }
- short getLayerId() { return this->m_layerId; }
- void setViewName(const char *viewName) { this->m_viewName = viewName; }
- const char *getViewName() { return this->m_viewName; }
- void initExecution();
- void deinitExecution();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ protected:
+ /**
+ * Reference to the scene object.
+ */
+ Scene *m_scene;
+
+ /**
+ * layerId of the layer where this operation needs to get its data from
+ */
+ short m_layerId;
+
+ /**
+ * viewName of the view to use (unless another view is specified by the node
+ */
+ const char *m_viewName;
+
+ /**
+ * cached instance to the float buffer inside the layer
+ */
+ float *m_inputBuffer;
+
+ /**
+ * renderpass where this operation needs to get its data from
+ */
+ std::string m_passName;
+
+ int m_elementsize;
+
+ /**
+ * \brief render data used for active rendering
+ */
+ const RenderData *m_rd;
+
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ /**
+ * retrieve the reference to the float buffer of the renderer.
+ */
+ inline float *getInputBuffer()
+ {
+ return this->m_inputBuffer;
+ }
+
+ void doInterpolation(float output[4], float x, float y, PixelSampler sampler);
+
+ public:
+ /**
+ * Constructor
+ */
+ RenderLayersProg(const char *passName, DataType type, int elementsize);
+ /**
+ * setter for the scene field. Will be called from
+ * \see RenderLayerNode to set the actual scene where
+ * the data will be retrieved from.
+ */
+ void setScene(Scene *scene)
+ {
+ this->m_scene = scene;
+ }
+ Scene *getScene()
+ {
+ return this->m_scene;
+ }
+ void setRenderData(const RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+ void setLayerId(short layerId)
+ {
+ this->m_layerId = layerId;
+ }
+ short getLayerId()
+ {
+ return this->m_layerId;
+ }
+ void setViewName(const char *viewName)
+ {
+ this->m_viewName = viewName;
+ }
+ const char *getViewName()
+ {
+ return this->m_viewName;
+ }
+ void initExecution();
+ void deinitExecution();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersAOOperation : public RenderLayersProg {
-public:
- RenderLayersAOOperation(const char *passName, DataType type, int elementsize)
- : RenderLayersProg(passName, type, elementsize) {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ RenderLayersAOOperation(const char *passName, DataType type, int elementsize)
+ : RenderLayersProg(passName, type, elementsize)
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersAlphaProg : public RenderLayersProg {
-public:
- RenderLayersAlphaProg(const char *passName, DataType type, int elementsize)
- : RenderLayersProg(passName, type, elementsize) {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ RenderLayersAlphaProg(const char *passName, DataType type, int elementsize)
+ : RenderLayersProg(passName, type, elementsize)
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class RenderLayersDepthProg : public RenderLayersProg {
-public:
- RenderLayersDepthProg(const char *passName, DataType type, int elementsize)
- : RenderLayersProg(passName, type, elementsize) {}
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ RenderLayersDepthProg(const char *passName, DataType type, int elementsize)
+ : RenderLayersProg(passName, type, elementsize)
+ {
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_RotateOperation.cpp b/source/blender/compositor/operations/COM_RotateOperation.cpp
index bc9fd46e8d7..3ccf36cec2c 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.cpp
+++ b/source/blender/compositor/operations/COM_RotateOperation.cpp
@@ -21,86 +21,87 @@
RotateOperation::RotateOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
- this->m_doDegree2RadConversion = false;
- this->m_isDegreeSet = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_imageSocket = NULL;
+ this->m_degreeSocket = NULL;
+ this->m_doDegree2RadConversion = false;
+ this->m_isDegreeSet = false;
}
void RotateOperation::initExecution()
{
- this->m_imageSocket = this->getInputSocketReader(0);
- this->m_degreeSocket = this->getInputSocketReader(1);
- this->m_centerX = (getWidth() - 1) / 2.0;
- this->m_centerY = (getHeight() - 1) / 2.0;
+ this->m_imageSocket = this->getInputSocketReader(0);
+ this->m_degreeSocket = this->getInputSocketReader(1);
+ this->m_centerX = (getWidth() - 1) / 2.0;
+ this->m_centerY = (getHeight() - 1) / 2.0;
}
void RotateOperation::deinitExecution()
{
- this->m_imageSocket = NULL;
- this->m_degreeSocket = NULL;
+ this->m_imageSocket = NULL;
+ this->m_degreeSocket = NULL;
}
inline void RotateOperation::ensureDegree()
{
- if (!this->m_isDegreeSet) {
- float degree[4];
- this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
- double rad;
- if (this->m_doDegree2RadConversion) {
- rad = DEG2RAD((double)degree[0]);
- }
- else {
- rad = degree[0];
- }
- this->m_cosine = cos(rad);
- this->m_sine = sin(rad);
+ if (!this->m_isDegreeSet) {
+ float degree[4];
+ this->m_degreeSocket->readSampled(degree, 0, 0, COM_PS_NEAREST);
+ double rad;
+ if (this->m_doDegree2RadConversion) {
+ rad = DEG2RAD((double)degree[0]);
+ }
+ else {
+ rad = degree[0];
+ }
+ this->m_cosine = cos(rad);
+ this->m_sine = sin(rad);
- this->m_isDegreeSet = true;
- }
+ this->m_isDegreeSet = true;
+ }
}
-
void RotateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- ensureDegree();
- const float dy = y - this->m_centerY;
- const float dx = x - this->m_centerX;
- const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
- const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
- this->m_imageSocket->readSampled(output, nx, ny, sampler);
+ ensureDegree();
+ const float dy = y - this->m_centerY;
+ const float dx = x - this->m_centerX;
+ const float nx = this->m_centerX + (this->m_cosine * dx + this->m_sine * dy);
+ const float ny = this->m_centerY + (-this->m_sine * dx + this->m_cosine * dy);
+ this->m_imageSocket->readSampled(output, nx, ny, sampler);
}
-bool RotateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool RotateOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- ensureDegree();
- rcti newInput;
+ ensureDegree();
+ rcti newInput;
- const float dxmin = input->xmin - this->m_centerX;
- const float dymin = input->ymin - this->m_centerY;
- const float dxmax = input->xmax - this->m_centerX;
- const float dymax = input->ymax - this->m_centerY;
+ const float dxmin = input->xmin - this->m_centerX;
+ const float dymin = input->ymin - this->m_centerY;
+ const float dxmax = input->xmax - this->m_centerX;
+ const float dymax = input->ymax - this->m_centerY;
- const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin);
- const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin);
- const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax);
- const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax);
- const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin);
- const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
- const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
- const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
- const float minx = min(x1, min(x2, min(x3, x4)));
- const float maxx = max(x1, max(x2, max(x3, x4)));
- const float miny = min(y1, min(y2, min(y3, y4)));
- const float maxy = max(y1, max(y2, max(y3, y4)));
+ const float x1 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymin);
+ const float x2 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymin);
+ const float x3 = this->m_centerX + (this->m_cosine * dxmin + this->m_sine * dymax);
+ const float x4 = this->m_centerX + (this->m_cosine * dxmax + this->m_sine * dymax);
+ const float y1 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymin);
+ const float y2 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymin);
+ const float y3 = this->m_centerY + (-this->m_sine * dxmin + this->m_cosine * dymax);
+ const float y4 = this->m_centerY + (-this->m_sine * dxmax + this->m_cosine * dymax);
+ const float minx = min(x1, min(x2, min(x3, x4)));
+ const float maxx = max(x1, max(x2, max(x3, x4)));
+ const float miny = min(y1, min(y2, min(y3, y4)));
+ const float maxy = max(y1, max(y2, max(y3, y4)));
- newInput.xmax = ceil(maxx) + 1;
- newInput.xmin = floor(minx) - 1;
- newInput.ymax = ceil(maxy) + 1;
- newInput.ymin = floor(miny) - 1;
+ newInput.xmax = ceil(maxx) + 1;
+ newInput.xmin = floor(minx) - 1;
+ newInput.ymax = ceil(maxy) + 1;
+ newInput.ymin = floor(miny) - 1;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_RotateOperation.h b/source/blender/compositor/operations/COM_RotateOperation.h
index 1ab8fbd87a1..46bdc68161e 100644
--- a/source/blender/compositor/operations/COM_RotateOperation.h
+++ b/source/blender/compositor/operations/COM_RotateOperation.h
@@ -22,24 +22,30 @@
#include "COM_NodeOperation.h"
class RotateOperation : public NodeOperation {
-private:
- SocketReader *m_imageSocket;
- SocketReader *m_degreeSocket;
- float m_centerX;
- float m_centerY;
- float m_cosine;
- float m_sine;
- bool m_doDegree2RadConversion;
- bool m_isDegreeSet;
-public:
- RotateOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
- void setDoDegree2RadConversion(bool abool) { this->m_doDegree2RadConversion = abool; }
+ private:
+ SocketReader *m_imageSocket;
+ SocketReader *m_degreeSocket;
+ float m_centerX;
+ float m_centerY;
+ float m_cosine;
+ float m_sine;
+ bool m_doDegree2RadConversion;
+ bool m_isDegreeSet;
- void ensureDegree();
+ public:
+ RotateOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void initExecution();
+ void deinitExecution();
+ void setDoDegree2RadConversion(bool abool)
+ {
+ this->m_doDegree2RadConversion = abool;
+ }
+
+ void ensureDegree();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 7c0c552c34d..3663d56dc87 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -28,275 +28,283 @@
BaseScaleOperation::BaseScaleOperation()
{
#ifdef USE_FORCE_BILINEAR
- m_sampler = (int) COM_PS_BILINEAR;
+ m_sampler = (int)COM_PS_BILINEAR;
#else
- m_sampler = -1;
+ m_sampler = -1;
#endif
- m_variable_size = false;
+ m_variable_size = false;
}
ScaleOperation::ScaleOperation() : BaseScaleOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
}
void ScaleOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputXOperation = this->getInputSocketReader(1);
- this->m_inputYOperation = this->getInputSocketReader(2);
- this->m_centerX = this->getWidth() / 2.0;
- this->m_centerY = this->getHeight() / 2.0;
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputXOperation = this->getInputSocketReader(1);
+ this->m_inputYOperation = this->getInputSocketReader(2);
+ this->m_centerX = this->getWidth() / 2.0;
+ this->m_centerY = this->getHeight() / 2.0;
}
void ScaleOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
}
-
void ScaleOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- PixelSampler effective_sampler = getEffectiveSampler(sampler);
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
- float scaleX[4];
- float scaleY[4];
+ float scaleX[4];
+ float scaleY[4];
- this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
- this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
+ this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
- const float scx = scaleX[0];
- const float scy = scaleY[0];
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
- float nx = this->m_centerX + (x - this->m_centerX) / scx;
- float ny = this->m_centerY + (y - this->m_centerY) / scy;
- this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
+ float nx = this->m_centerX + (x - this->m_centerX) / scx;
+ float ny = this->m_centerY + (y - this->m_centerY) / scy;
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
}
-bool ScaleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ScaleOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- if (!m_variable_size) {
- float scaleX[4];
- float scaleY[4];
-
- this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
-
- const float scx = scaleX[0];
- const float scy = scaleY[0];
-
- newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / scx;
- newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / scx;
- newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy;
- newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
- return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+ if (!m_variable_size) {
+ float scaleX[4];
+ float scaleY[4];
+
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+
+ newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / scx;
+ newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / scx;
+ newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / scy;
+ newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / scy;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-
// SCALE ABSOLUTE
ScaleAbsoluteOperation::ScaleAbsoluteOperation() : BaseScaleOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
}
void ScaleAbsoluteOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputXOperation = this->getInputSocketReader(1);
- this->m_inputYOperation = this->getInputSocketReader(2);
- this->m_centerX = this->getWidth() / 2.0;
- this->m_centerY = this->getHeight() / 2.0;
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputXOperation = this->getInputSocketReader(1);
+ this->m_inputYOperation = this->getInputSocketReader(2);
+ this->m_centerX = this->getWidth() / 2.0;
+ this->m_centerY = this->getHeight() / 2.0;
}
void ScaleAbsoluteOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
}
-
-void ScaleAbsoluteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ScaleAbsoluteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- PixelSampler effective_sampler = getEffectiveSampler(sampler);
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
- float scaleX[4];
- float scaleY[4];
+ float scaleX[4];
+ float scaleY[4];
- this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
- this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
+ this->m_inputXOperation->readSampled(scaleX, x, y, effective_sampler);
+ this->m_inputYOperation->readSampled(scaleY, x, y, effective_sampler);
- const float scx = scaleX[0]; // target absolute scale
- const float scy = scaleY[0]; // target absolute scale
+ const float scx = scaleX[0]; // target absolute scale
+ const float scy = scaleY[0]; // target absolute scale
- const float width = this->getWidth();
- const float height = this->getHeight();
- //div
- float relativeXScale = scx / width;
- float relativeYScale = scy / height;
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ //div
+ float relativeXScale = scx / width;
+ float relativeYScale = scy / height;
- float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale;
- float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale;
+ float nx = this->m_centerX + (x - this->m_centerX) / relativeXScale;
+ float ny = this->m_centerY + (y - this->m_centerY) / relativeYScale;
- this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
}
-bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ScaleAbsoluteOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- if (!m_variable_size) {
- float scaleX[4];
- float scaleY[4];
-
- this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
- this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
-
- const float scx = scaleX[0];
- const float scy = scaleY[0];
- const float width = this->getWidth();
- const float height = this->getHeight();
- //div
- float relateveXScale = scx / width;
- float relateveYScale = scy / height;
-
- newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / relateveXScale;
- newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / relateveXScale;
- newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale;
- newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale;
- }
- else {
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- }
-
- return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+ if (!m_variable_size) {
+ float scaleX[4];
+ float scaleY[4];
+
+ this->m_inputXOperation->readSampled(scaleX, 0, 0, COM_PS_NEAREST);
+ this->m_inputYOperation->readSampled(scaleY, 0, 0, COM_PS_NEAREST);
+
+ const float scx = scaleX[0];
+ const float scy = scaleY[0];
+ const float width = this->getWidth();
+ const float height = this->getHeight();
+ //div
+ float relateveXScale = scx / width;
+ float relateveYScale = scy / height;
+
+ newInput.xmax = this->m_centerX + (input->xmax - this->m_centerX) / relateveXScale;
+ newInput.xmin = this->m_centerX + (input->xmin - this->m_centerX) / relateveXScale;
+ newInput.ymax = this->m_centerY + (input->ymax - this->m_centerY) / relateveYScale;
+ newInput.ymin = this->m_centerY + (input->ymin - this->m_centerY) / relateveYScale;
+ }
+ else {
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ }
+
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-
// Absolute fixed size
ScaleFixedSizeOperation::ScaleFixedSizeOperation() : BaseScaleOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_is_offset = false;
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_is_offset = false;
}
void ScaleFixedSizeOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_relX = this->m_inputOperation->getWidth() / (float)this->m_newWidth;
- this->m_relY = this->m_inputOperation->getHeight() / (float)this->m_newHeight;
-
-
- /* *** all the options below are for a fairly special case - camera framing *** */
- if (this->m_offsetX != 0.0f || this->m_offsetY != 0.0f) {
- this->m_is_offset = true;
-
- if (this->m_newWidth > this->m_newHeight) {
- this->m_offsetX *= this->m_newWidth;
- this->m_offsetY *= this->m_newWidth;
- }
- else {
- this->m_offsetX *= this->m_newHeight;
- this->m_offsetY *= this->m_newHeight;
- }
- }
-
- if (this->m_is_aspect) {
- /* apply aspect from clip */
- const float w_src = this->m_inputOperation->getWidth();
- const float h_src = this->m_inputOperation->getHeight();
-
- /* destination aspect is already applied from the camera frame */
- const float w_dst = this->m_newWidth;
- const float h_dst = this->m_newHeight;
-
- const float asp_src = w_src / h_src;
- const float asp_dst = w_dst / h_dst;
-
- if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
- if ((asp_src > asp_dst) == (this->m_is_crop == true)) {
- /* fit X */
- const float div = asp_src / asp_dst;
- this->m_relX /= div;
- this->m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
- }
- else {
- /* fit Y */
- const float div = asp_dst / asp_src;
- this->m_relY /= div;
- this->m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
- }
-
- this->m_is_offset = true;
- }
- }
- /* *** end framing options *** */
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_relX = this->m_inputOperation->getWidth() / (float)this->m_newWidth;
+ this->m_relY = this->m_inputOperation->getHeight() / (float)this->m_newHeight;
+
+ /* *** all the options below are for a fairly special case - camera framing *** */
+ if (this->m_offsetX != 0.0f || this->m_offsetY != 0.0f) {
+ this->m_is_offset = true;
+
+ if (this->m_newWidth > this->m_newHeight) {
+ this->m_offsetX *= this->m_newWidth;
+ this->m_offsetY *= this->m_newWidth;
+ }
+ else {
+ this->m_offsetX *= this->m_newHeight;
+ this->m_offsetY *= this->m_newHeight;
+ }
+ }
+
+ if (this->m_is_aspect) {
+ /* apply aspect from clip */
+ const float w_src = this->m_inputOperation->getWidth();
+ const float h_src = this->m_inputOperation->getHeight();
+
+ /* destination aspect is already applied from the camera frame */
+ const float w_dst = this->m_newWidth;
+ const float h_dst = this->m_newHeight;
+
+ const float asp_src = w_src / h_src;
+ const float asp_dst = w_dst / h_dst;
+
+ if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
+ if ((asp_src > asp_dst) == (this->m_is_crop == true)) {
+ /* fit X */
+ const float div = asp_src / asp_dst;
+ this->m_relX /= div;
+ this->m_offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
+ }
+ else {
+ /* fit Y */
+ const float div = asp_dst / asp_src;
+ this->m_relY /= div;
+ this->m_offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
+ }
+
+ this->m_is_offset = true;
+ }
+ }
+ /* *** end framing options *** */
}
void ScaleFixedSizeOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
+ this->m_inputOperation = NULL;
}
-
-void ScaleFixedSizeOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ScaleFixedSizeOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- PixelSampler effective_sampler = getEffectiveSampler(sampler);
-
- if (this->m_is_offset) {
- float nx = ((x - this->m_offsetX) * this->m_relX);
- float ny = ((y - this->m_offsetY) * this->m_relY);
- this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
- }
- else {
- this->m_inputOperation->readSampled(output, x * this->m_relX, y * this->m_relY, effective_sampler);
- }
+ PixelSampler effective_sampler = getEffectiveSampler(sampler);
+
+ if (this->m_is_offset) {
+ float nx = ((x - this->m_offsetX) * this->m_relX);
+ float ny = ((y - this->m_offsetY) * this->m_relY);
+ this->m_inputOperation->readSampled(output, nx, ny, effective_sampler);
+ }
+ else {
+ this->m_inputOperation->readSampled(
+ output, x * this->m_relX, y * this->m_relY, effective_sampler);
+ }
}
-bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- newInput.xmax = (input->xmax - m_offsetX) * this->m_relX + 1;
- newInput.xmin = (input->xmin - m_offsetX) * this->m_relX;
- newInput.ymax = (input->ymax - m_offsetY) * this->m_relY + 1;
- newInput.ymin = (input->ymin - m_offsetY) * this->m_relY;
+ newInput.xmax = (input->xmax - m_offsetX) * this->m_relX + 1;
+ newInput.xmin = (input->xmin - m_offsetX) * this->m_relX;
+ newInput.ymax = (input->ymax - m_offsetY) * this->m_relY + 1;
+ newInput.ymin = (input->ymin - m_offsetY) * this->m_relY;
- return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return BaseScaleOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
-void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2], unsigned int /*preferredResolution*/[2])
+void ScaleFixedSizeOperation::determineResolution(unsigned int resolution[2],
+ unsigned int /*preferredResolution*/[2])
{
- unsigned int nr[2];
- nr[0] = this->m_newWidth;
- nr[1] = this->m_newHeight;
- BaseScaleOperation::determineResolution(resolution, nr);
- resolution[0] = this->m_newWidth;
- resolution[1] = this->m_newHeight;
+ unsigned int nr[2];
+ nr[0] = this->m_newWidth;
+ nr[1] = this->m_newHeight;
+ BaseScaleOperation::determineResolution(resolution, nr);
+ resolution[0] = this->m_newWidth;
+ resolution[1] = this->m_newHeight;
}
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h
index d761e441419..28e32ff8606 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.h
+++ b/source/blender/compositor/operations/COM_ScaleOperation.h
@@ -22,79 +22,112 @@
#include "COM_NodeOperation.h"
class BaseScaleOperation : public NodeOperation {
-public:
- void setSampler(PixelSampler sampler) { this->m_sampler = (int) sampler; }
- void setVariableSize(bool variable_size) { m_variable_size = variable_size; };
+ public:
+ void setSampler(PixelSampler sampler)
+ {
+ this->m_sampler = (int)sampler;
+ }
+ void setVariableSize(bool variable_size)
+ {
+ m_variable_size = variable_size;
+ };
-protected:
- BaseScaleOperation();
+ protected:
+ BaseScaleOperation();
- PixelSampler getEffectiveSampler(PixelSampler sampler) { return (m_sampler == -1) ? sampler : (PixelSampler) m_sampler; }
+ PixelSampler getEffectiveSampler(PixelSampler sampler)
+ {
+ return (m_sampler == -1) ? sampler : (PixelSampler)m_sampler;
+ }
- int m_sampler;
- bool m_variable_size;
+ int m_sampler;
+ bool m_variable_size;
};
class ScaleOperation : public BaseScaleOperation {
-private:
- SocketReader *m_inputOperation;
- SocketReader *m_inputXOperation;
- SocketReader *m_inputYOperation;
- float m_centerX;
- float m_centerY;
-public:
- ScaleOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
+ private:
+ SocketReader *m_inputOperation;
+ SocketReader *m_inputXOperation;
+ SocketReader *m_inputYOperation;
+ float m_centerX;
+ float m_centerY;
+
+ public:
+ ScaleOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
};
class ScaleAbsoluteOperation : public BaseScaleOperation {
- SocketReader *m_inputOperation;
- SocketReader *m_inputXOperation;
- SocketReader *m_inputYOperation;
- float m_centerX;
- float m_centerY;
-
-public:
- ScaleAbsoluteOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
+ SocketReader *m_inputOperation;
+ SocketReader *m_inputXOperation;
+ SocketReader *m_inputYOperation;
+ float m_centerX;
+ float m_centerY;
+
+ public:
+ ScaleAbsoluteOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
};
class ScaleFixedSizeOperation : public BaseScaleOperation {
- SocketReader *m_inputOperation;
- int m_newWidth;
- int m_newHeight;
- float m_relX;
- float m_relY;
-
- /* center is only used for aspect correction */
- float m_offsetX;
- float m_offsetY;
- bool m_is_aspect;
- bool m_is_crop;
- /* set from other properties on initialization,
- * check if we need to apply offset */
- bool m_is_offset;
-public:
- ScaleFixedSizeOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
- void setNewWidth(int width) { this->m_newWidth = width; }
- void setNewHeight(int height) { this->m_newHeight = height; }
- void setIsAspect(bool is_aspect) { this->m_is_aspect = is_aspect; }
- void setIsCrop(bool is_crop) { this->m_is_crop = is_crop; }
- void setOffset(float x, float y) { this->m_offsetX = x; this->m_offsetY = y; }
+ SocketReader *m_inputOperation;
+ int m_newWidth;
+ int m_newHeight;
+ float m_relX;
+ float m_relY;
+
+ /* center is only used for aspect correction */
+ float m_offsetX;
+ float m_offsetY;
+ bool m_is_aspect;
+ bool m_is_crop;
+ /* set from other properties on initialization,
+ * check if we need to apply offset */
+ bool m_is_offset;
+
+ public:
+ ScaleFixedSizeOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+ void setNewWidth(int width)
+ {
+ this->m_newWidth = width;
+ }
+ void setNewHeight(int height)
+ {
+ this->m_newHeight = height;
+ }
+ void setIsAspect(bool is_aspect)
+ {
+ this->m_is_aspect = is_aspect;
+ }
+ void setIsCrop(bool is_crop)
+ {
+ this->m_is_crop = is_crop;
+ }
+ void setOffset(float x, float y)
+ {
+ this->m_offsetX = x;
+ this->m_offsetY = y;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 0d7eb189c90..eeefb2a9f3b 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -19,323 +19,333 @@
#include "COM_ScreenLensDistortionOperation.h"
extern "C" {
-# include "BLI_math.h"
-# include "BLI_utildefines.h"
-# include "BLI_rand.h"
-# include "PIL_time.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_rand.h"
+#include "PIL_time.h"
}
ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->m_inputProgram = NULL;
- this->m_distortion = 0.0f;
- this->m_dispersion = 0.0f;
- this->m_distortion_const = false;
- this->m_dispersion_const = false;
- this->m_variables_ready = false;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->m_inputProgram = NULL;
+ this->m_distortion = 0.0f;
+ this->m_dispersion = 0.0f;
+ this->m_distortion_const = false;
+ this->m_dispersion_const = false;
+ this->m_variables_ready = false;
}
void ScreenLensDistortionOperation::setDistortion(float distortion)
{
- m_distortion = distortion;
- m_distortion_const = true;
+ m_distortion = distortion;
+ m_distortion_const = true;
}
void ScreenLensDistortionOperation::setDispersion(float dispersion)
{
- m_dispersion = dispersion;
- m_dispersion_const = true;
+ m_dispersion = dispersion;
+ m_dispersion_const = true;
}
void ScreenLensDistortionOperation::initExecution()
{
- this->m_inputProgram = this->getInputSocketReader(0);
- this->initMutex();
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->initMutex();
- uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
- rng_seed ^= (uint)POINTER_AS_INT(m_inputProgram);
- this->m_rng = BLI_rng_new(rng_seed);
+ uint rng_seed = (uint)(PIL_check_seconds_timer_i() & UINT_MAX);
+ rng_seed ^= (uint)POINTER_AS_INT(m_inputProgram);
+ this->m_rng = BLI_rng_new(rng_seed);
- this->m_cx = 0.5f * (float)getWidth();
- this->m_cy = 0.5f * (float)getHeight();
+ this->m_cx = 0.5f * (float)getWidth();
+ this->m_cy = 0.5f * (float)getHeight();
- /* if both are constant, init variables once */
- if (m_distortion_const && m_dispersion_const) {
- updateVariables(m_distortion, m_dispersion);
- m_variables_ready = true;
- }
+ /* if both are constant, init variables once */
+ if (m_distortion_const && m_dispersion_const) {
+ updateVariables(m_distortion, m_dispersion);
+ m_variables_ready = true;
+ }
}
void *ScreenLensDistortionOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = this->m_inputProgram->initializeTileData(NULL);
-
- /* get distortion/dispersion values once, by reading inputs at (0,0)
- * XXX this assumes invariable values (no image inputs),
- * we don't have a nice generic system for that yet
- */
- if (!m_variables_ready) {
- this->lockMutex();
-
- if (!m_distortion_const) {
- float result[4];
- getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
- m_distortion = result[0];
- }
- if (!m_dispersion_const) {
- float result[4];
- getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST);
- m_dispersion = result[0];
- }
-
- updateVariables(m_distortion, m_dispersion);
- m_variables_ready = true;
-
- this->unlockMutex();
- }
-
- return buffer;
+ void *buffer = this->m_inputProgram->initializeTileData(NULL);
+
+ /* get distortion/dispersion values once, by reading inputs at (0,0)
+ * XXX this assumes invariable values (no image inputs),
+ * we don't have a nice generic system for that yet
+ */
+ if (!m_variables_ready) {
+ this->lockMutex();
+
+ if (!m_distortion_const) {
+ float result[4];
+ getInputSocketReader(1)->readSampled(result, 0, 0, COM_PS_NEAREST);
+ m_distortion = result[0];
+ }
+ if (!m_dispersion_const) {
+ float result[4];
+ getInputSocketReader(2)->readSampled(result, 0, 0, COM_PS_NEAREST);
+ m_dispersion = result[0];
+ }
+
+ updateVariables(m_distortion, m_dispersion);
+ m_variables_ready = true;
+
+ this->unlockMutex();
+ }
+
+ return buffer;
}
void ScreenLensDistortionOperation::get_uv(const float xy[2], float uv[2]) const
{
- uv[0] = m_sc * ((xy[0] + 0.5f) - m_cx) / m_cx;
- uv[1] = m_sc * ((xy[1] + 0.5f) - m_cy) / m_cy;
+ uv[0] = m_sc * ((xy[0] + 0.5f) - m_cx) / m_cx;
+ uv[1] = m_sc * ((xy[1] + 0.5f) - m_cy) / m_cy;
}
void ScreenLensDistortionOperation::distort_uv(const float uv[2], float t, float xy[2]) const
{
- float d = 1.0f / (1.0f + sqrtf(t));
- xy[0] = (uv[0] * d + 0.5f) * getWidth() - 0.5f;
- xy[1] = (uv[1] * d + 0.5f) * getHeight() - 0.5f;
+ float d = 1.0f / (1.0f + sqrtf(t));
+ xy[0] = (uv[0] * d + 0.5f) * getWidth() - 0.5f;
+ xy[1] = (uv[1] * d + 0.5f) * getHeight() - 0.5f;
}
-bool ScreenLensDistortionOperation::get_delta(float r_sq, float k4, const float uv[2], float delta[2]) const
+bool ScreenLensDistortionOperation::get_delta(float r_sq,
+ float k4,
+ const float uv[2],
+ float delta[2]) const
{
- float t = 1.0f - k4 * r_sq;
- if (t >= 0.0f) {
- distort_uv(uv, t, delta);
- return true;
- }
- else
- return false;
-
+ float t = 1.0f - k4 * r_sq;
+ if (t >= 0.0f) {
+ distort_uv(uv, t, delta);
+ return true;
+ }
+ else
+ return false;
}
void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer,
- int a, int b,
- float r_sq, const float uv[2],
+ int a,
+ int b,
+ float r_sq,
+ const float uv[2],
const float delta[3][2],
- float sum[4], int count[3]) const
+ float sum[4],
+ int count[3]) const
{
- float color[4];
+ float color[4];
- float dsf = len_v2v2(delta[a], delta[b]) + 1.0f;
- int ds = m_jitter ? (dsf < 4.0f ? 2 : (int)sqrtf(dsf)) : (int)dsf;
- float sd = 1.0f / (float)ds;
+ float dsf = len_v2v2(delta[a], delta[b]) + 1.0f;
+ int ds = m_jitter ? (dsf < 4.0f ? 2 : (int)sqrtf(dsf)) : (int)dsf;
+ float sd = 1.0f / (float)ds;
- float k4 = m_k4[a];
- float dk4 = m_dk4[a];
+ float k4 = m_k4[a];
+ float dk4 = m_dk4[a];
- for (float z = 0; z < ds; ++z) {
- float tz = (z + (m_jitter ? BLI_rng_get_float(m_rng) : 0.5f)) * sd;
- float t = 1.0f - (k4 + tz * dk4) * r_sq;
+ for (float z = 0; z < ds; ++z) {
+ float tz = (z + (m_jitter ? BLI_rng_get_float(m_rng) : 0.5f)) * sd;
+ float t = 1.0f - (k4 + tz * dk4) * r_sq;
- float xy[2];
- distort_uv(uv, t, xy);
- buffer->readBilinear(color, xy[0], xy[1]);
+ float xy[2];
+ distort_uv(uv, t, xy);
+ buffer->readBilinear(color, xy[0], xy[1]);
- sum[a] += (1.0f - tz) * color[a];
- sum[b] += (tz ) * color[b];
- count[a]++;
- count[b]++;
- }
+ sum[a] += (1.0f - tz) * color[a];
+ sum[b] += (tz)*color[b];
+ count[a]++;
+ count[b]++;
+ }
}
void ScreenLensDistortionOperation::executePixel(float output[4], int x, int y, void *data)
{
- MemoryBuffer *buffer = (MemoryBuffer *)data;
- float xy[2] = { (float)x, (float)y };
- float uv[2];
- get_uv(xy, uv);
- float uv_dot = len_squared_v2(uv);
-
- int count[3] = { 0, 0, 0 };
- float delta[3][2];
- float sum[4] = { 0, 0, 0, 0 };
-
- bool valid_r = get_delta(uv_dot, m_k4[0], uv, delta[0]);
- bool valid_g = get_delta(uv_dot, m_k4[1], uv, delta[1]);
- bool valid_b = get_delta(uv_dot, m_k4[2], uv, delta[2]);
-
- if (valid_r && valid_g && valid_b) {
- accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count);
- accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count);
-
- if (count[0]) output[0] = 2.0f * sum[0] / (float)count[0];
- if (count[1]) output[1] = 2.0f * sum[1] / (float)count[1];
- if (count[2]) output[2] = 2.0f * sum[2] / (float)count[2];
-
- /* set alpha */
- output[3] = 1.0f;
- }
- else {
- zero_v4(output);
- }
+ MemoryBuffer *buffer = (MemoryBuffer *)data;
+ float xy[2] = {(float)x, (float)y};
+ float uv[2];
+ get_uv(xy, uv);
+ float uv_dot = len_squared_v2(uv);
+
+ int count[3] = {0, 0, 0};
+ float delta[3][2];
+ float sum[4] = {0, 0, 0, 0};
+
+ bool valid_r = get_delta(uv_dot, m_k4[0], uv, delta[0]);
+ bool valid_g = get_delta(uv_dot, m_k4[1], uv, delta[1]);
+ bool valid_b = get_delta(uv_dot, m_k4[2], uv, delta[2]);
+
+ if (valid_r && valid_g && valid_b) {
+ accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count);
+ accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count);
+
+ if (count[0])
+ output[0] = 2.0f * sum[0] / (float)count[0];
+ if (count[1])
+ output[1] = 2.0f * sum[1] / (float)count[1];
+ if (count[2])
+ output[2] = 2.0f * sum[2] / (float)count[2];
+
+ /* set alpha */
+ output[3] = 1.0f;
+ }
+ else {
+ zero_v4(output);
+ }
}
void ScreenLensDistortionOperation::deinitExecution()
{
- this->deinitMutex();
- this->m_inputProgram = NULL;
- BLI_rng_free(this->m_rng);
+ this->deinitMutex();
+ this->m_inputProgram = NULL;
+ BLI_rng_free(this->m_rng);
}
void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const
{
- const float xy[2] = {x, y};
- float uv[2];
- get_uv(xy, uv);
- float uv_dot = len_squared_v2(uv);
-
- copy_v2_v2(result + 0, xy);
- copy_v2_v2(result + 2, xy);
- copy_v2_v2(result + 4, xy);
- get_delta(uv_dot, m_k4[0], uv, result + 0);
- get_delta(uv_dot, m_k4[1], uv, result + 2);
- get_delta(uv_dot, m_k4[2], uv, result + 4);
+ const float xy[2] = {x, y};
+ float uv[2];
+ get_uv(xy, uv);
+ float uv_dot = len_squared_v2(uv);
+
+ copy_v2_v2(result + 0, xy);
+ copy_v2_v2(result + 2, xy);
+ copy_v2_v2(result + 4, xy);
+ get_delta(uv_dot, m_k4[0], uv, result + 0);
+ get_delta(uv_dot, m_k4[1], uv, result + 2);
+ get_delta(uv_dot, m_k4[2], uv, result + 4);
}
-bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(
+ rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInputValue;
- newInputValue.xmin = 0;
- newInputValue.ymin = 0;
- newInputValue.xmax = 2;
- newInputValue.ymax = 2;
-
- NodeOperation *operation = getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) {
- return true;
- }
-
- operation = getInputOperation(2);
- if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) {
- return true;
- }
-
- /* XXX the original method of estimating the area-of-interest does not work
- * it assumes a linear increase/decrease of mapped coordinates, which does not
- * yield correct results for the area and leaves uninitialized buffer areas.
- * So now just use the full image area, which may not be as efficient but works at least ...
- */
+ rcti newInputValue;
+ newInputValue.xmin = 0;
+ newInputValue.ymin = 0;
+ newInputValue.xmax = 2;
+ newInputValue.ymax = 2;
+
+ NodeOperation *operation = getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output)) {
+ return true;
+ }
+
+ operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output)) {
+ return true;
+ }
+
+ /* XXX the original method of estimating the area-of-interest does not work
+ * it assumes a linear increase/decrease of mapped coordinates, which does not
+ * yield correct results for the area and leaves uninitialized buffer areas.
+ * So now just use the full image area, which may not be as efficient but works at least ...
+ */
#if 1
- rcti imageInput;
-
- operation = getInputOperation(0);
- imageInput.xmax = operation->getWidth();
- imageInput.xmin = 0;
- imageInput.ymax = operation->getHeight();
- imageInput.ymin = 0;
-
- if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
- return true;
- }
- return false;
+ rcti imageInput;
+
+ operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output)) {
+ return true;
+ }
+ return false;
#else
- rcti newInput;
- const float margin = 2;
-
- BLI_rcti_init_minmax(&newInput);
-
- if (m_dispersion_const && m_distortion_const) {
- /* update from fixed distortion/dispersion */
-#define UPDATE_INPUT(x, y) \
- { \
- float coords[6]; \
- determineUV(coords, x, y); \
- newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \
- newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \
- newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \
- newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \
- } (void)0
-
- UPDATE_INPUT(input->xmin, input->xmax);
- UPDATE_INPUT(input->xmin, input->ymax);
- UPDATE_INPUT(input->xmax, input->ymax);
- UPDATE_INPUT(input->xmax, input->ymin);
-
-#undef UPDATE_INPUT
- }
- else {
- /* use maximum dispersion 1.0 if not const */
- float dispersion = m_dispersion_const ? m_dispersion : 1.0f;
-
-#define UPDATE_INPUT(x, y, distortion) \
- { \
- float coords[6]; \
- updateVariables(distortion, dispersion); \
- determineUV(coords, x, y); \
- newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \
- newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \
- newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \
- newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \
- } (void)0
-
- if (m_distortion_const) {
- /* update from fixed distortion */
- UPDATE_INPUT(input->xmin, input->xmax, m_distortion);
- UPDATE_INPUT(input->xmin, input->ymax, m_distortion);
- UPDATE_INPUT(input->xmax, input->ymax, m_distortion);
- UPDATE_INPUT(input->xmax, input->ymin, m_distortion);
- }
- else {
- /* update from min/max distortion (-1..1) */
- UPDATE_INPUT(input->xmin, input->xmax, -1.0f);
- UPDATE_INPUT(input->xmin, input->ymax, -1.0f);
- UPDATE_INPUT(input->xmax, input->ymax, -1.0f);
- UPDATE_INPUT(input->xmax, input->ymin, -1.0f);
-
- UPDATE_INPUT(input->xmin, input->xmax, 1.0f);
- UPDATE_INPUT(input->xmin, input->ymax, 1.0f);
- UPDATE_INPUT(input->xmax, input->ymax, 1.0f);
- UPDATE_INPUT(input->xmax, input->ymin, 1.0f);
-
-#undef UPDATE_INPUT
- }
- }
-
- newInput.xmin -= margin;
- newInput.ymin -= margin;
- newInput.xmax += margin;
- newInput.ymax += margin;
-
- operation = getInputOperation(0);
- if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
- return true;
- }
- return false;
+ rcti newInput;
+ const float margin = 2;
+
+ BLI_rcti_init_minmax(&newInput);
+
+ if (m_dispersion_const && m_distortion_const) {
+ /* update from fixed distortion/dispersion */
+# define UPDATE_INPUT(x, y) \
+ { \
+ float coords[6]; \
+ determineUV(coords, x, y); \
+ newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \
+ newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \
+ newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \
+ newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \
+ } \
+ (void)0
+
+ UPDATE_INPUT(input->xmin, input->xmax);
+ UPDATE_INPUT(input->xmin, input->ymax);
+ UPDATE_INPUT(input->xmax, input->ymax);
+ UPDATE_INPUT(input->xmax, input->ymin);
+
+# undef UPDATE_INPUT
+ }
+ else {
+ /* use maximum dispersion 1.0 if not const */
+ float dispersion = m_dispersion_const ? m_dispersion : 1.0f;
+
+# define UPDATE_INPUT(x, y, distortion) \
+ { \
+ float coords[6]; \
+ updateVariables(distortion, dispersion); \
+ determineUV(coords, x, y); \
+ newInput.xmin = min_ffff(newInput.xmin, coords[0], coords[2], coords[4]); \
+ newInput.ymin = min_ffff(newInput.ymin, coords[1], coords[3], coords[5]); \
+ newInput.xmax = max_ffff(newInput.xmax, coords[0], coords[2], coords[4]); \
+ newInput.ymax = max_ffff(newInput.ymax, coords[1], coords[3], coords[5]); \
+ } \
+ (void)0
+
+ if (m_distortion_const) {
+ /* update from fixed distortion */
+ UPDATE_INPUT(input->xmin, input->xmax, m_distortion);
+ UPDATE_INPUT(input->xmin, input->ymax, m_distortion);
+ UPDATE_INPUT(input->xmax, input->ymax, m_distortion);
+ UPDATE_INPUT(input->xmax, input->ymin, m_distortion);
+ }
+ else {
+ /* update from min/max distortion (-1..1) */
+ UPDATE_INPUT(input->xmin, input->xmax, -1.0f);
+ UPDATE_INPUT(input->xmin, input->ymax, -1.0f);
+ UPDATE_INPUT(input->xmax, input->ymax, -1.0f);
+ UPDATE_INPUT(input->xmax, input->ymin, -1.0f);
+
+ UPDATE_INPUT(input->xmin, input->xmax, 1.0f);
+ UPDATE_INPUT(input->xmin, input->ymax, 1.0f);
+ UPDATE_INPUT(input->xmax, input->ymax, 1.0f);
+ UPDATE_INPUT(input->xmax, input->ymin, 1.0f);
+
+# undef UPDATE_INPUT
+ }
+ }
+
+ newInput.xmin -= margin;
+ newInput.ymin -= margin;
+ newInput.xmax += margin;
+ newInput.ymax += margin;
+
+ operation = getInputOperation(0);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
+ return true;
+ }
+ return false;
#endif
}
void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion)
{
- m_k[1] = max_ff(min_ff(distortion, 1.0f), -0.999f);
- // smaller dispersion range for somewhat more control
- float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f);
- m_k[0] = max_ff(min_ff((m_k[1] + d), 1.0f), -0.999f);
- m_k[2] = max_ff(min_ff((m_k[1] - d), 1.0f), -0.999f);
- m_maxk = max_fff(m_k[0], m_k[1], m_k[2]);
- m_sc = (m_fit && (m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * m_maxk)) :
- (1.0f / (1.0f + m_maxk));
- m_dk4[0] = 4.0f * (m_k[1] - m_k[0]);
- m_dk4[1] = 4.0f * (m_k[2] - m_k[1]);
- m_dk4[2] = 0.0f; /* unused */
-
- mul_v3_v3fl(m_k4, m_k, 4.0f);
+ m_k[1] = max_ff(min_ff(distortion, 1.0f), -0.999f);
+ // smaller dispersion range for somewhat more control
+ float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f);
+ m_k[0] = max_ff(min_ff((m_k[1] + d), 1.0f), -0.999f);
+ m_k[2] = max_ff(min_ff((m_k[1] - d), 1.0f), -0.999f);
+ m_maxk = max_fff(m_k[0], m_k[1], m_k[2]);
+ m_sc = (m_fit && (m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * m_maxk)) : (1.0f / (1.0f + m_maxk));
+ m_dk4[0] = 4.0f * (m_k[1] - m_k[0]);
+ m_dk4[1] = 4.0f * (m_k[2] - m_k[1]);
+ m_dk4[2] = 0.0f; /* unused */
+
+ mul_v3_v3fl(m_k4, m_k, 4.0f);
}
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index c419378a2a6..c9db5bc88b8 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -22,64 +22,78 @@
#include "DNA_node_types.h"
class ScreenLensDistortionOperation : public NodeOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
- struct RNG *m_rng;
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ struct RNG *m_rng;
- bool m_fit;
- bool m_jitter;
+ bool m_fit;
+ bool m_jitter;
- float m_dispersion;
- float m_distortion;
- bool m_dispersion_const;
- bool m_distortion_const;
- bool m_variables_ready;
- float m_k[3];
- float m_k4[3];
- float m_dk4[3];
- float m_maxk;
- float m_sc, m_cx, m_cy;
-public:
- ScreenLensDistortionOperation();
+ float m_dispersion;
+ float m_distortion;
+ bool m_dispersion_const;
+ bool m_distortion_const;
+ bool m_variables_ready;
+ float m_k[3];
+ float m_k4[3];
+ float m_dk4[3];
+ float m_maxk;
+ float m_sc, m_cx, m_cy;
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ ScreenLensDistortionOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- void *initializeTileData(rcti *rect);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void setFit(bool fit) { m_fit = fit; }
- void setJitter(bool jitter) { m_jitter = jitter; }
+ void *initializeTileData(rcti *rect);
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- /** Set constant distortion value */
- void setDistortion(float distortion);
- /** Set constant dispersion value */
- void setDispersion(float dispersion);
+ void setFit(bool fit)
+ {
+ m_fit = fit;
+ }
+ void setJitter(bool jitter)
+ {
+ m_jitter = jitter;
+ }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ /** Set constant distortion value */
+ void setDistortion(float distortion);
+ /** Set constant dispersion value */
+ void setDispersion(float dispersion);
-private:
- void determineUV(float result[6], float x, float y) const;
- void updateVariables(float distortion, float dispersion);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- void get_uv(const float xy[2], float uv[2]) const;
- void distort_uv(const float uv[2], float t, float xy[2]) const;
- bool get_delta(float r_sq, float k4, const float uv[2], float delta[2]) const;
- void accumulate(MemoryBuffer *buffer, int a, int b,
- float r_sq, const float uv[2], const float delta[3][2],
- float sum[4], int count[3]) const;
+ private:
+ void determineUV(float result[6], float x, float y) const;
+ void updateVariables(float distortion, float dispersion);
+
+ void get_uv(const float xy[2], float uv[2]) const;
+ void distort_uv(const float uv[2], float t, float xy[2]) const;
+ bool get_delta(float r_sq, float k4, const float uv[2], float delta[2]) const;
+ void accumulate(MemoryBuffer *buffer,
+ int a,
+ int b,
+ float r_sq,
+ const float uv[2],
+ const float delta[3][2],
+ float sum[4],
+ int count[3]) const;
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
index 441e0835c95..68c165411b2 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.cpp
@@ -20,32 +20,35 @@
SetAlphaOperation::SetAlphaOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
- this->m_inputColor = NULL;
- this->m_inputAlpha = NULL;
+ this->m_inputColor = NULL;
+ this->m_inputAlpha = NULL;
}
void SetAlphaOperation::initExecution()
{
- this->m_inputColor = getInputSocketReader(0);
- this->m_inputAlpha = getInputSocketReader(1);
+ this->m_inputColor = getInputSocketReader(0);
+ this->m_inputAlpha = getInputSocketReader(1);
}
-void SetAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void SetAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float alphaInput[4];
+ float alphaInput[4];
- this->m_inputColor->readSampled(output, x, y, sampler);
- this->m_inputAlpha->readSampled(alphaInput, x, y, sampler);
+ this->m_inputColor->readSampled(output, x, y, sampler);
+ this->m_inputAlpha->readSampled(alphaInput, x, y, sampler);
- output[3] = alphaInput[0];
+ output[3] = alphaInput[0];
}
void SetAlphaOperation::deinitExecution()
{
- this->m_inputColor = NULL;
- this->m_inputAlpha = NULL;
+ this->m_inputColor = NULL;
+ this->m_inputAlpha = NULL;
}
diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h
index 38cd5135406..24f80b71eae 100644
--- a/source/blender/compositor/operations/COM_SetAlphaOperation.h
+++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h
@@ -20,28 +20,27 @@
#define __COM_SETALPHAOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class SetAlphaOperation : public NodeOperation {
-private:
- SocketReader *m_inputColor;
- SocketReader *m_inputAlpha;
+ private:
+ SocketReader *m_inputColor;
+ SocketReader *m_inputAlpha;
-public:
- /**
- * Default constructor
- */
- SetAlphaOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ SetAlphaOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.cpp b/source/blender/compositor/operations/COM_SetColorOperation.cpp
index d80ed6eb1ca..58bfcb44afd 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetColorOperation.cpp
@@ -20,18 +20,20 @@
SetColorOperation::SetColorOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
void SetColorOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
+ float /*x*/,
+ float /*y*/,
PixelSampler /*sampler*/)
{
- copy_v4_v4(output, this->m_color);
+ copy_v4_v4(output, this->m_color);
}
-void SetColorOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void SetColorOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h
index 376e4633ac8..d16d3806864 100644
--- a/source/blender/compositor/operations/COM_SetColorOperation.h
+++ b/source/blender/compositor/operations/COM_SetColorOperation.h
@@ -20,41 +20,66 @@
#define __COM_SETCOLOROPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class SetColorOperation : public NodeOperation {
-private:
- float m_color[4];
-
-public:
- /**
- * Default constructor
- */
- SetColorOperation();
+ private:
+ float m_color[4];
- float getChannel1() { return this->m_color[0]; }
- void setChannel1(float value) { this->m_color[0] = value; }
- float getChannel2() { return this->m_color[1]; }
- void setChannel2(float value) { this->m_color[1] = value; }
- float getChannel3() { return this->m_color[2]; }
- void setChannel3(float value) { this->m_color[2] = value; }
- float getChannel4() { return this->m_color[3]; }
- void setChannel4(const float value) { this->m_color[3] = value; }
- void setChannels(const float value[4])
- {
- copy_v4_v4(this->m_color, value);
- }
+ public:
+ /**
+ * Default constructor
+ */
+ SetColorOperation();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ float getChannel1()
+ {
+ return this->m_color[0];
+ }
+ void setChannel1(float value)
+ {
+ this->m_color[0] = value;
+ }
+ float getChannel2()
+ {
+ return this->m_color[1];
+ }
+ void setChannel2(float value)
+ {
+ this->m_color[1] = value;
+ }
+ float getChannel3()
+ {
+ return this->m_color[2];
+ }
+ void setChannel3(float value)
+ {
+ this->m_color[2] = value;
+ }
+ float getChannel4()
+ {
+ return this->m_color[3];
+ }
+ void setChannel4(const float value)
+ {
+ this->m_color[3] = value;
+ }
+ void setChannels(const float value[4])
+ {
+ copy_v4_v4(this->m_color, value);
+ }
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- bool isSetOperation() const { return true; }
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ bool isSetOperation() const
+ {
+ return true;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
index 38039bbf6bb..f3b3ed217f9 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.cpp
@@ -20,20 +20,23 @@
SetSamplerOperation::SetSamplerOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
void SetSamplerOperation::initExecution()
{
- this->m_reader = this->getInputSocketReader(0);
+ this->m_reader = this->getInputSocketReader(0);
}
void SetSamplerOperation::deinitExecution()
{
- this->m_reader = NULL;
+ this->m_reader = NULL;
}
-void SetSamplerOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void SetSamplerOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- this->m_reader->readSampled(output, x, y, this->m_sampler);
+ this->m_reader->readSampled(output, x, y, this->m_sampler);
}
diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h
index eaa8bbf744d..62f01129ff7 100644
--- a/source/blender/compositor/operations/COM_SetSamplerOperation.h
+++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h
@@ -20,28 +20,31 @@
#define __COM_SETSAMPLEROPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output Sampler.
* it assumes we are in sRGB color space.
*/
class SetSamplerOperation : public NodeOperation {
-private:
- PixelSampler m_sampler;
- SocketReader *m_reader;
-public:
- /**
- * Default constructor
- */
- SetSamplerOperation();
+ private:
+ PixelSampler m_sampler;
+ SocketReader *m_reader;
+
+ public:
+ /**
+ * Default constructor
+ */
+ SetSamplerOperation();
- void setSampler(PixelSampler sampler) { this->m_sampler = sampler; }
+ void setSampler(PixelSampler sampler)
+ {
+ this->m_sampler = sampler;
+ }
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void initExecution();
- void deinitExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void initExecution();
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.cpp b/source/blender/compositor/operations/COM_SetValueOperation.cpp
index 0aa1e2bcbef..e49b6941f49 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetValueOperation.cpp
@@ -20,18 +20,20 @@
SetValueOperation::SetValueOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
}
void SetValueOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
+ float /*x*/,
+ float /*y*/,
PixelSampler /*sampler*/)
{
- output[0] = this->m_value;
+ output[0] = this->m_value;
}
-void SetValueOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void SetValueOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h
index 59bcf28d012..6fb2832450d 100644
--- a/source/blender/compositor/operations/COM_SetValueOperation.h
+++ b/source/blender/compositor/operations/COM_SetValueOperation.h
@@ -20,31 +20,38 @@
#define __COM_SETVALUEOPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class SetValueOperation : public NodeOperation {
-private:
- float m_value;
-
-public:
- /**
- * Default constructor
- */
- SetValueOperation();
-
- float getValue() { return this->m_value; }
- void setValue(float value) { this->m_value = value; }
-
-
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- bool isSetOperation() const { return true; }
+ private:
+ float m_value;
+
+ public:
+ /**
+ * Default constructor
+ */
+ SetValueOperation();
+
+ float getValue()
+ {
+ return this->m_value;
+ }
+ void setValue(float value)
+ {
+ this->m_value = value;
+ }
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ bool isSetOperation() const
+ {
+ return true;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.cpp b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
index 29407df55e5..d3a0329c9b9 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.cpp
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.cpp
@@ -21,20 +21,22 @@
SetVectorOperation::SetVectorOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VECTOR);
}
void SetVectorOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
+ float /*x*/,
+ float /*y*/,
PixelSampler /*sampler*/)
{
- output[0] = this->m_x;
- output[1] = this->m_y;
- output[2] = this->m_z;
+ output[0] = this->m_x;
+ output[1] = this->m_y;
+ output[2] = this->m_z;
}
-void SetVectorOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void SetVectorOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h
index c00bd125dff..a2f9aaa6b3b 100644
--- a/source/blender/compositor/operations/COM_SetVectorOperation.h
+++ b/source/blender/compositor/operations/COM_SetVectorOperation.h
@@ -20,45 +20,72 @@
#define __COM_SETVECTOROPERATION_H__
#include "COM_NodeOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class SetVectorOperation : public NodeOperation {
-private:
- float m_x;
- float m_y;
- float m_z;
- float m_w;
+ private:
+ float m_x;
+ float m_y;
+ float m_z;
+ float m_w;
-public:
- /**
- * Default constructor
- */
- SetVectorOperation();
+ public:
+ /**
+ * Default constructor
+ */
+ SetVectorOperation();
- float getX() { return this->m_x; }
- void setX(float value) { this->m_x = value; }
- float getY() { return this->m_y; }
- void setY(float value) { this->m_y = value; }
- float getZ() { return this->m_z; }
- void setZ(float value) { this->m_z = value; }
- float getW() { return this->m_w; }
- void setW(float value) { this->m_w = value; }
+ float getX()
+ {
+ return this->m_x;
+ }
+ void setX(float value)
+ {
+ this->m_x = value;
+ }
+ float getY()
+ {
+ return this->m_y;
+ }
+ void setY(float value)
+ {
+ this->m_y = value;
+ }
+ float getZ()
+ {
+ return this->m_z;
+ }
+ void setZ(float value)
+ {
+ this->m_z = value;
+ }
+ float getW()
+ {
+ return this->m_w;
+ }
+ void setW(float value)
+ {
+ this->m_w = value;
+ }
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- bool isSetOperation() const { return true; }
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ bool isSetOperation() const
+ {
+ return true;
+ }
- void setVector(const float vector[3]) {
- setX(vector[0]);
- setY(vector[1]);
- setZ(vector[2]);
- }
+ void setVector(const float vector[3])
+ {
+ setX(vector[0]);
+ setY(vector[1]);
+ setZ(vector[2]);
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index 83ed7af1ffb..2d54d6ae45d 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -18,10 +18,9 @@
#include "COM_SocketProxyOperation.h"
-SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion) :
- NodeOperation(),
- m_use_conversion(use_conversion)
+SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion)
+ : NodeOperation(), m_use_conversion(use_conversion)
{
- this->addInputSocket(type);
- this->addOutputSocket(type);
+ this->addInputSocket(type);
+ this->addOutputSocket(type);
}
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index 47856031219..3855c26088a 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.h
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.h
@@ -22,17 +22,29 @@
#include "COM_NodeOperation.h"
class SocketProxyOperation : public NodeOperation {
-public:
- SocketProxyOperation(DataType type, bool use_conversion);
+ public:
+ SocketProxyOperation(DataType type, bool use_conversion);
- bool isProxyOperation() const { return true; }
- bool useDatatypeConversion() const { return m_use_conversion; }
+ bool isProxyOperation() const
+ {
+ return true;
+ }
+ bool useDatatypeConversion() const
+ {
+ return m_use_conversion;
+ }
- bool getUseConversion() const { return m_use_conversion; }
- void setUseConversion(bool use_conversion) { m_use_conversion = use_conversion; }
+ bool getUseConversion() const
+ {
+ return m_use_conversion;
+ }
+ void setUseConversion(bool use_conversion)
+ {
+ m_use_conversion = use_conversion;
+ }
-private:
- bool m_use_conversion;
+ private:
+ bool m_use_conversion;
};
#endif
diff --git a/source/blender/compositor/operations/COM_SplitOperation.cpp b/source/blender/compositor/operations/COM_SplitOperation.cpp
index aebae3c3f19..24978acc8f3 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.cpp
+++ b/source/blender/compositor/operations/COM_SplitOperation.cpp
@@ -24,53 +24,57 @@
#include "BLI_math_vector.h"
extern "C" {
-# include "MEM_guardedalloc.h"
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
+#include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
}
-
SplitOperation::SplitOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_image1Input = NULL;
- this->m_image2Input = NULL;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_image1Input = NULL;
+ this->m_image2Input = NULL;
}
void SplitOperation::initExecution()
{
- // When initializing the tree during initial load the width and height can be zero.
- this->m_image1Input = getInputSocketReader(0);
- this->m_image2Input = getInputSocketReader(1);
+ // When initializing the tree during initial load the width and height can be zero.
+ this->m_image1Input = getInputSocketReader(0);
+ this->m_image2Input = getInputSocketReader(1);
}
void SplitOperation::deinitExecution()
{
- this->m_image1Input = NULL;
- this->m_image2Input = NULL;
+ this->m_image1Input = NULL;
+ this->m_image2Input = NULL;
}
-void SplitOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void SplitOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f : this->m_splitPercentage * this->getHeight() / 100.0f;
- bool image1 = this->m_xSplit ? x > perc : y > perc;
- if (image1) {
- this->m_image1Input->readSampled(output, x, y, COM_PS_NEAREST);
- }
- else {
- this->m_image2Input->readSampled(output, x, y, COM_PS_NEAREST);
- }
+ int perc = this->m_xSplit ? this->m_splitPercentage * this->getWidth() / 100.0f :
+ this->m_splitPercentage * this->getHeight() / 100.0f;
+ bool image1 = this->m_xSplit ? x > perc : y > perc;
+ if (image1) {
+ this->m_image1Input->readSampled(output, x, y, COM_PS_NEAREST);
+ }
+ else {
+ this->m_image2Input->readSampled(output, x, y, COM_PS_NEAREST);
+ }
}
-void SplitOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void SplitOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- unsigned int tempPreferredResolution[2] = {0, 0};
- unsigned int tempResolution[2];
+ unsigned int tempPreferredResolution[2] = {0, 0};
+ unsigned int tempResolution[2];
- this->getInputSocket(0)->determineResolution(tempResolution, tempPreferredResolution);
- this->setResolutionInputSocketIndex((tempResolution[0] && tempResolution[1]) ? 0 : 1);
+ this->getInputSocket(0)->determineResolution(tempResolution, tempPreferredResolution);
+ this->setResolutionInputSocketIndex((tempResolution[0] && tempResolution[1]) ? 0 : 1);
- NodeOperation::determineResolution(resolution, preferredResolution);
+ NodeOperation::determineResolution(resolution, preferredResolution);
}
diff --git a/source/blender/compositor/operations/COM_SplitOperation.h b/source/blender/compositor/operations/COM_SplitOperation.h
index 34cb7f8f1b7..ea923123290 100644
--- a/source/blender/compositor/operations/COM_SplitOperation.h
+++ b/source/blender/compositor/operations/COM_SplitOperation.h
@@ -21,19 +21,26 @@
#include "COM_NodeOperation.h"
class SplitOperation : public NodeOperation {
-private:
- SocketReader *m_image1Input;
- SocketReader *m_image2Input;
+ private:
+ SocketReader *m_image1Input;
+ SocketReader *m_image2Input;
- float m_splitPercentage;
- bool m_xSplit;
-public:
- SplitOperation();
- void initExecution();
- void deinitExecution();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void setSplitPercentage(float splitPercentage) { this->m_splitPercentage = splitPercentage; }
- void setXSplit(bool xsplit) { this->m_xSplit = xsplit; }
+ float m_splitPercentage;
+ bool m_xSplit;
+
+ public:
+ SplitOperation();
+ void initExecution();
+ void deinitExecution();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void setSplitPercentage(float splitPercentage)
+ {
+ this->m_splitPercentage = splitPercentage;
+ }
+ void setXSplit(bool xsplit)
+ {
+ this->m_xSplit = xsplit;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
index 0da63dd1c7a..80b1c1f798a 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.cpp
@@ -21,19 +21,19 @@
SunBeamsOperation::SunBeamsOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
- this->setComplex(true);
+ this->setComplex(true);
}
void SunBeamsOperation::initExecution()
{
- /* convert to pixels */
- this->m_source_px[0] = this->m_data.source[0] * this->getWidth();
- this->m_source_px[1] = this->m_data.source[1] * this->getHeight();
- this->m_ray_length_px = this->m_data.ray_length * max(this->getWidth(), this->getHeight());
+ /* convert to pixels */
+ this->m_source_px[0] = this->m_data.source[0] * this->getWidth();
+ this->m_source_px[1] = this->m_data.source[1] * this->getHeight();
+ this->m_ray_length_px = this->m_data.ray_length * max(this->getWidth(), this->getHeight());
}
/**
@@ -53,165 +53,179 @@ void SunBeamsOperation::initExecution()
* fyu : buffer increment in y for sector u+1
* fyv : buffer increment in y for sector v+1
*/
-template <int fxu, int fxv, int fyu, int fyv>
-struct BufferLineAccumulator {
-
- /* utility functions implementing the matrix transform to/from sector space */
-
- static inline void buffer_to_sector(const float source[2], int x, int y, int &u, int &v)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x -= x0;
- y -= y0;
- u = x * fxu + y * fyu;
- v = x * fxv + y * fyv;
- }
-
- static inline void buffer_to_sector(const float source[2], float x, float y, float &u, float &v)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x -= (float)x0;
- y -= (float)y0;
- u = x * fxu + y * fyu;
- v = x * fxv + y * fyv;
- }
-
- static inline void sector_to_buffer(const float source[2], int u, int v, int &x, int &y)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x = x0 + u * fxu + v * fxv;
- y = y0 + u * fyu + v * fyv;
- }
-
- static inline void sector_to_buffer(const float source[2], float u, float v, float &x, float &y)
- {
- int x0 = (int)source[0];
- int y0 = (int)source[1];
- x = (float)x0 + u * fxu + v * fxv;
- y = (float)y0 + u * fyu + v * fyv;
- }
-
- /**
- * Set up the initial buffer pointer and calculate necessary variables for looping.
- *
- * Note that sector space is centered around the "source" point while the loop starts
- * at dist_min from the target pt. This way the loop can be canceled as soon as it runs
- * out of the buffer rect, because no pixels further along the line can contribute.
- *
- * \param x, y: Start location in the buffer
- * \param num: Total steps in the loop
- * \param v, dv: Vertical offset in sector space, for line offset perpendicular to the loop axis
- */
- static float *init_buffer_iterator(MemoryBuffer *input, const float source[2], const float co[2],
- float dist_min, float dist_max,
- int &x, int &y, int &num, float &v, float &dv, float &falloff_factor)
- {
- float pu, pv;
- buffer_to_sector(source, co[0], co[1], pu, pv);
-
- /* line angle */
- float tan_phi = pv / pu;
- float dr = sqrtf(tan_phi * tan_phi + 1.0f);
- float cos_phi = 1.0f / dr;
-
- /* clamp u range to avoid influence of pixels "behind" the source */
- float umin = max_ff(pu - cos_phi * dist_min, 0.0f);
- float umax = max_ff(pu - cos_phi * dist_max, 0.0f);
- v = umin * tan_phi;
- dv = tan_phi;
-
- int start = (int)floorf(umax);
- int end = (int)ceilf(umin);
- num = end - start;
-
- sector_to_buffer(source, end, (int)ceilf(v), x, y);
-
- falloff_factor = dist_max > dist_min ? dr / (float)(dist_max - dist_min) : 0.0f;
-
- float *iter = input->getBuffer() + COM_NUM_CHANNELS_COLOR * (x + input->getWidth() * y);
- return iter;
- }
-
- /**
- * Perform the actual accumulation along a ray segment from source to pt.
- * Only pixels within dist_min..dist_max contribute.
- *
- * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to pt.
- * After each step it decrements v by dv < 1, adding a buffer shift when necessary.
- */
- static void eval(MemoryBuffer *input, float output[4], const float co[2], const float source[2],
- float dist_min, float dist_max)
- {
- rcti rect = *input->getRect();
- int buffer_width = input->getWidth();
- int x, y, num;
- float v, dv;
- float falloff_factor;
- float border[4];
-
- zero_v4(output);
-
- if ((int)(co[0] - source[0]) == 0 && (int)(co[1] - source[1]) == 0) {
- copy_v4_v4(output, input->getBuffer() + COM_NUM_CHANNELS_COLOR * ((int)source[0] + input->getWidth() * (int)source[1]));
- return;
- }
-
- /* initialise the iteration variables */
- float *buffer = init_buffer_iterator(input, source, co, dist_min, dist_max, x, y, num, v, dv, falloff_factor);
- zero_v3(border);
- border[3] = 1.0f;
-
- /* v_local keeps track of when to decrement v (see below) */
- float v_local = v - floorf(v);
-
- for (int i = 0; i < num; i++) {
- float weight = 1.0f - (float)i * falloff_factor;
- weight *= weight;
-
- /* range check, use last valid color when running beyond the image border */
- if (x >= rect.xmin && x < rect.xmax && y >= rect.ymin && y < rect.ymax) {
- madd_v4_v4fl(output, buffer, buffer[3] * weight);
- /* use as border color in case subsequent pixels are out of bounds */
- copy_v4_v4(border, buffer);
- }
- else {
- madd_v4_v4fl(output, border, border[3] * weight);
- }
-
- /* TODO implement proper filtering here, see
- * https://en.wikipedia.org/wiki/Lanczos_resampling
- * https://en.wikipedia.org/wiki/Sinc_function
- *
- * using lanczos with x = distance from the line segment,
- * normalized to a == 0.5f, could give a good result
- *
- * for now just divide equally at the end ...
- */
-
- /* decrement u */
- x -= fxu;
- y -= fyu;
- buffer -= (fxu + fyu * buffer_width) * COM_NUM_CHANNELS_COLOR;
-
- /* decrement v (in steps of dv < 1) */
- v_local -= dv;
- if (v_local < 0.0f) {
- v_local += 1.0f;
-
- x -= fxv;
- y -= fyv;
- buffer -= (fxv + fyv * buffer_width) * COM_NUM_CHANNELS_COLOR;
- }
- }
-
- /* normalize */
- if (num > 0) {
- mul_v4_fl(output, 1.0f / (float)num);
- }
- }
+template<int fxu, int fxv, int fyu, int fyv> struct BufferLineAccumulator {
+
+ /* utility functions implementing the matrix transform to/from sector space */
+
+ static inline void buffer_to_sector(const float source[2], int x, int y, int &u, int &v)
+ {
+ int x0 = (int)source[0];
+ int y0 = (int)source[1];
+ x -= x0;
+ y -= y0;
+ u = x * fxu + y * fyu;
+ v = x * fxv + y * fyv;
+ }
+
+ static inline void buffer_to_sector(const float source[2], float x, float y, float &u, float &v)
+ {
+ int x0 = (int)source[0];
+ int y0 = (int)source[1];
+ x -= (float)x0;
+ y -= (float)y0;
+ u = x * fxu + y * fyu;
+ v = x * fxv + y * fyv;
+ }
+
+ static inline void sector_to_buffer(const float source[2], int u, int v, int &x, int &y)
+ {
+ int x0 = (int)source[0];
+ int y0 = (int)source[1];
+ x = x0 + u * fxu + v * fxv;
+ y = y0 + u * fyu + v * fyv;
+ }
+
+ static inline void sector_to_buffer(const float source[2], float u, float v, float &x, float &y)
+ {
+ int x0 = (int)source[0];
+ int y0 = (int)source[1];
+ x = (float)x0 + u * fxu + v * fxv;
+ y = (float)y0 + u * fyu + v * fyv;
+ }
+
+ /**
+ * Set up the initial buffer pointer and calculate necessary variables for looping.
+ *
+ * Note that sector space is centered around the "source" point while the loop starts
+ * at dist_min from the target pt. This way the loop can be canceled as soon as it runs
+ * out of the buffer rect, because no pixels further along the line can contribute.
+ *
+ * \param x, y: Start location in the buffer
+ * \param num: Total steps in the loop
+ * \param v, dv: Vertical offset in sector space, for line offset perpendicular to the loop axis
+ */
+ static float *init_buffer_iterator(MemoryBuffer *input,
+ const float source[2],
+ const float co[2],
+ float dist_min,
+ float dist_max,
+ int &x,
+ int &y,
+ int &num,
+ float &v,
+ float &dv,
+ float &falloff_factor)
+ {
+ float pu, pv;
+ buffer_to_sector(source, co[0], co[1], pu, pv);
+
+ /* line angle */
+ float tan_phi = pv / pu;
+ float dr = sqrtf(tan_phi * tan_phi + 1.0f);
+ float cos_phi = 1.0f / dr;
+
+ /* clamp u range to avoid influence of pixels "behind" the source */
+ float umin = max_ff(pu - cos_phi * dist_min, 0.0f);
+ float umax = max_ff(pu - cos_phi * dist_max, 0.0f);
+ v = umin * tan_phi;
+ dv = tan_phi;
+
+ int start = (int)floorf(umax);
+ int end = (int)ceilf(umin);
+ num = end - start;
+
+ sector_to_buffer(source, end, (int)ceilf(v), x, y);
+
+ falloff_factor = dist_max > dist_min ? dr / (float)(dist_max - dist_min) : 0.0f;
+
+ float *iter = input->getBuffer() + COM_NUM_CHANNELS_COLOR * (x + input->getWidth() * y);
+ return iter;
+ }
+
+ /**
+ * Perform the actual accumulation along a ray segment from source to pt.
+ * Only pixels within dist_min..dist_max contribute.
+ *
+ * The loop runs backwards(!) over the primary sector space axis u, i.e. increasing distance to pt.
+ * After each step it decrements v by dv < 1, adding a buffer shift when necessary.
+ */
+ static void eval(MemoryBuffer *input,
+ float output[4],
+ const float co[2],
+ const float source[2],
+ float dist_min,
+ float dist_max)
+ {
+ rcti rect = *input->getRect();
+ int buffer_width = input->getWidth();
+ int x, y, num;
+ float v, dv;
+ float falloff_factor;
+ float border[4];
+
+ zero_v4(output);
+
+ if ((int)(co[0] - source[0]) == 0 && (int)(co[1] - source[1]) == 0) {
+ copy_v4_v4(output,
+ input->getBuffer() + COM_NUM_CHANNELS_COLOR *
+ ((int)source[0] + input->getWidth() * (int)source[1]));
+ return;
+ }
+
+ /* initialise the iteration variables */
+ float *buffer = init_buffer_iterator(
+ input, source, co, dist_min, dist_max, x, y, num, v, dv, falloff_factor);
+ zero_v3(border);
+ border[3] = 1.0f;
+
+ /* v_local keeps track of when to decrement v (see below) */
+ float v_local = v - floorf(v);
+
+ for (int i = 0; i < num; i++) {
+ float weight = 1.0f - (float)i * falloff_factor;
+ weight *= weight;
+
+ /* range check, use last valid color when running beyond the image border */
+ if (x >= rect.xmin && x < rect.xmax && y >= rect.ymin && y < rect.ymax) {
+ madd_v4_v4fl(output, buffer, buffer[3] * weight);
+ /* use as border color in case subsequent pixels are out of bounds */
+ copy_v4_v4(border, buffer);
+ }
+ else {
+ madd_v4_v4fl(output, border, border[3] * weight);
+ }
+
+ /* TODO implement proper filtering here, see
+ * https://en.wikipedia.org/wiki/Lanczos_resampling
+ * https://en.wikipedia.org/wiki/Sinc_function
+ *
+ * using lanczos with x = distance from the line segment,
+ * normalized to a == 0.5f, could give a good result
+ *
+ * for now just divide equally at the end ...
+ */
+
+ /* decrement u */
+ x -= fxu;
+ y -= fyu;
+ buffer -= (fxu + fyu * buffer_width) * COM_NUM_CHANNELS_COLOR;
+
+ /* decrement v (in steps of dv < 1) */
+ v_local -= dv;
+ if (v_local < 0.0f) {
+ v_local += 1.0f;
+
+ x -= fxv;
+ y -= fyv;
+ buffer -= (fxv + fyv * buffer_width) * COM_NUM_CHANNELS_COLOR;
+ }
+ }
+
+ /* normalize */
+ if (num > 0) {
+ mul_v4_fl(output, 1.0f / (float)num);
+ }
+ }
};
/**
@@ -221,113 +235,120 @@ struct BufferLineAccumulator {
* The BufferLineAccumulator defines the actual loop over the buffer, with an efficient inner loop
* due to using compile time constants instead of a local matrix variable defining the sector space.
*/
-static void accumulate_line(MemoryBuffer *input, float output[4], const float co[2], const float source[2],
- float dist_min, float dist_max)
+static void accumulate_line(MemoryBuffer *input,
+ float output[4],
+ const float co[2],
+ const float source[2],
+ float dist_min,
+ float dist_max)
{
- /* coordinates relative to source */
- float pt_ofs[2] = {co[0] - source[0], co[1] - source[1]};
-
- /* The source sectors are defined like so:
- *
- * \ 3 | 2 /
- * \ | /
- * 4 \ | / 1
- * \|/
- * -----------
- * /|\
- * 5 / | \ 8
- * / | \
- * / 6 | 7 \
- *
- * The template arguments encode the transformation into "sector space",
- * by means of rotation/mirroring matrix elements.
- */
-
- if (fabsf(pt_ofs[1]) > fabsf(pt_ofs[0])) {
- if (pt_ofs[0] > 0.0f) {
- if (pt_ofs[1] > 0.0f) {
- /* 2 */
- BufferLineAccumulator<0, 1, 1, 0>::eval(input, output, co, source, dist_min, dist_max);
- }
- else {
- /* 7 */
- BufferLineAccumulator<0, 1, -1, 0>::eval(input, output, co, source, dist_min, dist_max);
- }
- }
- else {
- if (pt_ofs[1] > 0.0f) {
- /* 3 */
- BufferLineAccumulator<0, -1, 1, 0>::eval(input, output, co, source, dist_min, dist_max);
- }
- else {
- /* 6 */
- BufferLineAccumulator<0, -1, -1, 0>::eval(input, output, co, source, dist_min, dist_max);
- }
- }
- }
- else {
- if (pt_ofs[0] > 0.0f) {
- if (pt_ofs[1] > 0.0f) {
- /* 1 */
- BufferLineAccumulator< 1, 0, 0, 1>::eval(input, output, co, source, dist_min, dist_max);
- }
- else {
- /* 8 */
- BufferLineAccumulator< 1, 0, 0, -1>::eval(input, output, co, source, dist_min, dist_max);
- }
- }
- else {
- if (pt_ofs[1] > 0.0f) {
- /* 4 */
- BufferLineAccumulator<-1, 0, 0, 1>::eval(input, output, co, source, dist_min, dist_max);
- }
- else {
- /* 5 */
- BufferLineAccumulator<-1, 0, 0, -1>::eval(input, output, co, source, dist_min, dist_max);
- }
- }
- }
+ /* coordinates relative to source */
+ float pt_ofs[2] = {co[0] - source[0], co[1] - source[1]};
+
+ /* The source sectors are defined like so:
+ *
+ * \ 3 | 2 /
+ * \ | /
+ * 4 \ | / 1
+ * \|/
+ * -----------
+ * /|\
+ * 5 / | \ 8
+ * / | \
+ * / 6 | 7 \
+ *
+ * The template arguments encode the transformation into "sector space",
+ * by means of rotation/mirroring matrix elements.
+ */
+
+ if (fabsf(pt_ofs[1]) > fabsf(pt_ofs[0])) {
+ if (pt_ofs[0] > 0.0f) {
+ if (pt_ofs[1] > 0.0f) {
+ /* 2 */
+ BufferLineAccumulator<0, 1, 1, 0>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ else {
+ /* 7 */
+ BufferLineAccumulator<0, 1, -1, 0>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ }
+ else {
+ if (pt_ofs[1] > 0.0f) {
+ /* 3 */
+ BufferLineAccumulator<0, -1, 1, 0>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ else {
+ /* 6 */
+ BufferLineAccumulator<0, -1, -1, 0>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ }
+ }
+ else {
+ if (pt_ofs[0] > 0.0f) {
+ if (pt_ofs[1] > 0.0f) {
+ /* 1 */
+ BufferLineAccumulator<1, 0, 0, 1>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ else {
+ /* 8 */
+ BufferLineAccumulator<1, 0, 0, -1>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ }
+ else {
+ if (pt_ofs[1] > 0.0f) {
+ /* 4 */
+ BufferLineAccumulator<-1, 0, 0, 1>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ else {
+ /* 5 */
+ BufferLineAccumulator<-1, 0, 0, -1>::eval(input, output, co, source, dist_min, dist_max);
+ }
+ }
+ }
}
void *SunBeamsOperation::initializeTileData(rcti * /*rect*/)
{
- void *buffer = getInputOperation(0)->initializeTileData(NULL);
- return buffer;
+ void *buffer = getInputOperation(0)->initializeTileData(NULL);
+ return buffer;
}
void SunBeamsOperation::executePixel(float output[4], int x, int y, void *data)
{
- const float co[2] = {(float)x, (float)y};
+ const float co[2] = {(float)x, (float)y};
- accumulate_line((MemoryBuffer *)data, output, co, this->m_source_px, 0.0f, this->m_ray_length_px);
+ accumulate_line(
+ (MemoryBuffer *)data, output, co, this->m_source_px, 0.0f, this->m_ray_length_px);
}
static void calc_ray_shift(rcti *rect, float x, float y, const float source[2], float ray_length)
{
- float co[2] = {(float)x, (float)y};
- float dir[2], dist;
+ float co[2] = {(float)x, (float)y};
+ float dir[2], dist;
- /* move (x,y) vector toward the source by ray_length distance */
- sub_v2_v2v2(dir, co, source);
- dist = normalize_v2(dir);
- mul_v2_fl(dir, min_ff(dist, ray_length));
- sub_v2_v2(co, dir);
+ /* move (x,y) vector toward the source by ray_length distance */
+ sub_v2_v2v2(dir, co, source);
+ dist = normalize_v2(dir);
+ mul_v2_fl(dir, min_ff(dist, ray_length));
+ sub_v2_v2(co, dir);
- int ico[2] = {(int)co[0], (int)co[1]};
- BLI_rcti_do_minmax_v(rect, ico);
+ int ico[2] = {(int)co[0], (int)co[1]};
+ BLI_rcti_do_minmax_v(rect, ico);
}
-bool SunBeamsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool SunBeamsOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- /* Enlarges the rect by moving each corner toward the source.
- * This is the maximum distance that pixels can influence each other
- * and gives a rect that contains all possible accumulated pixels.
- */
- rcti rect = *input;
- calc_ray_shift(&rect, input->xmin, input->ymin, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmin, input->ymax, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmax, input->ymin, this->m_source_px, this->m_ray_length_px);
- calc_ray_shift(&rect, input->xmax, input->ymax, this->m_source_px, this->m_ray_length_px);
-
- return NodeOperation::determineDependingAreaOfInterest(&rect, readOperation, output);
+ /* Enlarges the rect by moving each corner toward the source.
+ * This is the maximum distance that pixels can influence each other
+ * and gives a rect that contains all possible accumulated pixels.
+ */
+ rcti rect = *input;
+ calc_ray_shift(&rect, input->xmin, input->ymin, this->m_source_px, this->m_ray_length_px);
+ calc_ray_shift(&rect, input->xmin, input->ymax, this->m_source_px, this->m_ray_length_px);
+ calc_ray_shift(&rect, input->xmax, input->ymin, this->m_source_px, this->m_ray_length_px);
+ calc_ray_shift(&rect, input->xmax, input->ymax, this->m_source_px, this->m_ray_length_px);
+
+ return NodeOperation::determineDependingAreaOfInterest(&rect, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_SunBeamsOperation.h b/source/blender/compositor/operations/COM_SunBeamsOperation.h
index 22c44b706dc..d8153264d98 100644
--- a/source/blender/compositor/operations/COM_SunBeamsOperation.h
+++ b/source/blender/compositor/operations/COM_SunBeamsOperation.h
@@ -21,24 +21,29 @@
#include "COM_NodeOperation.h"
class SunBeamsOperation : public NodeOperation {
-public:
- SunBeamsOperation();
+ public:
+ SunBeamsOperation();
- void executePixel(float output[4], int x, int y, void *data);
+ void executePixel(float output[4], int x, int y, void *data);
- void initExecution();
+ void initExecution();
- void *initializeTileData(rcti *rect);
+ void *initializeTileData(rcti *rect);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
- void setData(const NodeSunBeams &data) { m_data = data; }
+ void setData(const NodeSunBeams &data)
+ {
+ m_data = data;
+ }
-private:
- NodeSunBeams m_data;
+ private:
+ NodeSunBeams m_data;
- float m_source_px[2];
- float m_ray_length_px;
+ float m_source_px[2];
+ float m_ray_length_px;
};
#endif
diff --git a/source/blender/compositor/operations/COM_TextureOperation.cpp b/source/blender/compositor/operations/COM_TextureOperation.cpp
index 37d41a2afad..f23057bbe8e 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.cpp
+++ b/source/blender/compositor/operations/COM_TextureOperation.cpp
@@ -29,126 +29,120 @@ extern "C" {
TextureBaseOperation::TextureBaseOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VECTOR); //offset
- this->addInputSocket(COM_DT_VECTOR); //size
- this->m_texture = NULL;
- this->m_inputSize = NULL;
- this->m_inputOffset = NULL;
- this->m_rd = NULL;
- this->m_pool = NULL;
- this->m_sceneColorManage = false;
- setComplex(true);
+ this->addInputSocket(COM_DT_VECTOR); //offset
+ this->addInputSocket(COM_DT_VECTOR); //size
+ this->m_texture = NULL;
+ this->m_inputSize = NULL;
+ this->m_inputOffset = NULL;
+ this->m_rd = NULL;
+ this->m_pool = NULL;
+ this->m_sceneColorManage = false;
+ setComplex(true);
}
TextureOperation::TextureOperation() : TextureBaseOperation()
{
- this->addOutputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
}
TextureAlphaOperation::TextureAlphaOperation() : TextureBaseOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_VALUE);
}
void TextureBaseOperation::initExecution()
{
- this->m_inputOffset = getInputSocketReader(0);
- this->m_inputSize = getInputSocketReader(1);
- this->m_pool = BKE_image_pool_new();
- if (this->m_texture != NULL &&
- this->m_texture->nodetree != NULL &&
- this->m_texture->use_nodes)
- {
- ntreeTexBeginExecTree(this->m_texture->nodetree);
- }
- NodeOperation::initExecution();
+ this->m_inputOffset = getInputSocketReader(0);
+ this->m_inputSize = getInputSocketReader(1);
+ this->m_pool = BKE_image_pool_new();
+ if (this->m_texture != NULL && this->m_texture->nodetree != NULL && this->m_texture->use_nodes) {
+ ntreeTexBeginExecTree(this->m_texture->nodetree);
+ }
+ NodeOperation::initExecution();
}
void TextureBaseOperation::deinitExecution()
{
- this->m_inputSize = NULL;
- this->m_inputOffset = NULL;
- BKE_image_pool_free(this->m_pool);
- this->m_pool = NULL;
- if (this->m_texture != NULL &&
- this->m_texture->use_nodes &&
- this->m_texture->nodetree != NULL &&
- this->m_texture->nodetree->execdata != NULL)
- {
- ntreeTexEndExecTree(this->m_texture->nodetree->execdata);
- }
- NodeOperation::deinitExecution();
+ this->m_inputSize = NULL;
+ this->m_inputOffset = NULL;
+ BKE_image_pool_free(this->m_pool);
+ this->m_pool = NULL;
+ if (this->m_texture != NULL && this->m_texture->use_nodes && this->m_texture->nodetree != NULL &&
+ this->m_texture->nodetree->execdata != NULL) {
+ ntreeTexEndExecTree(this->m_texture->nodetree->execdata);
+ }
+ NodeOperation::deinitExecution();
}
-void TextureBaseOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void TextureBaseOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
- int width = this->m_rd->xsch * this->m_rd->size / 100;
- int height = this->m_rd->ysch * this->m_rd->size / 100;
- resolution[0] = width;
- resolution[1] = height;
- }
- else {
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
- }
+ if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
+ int width = this->m_rd->xsch * this->m_rd->size / 100;
+ int height = this->m_rd->ysch * this->m_rd->size / 100;
+ resolution[0] = width;
+ resolution[1] = height;
+ }
+ else {
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
+ }
}
-void TextureAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void TextureAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float color[4];
- TextureBaseOperation::executePixelSampled(color, x, y, sampler);
- output[0] = color[3];
+ float color[4];
+ TextureBaseOperation::executePixelSampled(color, x, y, sampler);
+ output[0] = color[3];
}
-void TextureBaseOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void TextureBaseOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
- float textureSize[4];
- float textureOffset[4];
- float vec[3];
- int retval;
- const float cx = this->getWidth() / 2;
- const float cy = this->getHeight() / 2;
- float u = (x - cx) / this->getWidth() * 2;
- float v = (y - cy) / this->getHeight() * 2;
+ TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
+ float textureSize[4];
+ float textureOffset[4];
+ float vec[3];
+ int retval;
+ const float cx = this->getWidth() / 2;
+ const float cy = this->getHeight() / 2;
+ float u = (x - cx) / this->getWidth() * 2;
+ float v = (y - cy) / this->getHeight() * 2;
- /* When no interpolation/filtering happens in multitex() foce nearest interpolation.
- * We do it here because (a) we can't easily say multitex() that we want nearest
- * interpolation and (b) in such configuration multitex() sinply floor's the value
- * which often produces artifacts.
- */
- if (m_texture != NULL && (m_texture->imaflag & TEX_INTERPOL) == 0) {
- u += 0.5f / cx;
- v += 0.5f / cy;
- }
+ /* When no interpolation/filtering happens in multitex() foce nearest interpolation.
+ * We do it here because (a) we can't easily say multitex() that we want nearest
+ * interpolation and (b) in such configuration multitex() sinply floor's the value
+ * which often produces artifacts.
+ */
+ if (m_texture != NULL && (m_texture->imaflag & TEX_INTERPOL) == 0) {
+ u += 0.5f / cx;
+ v += 0.5f / cy;
+ }
- this->m_inputSize->readSampled(textureSize, x, y, sampler);
- this->m_inputOffset->readSampled(textureOffset, x, y, sampler);
+ this->m_inputSize->readSampled(textureSize, x, y, sampler);
+ this->m_inputOffset->readSampled(textureOffset, x, y, sampler);
- vec[0] = textureSize[0] * (u + textureOffset[0]);
- vec[1] = textureSize[1] * (v + textureOffset[1]);
- vec[2] = textureSize[2] * textureOffset[2];
+ vec[0] = textureSize[0] * (u + textureOffset[0]);
+ vec[1] = textureSize[1] * (v + textureOffset[1]);
+ vec[2] = textureSize[2] * textureOffset[2];
- const int thread_id = WorkScheduler::current_thread_id();
- retval = multitex_ext(this->m_texture,
- vec,
- NULL, NULL,
- 0,
- &texres,
- thread_id,
- m_pool,
- m_sceneColorManage,
- false);
+ const int thread_id = WorkScheduler::current_thread_id();
+ retval = multitex_ext(
+ this->m_texture, vec, NULL, NULL, 0, &texres, thread_id, m_pool, m_sceneColorManage, false);
- if (texres.talpha)
- output[3] = texres.ta;
- else
- output[3] = texres.tin;
+ if (texres.talpha)
+ output[3] = texres.ta;
+ else
+ output[3] = texres.tin;
- if ((retval & TEX_RGB)) {
- output[0] = texres.tr;
- output[1] = texres.tg;
- output[2] = texres.tb;
- }
- else {
- output[0] = output[1] = output[2] = output[3];
- }
+ if ((retval & TEX_RGB)) {
+ output[0] = texres.tr;
+ output[1] = texres.tg;
+ output[2] = texres.tb;
+ }
+ else {
+ output[0] = output[1] = output[2] = output[3];
+ }
}
diff --git a/source/blender/compositor/operations/COM_TextureOperation.h b/source/blender/compositor/operations/COM_TextureOperation.h
index 463fe4cc3a0..934b6f8683f 100644
--- a/source/blender/compositor/operations/COM_TextureOperation.h
+++ b/source/blender/compositor/operations/COM_TextureOperation.h
@@ -16,7 +16,6 @@
* Copyright 2011, Blender Foundation.
*/
-
#ifndef __COM_TEXTUREOPERATION_H__
#define __COM_TEXTUREOPERATION_H__
@@ -24,10 +23,10 @@
#include "DNA_texture_types.h"
#include "BLI_listbase.h"
extern "C" {
-# include "RE_pipeline.h"
-# include "RE_shader_ext.h"
-# include "RE_render_ext.h"
-# include "MEM_guardedalloc.h"
+#include "RE_pipeline.h"
+#include "RE_shader_ext.h"
+#include "RE_render_ext.h"
+#include "MEM_guardedalloc.h"
}
/**
@@ -36,45 +35,52 @@ extern "C" {
* \todo: rename to operation.
*/
class TextureBaseOperation : public NodeOperation {
-private:
- Tex *m_texture;
- const RenderData *m_rd;
- SocketReader *m_inputSize;
- SocketReader *m_inputOffset;
- struct ImagePool *m_pool;
- bool m_sceneColorManage;
+ private:
+ Tex *m_texture;
+ const RenderData *m_rd;
+ SocketReader *m_inputSize;
+ SocketReader *m_inputOffset;
+ struct ImagePool *m_pool;
+ bool m_sceneColorManage;
-protected:
+ protected:
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ /**
+ * Constructor
+ */
+ TextureBaseOperation();
- /**
- * Constructor
- */
- TextureBaseOperation();
-public:
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void setTexture(Tex *texture) { this->m_texture = texture; }
- void initExecution();
- void deinitExecution();
- void setRenderData(const RenderData *rd) { this->m_rd = rd; }
- void setSceneColorManage(bool sceneColorManage) { this->m_sceneColorManage = sceneColorManage; }
+ void setTexture(Tex *texture)
+ {
+ this->m_texture = texture;
+ }
+ void initExecution();
+ void deinitExecution();
+ void setRenderData(const RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+ void setSceneColorManage(bool sceneColorManage)
+ {
+ this->m_sceneColorManage = sceneColorManage;
+ }
};
class TextureOperation : public TextureBaseOperation {
-public:
- TextureOperation();
-
+ public:
+ TextureOperation();
};
class TextureAlphaOperation : public TextureBaseOperation {
-public:
- TextureAlphaOperation();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
+ public:
+ TextureAlphaOperation();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index bc2177eefbe..6b408a0a791 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -26,127 +26,131 @@ extern "C" {
TonemapOperation::TonemapOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
- this->addOutputSocket(COM_DT_COLOR);
- this->m_imageReader = NULL;
- this->m_data = NULL;
- this->m_cachedInstance = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_imageReader = NULL;
+ this->m_data = NULL;
+ this->m_cachedInstance = NULL;
+ this->setComplex(true);
}
void TonemapOperation::initExecution()
{
- this->m_imageReader = this->getInputSocketReader(0);
- NodeOperation::initMutex();
+ this->m_imageReader = this->getInputSocketReader(0);
+ NodeOperation::initMutex();
}
void TonemapOperation::executePixel(float output[4], int x, int y, void *data)
{
- AvgLogLum *avg = (AvgLogLum *)data;
+ AvgLogLum *avg = (AvgLogLum *)data;
- this->m_imageReader->read(output, x, y, NULL);
- mul_v3_fl(output, avg->al);
- float dr = output[0] + this->m_data->offset;
- float dg = output[1] + this->m_data->offset;
- float db = output[2] + this->m_data->offset;
- output[0] /= ((dr == 0.0f) ? 1.0f : dr);
- output[1] /= ((dg == 0.0f) ? 1.0f : dg);
- output[2] /= ((db == 0.0f) ? 1.0f : db);
- const float igm = avg->igm;
- if (igm != 0.0f) {
- output[0] = powf(max(output[0], 0.0f), igm);
- output[1] = powf(max(output[1], 0.0f), igm);
- output[2] = powf(max(output[2], 0.0f), igm);
- }
+ this->m_imageReader->read(output, x, y, NULL);
+ mul_v3_fl(output, avg->al);
+ float dr = output[0] + this->m_data->offset;
+ float dg = output[1] + this->m_data->offset;
+ float db = output[2] + this->m_data->offset;
+ output[0] /= ((dr == 0.0f) ? 1.0f : dr);
+ output[1] /= ((dg == 0.0f) ? 1.0f : dg);
+ output[2] /= ((db == 0.0f) ? 1.0f : db);
+ const float igm = avg->igm;
+ if (igm != 0.0f) {
+ output[0] = powf(max(output[0], 0.0f), igm);
+ output[1] = powf(max(output[1], 0.0f), igm);
+ output[2] = powf(max(output[2], 0.0f), igm);
+ }
}
void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y, void *data)
{
- AvgLogLum *avg = (AvgLogLum *)data;
- NodeTonemap *ntm = this->m_data;
+ AvgLogLum *avg = (AvgLogLum *)data;
+ NodeTonemap *ntm = this->m_data;
- const float f = expf(-this->m_data->f);
- const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f));
- const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a;
+ const float f = expf(-this->m_data->f);
+ const float m = (ntm->m > 0.0f) ? ntm->m : (0.3f + 0.7f * powf(avg->auto_key, 1.4f));
+ const float ic = 1.0f - ntm->c, ia = 1.0f - ntm->a;
- this->m_imageReader->read(output, x, y, NULL);
+ this->m_imageReader->read(output, x, y, NULL);
- const float L = IMB_colormanagement_get_luminance(output);
- float I_l = output[0] + ic * (L - output[0]);
- float I_g = avg->cav[0] + ic * (avg->lav - avg->cav[0]);
- float I_a = I_l + ia * (I_g - I_l);
- output[0] /= (output[0] + powf(f * I_a, m));
- I_l = output[1] + ic * (L - output[1]);
- I_g = avg->cav[1] + ic * (avg->lav - avg->cav[1]);
- I_a = I_l + ia * (I_g - I_l);
- output[1] /= (output[1] + powf(f * I_a, m));
- I_l = output[2] + ic * (L - output[2]);
- I_g = avg->cav[2] + ic * (avg->lav - avg->cav[2]);
- I_a = I_l + ia * (I_g - I_l);
- output[2] /= (output[2] + powf(f * I_a, m));
+ const float L = IMB_colormanagement_get_luminance(output);
+ float I_l = output[0] + ic * (L - output[0]);
+ float I_g = avg->cav[0] + ic * (avg->lav - avg->cav[0]);
+ float I_a = I_l + ia * (I_g - I_l);
+ output[0] /= (output[0] + powf(f * I_a, m));
+ I_l = output[1] + ic * (L - output[1]);
+ I_g = avg->cav[1] + ic * (avg->lav - avg->cav[1]);
+ I_a = I_l + ia * (I_g - I_l);
+ output[1] /= (output[1] + powf(f * I_a, m));
+ I_l = output[2] + ic * (L - output[2]);
+ I_g = avg->cav[2] + ic * (avg->lav - avg->cav[2]);
+ I_a = I_l + ia * (I_g - I_l);
+ output[2] /= (output[2] + powf(f * I_a, m));
}
void TonemapOperation::deinitExecution()
{
- this->m_imageReader = NULL;
- if (this->m_cachedInstance) {
- delete this->m_cachedInstance;
- }
- NodeOperation::deinitMutex();
+ this->m_imageReader = NULL;
+ if (this->m_cachedInstance) {
+ delete this->m_cachedInstance;
+ }
+ NodeOperation::deinitMutex();
}
-bool TonemapOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool TonemapOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti imageInput;
+ rcti imageInput;
- NodeOperation *operation = getInputOperation(0);
- imageInput.xmax = operation->getWidth();
- imageInput.xmin = 0;
- imageInput.ymax = operation->getHeight();
- imageInput.ymin = 0;
- if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output) ) {
- return true;
- }
- return false;
+ NodeOperation *operation = getInputOperation(0);
+ imageInput.xmax = operation->getWidth();
+ imageInput.xmin = 0;
+ imageInput.ymax = operation->getHeight();
+ imageInput.ymin = 0;
+ if (operation->determineDependingAreaOfInterest(&imageInput, readOperation, output)) {
+ return true;
+ }
+ return false;
}
void *TonemapOperation::initializeTileData(rcti *rect)
{
- lockMutex();
- if (this->m_cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
- AvgLogLum *data = new AvgLogLum();
+ lockMutex();
+ if (this->m_cachedInstance == NULL) {
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_imageReader->initializeTileData(rect);
+ AvgLogLum *data = new AvgLogLum();
- float *buffer = tile->getBuffer();
+ float *buffer = tile->getBuffer();
- float lsum = 0.0f;
- int p = tile->getWidth() * tile->getHeight();
- float *bc = buffer;
- float avl, maxl = -1e10f, minl = 1e10f;
- const float sc = 1.0f / p;
- float Lav = 0.0f;
- float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- while (p--) {
- float L = IMB_colormanagement_get_luminance(bc);
- Lav += L;
- add_v3_v3(cav, bc);
- lsum += logf(MAX2(L, 0.0f) + 1e-5f);
- maxl = (L > maxl) ? L : maxl;
- minl = (L < minl) ? L : minl;
- bc += 4;
- }
- data->lav = Lav * sc;
- mul_v3_v3fl(data->cav, cav, sc);
- maxl = log((double)maxl + 1e-5); minl = log((double)minl + 1e-5); avl = lsum * sc;
- data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f;
- float al = exp((double)avl);
- data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al);
- data->igm = (this->m_data->gamma == 0.0f) ? 1 : (1.0f / this->m_data->gamma);
- this->m_cachedInstance = data;
- }
- unlockMutex();
- return this->m_cachedInstance;
+ float lsum = 0.0f;
+ int p = tile->getWidth() * tile->getHeight();
+ float *bc = buffer;
+ float avl, maxl = -1e10f, minl = 1e10f;
+ const float sc = 1.0f / p;
+ float Lav = 0.0f;
+ float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ while (p--) {
+ float L = IMB_colormanagement_get_luminance(bc);
+ Lav += L;
+ add_v3_v3(cav, bc);
+ lsum += logf(MAX2(L, 0.0f) + 1e-5f);
+ maxl = (L > maxl) ? L : maxl;
+ minl = (L < minl) ? L : minl;
+ bc += 4;
+ }
+ data->lav = Lav * sc;
+ mul_v3_v3fl(data->cav, cav, sc);
+ maxl = log((double)maxl + 1e-5);
+ minl = log((double)minl + 1e-5);
+ avl = lsum * sc;
+ data->auto_key = (maxl > minl) ? ((maxl - avl) / (maxl - minl)) : 1.0f;
+ float al = exp((double)avl);
+ data->al = (al == 0.0f) ? 0.0f : (this->m_data->key / al);
+ data->igm = (this->m_data->gamma == 0.0f) ? 1 : (1.0f / this->m_data->gamma);
+ this->m_cachedInstance = data;
+ }
+ unlockMutex();
+ return this->m_cachedInstance;
}
void TonemapOperation::deinitializeTileData(rcti * /*rect*/, void * /*data*/)
{
- /* pass */
+ /* pass */
}
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.h b/source/blender/compositor/operations/COM_TonemapOperation.h
index 2b4804e4bfd..11e82c1fc9c 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.h
+++ b/source/blender/compositor/operations/COM_TonemapOperation.h
@@ -26,11 +26,11 @@
* \ingroup operation
*/
typedef struct AvgLogLum {
- float al;
- float auto_key;
- float lav;
- float cav[4];
- float igm;
+ float al;
+ float auto_key;
+ float lav;
+ float cav[4];
+ float igm;
} AvgLogLum;
/**
@@ -38,46 +38,51 @@ typedef struct AvgLogLum {
* \ingroup operation
*/
class TonemapOperation : public NodeOperation {
-protected:
- /**
- * \brief Cached reference to the reader
- */
- SocketReader *m_imageReader;
+ protected:
+ /**
+ * \brief Cached reference to the reader
+ */
+ SocketReader *m_imageReader;
- /**
- * \brief settings of the Tonemap
- */
- NodeTonemap *m_data;
+ /**
+ * \brief settings of the Tonemap
+ */
+ NodeTonemap *m_data;
- /**
- * \brief temporarily cache of the execution storage
- */
- AvgLogLum *m_cachedInstance;
+ /**
+ * \brief temporarily cache of the execution storage
+ */
+ AvgLogLum *m_cachedInstance;
-public:
- TonemapOperation();
+ public:
+ TonemapOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- void *initializeTileData(rcti *rect);
- void deinitializeTileData(rcti *rect, void *data);
+ void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void setData(NodeTonemap *data) { this->m_data = data; }
+ void setData(NodeTonemap *data)
+ {
+ this->m_data = data;
+ }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
};
/**
@@ -87,11 +92,11 @@ public:
*/
class PhotoreceptorTonemapOperation : public TonemapOperation {
-public:
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ public:
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
};
#endif
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
index dbea46a4d85..178a9b57cba 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.cpp
@@ -25,111 +25,111 @@
#include "BLI_math_color.h"
extern "C" {
-# include "BKE_movieclip.h"
-# include "BKE_node.h"
-# include "BKE_tracking.h"
+#include "BKE_movieclip.h"
+#include "BKE_node.h"
+#include "BKE_tracking.h"
}
TrackPositionOperation::TrackPositionOperation() : NodeOperation()
{
- this->addOutputSocket(COM_DT_VALUE);
- this->m_movieClip = NULL;
- this->m_framenumber = 0;
- this->m_trackingObjectName[0] = 0;
- this->m_trackName[0] = 0;
- this->m_axis = 0;
- this->m_position = CMP_TRACKPOS_ABSOLUTE;
- this->m_relativeFrame = 0;
- this->m_speed_output = false;
+ this->addOutputSocket(COM_DT_VALUE);
+ this->m_movieClip = NULL;
+ this->m_framenumber = 0;
+ this->m_trackingObjectName[0] = 0;
+ this->m_trackName[0] = 0;
+ this->m_axis = 0;
+ this->m_position = CMP_TRACKPOS_ABSOLUTE;
+ this->m_relativeFrame = 0;
+ this->m_speed_output = false;
}
void TrackPositionOperation::initExecution()
{
- MovieTracking *tracking = NULL;
- MovieClipUser user = {0};
- MovieTrackingObject *object;
-
- zero_v2(this->m_markerPos);
- zero_v2(this->m_relativePos);
-
- if (!this->m_movieClip)
- return;
-
- tracking = &this->m_movieClip->tracking;
-
- BKE_movieclip_user_set_frame(&user, this->m_framenumber);
- BKE_movieclip_get_size(this->m_movieClip, &user, &this->m_width, &this->m_height);
-
- object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
- if (object) {
- MovieTrackingTrack *track;
-
- track = BKE_tracking_track_get_named(tracking, object, this->m_trackName);
-
- if (track) {
- MovieTrackingMarker *marker;
- int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip, this->m_framenumber);
-
- marker = BKE_tracking_marker_get(track, clip_framenr);
-
- copy_v2_v2(this->m_markerPos, marker->pos);
-
- if (this->m_speed_output) {
- int relative_clip_framenr =
- BKE_movieclip_remap_scene_to_clip_frame(
- this->m_movieClip,
- this->m_relativeFrame);
-
- marker = BKE_tracking_marker_get_exact(track,
- relative_clip_framenr);
- if (marker != NULL && (marker->flag & MARKER_DISABLED) == 0) {
- copy_v2_v2(this->m_relativePos, marker->pos);
- }
- else {
- copy_v2_v2(this->m_relativePos, this->m_markerPos);
- }
- if (this->m_relativeFrame < this->m_framenumber) {
- swap_v2_v2(this->m_relativePos, this->m_markerPos);
- }
- }
- else if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
- int i;
-
- for (i = 0; i < track->markersnr; i++) {
- marker = &track->markers[i];
-
- if ((marker->flag & MARKER_DISABLED) == 0) {
- copy_v2_v2(this->m_relativePos, marker->pos);
-
- break;
- }
- }
- }
- else if (this->m_position == CMP_TRACKPOS_RELATIVE_FRAME) {
- int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
- this->m_relativeFrame);
-
- marker = BKE_tracking_marker_get(track, relative_clip_framenr);
- copy_v2_v2(this->m_relativePos, marker->pos);
- }
- }
- }
+ MovieTracking *tracking = NULL;
+ MovieClipUser user = {0};
+ MovieTrackingObject *object;
+
+ zero_v2(this->m_markerPos);
+ zero_v2(this->m_relativePos);
+
+ if (!this->m_movieClip)
+ return;
+
+ tracking = &this->m_movieClip->tracking;
+
+ BKE_movieclip_user_set_frame(&user, this->m_framenumber);
+ BKE_movieclip_get_size(this->m_movieClip, &user, &this->m_width, &this->m_height);
+
+ object = BKE_tracking_object_get_named(tracking, this->m_trackingObjectName);
+ if (object) {
+ MovieTrackingTrack *track;
+
+ track = BKE_tracking_track_get_named(tracking, object, this->m_trackName);
+
+ if (track) {
+ MovieTrackingMarker *marker;
+ int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
+ this->m_framenumber);
+
+ marker = BKE_tracking_marker_get(track, clip_framenr);
+
+ copy_v2_v2(this->m_markerPos, marker->pos);
+
+ if (this->m_speed_output) {
+ int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
+ this->m_relativeFrame);
+
+ marker = BKE_tracking_marker_get_exact(track, relative_clip_framenr);
+ if (marker != NULL && (marker->flag & MARKER_DISABLED) == 0) {
+ copy_v2_v2(this->m_relativePos, marker->pos);
+ }
+ else {
+ copy_v2_v2(this->m_relativePos, this->m_markerPos);
+ }
+ if (this->m_relativeFrame < this->m_framenumber) {
+ swap_v2_v2(this->m_relativePos, this->m_markerPos);
+ }
+ }
+ else if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
+ int i;
+
+ for (i = 0; i < track->markersnr; i++) {
+ marker = &track->markers[i];
+
+ if ((marker->flag & MARKER_DISABLED) == 0) {
+ copy_v2_v2(this->m_relativePos, marker->pos);
+
+ break;
+ }
+ }
+ }
+ else if (this->m_position == CMP_TRACKPOS_RELATIVE_FRAME) {
+ int relative_clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(this->m_movieClip,
+ this->m_relativeFrame);
+
+ marker = BKE_tracking_marker_get(track, relative_clip_framenr);
+ copy_v2_v2(this->m_relativePos, marker->pos);
+ }
+ }
+ }
}
void TrackPositionOperation::executePixelSampled(float output[4],
- float /*x*/, float /*y*/,
+ float /*x*/,
+ float /*y*/,
PixelSampler /*sampler*/)
{
- output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
+ output[0] = this->m_markerPos[this->m_axis] - this->m_relativePos[this->m_axis];
- if (this->m_axis == 0)
- output[0] *= this->m_width;
- else
- output[0] *= this->m_height;
+ if (this->m_axis == 0)
+ output[0] *= this->m_width;
+ else
+ output[0] *= this->m_height;
}
-void TrackPositionOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void TrackPositionOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- resolution[0] = preferredResolution[0];
- resolution[1] = preferredResolution[1];
+ resolution[0] = preferredResolution[0];
+ resolution[1] = preferredResolution[1];
}
diff --git a/source/blender/compositor/operations/COM_TrackPositionOperation.h b/source/blender/compositor/operations/COM_TrackPositionOperation.h
index 95d27c3a5e4..695e85f4fa3 100644
--- a/source/blender/compositor/operations/COM_TrackPositionOperation.h
+++ b/source/blender/compositor/operations/COM_TrackPositionOperation.h
@@ -16,7 +16,6 @@
* Copyright 2012, Blender Foundation.
*/
-
#ifndef __COM_TRACKPOSITIONOPERATION_H__
#define __COM_TRACKPOSITIONOPERATION_H__
@@ -34,42 +33,69 @@
* Class with implementation of green screen gradient rasterization
*/
class TrackPositionOperation : public NodeOperation {
-protected:
- MovieClip *m_movieClip;
- int m_framenumber;
- char m_trackingObjectName[64];
- char m_trackName[64];
- int m_axis;
- int m_position;
- int m_relativeFrame;
- bool m_speed_output;
+ protected:
+ MovieClip *m_movieClip;
+ int m_framenumber;
+ char m_trackingObjectName[64];
+ char m_trackName[64];
+ int m_axis;
+ int m_position;
+ int m_relativeFrame;
+ bool m_speed_output;
- int m_width, m_height;
- float m_markerPos[2];
- float m_relativePos[2];
+ int m_width, m_height;
+ float m_markerPos[2];
+ float m_relativePos[2];
- /**
- * Determine the output resolution. The resolution is retrieved from the Renderer
- */
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ /**
+ * Determine the output resolution. The resolution is retrieved from the Renderer
+ */
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-public:
- TrackPositionOperation();
+ public:
+ TrackPositionOperation();
- void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
- void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); }
- void setTrackName(char *track) { BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName)); }
- void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
- void setAxis(int value) {this->m_axis = value;}
- void setPosition(int value) {this->m_position = value;}
- void setRelativeFrame(int value) {this->m_relativeFrame = value;}
- void setSpeedOutput(bool speed_output) {this->m_speed_output = speed_output;}
+ void setMovieClip(MovieClip *clip)
+ {
+ this->m_movieClip = clip;
+ }
+ void setTrackingObject(char *object)
+ {
+ BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));
+ }
+ void setTrackName(char *track)
+ {
+ BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName));
+ }
+ void setFramenumber(int framenumber)
+ {
+ this->m_framenumber = framenumber;
+ }
+ void setAxis(int value)
+ {
+ this->m_axis = value;
+ }
+ void setPosition(int value)
+ {
+ this->m_position = value;
+ }
+ void setRelativeFrame(int value)
+ {
+ this->m_relativeFrame = value;
+ }
+ void setSpeedOutput(bool speed_output)
+ {
+ this->m_speed_output = speed_output;
+ }
- void initExecution();
+ void initExecution();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- bool isSetOperation() const { return true; }
+ bool isSetOperation() const
+ {
+ return true;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.cpp b/source/blender/compositor/operations/COM_TranslateOperation.cpp
index 3e331a75c8d..b45e6a2b6a1 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.cpp
+++ b/source/blender/compositor/operations/COM_TranslateOperation.cpp
@@ -20,59 +20,63 @@
TranslateOperation::TranslateOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
- this->m_isDeltaSet = false;
- this->m_factorX = 1.0f;
- this->m_factorY = 1.0f;
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
+ this->m_isDeltaSet = false;
+ this->m_factorX = 1.0f;
+ this->m_factorY = 1.0f;
}
void TranslateOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputXOperation = this->getInputSocketReader(1);
- this->m_inputYOperation = this->getInputSocketReader(2);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputXOperation = this->getInputSocketReader(1);
+ this->m_inputYOperation = this->getInputSocketReader(2);
}
void TranslateOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputXOperation = NULL;
- this->m_inputYOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputXOperation = NULL;
+ this->m_inputYOperation = NULL;
}
-
-void TranslateOperation::executePixelSampled(float output[4], float x, float y, PixelSampler /*sampler*/)
+void TranslateOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler /*sampler*/)
{
- ensureDelta();
+ ensureDelta();
- float originalXPos = x - this->getDeltaX();
- float originalYPos = y - this->getDeltaY();
+ float originalXPos = x - this->getDeltaX();
+ float originalYPos = y - this->getDeltaY();
- this->m_inputOperation->readSampled(output, originalXPos, originalYPos, COM_PS_BILINEAR);
+ this->m_inputOperation->readSampled(output, originalXPos, originalYPos, COM_PS_BILINEAR);
}
-bool TranslateOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool TranslateOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
+ rcti newInput;
- ensureDelta();
+ ensureDelta();
- newInput.xmin = input->xmin - this->getDeltaX();
- newInput.xmax = input->xmax - this->getDeltaX();
- newInput.ymin = input->ymin - this->getDeltaY();
- newInput.ymax = input->ymax - this->getDeltaY();
+ newInput.xmin = input->xmin - this->getDeltaX();
+ newInput.xmax = input->xmax - this->getDeltaX();
+ newInput.ymin = input->ymin - this->getDeltaY();
+ newInput.ymax = input->ymax - this->getDeltaY();
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void TranslateOperation::setFactorXY(float factorX, float factorY)
{
- m_factorX = factorX;
- m_factorY = factorY;
+ m_factorX = factorX;
+ m_factorY = factorY;
}
diff --git a/source/blender/compositor/operations/COM_TranslateOperation.h b/source/blender/compositor/operations/COM_TranslateOperation.h
index c8fffaae2d8..2d13813a86a 100644
--- a/source/blender/compositor/operations/COM_TranslateOperation.h
+++ b/source/blender/compositor/operations/COM_TranslateOperation.h
@@ -22,38 +22,48 @@
#include "COM_NodeOperation.h"
class TranslateOperation : public NodeOperation {
-private:
- SocketReader *m_inputOperation;
- SocketReader *m_inputXOperation;
- SocketReader *m_inputYOperation;
- float m_deltaX;
- float m_deltaY;
- bool m_isDeltaSet;
- float m_factorX;
- float m_factorY;
-public:
- TranslateOperation();
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-
- void initExecution();
- void deinitExecution();
-
- float getDeltaX() { return this->m_deltaX * this->m_factorX; }
- float getDeltaY() { return this->m_deltaY * this->m_factorY; }
-
- inline void ensureDelta() {
- if (!this->m_isDeltaSet) {
- float tempDelta[4];
- this->m_inputXOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
- this->m_deltaX = tempDelta[0];
- this->m_inputYOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
- this->m_deltaY = tempDelta[0];
- this->m_isDeltaSet = true;
- }
- }
-
- void setFactorXY(float factorX, float factorY);
+ private:
+ SocketReader *m_inputOperation;
+ SocketReader *m_inputXOperation;
+ SocketReader *m_inputYOperation;
+ float m_deltaX;
+ float m_deltaY;
+ bool m_isDeltaSet;
+ float m_factorX;
+ float m_factorY;
+
+ public:
+ TranslateOperation();
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ void initExecution();
+ void deinitExecution();
+
+ float getDeltaX()
+ {
+ return this->m_deltaX * this->m_factorX;
+ }
+ float getDeltaY()
+ {
+ return this->m_deltaY * this->m_factorY;
+ }
+
+ inline void ensureDelta()
+ {
+ if (!this->m_isDeltaSet) {
+ float tempDelta[4];
+ this->m_inputXOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
+ this->m_deltaX = tempDelta[0];
+ this->m_inputYOperation->readSampled(tempDelta, 0, 0, COM_PS_NEAREST);
+ this->m_deltaY = tempDelta[0];
+ this->m_isDeltaSet = true;
+ }
+ }
+
+ void setFactorXY(float factorX, float factorY);
};
#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 1af4c107419..8b0335754aa 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -21,354 +21,363 @@
#include "COM_OpenCLDevice.h"
extern "C" {
-# include "RE_pipeline.h"
+#include "RE_pipeline.h"
}
VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
- this->addInputSocket(COM_DT_VALUE); // radius
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image.
+ this->addInputSocket(COM_DT_VALUE); // radius
#ifdef COM_DEFOCUS_SEARCH
- this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure.
+ this->addInputSocket(COM_DT_COLOR,
+ COM_SC_NO_RESIZE); // inverse search radius optimization structure.
#endif
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->setOpenCL(true);
-
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputSizeProgram = NULL;
- this->m_maxBlur = 32.0f;
- this->m_threshold = 1.0f;
- this->m_do_size_scale = false;
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->setOpenCL(true);
+
+ this->m_inputProgram = NULL;
+ this->m_inputBokehProgram = NULL;
+ this->m_inputSizeProgram = NULL;
+ this->m_maxBlur = 32.0f;
+ this->m_threshold = 1.0f;
+ this->m_do_size_scale = false;
#ifdef COM_DEFOCUS_SEARCH
- this->m_inputSearchProgram = NULL;
+ this->m_inputSearchProgram = NULL;
#endif
}
-
void VariableSizeBokehBlurOperation::initExecution()
{
- this->m_inputProgram = getInputSocketReader(0);
- this->m_inputBokehProgram = getInputSocketReader(1);
- this->m_inputSizeProgram = getInputSocketReader(2);
+ this->m_inputProgram = getInputSocketReader(0);
+ this->m_inputBokehProgram = getInputSocketReader(1);
+ this->m_inputSizeProgram = getInputSocketReader(2);
#ifdef COM_DEFOCUS_SEARCH
- this->m_inputSearchProgram = getInputSocketReader(3);
+ this->m_inputSearchProgram = getInputSocketReader(3);
#endif
- QualityStepHelper::initExecution(COM_QH_INCREASE);
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
}
struct VariableSizeBokehBlurTileData {
- MemoryBuffer *color;
- MemoryBuffer *bokeh;
- MemoryBuffer *size;
- int maxBlurScalar;
+ MemoryBuffer *color;
+ MemoryBuffer *bokeh;
+ MemoryBuffer *size;
+ int maxBlurScalar;
};
void *VariableSizeBokehBlurOperation::initializeTileData(rcti *rect)
{
- VariableSizeBokehBlurTileData *data = new VariableSizeBokehBlurTileData();
- data->color = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
- data->bokeh = (MemoryBuffer *)this->m_inputBokehProgram->initializeTileData(rect);
- data->size = (MemoryBuffer *)this->m_inputSizeProgram->initializeTileData(rect);
-
+ VariableSizeBokehBlurTileData *data = new VariableSizeBokehBlurTileData();
+ data->color = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
+ data->bokeh = (MemoryBuffer *)this->m_inputBokehProgram->initializeTileData(rect);
+ data->size = (MemoryBuffer *)this->m_inputSizeProgram->initializeTileData(rect);
- rcti rect2;
- this->determineDependingAreaOfInterest(rect, (ReadBufferOperation *)this->m_inputSizeProgram, &rect2);
+ rcti rect2;
+ this->determineDependingAreaOfInterest(
+ rect, (ReadBufferOperation *)this->m_inputSizeProgram, &rect2);
- const float max_dim = max(m_width, m_height);
- const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
+ const float max_dim = max(m_width, m_height);
+ const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
- data->maxBlurScalar = (int)(data->size->getMaximumValue(&rect2) * scalar);
- CLAMP(data->maxBlurScalar, 1.0f, this->m_maxBlur);
- return data;
+ data->maxBlurScalar = (int)(data->size->getMaximumValue(&rect2) * scalar);
+ CLAMP(data->maxBlurScalar, 1.0f, this->m_maxBlur);
+ return data;
}
void VariableSizeBokehBlurOperation::deinitializeTileData(rcti * /*rect*/, void *data)
{
- VariableSizeBokehBlurTileData *result = (VariableSizeBokehBlurTileData *)data;
- delete result;
+ VariableSizeBokehBlurTileData *result = (VariableSizeBokehBlurTileData *)data;
+ delete result;
}
void VariableSizeBokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- VariableSizeBokehBlurTileData *tileData = (VariableSizeBokehBlurTileData *)data;
- MemoryBuffer *inputProgramBuffer = tileData->color;
- MemoryBuffer *inputBokehBuffer = tileData->bokeh;
- MemoryBuffer *inputSizeBuffer = tileData->size;
- float *inputSizeFloatBuffer = inputSizeBuffer->getBuffer();
- float *inputProgramFloatBuffer = inputProgramBuffer->getBuffer();
- float readColor[4];
- float bokeh[4];
- float tempSize[4];
- float multiplier_accum[4];
- float color_accum[4];
-
- const float max_dim = max(m_width, m_height);
- const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
- int maxBlurScalar = tileData->maxBlurScalar;
-
- BLI_assert(inputBokehBuffer->getWidth() == COM_BLUR_BOKEH_PIXELS);
- BLI_assert(inputBokehBuffer->getHeight() == COM_BLUR_BOKEH_PIXELS);
+ VariableSizeBokehBlurTileData *tileData = (VariableSizeBokehBlurTileData *)data;
+ MemoryBuffer *inputProgramBuffer = tileData->color;
+ MemoryBuffer *inputBokehBuffer = tileData->bokeh;
+ MemoryBuffer *inputSizeBuffer = tileData->size;
+ float *inputSizeFloatBuffer = inputSizeBuffer->getBuffer();
+ float *inputProgramFloatBuffer = inputProgramBuffer->getBuffer();
+ float readColor[4];
+ float bokeh[4];
+ float tempSize[4];
+ float multiplier_accum[4];
+ float color_accum[4];
+
+ const float max_dim = max(m_width, m_height);
+ const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
+ int maxBlurScalar = tileData->maxBlurScalar;
+
+ BLI_assert(inputBokehBuffer->getWidth() == COM_BLUR_BOKEH_PIXELS);
+ BLI_assert(inputBokehBuffer->getHeight() == COM_BLUR_BOKEH_PIXELS);
#ifdef COM_DEFOCUS_SEARCH
- float search[4];
- this->m_inputSearchProgram->read(search, x / InverseSearchRadiusOperation::DIVIDER, y / InverseSearchRadiusOperation::DIVIDER, NULL);
- int minx = search[0];
- int miny = search[1];
- int maxx = search[2];
- int maxy = search[3];
+ float search[4];
+ this->m_inputSearchProgram->read(search,
+ x / InverseSearchRadiusOperation::DIVIDER,
+ y / InverseSearchRadiusOperation::DIVIDER,
+ NULL);
+ int minx = search[0];
+ int miny = search[1];
+ int maxx = search[2];
+ int maxy = search[3];
#else
- int minx = max(x - maxBlurScalar, 0);
- int miny = max(y - maxBlurScalar, 0);
- int maxx = min(x + maxBlurScalar, (int)m_width);
- int maxy = min(y + maxBlurScalar, (int)m_height);
+ int minx = max(x - maxBlurScalar, 0);
+ int miny = max(y - maxBlurScalar, 0);
+ int maxx = min(x + maxBlurScalar, (int)m_width);
+ int maxy = min(y + maxBlurScalar, (int)m_height);
#endif
- {
- inputSizeBuffer->readNoCheck(tempSize, x, y);
- inputProgramBuffer->readNoCheck(readColor, x, y);
-
- copy_v4_v4(color_accum, readColor);
- copy_v4_fl(multiplier_accum, 1.0f);
- float size_center = tempSize[0] * scalar;
-
- const int addXStepValue = QualityStepHelper::getStep();
- const int addYStepValue = addXStepValue;
- const int addXStepColor = addXStepValue * COM_NUM_CHANNELS_COLOR;
-
- if (size_center > this->m_threshold) {
- for (int ny = miny; ny < maxy; ny += addYStepValue) {
- float dy = ny - y;
- int offsetValueNy = ny * inputSizeBuffer->getWidth();
- int offsetValueNxNy = offsetValueNy + (minx);
- int offsetColorNxNy = offsetValueNxNy * COM_NUM_CHANNELS_COLOR;
- for (int nx = minx; nx < maxx; nx += addXStepValue) {
- if (nx != x || ny != y) {
- float size = min(inputSizeFloatBuffer[offsetValueNxNy] * scalar, size_center);
- if (size > this->m_threshold) {
- float dx = nx - x;
- if (size > fabsf(dx) && size > fabsf(dy)) {
- float uv[2] = {
- (float)(COM_BLUR_BOKEH_PIXELS / 2) + (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1),
- (float)(COM_BLUR_BOKEH_PIXELS / 2) + (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1)};
- inputBokehBuffer->read(bokeh, uv[0], uv[1]);
- madd_v4_v4v4(color_accum, bokeh, &inputProgramFloatBuffer[offsetColorNxNy]);
- add_v4_v4(multiplier_accum, bokeh);
- }
- }
- }
- offsetColorNxNy += addXStepColor;
- offsetValueNxNy += addXStepValue; }
- }
- }
-
- output[0] = color_accum[0] / multiplier_accum[0];
- output[1] = color_accum[1] / multiplier_accum[1];
- output[2] = color_accum[2] / multiplier_accum[2];
- output[3] = color_accum[3] / multiplier_accum[3];
-
- /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */
- if ((size_center > this->m_threshold) &&
- (size_center < this->m_threshold * 2.0f))
- {
- /* factor from 0-1 */
- float fac = (size_center - this->m_threshold) / this->m_threshold;
- interp_v4_v4v4(output, readColor, output, fac);
- }
- }
-
+ {
+ inputSizeBuffer->readNoCheck(tempSize, x, y);
+ inputProgramBuffer->readNoCheck(readColor, x, y);
+
+ copy_v4_v4(color_accum, readColor);
+ copy_v4_fl(multiplier_accum, 1.0f);
+ float size_center = tempSize[0] * scalar;
+
+ const int addXStepValue = QualityStepHelper::getStep();
+ const int addYStepValue = addXStepValue;
+ const int addXStepColor = addXStepValue * COM_NUM_CHANNELS_COLOR;
+
+ if (size_center > this->m_threshold) {
+ for (int ny = miny; ny < maxy; ny += addYStepValue) {
+ float dy = ny - y;
+ int offsetValueNy = ny * inputSizeBuffer->getWidth();
+ int offsetValueNxNy = offsetValueNy + (minx);
+ int offsetColorNxNy = offsetValueNxNy * COM_NUM_CHANNELS_COLOR;
+ for (int nx = minx; nx < maxx; nx += addXStepValue) {
+ if (nx != x || ny != y) {
+ float size = min(inputSizeFloatBuffer[offsetValueNxNy] * scalar, size_center);
+ if (size > this->m_threshold) {
+ float dx = nx - x;
+ if (size > fabsf(dx) && size > fabsf(dy)) {
+ float uv[2] = {(float)(COM_BLUR_BOKEH_PIXELS / 2) +
+ (dx / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1),
+ (float)(COM_BLUR_BOKEH_PIXELS / 2) +
+ (dy / size) * (float)((COM_BLUR_BOKEH_PIXELS / 2) - 1)};
+ inputBokehBuffer->read(bokeh, uv[0], uv[1]);
+ madd_v4_v4v4(color_accum, bokeh, &inputProgramFloatBuffer[offsetColorNxNy]);
+ add_v4_v4(multiplier_accum, bokeh);
+ }
+ }
+ }
+ offsetColorNxNy += addXStepColor;
+ offsetValueNxNy += addXStepValue;
+ }
+ }
+ }
+
+ output[0] = color_accum[0] / multiplier_accum[0];
+ output[1] = color_accum[1] / multiplier_accum[1];
+ output[2] = color_accum[2] / multiplier_accum[2];
+ output[3] = color_accum[3] / multiplier_accum[3];
+
+ /* blend in out values over the threshold, otherwise we get sharp, ugly transitions */
+ if ((size_center > this->m_threshold) && (size_center < this->m_threshold * 2.0f)) {
+ /* factor from 0-1 */
+ float fac = (size_center - this->m_threshold) / this->m_threshold;
+ interp_v4_v4v4(output, readColor, output, fac);
+ }
+ }
}
void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device,
- MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer,
- MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp,
- list<cl_kernel> * /*clKernelsToCleanUp*/)
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> * /*clKernelsToCleanUp*/)
{
- cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL);
-
- cl_int step = this->getStep();
- cl_int maxBlur;
- cl_float threshold = this->m_threshold;
-
- MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(inputMemoryBuffers);
-
- const float max_dim = max(m_width, m_height);
- cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
-
- maxBlur = (cl_int)min_ff(sizeMemoryBuffer->getMaximumValue() * scalar,
- (float)this->m_maxBlur);
-
- device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
- device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
- device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram);
- device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 3, clOutputBuffer);
- device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 5, outputMemoryBuffer);
- clSetKernelArg(defocusKernel, 6, sizeof(cl_int), &step);
- clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &maxBlur);
- clSetKernelArg(defocusKernel, 8, sizeof(cl_float), &threshold);
- clSetKernelArg(defocusKernel, 9, sizeof(cl_float), &scalar);
- device->COM_clAttachSizeToKernelParameter(defocusKernel, 10, this);
-
- device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 11, this);
+ cl_kernel defocusKernel = device->COM_clCreateKernel("defocusKernel", NULL);
+
+ cl_int step = this->getStep();
+ cl_int maxBlur;
+ cl_float threshold = this->m_threshold;
+
+ MemoryBuffer *sizeMemoryBuffer = this->m_inputSizeProgram->getInputMemoryBuffer(
+ inputMemoryBuffers);
+
+ const float max_dim = max(m_width, m_height);
+ cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
+
+ maxBlur = (cl_int)min_ff(sizeMemoryBuffer->getMaximumValue() * scalar, (float)this->m_maxBlur);
+
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram);
+ device->COM_clAttachMemoryBufferToKernelParameter(
+ defocusKernel, 2, 4, clMemToCleanUp, inputMemoryBuffers, this->m_inputSizeProgram);
+ device->COM_clAttachOutputMemoryBufferToKernelParameter(defocusKernel, 3, clOutputBuffer);
+ device->COM_clAttachMemoryBufferOffsetToKernelParameter(defocusKernel, 5, outputMemoryBuffer);
+ clSetKernelArg(defocusKernel, 6, sizeof(cl_int), &step);
+ clSetKernelArg(defocusKernel, 7, sizeof(cl_int), &maxBlur);
+ clSetKernelArg(defocusKernel, 8, sizeof(cl_float), &threshold);
+ clSetKernelArg(defocusKernel, 9, sizeof(cl_float), &scalar);
+ device->COM_clAttachSizeToKernelParameter(defocusKernel, 10, this);
+
+ device->COM_clEnqueueRange(defocusKernel, outputMemoryBuffer, 11, this);
}
void VariableSizeBokehBlurOperation::deinitExecution()
{
- this->m_inputProgram = NULL;
- this->m_inputBokehProgram = NULL;
- this->m_inputSizeProgram = NULL;
+ this->m_inputProgram = NULL;
+ this->m_inputBokehProgram = NULL;
+ this->m_inputSizeProgram = NULL;
#ifdef COM_DEFOCUS_SEARCH
- this->m_inputSearchProgram = NULL;
+ this->m_inputSearchProgram = NULL;
#endif
}
-bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newInput;
- rcti bokehInput;
-
- const float max_dim = max(m_width, m_height);
- const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
- int maxBlurScalar = this->m_maxBlur * scalar;
-
- newInput.xmax = input->xmax + maxBlurScalar + 2;
- newInput.xmin = input->xmin - maxBlurScalar + 2;
- newInput.ymax = input->ymax + maxBlurScalar - 2;
- newInput.ymin = input->ymin - maxBlurScalar - 2;
- bokehInput.xmax = COM_BLUR_BOKEH_PIXELS;
- bokehInput.xmin = 0;
- bokehInput.ymax = COM_BLUR_BOKEH_PIXELS;
- bokehInput.ymin = 0;
-
-
- NodeOperation *operation = getInputOperation(2);
- if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
- return true;
- }
- operation = getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output) ) {
- return true;
- }
+ rcti newInput;
+ rcti bokehInput;
+
+ const float max_dim = max(m_width, m_height);
+ const float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f;
+ int maxBlurScalar = this->m_maxBlur * scalar;
+
+ newInput.xmax = input->xmax + maxBlurScalar + 2;
+ newInput.xmin = input->xmin - maxBlurScalar + 2;
+ newInput.ymax = input->ymax + maxBlurScalar - 2;
+ newInput.ymin = input->ymin - maxBlurScalar - 2;
+ bokehInput.xmax = COM_BLUR_BOKEH_PIXELS;
+ bokehInput.xmin = 0;
+ bokehInput.ymax = COM_BLUR_BOKEH_PIXELS;
+ bokehInput.ymin = 0;
+
+ NodeOperation *operation = getInputOperation(2);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
+ return true;
+ }
+ operation = getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&bokehInput, readOperation, output)) {
+ return true;
+ }
#ifdef COM_DEFOCUS_SEARCH
- rcti searchInput;
- searchInput.xmax = (input->xmax / InverseSearchRadiusOperation::DIVIDER) + 1;
- searchInput.xmin = (input->xmin / InverseSearchRadiusOperation::DIVIDER) - 1;
- searchInput.ymax = (input->ymax / InverseSearchRadiusOperation::DIVIDER) + 1;
- searchInput.ymin = (input->ymin / InverseSearchRadiusOperation::DIVIDER) - 1;
- operation = getInputOperation(3);
- if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) {
- return true;
- }
+ rcti searchInput;
+ searchInput.xmax = (input->xmax / InverseSearchRadiusOperation::DIVIDER) + 1;
+ searchInput.xmin = (input->xmin / InverseSearchRadiusOperation::DIVIDER) - 1;
+ searchInput.ymax = (input->ymax / InverseSearchRadiusOperation::DIVIDER) + 1;
+ searchInput.ymin = (input->ymin / InverseSearchRadiusOperation::DIVIDER) - 1;
+ operation = getInputOperation(3);
+ if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output)) {
+ return true;
+ }
#endif
- operation = getInputOperation(0);
- if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) {
- return true;
- }
- return false;
+ operation = getInputOperation(0);
+ if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output)) {
+ return true;
+ }
+ return false;
}
#ifdef COM_DEFOCUS_SEARCH
// InverseSearchRadiusOperation
InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius
- this->addOutputSocket(COM_DT_COLOR);
- this->setComplex(true);
- this->m_inputRadius = NULL;
+ this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setComplex(true);
+ this->m_inputRadius = NULL;
}
void InverseSearchRadiusOperation::initExecution()
{
- this->m_inputRadius = this->getInputSocketReader(0);
+ this->m_inputRadius = this->getInputSocketReader(0);
}
void *InverseSearchRadiusOperation::initializeTileData(rcti *rect)
{
- MemoryBuffer *data = new MemoryBuffer(COM_DT_COLOR, rect);
- float *buffer = data->getBuffer();
- int x, y;
- int width = this->m_inputRadius->getWidth();
- int height = this->m_inputRadius->getHeight();
- float temp[4];
- int offset = 0;
- for (y = rect->ymin; y < rect->ymax ; y++) {
- for (x = rect->xmin; x < rect->xmax ; x++) {
- int rx = x * DIVIDER;
- int ry = y * DIVIDER;
- buffer[offset] = MAX2(rx - m_maxBlur, 0);
- buffer[offset + 1] = MAX2(ry - m_maxBlur, 0);
- buffer[offset + 2] = MIN2(rx + DIVIDER + m_maxBlur, width);
- buffer[offset + 3] = MIN2(ry + DIVIDER + m_maxBlur, height);
- offset += 4;
- }
- }
-// for (x = rect->xmin; x < rect->xmax ; x++) {
-// for (y = rect->ymin; y < rect->ymax ; y++) {
-// int rx = x * DIVIDER;
-// int ry = y * DIVIDER;
-// float radius = 0.0f;
-// float maxx = x;
-// float maxy = y;
-
-// for (int x2 = 0 ; x2 < DIVIDER ; x2 ++) {
-// for (int y2 = 0 ; y2 < DIVIDER ; y2 ++) {
-// this->m_inputRadius->read(temp, rx+x2, ry+y2, COM_PS_NEAREST);
-// if (radius < temp[0]) {
-// radius = temp[0];
-// maxx = x2;
-// maxy = y2;
-// }
-// }
-// }
-// int impactRadius = ceil(radius / DIVIDER);
-// for (int x2 = x - impactRadius ; x2 < x + impactRadius ; x2 ++) {
-// for (int y2 = y - impactRadius ; y2 < y + impactRadius ; y2 ++) {
-// data->read(temp, x2, y2);
-// temp[0] = MIN2(temp[0], maxx);
-// temp[1] = MIN2(temp[1], maxy);
-// temp[2] = MAX2(temp[2], maxx);
-// temp[3] = MAX2(temp[3], maxy);
-// data->writePixel(x2, y2, temp);
-// }
-// }
-// }
-// }
- return data;
+ MemoryBuffer *data = new MemoryBuffer(COM_DT_COLOR, rect);
+ float *buffer = data->getBuffer();
+ int x, y;
+ int width = this->m_inputRadius->getWidth();
+ int height = this->m_inputRadius->getHeight();
+ float temp[4];
+ int offset = 0;
+ for (y = rect->ymin; y < rect->ymax; y++) {
+ for (x = rect->xmin; x < rect->xmax; x++) {
+ int rx = x * DIVIDER;
+ int ry = y * DIVIDER;
+ buffer[offset] = MAX2(rx - m_maxBlur, 0);
+ buffer[offset + 1] = MAX2(ry - m_maxBlur, 0);
+ buffer[offset + 2] = MIN2(rx + DIVIDER + m_maxBlur, width);
+ buffer[offset + 3] = MIN2(ry + DIVIDER + m_maxBlur, height);
+ offset += 4;
+ }
+ }
+ // for (x = rect->xmin; x < rect->xmax ; x++) {
+ // for (y = rect->ymin; y < rect->ymax ; y++) {
+ // int rx = x * DIVIDER;
+ // int ry = y * DIVIDER;
+ // float radius = 0.0f;
+ // float maxx = x;
+ // float maxy = y;
+
+ // for (int x2 = 0 ; x2 < DIVIDER ; x2 ++) {
+ // for (int y2 = 0 ; y2 < DIVIDER ; y2 ++) {
+ // this->m_inputRadius->read(temp, rx+x2, ry+y2, COM_PS_NEAREST);
+ // if (radius < temp[0]) {
+ // radius = temp[0];
+ // maxx = x2;
+ // maxy = y2;
+ // }
+ // }
+ // }
+ // int impactRadius = ceil(radius / DIVIDER);
+ // for (int x2 = x - impactRadius ; x2 < x + impactRadius ; x2 ++) {
+ // for (int y2 = y - impactRadius ; y2 < y + impactRadius ; y2 ++) {
+ // data->read(temp, x2, y2);
+ // temp[0] = MIN2(temp[0], maxx);
+ // temp[1] = MIN2(temp[1], maxy);
+ // temp[2] = MAX2(temp[2], maxx);
+ // temp[3] = MAX2(temp[3], maxy);
+ // data->writePixel(x2, y2, temp);
+ // }
+ // }
+ // }
+ // }
+ return data;
}
void InverseSearchRadiusOperation::executePixelChunk(float output[4], int x, int y, void *data)
{
- MemoryBuffer *buffer = (MemoryBuffer *)data;
- buffer->readNoCheck(output, x, y);
+ MemoryBuffer *buffer = (MemoryBuffer *)data;
+ buffer->readNoCheck(output, x, y);
}
void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, void *data)
{
- if (data) {
- MemoryBuffer *mb = (MemoryBuffer *)data;
- delete mb;
- }
+ if (data) {
+ MemoryBuffer *mb = (MemoryBuffer *)data;
+ delete mb;
+ }
}
void InverseSearchRadiusOperation::deinitExecution()
{
- this->m_inputRadius = NULL;
+ this->m_inputRadius = NULL;
}
-void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- resolution[0] = resolution[0] / DIVIDER;
- resolution[1] = resolution[1] / DIVIDER;
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ resolution[0] = resolution[0] / DIVIDER;
+ resolution[1] = resolution[1] / DIVIDER;
}
-bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(
+ rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
- rcti newRect;
- newRect.ymin = input->ymin * DIVIDER - m_maxBlur;
- newRect.ymax = input->ymax * DIVIDER + m_maxBlur;
- newRect.xmin = input->xmin * DIVIDER - m_maxBlur;
- newRect.xmax = input->xmax * DIVIDER + m_maxBlur;
- return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output);
+ rcti newRect;
+ newRect.ymin = input->ymin * DIVIDER - m_maxBlur;
+ newRect.ymax = input->ymax * DIVIDER + m_maxBlur;
+ newRect.xmin = input->xmin * DIVIDER - m_maxBlur;
+ newRect.xmax = input->xmax * DIVIDER + m_maxBlur;
+ return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output);
}
#endif
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
index f586bf73dca..930bfd77943 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h
@@ -24,81 +24,103 @@
//#define COM_DEFOCUS_SEARCH
class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper {
-private:
- int m_maxBlur;
- float m_threshold;
- bool m_do_size_scale; /* scale size, matching 'BokehBlurNode' */
- SocketReader *m_inputProgram;
- SocketReader *m_inputBokehProgram;
- SocketReader *m_inputSizeProgram;
+ private:
+ int m_maxBlur;
+ float m_threshold;
+ bool m_do_size_scale; /* scale size, matching 'BokehBlurNode' */
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputBokehProgram;
+ SocketReader *m_inputSizeProgram;
#ifdef COM_DEFOCUS_SEARCH
- SocketReader *m_inputSearchProgram;
+ SocketReader *m_inputSearchProgram;
#endif
-public:
- VariableSizeBokehBlurOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
-
- void *initializeTileData(rcti *rect);
-
- void deinitializeTileData(rcti *rect, void *data);
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-
- void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
-
- void setThreshold(float threshold) { this->m_threshold = threshold; }
-
- void setDoScaleSize(bool scale_size) { this->m_do_size_scale = scale_size; }
-
- void executeOpenCL(OpenCLDevice *device, MemoryBuffer *outputMemoryBuffer, cl_mem clOutputBuffer, MemoryBuffer **inputMemoryBuffers, list<cl_mem> *clMemToCleanUp, list<cl_kernel> *clKernelsToCleanUp);
+ public:
+ VariableSizeBokehBlurOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ void *initializeTileData(rcti *rect);
+
+ void deinitializeTileData(rcti *rect, void *data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+
+ void setMaxBlur(int maxRadius)
+ {
+ this->m_maxBlur = maxRadius;
+ }
+
+ void setThreshold(float threshold)
+ {
+ this->m_threshold = threshold;
+ }
+
+ void setDoScaleSize(bool scale_size)
+ {
+ this->m_do_size_scale = scale_size;
+ }
+
+ void executeOpenCL(OpenCLDevice *device,
+ MemoryBuffer *outputMemoryBuffer,
+ cl_mem clOutputBuffer,
+ MemoryBuffer **inputMemoryBuffers,
+ list<cl_mem> *clMemToCleanUp,
+ list<cl_kernel> *clKernelsToCleanUp);
};
#ifdef COM_DEFOCUS_SEARCH
class InverseSearchRadiusOperation : public NodeOperation {
-private:
- int m_maxBlur;
- SocketReader *m_inputRadius;
-public:
- static const int DIVIDER = 4;
-
- InverseSearchRadiusOperation();
-
- /**
- * the inner loop of this program
- */
- void executePixelChunk(float output[4], int x, int y, void *data);
-
- /**
- * Initialize the execution
- */
- void initExecution();
- void *initializeTileData(rcti *rect);
- void deinitializeTileData(rcti *rect, void *data);
-
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
-
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
-
- void setMaxBlur(int maxRadius) { this->m_maxBlur = maxRadius; }
+ private:
+ int m_maxBlur;
+ SocketReader *m_inputRadius;
+
+ public:
+ static const int DIVIDER = 4;
+
+ InverseSearchRadiusOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelChunk(float output[4], int x, int y, void *data);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+ void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+
+ void setMaxBlur(int maxRadius)
+ {
+ this->m_maxBlur = maxRadius;
+ }
};
#endif
#endif
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 6e408d9860d..26e688e1c97 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -24,441 +24,470 @@ extern "C" {
}
#include "COM_VectorBlurOperation.h"
-
/* Defined */
#define PASS_VECTOR_MAX 10000.0f
/* Forward declarations */
struct DrawBufPixel;
struct ZSpan;
-void zbuf_accumulate_vecblur(
- NodeBlurData *nbd, int xsize, int ysize, float *newrect,
- const float *imgrect, float *vecbufrect, const float *zbufrect);
+void zbuf_accumulate_vecblur(NodeBlurData *nbd,
+ int xsize,
+ int ysize,
+ float *newrect,
+ const float *imgrect,
+ float *vecbufrect,
+ const float *zbufrect);
void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop);
void zbuf_free_span(ZSpan *zspan);
void antialias_tagbuf(int xsize, int ysize, char *rectmove);
-
/* VectorBlurOperation */
VectorBlurOperation::VectorBlurOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE); // ZBUF
- this->addInputSocket(COM_DT_COLOR); //SPEED
- this->addOutputSocket(COM_DT_COLOR);
- this->m_settings = NULL;
- this->m_cachedInstance = NULL;
- this->m_inputImageProgram = NULL;
- this->m_inputSpeedProgram = NULL;
- this->m_inputZProgram = NULL;
- setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE); // ZBUF
+ this->addInputSocket(COM_DT_COLOR); //SPEED
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_settings = NULL;
+ this->m_cachedInstance = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputSpeedProgram = NULL;
+ this->m_inputZProgram = NULL;
+ setComplex(true);
}
void VectorBlurOperation::initExecution()
{
- initMutex();
- this->m_inputImageProgram = getInputSocketReader(0);
- this->m_inputZProgram = getInputSocketReader(1);
- this->m_inputSpeedProgram = getInputSocketReader(2);
- this->m_cachedInstance = NULL;
- QualityStepHelper::initExecution(COM_QH_INCREASE);
-
+ initMutex();
+ this->m_inputImageProgram = getInputSocketReader(0);
+ this->m_inputZProgram = getInputSocketReader(1);
+ this->m_inputSpeedProgram = getInputSocketReader(2);
+ this->m_cachedInstance = NULL;
+ QualityStepHelper::initExecution(COM_QH_INCREASE);
}
void VectorBlurOperation::executePixel(float output[4], int x, int y, void *data)
{
- float *buffer = (float *)data;
- int index = (y * this->getWidth() + x) * COM_NUM_CHANNELS_COLOR;
- copy_v4_v4(output, &buffer[index]);
+ float *buffer = (float *)data;
+ int index = (y * this->getWidth() + x) * COM_NUM_CHANNELS_COLOR;
+ copy_v4_v4(output, &buffer[index]);
}
void VectorBlurOperation::deinitExecution()
{
- deinitMutex();
- this->m_inputImageProgram = NULL;
- this->m_inputSpeedProgram = NULL;
- this->m_inputZProgram = NULL;
- if (this->m_cachedInstance) {
- MEM_freeN(this->m_cachedInstance);
- this->m_cachedInstance = NULL;
- }
+ deinitMutex();
+ this->m_inputImageProgram = NULL;
+ this->m_inputSpeedProgram = NULL;
+ this->m_inputZProgram = NULL;
+ if (this->m_cachedInstance) {
+ MEM_freeN(this->m_cachedInstance);
+ this->m_cachedInstance = NULL;
+ }
}
void *VectorBlurOperation::initializeTileData(rcti *rect)
{
- if (this->m_cachedInstance) {
- return this->m_cachedInstance;
- }
-
- lockMutex();
- if (this->m_cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
- MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect);
- MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect);
- float *data = (float *)MEM_dupallocN(tile->getBuffer());
- this->generateVectorBlur(data, tile, speed, z);
- this->m_cachedInstance = data;
- }
- unlockMutex();
- return this->m_cachedInstance;
+ if (this->m_cachedInstance) {
+ return this->m_cachedInstance;
+ }
+
+ lockMutex();
+ if (this->m_cachedInstance == NULL) {
+ MemoryBuffer *tile = (MemoryBuffer *)this->m_inputImageProgram->initializeTileData(rect);
+ MemoryBuffer *speed = (MemoryBuffer *)this->m_inputSpeedProgram->initializeTileData(rect);
+ MemoryBuffer *z = (MemoryBuffer *)this->m_inputZProgram->initializeTileData(rect);
+ float *data = (float *)MEM_dupallocN(tile->getBuffer());
+ this->generateVectorBlur(data, tile, speed, z);
+ this->m_cachedInstance = data;
+ }
+ unlockMutex();
+ return this->m_cachedInstance;
}
-bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/, ReadBufferOperation *readOperation, rcti *output)
+bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- if (this->m_cachedInstance == NULL) {
- rcti newInput;
- newInput.xmax = this->getWidth();
- newInput.xmin = 0;
- newInput.ymax = this->getHeight();
- newInput.ymin = 0;
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
- }
- else {
- return false;
- }
+ if (this->m_cachedInstance == NULL) {
+ rcti newInput;
+ newInput.xmax = this->getWidth();
+ newInput.xmin = 0;
+ newInput.ymax = this->getHeight();
+ newInput.ymin = 0;
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ }
+ else {
+ return false;
+ }
}
-void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputImage, MemoryBuffer *inputSpeed, MemoryBuffer *inputZ)
+void VectorBlurOperation::generateVectorBlur(float *data,
+ MemoryBuffer *inputImage,
+ MemoryBuffer *inputSpeed,
+ MemoryBuffer *inputZ)
{
- NodeBlurData blurdata;
- blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep();
- blurdata.maxspeed = this->m_settings->maxspeed;
- blurdata.minspeed = this->m_settings->minspeed;
- blurdata.curved = this->m_settings->curved;
- blurdata.fac = this->m_settings->fac;
- zbuf_accumulate_vecblur(&blurdata, this->getWidth(), this->getHeight(), data, inputImage->getBuffer(), inputSpeed->getBuffer(), inputZ->getBuffer());
- return;
+ NodeBlurData blurdata;
+ blurdata.samples = this->m_settings->samples / QualityStepHelper::getStep();
+ blurdata.maxspeed = this->m_settings->maxspeed;
+ blurdata.minspeed = this->m_settings->minspeed;
+ blurdata.curved = this->m_settings->curved;
+ blurdata.fac = this->m_settings->fac;
+ zbuf_accumulate_vecblur(&blurdata,
+ this->getWidth(),
+ this->getHeight(),
+ data,
+ inputImage->getBuffer(),
+ inputSpeed->getBuffer(),
+ inputZ->getBuffer());
+ return;
}
/* ****************** Spans ******************************* */
/* span fill in method, is also used to localize data for zbuffering */
typedef struct ZSpan {
- /* range for clipping */
- int rectx, recty;
+ /* range for clipping */
+ int rectx, recty;
- /* actual filled in range */
- int miny1, maxy1, miny2, maxy2;
- /* vertex pointers detect min/max range in */
- const float *minp1, *maxp1, *minp2, *maxp2;
- float *span1, *span2;
+ /* actual filled in range */
+ int miny1, maxy1, miny2, maxy2;
+ /* vertex pointers detect min/max range in */
+ const float *minp1, *maxp1, *minp2, *maxp2;
+ float *span1, *span2;
- /* transform from hoco to zbuf co */
- float zmulx, zmuly, zofsx, zofsy;
+ /* transform from hoco to zbuf co */
+ float zmulx, zmuly, zofsx, zofsy;
- int *rectz;
- DrawBufPixel *rectdraw;
- float clipcrop;
+ int *rectz;
+ DrawBufPixel *rectdraw;
+ float clipcrop;
} ZSpan;
/* each zbuffer has coordinates transformed to local rect coordinates, so we can simply clip */
void zbuf_alloc_span(ZSpan *zspan, int rectx, int recty, float clipcrop)
{
- memset(zspan, 0, sizeof(ZSpan));
+ memset(zspan, 0, sizeof(ZSpan));
- zspan->rectx = rectx;
- zspan->recty = recty;
+ zspan->rectx = rectx;
+ zspan->recty = recty;
- zspan->span1 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
- zspan->span2 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
+ zspan->span1 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
+ zspan->span2 = (float *)MEM_mallocN(recty * sizeof(float), "zspan");
- zspan->clipcrop = clipcrop;
+ zspan->clipcrop = clipcrop;
}
void zbuf_free_span(ZSpan *zspan)
{
- if (zspan) {
- if (zspan->span1) MEM_freeN(zspan->span1);
- if (zspan->span2) MEM_freeN(zspan->span2);
- zspan->span1 = zspan->span2 = NULL;
- }
+ if (zspan) {
+ if (zspan->span1)
+ MEM_freeN(zspan->span1);
+ if (zspan->span2)
+ MEM_freeN(zspan->span2);
+ zspan->span1 = zspan->span2 = NULL;
+ }
}
/* reset range for clipping */
static void zbuf_init_span(ZSpan *zspan)
{
- zspan->miny1 = zspan->miny2 = zspan->recty + 1;
- zspan->maxy1 = zspan->maxy2 = -1;
- zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL;
+ zspan->miny1 = zspan->miny2 = zspan->recty + 1;
+ zspan->maxy1 = zspan->maxy2 = -1;
+ zspan->minp1 = zspan->maxp1 = zspan->minp2 = zspan->maxp2 = NULL;
}
static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
{
- const float *minv, *maxv;
- float *span;
- float xx1, dx0, xs0;
- int y, my0, my2;
-
- if (v1[1] < v2[1]) {
- minv = v1; maxv = v2;
- }
- else {
- minv = v2; maxv = v1;
- }
-
- my0 = ceil(minv[1]);
- my2 = floor(maxv[1]);
-
- if (my2 < 0 || my0 >= zspan->recty) return;
-
- /* clip top */
- if (my2 >= zspan->recty) my2 = zspan->recty - 1;
- /* clip bottom */
- if (my0 < 0) my0 = 0;
-
- if (my0 > my2) return;
- /* if (my0>my2) should still fill in, that way we get spans that skip nicely */
-
- xx1 = maxv[1] - minv[1];
- if (xx1 > FLT_EPSILON) {
- dx0 = (minv[0] - maxv[0]) / xx1;
- xs0 = dx0 * (minv[1] - my2) + minv[0];
- }
- else {
- dx0 = 0.0f;
- xs0 = min_ff(minv[0], maxv[0]);
- }
-
- /* empty span */
- if (zspan->maxp1 == NULL) {
- span = zspan->span1;
- }
- else { /* does it complete left span? */
- if (maxv == zspan->minp1 || minv == zspan->maxp1) {
- span = zspan->span1;
- }
- else {
- span = zspan->span2;
- }
- }
-
- if (span == zspan->span1) {
-// printf("left span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) {
- zspan->minp1 = minv;
- }
- if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
- zspan->maxp1 = maxv;
- }
- if (my0 < zspan->miny1) zspan->miny1 = my0;
- if (my2 > zspan->maxy1) zspan->maxy1 = my2;
- }
- else {
-// printf("right span my0 %d my2 %d\n", my0, my2);
- if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) {
- zspan->minp2 = minv;
- }
- if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
- zspan->maxp2 = maxv;
- }
- if (my0 < zspan->miny2) zspan->miny2 = my0;
- if (my2 > zspan->maxy2) zspan->maxy2 = my2;
- }
-
- for (y = my2; y >= my0; y--, xs0 += dx0) {
- /* xs0 is the xcoord! */
- span[y] = xs0;
- }
+ const float *minv, *maxv;
+ float *span;
+ float xx1, dx0, xs0;
+ int y, my0, my2;
+
+ if (v1[1] < v2[1]) {
+ minv = v1;
+ maxv = v2;
+ }
+ else {
+ minv = v2;
+ maxv = v1;
+ }
+
+ my0 = ceil(minv[1]);
+ my2 = floor(maxv[1]);
+
+ if (my2 < 0 || my0 >= zspan->recty)
+ return;
+
+ /* clip top */
+ if (my2 >= zspan->recty)
+ my2 = zspan->recty - 1;
+ /* clip bottom */
+ if (my0 < 0)
+ my0 = 0;
+
+ if (my0 > my2)
+ return;
+ /* if (my0>my2) should still fill in, that way we get spans that skip nicely */
+
+ xx1 = maxv[1] - minv[1];
+ if (xx1 > FLT_EPSILON) {
+ dx0 = (minv[0] - maxv[0]) / xx1;
+ xs0 = dx0 * (minv[1] - my2) + minv[0];
+ }
+ else {
+ dx0 = 0.0f;
+ xs0 = min_ff(minv[0], maxv[0]);
+ }
+
+ /* empty span */
+ if (zspan->maxp1 == NULL) {
+ span = zspan->span1;
+ }
+ else { /* does it complete left span? */
+ if (maxv == zspan->minp1 || minv == zspan->maxp1) {
+ span = zspan->span1;
+ }
+ else {
+ span = zspan->span2;
+ }
+ }
+
+ if (span == zspan->span1) {
+ // printf("left span my0 %d my2 %d\n", my0, my2);
+ if (zspan->minp1 == NULL || zspan->minp1[1] > minv[1]) {
+ zspan->minp1 = minv;
+ }
+ if (zspan->maxp1 == NULL || zspan->maxp1[1] < maxv[1]) {
+ zspan->maxp1 = maxv;
+ }
+ if (my0 < zspan->miny1)
+ zspan->miny1 = my0;
+ if (my2 > zspan->maxy1)
+ zspan->maxy1 = my2;
+ }
+ else {
+ // printf("right span my0 %d my2 %d\n", my0, my2);
+ if (zspan->minp2 == NULL || zspan->minp2[1] > minv[1]) {
+ zspan->minp2 = minv;
+ }
+ if (zspan->maxp2 == NULL || zspan->maxp2[1] < maxv[1]) {
+ zspan->maxp2 = maxv;
+ }
+ if (my0 < zspan->miny2)
+ zspan->miny2 = my0;
+ if (my2 > zspan->maxy2)
+ zspan->maxy2 = my2;
+ }
+
+ for (y = my2; y >= my0; y--, xs0 += dx0) {
+ /* xs0 is the xcoord! */
+ span[y] = xs0;
+ }
}
/* ******************** VECBLUR ACCUM BUF ************************* */
typedef struct DrawBufPixel {
- const float *colpoin;
- float alpha;
+ const float *colpoin;
+ float alpha;
} DrawBufPixel;
-
-static void zbuf_fill_in_rgba(ZSpan *zspan, DrawBufPixel *col, float *v1, float *v2, float *v3, float *v4)
+static void zbuf_fill_in_rgba(
+ ZSpan *zspan, DrawBufPixel *col, float *v1, float *v2, float *v3, float *v4)
{
- DrawBufPixel *rectpofs, *rp;
- double zxd, zyd, zy0, zverg;
- float x0, y0, z0;
- float x1, y1, z1, x2, y2, z2, xx1;
- const float *span1, *span2;
- float *rectzofs, *rz;
- int x, y;
- int sn1, sn2, rectx, my0, my2;
-
- /* init */
- zbuf_init_span(zspan);
-
- /* set spans */
- zbuf_add_to_span(zspan, v1, v2);
- zbuf_add_to_span(zspan, v2, v3);
- zbuf_add_to_span(zspan, v3, v4);
- zbuf_add_to_span(zspan, v4, v1);
-
- /* clipped */
- if (zspan->minp2 == NULL || zspan->maxp2 == NULL) return;
-
- my0 = max_ii(zspan->miny1, zspan->miny2);
- my2 = min_ii(zspan->maxy1, zspan->maxy2);
-
- // printf("my %d %d\n", my0, my2);
- if (my2 < my0) return;
-
- /* ZBUF DX DY, in floats still */
- x1 = v1[0] - v2[0];
- x2 = v2[0] - v3[0];
- y1 = v1[1] - v2[1];
- y2 = v2[1] - v3[1];
- z1 = v1[2] - v2[2];
- z2 = v2[2] - v3[2];
- x0 = y1 * z2 - z1 * y2;
- y0 = z1 * x2 - x1 * z2;
- z0 = x1 * y2 - y1 * x2;
-
- if (z0 == 0.0f) return;
-
- xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2];
-
- zxd = -(double)x0 / (double)z0;
- zyd = -(double)y0 / (double)z0;
- zy0 = ((double)my2) * zyd + (double)xx1;
-
- /* start-offset in rect */
- rectx = zspan->rectx;
- rectzofs = (float *)(zspan->rectz + rectx * my2);
- rectpofs = ((DrawBufPixel *)zspan->rectdraw) + rectx * my2;
-
- /* correct span */
- sn1 = (my0 + my2) / 2;
- if (zspan->span1[sn1] < zspan->span2[sn1]) {
- span1 = zspan->span1 + my2;
- span2 = zspan->span2 + my2;
- }
- else {
- span1 = zspan->span2 + my2;
- span2 = zspan->span1 + my2;
- }
-
- for (y = my2; y >= my0; y--, span1--, span2--) {
-
- sn1 = floor(*span1);
- sn2 = floor(*span2);
- sn1++;
-
- if (sn2 >= rectx) sn2 = rectx - 1;
- if (sn1 < 0) sn1 = 0;
-
- if (sn2 >= sn1) {
- zverg = (double)sn1 * zxd + zy0;
- rz = rectzofs + sn1;
- rp = rectpofs + sn1;
- x = sn2 - sn1;
-
- while (x >= 0) {
- if (zverg < (double)*rz) {
- *rz = zverg;
- *rp = *col;
- }
- zverg += zxd;
- rz++;
- rp++;
- x--;
- }
- }
-
- zy0 -= zyd;
- rectzofs -= rectx;
- rectpofs -= rectx;
- }
+ DrawBufPixel *rectpofs, *rp;
+ double zxd, zyd, zy0, zverg;
+ float x0, y0, z0;
+ float x1, y1, z1, x2, y2, z2, xx1;
+ const float *span1, *span2;
+ float *rectzofs, *rz;
+ int x, y;
+ int sn1, sn2, rectx, my0, my2;
+
+ /* init */
+ zbuf_init_span(zspan);
+
+ /* set spans */
+ zbuf_add_to_span(zspan, v1, v2);
+ zbuf_add_to_span(zspan, v2, v3);
+ zbuf_add_to_span(zspan, v3, v4);
+ zbuf_add_to_span(zspan, v4, v1);
+
+ /* clipped */
+ if (zspan->minp2 == NULL || zspan->maxp2 == NULL)
+ return;
+
+ my0 = max_ii(zspan->miny1, zspan->miny2);
+ my2 = min_ii(zspan->maxy1, zspan->maxy2);
+
+ // printf("my %d %d\n", my0, my2);
+ if (my2 < my0)
+ return;
+
+ /* ZBUF DX DY, in floats still */
+ x1 = v1[0] - v2[0];
+ x2 = v2[0] - v3[0];
+ y1 = v1[1] - v2[1];
+ y2 = v2[1] - v3[1];
+ z1 = v1[2] - v2[2];
+ z2 = v2[2] - v3[2];
+ x0 = y1 * z2 - z1 * y2;
+ y0 = z1 * x2 - x1 * z2;
+ z0 = x1 * y2 - y1 * x2;
+
+ if (z0 == 0.0f)
+ return;
+
+ xx1 = (x0 * v1[0] + y0 * v1[1]) / z0 + v1[2];
+
+ zxd = -(double)x0 / (double)z0;
+ zyd = -(double)y0 / (double)z0;
+ zy0 = ((double)my2) * zyd + (double)xx1;
+
+ /* start-offset in rect */
+ rectx = zspan->rectx;
+ rectzofs = (float *)(zspan->rectz + rectx * my2);
+ rectpofs = ((DrawBufPixel *)zspan->rectdraw) + rectx * my2;
+
+ /* correct span */
+ sn1 = (my0 + my2) / 2;
+ if (zspan->span1[sn1] < zspan->span2[sn1]) {
+ span1 = zspan->span1 + my2;
+ span2 = zspan->span2 + my2;
+ }
+ else {
+ span1 = zspan->span2 + my2;
+ span2 = zspan->span1 + my2;
+ }
+
+ for (y = my2; y >= my0; y--, span1--, span2--) {
+
+ sn1 = floor(*span1);
+ sn2 = floor(*span2);
+ sn1++;
+
+ if (sn2 >= rectx)
+ sn2 = rectx - 1;
+ if (sn1 < 0)
+ sn1 = 0;
+
+ if (sn2 >= sn1) {
+ zverg = (double)sn1 * zxd + zy0;
+ rz = rectzofs + sn1;
+ rp = rectpofs + sn1;
+ x = sn2 - sn1;
+
+ while (x >= 0) {
+ if (zverg < (double)*rz) {
+ *rz = zverg;
+ *rp = *col;
+ }
+ zverg += zxd;
+ rz++;
+ rp++;
+ x--;
+ }
+ }
+
+ zy0 -= zyd;
+ rectzofs -= rectx;
+ rectpofs -= rectx;
+ }
}
/* char value==255 is filled in, rest should be zero */
/* returns alpha values, but sets alpha to 1 for zero alpha pixels that have an alpha value as neighbor */
void antialias_tagbuf(int xsize, int ysize, char *rectmove)
{
- char *row1, *row2, *row3;
- char prev, next;
- int a, x, y, step;
-
- /* 1: tag pixels to be candidate for AA */
- for (y = 2; y < ysize; y++) {
- /* setup rows */
- row1 = rectmove + (y - 2) * xsize;
- row2 = row1 + xsize;
- row3 = row2 + xsize;
- for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
- if (row2[1]) {
- if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0)
- row2[1] = 128;
- }
- }
- }
-
- /* 2: evaluate horizontal scanlines and calculate alphas */
- row1 = rectmove;
- for (y = 0; y < ysize; y++) {
- row1++;
- for (x = 1; x < xsize; x++, row1++) {
- if (row1[0] == 128 && row1[1] == 128) {
- /* find previous color and next color and amount of steps to blend */
- prev = row1[-1];
- step = 1;
- while (x + step < xsize && row1[step] == 128)
- step++;
-
- if (x + step != xsize) {
- /* now we can blend values */
- next = row1[step];
-
- /* note, prev value can be next value, but we do this loop to clear 128 then */
- for (a = 0; a < step; a++) {
- int fac, mfac;
-
- fac = ((a + 1) << 8) / (step + 1);
- mfac = 255 - fac;
-
- row1[a] = (prev * mfac + next * fac) >> 8;
- }
- }
- }
- }
- }
-
- /* 3: evaluate vertical scanlines and calculate alphas */
- /* use for reading a copy of the original tagged buffer */
- for (x = 0; x < xsize; x++) {
- row1 = rectmove + x + xsize;
-
- for (y = 1; y < ysize; y++, row1 += xsize) {
- if (row1[0] == 128 && row1[xsize] == 128) {
- /* find previous color and next color and amount of steps to blend */
- prev = row1[-xsize];
- step = 1;
- while (y + step < ysize && row1[step * xsize] == 128)
- step++;
-
- if (y + step != ysize) {
- /* now we can blend values */
- next = row1[step * xsize];
- /* note, prev value can be next value, but we do this loop to clear 128 then */
- for (a = 0; a < step; a++) {
- int fac, mfac;
-
- fac = ((a + 1) << 8) / (step + 1);
- mfac = 255 - fac;
-
- row1[a * xsize] = (prev * mfac + next * fac) >> 8;
- }
- }
- }
- }
- }
-
- /* last: pixels with 0 we fill in zbuffer, with 1 we skip for mask */
- for (y = 2; y < ysize; y++) {
- /* setup rows */
- row1 = rectmove + (y - 2) * xsize;
- row2 = row1 + xsize;
- row3 = row2 + xsize;
- for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
- if (row2[1] == 0) {
- if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1)
- row2[1] = 1;
- }
- }
- }
+ char *row1, *row2, *row3;
+ char prev, next;
+ int a, x, y, step;
+
+ /* 1: tag pixels to be candidate for AA */
+ for (y = 2; y < ysize; y++) {
+ /* setup rows */
+ row1 = rectmove + (y - 2) * xsize;
+ row2 = row1 + xsize;
+ row3 = row2 + xsize;
+ for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
+ if (row2[1]) {
+ if (row2[0] == 0 || row2[2] == 0 || row1[1] == 0 || row3[1] == 0)
+ row2[1] = 128;
+ }
+ }
+ }
+
+ /* 2: evaluate horizontal scanlines and calculate alphas */
+ row1 = rectmove;
+ for (y = 0; y < ysize; y++) {
+ row1++;
+ for (x = 1; x < xsize; x++, row1++) {
+ if (row1[0] == 128 && row1[1] == 128) {
+ /* find previous color and next color and amount of steps to blend */
+ prev = row1[-1];
+ step = 1;
+ while (x + step < xsize && row1[step] == 128)
+ step++;
+
+ if (x + step != xsize) {
+ /* now we can blend values */
+ next = row1[step];
+
+ /* note, prev value can be next value, but we do this loop to clear 128 then */
+ for (a = 0; a < step; a++) {
+ int fac, mfac;
+
+ fac = ((a + 1) << 8) / (step + 1);
+ mfac = 255 - fac;
+
+ row1[a] = (prev * mfac + next * fac) >> 8;
+ }
+ }
+ }
+ }
+ }
+
+ /* 3: evaluate vertical scanlines and calculate alphas */
+ /* use for reading a copy of the original tagged buffer */
+ for (x = 0; x < xsize; x++) {
+ row1 = rectmove + x + xsize;
+
+ for (y = 1; y < ysize; y++, row1 += xsize) {
+ if (row1[0] == 128 && row1[xsize] == 128) {
+ /* find previous color and next color and amount of steps to blend */
+ prev = row1[-xsize];
+ step = 1;
+ while (y + step < ysize && row1[step * xsize] == 128)
+ step++;
+
+ if (y + step != ysize) {
+ /* now we can blend values */
+ next = row1[step * xsize];
+ /* note, prev value can be next value, but we do this loop to clear 128 then */
+ for (a = 0; a < step; a++) {
+ int fac, mfac;
+
+ fac = ((a + 1) << 8) / (step + 1);
+ mfac = 255 - fac;
+
+ row1[a * xsize] = (prev * mfac + next * fac) >> 8;
+ }
+ }
+ }
+ }
+ }
+
+ /* last: pixels with 0 we fill in zbuffer, with 1 we skip for mask */
+ for (y = 2; y < ysize; y++) {
+ /* setup rows */
+ row1 = rectmove + (y - 2) * xsize;
+ row2 = row1 + xsize;
+ row3 = row2 + xsize;
+ for (x = 2; x < xsize; x++, row1++, row2++, row3++) {
+ if (row2[1] == 0) {
+ if (row2[0] > 1 || row2[2] > 1 || row1[1] > 1 || row3[1] > 1)
+ row2[1] = 1;
+ }
+ }
+ }
}
/* in: two vectors, first vector points from origin back in time, 2nd vector points to future */
@@ -467,347 +496,369 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove)
static void quad_bezier_2d(float *result, float *v1, float *v2, float *ipodata)
{
- float p1[2], p2[2], p3[2];
+ float p1[2], p2[2], p3[2];
- p3[0] = -v2[0];
- p3[1] = -v2[1];
+ p3[0] = -v2[0];
+ p3[1] = -v2[1];
- p1[0] = v1[0];
- p1[1] = v1[1];
+ p1[0] = v1[0];
+ p1[1] = v1[1];
- /* official formula 2*p2 - 0.5*p1 - 0.5*p3 */
- p2[0] = -0.5f * p1[0] - 0.5f * p3[0];
- p2[1] = -0.5f * p1[1] - 0.5f * p3[1];
+ /* official formula 2*p2 - 0.5*p1 - 0.5*p3 */
+ p2[0] = -0.5f * p1[0] - 0.5f * p3[0];
+ p2[1] = -0.5f * p1[1] - 0.5f * p3[1];
- result[0] = ipodata[0] * p1[0] + ipodata[1] * p2[0] + ipodata[2] * p3[0];
- result[1] = ipodata[0] * p1[1] + ipodata[1] * p2[1] + ipodata[2] * p3[1];
+ result[0] = ipodata[0] * p1[0] + ipodata[1] * p2[0] + ipodata[2] * p3[0];
+ result[1] = ipodata[0] * p1[1] + ipodata[1] * p2[1] + ipodata[2] * p3[1];
}
static void set_quad_bezier_ipo(float fac, float *data)
{
- float mfac = (1.0f - fac);
+ float mfac = (1.0f - fac);
- data[0] = mfac * mfac;
- data[1] = 2.0f * mfac * fac;
- data[2] = fac * fac;
+ data[0] = mfac * mfac;
+ data[1] = 2.0f * mfac * fac;
+ data[2] = fac * fac;
}
-void zbuf_accumulate_vecblur(
- NodeBlurData *nbd, int xsize, int ysize, float *newrect,
- const float *imgrect, float *vecbufrect, const float *zbufrect)
+void zbuf_accumulate_vecblur(NodeBlurData *nbd,
+ int xsize,
+ int ysize,
+ float *newrect,
+ const float *imgrect,
+ float *vecbufrect,
+ const float *zbufrect)
{
- ZSpan zspan;
- DrawBufPixel *rectdraw, *dr;
- static float jit[256][2];
- float v1[3], v2[3], v3[3], v4[3], fx, fy;
- const float *dimg, *dz, *ro;
- float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz;
- float *minvecbufrect = NULL, *rectweight, *rw, *rectmax, *rm;
- float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed;
- int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples;
- int tsktsk = 0;
- static int firsttime = 1;
- char *rectmove, *dm;
-
- zbuf_alloc_span(&zspan, xsize, ysize, 1.0f);
- zspan.zmulx = ((float)xsize) / 2.0f;
- zspan.zmuly = ((float)ysize) / 2.0f;
- zspan.zofsx = 0.0f;
- zspan.zofsy = 0.0f;
-
- /* the buffers */
- rectz = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "zbuf accum");
- zspan.rectz = (int *)rectz;
-
- rectmove = (char *)MEM_mapallocN(xsize * ysize, "rectmove");
- rectdraw = (DrawBufPixel *)MEM_mapallocN(sizeof(DrawBufPixel) * xsize * ysize, "rect draw");
- zspan.rectdraw = rectdraw;
-
- rectweight = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect weight");
- rectmax = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect max");
-
- /* debug... check if PASS_VECTOR_MAX still is in buffers */
- dvec1 = vecbufrect;
- for (x = 4 * xsize * ysize; x > 0; x--, dvec1++) {
- if (dvec1[0] == PASS_VECTOR_MAX) {
- dvec1[0] = 0.0f;
- tsktsk = 1;
- }
- }
- if (tsktsk) printf("Found uninitialized speed in vector buffer... fixed.\n");
-
- /* min speed? then copy speedbuffer to recalculate speed vectors */
- if (nbd->minspeed) {
- float minspeed = (float)nbd->minspeed;
- float minspeedsq = minspeed * minspeed;
-
- minvecbufrect = (float *)MEM_mapallocN(4 * sizeof(float) * xsize * ysize, "minspeed buf");
-
- dvec1 = vecbufrect;
- dvec2 = minvecbufrect;
- for (x = 2 * xsize * ysize; x > 0; x--, dvec1 += 2, dvec2 += 2) {
- if (dvec1[0] == 0.0f && dvec1[1] == 0.0f) {
- dvec2[0] = dvec1[0];
- dvec2[1] = dvec1[1];
- }
- else {
- float speedsq = dvec1[0] * dvec1[0] + dvec1[1] * dvec1[1];
- if (speedsq <= minspeedsq) {
- dvec2[0] = 0.0f;
- dvec2[1] = 0.0f;
- }
- else {
- speedsq = 1.0f - minspeed / sqrtf(speedsq);
- dvec2[0] = speedsq * dvec1[0];
- dvec2[1] = speedsq * dvec1[1];
- }
- }
- }
- SWAP(float *, minvecbufrect, vecbufrect);
- }
-
- /* make vertex buffer with averaged speed and zvalues */
- rectvz = (float *)MEM_mapallocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices");
- dvz = rectvz;
- for (y = 0; y <= ysize; y++) {
-
- if (y == 0)
- dvec1 = vecbufrect + 4 * y * xsize;
- else
- dvec1 = vecbufrect + 4 * (y - 1) * xsize;
-
- if (y == ysize)
- dvec2 = vecbufrect + 4 * (y - 1) * xsize;
- else
- dvec2 = vecbufrect + 4 * y * xsize;
-
- for (x = 0; x <= xsize; x++) {
-
- /* two vectors, so a step loop */
- for (step = 0; step < 2; step++, dvec1 += 2, dvec2 += 2, dvz += 2) {
- /* average on minimal speed */
- int div = 0;
-
- if (x != 0) {
- if (dvec1[-4] != 0.0f || dvec1[-3] != 0.0f) {
- dvz[0] = dvec1[-4];
- dvz[1] = dvec1[-3];
- div++;
- }
- if (dvec2[-4] != 0.0f || dvec2[-3] != 0.0f) {
- if (div == 0) {
- dvz[0] = dvec2[-4];
- dvz[1] = dvec2[-3];
- div++;
- }
- else if ( (ABS(dvec2[-4]) + ABS(dvec2[-3])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0] = dvec2[-4];
- dvz[1] = dvec2[-3];
- }
- }
- }
-
- if (x != xsize) {
- if (dvec1[0] != 0.0f || dvec1[1] != 0.0f) {
- if (div == 0) {
- dvz[0] = dvec1[0];
- dvz[1] = dvec1[1];
- div++;
- }
- else if ( (ABS(dvec1[0]) + ABS(dvec1[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0] = dvec1[0];
- dvz[1] = dvec1[1];
- }
- }
- if (dvec2[0] != 0.0f || dvec2[1] != 0.0f) {
- if (div == 0) {
- dvz[0] = dvec2[0];
- dvz[1] = dvec2[1];
- }
- else if ( (ABS(dvec2[0]) + ABS(dvec2[1])) < (ABS(dvz[0]) + ABS(dvz[1])) ) {
- dvz[0] = dvec2[0];
- dvz[1] = dvec2[1];
- }
- }
- }
- if (maxspeed) {
- float speedsq = dvz[0] * dvz[0] + dvz[1] * dvz[1];
- if (speedsq > maxspeedsq) {
- speedsq = (float)maxspeed / sqrtf(speedsq);
- dvz[0] *= speedsq;
- dvz[1] *= speedsq;
- }
- }
- }
- }
- }
-
- /* set border speeds to keep border speeds on border */
- dz1 = rectvz;
- dz2 = rectvz + 4 * (ysize) * (xsize + 1);
- for (x = 0; x <= xsize; x++, dz1 += 4, dz2 += 4) {
- dz1[1] = 0.0f;
- dz2[1] = 0.0f;
- dz1[3] = 0.0f;
- dz2[3] = 0.0f;
- }
- dz1 = rectvz;
- dz2 = rectvz + 4 * (xsize);
- for (y = 0; y <= ysize; y++, dz1 += 4 * (xsize + 1), dz2 += 4 * (xsize + 1)) {
- dz1[0] = 0.0f;
- dz2[0] = 0.0f;
- dz1[2] = 0.0f;
- dz2[2] = 0.0f;
- }
-
- /* tag moving pixels, only these faces we draw */
- dm = rectmove;
- dvec1 = vecbufrect;
- for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) {
- if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f))
- *dm = 255;
- }
-
- antialias_tagbuf(xsize, ysize, rectmove);
-
- /* has to become static, the init-jit calls a random-seed, screwing up texture noise node */
- if (firsttime) {
- firsttime = 0;
- BLI_jitter_init(jit, 256);
- }
-
- memset(newrect, 0, sizeof(float) * xsize * ysize * 4);
-
- /* accumulate */
- samples /= 2;
- for (step = 1; step <= samples; step++) {
- float speedfac = 0.5f * nbd->fac * (float)step / (float)(samples + 1);
- int side;
-
- for (side = 0; side < 2; side++) {
- float blendfac, ipodata[4];
-
- /* clear zbuf, if we draw future we fill in not moving pixels */
- if (0)
- for (x = xsize * ysize - 1; x >= 0; x--) rectz[x] = 10e16;
- else
- for (x = xsize * ysize - 1; x >= 0; x--) {
- if (rectmove[x] == 0)
- rectz[x] = zbufrect[x];
- else
- rectz[x] = 10e16;
- }
-
- /* clear drawing buffer */
- for (x = xsize * ysize - 1; x >= 0; x--) rectdraw[x].colpoin = NULL;
-
- dimg = imgrect;
- dm = rectmove;
- dz = zbufrect;
- dz1 = rectvz;
- dz2 = rectvz + 4 * (xsize + 1);
-
- if (side) {
- if (nbd->curved == 0) {
- dz1 += 2;
- dz2 += 2;
- }
- speedfac = -speedfac;
- }
-
- set_quad_bezier_ipo(0.5f + 0.5f * speedfac, ipodata);
-
- for (fy = -0.5f + jit[step & 255][0], y = 0; y < ysize; y++, fy += 1.0f) {
- for (fx = -0.5f + jit[step & 255][1], x = 0; x < xsize; x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) {
- if (*dm > 1) {
- float jfx = fx + 0.5f;
- float jfy = fy + 0.5f;
- DrawBufPixel col;
-
- /* make vertices */
- if (nbd->curved) { /* curved */
- quad_bezier_2d(v1, dz1, dz1 + 2, ipodata);
- v1[0] += jfx; v1[1] += jfy; v1[2] = *dz;
-
- quad_bezier_2d(v2, dz1 + 4, dz1 + 4 + 2, ipodata);
- v2[0] += jfx + 1.0f; v2[1] += jfy; v2[2] = *dz;
-
- quad_bezier_2d(v3, dz2 + 4, dz2 + 4 + 2, ipodata);
- v3[0] += jfx + 1.0f; v3[1] += jfy + 1.0f; v3[2] = *dz;
-
- quad_bezier_2d(v4, dz2, dz2 + 2, ipodata);
- v4[0] += jfx; v4[1] += jfy + 1.0f; v4[2] = *dz;
- }
- else {
- ARRAY_SET_ITEMS(v1, speedfac * dz1[0] + jfx, speedfac * dz1[1] + jfy, *dz);
- ARRAY_SET_ITEMS(v2, speedfac * dz1[4] + jfx + 1.0f, speedfac * dz1[5] + jfy, *dz);
- ARRAY_SET_ITEMS(v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz);
- ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz);
- }
- if (*dm == 255) col.alpha = 1.0f;
- else if (*dm < 2) col.alpha = 0.0f;
- else col.alpha = ((float)*dm) / 255.0f;
- col.colpoin = dimg;
-
- zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4);
- }
- }
- dz1 += 4;
- dz2 += 4;
- }
-
- /* blend with a falloff. this fixes the ugly effect you get with
- * a fast moving object. then it looks like a solid object overlaid
- * over a very transparent moving version of itself. in reality, the
- * whole object should become transparent if it is moving fast, be
- * we don't know what is behind it so we don't do that. this hack
- * overestimates the contribution of foreground pixels but looks a
- * bit better without a sudden cutoff. */
- blendfac = ((samples - step) / (float)samples);
- /* smoothstep to make it look a bit nicer as well */
- blendfac = 3.0f * pow(blendfac, 2.0f) - 2.0f * pow(blendfac, 3.0f);
-
- /* accum */
- rw = rectweight;
- rm = rectmax;
- for (dr = rectdraw, dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dr++, dz2 += 4, rw++, rm++) {
- if (dr->colpoin) {
- float bfac = dr->alpha * blendfac;
-
- dz2[0] += bfac * dr->colpoin[0];
- dz2[1] += bfac * dr->colpoin[1];
- dz2[2] += bfac * dr->colpoin[2];
- dz2[3] += bfac * dr->colpoin[3];
-
- *rw += bfac;
- *rm = MAX2(*rm, bfac);
- }
- }
- }
- }
-
- /* blend between original images and accumulated image */
- rw = rectweight;
- rm = rectmax;
- ro = imgrect;
- dm = rectmove;
- for (dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dz2 += 4, ro += 4, rw++, rm++, dm++) {
- float mfac = *rm;
- float fac = (*rw == 0.0f) ? 0.0f : mfac / (*rw);
- float nfac = 1.0f - mfac;
-
- dz2[0] = fac * dz2[0] + nfac * ro[0];
- dz2[1] = fac * dz2[1] + nfac * ro[1];
- dz2[2] = fac * dz2[2] + nfac * ro[2];
- dz2[3] = fac * dz2[3] + nfac * ro[3];
- }
-
- MEM_freeN(rectz);
- MEM_freeN(rectmove);
- MEM_freeN(rectdraw);
- MEM_freeN(rectvz);
- MEM_freeN(rectweight);
- MEM_freeN(rectmax);
- if (minvecbufrect) MEM_freeN(vecbufrect); /* rects were swapped! */
- zbuf_free_span(&zspan);
+ ZSpan zspan;
+ DrawBufPixel *rectdraw, *dr;
+ static float jit[256][2];
+ float v1[3], v2[3], v3[3], v4[3], fx, fy;
+ const float *dimg, *dz, *ro;
+ float *rectvz, *dvz, *dvec1, *dvec2, *dz1, *dz2, *rectz;
+ float *minvecbufrect = NULL, *rectweight, *rw, *rectmax, *rm;
+ float maxspeedsq = (float)nbd->maxspeed * nbd->maxspeed;
+ int y, x, step, maxspeed = nbd->maxspeed, samples = nbd->samples;
+ int tsktsk = 0;
+ static int firsttime = 1;
+ char *rectmove, *dm;
+
+ zbuf_alloc_span(&zspan, xsize, ysize, 1.0f);
+ zspan.zmulx = ((float)xsize) / 2.0f;
+ zspan.zmuly = ((float)ysize) / 2.0f;
+ zspan.zofsx = 0.0f;
+ zspan.zofsy = 0.0f;
+
+ /* the buffers */
+ rectz = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "zbuf accum");
+ zspan.rectz = (int *)rectz;
+
+ rectmove = (char *)MEM_mapallocN(xsize * ysize, "rectmove");
+ rectdraw = (DrawBufPixel *)MEM_mapallocN(sizeof(DrawBufPixel) * xsize * ysize, "rect draw");
+ zspan.rectdraw = rectdraw;
+
+ rectweight = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect weight");
+ rectmax = (float *)MEM_mapallocN(sizeof(float) * xsize * ysize, "rect max");
+
+ /* debug... check if PASS_VECTOR_MAX still is in buffers */
+ dvec1 = vecbufrect;
+ for (x = 4 * xsize * ysize; x > 0; x--, dvec1++) {
+ if (dvec1[0] == PASS_VECTOR_MAX) {
+ dvec1[0] = 0.0f;
+ tsktsk = 1;
+ }
+ }
+ if (tsktsk)
+ printf("Found uninitialized speed in vector buffer... fixed.\n");
+
+ /* min speed? then copy speedbuffer to recalculate speed vectors */
+ if (nbd->minspeed) {
+ float minspeed = (float)nbd->minspeed;
+ float minspeedsq = minspeed * minspeed;
+
+ minvecbufrect = (float *)MEM_mapallocN(4 * sizeof(float) * xsize * ysize, "minspeed buf");
+
+ dvec1 = vecbufrect;
+ dvec2 = minvecbufrect;
+ for (x = 2 * xsize * ysize; x > 0; x--, dvec1 += 2, dvec2 += 2) {
+ if (dvec1[0] == 0.0f && dvec1[1] == 0.0f) {
+ dvec2[0] = dvec1[0];
+ dvec2[1] = dvec1[1];
+ }
+ else {
+ float speedsq = dvec1[0] * dvec1[0] + dvec1[1] * dvec1[1];
+ if (speedsq <= minspeedsq) {
+ dvec2[0] = 0.0f;
+ dvec2[1] = 0.0f;
+ }
+ else {
+ speedsq = 1.0f - minspeed / sqrtf(speedsq);
+ dvec2[0] = speedsq * dvec1[0];
+ dvec2[1] = speedsq * dvec1[1];
+ }
+ }
+ }
+ SWAP(float *, minvecbufrect, vecbufrect);
+ }
+
+ /* make vertex buffer with averaged speed and zvalues */
+ rectvz = (float *)MEM_mapallocN(4 * sizeof(float) * (xsize + 1) * (ysize + 1), "vertices");
+ dvz = rectvz;
+ for (y = 0; y <= ysize; y++) {
+
+ if (y == 0)
+ dvec1 = vecbufrect + 4 * y * xsize;
+ else
+ dvec1 = vecbufrect + 4 * (y - 1) * xsize;
+
+ if (y == ysize)
+ dvec2 = vecbufrect + 4 * (y - 1) * xsize;
+ else
+ dvec2 = vecbufrect + 4 * y * xsize;
+
+ for (x = 0; x <= xsize; x++) {
+
+ /* two vectors, so a step loop */
+ for (step = 0; step < 2; step++, dvec1 += 2, dvec2 += 2, dvz += 2) {
+ /* average on minimal speed */
+ int div = 0;
+
+ if (x != 0) {
+ if (dvec1[-4] != 0.0f || dvec1[-3] != 0.0f) {
+ dvz[0] = dvec1[-4];
+ dvz[1] = dvec1[-3];
+ div++;
+ }
+ if (dvec2[-4] != 0.0f || dvec2[-3] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec2[-4];
+ dvz[1] = dvec2[-3];
+ div++;
+ }
+ else if ((ABS(dvec2[-4]) + ABS(dvec2[-3])) < (ABS(dvz[0]) + ABS(dvz[1]))) {
+ dvz[0] = dvec2[-4];
+ dvz[1] = dvec2[-3];
+ }
+ }
+ }
+
+ if (x != xsize) {
+ if (dvec1[0] != 0.0f || dvec1[1] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec1[0];
+ dvz[1] = dvec1[1];
+ div++;
+ }
+ else if ((ABS(dvec1[0]) + ABS(dvec1[1])) < (ABS(dvz[0]) + ABS(dvz[1]))) {
+ dvz[0] = dvec1[0];
+ dvz[1] = dvec1[1];
+ }
+ }
+ if (dvec2[0] != 0.0f || dvec2[1] != 0.0f) {
+ if (div == 0) {
+ dvz[0] = dvec2[0];
+ dvz[1] = dvec2[1];
+ }
+ else if ((ABS(dvec2[0]) + ABS(dvec2[1])) < (ABS(dvz[0]) + ABS(dvz[1]))) {
+ dvz[0] = dvec2[0];
+ dvz[1] = dvec2[1];
+ }
+ }
+ }
+ if (maxspeed) {
+ float speedsq = dvz[0] * dvz[0] + dvz[1] * dvz[1];
+ if (speedsq > maxspeedsq) {
+ speedsq = (float)maxspeed / sqrtf(speedsq);
+ dvz[0] *= speedsq;
+ dvz[1] *= speedsq;
+ }
+ }
+ }
+ }
+ }
+
+ /* set border speeds to keep border speeds on border */
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (ysize) * (xsize + 1);
+ for (x = 0; x <= xsize; x++, dz1 += 4, dz2 += 4) {
+ dz1[1] = 0.0f;
+ dz2[1] = 0.0f;
+ dz1[3] = 0.0f;
+ dz2[3] = 0.0f;
+ }
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (xsize);
+ for (y = 0; y <= ysize; y++, dz1 += 4 * (xsize + 1), dz2 += 4 * (xsize + 1)) {
+ dz1[0] = 0.0f;
+ dz2[0] = 0.0f;
+ dz1[2] = 0.0f;
+ dz2[2] = 0.0f;
+ }
+
+ /* tag moving pixels, only these faces we draw */
+ dm = rectmove;
+ dvec1 = vecbufrect;
+ for (x = xsize * ysize; x > 0; x--, dm++, dvec1 += 4) {
+ if ((dvec1[0] != 0.0f || dvec1[1] != 0.0f || dvec1[2] != 0.0f || dvec1[3] != 0.0f))
+ *dm = 255;
+ }
+
+ antialias_tagbuf(xsize, ysize, rectmove);
+
+ /* has to become static, the init-jit calls a random-seed, screwing up texture noise node */
+ if (firsttime) {
+ firsttime = 0;
+ BLI_jitter_init(jit, 256);
+ }
+
+ memset(newrect, 0, sizeof(float) * xsize * ysize * 4);
+
+ /* accumulate */
+ samples /= 2;
+ for (step = 1; step <= samples; step++) {
+ float speedfac = 0.5f * nbd->fac * (float)step / (float)(samples + 1);
+ int side;
+
+ for (side = 0; side < 2; side++) {
+ float blendfac, ipodata[4];
+
+ /* clear zbuf, if we draw future we fill in not moving pixels */
+ if (0)
+ for (x = xsize * ysize - 1; x >= 0; x--)
+ rectz[x] = 10e16;
+ else
+ for (x = xsize * ysize - 1; x >= 0; x--) {
+ if (rectmove[x] == 0)
+ rectz[x] = zbufrect[x];
+ else
+ rectz[x] = 10e16;
+ }
+
+ /* clear drawing buffer */
+ for (x = xsize * ysize - 1; x >= 0; x--)
+ rectdraw[x].colpoin = NULL;
+
+ dimg = imgrect;
+ dm = rectmove;
+ dz = zbufrect;
+ dz1 = rectvz;
+ dz2 = rectvz + 4 * (xsize + 1);
+
+ if (side) {
+ if (nbd->curved == 0) {
+ dz1 += 2;
+ dz2 += 2;
+ }
+ speedfac = -speedfac;
+ }
+
+ set_quad_bezier_ipo(0.5f + 0.5f * speedfac, ipodata);
+
+ for (fy = -0.5f + jit[step & 255][0], y = 0; y < ysize; y++, fy += 1.0f) {
+ for (fx = -0.5f + jit[step & 255][1], x = 0; x < xsize;
+ x++, fx += 1.0f, dimg += 4, dz1 += 4, dz2 += 4, dm++, dz++) {
+ if (*dm > 1) {
+ float jfx = fx + 0.5f;
+ float jfy = fy + 0.5f;
+ DrawBufPixel col;
+
+ /* make vertices */
+ if (nbd->curved) { /* curved */
+ quad_bezier_2d(v1, dz1, dz1 + 2, ipodata);
+ v1[0] += jfx;
+ v1[1] += jfy;
+ v1[2] = *dz;
+
+ quad_bezier_2d(v2, dz1 + 4, dz1 + 4 + 2, ipodata);
+ v2[0] += jfx + 1.0f;
+ v2[1] += jfy;
+ v2[2] = *dz;
+
+ quad_bezier_2d(v3, dz2 + 4, dz2 + 4 + 2, ipodata);
+ v3[0] += jfx + 1.0f;
+ v3[1] += jfy + 1.0f;
+ v3[2] = *dz;
+
+ quad_bezier_2d(v4, dz2, dz2 + 2, ipodata);
+ v4[0] += jfx;
+ v4[1] += jfy + 1.0f;
+ v4[2] = *dz;
+ }
+ else {
+ ARRAY_SET_ITEMS(v1, speedfac * dz1[0] + jfx, speedfac * dz1[1] + jfy, *dz);
+ ARRAY_SET_ITEMS(v2, speedfac * dz1[4] + jfx + 1.0f, speedfac * dz1[5] + jfy, *dz);
+ ARRAY_SET_ITEMS(
+ v3, speedfac * dz2[4] + jfx + 1.0f, speedfac * dz2[5] + jfy + 1.0f, *dz);
+ ARRAY_SET_ITEMS(v4, speedfac * dz2[0] + jfx, speedfac * dz2[1] + jfy + 1.0f, *dz);
+ }
+ if (*dm == 255)
+ col.alpha = 1.0f;
+ else if (*dm < 2)
+ col.alpha = 0.0f;
+ else
+ col.alpha = ((float)*dm) / 255.0f;
+ col.colpoin = dimg;
+
+ zbuf_fill_in_rgba(&zspan, &col, v1, v2, v3, v4);
+ }
+ }
+ dz1 += 4;
+ dz2 += 4;
+ }
+
+ /* blend with a falloff. this fixes the ugly effect you get with
+ * a fast moving object. then it looks like a solid object overlaid
+ * over a very transparent moving version of itself. in reality, the
+ * whole object should become transparent if it is moving fast, be
+ * we don't know what is behind it so we don't do that. this hack
+ * overestimates the contribution of foreground pixels but looks a
+ * bit better without a sudden cutoff. */
+ blendfac = ((samples - step) / (float)samples);
+ /* smoothstep to make it look a bit nicer as well */
+ blendfac = 3.0f * pow(blendfac, 2.0f) - 2.0f * pow(blendfac, 3.0f);
+
+ /* accum */
+ rw = rectweight;
+ rm = rectmax;
+ for (dr = rectdraw, dz2 = newrect, x = xsize * ysize - 1; x >= 0;
+ x--, dr++, dz2 += 4, rw++, rm++) {
+ if (dr->colpoin) {
+ float bfac = dr->alpha * blendfac;
+
+ dz2[0] += bfac * dr->colpoin[0];
+ dz2[1] += bfac * dr->colpoin[1];
+ dz2[2] += bfac * dr->colpoin[2];
+ dz2[3] += bfac * dr->colpoin[3];
+
+ *rw += bfac;
+ *rm = MAX2(*rm, bfac);
+ }
+ }
+ }
+ }
+
+ /* blend between original images and accumulated image */
+ rw = rectweight;
+ rm = rectmax;
+ ro = imgrect;
+ dm = rectmove;
+ for (dz2 = newrect, x = xsize * ysize - 1; x >= 0; x--, dz2 += 4, ro += 4, rw++, rm++, dm++) {
+ float mfac = *rm;
+ float fac = (*rw == 0.0f) ? 0.0f : mfac / (*rw);
+ float nfac = 1.0f - mfac;
+
+ dz2[0] = fac * dz2[0] + nfac * ro[0];
+ dz2[1] = fac * dz2[1] + nfac * ro[1];
+ dz2[2] = fac * dz2[2] + nfac * ro[2];
+ dz2[3] = fac * dz2[3] + nfac * ro[3];
+ }
+
+ MEM_freeN(rectz);
+ MEM_freeN(rectmove);
+ MEM_freeN(rectdraw);
+ MEM_freeN(rectvz);
+ MEM_freeN(rectweight);
+ MEM_freeN(rectmax);
+ if (minvecbufrect)
+ MEM_freeN(vecbufrect); /* rects were swapped! */
+ zbuf_free_span(&zspan);
}
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.h b/source/blender/compositor/operations/COM_VectorBlurOperation.h
index acb08890e91..aedc0d85a50 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.h
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.h
@@ -23,47 +23,53 @@
#include "COM_QualityStepHelper.h"
class VectorBlurOperation : public NodeOperation, public QualityStepHelper {
-private:
- /**
- * \brief Cached reference to the inputProgram
- */
- SocketReader *m_inputImageProgram;
- SocketReader *m_inputSpeedProgram;
- SocketReader *m_inputZProgram;
+ private:
+ /**
+ * \brief Cached reference to the inputProgram
+ */
+ SocketReader *m_inputImageProgram;
+ SocketReader *m_inputSpeedProgram;
+ SocketReader *m_inputZProgram;
- /**
- * \brief settings of the glare node.
- */
- NodeBlurData *m_settings;
+ /**
+ * \brief settings of the glare node.
+ */
+ NodeBlurData *m_settings;
- float *m_cachedInstance;
+ float *m_cachedInstance;
-public:
- VectorBlurOperation();
+ public:
+ VectorBlurOperation();
- /**
- * the inner loop of this program
- */
- void executePixel(float output[4], int x, int y, void *data);
+ /**
+ * the inner loop of this program
+ */
+ void executePixel(float output[4], int x, int y, void *data);
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
- void *initializeTileData(rcti *rect);
-
- void setVectorBlurSettings(NodeBlurData *settings) { this->m_settings = settings; }
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
-protected:
-
- void generateVectorBlur(float *data, MemoryBuffer *inputImage, MemoryBuffer *inputSpeed, MemoryBuffer *inputZ);
+ void *initializeTileData(rcti *rect);
+ void setVectorBlurSettings(NodeBlurData *settings)
+ {
+ this->m_settings = settings;
+ }
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ protected:
+ void generateVectorBlur(float *data,
+ MemoryBuffer *inputImage,
+ MemoryBuffer *inputSpeed,
+ MemoryBuffer *inputZ);
};
#endif
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
index 2381656a289..850aef122f4 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.cpp
@@ -21,36 +21,38 @@
#ifdef __cplusplus
extern "C" {
#endif
-# include "BKE_colortools.h"
+#include "BKE_colortools.h"
#ifdef __cplusplus
}
#endif
VectorCurveOperation::VectorCurveOperation() : CurveBaseOperation()
{
- this->addInputSocket(COM_DT_VECTOR);
- this->addOutputSocket(COM_DT_VECTOR);
+ this->addInputSocket(COM_DT_VECTOR);
+ this->addOutputSocket(COM_DT_VECTOR);
- this->m_inputProgram = NULL;
+ this->m_inputProgram = NULL;
}
void VectorCurveOperation::initExecution()
{
- CurveBaseOperation::initExecution();
- this->m_inputProgram = this->getInputSocketReader(0);
+ CurveBaseOperation::initExecution();
+ this->m_inputProgram = this->getInputSocketReader(0);
}
-void VectorCurveOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void VectorCurveOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float input[4];
+ float input[4];
+ this->m_inputProgram->readSampled(input, x, y, sampler);
- this->m_inputProgram->readSampled(input, x, y, sampler);
-
- curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input);
+ curvemapping_evaluate_premulRGBF(this->m_curveMapping, output, input);
}
void VectorCurveOperation::deinitExecution()
{
- CurveBaseOperation::deinitExecution();
- this->m_inputProgram = NULL;
+ CurveBaseOperation::deinitExecution();
+ this->m_inputProgram = NULL;
}
diff --git a/source/blender/compositor/operations/COM_VectorCurveOperation.h b/source/blender/compositor/operations/COM_VectorCurveOperation.h
index 5b704d3504f..c8575de6aa8 100644
--- a/source/blender/compositor/operations/COM_VectorCurveOperation.h
+++ b/source/blender/compositor/operations/COM_VectorCurveOperation.h
@@ -22,27 +22,28 @@
#include "COM_CurveBaseOperation.h"
class VectorCurveOperation : public CurveBaseOperation {
-private:
- /**
- * Cached reference to the inputProgram
- */
- SocketReader *m_inputProgram;
-public:
- VectorCurveOperation();
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ public:
+ VectorCurveOperation();
- /**
- * Initialize the execution
- */
- void initExecution();
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- /**
- * Deinitialize the execution
- */
- void deinitExecution();
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
};
#endif
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp
index 0f6512de61d..fcf6a2a731d 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.cpp
+++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp
@@ -28,168 +28,178 @@
#include "BLI_math_vector.h"
extern "C" {
-# include "MEM_guardedalloc.h"
-# include "IMB_imbuf.h"
-# include "IMB_imbuf_types.h"
-# include "IMB_colormanagement.h"
+#include "MEM_guardedalloc.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+#include "IMB_colormanagement.h"
}
-
ViewerOperation::ViewerOperation() : NodeOperation()
{
- this->setImage(NULL);
- this->setImageUser(NULL);
- this->m_outputBuffer = NULL;
- this->m_depthBuffer = NULL;
- this->m_active = false;
- this->m_doDepthBuffer = false;
- this->m_viewSettings = NULL;
- this->m_displaySettings = NULL;
- this->m_useAlphaInput = false;
-
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_VALUE);
-
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
- this->m_rd = NULL;
- this->m_viewName = NULL;
+ this->setImage(NULL);
+ this->setImageUser(NULL);
+ this->m_outputBuffer = NULL;
+ this->m_depthBuffer = NULL;
+ this->m_active = false;
+ this->m_doDepthBuffer = false;
+ this->m_viewSettings = NULL;
+ this->m_displaySettings = NULL;
+ this->m_useAlphaInput = false;
+
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
+
+ this->m_imageInput = NULL;
+ this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
+ this->m_rd = NULL;
+ this->m_viewName = NULL;
}
void ViewerOperation::initExecution()
{
- // When initializing the tree during initial load the width and height can be zero.
- this->m_imageInput = getInputSocketReader(0);
- this->m_alphaInput = getInputSocketReader(1);
- this->m_depthInput = getInputSocketReader(2);
- this->m_doDepthBuffer = (this->m_depthInput != NULL);
-
- if (isActiveViewerOutput()) {
- initImage();
- }
+ // When initializing the tree during initial load the width and height can be zero.
+ this->m_imageInput = getInputSocketReader(0);
+ this->m_alphaInput = getInputSocketReader(1);
+ this->m_depthInput = getInputSocketReader(2);
+ this->m_doDepthBuffer = (this->m_depthInput != NULL);
+
+ if (isActiveViewerOutput()) {
+ initImage();
+ }
}
void ViewerOperation::deinitExecution()
{
- this->m_imageInput = NULL;
- this->m_alphaInput = NULL;
- this->m_depthInput = NULL;
- this->m_outputBuffer = NULL;
+ this->m_imageInput = NULL;
+ this->m_alphaInput = NULL;
+ this->m_depthInput = NULL;
+ this->m_outputBuffer = NULL;
}
void ViewerOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- float *buffer = this->m_outputBuffer;
- float *depthbuffer = this->m_depthBuffer;
- if (!buffer) return;
- const int x1 = rect->xmin;
- const int y1 = rect->ymin;
- const int x2 = rect->xmax;
- const int y2 = rect->ymax;
- const int offsetadd = (this->getWidth() - (x2 - x1));
- const int offsetadd4 = offsetadd * 4;
- int offset = (y1 * this->getWidth() + x1);
- int offset4 = offset * 4;
- float alpha[4], depth[4];
- int x;
- int y;
- bool breaked = false;
-
- for (y = y1; y < y2 && (!breaked); y++) {
- for (x = x1; x < x2; x++) {
- this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
- if (this->m_useAlphaInput) {
- this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
- buffer[offset4 + 3] = alpha[0];
- }
- this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
- depthbuffer[offset] = depth[0];
-
- offset ++;
- offset4 += 4;
- }
- if (isBreaked()) {
- breaked = true;
- }
- offset += offsetadd;
- offset4 += offsetadd4;
- }
- updateImage(rect);
+ float *buffer = this->m_outputBuffer;
+ float *depthbuffer = this->m_depthBuffer;
+ if (!buffer)
+ return;
+ const int x1 = rect->xmin;
+ const int y1 = rect->ymin;
+ const int x2 = rect->xmax;
+ const int y2 = rect->ymax;
+ const int offsetadd = (this->getWidth() - (x2 - x1));
+ const int offsetadd4 = offsetadd * 4;
+ int offset = (y1 * this->getWidth() + x1);
+ int offset4 = offset * 4;
+ float alpha[4], depth[4];
+ int x;
+ int y;
+ bool breaked = false;
+
+ for (y = y1; y < y2 && (!breaked); y++) {
+ for (x = x1; x < x2; x++) {
+ this->m_imageInput->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
+ if (this->m_useAlphaInput) {
+ this->m_alphaInput->readSampled(alpha, x, y, COM_PS_NEAREST);
+ buffer[offset4 + 3] = alpha[0];
+ }
+ this->m_depthInput->readSampled(depth, x, y, COM_PS_NEAREST);
+ depthbuffer[offset] = depth[0];
+
+ offset++;
+ offset4 += 4;
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ offset += offsetadd;
+ offset4 += offsetadd4;
+ }
+ updateImage(rect);
}
void ViewerOperation::initImage()
{
- Image *ima = this->m_image;
- ImageUser iuser = *this->m_imageUser;
- void *lock;
- ImBuf *ibuf;
-
- /* make sure the image has the correct number of views */
- if (ima && BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
- BKE_image_verify_viewer_views(this->m_rd, ima, this->m_imageUser);
- }
-
- BLI_thread_lock(LOCK_DRAW_IMAGE);
-
- /* local changes to the original ImageUser */
- iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
- ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock);
-
- if (!ibuf) {
- BLI_thread_unlock(LOCK_DRAW_IMAGE);
- return;
- }
- if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
-
- imb_freerectImBuf(ibuf);
- imb_freerectfloatImBuf(ibuf);
- IMB_freezbuffloatImBuf(ibuf);
- ibuf->x = getWidth();
- ibuf->y = getHeight();
- /* zero size can happen if no image buffers exist to define a sensible resolution */
- if (ibuf->x > 0 && ibuf->y > 0)
- imb_addrectfloatImBuf(ibuf);
- ima->ok = IMA_OK_LOADED;
-
- ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
- }
-
- if (m_doDepthBuffer) {
- addzbuffloatImBuf(ibuf);
- }
-
- /* now we combine the input with ibuf */
- this->m_outputBuffer = ibuf->rect_float;
-
- /* needed for display buffer update */
- this->m_ibuf = ibuf;
-
- if (m_doDepthBuffer) {
- this->m_depthBuffer = ibuf->zbuf_float;
- }
-
- BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);
-
- BLI_thread_unlock(LOCK_DRAW_IMAGE);
+ Image *ima = this->m_image;
+ ImageUser iuser = *this->m_imageUser;
+ void *lock;
+ ImBuf *ibuf;
+
+ /* make sure the image has the correct number of views */
+ if (ima && BKE_scene_multiview_is_render_view_first(this->m_rd, this->m_viewName)) {
+ BKE_image_verify_viewer_views(this->m_rd, ima, this->m_imageUser);
+ }
+
+ BLI_thread_lock(LOCK_DRAW_IMAGE);
+
+ /* local changes to the original ImageUser */
+ iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
+ ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock);
+
+ if (!ibuf) {
+ BLI_thread_unlock(LOCK_DRAW_IMAGE);
+ return;
+ }
+ if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
+
+ imb_freerectImBuf(ibuf);
+ imb_freerectfloatImBuf(ibuf);
+ IMB_freezbuffloatImBuf(ibuf);
+ ibuf->x = getWidth();
+ ibuf->y = getHeight();
+ /* zero size can happen if no image buffers exist to define a sensible resolution */
+ if (ibuf->x > 0 && ibuf->y > 0)
+ imb_addrectfloatImBuf(ibuf);
+ ima->ok = IMA_OK_LOADED;
+
+ ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
+ }
+
+ if (m_doDepthBuffer) {
+ addzbuffloatImBuf(ibuf);
+ }
+
+ /* now we combine the input with ibuf */
+ this->m_outputBuffer = ibuf->rect_float;
+
+ /* needed for display buffer update */
+ this->m_ibuf = ibuf;
+
+ if (m_doDepthBuffer) {
+ this->m_depthBuffer = ibuf->zbuf_float;
+ }
+
+ BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);
+
+ BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
void ViewerOperation::updateImage(rcti *rect)
{
- IMB_partial_display_buffer_update(this->m_ibuf, this->m_outputBuffer, NULL, getWidth(), 0, 0,
- this->m_viewSettings, this->m_displaySettings,
- rect->xmin, rect->ymin, rect->xmax, rect->ymax, false);
-
- this->updateDraw();
+ IMB_partial_display_buffer_update(this->m_ibuf,
+ this->m_outputBuffer,
+ NULL,
+ getWidth(),
+ 0,
+ 0,
+ this->m_viewSettings,
+ this->m_displaySettings,
+ rect->xmin,
+ rect->ymin,
+ rect->xmax,
+ rect->ymax,
+ false);
+
+ this->updateDraw();
}
CompositorPriority ViewerOperation::getRenderPriority() const
{
- if (this->isActiveViewerOutput()) {
- return COM_PRIORITY_HIGH;
- }
- else {
- return COM_PRIORITY_LOW;
- }
+ if (this->isActiveViewerOutput()) {
+ return COM_PRIORITY_HIGH;
+ }
+ else {
+ return COM_PRIORITY_LOW;
+ }
}
diff --git a/source/blender/compositor/operations/COM_ViewerOperation.h b/source/blender/compositor/operations/COM_ViewerOperation.h
index 49a2b0962d1..29c3b6d8075 100644
--- a/source/blender/compositor/operations/COM_ViewerOperation.h
+++ b/source/blender/compositor/operations/COM_ViewerOperation.h
@@ -24,55 +24,108 @@
#include "BKE_global.h"
class ViewerOperation : public NodeOperation {
-private:
- float *m_outputBuffer;
- float *m_depthBuffer;
- Image *m_image;
- ImageUser *m_imageUser;
- bool m_active;
- float m_centerX;
- float m_centerY;
- OrderOfChunks m_chunkOrder;
- bool m_doDepthBuffer;
- ImBuf *m_ibuf;
- bool m_useAlphaInput;
- const RenderData *m_rd;
- const char *m_viewName;
+ private:
+ float *m_outputBuffer;
+ float *m_depthBuffer;
+ Image *m_image;
+ ImageUser *m_imageUser;
+ bool m_active;
+ float m_centerX;
+ float m_centerY;
+ OrderOfChunks m_chunkOrder;
+ bool m_doDepthBuffer;
+ ImBuf *m_ibuf;
+ bool m_useAlphaInput;
+ const RenderData *m_rd;
+ const char *m_viewName;
- const ColorManagedViewSettings *m_viewSettings;
- const ColorManagedDisplaySettings *m_displaySettings;
+ const ColorManagedViewSettings *m_viewSettings;
+ const ColorManagedDisplaySettings *m_displaySettings;
- SocketReader *m_imageInput;
- SocketReader *m_alphaInput;
- SocketReader *m_depthInput;
+ SocketReader *m_imageInput;
+ SocketReader *m_alphaInput;
+ SocketReader *m_depthInput;
-public:
- ViewerOperation();
- void initExecution();
- void deinitExecution();
- void executeRegion(rcti *rect, unsigned int tileNumber);
- bool isOutputOperation(bool /*rendering*/) const { if (G.background) return false; return isActiveViewerOutput(); }
- void setImage(Image *image) { this->m_image = image; }
- void setImageUser(ImageUser *imageUser) { this->m_imageUser = imageUser; }
- bool isActiveViewerOutput() const { return this->m_active; }
- void setActive(bool active) { this->m_active = active; }
- void setCenterX(float centerX) { this->m_centerX = centerX;}
- void setCenterY(float centerY) { this->m_centerY = centerY;}
- void setChunkOrder(OrderOfChunks tileOrder) { this->m_chunkOrder = tileOrder; }
- float getCenterX() const { return this->m_centerX; }
- float getCenterY() const { return this->m_centerY; }
- OrderOfChunks getChunkOrder() const { return this->m_chunkOrder; }
- CompositorPriority getRenderPriority() const;
- bool isViewerOperation() const { return true; }
- void setUseAlphaInput(bool value) { this->m_useAlphaInput = value; }
- void setRenderData(const RenderData *rd) { this->m_rd = rd; }
- void setViewName(const char *viewName) { this->m_viewName = viewName; }
+ public:
+ ViewerOperation();
+ void initExecution();
+ void deinitExecution();
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ bool isOutputOperation(bool /*rendering*/) const
+ {
+ if (G.background)
+ return false;
+ return isActiveViewerOutput();
+ }
+ void setImage(Image *image)
+ {
+ this->m_image = image;
+ }
+ void setImageUser(ImageUser *imageUser)
+ {
+ this->m_imageUser = imageUser;
+ }
+ bool isActiveViewerOutput() const
+ {
+ return this->m_active;
+ }
+ void setActive(bool active)
+ {
+ this->m_active = active;
+ }
+ void setCenterX(float centerX)
+ {
+ this->m_centerX = centerX;
+ }
+ void setCenterY(float centerY)
+ {
+ this->m_centerY = centerY;
+ }
+ void setChunkOrder(OrderOfChunks tileOrder)
+ {
+ this->m_chunkOrder = tileOrder;
+ }
+ float getCenterX() const
+ {
+ return this->m_centerX;
+ }
+ float getCenterY() const
+ {
+ return this->m_centerY;
+ }
+ OrderOfChunks getChunkOrder() const
+ {
+ return this->m_chunkOrder;
+ }
+ CompositorPriority getRenderPriority() const;
+ bool isViewerOperation() const
+ {
+ return true;
+ }
+ void setUseAlphaInput(bool value)
+ {
+ this->m_useAlphaInput = value;
+ }
+ void setRenderData(const RenderData *rd)
+ {
+ this->m_rd = rd;
+ }
+ void setViewName(const char *viewName)
+ {
+ this->m_viewName = viewName;
+ }
- void setViewSettings(const ColorManagedViewSettings *viewSettings) { this->m_viewSettings = viewSettings; }
- void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings) { this->m_displaySettings = displaySettings; }
+ void setViewSettings(const ColorManagedViewSettings *viewSettings)
+ {
+ this->m_viewSettings = viewSettings;
+ }
+ void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
+ {
+ this->m_displaySettings = displaySettings;
+ }
-private:
- void updateImage(rcti *rect);
- void initImage();
+ private:
+ void updateImage(rcti *rect);
+ void initImage();
};
#endif
diff --git a/source/blender/compositor/operations/COM_WrapOperation.cpp b/source/blender/compositor/operations/COM_WrapOperation.cpp
index c43e6961064..e55f63f7d73 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.cpp
+++ b/source/blender/compositor/operations/COM_WrapOperation.cpp
@@ -20,86 +20,92 @@
WrapOperation::WrapOperation(DataType datatype) : ReadBufferOperation(datatype)
{
- this->m_wrappingType = CMP_NODE_WRAP_NONE;
+ this->m_wrappingType = CMP_NODE_WRAP_NONE;
}
inline float WrapOperation::getWrappedOriginalXPos(float x)
{
- if (this->getWidth() == 0) return 0;
- while (x < 0) x += this->m_width;
- return fmodf(x, this->getWidth());
+ if (this->getWidth() == 0)
+ return 0;
+ while (x < 0)
+ x += this->m_width;
+ return fmodf(x, this->getWidth());
}
inline float WrapOperation::getWrappedOriginalYPos(float y)
{
- if (this->getHeight() == 0) return 0;
- while (y < 0) y += this->m_height;
- return fmodf(y, this->getHeight());
+ if (this->getHeight() == 0)
+ return 0;
+ while (y < 0)
+ y += this->m_height;
+ return fmodf(y, this->getHeight());
}
void WrapOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
{
- float nx, ny;
- nx = x;
- ny = y;
- MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP;
- switch (m_wrappingType) {
- case CMP_NODE_WRAP_NONE:
- //Intentionally empty, originalXPos and originalYPos have been set before
- break;
- case CMP_NODE_WRAP_X:
- // wrap only on the x-axis
- nx = this->getWrappedOriginalXPos(x);
- extend_x = COM_MB_REPEAT;
- break;
- case CMP_NODE_WRAP_Y:
- // wrap only on the y-axis
- ny = this->getWrappedOriginalYPos(y);
- extend_y = COM_MB_REPEAT;
- break;
- case CMP_NODE_WRAP_XY:
- // wrap on both
- nx = this->getWrappedOriginalXPos(x);
- ny = this->getWrappedOriginalYPos(y);
- extend_x = COM_MB_REPEAT;
- extend_y = COM_MB_REPEAT;
- break;
- }
+ float nx, ny;
+ nx = x;
+ ny = y;
+ MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP;
+ switch (m_wrappingType) {
+ case CMP_NODE_WRAP_NONE:
+ //Intentionally empty, originalXPos and originalYPos have been set before
+ break;
+ case CMP_NODE_WRAP_X:
+ // wrap only on the x-axis
+ nx = this->getWrappedOriginalXPos(x);
+ extend_x = COM_MB_REPEAT;
+ break;
+ case CMP_NODE_WRAP_Y:
+ // wrap only on the y-axis
+ ny = this->getWrappedOriginalYPos(y);
+ extend_y = COM_MB_REPEAT;
+ break;
+ case CMP_NODE_WRAP_XY:
+ // wrap on both
+ nx = this->getWrappedOriginalXPos(x);
+ ny = this->getWrappedOriginalYPos(y);
+ extend_x = COM_MB_REPEAT;
+ extend_y = COM_MB_REPEAT;
+ break;
+ }
- executePixelExtend(output, nx, ny, sampler, extend_x, extend_y);
+ executePixelExtend(output, nx, ny, sampler, extend_x, extend_y);
}
-bool WrapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool WrapOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- newInput.xmin = input->xmin;
- newInput.xmax = input->xmax;
- newInput.ymin = input->ymin;
- newInput.ymax = input->ymax;
+ rcti newInput;
+ newInput.xmin = input->xmin;
+ newInput.xmax = input->xmax;
+ newInput.ymin = input->ymin;
+ newInput.ymax = input->ymax;
- if (m_wrappingType == CMP_NODE_WRAP_X || m_wrappingType == CMP_NODE_WRAP_XY) {
- // wrap only on the x-axis if tile is wrapping
- newInput.xmin = getWrappedOriginalXPos(input->xmin);
- newInput.xmax = getWrappedOriginalXPos(input->xmax) + 0.5f;
- if (newInput.xmin >= newInput.xmax) {
- newInput.xmin = 0;
- newInput.xmax = this->getWidth();
- }
- }
- if (m_wrappingType == CMP_NODE_WRAP_Y || m_wrappingType == CMP_NODE_WRAP_XY) {
- // wrap only on the y-axis if tile is wrapping
- newInput.ymin = getWrappedOriginalYPos(input->ymin);
- newInput.ymax = getWrappedOriginalYPos(input->ymax) + 0.5f;
- if (newInput.ymin >= newInput.ymax) {
- newInput.ymin = 0;
- newInput.ymax = this->getHeight();
- }
- }
+ if (m_wrappingType == CMP_NODE_WRAP_X || m_wrappingType == CMP_NODE_WRAP_XY) {
+ // wrap only on the x-axis if tile is wrapping
+ newInput.xmin = getWrappedOriginalXPos(input->xmin);
+ newInput.xmax = getWrappedOriginalXPos(input->xmax) + 0.5f;
+ if (newInput.xmin >= newInput.xmax) {
+ newInput.xmin = 0;
+ newInput.xmax = this->getWidth();
+ }
+ }
+ if (m_wrappingType == CMP_NODE_WRAP_Y || m_wrappingType == CMP_NODE_WRAP_XY) {
+ // wrap only on the y-axis if tile is wrapping
+ newInput.ymin = getWrappedOriginalYPos(input->ymin);
+ newInput.ymax = getWrappedOriginalYPos(input->ymax) + 0.5f;
+ if (newInput.ymin >= newInput.ymax) {
+ newInput.ymin = 0;
+ newInput.ymax = this->getHeight();
+ }
+ }
- return ReadBufferOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ return ReadBufferOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void WrapOperation::setWrapping(int wrapping_type)
{
- m_wrappingType = wrapping_type;
+ m_wrappingType = wrapping_type;
}
diff --git a/source/blender/compositor/operations/COM_WrapOperation.h b/source/blender/compositor/operations/COM_WrapOperation.h
index 2e25cbd552d..6360fa0c246 100644
--- a/source/blender/compositor/operations/COM_WrapOperation.h
+++ b/source/blender/compositor/operations/COM_WrapOperation.h
@@ -22,18 +22,21 @@
#include "COM_ReadBufferOperation.h"
class WrapOperation : public ReadBufferOperation {
-private:
- int m_wrappingType;
-public:
- WrapOperation(DataType datetype);
- bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ private:
+ int m_wrappingType;
- void setWrapping(int wrapping_type);
- float getWrappedOriginalXPos(float x);
- float getWrappedOriginalYPos(float y);
+ public:
+ WrapOperation(DataType datetype);
+ bool determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- void setFactorXY(float factorX, float factorY);
+ void setWrapping(int wrapping_type);
+ float getWrappedOriginalXPos(float x);
+ float getWrappedOriginalYPos(float y);
+
+ void setFactorXY(float factorX, float factorY);
};
#endif
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
index 30c1d4525ab..beba29e6755 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp
@@ -23,168 +23,206 @@
WriteBufferOperation::WriteBufferOperation(DataType datatype) : NodeOperation()
{
- this->addInputSocket(datatype);
- this->m_memoryProxy = new MemoryProxy(datatype);
- this->m_memoryProxy->setWriteBufferOperation(this);
- this->m_memoryProxy->setExecutor(NULL);
+ this->addInputSocket(datatype);
+ this->m_memoryProxy = new MemoryProxy(datatype);
+ this->m_memoryProxy->setWriteBufferOperation(this);
+ this->m_memoryProxy->setExecutor(NULL);
}
WriteBufferOperation::~WriteBufferOperation()
{
- if (this->m_memoryProxy) {
- delete this->m_memoryProxy;
- this->m_memoryProxy = NULL;
- }
+ if (this->m_memoryProxy) {
+ delete this->m_memoryProxy;
+ this->m_memoryProxy = NULL;
+ }
}
-void WriteBufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void WriteBufferOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- this->m_input->readSampled(output, x, y, sampler);
+ this->m_input->readSampled(output, x, y, sampler);
}
void WriteBufferOperation::initExecution()
{
- this->m_input = this->getInputOperation(0);
- this->m_memoryProxy->allocate(this->m_width, this->m_height);
+ this->m_input = this->getInputOperation(0);
+ this->m_memoryProxy->allocate(this->m_width, this->m_height);
}
void WriteBufferOperation::deinitExecution()
{
- this->m_input = NULL;
- this->m_memoryProxy->free();
+ this->m_input = NULL;
+ this->m_memoryProxy->free();
}
void WriteBufferOperation::executeRegion(rcti *rect, unsigned int /*tileNumber*/)
{
- MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
- float *buffer = memoryBuffer->getBuffer();
- const int num_channels = memoryBuffer->get_num_channels();
- if (this->m_input->isComplex()) {
- void *data = this->m_input->initializeTileData(rect);
- int x1 = rect->xmin;
- int y1 = rect->ymin;
- int x2 = rect->xmax;
- int y2 = rect->ymax;
- int x;
- int y;
- bool breaked = false;
- for (y = y1; y < y2 && (!breaked); y++) {
- int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
- for (x = x1; x < x2; x++) {
- this->m_input->read(&(buffer[offset4]), x, y, data);
- offset4 += num_channels;
- }
- if (isBreaked()) {
- breaked = true;
- }
-
- }
- if (data) {
- this->m_input->deinitializeTileData(rect, data);
- data = NULL;
- }
- }
- else {
- int x1 = rect->xmin;
- int y1 = rect->ymin;
- int x2 = rect->xmax;
- int y2 = rect->ymax;
-
- int x;
- int y;
- bool breaked = false;
- for (y = y1; y < y2 && (!breaked); y++) {
- int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
- for (x = x1; x < x2; x++) {
- this->m_input->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
- offset4 += num_channels;
- }
- if (isBreaked()) {
- breaked = true;
- }
- }
- }
- memoryBuffer->setCreatedState();
+ MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer();
+ float *buffer = memoryBuffer->getBuffer();
+ const int num_channels = memoryBuffer->get_num_channels();
+ if (this->m_input->isComplex()) {
+ void *data = this->m_input->initializeTileData(rect);
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+ int x;
+ int y;
+ bool breaked = false;
+ for (y = y1; y < y2 && (!breaked); y++) {
+ int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
+ for (x = x1; x < x2; x++) {
+ this->m_input->read(&(buffer[offset4]), x, y, data);
+ offset4 += num_channels;
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ if (data) {
+ this->m_input->deinitializeTileData(rect, data);
+ data = NULL;
+ }
+ }
+ else {
+ int x1 = rect->xmin;
+ int y1 = rect->ymin;
+ int x2 = rect->xmax;
+ int y2 = rect->ymax;
+
+ int x;
+ int y;
+ bool breaked = false;
+ for (y = y1; y < y2 && (!breaked); y++) {
+ int offset4 = (y * memoryBuffer->getWidth() + x1) * num_channels;
+ for (x = x1; x < x2; x++) {
+ this->m_input->readSampled(&(buffer[offset4]), x, y, COM_PS_NEAREST);
+ offset4 += num_channels;
+ }
+ if (isBreaked()) {
+ breaked = true;
+ }
+ }
+ }
+ memoryBuffer->setCreatedState();
}
-void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device, rcti * /*rect*/, unsigned int /*chunkNumber*/,
- MemoryBuffer **inputMemoryBuffers, MemoryBuffer *outputBuffer)
+void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice *device,
+ rcti * /*rect*/,
+ unsigned int /*chunkNumber*/,
+ MemoryBuffer **inputMemoryBuffers,
+ MemoryBuffer *outputBuffer)
{
- float *outputFloatBuffer = outputBuffer->getBuffer();
- cl_int error;
- /*
- * 1. create cl_mem from outputbuffer
- * 2. call NodeOperation (input) executeOpenCLChunk(.....)
- * 3. schedule readback from opencl to main device (outputbuffer)
- * 4. schedule native callback
- *
- * note: list of cl_mem will be filled by 2, and needs to be cleaned up by 4
- */
- // STEP 1
- const unsigned int outputBufferWidth = outputBuffer->getWidth();
- const unsigned int outputBufferHeight = outputBuffer->getHeight();
-
- const cl_image_format *imageFormat = device->determineImageFormat(outputBuffer);
-
- cl_mem clOutputBuffer = clCreateImage2D(device->getContext(), CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, imageFormat, outputBufferWidth, outputBufferHeight, 0, outputFloatBuffer, &error);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
-
- // STEP 2
- list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
- clMemToCleanUp->push_back(clOutputBuffer);
- list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
-
- this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp);
-
- // STEP 3
-
- size_t origin[3] = {0, 0, 0};
- size_t region[3] = {outputBufferWidth, outputBufferHeight, 1};
-
-// clFlush(queue);
-// clFinish(queue);
-
- error = clEnqueueBarrier(device->getQueue());
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- error = clEnqueueReadImage(device->getQueue(), clOutputBuffer, CL_TRUE, origin, region, 0, 0, outputFloatBuffer, 0, NULL, NULL);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
-
- this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
-
- // STEP 4
- while (!clMemToCleanUp->empty()) {
- cl_mem mem = clMemToCleanUp->front();
- error = clReleaseMemObject(mem);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- clMemToCleanUp->pop_front();
- }
-
- while (!clKernelsToCleanUp->empty()) {
- cl_kernel kernel = clKernelsToCleanUp->front();
- error = clReleaseKernel(kernel);
- if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); }
- clKernelsToCleanUp->pop_front();
- }
- delete clKernelsToCleanUp;
+ float *outputFloatBuffer = outputBuffer->getBuffer();
+ cl_int error;
+ /*
+ * 1. create cl_mem from outputbuffer
+ * 2. call NodeOperation (input) executeOpenCLChunk(.....)
+ * 3. schedule readback from opencl to main device (outputbuffer)
+ * 4. schedule native callback
+ *
+ * note: list of cl_mem will be filled by 2, and needs to be cleaned up by 4
+ */
+ // STEP 1
+ const unsigned int outputBufferWidth = outputBuffer->getWidth();
+ const unsigned int outputBufferHeight = outputBuffer->getHeight();
+
+ const cl_image_format *imageFormat = device->determineImageFormat(outputBuffer);
+
+ cl_mem clOutputBuffer = clCreateImage2D(device->getContext(),
+ CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR,
+ imageFormat,
+ outputBufferWidth,
+ outputBufferHeight,
+ 0,
+ outputFloatBuffer,
+ &error);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+
+ // STEP 2
+ list<cl_mem> *clMemToCleanUp = new list<cl_mem>();
+ clMemToCleanUp->push_back(clOutputBuffer);
+ list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>();
+
+ this->m_input->executeOpenCL(device,
+ outputBuffer,
+ clOutputBuffer,
+ inputMemoryBuffers,
+ clMemToCleanUp,
+ clKernelsToCleanUp);
+
+ // STEP 3
+
+ size_t origin[3] = {0, 0, 0};
+ size_t region[3] = {outputBufferWidth, outputBufferHeight, 1};
+
+ // clFlush(queue);
+ // clFinish(queue);
+
+ error = clEnqueueBarrier(device->getQueue());
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ error = clEnqueueReadImage(device->getQueue(),
+ clOutputBuffer,
+ CL_TRUE,
+ origin,
+ region,
+ 0,
+ 0,
+ outputFloatBuffer,
+ 0,
+ NULL,
+ NULL);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+
+ this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer);
+
+ // STEP 4
+ while (!clMemToCleanUp->empty()) {
+ cl_mem mem = clMemToCleanUp->front();
+ error = clReleaseMemObject(mem);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ clMemToCleanUp->pop_front();
+ }
+
+ while (!clKernelsToCleanUp->empty()) {
+ cl_kernel kernel = clKernelsToCleanUp->front();
+ error = clReleaseKernel(kernel);
+ if (error != CL_SUCCESS) {
+ printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
+ }
+ clKernelsToCleanUp->pop_front();
+ }
+ delete clKernelsToCleanUp;
}
-void WriteBufferOperation::determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2])
+void WriteBufferOperation::determineResolution(unsigned int resolution[2],
+ unsigned int preferredResolution[2])
{
- NodeOperation::determineResolution(resolution, preferredResolution);
- /* make sure there is at least one pixel stored in case the input is a single value */
- m_single_value = false;
- if (resolution[0] == 0) {
- resolution[0] = 1;
- m_single_value = true;
- }
- if (resolution[1] == 0) {
- resolution[1] = 1;
- m_single_value = true;
- }
+ NodeOperation::determineResolution(resolution, preferredResolution);
+ /* make sure there is at least one pixel stored in case the input is a single value */
+ m_single_value = false;
+ if (resolution[0] == 0) {
+ resolution[0] = 1;
+ m_single_value = true;
+ }
+ if (resolution[1] == 0) {
+ resolution[1] = 1;
+ m_single_value = true;
+ }
}
void WriteBufferOperation::readResolutionFromInputSocket()
{
- NodeOperation *inputOperation = this->getInputOperation(0);
- this->setWidth(inputOperation->getWidth());
- this->setHeight(inputOperation->getHeight());
+ NodeOperation *inputOperation = this->getInputOperation(0);
+ this->setWidth(inputOperation->getWidth());
+ this->setHeight(inputOperation->getHeight());
}
diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.h b/source/blender/compositor/operations/COM_WriteBufferOperation.h
index be8a8fb7159..83f7ed1ae56 100644
--- a/source/blender/compositor/operations/COM_WriteBufferOperation.h
+++ b/source/blender/compositor/operations/COM_WriteBufferOperation.h
@@ -27,26 +27,40 @@
* \ingroup Operation
*/
class WriteBufferOperation : public NodeOperation {
- MemoryProxy *m_memoryProxy;
- bool m_single_value; /* single value stored in buffer */
- NodeOperation *m_input;
-public:
- WriteBufferOperation(DataType datatype);
- ~WriteBufferOperation();
- MemoryProxy *getMemoryProxy() { return this->m_memoryProxy; }
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
- bool isWriteBufferOperation() const { return true; }
- bool isSingleValue() const { return m_single_value; }
+ MemoryProxy *m_memoryProxy;
+ bool m_single_value; /* single value stored in buffer */
+ NodeOperation *m_input;
- void executeRegion(rcti *rect, unsigned int tileNumber);
- void initExecution();
- void deinitExecution();
- void executeOpenCLRegion(OpenCLDevice *device, rcti *rect, unsigned int chunkNumber, MemoryBuffer **memoryBuffers, MemoryBuffer *outputBuffer);
- void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
- void readResolutionFromInputSocket();
- inline NodeOperation *getInput() {
- return m_input;
- }
+ public:
+ WriteBufferOperation(DataType datatype);
+ ~WriteBufferOperation();
+ MemoryProxy *getMemoryProxy()
+ {
+ return this->m_memoryProxy;
+ }
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ bool isWriteBufferOperation() const
+ {
+ return true;
+ }
+ bool isSingleValue() const
+ {
+ return m_single_value;
+ }
+ void executeRegion(rcti *rect, unsigned int tileNumber);
+ void initExecution();
+ void deinitExecution();
+ void executeOpenCLRegion(OpenCLDevice *device,
+ rcti *rect,
+ unsigned int chunkNumber,
+ MemoryBuffer **memoryBuffers,
+ MemoryBuffer *outputBuffer);
+ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
+ void readResolutionFromInputSocket();
+ inline NodeOperation *getInput()
+ {
+ return m_input;
+ }
};
#endif
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.cpp b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
index 5c7472acbe8..222f42e8241 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.cpp
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.cpp
@@ -21,129 +21,140 @@
ZCombineOperation::ZCombineOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
-
- this->m_image1Reader = NULL;
- this->m_depth1Reader = NULL;
- this->m_image2Reader = NULL;
- this->m_depth2Reader = NULL;
-
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->m_image1Reader = NULL;
+ this->m_depth1Reader = NULL;
+ this->m_image2Reader = NULL;
+ this->m_depth2Reader = NULL;
}
void ZCombineOperation::initExecution()
{
- this->m_image1Reader = this->getInputSocketReader(0);
- this->m_depth1Reader = this->getInputSocketReader(1);
- this->m_image2Reader = this->getInputSocketReader(2);
- this->m_depth2Reader = this->getInputSocketReader(3);
+ this->m_image1Reader = this->getInputSocketReader(0);
+ this->m_depth1Reader = this->getInputSocketReader(1);
+ this->m_image2Reader = this->getInputSocketReader(2);
+ this->m_depth2Reader = this->getInputSocketReader(3);
}
-void ZCombineOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float depth1[4];
- float depth2[4];
-
- this->m_depth1Reader->readSampled(depth1, x, y, sampler);
- this->m_depth2Reader->readSampled(depth2, x, y, sampler);
- if (depth1[0] < depth2[0]) {
- this->m_image1Reader->readSampled(output, x, y, sampler);
- }
- else {
- this->m_image2Reader->readSampled(output, x, y, sampler);
- }
+ float depth1[4];
+ float depth2[4];
+
+ this->m_depth1Reader->readSampled(depth1, x, y, sampler);
+ this->m_depth2Reader->readSampled(depth2, x, y, sampler);
+ if (depth1[0] < depth2[0]) {
+ this->m_image1Reader->readSampled(output, x, y, sampler);
+ }
+ else {
+ this->m_image2Reader->readSampled(output, x, y, sampler);
+ }
}
-void ZCombineAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float depth1[4];
- float depth2[4];
- float color1[4];
- float color2[4];
-
- this->m_depth1Reader->readSampled(depth1, x, y, sampler);
- this->m_depth2Reader->readSampled(depth2, x, y, sampler);
- if (depth1[0] <= depth2[0]) {
- this->m_image1Reader->readSampled(color1, x, y, sampler);
- this->m_image2Reader->readSampled(color2, x, y, sampler);
- }
- else {
- this->m_image1Reader->readSampled(color2, x, y, sampler);
- this->m_image2Reader->readSampled(color1, x, y, sampler);
- }
- float fac = color1[3];
- float ifac = 1.0f - fac;
- output[0] = fac * color1[0] + ifac * color2[0];
- output[1] = fac * color1[1] + ifac * color2[1];
- output[2] = fac * color1[2] + ifac * color2[2];
- output[3] = max(color1[3], color2[3]);
+ float depth1[4];
+ float depth2[4];
+ float color1[4];
+ float color2[4];
+
+ this->m_depth1Reader->readSampled(depth1, x, y, sampler);
+ this->m_depth2Reader->readSampled(depth2, x, y, sampler);
+ if (depth1[0] <= depth2[0]) {
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
+ }
+ else {
+ this->m_image1Reader->readSampled(color2, x, y, sampler);
+ this->m_image2Reader->readSampled(color1, x, y, sampler);
+ }
+ float fac = color1[3];
+ float ifac = 1.0f - fac;
+ output[0] = fac * color1[0] + ifac * color2[0];
+ output[1] = fac * color1[1] + ifac * color2[1];
+ output[2] = fac * color1[2] + ifac * color2[2];
+ output[3] = max(color1[3], color2[3]);
}
void ZCombineOperation::deinitExecution()
{
- this->m_image1Reader = NULL;
- this->m_depth1Reader = NULL;
- this->m_image2Reader = NULL;
- this->m_depth2Reader = NULL;
+ this->m_image1Reader = NULL;
+ this->m_depth1Reader = NULL;
+ this->m_image2Reader = NULL;
+ this->m_depth2Reader = NULL;
}
// MASK combine
ZCombineMaskOperation::ZCombineMaskOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_VALUE); //mask
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_COLOR);
- this->addOutputSocket(COM_DT_COLOR);
-
- this->m_maskReader = NULL;
- this->m_image1Reader = NULL;
- this->m_image2Reader = NULL;
+ this->addInputSocket(COM_DT_VALUE); //mask
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addOutputSocket(COM_DT_COLOR);
+
+ this->m_maskReader = NULL;
+ this->m_image1Reader = NULL;
+ this->m_image2Reader = NULL;
}
void ZCombineMaskOperation::initExecution()
{
- this->m_maskReader = this->getInputSocketReader(0);
- this->m_image1Reader = this->getInputSocketReader(1);
- this->m_image2Reader = this->getInputSocketReader(2);
+ this->m_maskReader = this->getInputSocketReader(0);
+ this->m_image1Reader = this->getInputSocketReader(1);
+ this->m_image2Reader = this->getInputSocketReader(2);
}
-void ZCombineMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineMaskOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float mask[4];
- float color1[4];
- float color2[4];
+ float mask[4];
+ float color1[4];
+ float color2[4];
- this->m_maskReader->readSampled(mask, x, y, sampler);
- this->m_image1Reader->readSampled(color1, x, y, sampler);
- this->m_image2Reader->readSampled(color2, x, y, sampler);
+ this->m_maskReader->readSampled(mask, x, y, sampler);
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
- interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]);
+ interp_v4_v4v4(output, color1, color2, 1.0f - mask[0]);
}
-void ZCombineMaskAlphaOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ZCombineMaskAlphaOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float mask[4];
- float color1[4];
- float color2[4];
+ float mask[4];
+ float color1[4];
+ float color2[4];
- this->m_maskReader->readSampled(mask, x, y, sampler);
- this->m_image1Reader->readSampled(color1, x, y, sampler);
- this->m_image2Reader->readSampled(color2, x, y, sampler);
+ this->m_maskReader->readSampled(mask, x, y, sampler);
+ this->m_image1Reader->readSampled(color1, x, y, sampler);
+ this->m_image2Reader->readSampled(color2, x, y, sampler);
- float fac = (1.0f - mask[0]) * (1.0f - color1[3]) + mask[0] * color2[3];
- float mfac = 1.0f - fac;
+ float fac = (1.0f - mask[0]) * (1.0f - color1[3]) + mask[0] * color2[3];
+ float mfac = 1.0f - fac;
- output[0] = color1[0] * mfac + color2[0] * fac;
- output[1] = color1[1] * mfac + color2[1] * fac;
- output[2] = color1[2] * mfac + color2[2] * fac;
- output[3] = max(color1[3], color2[3]);
+ output[0] = color1[0] * mfac + color2[0] * fac;
+ output[1] = color1[1] * mfac + color2[1] * fac;
+ output[2] = color1[2] * mfac + color2[2] * fac;
+ output[3] = max(color1[3], color2[3]);
}
void ZCombineMaskOperation::deinitExecution()
{
- this->m_image1Reader = NULL;
- this->m_maskReader = NULL;
- this->m_image2Reader = NULL;
+ this->m_image1Reader = NULL;
+ this->m_maskReader = NULL;
+ this->m_image2Reader = NULL;
}
diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h
index 9f9ecfa57e9..9a93d080a2f 100644
--- a/source/blender/compositor/operations/COM_ZCombineOperation.h
+++ b/source/blender/compositor/operations/COM_ZCombineOperation.h
@@ -20,50 +20,51 @@
#define __COM_ZCOMBINEOPERATION_H__
#include "COM_MixOperation.h"
-
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ZCombineOperation : public NodeOperation {
-protected:
- SocketReader *m_image1Reader;
- SocketReader *m_depth1Reader;
- SocketReader *m_image2Reader;
- SocketReader *m_depth2Reader;
-public:
- /**
- * Default constructor
- */
- ZCombineOperation();
+ protected:
+ SocketReader *m_image1Reader;
+ SocketReader *m_depth1Reader;
+ SocketReader *m_image2Reader;
+ SocketReader *m_depth2Reader;
+
+ public:
+ /**
+ * Default constructor
+ */
+ ZCombineOperation();
- void initExecution();
- void deinitExecution();
+ void initExecution();
+ void deinitExecution();
- /**
- * the inner loop of this program
- */
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineAlphaOperation : public ZCombineOperation {
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineMaskOperation : public NodeOperation {
-protected:
- SocketReader *m_maskReader;
- SocketReader *m_image1Reader;
- SocketReader *m_image2Reader;
-public:
- ZCombineMaskOperation();
+ protected:
+ SocketReader *m_maskReader;
+ SocketReader *m_image1Reader;
+ SocketReader *m_image2Reader;
+
+ public:
+ ZCombineMaskOperation();
- void initExecution();
- void deinitExecution();
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void initExecution();
+ void deinitExecution();
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
class ZCombineMaskAlphaOperation : public ZCombineMaskOperation {
- void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
};
#endif