From 8fd747114388dbbb10733415eaa707f9801abf1a Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 28 Aug 2012 10:41:37 +0000 Subject: cleanup pixel sampler code (pixel interpolations in compositor) --- .../blender/compositor/intern/COM_SocketReader.h | 6 ++-- source/blender/compositor/nodes/COM_RotateNode.cpp | 14 +-------- .../compositor/nodes/COM_Stabilize2dNode.cpp | 9 ++++-- .../blender/compositor/nodes/COM_TransformNode.cpp | 12 +------- source/blender/makesrna/intern/rna_nodetree.c | 35 +++++++--------------- 5 files changed, 23 insertions(+), 53 deletions(-) (limited to 'source') diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index 01e1403b021..88b018ef8ba 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -30,9 +30,9 @@ #endif typedef enum PixelSampler { - COM_PS_NEAREST, - COM_PS_BILINEAR, - COM_PS_BICUBIC + COM_PS_NEAREST = 0, + COM_PS_BILINEAR = 1, + COM_PS_BICUBIC = 2 } PixelSampler; class MemoryBuffer; diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp index bb058d18b80..d7712323a27 100644 --- a/source/blender/compositor/nodes/COM_RotateNode.cpp +++ b/source/blender/compositor/nodes/COM_RotateNode.cpp @@ -39,19 +39,7 @@ void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext RotateOperation *operation = new RotateOperation(); SetSamplerOperation *sampler = new SetSamplerOperation(); - switch (this->getbNode()->custom1) { - case 0: - sampler->setSampler(COM_PS_NEAREST); - break; - case 1: - sampler->setSampler(COM_PS_BILINEAR); - break; - case 2: - sampler->setSampler(COM_PS_BICUBIC); - break; - - } - + sampler->setSampler((PixelSampler)this->getbNode()->custom1); addLink(system, sampler->getOutputSocket(), operation->getInputSocket(0)); inputSocket->relinkConnections(sampler->getInputSocket(0), 0, system); diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp index 85b8695263f..b28ee3eade1 100644 --- a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp @@ -26,6 +26,7 @@ #include "COM_RotateOperation.h" #include "COM_ScaleOperation.h" #include "COM_MovieClipAttributeOperation.h" +#include "COM_SetSamplerOperation.h" extern "C" { #include "DNA_movieclip_types.h" @@ -49,6 +50,7 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); + SetSamplerOperation *psoperation = new SetSamplerOperation(); scaleAttribute->setAttribute(MCA_SCALE); scaleAttribute->setFramenumber(context->getFramenumber()); @@ -77,8 +79,10 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); addLink(graph, xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); addLink(graph, yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); - - this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket()); + + psoperation->setSampler((PixelSampler)this->getbNode()->custom1); + addLink(graph, translateOperation->getOutputSocket(), psoperation->getInputSocket(0)); + this->getOutputSocket()->relinkConnections(psoperation->getOutputSocket()); graph->addOperation(scaleAttribute); graph->addOperation(angleAttribute); @@ -87,4 +91,5 @@ void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorCont graph->addOperation(scaleOperation); graph->addOperation(translateOperation); graph->addOperation(rotateOperation); + graph->addOperation(psoperation); } diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp index ff6e276d1ac..154761665cf 100644 --- a/source/blender/compositor/nodes/COM_TransformNode.cpp +++ b/source/blender/compositor/nodes/COM_TransformNode.cpp @@ -46,17 +46,7 @@ void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContex TranslateOperation *translateOperation = new TranslateOperation(); SetSamplerOperation *sampler = new SetSamplerOperation(); - switch (this->getbNode()->custom1) { - case 0: - sampler->setSampler(COM_PS_NEAREST); - break; - case 1: - sampler->setSampler(COM_PS_BILINEAR); - break; - case 2: - sampler->setSampler(COM_PS_BICUBIC); - break; - } + sampler->setSampler((PixelSampler)this->getbNode()->custom1); imageInput->relinkConnections(sampler->getInputSocket(0), 0, graph); addLink(graph, sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 497cb9291ec..2f763a6ed0e 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -133,6 +133,14 @@ EnumPropertyItem node_filter_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem node_sampler_type_items[] = { + {0, "NEAREST", 0, "Nearest", ""}, + {1, "BILINEAR", 0, "Bilinear", ""}, + {2, "BICUBIC", 0, "Bicubic", ""}, + {0, NULL, 0, NULL, NULL} +}; + + EnumPropertyItem prop_noise_basis_items[] = { {SHD_NOISE_PERLIN, "PERLIN", 0, "Perlin", ""}, {SHD_NOISE_VORONOI_F1, "VORONOI_F1", 0, "Voronoi F1", ""}, @@ -2213,16 +2221,9 @@ static void def_cmp_rotate(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem rotate_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, rotate_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter rotation"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3150,13 +3151,6 @@ static void def_cmp_stabilize2d(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem filter_type_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "id"); RNA_def_property_struct_type(prop, "MovieClip"); @@ -3166,7 +3160,7 @@ static void def_cmp_stabilize2d(StructRNA *srna) prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, filter_type_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter stabilization"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } @@ -3264,16 +3258,9 @@ static void dev_cmd_transform(StructRNA *srna) { PropertyRNA *prop; - static EnumPropertyItem filter_type_items[] = { - {0, "NEAREST", 0, "Nearest", ""}, - {1, "BILINEAR", 0, "Bilinear", ""}, - {2, "BICUBIC", 0, "Bicubic", ""}, - {0, NULL, 0, NULL, NULL} - }; - prop = RNA_def_property(srna, "filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "custom1"); - RNA_def_property_enum_items(prop, filter_type_items); + RNA_def_property_enum_items(prop, node_sampler_type_items); RNA_def_property_ui_text(prop, "Filter", "Method to use to filter transform"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } -- cgit v1.2.3