2 * Copyright 2012, Blender Foundation.
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.
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.
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.
24 #include "COM_MaskNode.h"
25 #include "COM_ExecutionSystem.h"
26 #include "COM_MaskOperation.h"
29 #include "DNA_mask_types.h"
32 MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
37 void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
39 const RenderData *data = &context->getScene()->r;
41 OutputSocket *outputMask = this->getOutputSocket(0);
43 bNode *editorNode = this->getbNode();
44 Mask *mask = (Mask *)editorNode->id;
46 // always connect the output image
47 MaskOperation *operation = new MaskOperation();
49 operation->setMaskWidth(data->xsch * data->size / 100.0f);
50 operation->setMaskHeight(data->ysch * data->size / 100.0f);
52 if (outputMask->isConnected()) {
53 outputMask->relinkConnections(operation->getOutputSocket());
56 operation->setMask(mask);
57 operation->setFramenumber(context->getFramenumber());
58 operation->setSmooth((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_AA) != 0);
59 operation->setFeather((bool)(editorNode->custom1 & CMP_NODEFLAG_MASK_FEATHER) != 0);
61 graph->addOperation(operation);