[Commit] twin ChangeLog, 1.1.1.1, 1.2 Makefile.am, 1.1.1.1,
1.2 architecture, 1.1.1.1, 1.2 twin.h, 1.1.1.1,
1.2 twin_convolve.c, NONE, 1.1 twin_draw.c, 1.1.1.1,
1.2 twin_geom.c, NONE, 1.1 twin_path.c, NONE, 1.1 twin_poly.c,
NONE, 1.1 twin_screen.c, 1.1.1.1, 1.2 twin_spline.c, NONE,
1.1 twinint.h, 1.1.1.1, 1.2 xtwin.c, 1.1.1.1, 1.2
Keith Packard
commit at keithp.com
Tue Sep 21 08:42:59 PDT 2004
- Previous message: [Commit]
twin ChangeLog, 1.2, 1.3 Makefile.am, 1.2, 1.3 twin.h, 1.2,
1.3 twin_convolve.c, NONE, 1.1 twin_geom.c, NONE,
1.1 twin_path.c, 1.1, 1.2 twin_poly.c, 1.1, 1.2 twin_spline.c,
1.1, 1.2 twinint.h, 1.2, 1.3 xtwin.c, 1.2, 1.3
- Next message: [Commit] twin .cvsignore,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: keithp
Update of /local/src/CVS/twin
In directory home.keithp.com:/tmp/cvs-serv8894
Modified Files:
ChangeLog Makefile.am architecture twin.h twin_draw.c
twin_screen.c twinint.h xtwin.c
Added Files:
twin_convolve.c twin_geom.c twin_path.c twin_poly.c
twin_spline.c
Log Message:
2004-09-21 Keith Packard <keithp at keithp.com>
* Makefile.am:
* twin.h:
* twin_convolve.c: (_twin_path_leftmost), (_twin_path_step),
(_clockwise), (twin_path_convolve):
Add convolution. Pen starting position needs work.
* twin_geom.c: (_twin_distance_to_point_squared),
(_twin_distance_to_line_squared):
* twin_spline.c: (_twin_spline_error_squared), (twin_path_curve):
* twinint.h:
Move shared geometric functions to new file
* twin_path.c: (_sin), (_cos), (twin_path_circle),
(twin_path_fill):
Add twin_path_circle to generate pens.
Fix path edge generator to handle last subpath right.
* twin_poly.c: (_twin_edge_build):
Skip vertices which don't span a sample row
* xtwin.c: (main):
test convolutions
2004-09-20 Keith Packard <keithp at keithp.com>
* .cvsignore:
Add .cvsignore file
* architecture:
Mention path primitives
* Makefile.am:
* twin.h:
* twinint.h:
Add paths
* twin_draw.c: (twin_composite):
Eliminate some unused variables.
* twin_path.c: (twin_path_move), (twin_path_draw),
(twin_path_close), (twin_path_fill), (twin_path_empty),
(twin_path_create), (twin_path_destroy):
Simple path construction
* twin_poly.c: (_edge_compare_y), (_edge_step_by), (_dump_edge),
(_twin_edge_build), (_span_fill), (_twin_edge_fill),
(twin_polygon):
Anti-aliased polygon fill code
* twin_screen.c:
Change twin_bool to twin_bool_t
* twin_spline.c: (_lerp_half), (_de_casteljau),
(_distance_squared_to_point), (_distance_squared_to_segment),
(_twin_spline_error_squared), (_twin_spline_decompose),
(twin_path_curve):
Append cubic Bézier splines to paths
* xtwin.c: (main):
Test paths
Index: ChangeLog
===================================================================
RCS file: /local/src/CVS/twin/ChangeLog,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- ChangeLog 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ ChangeLog 21 Sep 2004 15:42:56 -0000 1.2
@@ -0,0 +1,61 @@
+2004-09-21 Keith Packard <keithp at keithp.com>
+
+ * Makefile.am:
+ * twin.h:
+ * twin_convolve.c: (_twin_path_leftmost), (_twin_path_step),
+ (_clockwise), (twin_path_convolve):
+ Add convolution. Pen starting position needs work.
+
+ * twin_geom.c: (_twin_distance_to_point_squared),
+ (_twin_distance_to_line_squared):
+ * twin_spline.c: (_twin_spline_error_squared), (twin_path_curve):
+ * twinint.h:
+ Move shared geometric functions to new file
+
+ * twin_path.c: (_sin), (_cos), (twin_path_circle),
+ (twin_path_fill):
+ Add twin_path_circle to generate pens.
+ Fix path edge generator to handle last subpath right.
+
+ * twin_poly.c: (_twin_edge_build):
+ Skip vertices which don't span a sample row
+
+ * xtwin.c: (main):
+ test convolutions
+
+2004-09-20 Keith Packard <keithp at keithp.com>
+
+ * .cvsignore:
+ Add .cvsignore file
+
+ * architecture:
+ Mention path primitives
+ * Makefile.am:
+ * twin.h:
+ * twinint.h:
+ Add paths
+
+ * twin_draw.c: (twin_composite):
+ Eliminate some unused variables.
+
+ * twin_path.c: (twin_path_move), (twin_path_draw),
+ (twin_path_close), (twin_path_fill), (twin_path_empty),
+ (twin_path_create), (twin_path_destroy):
+ Simple path construction
+
+ * twin_poly.c: (_edge_compare_y), (_edge_step_by), (_dump_edge),
+ (_twin_edge_build), (_span_fill), (_twin_edge_fill),
+ (twin_polygon):
+ Anti-aliased polygon fill code
+
+ * twin_screen.c:
+ Change twin_bool to twin_bool_t
+
+ * twin_spline.c: (_lerp_half), (_de_casteljau),
+ (_distance_squared_to_point), (_distance_squared_to_segment),
+ (_twin_spline_error_squared), (_twin_spline_decompose),
+ (twin_path_curve):
+ Append cubic Bézier splines to paths
+
+ * xtwin.c: (main):
+ Test paths
Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/twin/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.am 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ Makefile.am 21 Sep 2004 15:42:56 -0000 1.2
@@ -16,10 +16,15 @@
xtwin_SOURCES = \
twin.h \
+ twin_convolve.c \
twin_draw.c \
+ twin_geom.c \
+ twin_path.c \
twin_pixmap.c \
+ twin_poly.c \
twin_primitive.c \
twin_screen.c \
+ twin_spline.c \
twin_x11.c \
twinint.h \
xtwin.c
Index: architecture
===================================================================
RCS file: /local/src/CVS/twin/architecture,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- architecture 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ architecture 21 Sep 2004 15:42:56 -0000 1.2
@@ -52,3 +52,9 @@
Geometry can be displayed by computing an appropriate A8 pixmap and
compositing the result to a pixmap.
+7. Paths
+
+To draw the A8 pixmap mentioned above, use a combination of move, draw
+and curve primitives to construct a path and then fill it. To outline a
+path, use the convolution operator to convolve a pen with the path to
+construct a closed path surrounding the stroke.
Index: twin.h
===================================================================
RCS file: /local/src/CVS/twin/twin.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- twin.h 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ twin.h 21 Sep 2004 15:42:56 -0000 1.2
@@ -29,9 +29,21 @@
#include <stdint.h>
typedef uint8_t twin_a8_t;
+typedef uint16_t twin_a16_t;
typedef uint16_t twin_rgb16_t;
typedef uint32_t twin_argb32_t;
-typedef int twin_bool;
+typedef int twin_bool_t;
+typedef int16_t twin_fixed_t; /* 12.4 format */
+typedef int32_t twin_dfixed_t;
+
+#define twin_fixed_floor(f) ((((f) < 0) ? ((f) + 0xf) : (f)) >> 4)
+#define twin_fixed_trunc(f) ((f) >> 4)
+
+#define twin_double_to_fixed(d) ((twin_fixed_t) ((d) * 16.0))
+#define twin_fixed_to_double(f) ((double) (f) / 16.0)
+
+#define TWIN_FIXED_ONE (0x10)
+#define TWIN_FIXED_TOLERANCE (TWIN_FIXED_ONE >> 1)
#define TWIN_FALSE 0
#define TWIN_TRUE 1
@@ -133,6 +145,24 @@
typedef enum { TWIN_OVER, TWIN_SOURCE } twin_operator_t;
/*
+ * A (fixed point) point
+ */
+
+typedef struct _twin_point {
+ twin_fixed_t x, y;
+} twin_point_t;
+
+typedef struct _twin_path twin_path_t;
+
+/*
+ * twin_convolve.c
+ */
+void
+twin_path_convolve (twin_path_t *dest,
+ twin_path_t *stroke,
+ twin_path_t *pen);
+
+/*
* twin_draw.c
*/
@@ -160,6 +190,34 @@
int height);
/*
+ * twin_path.c
+ */
+
+void
+twin_path_move (twin_path_t *path, twin_fixed_t x, twin_fixed_t y);
+
+void
+twin_path_draw (twin_path_t *path, twin_fixed_t x, twin_fixed_t y);
+
+void
+twin_path_circle(twin_path_t *path, twin_fixed_t radius);
+
+void
+twin_path_close (twin_path_t *path);
+
+void
+twin_path_fill (twin_pixmap_t *pixmap, twin_path_t *path);
+
+void
+twin_path_empty (twin_path_t *path);
+
+twin_path_t *
+twin_path_create (void);
+
+void
+twin_path_destroy (twin_path_t *path);
+
+/*
* twin_pixmap.c
*/
@@ -188,6 +246,12 @@
twin_pixmap_pointer (twin_pixmap_t *pixmap, int x, int y);
/*
+ * twin_poly.c
+ */
+void
+twin_polygon (twin_pixmap_t *pixmap, twin_point_t *vertices, int nvertices);
+
+/*
* twin_screen.c
*/
@@ -207,13 +271,25 @@
void
twin_screen_resize (twin_screen_t *screen, int width, int height);
-twin_bool
+twin_bool_t
twin_screen_damaged (twin_screen_t *screen);
void
twin_screen_update (twin_screen_t *screen);
-/* twin_x11.c */
+/*
+ * twin_spline.c
+ */
+
+void
+twin_path_curve (twin_path_t *path,
+ twin_fixed_t x1, twin_fixed_t y1,
+ twin_fixed_t x2, twin_fixed_t y2,
+ twin_fixed_t x3, twin_fixed_t y3);
+
+/*
+ * twin_x11.c
+ */
#include <X11/Xlib.h>
--- NEW FILE: twin_convolve.c ---
(This appears to be a binary file; contents omitted.)
Index: twin_draw.c
===================================================================
RCS file: /local/src/CVS/twin/twin_draw.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- twin_draw.c 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ twin_draw.c 21 Sep 2004 15:42:56 -0000 1.2
@@ -280,9 +280,6 @@
twin_src_msk_op op;
twin_source_u s, m;
int sdx, sdy, mdx, mdy;
- twin_argb32_t *src_tmp;
- twin_argb32_t *msk_tmp;
- twin_argb32_t *dst_tmp;
sdx = src_x - dst_x;
sdy = src_y - dst_y;
--- NEW FILE: twin_geom.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: twin_path.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: twin_poly.c ---
(This appears to be a binary file; contents omitted.)
Index: twin_screen.c
===================================================================
RCS file: /local/src/CVS/twin/twin_screen.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- twin_screen.c 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ twin_screen.c 21 Sep 2004 15:42:57 -0000 1.2
@@ -83,7 +83,7 @@
twin_screen_damage (screen, 0, 0, screen->width, screen->height);
}
-twin_bool
+twin_bool_t
twin_screen_damaged (twin_screen_t *screen)
{
return (screen->damage.left < screen->damage.right &&
--- NEW FILE: twin_spline.c ---
(This appears to be a binary file; contents omitted.)
Index: twinint.h
===================================================================
RCS file: /local/src/CVS/twin/twinint.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- twinint.h 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ twinint.h 21 Sep 2004 15:42:57 -0000 1.2
@@ -28,6 +28,9 @@
#include "twin.h"
#include <string.h>
+/*
+ * Compositing stuff
+ */
#define twin_int_mult(a,b,t) ((t) = (a) * (b) + 0x80, \
((((t)>>8 ) + (t))>>8 ))
#define twin_int_div(a,b) (((uint16_t) (a) * 255) / (b))
@@ -79,6 +82,9 @@
twin_source_u src,
int width);
+/*
+ * This needs to be refactored to reduce the number of functions...
+ */
twin_in_op_func _twin_argb32_in_argb32_over_argb32;
twin_in_op_func _twin_argb32_in_rgb16_over_argb32;
twin_in_op_func _twin_argb32_in_a8_over_argb32;
@@ -210,4 +216,57 @@
twin_argb32_t *
_twin_fetch_argb32 (twin_pixmap_t *pixmap, int x, int y, int w, twin_argb32_t *span);
+/*
+ * Geometry helper functions
+ */
+
+twin_dfixed_t
+_twin_distance_to_point_squared (twin_point_t *a, twin_point_t *b);
+
+twin_dfixed_t
+_twin_distance_to_line_squared (twin_point_t *p, twin_point_t *p1, twin_point_t *p2);
+
+
+/*
+ * Polygon stuff
+ */
+
+typedef struct _twin_edge {
+ struct _twin_edge *next;
+ twin_fixed_t top, bot;
+ twin_fixed_t x;
+ twin_fixed_t e;
+ twin_fixed_t dx, dy;
+ twin_fixed_t inc_x;
+ twin_fixed_t step_x;
+ int winding;
+} twin_edge_t;
+
+/*
+ * Pixmap must be in a8 format.
+ */
+
+int
+_twin_edge_build (twin_point_t *vertices, int nvertices, twin_edge_t *edges);
+
+void
+_twin_edge_fill (twin_pixmap_t *pixmap, twin_edge_t *edges, int nedges);
+
+/*
+ * Path stuff
+ */
+
+/*
+ * A (fixed point) path
+ */
+
+struct _twin_path {
+ twin_point_t *points;
+ int size_points;
+ int npoints;
+ int *sublen;
+ int size_sublen;
+ int nsublen;
+};
+
#endif /* _TWININT_H_ */
Index: xtwin.c
===================================================================
RCS file: /local/src/CVS/twin/xtwin.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- xtwin.c 15 Sep 2004 20:43:17 -0000 1.1.1.1
+++ xtwin.c 21 Sep 2004 15:42:57 -0000 1.2
@@ -34,16 +34,64 @@
twin_x11_t *x11 = twin_x11_create (dpy, 256, 256);
twin_pixmap_t *red = twin_pixmap_create (TWIN_ARGB32, 100, 100);
twin_pixmap_t *blue = twin_pixmap_create (TWIN_ARGB32, 100, 100);
+ twin_pixmap_t *alpha = twin_pixmap_create (TWIN_A8, 100, 100);
+ twin_operand_t source, mask;
+ twin_path_t *path;
+ twin_path_t *pen;
+ twin_path_t *stroke;
XEvent ev;
int x, y;
twin_fill (red, 0x80800000, TWIN_SOURCE, 0, 0, 100, 100);
twin_fill (red, 0xffffff00, TWIN_SOURCE, 25, 25, 50, 50);
+
+ twin_fill (blue, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
+ twin_fill (alpha, 0x00000000, TWIN_SOURCE, 0, 0, 100, 100);
+
+ path = twin_path_create ();
+
+#if 1
+ pen = twin_path_create ();
+ twin_path_circle (pen, twin_double_to_fixed (6));
+
+ stroke = twin_path_create ();
+
+ twin_path_move (stroke, twin_double_to_fixed (10), twin_double_to_fixed (50));
+ twin_path_draw (stroke, twin_double_to_fixed (30), twin_double_to_fixed (50));
+ twin_path_draw (stroke, twin_double_to_fixed (10), twin_double_to_fixed (10));
+
+ twin_path_convolve (path, stroke, pen);
+#else
+ twin_path_move (path, twin_double_to_fixed (10), twin_double_to_fixed (10));
+ twin_path_circle (path, twin_double_to_fixed (10));
+#endif
+
+ twin_path_fill (alpha, path);
+ twin_path_empty (path);
+
+ twin_path_move (path,
+ twin_double_to_fixed (50), twin_double_to_fixed (50));
+ twin_path_curve (path,
+ twin_double_to_fixed (70), twin_double_to_fixed (70),
+ twin_double_to_fixed (80), twin_double_to_fixed (70),
+ twin_double_to_fixed (100), twin_double_to_fixed (50));
+
+ twin_path_fill (alpha, path);
+
+ source.source_kind = TWIN_SOLID;
+ source.u.argb = 0xff0000ff;
+ mask.source_kind = TWIN_PIXMAP;
+ mask.u.pixmap = alpha;
+ twin_composite (blue, 0, 0, &source, 0, 0, &mask, 0, 0, TWIN_OVER,
+ 100, 100);
+
+ /*
twin_fill (blue, 0x80000080, TWIN_SOURCE, 0, 0, 100, 100);
twin_fill (blue, 0xff00c000, TWIN_SOURCE, 25, 25, 50, 50);
+ */
twin_pixmap_move (red, 20, 20);
twin_pixmap_move (blue, 80, 80);
- twin_pixmap_show (red, x11->screen, 0);
+/* twin_pixmap_show (red, x11->screen, 0); */
twin_pixmap_show (blue, x11->screen, 0);
for (;;)
{
- Previous message: [Commit]
twin ChangeLog, 1.2, 1.3 Makefile.am, 1.2, 1.3 twin.h, 1.2,
1.3 twin_convolve.c, NONE, 1.1 twin_geom.c, NONE,
1.1 twin_path.c, 1.1, 1.2 twin_poly.c, 1.1, 1.2 twin_spline.c,
1.1, 1.2 twinint.h, 1.2, 1.3 xtwin.c, 1.2, 1.3
- Next message: [Commit] twin .cvsignore,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list