Blender  V2.93
COM_DistanceMatteNode.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2011, Blender Foundation.
17  */
18 
19 #include "COM_DistanceMatteNode.h"
20 #include "BKE_node.h"
21 #include "COM_ConvertOperation.h"
25 
26 namespace blender::compositor {
27 
29 {
30  /* pass */
31 }
32 
34  const CompositorContext & /*context*/) const
35 {
36  bNode *editorsnode = getbNode();
37  NodeChroma *storage = (NodeChroma *)editorsnode->storage;
38 
39  NodeInput *inputSocketImage = this->getInputSocket(0);
40  NodeInput *inputSocketKey = this->getInputSocket(1);
41  NodeOutput *outputSocketImage = this->getOutputSocket(0);
42  NodeOutput *outputSocketMatte = this->getOutputSocket(1);
43 
45  converter.addOperation(operationAlpha);
46 
47  /* work in RGB color space */
48  NodeOperation *operation;
49  if (storage->channel == 1) {
51  matte->setSettings(storage);
52  converter.addOperation(matte);
53 
54  converter.mapInputSocket(inputSocketImage, matte->getInputSocket(0));
55  converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
56 
57  converter.mapInputSocket(inputSocketKey, matte->getInputSocket(1));
58 
59  operation = matte;
60  }
61  /* work in YCbCr color space */
62  else {
64  matte->setSettings(storage);
65  converter.addOperation(matte);
66 
67  ConvertRGBToYCCOperation *operationYCCImage = new ConvertRGBToYCCOperation();
68  ConvertRGBToYCCOperation *operationYCCMatte = new ConvertRGBToYCCOperation();
69  operationYCCImage->setMode(BLI_YCC_ITU_BT709);
70  operationYCCMatte->setMode(BLI_YCC_ITU_BT709);
71  converter.addOperation(operationYCCImage);
72  converter.addOperation(operationYCCMatte);
73 
74  converter.mapInputSocket(inputSocketImage, operationYCCImage->getInputSocket(0));
75  converter.addLink(operationYCCImage->getOutputSocket(), matte->getInputSocket(0));
76  converter.addLink(operationYCCImage->getOutputSocket(), operationAlpha->getInputSocket(0));
77 
78  converter.mapInputSocket(inputSocketKey, operationYCCMatte->getInputSocket(0));
79  converter.addLink(operationYCCMatte->getOutputSocket(), matte->getInputSocket(1));
80 
81  operation = matte;
82  }
83 
84  converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
85  converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
86 
87  if (storage->channel != 1) {
89  inv_convert->setMode(BLI_YCC_ITU_BT709);
90 
91  converter.addOperation(inv_convert);
92  converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0));
93  converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket());
94  converter.addPreview(inv_convert->getOutputSocket());
95  }
96  else {
97  converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
98  converter.addPreview(operationAlpha->getOutputSocket());
99  }
100 }
101 
102 } // namespace blender::compositor
#define BLI_YCC_ITU_BT709
Overall context of the compositor.
void convertToOperations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
void addPreview(NodeOperationOutput *output)
void addOperation(NodeOperation *operation)
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void addLink(NodeOperationOutput *from, NodeOperationInput *to)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:210
NodeOperation contains calculation logic.
NodeOperationInput * getInputSocket(unsigned int index)
NodeOperationOutput * getOutputSocket(unsigned int index=0)
NodeOutput are sockets that can send data/input.
Definition: COM_Node.h:258
NodeOutput * getOutputSocket(const unsigned int index=0) const
Definition: COM_Node.cc:108
bNode * getbNode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:82
NodeInput * getInputSocket(const unsigned int index) const
Definition: COM_Node.cc:113
void * storage