~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/compositor/nodes/COM_MixNode.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_MixNode.h"
 
24
 
 
25
#include "COM_MixBlendOperation.h"
 
26
#include "COM_MixAddOperation.h"
 
27
#include "COM_MixMultiplyOperation.h"
 
28
#include "COM_MixBurnOperation.h"
 
29
#include "COM_MixColorOperation.h"
 
30
#include "COM_MixDarkenOperation.h"
 
31
#include "COM_MixDifferenceOperation.h"
 
32
#include "COM_MixDivideOperation.h"
 
33
#include "COM_MixHueOperation.h"
 
34
#include "COM_MixLightenOperation.h"
 
35
#include "COM_MixLinearLightOperation.h"
 
36
#include "COM_MixOverlayOperation.h"
 
37
#include "COM_MixSaturationOperation.h"
 
38
#include "COM_MixScreenOperation.h"
 
39
#include "COM_MixSoftLightOperation.h"
 
40
#include "COM_MixSubtractOperation.h"
 
41
#include "COM_MixValueOperation.h"
 
42
#include "COM_MixDodgeOperation.h"
 
43
 
 
44
#include "COM_ExecutionSystem.h"
 
45
#include "COM_SetValueOperation.h"
 
46
#include "DNA_material_types.h" // the ramp types
 
47
 
 
48
 
 
49
MixNode::MixNode(bNode *editorNode) : Node(editorNode)
 
50
{
 
51
        /* pass */
 
52
}
 
53
 
 
54
void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
 
55
{
 
56
        InputSocket *valueSocket = this->getInputSocket(0);
 
57
        InputSocket *color1Socket = this->getInputSocket(1);
 
58
        InputSocket *color2Socket = this->getInputSocket(2);
 
59
        OutputSocket *outputSocket = this->getOutputSocket(0);
 
60
        bNode *editorNode = this->getbNode();
 
61
        bool useAlphaPremultiply = this->getbNode()->custom2 & 1;
 
62
        bool useClamp = this->getbNode()->custom2 & 2;
 
63
        
 
64
        MixBaseOperation *convertProg;
 
65
        
 
66
        switch (editorNode->custom1) {
 
67
                case MA_RAMP_ADD:
 
68
                        convertProg = new MixAddOperation();
 
69
                        break;
 
70
                case MA_RAMP_MULT:
 
71
                        convertProg = new MixMultiplyOperation();
 
72
                        break;
 
73
                case MA_RAMP_LIGHT:
 
74
                        convertProg = new MixLightenOperation();
 
75
                        break;
 
76
                case MA_RAMP_BURN:
 
77
                        convertProg = new MixBurnOperation();
 
78
                        break;
 
79
                case MA_RAMP_HUE:
 
80
                        convertProg = new MixHueOperation();
 
81
                        break;
 
82
                case MA_RAMP_COLOR:
 
83
                        convertProg = new MixColorOperation();
 
84
                        break;
 
85
                case MA_RAMP_SOFT:
 
86
                        convertProg = new MixSoftLightOperation();
 
87
                        break;
 
88
                case MA_RAMP_SCREEN:
 
89
                        convertProg = new MixScreenOperation();
 
90
                        break;
 
91
                case MA_RAMP_LINEAR:
 
92
                        convertProg = new MixLinearLightOperation();
 
93
                        break;
 
94
                case MA_RAMP_DIFF:
 
95
                        convertProg = new MixDifferenceOperation();
 
96
                        break;
 
97
                case MA_RAMP_SAT:
 
98
                        convertProg = new MixSaturationOperation();
 
99
                        break;
 
100
                case MA_RAMP_DIV:
 
101
                        convertProg = new MixDivideOperation();
 
102
                        break;
 
103
                case MA_RAMP_SUB:
 
104
                        convertProg = new MixSubtractOperation();
 
105
                        break;
 
106
                case MA_RAMP_DARK:
 
107
                        convertProg = new MixDarkenOperation();
 
108
                        break;
 
109
                case MA_RAMP_OVERLAY:
 
110
                        convertProg = new MixOverlayOperation();
 
111
                        break;
 
112
                case MA_RAMP_VAL:
 
113
                        convertProg = new MixValueOperation();
 
114
                        break;
 
115
                case MA_RAMP_DODGE:
 
116
                        convertProg = new MixDodgeOperation();
 
117
                        break;
 
118
 
 
119
                case MA_RAMP_BLEND:
 
120
                default:
 
121
                        convertProg = new MixBlendOperation();
 
122
                        break;
 
123
        }
 
124
        convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
 
125
        convertProg->setUseClamp(useClamp);
 
126
 
 
127
        valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
 
128
        color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
 
129
        color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph);
 
130
        outputSocket->relinkConnections(convertProg->getOutputSocket(0));
 
131
        addPreviewOperation(graph, context, convertProg->getOutputSocket(0));
 
132
        
 
133
        convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode());
 
134
        
 
135
        graph->addOperation(convertProg);
 
136
}