[teklib-general] changeset in /hg/teklib/current: Tagged rendering functions adde...

Timm S. Mueller tmueller at neoscientists.org
Mon Nov 26 16:26:20 CET 2007


changeset 9047477fd0ff in /hg/teklib/current
details: http://teklib.org:8001/hg/teklib/current?cmd=changeset;node=9047477fd0ff
description:
	Tagged rendering functions added; cleanup in visual module

diffs (truncated from 352 to 300 lines):

diff -r 50cfde2833e2 -r 9047477fd0ff src/display_x11/display_x11_api.c
--- a/src/display_x11/display_x11_api.c	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/display_x11/display_x11_api.c	Mon Oct 15 16:21:39 2007 +0200
@@ -562,7 +562,7 @@ x11_drawtext(TMOD_X11 *mod, struct TVReq
 	setfgpen(mod, v, (TVPEN) fgpen);
 	setbgpen(mod, v, (TVPEN) bgpen);
 
-	if ((TUINTPTR) bgpen == TVPEN_UNDEFINED)
+	if ((TVPEN) bgpen == TVPEN_UNDEFINED)
 	{
 		if (mod->x11_use_xft == TTRUE)
 		{
@@ -679,3 +679,85 @@ x11_getnextfont(TMOD_X11 *mod, struct TV
 	req->tvr_Op.GetNextFont.Attrs =
 		x11_hostgetnextfont(mod, req->tvr_Op.GetNextFont.Handle);
 }
+
+/*****************************************************************************/
+
+struct drawdata
+{
+	VISUAL *v;
+	TMOD_X11 *mod;
+	Display *display;
+	Window window;
+	GC gc;
+	TINT x0, x1, y0, y1;
+};
+
+static THOOKENTRY TTAG
+drawtagfunc(struct THook *hook, TAPTR obj, TTAG msg)
+{
+	struct drawdata *data = hook->thk_Data;
+	TTAGITEM *item = obj;
+
+	switch (item->tti_Tag)
+	{
+		case TVisualDraw_X0:
+			data->x0 = item->tti_Value;
+			break;
+		case TVisualDraw_Y0:
+			data->y0 = item->tti_Value;
+			break;
+		case TVisualDraw_X1:
+			data->x1 = item->tti_Value;
+			break;
+		case TVisualDraw_Y1:
+			data->y1 = item->tti_Value;
+			break;
+		case TVisualDraw_NewX:
+			data->x0 = data->x1;
+			data->x1 = item->tti_Value;
+			break;
+		case TVisualDraw_NewY:
+			data->y0 = data->y1;
+			data->y1 = item->tti_Value;
+			break;
+		case TVisualDraw_FgPen:
+			setfgpen(data->mod, data->v, item->tti_Value);
+			break;
+		case TVisualDraw_BgPen:
+			setbgpen(data->mod, data->v, item->tti_Value);
+			break;
+		case TVisualDraw_Command:
+			switch (item->tti_Value)
+			{
+				case TVCMD_FRECT:
+					XFillRectangle(data->display, data->window, data->gc,
+						data->x0, data->y0, data->x1, data->y1);
+					break;
+				case TVCMD_RECT:
+					XDrawRectangle(data->display, data->window, data->gc,
+						data->x0, data->y0, data->x1 - 1, data->y1 - 1);
+					break;
+				case TVCMD_LINE:
+					XDrawLine(data->display, data->window, data->gc,
+						data->x0, data->y0, data->x1, data->y1);
+					break;
+			}
+			break;
+	}
+	return TTRUE;
+}
+
+LOCAL void
+x11_drawtags(TMOD_X11 *mod, struct TVRequest *req)
+{
+	struct THook hook;
+	struct drawdata data;
+	data.v = req->tvr_Op.DrawTags.Instance;
+	data.mod = mod;
+	data.display = mod->x11_Display;
+	data.window = data.v->window;
+	data.gc = data.v->gc;
+
+	TInitHook(&hook, drawtagfunc, &data);
+	TForEachTag(req->tvr_Op.DrawTags.Tags, &hook);
+}
diff -r 50cfde2833e2 -r 9047477fd0ff src/display_x11/display_x11_inst.c
--- a/src/display_x11/display_x11_inst.c	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/display_x11/display_x11_inst.c	Mon Oct 15 16:21:39 2007 +0200
@@ -357,6 +357,9 @@ x11_docmd(TMOD_X11 *inst, struct TVReque
 			break;
 		case TVCMD_TEXT:
 			x11_drawtext(inst, req);
+			break;
+		case TVCMD_DRAWTAGS:
+			x11_drawtags(inst, req);
 			break;
 		default:
 			TDBPRINTF(TDB_ERROR,("Unknown command code: %d\n",
diff -r 50cfde2833e2 -r 9047477fd0ff src/display_x11/display_x11_mod.h
--- a/src/display_x11/display_x11_mod.h	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/display_x11/display_x11_mod.h	Mon Oct 15 16:21:39 2007 +0200
@@ -201,6 +201,8 @@ LOCAL void x11_queryfonts(TMOD_X11 *mod,
 LOCAL void x11_queryfonts(TMOD_X11 *mod, struct TVRequest *req);
 LOCAL void x11_getnextfont(TMOD_X11 *mod, struct TVRequest *req);
 
+LOCAL void x11_drawtags(TMOD_X11 *mod, struct TVRequest *req);
+
 LOCAL void x11_wake(TMOD_X11 *inst);
 
 TVOID x11_hostsetfont(TMOD_X11 *mod, VISUAL *v, TAPTR font);
diff -r 50cfde2833e2 -r 9047477fd0ff src/visual/tests/bashing.c
--- a/src/visual/tests/bashing.c	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/visual/tests/bashing.c	Mon Oct 15 16:21:39 2007 +0200
@@ -32,6 +32,7 @@ struct efxdata
 	TAPTR visual;
 	TINT framerate;
 	struct TTimeRequest *treq;
+	TTAGITEM drawtags[200];
 };
 
 /*****************************************************************************/
@@ -84,8 +85,6 @@ TTASKENTRY TVOID efxfunc(TAPTR task)
 	TUINT signals;
 	TCHR buf[30];
 
-	struct { TINT16 x, y; } xyarray[NUMLINES + 1];
-
 	TINT fw,fh;
 	TTAGITEM tags[3];
 
@@ -110,17 +109,39 @@ TTASKENTRY TVOID efxfunc(TAPTR task)
 	{
 		TFLOAT sec;
 		TQueryTime(data->treq, &t0);
-
-		TVisualFRect(data->visual, data->x, data->y, 200, 200, data->backpen);
+		TTAGITEM *tp = data->drawtags;
+
+		tp->tti_Tag = TVisualDraw_FgPen;
+		(tp++)->tti_Value = data->backpen;
+		tp->tti_Tag = TVisualDraw_X0;
+		(tp++)->tti_Value = data->x;
+		tp->tti_Tag = TVisualDraw_Y0;
+		(tp++)->tti_Value = data->y;
+		tp->tti_Tag = TVisualDraw_X1;
+		(tp++)->tti_Value = 200;
+		tp->tti_Tag = TVisualDraw_Y1;
+		(tp++)->tti_Value = 200;
+		tp->tti_Tag = TVisualDraw_Command;
+		(tp++)->tti_Value = TVCMD_FRECT;
+		tp->tti_Tag = TVisualDraw_FgPen;
+		(tp++)->tti_Value = data->pen;
 
 		for (i = 0; i < 6; ++i) ss[i] = s[i];
 
 		for (j = 0; j < NUMLINES + 1; ++j)
 		{
-			xyarray[j].x = (TINT) ((sin(ss[0]) + sin(ss[1]) + sin(ss[2])) *
+			tp->tti_Tag = TVisualDraw_NewX;
+			(tp++)->tti_Value = (TINT) ((sin(ss[0]) + sin(ss[1]) + sin(ss[2])) *
 				200 / 6 + 200 / 2 + data->x);
-			xyarray[j].y = (TINT) ((sin(ss[3]) + sin(ss[4]) + sin(ss[5])) *
+			tp->tti_Tag = TVisualDraw_NewY;
+			(tp++)->tti_Value = (TINT) ((sin(ss[3]) + sin(ss[4]) + sin(ss[5])) *
 				200 / 6 + 200 / 2 + data->y);
+			if (j > 0)
+			{
+				tp->tti_Tag = TVisualDraw_Command;
+				(tp++)->tti_Value = TVCMD_LINE;
+			}
+
 			for (i = 0; i < 6; ++i)
 			{
 				ss[i] += dss[i];
@@ -128,14 +149,15 @@ TTASKENTRY TVOID efxfunc(TAPTR task)
 			}
 		}
 
+		tp->tti_Tag = TTAG_DONE;
+
+		TVisualDrawTags(data->visual, data->drawtags);
+
 		for (i = 0; i < 6; ++i)
 		{
 			s[i] += ds[i];
 			if (s[i] > 2*TPI) s[i] -= (TFLOAT) (2*TPI);
 		}
-
-		TVisualLineArray(data->visual, (TINT16 *) xyarray, NUMLINES + 1,
-			data->pen);
 
 		sprintf(buf, "FPS: %d/%d/%d%% ", (TINT) fps, data->framerate,
 			(TINT) (fps * 100 / data->framerate));
diff -r 50cfde2833e2 -r 9047477fd0ff src/visual/visual_api.c
--- a/src/visual/visual_api.c	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/visual/visual_api.c	Mon Oct 15 16:21:39 2007 +0200
@@ -453,6 +453,17 @@ EXPORT void vis_plot(TMOD_VIS *inst, TIN
 
 /*****************************************************************************/
 
+EXPORT void vis_drawtags(TMOD_VIS *inst, TTAGITEM *tags)
+{
+	struct TVRequest *req = visi_getreq(inst, TVCMD_DRAWTAGS,
+		inst->vis_Display, TNULL);
+	req->tvr_Op.DrawTags.Instance = inst->vis_Visual;
+	req->tvr_Op.DrawTags.Tags = tags;
+	visi_dosync(inst, req);
+}
+
+/*****************************************************************************/
+
 EXPORT void vis_text(TMOD_VIS *inst, TINT x, TINT y, TSTRPTR t, TUINT l,
 	TVPEN fg, TVPEN bg)
 {
@@ -483,25 +494,6 @@ EXPORT void vis_drawrgb(TMOD_VIS *inst, 
 
 /*****************************************************************************/
 
-EXPORT void vis_linearray(TMOD_VIS *inst, TINT16 *array, TINT n, TVPEN pen)
-{
-	TINT x0, y0, x1, y1;
-
-	x0 = *array++;
-	y0 = *array++;
-
-	while (--n)
-	{
-		x1 = *array++;
-		y1 = *array++;
-		vis_line(inst, x0,y0, x1,y1, pen);
-		x0 = x1;
-		y0 = y1;
-	}
-}
-
-/*****************************************************************************/
-
 EXPORT void vis_scroll(TMOD_VIS *inst, TINT x, TINT y, TINT w, TINT h,
 	TINT dx, TINT dy)
 {
diff -r 50cfde2833e2 -r 9047477fd0ff src/visual/visual_mod.c
--- a/src/visual/visual_mod.c	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/visual/visual_mod.c	Mon Oct 15 16:21:39 2007 +0200
@@ -50,8 +50,9 @@ vis_vectors[VISUAL_NUMVECTORS] =
 
 	(TMFPTR) vis_fpoly,
 	(TMFPTR) vis_drawrgb,
-	(TMFPTR) vis_linearray,
+	(TMFPTR) vis_drawtags,
 	(TMFPTR) vis_scroll,
+
 };
 
 static void
diff -r 50cfde2833e2 -r 9047477fd0ff src/visual/visual_mod.h
--- a/src/visual/visual_mod.h	Tue Oct 02 15:38:12 2007 +0200
+++ b/src/visual/visual_mod.h	Mon Oct 15 16:21:39 2007 +0200
@@ -22,7 +22,7 @@
 
 #define VISUAL_VERSION		2
 #define VISUAL_REVISION		0
-#define VISUAL_NUMVECTORS	34
+#define VISUAL_NUMVECTORS	35
 
 #ifndef LOCAL
 #define LOCAL
@@ -126,8 +126,9 @@ EXPORT void vis_fpoly(TMOD_VIS *mod, TIN
 EXPORT void vis_fpoly(TMOD_VIS *mod, TINT16 *array, TINT num, TVPEN pen);
 EXPORT void vis_drawrgb(TMOD_VIS *mod, TINT x, TINT y, TUINT *buf, TINT w,
 	TINT h, TINT totw);
-EXPORT void vis_linearray(TMOD_VIS *mod, TINT16 *array, TINT n, TVPEN pen);
 EXPORT void vis_scroll(TMOD_VIS *mod, TINT x, TINT y, TINT w, TINT h,
 	TINT dx, TINT dy);
 
+EXPORT void vis_drawtags(TMOD_VIS *mod, TTAGITEM *tags);
+
 #endif
diff -r 50cfde2833e2 -r 9047477fd0ff tek/ansicall/visual.h
--- a/tek/ansicall/visual.h	Tue Oct 02 15:38:12 2007 +0200
+++ b/tek/ansicall/visual.h	Mon Oct 15 16:21:39 2007 +0200
@@ -80,8 +80,8 @@
 #define TVisualDrawRGB(visual,x,y,buf,w,h,totw) \
 	(*(((TMODCALL void(**)(TAPTR,TINT,TINT,TUINT *,TINT,TINT,TINT))(visual))[-32]))(visual,x,y,buf,w,h,totw)
 
-#define TVisualLineArray(visual,array,num,pen) \
-	(*(((TMODCALL void(**)(TAPTR,TINT16 *,TINT,TVPEN))(visual))[-33]))(visual,array,num,pen)
+#define TVisualDrawTags(visual,tags) \


More information about the teklib-general mailing list