~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/CMP_nodes/CMP_sepcombRGBA.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: CMP_sepcombRGBA.c,v 1.4 2007/04/04 13:58:10 jesterking Exp $
 
3
 *
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version. 
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software Foundation,
 
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 *
 
20
 * The Original Code is Copyright (C) 2006 Blender Foundation.
 
21
 * All rights reserved.
 
22
 *
 
23
 * The Original Code is: all of this file.
 
24
 *
 
25
 * Contributor(s): none yet.
 
26
 *
 
27
 * ***** END GPL LICENSE BLOCK *****
 
28
 */
 
29
 
 
30
#include "../CMP_util.h"
 
31
 
 
32
/* **************** SEPARATE RGBA ******************** */
 
33
static bNodeSocketType cmp_node_seprgba_in[]= {
 
34
        {       SOCK_RGBA, 1, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
 
35
        {       -1, 0, ""       }
 
36
};
 
37
static bNodeSocketType cmp_node_seprgba_out[]= {
 
38
        {       SOCK_VALUE, 0, "R",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
39
        {       SOCK_VALUE, 0, "G",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
40
        {       SOCK_VALUE, 0, "B",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
41
        {       SOCK_VALUE, 0, "A",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
42
        {       -1, 0, ""       }
 
43
};
 
44
 
 
45
static void node_composit_exec_seprgba(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
46
{
 
47
        /* stack order out: bw channels */
 
48
        /* stack order in: col */
 
49
        
 
50
        /* input no image? then only color operation */
 
51
        if(in[0]->data==NULL) {
 
52
                out[0]->vec[0] = in[0]->vec[0];
 
53
                out[1]->vec[0] = in[0]->vec[1];
 
54
                out[2]->vec[0] = in[0]->vec[2];
 
55
                out[3]->vec[0] = in[0]->vec[3];
 
56
        }
 
57
        else {
 
58
                /* make sure we get right rgba buffer */
 
59
                CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
 
60
 
 
61
                /* don't do any pixel processing, just copy the stack directly (faster, I presume) */
 
62
                if(out[0]->hasoutput)
 
63
                        out[0]->data= valbuf_from_rgbabuf(cbuf, CHAN_R);
 
64
                if(out[1]->hasoutput)
 
65
                        out[1]->data= valbuf_from_rgbabuf(cbuf, CHAN_G);
 
66
                if(out[2]->hasoutput)
 
67
                        out[2]->data= valbuf_from_rgbabuf(cbuf, CHAN_B);
 
68
                if(out[3]->hasoutput)
 
69
                        out[3]->data= valbuf_from_rgbabuf(cbuf, CHAN_A);
 
70
                
 
71
                if(cbuf!=in[0]->data) 
 
72
                        free_compbuf(cbuf);
 
73
 
 
74
        }
 
75
}
 
76
 
 
77
bNodeType cmp_node_seprgba= {
 
78
        /* *next,*prev */       NULL, NULL,
 
79
        /* type code   */       CMP_NODE_SEPRGBA,
 
80
        /* name        */       "Separate RGBA",
 
81
        /* width+range */       80, 40, 140,
 
82
        /* class+opts  */       NODE_CLASS_CONVERTOR, 0,
 
83
        /* input sock  */       cmp_node_seprgba_in,
 
84
        /* output sock */       cmp_node_seprgba_out,
 
85
        /* storage     */       "",
 
86
        /* execfunc    */       node_composit_exec_seprgba,
 
87
        /* butfunc     */       NULL,
 
88
        /* initfunc    */       NULL,
 
89
        /* freestoragefunc    */        NULL,
 
90
        /* copystoragefunc    */        NULL,
 
91
        /* id          */       NULL
 
92
        
 
93
};
 
94
 
 
95
 
 
96
/* **************** COMBINE RGBA ******************** */
 
97
static bNodeSocketType cmp_node_combrgba_in[]= {
 
98
        {       SOCK_VALUE, 1, "R",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
99
        {       SOCK_VALUE, 1, "G",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
100
        {       SOCK_VALUE, 1, "B",                     0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
101
        {       SOCK_VALUE, 1, "A",                     1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
102
        {       -1, 0, ""       }
 
103
};
 
104
static bNodeSocketType cmp_node_combrgba_out[]= {
 
105
        {       SOCK_RGBA, 0, "Image",                  0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
 
106
        {       -1, 0, ""       }
 
107
};
 
108
 
 
109
static void do_combrgba(bNode *node, float *out, float *in1, float *in2, float *in3, float *in4)
 
110
{
 
111
        out[0] = in1[0];
 
112
        out[1] = in2[0];
 
113
        out[2] = in3[0];
 
114
        out[3] = in4[0];
 
115
}
 
116
 
 
117
static void node_composit_exec_combrgba(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
118
{
 
119
        /* stack order out: 1 rgba channels */
 
120
        /* stack order in: 4 value channels */
 
121
        
 
122
        /* input no image? then only color operation */
 
123
        if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) {
 
124
                out[0]->vec[0] = in[0]->vec[0];
 
125
                out[0]->vec[1] = in[1]->vec[0];
 
126
                out[0]->vec[2] = in[2]->vec[0];
 
127
                out[0]->vec[3] = in[3]->vec[0];
 
128
        }
 
129
        else {
 
130
                /* make output size of first available input image */
 
131
                CompBuf *cbuf;
 
132
                CompBuf *stackbuf;
 
133
 
 
134
                /* allocate a CompBuf the size of the first available input */
 
135
                if (in[0]->data) cbuf = in[0]->data;
 
136
                else if (in[1]->data) cbuf = in[1]->data;
 
137
                else if (in[2]->data) cbuf = in[2]->data;
 
138
                else cbuf = in[3]->data;
 
139
                
 
140
                stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
 
141
                
 
142
                composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, 
 
143
                                                                  in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, 
 
144
                                                                  do_combrgba, CB_VAL, CB_VAL, CB_VAL, CB_VAL);
 
145
                
 
146
                out[0]->data= stackbuf;
 
147
        }       
 
148
}
 
149
 
 
150
bNodeType cmp_node_combrgba= {
 
151
        /* *next,*prev */       NULL, NULL,
 
152
        /* type code   */       CMP_NODE_COMBRGBA,
 
153
        /* name        */       "Combine RGBA",
 
154
        /* width+range */       80, 40, 140,
 
155
        /* class+opts  */       NODE_CLASS_CONVERTOR, NODE_OPTIONS,
 
156
        /* input sock  */       cmp_node_combrgba_in,
 
157
        /* output sock */       cmp_node_combrgba_out,
 
158
        /* storage     */       "",
 
159
        /* execfunc    */       node_composit_exec_combrgba,
 
160
        /* butfunc     */       NULL,
 
161
        /* initfunc    */       NULL,
 
162
        /* freestoragefunc    */        NULL,
 
163
        /* copystoragefunc    */        NULL,
 
164
        /* id          */       NULL
 
165
        
 
166
};
 
167