Here's the first patch..., it's for cli_c. It includes a change on the demo
application to draw a 11 point star. On my machine the point calculations
take 36 microseconds for the star, and it's 2.45k for the entire polygon
implementation. 2.45k is pretty small for a polygon implementation, but it's
still on the big side for picogui's current primitives. Anyway, have a look
and let me know what you think. I'm not posting this for inclusion, I'm
posting it for brain storming. I really don't think the clip stuff is going
to be hard to do because you just have to put some constraints on it when it
draws the slabs. (The actual plotting of the points takes a lot longer than
deciding where the points should be, so it's not too bad)
Anyway, let me know what you think Micah, and what the best way is to fix the
clip, and the expansion issue. (Most of that code is in 2/2) I have spent a
ton of time on it, and done a lot of benchmark calcs on Intel, and code size
comparisions of various minute changes, etc. I know that there are some
pixel errors, but I actually left them in on purpose. I corrected them with
some code, but I noticed the polygons looked smoother with the pixel errors,
so I put them back in. If someone could run some time tests on some target
hardware that would be cool. (gettimeofday at the beginning of the function
and end the timer before the "big loop", start a new timer at that beginning
and get the time at the exit point, if you are willing to do the test, I can
send you a patch)
When we have a final implementation, I'll do a ChangeLog, etc.
Thanks,
Shane.
Index: cli_c/demos/pgfx_canvas_persistent.c
===================================================================
RCS file: /cvsroot/pgui/cli_c/demos/pgfx_canvas_persistent.c,v
retrieving revision 1.8
diff -u -r1.8 pgfx_canvas_persistent.c
--- cli_c/demos/pgfx_canvas_persistent.c 2001/05/31 07:32:52 1.8
+++ cli_c/demos/pgfx_canvas_persistent.c 2001/06/06 18:43:38
@@ -5,7 +5,7 @@
int main(int argc,char **argv) {
pgcontext gc;
-
+ short poly[]={11, 40,40, 50,70, 80,70, 50,86, 70,116, 45,96, 35,96,
10,116, 30,86, 0,70, 30,70};
/* Initialize PicoGUI, create an application with a canvas widget,
* and get a PGFX context for the canvas */
pgInit(argc,argv);
@@ -35,6 +35,7 @@
pgFrame(gc,30,30,40,40);
pgSetColor(gc,0xFFFF00); /* Ellipses */
pgFEllipse(gc,35,35,30,30);
+ pgFPolygon(gc,pgNewArray(poly,50));
pgSetColor(gc,0x000000);
pgEllipse(gc,35,35,30,30);
pgSetColor(gc,0xFFFFFF); /* XOR a stripe down the middle */
Index: cli_c/include/picogui/client_c.h
===================================================================
RCS file: /cvsroot/pgui/cli_c/include/picogui/client_c.h,v
retrieving revision 1.47
diff -u -r1.47 client_c.h
--- cli_c/include/picogui/client_c.h 2001/05/17 04:46:36 1.47
+++ cli_c/include/picogui/client_c.h 2001/06/06 18:43:38
@@ -584,6 +584,17 @@
pghandle pgNewString(const char *str);
/*!
+ * \brief Create a new array object
+ *
+ * \param dat The data to put in the array
+ * \param size The size of the array (in bytes)
+ * \returns A handle to the new array object
+ *
+ */
+
+pghandle pgNewArray(short* dat, unsigned short size);
+
+/*!
* \brief Evaluate a PicoGUI request packet
*
* \param reqtype A PGREQ_* constant indicating the packet type
Index: cli_c/include/picogui/constants.h
===================================================================
RCS file: /cvsroot/pgui/cli_c/include/picogui/constants.h,v
retrieving revision 1.48
diff -u -r1.48 constants.h
--- cli_c/include/picogui/constants.h 2001/05/31 07:32:52 1.48
+++ cli_c/include/picogui/constants.h 2001/06/06 18:43:39
@@ -222,6 +222,7 @@
#define PG_TYPE_STRING 4 //!< Created by pgNewString()
#define PG_TYPE_THEME 5 //!< Created by pgLoadTheme()
#define PG_TYPE_FILLSTYLE 6 //!< Used internally to store a theme's
fillstyles
+#define PG_TYPE_ARRAY 7 //!< Created by pgNewArray()
//! \}
@@ -536,6 +537,7 @@
#define PG_GROP_LINE 0x50
#define PG_GROP_ELLIPSE 0x60
#define PG_GROP_FELLIPSE 0x70
+#define PG_GROP_FPOLYGON 0x90
#define PG_GROP_TEXT 0x04 //!< Param: string
#define PG_GROP_BITMAP 0x14 //!< Param: bitmap
#define PG_GROP_TILEBITMAP 0x24 //!< Param: bitmap
Index: cli_c/include/picogui/network.h
===================================================================
RCS file: /cvsroot/pgui/cli_c/include/picogui/network.h,v
retrieving revision 1.30
diff -u -r1.30 network.h
--- cli_c/include/picogui/network.h 2001/05/16 04:22:56 1.30
+++ cli_c/include/picogui/network.h 2001/06/06 18:43:39
@@ -127,8 +127,9 @@
#define PGREQ_MKMENU 30 /* Creates a simple popup menu | handle[]
*/
#define PGREQ_WRITETO 31 /* Stream data to a widget | handle +
data */
#define PGREQ_UPDATEPART 32 /* Updates subtree defined by wgt | handle */
+#define PGREQ_MKARRAY 33 /* Makes a array, returns handle | data
*/
-#define PGREQ_UNDEF 33 /* types > this will be truncated. return
error */
+#define PGREQ_UNDEF 34 /* types > this will be truncated. return
error */
/******* Request data structures */
Index: cli_c/include/picogui/pgfx.h
===================================================================
RCS file: /cvsroot/pgui/cli_c/include/picogui/pgfx.h,v
retrieving revision 1.11
diff -u -r1.11 pgfx.h
--- cli_c/include/picogui/pgfx.h 2001/05/31 07:32:52 1.11
+++ cli_c/include/picogui/pgfx.h 2001/06/06 18:43:40
@@ -133,6 +133,8 @@
pgprim (*ellipse) (pgcontext c, pgu x, pgu y, pgu w, pgu h);
//! Implementation of pgFEllipse
pgprim (*fellipse) (pgcontext c, pgu x, pgu y, pgu w, pgu h);
+ //! Implementation of pgFPolygon
+ pgprim (*fpolygon) (pgcontext c, pghandle array);
//! Implementation of pgText
pgprim (*text) (pgcontext c, pgu x, pgu y, pghandle string);
//! Implementation of pgBitmap
@@ -187,6 +189,8 @@
inline pgprim pgEllipse(pgcontext c,pgu x,pgu y,pgu w,pgu h);
//! Draw a filled ellipse in the current color
inline pgprim pgFEllipse(pgcontext c,pgu x,pgu y,pgu w,pgu h);
+//! Draw a filled polygon in the current color
+inline pgprim pgFPolygon(pgcontext c, pghandle array);
/*!
* \brief Draw a string in the current color, font, and angle
*
Index: cli_c/src/api.c
===================================================================
RCS file: /cvsroot/pgui/cli_c/src/api.c,v
retrieving revision 1.9
diff -u -r1.9 api.c
--- cli_c/src/api.c 2001/05/04 23:26:55 1.9
+++ cli_c/src/api.c 2001/06/06 18:43:40
@@ -464,6 +464,12 @@
return _pg_return.e.retdata;
}
+pghandle pgNewArray(short* dat, unsigned short size) {
+ _pg_add_request(PGREQ_MKARRAY,(void *) dat, size);
+ pgFlushRequests();
+ return _pg_return.e.retdata;
+}
+
pghandle pgEvalRequest(short reqtype, void *data, unsigned long datasize) {
_pg_add_request(reqtype,data,datasize);
pgFlushRequests();
Index: cli_c/src/pgfx.c
===================================================================
RCS file: /cvsroot/pgui/cli_c/src/pgfx.c,v
retrieving revision 1.5
diff -u -r1.5 pgfx.c
--- cli_c/src/pgfx.c 2001/05/31 07:32:52 1.5
+++ cli_c/src/pgfx.c 2001/06/06 18:43:41
@@ -65,6 +65,9 @@
inline pgprim pgFEllipse(pgcontext c,pgu x,pgu y,pgu w,pgu h) {
return (*(c)->lib->fellipse)(c,x,y,w,h);
}
+inline pgprim pgFPolygon(pgcontext c, pghandle array) {
+ return (*(c)->lib->fpolygon)(c,array);
+}
inline pgprim pgText(pgcontext c,pgu x,pgu y,pghandle string) {
return (*(c)->lib->text)(c,x,y,string);
}
Index: cli_c/src/pgfx_canvas.c
===================================================================
RCS file: /cvsroot/pgui/cli_c/src/pgfx_canvas.c,v
retrieving revision 1.8
diff -u -r1.8 pgfx_canvas.c
--- cli_c/src/pgfx_canvas.c 2001/05/31 07:32:52 1.8
+++ cli_c/src/pgfx_canvas.c 2001/06/06 18:43:41
@@ -68,7 +68,11 @@
pgprim _pgfxcanvas_fellipse(pgcontext c, pgu x, pgu y, pgu w, pgu h) {
pgWriteCmd(c->device,PGCANVAS_GROP,5,PG_GROP_FELLIPSE,x,y,w,h);
return 0;
-}
+}
+
+pgprim _pgfxcanvas_fpolygon(pgcontext c, pghandle array) {
+ pgWriteCmd(c->device,PGCANVAS_GROP,6,PG_GROP_FPOLYGON,1,1,1,1,array);
+}
pgprim _pgfxcanvas_text(pgcontext c, pgu x, pgu y, pghandle string) {
pgWriteCmd(c->device,PGCANVAS_GROP,6,PG_GROP_TEXT,x,y,1,1,string);
@@ -151,7 +155,8 @@
l.slab = _pgfxcanvas_slab;
l.bar = _pgfxcanvas_bar;
l.ellipse = _pgfxcanvas_ellipse;
- l.fellipse = _pgfxcanvas_fellipse;
+ l.fellipse = _pgfxcanvas_fellipse;
+ l.fpolygon = _pgfxcanvas_fpolygon;
l.text = _pgfxcanvas_text;
l.bitmap = _pgfxcanvas_bitmap;
l.tilebitmap = _pgfxcanvas_tilebitmap;
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/pgui-devel