On Fri, 17 Nov 2000, Christoph Egger wrote:
> > At a quick glance the code looks completely bogus, I'll have a look at
> > it this weekend. The extension-segfault problems are the major reason
> > why I said the extension system should be re-designed a while ago.
>
> I am just trying to get the X-target working. XMI_X_getapi() is called for some
> days. But XMI_X_setmode() not. Jon said, that this _have_ to happen to
> replace the drawing functions with the ones of the X-target.
The libxmi has now a working X-target, even the output of the accelerated
functions is a bit different in comparison to the default one. I can't
describe that in words... you have to run the libxmi-demo.
It currenty accel's solid filled polygons and solid filled arcs. I know, that
this isn't much, but IHMO it is more important that it works!
I also know, that not everything is done in the right way in it (i.e. hooking
the x-target-functions in XMI_X_getapi()), but this is necessary to work around
stupid the design bug, I described in my last mail.
Solving this bug will make work the ggiSetMode() too, after xmiAttach() is
called.
I attached the patch (it is against the latest cvs-snapshot), so that you,
Marcus, can get in sync with my newest hack.
BTW: Anyone here to merge it in? Jon, what about you?
> I solved that by changing a demo of libxmi: I moved xmiAttach(), so
> that ggiSetMode() is called _after_ xmiAttach(). But then I got segfaults. Jon
> said to me, that this is the wrong way. So I redid this.
>
> Just a few minutes ago, I got the first success:
>
> I hooked the XMI_X_fillpolygon() in XMI_X_getapi(). XMI_X_fillpolygon() is now
> called instead of the stubs one. Unfortunetly, it results in an X-error:
>
> ---------------------------------------------------------------------------
> X error of failed request: BadDrawable (invalid Pixmap or Window parameter)
> Major opcode of failed request: 69 (X_FillPoly)
> Resource id in failed request: 0x1
> Serial number of failed request: 227
> Current serial number in output stream: 228
> ---------------------------------------------------------------------------
>
> I think, that this is caused by an wrong argument.
This one is fixed now. I assumed that the "Drawable" field was of boolean. :)
Design bug description:
> BTW: I also found an (design) bug: Both the stubs code and the x-target-code
> uses it's own private data-field allocated with malloc(). The pointer returned
> by malloc() is stored in LIBGGI_XMIEXT(vis)->priv.
>
> In other words: Both the default-stubs-target and the x-target overwrite
> themself causing memory-leaks...
CU,
Christoph Egger
E-Mail: [EMAIL PROTECTED]
diff -uNr 20001115/degas/lib/libxmi/default/stubs/init.c
degas/lib/libxmi/default/stubs/init.c
--- 20001115/degas/lib/libxmi/default/stubs/init.c Wed Nov 8 07:09:27 2000
+++ degas/lib/libxmi/default/stubs/init.c Fri Nov 17 20:18:40 2000
@@ -17,7 +17,7 @@
xmipriv *priv = LIBGGI_XMIEXT(vis);
- XMIDPRINT_CORE("LIBXMI: GGIopen(%p, %p, %s, %p, %p) called for stubs
sublib\n",
+ XMIDPRINT_CORE("GGIopen(%p, %p, %s, %p, %p) called for stubs sublib\n",
vis, dlh, args ? args : "(NULL)", argptr, dlret);
STUBSXMI_PRIV(vis) = malloc(sizeof(struct stubsxmi_priv));
@@ -55,9 +55,8 @@
priv->fillpolygon = XMI_stubs_fillpolygon;
priv->fillarcs = XMI_stubs_fillarcs;
- XMIDPRINT("default-stubs: GGIopen success.\n");
-
- *dlret = GGI_DL_EXTENSION;
+
+ *dlret = (GGI_DL_EXTENSION | GGI_DL_OPDISPLAY);
return 0;
}
@@ -68,10 +67,8 @@
#if 0
/* FIXME: the access to STUBSXMI_PRIV(vis) segfaults */
- if (STUBSXMI_PRIV(vis) != NULL) {
- free(STUBSXMI_PRIV(vis));
- STUBSXMI_PRIV(vis) = NULL;
- }
+ free(STUBSXMI_PRIV(vis));
+ STUBSXMI_PRIV(vis) = NULL;
#endif
return 0;
diff -uNr 20001115/degas/lib/libxmi/display/X/funcs.c
degas/lib/libxmi/display/X/funcs.c
--- 20001115/degas/lib/libxmi/display/X/funcs.c Sun Nov 12 22:01:46 2000
+++ degas/lib/libxmi/display/X/funcs.c Fri Nov 17 20:17:18 2000
@@ -1,6 +1,27 @@
/*
******************************************************************************
+ X-Target library for libXMI.
+
+ Copyright (C) 2000 Christoph Egger [[EMAIL PROTECTED]]
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
******************************************************************************
*/
@@ -14,10 +35,6 @@
#include "xmi_debug.h"
-#define FALSE 0
-#define TRUE !FALSE
-
-
/* _All_ non-local (ie not declared 'static') functions and variables _must_
be prefixed with the extension name, and for sublibs also with a unique
sublib identifier. This is to keep the namespace clean on systems where
@@ -25,27 +42,32 @@
*/
-miGC *XMI_X_newgc(ggi_visual_t vis, int npixels, const miPixel *pixels)
-{
- XMIDPRINT_CORE("XMI_X_new_gc(%p, %d, %p) called\n", vis, npixels, pixels);
-
- return NULL;
-}
-
void XMI_X_fillpolygon(ggi_visual_t vis, miPaintedSet *paintedSet,
const miGC *pGC, miPolygonShape shape,
miCoordMode mode, int npts, const miPoint *pPts)
{
ggi_xwin_common *priv;
- XPoint *points;
+ XPoint *points = NULL;
+ ggi_pixel col = 0;
+ int i;
- XMIDPRINT_DRAW("XMI_X_fillpolygon() called\n");
+ XMIDPRINT_CORE("X: XMI_X_fillpolygon() called\n");
priv = LIBGGI_PRIVATE(vis);
- points = (XPoint *)pPts;
+ points = malloc(sizeof(XPoint) * npts);
+
+
+ for (i = 0; i < npts; i++) {
+ points[i].x = (short)pPts[i].x;
+ points[i].y = (short)pPts[i].y;
+ }
+
+ if (pGC->numPixels > 0) {
+ col = pGC->pixels[0];
+ }
switch (shape) {
@@ -59,15 +81,18 @@
}
+ XSetForeground(priv->x.display, priv->x.gc, col);
XFillPolygon(priv->x.display,
- TRUE, /* drawable */
+ priv->window, /* drawable */
priv->x.gc,
points, /* the array of points */
npts, /* number of points in the array */
shape,
mode);
- XLIB_DOSYNC(vis);
+ free(points);
+
+ ggiFlush(vis);
return;
}
@@ -76,19 +101,25 @@
void XMI_X_fillarc(ggi_visual_t vis, miPaintedSet *paintedSet, const miGC *pGC, const
miArc *parc)
{
ggi_xwin_common *priv;
-
- XMIDPRINT_DRAW("XMI_X_fillarc() called\n");
+ ggi_pixel col = 0;
priv = LIBGGI_PRIVATE(vis);
+
+ if (pGC->numPixels > 0) {
+ col = pGC->pixels[0];
+ }
+
+
+ XSetForeground(priv->x.display, priv->x.gc, col);
XFillArc(priv->x.display,
- TRUE, /* drawable */
+ priv->window, /* drawable */
priv->x.gc,
parc->x, parc->y,
parc->width, parc->height,
parc->angle1, parc->angle2);
- XLIB_DOSYNC(vis);
+ ggiFlush(vis);
return;
}
@@ -98,13 +129,11 @@
{
int i;
- XMIDPRINT_DRAW("XMI_X_fillarcs() called\n");
+ XMIDPRINT_CORE("XMI_X_fillarcs() called\n");
for (i = 0; i < narcs; i++) {
XMI_X_fillarc(vis, paintedSet, pGC, &parcs[i]);
- }
+ }
return;
}
-
-
diff -uNr 20001115/degas/lib/libxmi/display/X/init.c degas/lib/libxmi/display/X/init.c
--- 20001115/degas/lib/libxmi/display/X/init.c Sun Nov 12 22:01:46 2000
+++ degas/lib/libxmi/display/X/init.c Fri Nov 17 20:18:06 2000
@@ -1,6 +1,25 @@
/*
******************************************************************************
+ Copyright (C) 2000 Christoph Egger [[EMAIL PROTECTED]]
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
******************************************************************************
*/
@@ -29,9 +48,6 @@
return GGI_ENOMEM;
}
-#if 0
- XXMI_PRIV(vis)->newgc = XMI_X_newgc;
-#endif
/* used by XMI_X_setmode */
XXMI_PRIV(vis)->setmode = vis->opdisplay->setmode;
XXMI_PRIV(vis)->getapi = vis->opdisplay->getapi;
@@ -40,7 +56,7 @@
vis->opdisplay->getapi = XMI_X_getapi;
- *dlret = GGI_DL_OPDISPLAY;
+ *dlret = (GGI_DL_EXTENSION | GGI_DL_OPDISPLAY);
return 0;
}
@@ -52,10 +68,8 @@
#if 0
/* FIXME: the access to XXMI_PRIV(vis) segfaults */
- if (XXMI_PRIV(vis) != NULL) {
- free(XXMI_PRIV(vis));
- XXMI_PRIV(vis) = NULL;
- }
+ free(XXMI_PRIV(vis));
+ XXMI_PRIV(vis) = NULL;
#endif
return 0;
diff -uNr 20001115/degas/lib/libxmi/display/X/mode.inc
degas/lib/libxmi/display/X/mode.inc
--- 20001115/degas/lib/libxmi/display/X/mode.inc Wed Nov 15 15:25:50 2000
+++ degas/lib/libxmi/display/X/mode.inc Fri Nov 17 20:31:47 2000
@@ -36,10 +36,36 @@
int XMI_X_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
{
+ xmipriv *priv = LIBGGI_XMIEXT(vis);
+ int rc;
- XMIDPRINT_CORE("XMI_X_getapi() is called\n");
+ XMIDPRINT_CORE("XMI_X_getapi(%p, %i, %s, %s) is called\n",
+ vis, num, apiname, arguments);
+ /* Call the native getapi()
+ *
+ * Note: That if-statement is necessary to avoid an segfault.
+ * XXMI_PRIV(vis) is overwritten by GGIopen() in the
+ * default-stubs, which shouldn't be. The native one
+ * has to be called to reload some other libraries
+ * i.e. generic-linear-%d inside of libggi.
+ */
+ if (XXMI_PRIV(vis)->getapi != NULL) {
+ rc = XXMI_PRIV(vis)->getapi(vis, num, apiname, arguments);
+ if (rc != 0) {
+ return rc;
+ }
+ }
+
+ /* I know, that this shouldn't be here, but
+ * a (design) bug in the extension makes this necessary
+ * to replace the default-stubs functions with our own...
+ */
+
+ priv->fillpolygon = XMI_X_fillpolygon;
+ priv->fillarcs = XMI_X_fillarcs;
+
switch(num) {
case 0:
#ifdef GGI_X_TARGET
@@ -71,9 +97,11 @@
static int _GGIdomode(ggi_visual *vis)
{
xmipriv *priv = LIBGGI_XMIEXT(vis);
- int err,id;
- char sugname[256],args[256];
-
+ int err, id;
+ char sugname[GGI_MAX_APILEN], args[GGI_MAX_APILEN];
+
+ XMIDPRINT_CORE("_GGIdomode(%p) is called\n", vis);
+
_ggiZapMode(vis, 0);
for (id=1; 0 == XMI_X_getapi(vis,id,sugname,args); id++) {
@@ -100,7 +128,6 @@
priv->fillpolygon = XMI_X_fillpolygon;
priv->fillarcs = XMI_X_fillarcs;
-
ggiIndicateChange(vis, GGI_CHG_APILIST);
return 0;
@@ -115,10 +142,22 @@
XMIDPRINT_CORE("XMI_X_setmode(%p,%p) is called\n", vis, tm);
- /* Call the native setmode() */
- rc = XXMI_PRIV(vis)->setmode(vis, tm);
- if (rc != 0) {
- return rc;
+ /* Call the native setmode()
+ *
+ * Note: That if-statement is necessary to avoid an segfault.
+ * XXMI_PRIV(vis) is overwritten by GGIopen() in the
+ * default-stubs.
+ *
+ * Note: ggiSetMode() doesn't work at all. The pointer to the native
+ * setmode()-function is saved in XXMI_PRIV(vis)->setmode, but
+ * because of the (design) bug it is destroyed and set back to
+ * NULL by something...
+ */
+ if (XXMI_PRIV(vis)->setmode != NULL) {
+ rc = XXMI_PRIV(vis)->setmode(vis, tm);
+ if (rc != 0) {
+ return rc;
+ }
}
rc = _GGIdomode(vis);
diff -uNr 20001115/degas/lib/libxmi/display/X/xxmi.h degas/lib/libxmi/display/X/xxmi.h
--- 20001115/degas/lib/libxmi/display/X/xxmi.h Sun Nov 12 22:01:46 2000
+++ degas/lib/libxmi/display/X/xxmi.h Wed Nov 15 15:37:51 2000
@@ -3,6 +3,26 @@
XMI implementation for X target - header.
+ Copyright (C) 2000 Christoph Egger [[EMAIL PROTECTED]]
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
******************************************************************************
*/
diff -uNr 20001115/degas/lib/libxmi/xmi/init.c degas/lib/libxmi/xmi/init.c
--- 20001115/degas/lib/libxmi/xmi/init.c Sun Nov 12 22:01:46 2000
+++ degas/lib/libxmi/xmi/init.c Thu Nov 16 17:28:35 2000
@@ -3,8 +3,26 @@
XMI extension initialization.
- Author: Jon Taylor [[EMAIL PROTECTED]]
-
+ Copyright (C) 2000 Jon Taylor [[EMAIL PROTECTED]]
+ Copyright (C) 2000 Christoph Egger [[EMAIL PROTECTED]]
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
******************************************************************************
*/
@@ -101,14 +119,10 @@
fname = ggMatchConfig(_xmiConfigHandle, api, NULL);
if (fname == NULL) {
- XMIDPRINT_LIBS(" Not available\n");
-
/* No special implementation for this sublib
*/
continue;
}
lib = ggiExtensionLoadDL(vis, fname, args, NULL,
GGI_SYMNAME_PREFIX);
-
- XMIDPRINT_LIBS(" Success\n");
}
}
break;