~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: CMP_setalpha.c 26841 2010-02-12 13:34:04Z campbellbarton $
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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
 
/* **************** SET ALPHA ******************** */
33
 
static bNodeSocketType cmp_node_setalpha_in[]= {
34
 
        {       SOCK_RGBA, 1, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
35
 
        {       SOCK_VALUE, 1, "Alpha",                 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
36
 
        {       -1, 0, ""       }
37
 
};
38
 
static bNodeSocketType cmp_node_setalpha_out[]= {
39
 
        {       SOCK_RGBA, 0, "Image",  0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
40
 
        {       -1, 0, ""       }
41
 
};
42
 
 
43
 
static void node_composit_exec_setalpha(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
44
 
{
45
 
        /* stack order out: RGBA image */
46
 
        /* stack order in: col, alpha */
47
 
        
48
 
        /* input no image? then only color operation */
49
 
        if(in[0]->data==NULL && in[1]->data==NULL) {
50
 
                out[0]->vec[0] = in[0]->vec[0];
51
 
                out[0]->vec[1] = in[0]->vec[1];
52
 
                out[0]->vec[2] = in[0]->vec[2];
53
 
                out[0]->vec[3] = in[1]->vec[0];
54
 
        }
55
 
        else {
56
 
                /* make output size of input image */
57
 
                CompBuf *cbuf= in[0]->data?in[0]->data:in[1]->data;
58
 
                CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
59
 
                
60
 
                if(in[1]->data==NULL && in[1]->vec[0]==1.0f) {
61
 
                        /* pass on image */
62
 
                        composit1_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, do_copy_rgb, CB_RGBA);
63
 
                }
64
 
                else {
65
 
                        /* send an compbuf or a value to set as alpha - composit2_pixel_processor handles choosing the right one */
66
 
                        composit2_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL);
67
 
                }
68
 
        
69
 
                out[0]->data= stackbuf;
70
 
        }
71
 
}
72
 
 
73
 
bNodeType cmp_node_setalpha= {
74
 
        /* *next,*prev */       NULL, NULL,
75
 
        /* type code   */       CMP_NODE_SETALPHA,
76
 
        /* name        */       "Set Alpha",
77
 
        /* width+range */       120, 40, 140,
78
 
        /* class+opts  */       NODE_CLASS_CONVERTOR, NODE_OPTIONS,
79
 
        /* input sock  */       cmp_node_setalpha_in,
80
 
        /* output sock */       cmp_node_setalpha_out,
81
 
        /* storage     */       "",
82
 
        /* execfunc    */       node_composit_exec_setalpha,
83
 
        /* butfunc     */       NULL,
84
 
        /* initfunc    */       NULL,
85
 
        /* freestoragefunc    */        NULL,
86
 
        /* copystoragefunc    */        NULL,
87
 
        /* id          */       NULL
88
 
        
89
 
};