Cleanup: comment line length (editors)
[blender.git] / source / blender / compositor / nodes / COM_AlphaOverNode.cpp
1 /*
2  * Copyright 2011, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor:
19  *      Jeroen Bakker
20  *      Monique Dewanchand
21  */
22
23 #include "COM_AlphaOverNode.h"
24
25 #include "COM_MixOperation.h"
26 #include "COM_AlphaOverKeyOperation.h"
27 #include "COM_AlphaOverMixedOperation.h"
28 #include "COM_AlphaOverPremultiplyOperation.h"
29
30 #include "COM_SetValueOperation.h"
31 #include "DNA_material_types.h" // the ramp types
32
33 void AlphaOverNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
34 {
35         NodeInput *color1Socket = this->getInputSocket(1);
36         NodeInput *color2Socket = this->getInputSocket(2);
37         bNode *editorNode = this->getbNode();
38
39         MixBaseOperation *convertProg;
40         NodeTwoFloats *ntf = (NodeTwoFloats *)editorNode->storage;
41         if (ntf->x != 0.0f) {
42                 AlphaOverMixedOperation *mixOperation  = new AlphaOverMixedOperation();
43                 mixOperation->setX(ntf->x);
44                 convertProg = mixOperation;
45
46         }
47         else if (editorNode->custom1) {
48                 convertProg = new AlphaOverKeyOperation();
49         }
50         else {
51                 convertProg = new AlphaOverPremultiplyOperation();
52         }
53
54         convertProg->setUseValueAlphaMultiply(false);
55         if (color1Socket->isLinked()) {
56                 convertProg->setResolutionInputSocketIndex(1);
57         }
58         else if (color2Socket->isLinked()) {
59                 convertProg->setResolutionInputSocketIndex(2);
60         }
61         else {
62                 convertProg->setResolutionInputSocketIndex(0);
63         }
64
65         converter.addOperation(convertProg);
66         converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0));
67         converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1));
68         converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2));
69         converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0));
70 }