Code cleanup: use an enum for GPUNodeLink.image
authorNicholas Bishop <nicholasbishop@gmail.com>
Sat, 24 Jan 2015 14:09:18 +0000 (15:09 +0100)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 26 Jan 2015 15:35:59 +0000 (16:35 +0100)
Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1026

source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_codegen.h

index ee81abec2c3eefb2a626a79d002790383e1ba3b6..ff94258028e341ce9b08682fe0d17ad5277629b2 100644 (file)
@@ -88,9 +88,6 @@ typedef struct GPUFunction {
 static const char *GPU_DATATYPE_STR[17] = {"", "float", "vec2", "vec3", "vec4",
        NULL, NULL, NULL, NULL, "mat3", NULL, NULL, NULL, NULL, NULL, NULL, "mat4"};
 
-#define LINK_IMAGE_BLENDER     1
-#define LINK_IMAGE_PREVIEW     2
-
 /* GLSL code parsing for finding function definitions.
  * These are stored in a hash for lookup when creating a material. */
 
@@ -993,7 +990,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
                input->type = GPU_VEC4;
                input->source = GPU_SOURCE_TEX;
 
-               if (link->image == LINK_IMAGE_PREVIEW)
+               if (link->image == GPU_NODE_LINK_IMAGE_PREVIEW)
                        input->prv = link->ptr1;
                else {
                        input->ima = link->ptr1;
@@ -1198,7 +1195,7 @@ GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, bool is_data)
 {
        GPUNodeLink *link = GPU_node_link_create();
 
-       link->image = LINK_IMAGE_BLENDER;
+       link->image = GPU_NODE_LINK_IMAGE_BLENDER;
        link->ptr1 = ima;
        link->ptr2 = iuser;
        link->image_isdata = is_data;
@@ -1210,7 +1207,7 @@ GPUNodeLink *GPU_image_preview(PreviewImage *prv)
 {
        GPUNodeLink *link = GPU_node_link_create();
        
-       link->image= LINK_IMAGE_PREVIEW;
+       link->image= GPU_NODE_LINK_IMAGE_PREVIEW;
        link->ptr1= prv;
        
        return link;
index 0d60b85bdf544113b281c96059ccc86a40b31b19..5c19f25921409f70842220dfcde194ce8e4ac025 100644 (file)
@@ -61,6 +61,12 @@ typedef enum GPUDataSource {
        GPU_SOURCE_ATTRIB
 } GPUDataSource;
 
+typedef enum {
+       GPU_NODE_LINK_IMAGE_NONE = 0,
+       GPU_NODE_LINK_IMAGE_BLENDER = 1,
+       GPU_NODE_LINK_IMAGE_PREVIEW = 2
+} GPUNodeLinkImage;
+
 struct GPUNode {
        struct GPUNode *next, *prev;
 
@@ -77,7 +83,7 @@ struct GPUNodeLink {
        CustomDataType attribtype;
        const char *attribname;
 
-       int image;
+       GPUNodeLinkImage image;
        int image_isdata;
 
        int texture;