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

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/CMP_nodes/CMP_composite.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_composite.c,v 1.4 2007/04/04 13:58:09 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
 
 
33
 
 
34
/* **************** COMPOSITE ******************** */
 
35
static bNodeSocketType cmp_node_composite_in[]= {
 
36
        {       SOCK_RGBA, 1, "Image",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
 
37
        {       SOCK_VALUE, 1, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 
38
        {       SOCK_VALUE, 1, "Z",                     1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
 
39
        {       -1, 0, ""       }
 
40
};
 
41
 
 
42
/* applies to render pipeline */
 
43
static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
44
{
 
45
        /* image assigned to output */
 
46
        /* stack order input sockets: col, alpha, z */
 
47
        
 
48
        if(node->flag & NODE_DO_OUTPUT) {       /* only one works on out */
 
49
                RenderData *rd= data;
 
50
                if(rd->scemode & R_DOCOMP) {
 
51
                        RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name)); /* G.scene is WEAK! */
 
52
                        if(rr) {
 
53
                                CompBuf *outbuf, *zbuf=NULL;
 
54
                                
 
55
                                if(rr->rectf) 
 
56
                                        MEM_freeN(rr->rectf);
 
57
                                outbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 1);
 
58
                                
 
59
                                if(in[1]->data==NULL)
 
60
                                        composit1_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA);
 
61
                                else
 
62
                                        composit2_pixel_processor(node, outbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL);
 
63
                                
 
64
                                if(in[2]->data) {
 
65
                                        if(rr->rectz) 
 
66
                                                MEM_freeN(rr->rectz);
 
67
                                        zbuf= alloc_compbuf(rr->rectx, rr->recty, CB_VAL, 1);
 
68
                                        composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL);
 
69
                                        rr->rectz= zbuf->rect;
 
70
                                        zbuf->malloc= 0;
 
71
                                        free_compbuf(zbuf);
 
72
                                }
 
73
                                generate_preview(node, outbuf);
 
74
                                
 
75
                                /* we give outbuf to rr... */
 
76
                                rr->rectf= outbuf->rect;
 
77
                                outbuf->malloc= 0;
 
78
                                free_compbuf(outbuf);
 
79
                                
 
80
                                /* signal for imageviewer to refresh (it converts to byte rects...) */
 
81
                                BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
 
82
                                return;
 
83
                        }
 
84
                }
 
85
        }
 
86
        if(in[0]->data)
 
87
                generate_preview(node, in[0]->data);
 
88
}
 
89
 
 
90
bNodeType cmp_node_composite= {
 
91
        /* *next,*prev */       NULL, NULL,
 
92
        /* type code   */       CMP_NODE_COMPOSITE,
 
93
        /* name        */       "Composite",
 
94
        /* width+range */       80, 60, 200,
 
95
        /* class+opts  */       NODE_CLASS_OUTPUT, NODE_PREVIEW,
 
96
        /* input sock  */       cmp_node_composite_in,
 
97
        /* output sock */       NULL,
 
98
        /* storage     */       "",
 
99
        /* execfunc    */       node_composit_exec_composite,
 
100
        /* butfunc     */       NULL,
 
101
        /* initfunc    */       NULL,
 
102
        /* freestoragefunc    */        NULL,
 
103
        /* copystoragefunc    */        NULL,
 
104
        /* id          */       NULL
 
105
};