Keying Screen node from tomato branch
[blender.git] / source / blender / compositor / nodes / COM_KeyingScreenNode.cpp
1 /*
2  * Copyright 2012, 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  *              Sergey Sharybin
22  */
23
24 #include "COM_KeyingScreenNode.h"
25 #include "COM_ExecutionSystem.h"
26 #include "COM_KeyingScreenOperation.h"
27
28 extern "C" {
29         #include "DNA_movieclip_types.h"
30 }
31
32 KeyingScreenNode::KeyingScreenNode(bNode *editorNode): Node(editorNode)
33 {
34 }
35
36 void KeyingScreenNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
37 {
38         OutputSocket *outputScreen = this->getOutputSocket(0);
39
40         bNode *editorNode = this->getbNode();
41         MovieClip *clip = (MovieClip *) editorNode->id;
42
43         NodeKeyingScreenData *keyingscreen_data = (NodeKeyingScreenData *) editorNode->storage;
44
45         // always connect the output image
46         KeyingScreenOperation *operation = new KeyingScreenOperation();
47
48         if (outputScreen->isConnected()) {
49                 outputScreen->relinkConnections(operation->getOutputSocket());
50         }
51
52         operation->setMovieClip(clip);
53         operation->setTrackingObject(keyingscreen_data->tracking_object);
54         operation->setFramenumber(context->getFramenumber());
55
56         graph->addOperation(operation);
57 }