changeset 8:94b4b5bd8810

-
author Thinker K.F. Li <thinker@branda.to>
date Sat, 26 Jul 2008 03:20:49 +0800
parents 569f3168ba53
children 6eecdd331fe7
files src/X_main.c src/shape_path.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/X_main.c	Sat Jul 26 02:53:08 2008 +0800
+++ b/src/X_main.c	Sat Jul 26 03:20:49 2008 +0800
@@ -11,7 +11,7 @@
     shape_t *path;
     coord_t coord;
 
-    path = sh_path_new("M80 80 c 20 5 -30 20 10 30 l -30 0 z");
+    path = sh_path_new("m80 80 c 20 5 -30 20 10 30 l -30 0 z");
     memset(coord.aggr_matrix, 0, sizeof(co_aix) * 6);
     coord.aggr_matrix[0] = 1;
     coord.aggr_matrix[1] = 0.5;
--- a/src/shape_path.c	Sat Jul 26 02:53:08 2008 +0800
+++ b/src/shape_path.c	Sat Jul 26 03:20:49 2008 +0800
@@ -5,6 +5,12 @@
 #include <cairo.h>
 #include "mb_types.h"
 
+/*! \brief Implement respective objects for SVG path tag.
+ *
+ * In user_data or dev_data, 0x00 bytes are padding after commands.
+ * No commands other than 0x00 can resident after 0x00 itself.
+ * It means command processing code can skip commands after a 0x00.
+ */
 typedef struct _sh_path {
     shape_t shape;
     int cmd_len;
@@ -320,6 +326,11 @@
     if(r == ERR)
 	return NULL;
 
+    /* Align at 4's boundary and keep 2 unused co_aix space
+     * to make logic of transformation from relative to absolute
+     * simple.
+     */
+    cmd_cnt += sizeof(co_aix) * 2;
     cmd_cnt = (cmd_cnt + 3) & ~0x3;
 
     path = (sh_path_t *)malloc(sizeof(sh_path_t));
@@ -485,6 +496,7 @@
 	    cairo_close_path(cr);
 	    break;
 	case '\x0':
+	    i = cmd_len;	/* padding! Skip remain ones. */
 	    break;
 	}
     }