Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-11-15 18:18:06 +0300
committerTon Roosendaal <ton@blender.org>2006-11-15 18:18:06 +0300
commit3959fbcf1f6eb36e908d238b4ff608eb88b59d03 (patch)
treee55e2786b8059c1f8a543aee855266b019c9b99e
parent5d8efc975699ae5ca60aa2892d96dd3e361b9c1d (diff)
Patch #5166, Juho V (bebraw)
New Composite Node: Flip (X/Y/both)
-rw-r--r--source/blender/blenkernel/BKE_node.h7
-rw-r--r--source/blender/blenkernel/intern/node_composite.c71
-rw-r--r--source/blender/src/drawnode.c17
3 files changed, 89 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index c6da0b9af98..5197e32d4e4 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -230,7 +230,8 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
#define CMP_NODE_ZCOMBINE 226
#define CMP_NODE_COMBRGBA 227
#define CMP_NODE_DILATEERODE 228
-
+#define CMP_NODE_ROTATE 229
+#define CMP_NODE_SCALE 230
#define CMP_NODE_SEPYCCA 231
#define CMP_NODE_COMBYCCA 232
#define CMP_NODE_SEPYUVA 233
@@ -239,11 +240,10 @@ void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, str
#define CMP_NODE_COLOR_SPILL 236
#define CMP_NODE_CHROMA 237
#define CMP_NODE_LUMA 238
+#define CMP_NODE_FLIP 239
/* filter types */
-#define CMP_NODE_ROTATE 229
-#define CMP_NODE_SCALE 230
/* filter types, in custom1 */
@@ -271,4 +271,3 @@ void ntreeCompositTagGenerators(struct bNodeTree *ntree);
void free_compbuf(struct CompBuf *cbuf); /* internal...*/
#endif
-
diff --git a/source/blender/blenkernel/intern/node_composite.c b/source/blender/blenkernel/intern/node_composite.c
index 61f9e464d46..21ca4b21824 100644
--- a/source/blender/blenkernel/intern/node_composite.c
+++ b/source/blender/blenkernel/intern/node_composite.c
@@ -2982,6 +2982,74 @@ static bNodeType cmp_node_translate= {
/* execfunc */ node_composit_exec_translate
};
+/* **************** Flip ******************** */
+static bNodeSocketType cmp_node_flip_in[]= {
+ { SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static bNodeSocketType cmp_node_flip_out[]= {
+ { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
+};
+
+static void node_composit_exec_flip(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
+{
+ if(in[0]->data) {
+ CompBuf *cbuf= in[0]->data;
+ CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1); /* note, this returns zero'd image */
+ int i, src_pix, src_width,src_height,srcydelt,outydelt, x, y;
+ float *srcfp, *outfp;
+
+ src_pix= cbuf->type;
+ src_width= cbuf->x;
+ src_height= cbuf->y;
+ srcfp= cbuf->rect;
+ outfp= stackbuf->rect;
+ srcydelt= src_width*src_pix;
+ outydelt= srcydelt;
+
+ if(node->custom1){ /*set up output pointer for y flip*/
+ outfp+= (src_height-1)*outydelt;
+ outydelt= -outydelt;
+ }
+
+ for(y=0; y<src_height; y++){
+ if(node->custom1 == 1){ /* no x flip so just copy line*/
+ memcpy(outfp, srcfp, sizeof(float) * src_pix * src_width);
+ srcfp+=srcydelt;
+ }
+ else{
+ outfp+=(src_width-1)*src_pix;
+ for(x=0;x<src_width;x++){
+ for(i=0; i<src_pix; i++){
+ outfp[i]=srcfp[i];
+ }
+ outfp-=src_pix;
+ srcfp+=src_pix;
+ }
+ outfp+=src_pix;
+ }
+ outfp+=outydelt;
+ }
+
+ out[0]->data= stackbuf;
+ if(cbuf!=in[0]->data)
+ free_compbuf(cbuf);
+ }
+}
+
+static bNodeType cmp_node_flip= {
+ /* type code */ CMP_NODE_FLIP,
+ /* name */ "Flip",
+ /* width+range */ 140, 100, 320,
+ /* class+opts */ NODE_CLASS_CONVERTOR, NODE_OPTIONS,
+ /* input sock */ cmp_node_flip_in,
+ /* output sock */ cmp_node_flip_out,
+ /* storage */ "",
+ /* execfunc */ node_composit_exec_flip
+};
+
/* **************** Dilate/Erode ******************** */
static bNodeSocketType cmp_node_dilateerode_in[]= {
@@ -4130,6 +4198,7 @@ bNodeType *node_all_composit[]= {
&cmp_node_setalpha,
&cmp_node_texture,
&cmp_node_translate,
+ &cmp_node_flip,
&cmp_node_zcombine,
&cmp_node_dilateerode,
&cmp_node_sepyuva,
@@ -4192,5 +4261,3 @@ void ntreeCompositTagGenerators(bNodeTree *ntree)
NodeTagChanged(ntree, node);
}
}
-
-
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index 196086799c8..1e4f0d51bb5 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -941,6 +941,20 @@ static int node_composit_buts_filter(uiBlock *block, bNodeTree *ntree, bNode *no
return 20;
}
+static int node_composit_buts_flip(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block) {
+ uiBut *bt;
+
+ /* flip x\y */
+ bt=uiDefButS(block, MENU, B_NODE_EXEC+node->nr, "Flip X %x0|Flip Y %x1|Flip X & Y %x2",
+ butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20,
+ &node->custom1, 0, 0, 0, 0, "");
+ uiButSetFunc(bt, node_but_title_cb, node, bt);
+ }
+ return 20;
+}
+
static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
@@ -1278,6 +1292,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_RGB:
ntype->butfunc= node_buts_rgb;
break;
+ case CMP_NODE_FLIP:
+ ntype->butfunc= node_composit_buts_flip;
+ break;
case CMP_NODE_MIX_RGB:
ntype->butfunc= node_buts_mix_rgb;
break;