]> granicus.if.org Git - graphviz/commitdiff
doc't lose changes
authorellson <devnull@localhost>
Sun, 28 Sep 2008 21:51:16 +0000 (21:51 +0000)
committerellson <devnull@localhost>
Sun, 28 Sep 2008 21:51:16 +0000 (21:51 +0000)
lib/inkpot/inkpot.h
lib/inkpot/inkpot_scheme.c
lib/inkpot/inkpot_value.c
lib/inkpot/inkpot_value.h
lib/inkpot/test.c

index f30e620306a357d3a0366ab8403c2e1ba3e1730d..21708d99555b184786db4a50f3af10acbaf796d1 100644 (file)
@@ -26,8 +26,8 @@ typedef enum {
     INKPOT_MALLOC_FAIL,
     INKPOT_COLOR_UNKNOWN,
     INKPOT_COLOR_NONAME,
-    INKPOT_COLOR_NOPALETTE,
     INKPOT_SCHEME_UNKNOWN,
+    INKPOT_NOPALETTE,
     INKPOT_NOSUCH_INDEX
 } inkpot_status_t;
 
index d018423d58f61bf945ce13ed38234385defd9876..a251684d757dd785397d7bf077b47398939ec4e2 100644 (file)
@@ -36,34 +36,12 @@ static inkpot_disc_t inkpot_default_disc = { inkpot_writer, inkpot_writer };
 
 inkpot_t *inkpot_init ( void )
 {
-    inkpot_t *inkpot;
-    IDX_MRU_CACHE i;
-   
-    inkpot = malloc(sizeof(inkpot_t));
+    inkpot_t *inkpot = malloc(sizeof(inkpot_t));
     if (inkpot) {
-
-       inkpot->values.no_palette_value = 0;
-       inkpot->values.no_palette_vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb);
-
-       inkpot->value.index = 0;
-       inkpot->value.value = 0;
-       inkpot->value.vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb);
-
-       inkpot->canon = NULL;
-       inkpot->canon_alloc = 0;
-
+       memset(inkpot, 0, sizeof(inkpot_t));
        inkpot->disc = inkpot_default_disc;
        inkpot->out_closure = stdout;
        inkpot->err_closure = stderr;
-
-       inkpot->most_recently_used_idx = 0;
-        for (i = 0; i < SZT_MRU_CACHE; i++)
-           inkpot->cache[i].next_recently_used_idx = i + 1;
-
-        inkpot->scheme_bits = 0;  /* clear schemes */
-        inkpot->active_schemes = 0;
-        inkpot->active_out_schemes = 0;
-        inkpot->out_name = NULL; 
     }
     return inkpot;
 }
@@ -397,7 +375,7 @@ inkpot_status_t inkpot_set_rgba ( inkpot_t *inkpot, double rgba[4] )
        v = (v > 1.0) ? 1.0 : v;
        value.value |= (int)(v * 65535);
     }
-    value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;
+    value.vtype = VTYPE_rgba;
     
     rc = inkpot_value_set ( &inkpot->values, &value );
     if (rc == INKPOT_SUCCESS)
@@ -453,24 +431,24 @@ inkpot_status_t inkpot_set ( inkpot_t *inkpot, const char *color )
     if (*inkpot->canon == '#') {
        a = 65535;
         if ((len = sscanf(inkpot->canon, "#%4x%4x%4x%4x", &r, &g, &b, &a)) >= 3) {
-           if (len == 4)
-               value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;
-           else
-               value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb;
+           value.value = (((((((unsigned long)r) << 16)
+                             | (unsigned long)g) << 16)
+                             | (unsigned long)b) << 16)
+                             | (unsigned long)a;
        }
        else if (len < 3) {
            a = 255;
            if ((len = sscanf(inkpot->canon, "#%2x%2x%2x%2x", &r, &g, &b, &a)) >= 3) {
-               r *= 65535/255; g *= 65535/255; b *= 65535/255; a *= 65535/255;
-               if (len == 4)
-                   value.vtype = BIT_VTYPE_size_8 | BIT_VTYPE_code_rgba;
-               else
-                   value.vtype = BIT_VTYPE_size_8 | BIT_VTYPE_code_rgb;
+/*             r *= 65535/255; g *= 65535/255; b *= 65535/255; a *= 65535/255;   // too ugly */
+               value.value = (((((((unsigned long)r) << 16)
+                                 | (unsigned long)g) << 16)
+                                 | (unsigned long)b) << 16)
+                                 | (unsigned long)a;
+               value.value |= value.value << 8;                                  /* not ugly */
            } 
        }
        if (len >= 3) {
-           value.value = (((((((unsigned long)r) << 16) | (unsigned long)g) << 16) | (unsigned long)b) << 16) | (unsigned long)a;
-
+           value.vtype = VTYPE_rgba;
            rc = inkpot_value_set ( &inkpot->values, &value );
            if (rc ==  INKPOT_SUCCESS)
                inkpot->value = value;
@@ -547,6 +525,9 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
         return ((inkpot->status = INKPOT_SUCCESS));
     }
     
+
+    /* FIXME - most of this should go */
+
     if (inkpot->out_scheme_bit) {
         value_idx = inkpot->value.index;
         if (value_idx < SZT_VALUES) {
@@ -570,7 +551,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
         }
         if (value_idx == SZT_NONAME_VALUES) {
             *color = NULL;
-           return ((inkpot->status = INKPOT_COLOR_NOPALETTE));
+           return ((inkpot->status = INKPOT_NOPALETTE));
         }
         assert(0);  /* support for dynamic values to go here */
     }
@@ -930,10 +911,10 @@ inkpot_status_t inkpot_debug_error ( inkpot_t *inkpot )
            m = "\nINKPOT_COLOR_UNKNOWN\n"; break;
        case INKPOT_COLOR_NONAME:
            m = "\nINKPOT_COLOR_NONAME\n"; break;
-       case INKPOT_COLOR_NOPALETTE:
-           m = "\nINKPOT_COLOR_PALETTE\n"; break;
        case INKPOT_SCHEME_UNKNOWN:
            m = "\nINKPOT_SCHEME_UNKNOWN\n"; break;
+       case INKPOT_NOPALETTE:
+           m = "\nINKPOT_PALETTE\n"; break;
        case INKPOT_NOSUCH_INDEX:
            m = "\nINKPOT_NOSUCH_INDEX\n"; break;
     }
