doxygen: prevent GPL license block from being parsed as doxygen comment.
[blender.git] / source / blender / nodes / intern / CMP_nodes / CMP_flip.c
1 /*
2  * $Id$
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 /* **************** Flip  ******************** */
33 static bNodeSocketType cmp_node_flip_in[]= {
34         {       SOCK_RGBA, 1, "Image",              0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
35         {       -1, 0, ""       }
36 };
37
38 static bNodeSocketType cmp_node_flip_out[]= {
39         {       SOCK_RGBA, 0, "Image",                  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
40         {       -1, 0, ""       }
41 };
42
43 static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
44 {
45         if(in[0]->data) {
46                 CompBuf *cbuf= in[0]->data;
47                 CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1);      /* note, this returns zero'd image */
48                 int i, src_pix, src_width, src_height, srcydelt, outydelt, x, y;
49                 float *srcfp, *outfp;
50                 
51                 src_pix= cbuf->type;
52                 src_width= cbuf->x;
53                 src_height= cbuf->y;
54                 srcfp= cbuf->rect;
55                 outfp= stackbuf->rect;
56                 srcydelt= src_width*src_pix;
57                 outydelt= srcydelt;
58                 
59                 if(node->custom1) {             /*set up output pointer for y flip*/
60                         outfp+= (src_height-1)*outydelt;
61                         outydelt= -outydelt;
62                 }
63
64                 for(y=0; y<src_height; y++) {
65                         if(node->custom1 == 1) {        /* no x flip so just copy line*/
66                                 memcpy(outfp, srcfp, sizeof(float) * src_pix * src_width);
67                                 srcfp+=srcydelt;
68                         }
69                         else {
70                                 outfp += (src_width-1)*src_pix;
71                                 for(x=0; x<src_width; x++) {
72                                         for(i=0; i<src_pix; i++) {
73                                                 outfp[i]= srcfp[i];
74                                         }
75                                         outfp -= src_pix;
76                                         srcfp += src_pix;
77                                 }
78                                 outfp += src_pix;
79                         }
80                         outfp += outydelt;
81                 }
82
83                 out[0]->data= stackbuf;
84
85         }
86 }
87
88 void register_node_type_cmp_flip(ListBase *lb)
89 {
90         static bNodeType ntype;
91
92         node_type_base(&ntype, CMP_NODE_FLIP, "Flip", NODE_CLASS_DISTORT, NODE_OPTIONS,
93                 cmp_node_flip_in, cmp_node_flip_out);
94         node_type_size(&ntype, 140, 100, 320);
95         node_type_exec(&ntype, node_composit_exec_flip);
96
97         nodeRegisterType(lb, &ntype);
98 }
99
100
101