33
33
#include "node_composite_util.h"
35
35
/* **************** SPLIT VIEWER ******************** */
36
static bNodeSocketTemplate cmp_node_splitviewer_in[]= {
37
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f},
38
{ SOCK_RGBA, 1, "Image", 0.0f, 0.0f, 0.0f, 1.0f},
36
static bNodeSocketTemplate cmp_node_splitviewer_in[] = {
37
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
38
{ SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f},
42
static void do_copy_split_rgba(bNode *UNUSED(node), float *out, float *in1, float *in2, float *fac)
52
static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack **in, bNodeStack **UNUSED(out))
54
/* image assigned to output */
55
/* stack order input sockets: image image */
57
if (in[0]->data==NULL || in[1]->data==NULL)
60
if (node->id && (node->flag & NODE_DO_OUTPUT)) { /* only one works on out */
61
Image *ima= (Image *)node->id;
64
CompBuf *cbuf, *buf1, *buf2, *mask;
69
buf1= typecheck_compbuf(in[0]->data, CB_RGBA);
70
buf2= typecheck_compbuf(in[1]->data, CB_RGBA);
72
BKE_image_user_calc_frame(node->storage, rd->cfra, 0);
74
/* always returns for viewer image, but we check nevertheless */
75
ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock);
77
printf("node_composit_exec_viewer error\n");
78
BKE_image_release_ibuf(ima, lock);
82
/* free all in ibuf */
83
imb_freerectImBuf(ibuf);
84
imb_freerectfloatImBuf(ibuf);
85
IMB_freezbuffloatImBuf(ibuf);
87
/* make ibuf, and connect to ima */
90
imb_addrectfloatImBuf(ibuf);
92
ima->ok= IMA_OK_LOADED;
95
cbuf= alloc_compbuf(buf1->x, buf1->y, CB_RGBA, 0); /* no alloc*/
96
cbuf->rect= ibuf->rect_float;
99
mask= alloc_compbuf(buf1->x, buf1->y, CB_VAL, 1);
102
/* Check which offset mode is selected and limit offset if needed */
103
if (node->custom2 == 0) {
104
offset = buf1->x / 100.0f * node->custom1;
105
CLAMP(offset, 0, buf1->x);
108
offset = buf1->y / 100.0f * node->custom1;
109
CLAMP(offset, 0, buf1->y);
112
if (node->custom2 == 0) {
113
for (y=0; y<buf1->y; y++) {
114
float *fac= mask->rect + y*buf1->x;
115
for (x=offset; x>0; x--, fac++)
120
for (y=0; y<offset; y++) {
121
float *fac= mask->rect + y*buf1->x;
122
for (x=buf1->x; x>0; x--, fac++)
127
composit3_pixel_processor(node, cbuf, buf1, in[0]->vec, buf2, in[1]->vec, mask, NULL, do_copy_split_rgba, CB_RGBA, CB_RGBA, CB_VAL);
129
BKE_image_release_ibuf(ima, lock);
131
generate_preview(data, node, cbuf);
135
if (in[0]->data != buf1)
137
if (in[1]->data != buf2)
142
static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
42
static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
144
44
ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user");
145
45
node->storage= iuser;
154
54
static bNodeType ntype;
156
node_type_base(ttype, &ntype, CMP_NODE_SPLITVIEWER, "SplitViewer", NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS);
56
node_type_base(ttype, &ntype, CMP_NODE_SPLITVIEWER, "Split Viewer", NODE_CLASS_OUTPUT, NODE_PREVIEW|NODE_OPTIONS);
157
57
node_type_socket_templates(&ntype, cmp_node_splitviewer_in, NULL);
158
58
node_type_size(&ntype, 140, 100, 320);
159
59
node_type_init(&ntype, node_composit_init_splitviewer);
160
60
node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
161
node_type_exec(&ntype, node_composit_exec_splitviewer);
162
62
/* Do not allow muting for this node. */
163
node_type_internal_connect(&ntype, NULL);
63
node_type_internal_links(&ntype, NULL);
165
65
nodeRegisterType(ttype, &ntype);