cleanup pixel sampler code (pixel interpolations in compositor)
authorJeroen Bakker <j.bakker@atmind.nl>
Tue, 28 Aug 2012 10:41:37 +0000 (10:41 +0000)
committerJeroen Bakker <j.bakker@atmind.nl>
Tue, 28 Aug 2012 10:41:37 +0000 (10:41 +0000)
source/blender/compositor/intern/COM_SocketReader.h
source/blender/compositor/nodes/COM_RotateNode.cpp
source/blender/compositor/nodes/COM_Stabilize2dNode.cpp
source/blender/compositor/nodes/COM_TransformNode.cpp
source/blender/makesrna/intern/rna_nodetree.c

index 01e1403b021cbff2eb7a76f26cb900ddf04ed863..88b018ef8ba53688c593977e591680886f82f3e5 100644 (file)
@@ -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;
index bb058d18b8072d4e6c30ce801aba72366a34a18b..d7712323a27c329715fc0cac0950121f754e40bc 100644 (file)
@@ -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);
index 85b8695263f5523b958cf6576445025d1de3ad73..b28ee3eade193227d244618f249e3fe8ae290fc8 100644 (file)
@@ -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);
 }
index ff6e276d1acd536c53d974ba0c4f71ff9f79fa93..154761665cfef1f1f837b5731c632bcedc718f6c 100644 (file)
@@ -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));
index 497cb9291ece4e8aef4dd6053ed09b58d1e4314b..2f763a6ed0e4c4c429e12dae9819430e7c244c7d 100644 (file)
@@ -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");
 }