index 46faf61bc332b68d13950eb15c6f9d566660958d..df322b6495c26774af10c3237351a8ebcc8772db 100644 (file)
@@ -25,8 +25,7 @@
 
 inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value )
 {
-    values->no_palette_value = value->value;
-    values->no_palette_vtype = value->vtype;
+    value->vtype = VTYPE_rgba;  /* FIXME */
     value->index = SZT_VALUES + SZT_NONAME_VALUES;
 
     return INKPOT_SUCCESS;
@@ -34,22 +33,21 @@ inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *valu
 
 inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *value )
 {
-    IDX_VALUES index;
+    IDX_VALUES index = value->index;
 
     /* FIXME - this routine must check for 8 bit values and properly scale to 16 for the api */
-   
-    index  = value->index;
+
     if (index < SZT_VALUES) {
        value->value = TAB_VALUES[index];
-       value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;  /* FIXME */
+       value->vtype = VTYPE_rgba;  /* FIXME */
     }
     else if (index - SZT_VALUES < SZT_NONAME_VALUES) {
        value->value = TAB_NONAME_VALUES[index - SZT_VALUES];
-       value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;  /* FIXME */
+       value->vtype = VTYPE_rgba;  /* FIXME */
     }
     else if (index == SZT_VALUES + SZT_NONAME_VALUES) {
-       value->value = values->no_palette_value;
-       value->vtype = values->no_palette_vtype;
+       value->vtype = VTYPE_rgba;  /* FIXME */
+        return INKPOT_NOPALETTE;
     }
     else
        return INKPOT_NOSUCH_INDEX;
index 1e86788a27cead7fb68765650191669a729d6d44..2e5cbe3d71cf3629d8940d7a1119ab8c7183800c 100644 (file)
@@ -23,20 +23,33 @@ extern "C" {
 
 typedef int BIT_VTYPE;
 
-#define MSK_VTYPE_size       0x01
-#define BIT_VTYPE_size_16    0x00
-#define BIT_VTYPE_size_8     0x01
-
-#define MSK_VTYPE_code       0x0e
-#define BIT_VTYPE_code_rgba  0x00
-#define BIT_VTYPE_code_hsva  0x02
-#define BIT_VTYPE_code_cmyk  0x04
-#define BIT_VTYPE_code_rgb   0x06
-#define BIT_VTYPE_code_hsv   0x08
+typedef enum {
+    VTYPE_rgba = 0,
+    VTYPE_hsva,
+    VTYPE_cmyk,
+    SZT_VTYPE
+} inkpot_value_vtype_t;
 
 typedef struct inkpot_values_s {
-    unsigned long no_palette_value;
-    BIT_VTYPE no_palette_vtype;
+#if 0
+/* FIXME - not sure about all this ... */
+    unsigned long *         named[SZT_VTYPE];
+    unsigned long *       unnamed[SZT_VTYPE];
+    unsigned long *       palette[SZT_VTYPE];
+    size_t          named_64_size[SZT_VTYPE];
+    size_t          named_48_size[SZT_VTYPE];
+    size_t          named_32_size[SZT_VTYPE];
+    size_t          named_24_size[SZT_VTYPE];
+    size_t        unnamed_64_size[SZT_VTYPE];
+    size_t        unnamed_48_size[SZT_VTYPE];
+    size_t        unnamed_32_size[SZT_VTYPE];
+    size_t        unnamed_24_size[SZT_VTYPE];
+    size_t        palette_64_size[SZT_VTYPE];
+    size_t        palette_48_size[SZT_VTYPE];
+    size_t        palette_32_size[SZT_VTYPE];
+    size_t        palette_24_size[SZT_VTYPE];
+    size_t          palette_alloc[SZT_VTYPE];
+#endif
 } inkpot_values_t;
 
 typedef struct inkpot_value_s {
index cdab4ae4d537ca57864aade73a2ab797cde7a54f..5ae89fcc6c34bb1991c96f4007bfafa67b6cc801 100644 (file)
@@ -81,7 +81,7 @@ int main (int argc, char *argv[])
     fprintf(stdout, "\n text: ");
 
     rc = inkpot_write(inkpot);
-    if (rc == INKPOT_COLOR_NONAME || rc == INKPOT_COLOR_NOPALETTE) {
+    if (rc == INKPOT_COLOR_NONAME || rc == INKPOT_NOPALETTE) {
         fprintf(stdout, "#");
         rc = inkpot_write_rgba8(inkpot);
     }