[gs-cvs] rev 8127 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Sun Jul 15 10:27:08 PDT 2007


Author: leonardo
Date: 2007-07-15 10:27:07 -0700 (Sun, 15 Jul 2007)
New Revision: 8127

Modified:
   trunk/gs/src/gxcldev.h
   trunk/gs/src/gxclrast.c
   trunk/gs/src/gxclrect.c
   trunk/gs/src/gxclutil.c
Log:
Banding : Extend clist language with trapezoids, linear color trapezoids and linear color triangles (continued 4).

DETAILS :

Provide a better compression when writing frac31 values to clist.
The new method is based on fact that fractional color values have many zeros in lower bits.
  
EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/gxcldev.h
===================================================================
--- trunk/gs/src/gxcldev.h	2007-07-15 14:04:35 UTC (rev 8126)
+++ trunk/gs/src/gxcldev.h	2007-07-15 17:27:07 UTC (rev 8127)
@@ -446,6 +446,9 @@
    (dp = cmd_put_w((uint)(wy), cmd_put_w((uint)(wx), dp))))
 #define cmd_putxy(xy,dp) cmd_put2w((xy).x, (xy).y, dp)
 
+int cmd_size_frac31(register frac31 w);
+byte * cmd_put_frac31(register frac31 w, register byte * dp);
+
 /* Put out a command to set a color. */
 typedef struct {
     byte set_op;

Modified: trunk/gs/src/gxclrast.c
===================================================================
--- trunk/gs/src/gxclrast.c	2007-07-15 14:04:35 UTC (rev 8126)
+++ trunk/gs/src/gxclrast.c	2007-07-15 17:27:07 UTC (rev 8127)
@@ -95,6 +95,24 @@
     return val;
 }
 
+/* Get a variable-length fractional operand. */
+#define cmd_getfrac(var, p)\
+  BEGIN\
+    if ( !(*p & 1) ) var = (*p++) << 24;\
+    else { const byte *_cbp; var = cmd_get_frac31(p, &_cbp); p = _cbp; }\
+  END
+private frac31
+cmd_get_frac31(const byte * p, const byte ** rp)
+{
+    frac31 val = (*p++ & 0xFE) << 24;
+    int shift = 24 - 7;
+
+    for (; val |= (frac31)(*p & 0xFE) << shift, *p++ & 1; shift -= 7);
+    *rp = p;
+    return val;
+}
+
+
 /*
  * Define the structure for keeping track of the command reading buffer.
  *
@@ -1462,7 +1480,7 @@
 						cbp = top_up_cbuf(&cbuf, cbp);
 					    cc[i] = c[i];
 					    for (j = 0; j < num_components; j++)
-						cmd_getw(c[i][j], cbp);
+						cmd_getfrac(c[i][j], cbp);
 					} else
 					    cc[i] = NULL;
 				    }

Modified: trunk/gs/src/gxclrect.c
===================================================================
--- trunk/gs/src/gxclrect.c	2007-07-15 14:04:35 UTC (rev 8126)
+++ trunk/gs/src/gxclrect.c	2007-07-15 17:27:07 UTC (rev 8127)
@@ -141,7 +141,7 @@
     int j;
 
     for (j = 0; j < num_components; j++)
-	cmd_putw(c[j], dp);
+	dp = cmd_put_frac31(c[j], dp);
     return dp;
 }
 
@@ -152,7 +152,7 @@
     int num_components = cldev->color_info.num_components;
 
     for (j = 0; j < num_components; j++)
-	s += cmd_sizew(c[j]);
+	s += cmd_size_frac31(c[j]);
     return s;
 }
 

Modified: trunk/gs/src/gxclutil.c
===================================================================
--- trunk/gs/src/gxclutil.c	2007-07-15 14:04:35 UTC (rev 8126)
+++ trunk/gs/src/gxclutil.c	2007-07-15 17:27:07 UTC (rev 8127)
@@ -329,8 +329,30 @@
     *dp = w;
     return dp + 1;
 }
+/* Write a variable-size positive fractional. */
+int
+cmd_size_frac31(register frac31 w)
+{
+    register int size = 1;
+    register uint32_t v = w;
 
+    while (v & 0x01FFFFFF)
+	v <<= 7, size++;
+    return size;
+}
+byte *
+cmd_put_frac31(register frac31 w, register byte * dp)
+{
+    register uint32_t v = w;
 
+    while (v & 0x01FFFFFF)
+	*dp++ = (v >> 24) | 1, v <<= 7;
+    *dp = (v >> 24);
+    return dp + 1;
+}
+
+
+
 /*
  * This next two arrays are used for the 'delta' mode of placing a color
  * in the clist.  These arrays are indexed by the number of bytes in the



More information about the gs-cvs mailing list