2
* $Id: CMP_viewer.c,v 1.4 2007/04/04 13:58:10 jesterking Exp $
4
* ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
20
* The Original Code is Copyright (C) 2006 Blender Foundation.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): none yet.
27
* ***** END GPL LICENSE BLOCK *****
30
#include "../CMP_util.h"
33
/* **************** VIEWER ******************** */
34
static bNodeSocketType cmp_node_viewer_in[]= {
35
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
36
{ SOCK_VALUE, 1, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
37
{ SOCK_VALUE, 1, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
42
static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
44
/* image assigned to output */
45
/* stack order input sockets: col, alpha, z */
47
if(node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
49
Image *ima= (Image *)node->id;
54
BKE_image_user_calc_imanr(node->storage, rd->cfra, 0);
56
/* always returns for viewer image, but we check nevertheless */
57
ibuf= BKE_image_get_ibuf(ima, node->storage);
59
printf("node_composit_exec_viewer error\n");
63
/* free all in ibuf */
64
imb_freerectImBuf(ibuf);
65
imb_freerectfloatImBuf(ibuf);
66
IMB_freezbuffloatImBuf(ibuf);
69
tbuf= in[0]->data?in[0]->data:(in[1]->data?in[1]->data:in[2]->data);
71
rectx= 320; recty= 256;
78
/* make ibuf, and connect to ima */
81
imb_addrectfloatImBuf(ibuf);
83
ima->ok= IMA_OK_LOADED;
85
/* now we combine the input with ibuf */
86
cbuf= alloc_compbuf(rectx, recty, CB_RGBA, 0); /* no alloc*/
87
cbuf->rect= ibuf->rect_float;
89
/* when no alpha, we can simply copy */
90
if(in[1]->data==NULL) {
91
composit1_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, do_copy_rgba, CB_RGBA);
94
composit2_pixel_processor(node, cbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, do_copy_a_rgba, CB_RGBA, CB_VAL);
98
CompBuf *zbuf= alloc_compbuf(rectx, recty, CB_VAL, 1);
99
ibuf->zbuf_float= zbuf->rect;
100
ibuf->mall |= IB_zbuffloat;
102
composit1_pixel_processor(node, zbuf, in[2]->data, in[2]->vec, do_copy_value, CB_VAL);
104
/* free compbuf, but not the rect */
109
generate_preview(node, cbuf);
113
else if(in[0]->data) {
114
generate_preview(node, in[0]->data);
118
static void node_composit_init_viewer(bNode* node)
120
ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user");
121
node->storage= iuser;
127
bNodeType cmp_node_viewer= {
128
/* *next,*prev */ NULL, NULL,
129
/* type code */ CMP_NODE_VIEWER,
131
/* width+range */ 80, 60, 200,
132
/* class+opts */ NODE_CLASS_OUTPUT, NODE_PREVIEW,
133
/* input sock */ cmp_node_viewer_in,
134
/* output sock */ NULL,
135
/* storage */ "ImageUser",
136
/* execfunc */ node_composit_exec_viewer,
138
/* initfunc */ node_composit_init_viewer,
139
/* freestoragefunc */ node_free_standard_storage,
140
/* copystoragefunc */ node_copy_standard_storage,