Color Management, Stage 2: Switch color pipeline to use OpenColorIO
[blender.git] / source / blender / compositor / nodes / COM_DespeckleNode.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: Campbell Barton
19  */
20
21 #include "COM_DespeckleNode.h"
22 #include "DNA_scene_types.h"
23 #include "COM_ExecutionSystem.h"
24 #include "COM_DespeckleOperation.h"
25 #include "BLI_math.h"
26
27 DespeckleNode::DespeckleNode(bNode *editorNode) : Node(editorNode)
28 {
29         /* pass */
30 }
31
32 void DespeckleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
33 {
34         bNode *editorNode = this->getbNode();
35         InputSocket *inputSocket = this->getInputSocket(0);
36         InputSocket *inputImageSocket = this->getInputSocket(1);
37         OutputSocket *outputSocket = this->getOutputSocket(0);
38         DespeckleOperation *operation = new DespeckleOperation();
39
40         operation->setbNode(editorNode);
41         operation->setThreshold(editorNode->custom3);
42         operation->setThresholdNeighbour(editorNode->custom4);
43
44         inputImageSocket->relinkConnections(operation->getInputSocket(0), 1, graph);
45         inputSocket->relinkConnections(operation->getInputSocket(1), 0, graph);
46         outputSocket->relinkConnections(operation->getOutputSocket());
47         addPreviewOperation(graph, context, operation->getOutputSocket(0));
48
49         graph->addOperation(operation);
50 }