From dbc45b887840b0b2a02df8269b2d963396b97bc0 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 26 Sep 2002 10:06:45 +0000 Subject: * (ZnGetBitmap, ZnGetImage): Passage syst�matique par Tk_GetUid avant d'utiliser les noms de bitmap/image. * Corrections assurant une compilation correcte sans GLX. --- generic/Image.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'generic/Image.c') diff --git a/generic/Image.c b/generic/Image.c index dc314ee..666baf9 100644 --- a/generic/Image.c +++ b/generic/Image.c @@ -61,7 +61,9 @@ typedef struct _ImageStruct { Display *dpy; } x; struct { +#ifdef GLX GLuint texobj; +#endif struct _WidgetInfo *wi; } gl; } i; @@ -384,11 +386,11 @@ GetImageInstance(WidgetInfo *wi, image->refcount = 1; image->for_gl = for_gl; if (image->for_gl) { -#ifdef GLX image->i.gl.wi = wi; +#ifdef GLX image->i.gl.texobj = 0; - } #endif + } else { image->i.x.dpy = wi->dpy; image->i.x.pixmap = XCreatePixmap(wi->dpy, RootWindowOfScreen(wi->screen), @@ -432,6 +434,7 @@ ZnGetImage(WidgetInfo *wi, Tcl_InitHashTable(&images, TCL_STRING_KEYS); images_inited = 1; } + image_name = Tk_GetUid(image_name); entry = Tcl_FindHashEntry(&images, image_name); if (entry != NULL) { /*printf("Image %s déjà connue\n", image_name);*/ @@ -472,6 +475,10 @@ ZnGetImage(WidgetInfo *wi, } if (!bits->ipixels) { + /* + * First time use of the image, read in + * the bits and free the Tk image. + */ GatherImageBits(wi, tkimage, bits); Tk_FreeImage(tkimage); } @@ -503,12 +510,13 @@ ZnGetBitmap(WidgetInfo *wi, Tcl_InitHashTable(&images, TCL_STRING_KEYS); images_inited = 1; } + bitmap_name = Tk_GetUid(bitmap_name); entry = Tcl_FindHashEntry(&images, bitmap_name); if (entry != NULL) { bits = (ImageBits *) Tcl_GetHashValue(entry); } else { - pmap = Tk_GetBitmap(wi->interp, wi->win, Tk_GetUid(bitmap_name)); + pmap = Tk_GetBitmap(wi->interp, wi->win, bitmap_name); if (pmap == ZnUnspecifiedImage) { return ZnUnspecifiedImage; } @@ -567,18 +575,18 @@ ZnGetBitmap(WidgetInfo *wi, image->refcount = 1; image->for_gl = for_gl; if (image->for_gl) { -#ifdef GLX image->i.gl.wi = wi; +#ifdef GLX image->i.gl.texobj = 0; - } #endif + } else { image->i.x.dpy = wi->dpy; image->i.x.mask_pmap = None; /* * Need to get a pixmap that match this dpy. */ - image->i.x.pixmap = Tk_GetBitmap(wi->interp, wi->win, Tk_GetUid(bitmap_name)); + image->i.x.pixmap = Tk_GetBitmap(wi->interp, wi->win, bitmap_name); } image->next = bits->images; bits->images = image; @@ -638,9 +646,11 @@ ZnFreeImage(ZnImage image) prev->next = this->next; } if (this->for_gl) { +#ifdef GLX if (this->i.gl.texobj) { glDeleteTextures(1, &this->i.gl.texobj); } +#endif } else if (bits->ipixels) { /* @@ -666,9 +676,11 @@ ZnFreeImage(ZnImage image) */ if (bits->images == NULL) { /*printf("destruction complète de l'image %s\n", ZnNameOfImage(this));*/ +#ifdef GLX if (bits->t_bits) { ZnFree(bits->t_bits); } +#endif if (bits->mask) { XDestroyImage(bits->mask); } @@ -771,6 +783,7 @@ ZnImagePixmap(ZnImage image, Pixmap *mask_pmap) { if (((Image) image)->for_gl) { + printf("Bogus use of an image, it was created for GL and use in an X11 context\n"); return None; } if (mask_pmap) { -- cgit v1.1